From fc41a131ee5ace63bf95686fda90f9460d5f563c Mon Sep 17 00:00:00 2001 From: Gurunandan Rao Date: Wed, 23 Aug 2023 11:38:56 +0530 Subject: [PATCH 01/20] jpa standalone tck refactor. Signed-off-by: Gurunandan Rao --- jpa/pom.xml | 27 +- .../sun/ts/tests/jpa/common/PMClientBase.java | 2001 ++++++------- .../pluggability/util/LogFileProcessor.java | 11 +- .../ts/tests/jpa/common/schema30/Util.java | 93 +- .../ts/tests/jpa/core/EntityGraph/Client.java | 72 +- .../jpa/core/StoredProcedureQuery/Client.java | 2618 +---------------- .../core/annotations/access/field/Client.java | 1596 +--------- .../annotations/access/mappedsc/Client.java | 358 ++- .../annotations/access/property/Client.java | 954 ------ .../access/property/ClientIT1.java | 802 +++++ .../annotations/assocoverride/Client.java | 316 +- .../jpa/core/annotations/basic/Client.java | 1267 +------- .../annotations/collectiontable/Client.java | 20 +- .../jpa/core/annotations/convert/Client.java | 53 +- .../discriminatorValue/Client.java | 20 +- .../annotations/elementcollection/Client.java | 365 --- .../core/annotations/embeddable/Client.java | 21 +- .../embeddableMapValue/Client.java | 20 +- .../jpa/core/annotations/entity/Client.java | 29 +- .../tests/jpa/core/annotations/id/Client.java | 70 +- .../jpa/core/annotations/lob/Client.java | 22 +- .../jpa/core/annotations/mapkey/Client.java | 677 +---- .../core/annotations/mapkeyclass/Client.java | 22 +- .../core/annotations/mapkeycolumn/Client.java | 37 +- .../annotations/mapkeyenumerated/Client.java | 48 +- .../annotations/mapkeyjoincolumn/Client.java | 24 +- .../annotations/mapkeytemporal/Client.java | 49 +- .../jpa/core/annotations/mapsid/Client.java | 22 +- .../core/annotations/nativequery/Client.java | 63 +- .../core/annotations/onexmanyuni/Client.java | 21 +- .../jpa/core/annotations/orderby/Client.java | 884 ------ .../core/annotations/ordercolumn/Client.java | 37 +- .../annotations/tableGenerator/Client.java | 54 +- .../jpa/core/annotations/temporal/Client.java | 41 +- .../jpa/core/annotations/version/Client.java | 77 +- .../sun/ts/tests/jpa/core/basic/Client.java | 26 +- .../jpa/core/cache/basicTests/Client.java | 30 +- .../common/EntityCallbackClientBase.java | 10 +- .../jpa/core/callback/inheritance/Client.java | 43 +- .../jpa/core/callback/listener/Client.java | 68 +- .../callback/listeneroverride/Client.java | 68 +- .../jpa/core/callback/method/Client.java | 69 +- .../core/callback/methodoverride/Client.java | 70 +- .../tests/jpa/core/callback/xml/Client.java | 76 +- .../criteriaapi/CriteriaBuilder/Client.java | 482 ++- .../criteriaapi/CriteriaDelete/Client.java | 32 +- .../criteriaapi/CriteriaQuery/Client.java | 126 +- .../criteriaapi/CriteriaUpdate/Client.java | 46 +- .../jpa/core/criteriaapi/From/Client.java | 99 +- .../jpa/core/criteriaapi/Join/Client.java | 118 +- .../jpa/core/criteriaapi/Root/Client.java | 59 +- .../criteriaapi/metamodelquery/Client.java | 314 +- .../jpa/core/criteriaapi/misc/Client.java | 75 +- .../core/criteriaapi/parameter/Client.java | 26 +- .../jpa/core/criteriaapi/strquery/Client.java | 271 +- .../tests/jpa/core/derivedid/ex1a/Client.java | 15 +- .../tests/jpa/core/derivedid/ex1b/Client.java | 15 +- .../tests/jpa/core/derivedid/ex2a/Client.java | 15 +- .../tests/jpa/core/derivedid/ex2b/Client.java | 15 +- .../tests/jpa/core/derivedid/ex3a/Client.java | 15 +- .../tests/jpa/core/derivedid/ex3b/Client.java | 15 +- .../tests/jpa/core/derivedid/ex4a/Client.java | 15 +- .../tests/jpa/core/derivedid/ex4b/Client.java | 15 +- .../tests/jpa/core/derivedid/ex5a/Client.java | 15 +- .../tests/jpa/core/derivedid/ex5b/Client.java | 15 +- .../tests/jpa/core/derivedid/ex6a/Client.java | 15 +- .../tests/jpa/core/derivedid/ex6b/Client.java | 15 +- .../tests/jpa/core/entityManager/Client.java | 161 +- .../tests/jpa/core/entityManager2/Client.java | 135 +- .../jpa/core/entityManagerFactory/Client.java | 61 +- .../Client.java | 18 +- .../jpa/core/entityTransaction/Client.java | 34 +- .../jpa/core/entitytest/apitests/Client.java | 55 +- .../core/entitytest/bigdecimal/Client.java | 23 +- .../core/entitytest/biginteger/Client.java | 23 +- .../cascadeall/manyXmany/Client.java | 35 +- .../cascadeall/manyXone/Client.java | 34 +- .../cascadeall/oneXmany/Client.java | 35 +- .../entitytest/cascadeall/oneXone/Client.java | 34 +- .../core/entitytest/detach/basic/Client.java | 18 +- .../entitytest/detach/manyXmany/Client.java | 15 +- .../entitytest/detach/manyXone/Client.java | 16 +- .../entitytest/detach/oneXmany/Client.java | 17 +- .../entitytest/detach/oneXone/Client.java | 18 +- .../core/entitytest/persist/basic/Client.java | 24 +- .../entitytest/persist/manyXmany/Client.java | 35 +- .../entitytest/persist/manyXone/Client.java | 34 +- .../entitytest/persist/oneXmany/Client.java | 43 +- .../persist/oneXmanyFetchEager/Client.java | 45 +- .../entitytest/persist/oneXone/Client.java | 38 +- .../core/entitytest/remove/basic/Client.java | 26 +- .../entitytest/remove/oneXmany/Client.java | 27 +- .../entitytest/remove/oneXone/Client.java | 32 +- .../sun/ts/tests/jpa/core/enums/Client.java | 119 +- .../ts/tests/jpa/core/exceptions/Client.java | 48 +- .../inheritance/abstractentity/Client.java | 19 +- .../mappedsc/annotation/Client.java | 17 +- .../mappedsc/descriptors/Client.java | 17 +- .../core/inheritance/nonentity/Client.java | 19 +- .../jpa/core/lock/entitymanager/Client.java | 31 +- .../ts/tests/jpa/core/lock/query/Client.java | 29 +- .../core/metamodelapi/attribute/Client.java | 28 +- .../core/metamodelapi/basictype/Client.java | 18 +- .../core/metamodelapi/bindable/Client.java | 17 +- .../collectionattribute/Client.java | 18 +- .../metamodelapi/embeddabletype/Client.java | 115 +- .../core/metamodelapi/entitytype/Client.java | 47 +- .../metamodelapi/identifiabletype/Client.java | 141 +- .../metamodelapi/listattribute/Client.java | 24 +- .../core/metamodelapi/managedtype/Client.java | 117 +- .../metamodelapi/mapattribute/Client.java | 22 +- .../mappedsuperclasstype/Client.java | 41 +- .../core/metamodelapi/metamodel/Client.java | 25 +- .../metamodelapi/pluralattribute/Client.java | 36 +- .../metamodelapi/setattribute/Client.java | 20 +- .../singularattribute/Client.java | 40 +- .../jpa/core/metamodelapi/type/Client.java | 20 +- .../jpa/core/nestedembedding/Client.java | 19 +- .../override/attributeoverride/Client.java | 15 +- .../override/callbacklistener/Client.java | 26 +- .../jpa/core/override/embeddable/Client.java | 30 +- .../jpa/core/override/entity/Client.java | 23 +- .../core/override/entitylistener/Client.java | 28 +- .../jpa/core/override/joincolumn/Client.java | 21 +- .../jpa/core/override/manytomany/Client.java | 15 +- .../jpa/core/override/mapkey/Client.java | 27 +- .../override/nocallbacklistener/Client.java | 19 +- .../tests/jpa/core/override/table/Client.java | 14 +- .../jpa/core/persistenceUtil/Client.java | 16 +- .../jpa/core/persistenceUtilUtil/Client.java | 20 +- .../tests/jpa/core/query/apitests/Client.java | 152 +- .../jpa/core/query/flushmode/Client.java | 29 +- .../tests/jpa/core/query/language/Client.java | 297 +- .../jpa/core/query/parameter/Client.java | 44 +- .../core/relationship/annotations/Client.java | 31 +- .../relationship/bidirmanyxmany/Client.java | 15 +- .../relationship/bidirmanyxone/Client.java | 15 +- .../relationship/bidironexmany/Client.java | 15 +- .../relationship/bidironexone/Client.java | 16 +- .../core/relationship/defaults/Client.java | 29 +- .../core/relationship/descriptors/Client.java | 29 +- .../relationship/unimanyxmany/Client.java | 15 +- .../core/relationship/unimanyxone/Client.java | 16 +- .../core/relationship/unionexmany/Client.java | 15 +- .../core/relationship/unionexone/Client.java | 16 +- .../ts/tests/jpa/core/types/auto/Client.java | 26 +- .../ts/tests/jpa/core/types/field/Client.java | 55 +- .../jpa/core/types/generator/Client.java | 780 +---- .../types/primarykey/compound/Client.java | 31 +- .../tests/jpa/core/types/property/Client.java | 81 +- .../ts/tests/jpa/core/versioning/Client.java | 26 +- .../ts/tests/jpa/ee/entityManager/Client.java | 31 +- .../jpa/ee/entityManagerFactory/Client.java | 31 +- .../appclient/annotation/Client.java | 29 +- .../appclient/descriptor/Client.java | 31 +- .../ee/packaging/ejb/descriptor/Client.java | 46 +- .../jpa/ee/packaging/ejb/exclude/Client.java | 32 +- .../packaging/ejb/resource_local/Client.java | 82 +- .../ee/packaging/ejb/standalone/Client.java | 25 +- .../ts/tests/jpa/ee/packaging/jar/Client.java | 22 +- .../jpa/ee/packaging/web/scope/Client.java | 28 +- .../ee/packaging/web/standalone/Client.java | 28 +- .../ee/pluggability/contracts/jta/Client.java | 76 +- .../contracts/resource_local/Client.java | 79 +- .../tests/jpa/ee/propagation/am/Client.java | 44 +- .../ee/propagation/cm/extended/Client.java | 53 +- .../jpa/ee/propagation/cm/jta/Client.java | 55 +- .../ts/tests/jpa/jpa22/datetime/Client.java | 27 +- .../generators/tablegenerators/Client.java | 24 +- .../tests/jpa/jpa22/query/stream/Client.java | 41 +- .../jpa22/repeatable/attroverride/Client.java | 30 +- .../jpa/jpa22/repeatable/convert/Client.java | 21 +- .../jpa22/repeatable/joincolumn/Client.java | 22 +- .../repeatable/mapkeyjoincolumn/Client.java | 24 +- .../repeatable/namedentitygraph/Client.java | 40 +- .../repeatable/namednativequery/Client.java | 23 +- .../namedstoredprocedurequery/Client.java | 42 +- .../generators/sequencegenerators/Client.java | 29 +- .../se/repeatable/secondarytable/Client.java | 23 +- .../ts/tests/jpa/se/cache/inherit/Client.java | 26 +- .../ts/tests/jpa/se/cache/xml/all/Client.java | 41 +- .../se/cache/xml/disableselective/Client.java | 23 +- .../se/cache/xml/enableselective/Client.java | 24 +- .../tests/jpa/se/cache/xml/none/Client.java | 21 +- .../ts/tests/jpa/se/descriptor/Client.java | 22 +- .../ts/tests/jpa/se/entityManager/Client.java | 332 ++- .../jpa/se/entityManagerFactory/Client.java | 47 +- .../contracts/resource_local/Client.java | 64 +- .../tests/jpa/se/resource_local/Client.java | 96 +- .../discriminatorColumn/Client.java | 27 +- .../annotations/enumerated/Client.java | 28 +- .../annotations/id/Client.java | 28 +- .../annotations/index/Client.java | 28 +- .../annotations/joinTable/Client.java | 28 +- .../annotations/orderColumn/Client.java | 28 +- .../annotations/secondaryTable/Client.java | 28 +- .../annotations/sequenceGenerator/Client.java | 30 +- .../annotations/table/Client.java | 29 +- .../annotations/tableGenerator/Client.java | 28 +- .../annotations/temporal/Client.java | 29 +- .../annotations/uniqueConstraint/Client.java | 29 +- .../annotations/version/Client.java | 27 +- .../se/schemaGeneration/scripts/Client.java | 63 +- 203 files changed, 6476 insertions(+), 14837 deletions(-) delete mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/Client.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT1.java delete mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/Client.java delete mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/Client.java diff --git a/jpa/pom.xml b/jpa/pom.xml index 9bece7a131..2fa22ef99d 100644 --- a/jpa/pom.xml +++ b/jpa/pom.xml @@ -32,11 +32,15 @@ JPA JPA + + 1.7.0.Alpha14 + 5.9.1 + 11 + 11 + ${project.version} + + - - javatest - javatest - ${project.groupId} libutil @@ -57,6 +61,21 @@ jakarta.ejb jakarta.ejb-api + + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} + + + org.jboss.arquillian.junit5 + arquillian-junit5-container + ${arquillian.junit} + + + org.jboss.arquillian.junit5 + arquillian-junit5-core + ${arquillian.junit} + diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/common/PMClientBase.java b/jpa/src/main/java/com/sun/ts/tests/jpa/common/PMClientBase.java index 91ba3e727f..effb6a44cf 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/common/PMClientBase.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/common/PMClientBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -38,7 +38,6 @@ import java.util.Set; import java.util.StringTokenizer; -import com.sun.ts.lib.harness.ServiceEETest; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManager; import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManagerFactory; @@ -50,1056 +49,976 @@ import jakarta.persistence.Persistence; import jakarta.persistence.PersistenceException; -abstract public class PMClientBase extends ServiceEETest - implements UseEntityManager, UseEntityManagerFactory, java.io.Serializable { +abstract public class PMClientBase implements UseEntityManager, UseEntityManagerFactory, java.io.Serializable { - protected Properties myProps; + protected Properties myProps; - transient private EntityManager em; + transient private EntityManager em; - transient private EntityTransaction et; + transient private EntityTransaction et; - transient private boolean inContainer; + transient private boolean inContainer; - // The following are properties specific to standalone TCK, - // not used when running tests in JakartaEE environment - transient private EntityManagerFactory emf; + // The following are properties specific to standalone TCK, + // not used when running tests in JakartaEE environment + transient private EntityManagerFactory emf; - EntityManagerFactory jakartaEEemf; + EntityManagerFactory jakartaEEemf; - public boolean cachingSupported = true; + public boolean cachingSupported = true; - transient public static final String PROVIDER_PROP = "jakarta.persistence.provider"; + transient public static final String PROVIDER_PROP = "jakarta.persistence.provider"; - transient public static final String TRANSACTION_TYPE_PROP = "jakarta.persistence.transactionType"; + transient public static final String TRANSACTION_TYPE_PROP = "jakarta.persistence.transactionType"; - transient public static final String JTA_DATASOURCE_PROP = "jakarta.persistence.jtaDataSource"; + transient public static final String JTA_DATASOURCE_PROP = "jakarta.persistence.jtaDataSource"; - transient public static final String NON_JTA_DATASOURCE_PROP = "jakarta.persistence.nonJtaDataSource"; + transient public static final String NON_JTA_DATASOURCE_PROP = "jakarta.persistence.nonJtaDataSource"; - transient public static final String RESOURCE_LOCAL = "RESOURCE_LOCAL"; + transient public static final String RESOURCE_LOCAL = "RESOURCE_LOCAL"; - /** - * Name of a property defined in ts.jte, to denote whether tests run in JakartaEE - * or Java SE mode. - */ - transient public static final String MODE_PROP = "platform.mode"; - - /** - * Denotes that tests are running in Java EE mode. This is the only valid - * non-null value for this property. - */ - transient public static final String JAVAEE_MODE = "jakartaEE"; - - /** - * Denotes that tests are running in Java SE mode. This is the only valid - * non-null value for this property. - */ - transient public static final String STANDALONE_MODE = "standalone"; - - /** - * Name of a property defined in ts.jte, to specify the name of the - * persistence unit used in the testsuite. It must be consistent with the - * value in persistence.xml - */ - transient public static final String PERSISTENCE_UNIT_NAME_PROP = "persistence.unit.name"; - - transient public static final String SECOND_PERSISTENCE_UNIT_NAME_PROP = "persistence.unit.name.2"; - - /** - * Name of the property in ts.jte that specifies an absolute path to the - * properties file that contains properties for initializing - * EntityManagerFactory, including both standard and provider-specific - * properties. - */ - transient public static final String JAVAX_PERSISTENCE_PROVIDER = "jakarta.persistence.provider"; - - transient public static final String JAVAX_PERSISTENCE_JDBC_DRIVER = "jakarta.persistence.jdbc.driver"; - - transient public static final String JAVAX_PERSISTENCE_JDBC_URL = "jakarta.persistence.jdbc.url"; - - transient public static final String JAVAX_PERSISTENCE_JDBC_USER = "jakarta.persistence.jdbc.user"; - - transient public static final String JAVAX_PERSISTENCE_JDBC_PASSWORD = "jakarta.persistence.jdbc.password"; - - transient public static final String JPA_PROVIDER_IMPLEMENTATION_SPECIFIC_PROPERTIES = "jpa.provider.implementation.specific.properties"; - - transient public static final String PERSISTENCE_SECOND_LEVEL_CACHING_SUPPORTED = "persistence.second.level.caching.supported"; - - /** - * The current test mode. The only valid non-null value is "standalone". - */ - transient private String mode; - - /** - * Persistence unit name, as defined in ts.jte. - */ - private String persistenceUnitName; - - protected String secondPersistenceUnitName; - - protected PMClientBase() { - super(); - } - - protected void removeEntity(Object o) { - if (o != null) { - try { - getEntityManager().remove(o); - } catch (Exception e) { - TestUtil.logErr("removeEntity: Exception caught when removing entity: ", - e); - } - } - } - - public String getPersistenceUnitName() { - TestUtil.logTrace("getPersistenceUnitName() - Persistence Unit Name:" - + this.persistenceUnitName); - return this.persistenceUnitName; - } - - public String getSecondPersistenceUnitName() { - TestUtil.logTrace( - "getSecondPersistenceUnitName() - Second Persistence Unit Name:" - + this.secondPersistenceUnitName); - return secondPersistenceUnitName; - } - - /** - * If a subclass overrides this method, the overriding implementation must - * call super.setup() at the beginning. - */ - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("PMClientBase.setup"); - myProps = p; - mode = p.getProperty(MODE_PROP); - persistenceUnitName = p.getProperty(PERSISTENCE_UNIT_NAME_PROP); - TestUtil.logTrace("Persistence Unit Name =" + persistenceUnitName); - secondPersistenceUnitName = p - .getProperty(SECOND_PERSISTENCE_UNIT_NAME_PROP); - TestUtil - .logTrace("Second Persistence Unit Name =" + secondPersistenceUnitName); - if (JAVAEE_MODE.equalsIgnoreCase(mode)) { - TestUtil.logTrace(MODE_PROP + " is set to " + mode - + ", so tests are running in JakartaEE environment."); - } else if (STANDALONE_MODE.equalsIgnoreCase(mode)) { - TestUtil.logTrace(MODE_PROP + " is set to " + mode - + ", so tests are running in J2SE environment standalone mode." - + PERSISTENCE_UNIT_NAME_PROP + " is set to " + persistenceUnitName); - } else { - TestUtil.logMsg("WARNING: " + MODE_PROP + " is set to " + mode - + ", an invalid value."); - } - - cachingSupported = Boolean.parseBoolean( - p.getProperty(PERSISTENCE_SECOND_LEVEL_CACHING_SUPPORTED, "true")); - if (TestUtil.traceflag) { - displayProperties(p); - } - } - - public void displayProperties(Properties props) { - TestUtil.logMsg("Current properties:"); - - for (Object entry : props.keySet()) { - if (props.get(entry) instanceof String) { - TestUtil.logTrace( - "Key:" + (String) entry + ", value:[" + props.get(entry) + "]"); - } else { - TestUtil.logTrace("Key:" + (String) entry + ", value:" - + props.get(entry).getClass().getSimpleName()); - - } - } - } - - /** - * In JakartaEE environment, does nothing. In Java SE environment, closes the - * EntityManager if its open, and closes the EntityManagerFactory if its open. - * If a subclass overrides this method, the overriding implementation must - * call super.cleanup() at the end. Also, the cache cleared. - */ - public void cleanup() throws Exception { - closeEMAndEMF(); - } - - /* - * This method is inherited by clients and is used when no super.cleanup() - * call is needed - */ - public void cleanupNoSuper() throws Exception { - } - - /** - * In JakartaEE environment, does nothing. In Java SE environment, closes the - * EntityManager if its open, and closes the EntityManagerFactory if its open. - * Also, the cache cleared. - */ - public void closeEMAndEMF() throws Exception { - - try { - TestUtil.logTrace( - "Rolling back any existing transaction before closing EMF and EM if one exists."); - if (getEntityTransaction(false) != null - && getEntityTransaction(false).isActive()) { - TestUtil.logTrace("An active transaction was found, rolling it back."); - getEntityTransaction(false).rollback(); - } - } catch (Exception fe) { - TestUtil.logMsg("Unexpected exception rolling back TX:", fe); - } - - clearCache(); - - if (isStandAloneMode()) { - TestUtil.logTrace("Closing EM and EMF"); - if (getEntityManager(false) != null && getEntityManager(false).isOpen()) { - getEntityManager(false).close(); - } - - if (getEntityManagerFactory() != null - && getEntityManagerFactory().isOpen()) { - getEntityManagerFactory().close(); - } - } - } - - public void clearEMAndEMF() throws Exception { - closeEMAndEMF(); - clearEntityManager(); - clearEntityManagerFactory(); - } - - public void clearEntityManager() { - if (isStandAloneMode()) { - this.em = null; - } - } - - public void clearEntityManagerFactory() { - if (isStandAloneMode()) { - this.emf = null; - } - } - - public void clearCache() throws Exception { - - if (cachingSupported) { - if (getEntityManager() != null && getEntityManager().isOpen()) { - if (getEntityManager().getEntityManagerFactory() != null - && getEntityManager().getEntityManagerFactory().isOpen()) { - - // if the EntityManager is open, clear the context causing all - // managed entities to become detached - TestUtil.logTrace("Clearing context"); - getEntityManager().clear(); - - TestUtil.logTrace( - "Trying to clear cache via call to EMF.getCache().evictAll()."); - Cache cache = getEntityManager().getEntityManagerFactory().getCache(); - if (cache != null) { - cache.evictAll(); - TestUtil.logTrace("EMF.getCache().evictAll() was executed."); - } else { - TestUtil.logErr( - "Cache supported is true in ts.jte but getCache() is returning null"); - } - - } else { - TestUtil.logTrace( - "Clearing of cache did not occur because either EntityManagerFactory was null or closed"); - } - } else { - TestUtil.logTrace( - "Clearing of cache did not occur because either EntityManager was null or closed"); - } - } else { - TestUtil.logTrace( - "Clearing of cache did not occur because it is not supposed."); - } - } - - public void setEntityManager(jakarta.persistence.EntityManager em) { - this.em = em; - } - - public void setEntityManagerFactory(EntityManagerFactory emf) { - this.jakartaEEemf = emf; - } - - public EntityManager getEntityManager() { - // get exist entity manager and use the default persistence unit name - return getEntityManager(false); - } - - public EntityManager getEntityManager(boolean reInit) { - // If reInit=false then it will return existing EntityManager - // otherwise this returns new EntityManager - if (!reInit) { - if (this.em != null) { - TestUtil.logTrace("Using existing entity manager class:" - + em.getClass().getName() + " isOpen:" + em.isOpen()); - return this.em; - } - TestUtil.logTrace("getEntityManager: false was specified and EM is null"); - } - TestUtil.logTrace("Need to Initialize EntityManager"); - if (isStandAloneMode()) { - initEntityManager(persistenceUnitName, true); - TestUtil.logTrace("EntityManager class:" + em.getClass().getName() - + " isOpen:" + em.isOpen()); - return this.em; - } - throw new IllegalStateException( - "The test is running in JakartaEE environment, " - + "but PMClientBase.em has not been initialized from the vehicle component."); - } - - public EntityManagerFactory getEntityManagerFactory() { - if (isStandAloneMode()) { - if (emf != null) { - TestUtil.logTrace("EntityManagerFactory class:" - + emf.getClass().getName() + " isOpen:" + emf.isOpen()); - } - return emf; - } else { - if (jakartaEEemf != null) { - TestUtil.logTrace("EntityManagerFactory class:" - + jakartaEEemf.getClass().getName() + " isOpen:" + jakartaEEemf.isOpen()); - } - return jakartaEEemf; - } - } - - public void clearEntityTransaction() { - this.et = null; - } - - public void setEntityTransaction(EntityTransaction et) { - this.et = et; - } - - public EntityTransaction getEntityTransaction() { - if (this.et != null) { - TestUtil.logTrace("Transaction class:" + et.getClass().getName() - + " isActive():" + et.isActive()); - return this.et; - } - TestUtil.logTrace("Need to get Transaction"); - if (isStandAloneMode()) { - initEntityTransaction(); - if (et != null) { - TestUtil.logTrace("Transaction class:" + et.getClass().getName() - + " isActive():" + et.isActive()); - } - return this.et; - } - throw new IllegalStateException( - "The test is running in JakartaEE environment, " - + "but PMClientBase.et has not been initialized from the vehicle component."); - } - - public EntityTransaction getEntityTransaction(boolean reInit, - EntityManager em) { - // If reInit=false then it will return existing EntityTransaction - // otherwise this returns new EntityTransaction - if (!reInit) { - if (this.et != null) { - TestUtil.logTrace("Transaction class:" + et.getClass().getName() - + " isActive():" + et.isActive()); - return this.et; - } - } - if (isStandAloneMode()) { - initEntityTransaction(em); - if (et != null) { - TestUtil.logTrace("Transaction class:" + et.getClass().getName() - + " isActive():" + et.isActive()); - } - return this.et; - } - throw new IllegalStateException( - "The test is running in JakartaEE environment, " - + "but PMClientBase.et has not been initialized from the vehicle component."); - } - - public EntityTransaction getEntityTransaction(boolean reInit) { - // If reInit=false then it will return existing EntityTransaction - // otherwise this returns new EntityTransaction - if (!reInit) { - if (this.et != null) { - TestUtil.logTrace("Transaction class:" + et.getClass().getName() - + " isActive():" + et.isActive()); - return this.et; - } - } - if (isStandAloneMode()) { - initEntityTransaction(); - if (et != null) { - TestUtil.logTrace("Transaction class:" + et.getClass().getName() - + " isActive():" + et.isActive()); - } - return this.et; - } - throw new IllegalStateException( - "The test is running in JakartaEE environment, " - + "but PMClientBase.et has not been initialized from the vehicle component."); - } - - /** - * Creates EntityManager in JavaSE environment. In JakartaEE environment, - * EntityManager should already have been set from within the vehicle. - */ - protected void initEntityManager(String persistenceUnitName, - boolean useProps) { - if (isStandAloneMode()) { - TestUtil.logTrace( - "in initEntityManager(String, boolean): " + persistenceUnitName); - if (useProps) { - Properties propsMap = getPersistenceUnitProperties(); - TestUtil.logTrace("createEntityManagerFactory(String,Map)"); - emf = Persistence.createEntityManagerFactory(persistenceUnitName, - propsMap); - } else { - TestUtil.logTrace("createEntityManagerFactory(String)"); - emf = Persistence.createEntityManagerFactory(persistenceUnitName); - } - Map emfMap = emf.getProperties(); - if (emfMap != null) { - displayMap(emfMap); - } - this.em = emf.createEntityManager(); - } else { - TestUtil.logMsg("The test is running in JakartaEE environment, " - + "the EntityManager is initialized in the vehicle component."); - } - } - - /** - * Creates EntityTransaction in JavaSE environment. In JakartaEE environment, - * EntityManager should already have been set from within the vehicle. - */ - protected void initEntityTransaction() { - EntityTransaction delegate = getEntityManager().getTransaction(); - this.et = delegate; - } - - /** - * Creates EntityTransaction in JavaSE environment. In JakartaEE environment, - * EntityManager should already have been set from within the vehicle. - */ - protected void initEntityTransaction(EntityManager em) { - EntityTransaction delegate = em.getTransaction(); - this.et = delegate; - } - - public boolean isInContainer() { - return inContainer; - } - - public void setInContainer(boolean inContainer) { - this.inContainer = inContainer; - } - - /* - * Properties needed for Standalone TCK persistence.xml - */ - protected Properties getPersistenceUnitProperties() { - Properties jpaProps = new Properties(); - jpaProps.put(JAVAX_PERSISTENCE_PROVIDER, - myProps.get(JAVAX_PERSISTENCE_PROVIDER)); - jpaProps.put(JAVAX_PERSISTENCE_JDBC_DRIVER, - myProps.get(JAVAX_PERSISTENCE_JDBC_DRIVER)); - jpaProps.put(JAVAX_PERSISTENCE_JDBC_URL, - myProps.get(JAVAX_PERSISTENCE_JDBC_URL)); - jpaProps.put(JAVAX_PERSISTENCE_JDBC_USER, - myProps.get(JAVAX_PERSISTENCE_JDBC_USER)); - jpaProps.put(JAVAX_PERSISTENCE_JDBC_PASSWORD, - myProps.get(JAVAX_PERSISTENCE_JDBC_PASSWORD)); - String provider_specific_props = (String) myProps - .get(JPA_PROVIDER_IMPLEMENTATION_SPECIFIC_PROPERTIES); - - StringTokenizer st = new StringTokenizer(provider_specific_props, ":"); - while (st.hasMoreTokens()) { - StringTokenizer st1 = new StringTokenizer(st.nextToken(), "="); - String pspName, pspValue; - pspName = pspValue = null; - if (st1.hasMoreTokens()) { - pspName = st1.nextToken(); - } - if (st1.hasMoreTokens()) { - pspValue = st1.nextToken(); - } - jpaProps.put(pspName, pspValue); - - } - checkPersistenceUnitProperties(jpaProps); - return jpaProps; - } - - public boolean isStandAloneMode() { - if (STANDALONE_MODE.equalsIgnoreCase(mode)) { - return true; - } - return false; - } - - /** - * Verifies certain properties that are not applicable in Java SE environment - * are not filtered out, and not passed to - * Persistence.createEntityManagerFactory. - */ - private void checkPersistenceUnitProperties(Properties jpaProps) { - TestUtil.logTrace( - "persistence unit properites from user: " + jpaProps.toString()); - String provider = jpaProps.getProperty(PROVIDER_PROP); - if (provider == null) { - throw new IllegalStateException( - PROVIDER_PROP + " not specified in persistence unit properties file"); - } - String transactionType = jpaProps.getProperty(TRANSACTION_TYPE_PROP); - if (transactionType != null && !RESOURCE_LOCAL.equals(transactionType)) { - throw new IllegalStateException(TRANSACTION_TYPE_PROP - + " is set to an unsupported value: " + transactionType - + ". The only portably supported type is " + RESOURCE_LOCAL - + ". Please correct it in persistence unit properties file."); - } - String jtaDataSource = jpaProps.getProperty(JTA_DATASOURCE_PROP); - if (jtaDataSource != null) { - TestUtil.logMsg("WARNING: " + JTA_DATASOURCE_PROP + " is specified as " - + jtaDataSource + ", and it will be passed to the persistence " - + "provider. However, this is in general not supported in " - + "Java SE environment"); - // jpaProps.remove(JTA_DATASOURCE_PROP); - } - // String nonJtaDataSource = jpaProps.getProperty(NON_JTA_DATASOURCE_PROP); - // if(nonJtaDataSource == null) { - // throw new IllegalStateException(NON_JTA_DATASOURCE_PROP + " is required " - // + - // "in Java SE environment. It has not been specified. Please " + - // "set it in persistence unit properties file."); - // } - TestUtil.logTrace( - "persistence unit properites verified: " + jpaProps.toString()); - } - - public Calendar getCalDate() { - return Calendar.getInstance(); - } - - public Calendar getCalDate(final int yy, final int mm, final int dd) { - Calendar cal = new GregorianCalendar(yy, mm, dd); - TestUtil.logTrace("returning date:" + cal); - return cal; - } - - public java.sql.Date getSQLDate(final String sDate) { - Date d = java.sql.Date.valueOf(sDate); - TestUtil.logTrace("returning date:" + d); - return d; - } - - public java.sql.Date getSQLDate(final int yy, final int mm, final int dd) { - Calendar newCal = getCalDate(); - newCal.clear(); - newCal.set(yy, mm, dd); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String sDate = sdf.format(newCal.getTime()); - TestUtil.logTrace("returning date:" + java.sql.Date.valueOf(sDate)); - return java.sql.Date.valueOf(sDate); - } - - public java.sql.Date getSQLDate() { - Calendar calDate = getCalDate(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String sDate = sdf.format(calDate.getTime()); - java.sql.Date d = java.sql.Date.valueOf(sDate); - TestUtil.logTrace("returning date:" + d); - return d; - } - - public java.util.Date getUtilDate() { - java.util.Date d = new java.util.Date(); - TestUtil.logTrace("getPKDate: returning date:" + d); - return d; - } - - public java.util.Date getUtilDate(final String sDate) { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - java.util.Date d = null; - try { - d = formatter.parse(sDate); - } catch (ParseException pe) { - TestUtil.logErr("Received unexpected exception:" + pe); - } - TestUtil.logTrace("getPKDate: returning date:" + d); - return d; - } - - public java.sql.Time getTimeData(final String sTime) { - java.sql.Time t = java.sql.Time.valueOf(sTime); - TestUtil.logTrace("getTimeData: returning Time:" + t); - return t; - } - - public java.sql.Time getTimeData(final int hh, final int mm, final int ss) { - Calendar newCal = Calendar.getInstance(); - newCal.clear(); - newCal.set(hh, mm, ss); - SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); - String sDate = sdf.format(newCal.getTime()); - TestUtil.logTrace( - "getTimeData: returning Time:" + java.sql.Time.valueOf(sDate)); - return java.sql.Time.valueOf(sDate); - } - - public java.sql.Timestamp getTimestampData(final String sDate) { - String tFormat = sDate + " " + "10:10:10"; - java.sql.Timestamp ts = java.sql.Timestamp.valueOf(tFormat); - TestUtil.logTrace("getTimestampData: returning TimeStamp:" + ts); - return ts; - } - - public Timestamp getTimestampData(final int yy, final int mm, final int dd) { - TestUtil.logTrace("Entering getTimestampData"); - Calendar newCal = Calendar.getInstance(); - newCal.clear(); - newCal.set(yy, mm, dd); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String sDate = sdf.format(newCal.getTime()); - TestUtil.logTrace("getTimestampData: returning TimeStamp:" - + java.sql.Timestamp.valueOf(sDate)); - return java.sql.Timestamp.valueOf(sDate); - } - - public java.util.Date getPKDate(final int yy, final int mm, final int dd) { - Calendar newCal = Calendar.getInstance(); - newCal.clear(); - newCal.set(yy, mm, dd); - TestUtil.logTrace("getPKDate: returning date:" + newCal.getTime()); - return newCal.getTime(); - } - - public void doFlush() throws PersistenceException { - // TestUtil.logTrace("Entering doFlush method"); - try { - getEntityManager().flush(); - } catch (PersistenceException pe) { - TestUtil.logErr("Unexpected Exception caught while flushing: ", pe); - throw new PersistenceException( - "Unexpected Exception caught while flushing: " + pe); - } - } - - public boolean checkEntityPK(Collection actualPKS, - Collection expectedPKS) { - TestUtil - .logTrace("PMClientBase.checkEntityPK(Collection,Collection)"); - return checkEntityPK(actualPKS, expectedPKS, false); - } - - public boolean checkEntityPK(final Collection actualPKS, - final Collection expectedPKS, final boolean allowDups) { - Integer epks2[] = new Integer[expectedPKS.size()]; - TestUtil.logTrace( - "PMClientBase.checkEntityPK(Collection,Collection, boolean)"); - if (expectedPKS.size() != 0) { - int i = 0; - for (T o : expectedPKS) { - T ref = (T) o; - - try { - if (ref instanceof Integer) { - epks2[i++] = (Integer) ref; - } else if (ref instanceof String) { - epks2[i++] = Integer.valueOf((String) ref); - } else { - Method m = ref.getClass().getMethod("getId"); - Object oo = m.invoke(ref); - if (oo instanceof String) { - epks2[i++] = Integer.valueOf((String) oo); - } else { - epks2[i++] = (Integer) oo; - } - } - } catch (NoSuchMethodException nsme) { - TestUtil.logErr("Unexpected exception thrown", nsme); - } catch (IllegalAccessException iae) { - TestUtil.logErr("Unexpected exception thrown", iae); - } catch (InvocationTargetException ite) { - TestUtil.logErr("Unexpected exception thrown", ite); - } - } - } - return checkEntityPK(actualPKS, epks2, allowDups, true); - } - - public boolean checkEntityPK(final Collection actualPKS, - final String expectedPKS[]) { - TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,String[])"); - return checkEntityPK(actualPKS, expectedPKS, false); - } - - public boolean checkEntityPK(Collection actualPKS, - String expectedPKS[], boolean allowDups) { - Integer epks2[] = new Integer[expectedPKS.length]; - TestUtil.logTrace( - "PMClientBase.checkEntityPK(Collection,String[], boolean)"); - if (expectedPKS.length != 0) { - int i = 0; - for (String s : expectedPKS) { - epks2[i++] = Integer.valueOf(s); - } - } - return checkEntityPK(actualPKS, epks2, allowDups, true); - } - - public boolean checkEntityPK(final Collection actualPKS, - final Integer expectedPKS[]) { - TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,Integer[])"); - return checkEntityPK(actualPKS, expectedPKS, false, true); - } - - public boolean checkEntityPK(final Collection actualPKS, - final Integer expectedPKS[], final boolean allowDups, boolean sortLists) { - Integer cpks2[] = new Integer[actualPKS.size()]; - String cpks; - String epks; - TestUtil.logTrace( - "PMClientBase.checkEntityPK(Collection,Integer[], boolean)"); - try { - if (expectedPKS.length == 0) { - epks = "()"; - } else { - if (sortLists) { - Arrays.sort(expectedPKS); - } - epks = createStringVersionOfPKS(expectedPKS); - } - if (actualPKS.size() == 0) { - cpks = "()"; - } else { - - int k = 0; - for (T o : actualPKS) { - T ref = (T) o; - - try { - if (ref instanceof Integer) { - cpks2[k++] = (Integer) ref; - } else if (ref instanceof String) { - cpks2[k++] = Integer.valueOf((String) ref); - } else { - Method m = ref.getClass().getMethod("getId"); - Object oo = m.invoke(ref); - if (oo instanceof String) { - cpks2[k++] = Integer.valueOf((String) oo); - } else { - cpks2[k++] = (Integer) oo; - } - } - // TestUtil.logTrace("cpks2[" + k + "]=" + cpks2[k]); - } catch (NoSuchMethodException nsme) { - TestUtil.logErr("Unexpected exception thrown", nsme); - } catch (IllegalAccessException iae) { - TestUtil.logErr("Unexpected exception thrown", iae); - } catch (InvocationTargetException ite) { - TestUtil.logErr("Unexpected exception thrown", ite); - } - } - } - if (sortLists) { - Arrays.sort(cpks2); - } - cpks = createStringVersionOfPKS(cpks2); - - if (checkWrongSize(expectedPKS, cpks2)) { - TestUtil.logErr("Wrong size returned, expected " + "PKs of " + epks - + ", got PKs of " + cpks); - return false; - } - if (!allowDups) { - if (checkDuplicates(cpks2)) { - TestUtil.logErr("Duplicate values returned, expected " + "PKs of " - + epks + ", got PKs of " + cpks); - return false; - } - } - if (!Arrays.equals(expectedPKS, cpks2)) { - TestUtil.logErr("Wrong values returned, expected PKs of " + epks - + ", got PKs of " + cpks); - return false; - } - - } catch (Exception e) { - TestUtil.logErr( - "Exception in PMClientBase.checkEntityPK(Collection,Integer[]: ", - e); - return false; - } - - return true; - } - - public String createStringVersionOfPKS(final Integer[] iArray) { - StringBuilder sb = new StringBuilder(2); - sb.append("("); - - for (int i = 0; i < iArray.length; i++) { - sb.append(iArray[i]); - if (i < iArray.length - 1) { - sb.append(", "); - } - } - sb.append(")"); - return sb.toString(); - } - - public boolean checkWrongSize(final Integer[] expected, - final Integer[] actual) { - TestUtil.logTrace("PMClientbase.checkWrongSize"); - if (expected.length != actual.length) { - TestUtil.logErr("Wrong collection size returned (expected " - + expected.length + ", got " + actual.length + ")"); - return true; - } - return false; - } - - public boolean checkDuplicates(final Integer[] iArray) { - TestUtil.logTrace("PMClientbase.checkDuplicates"); - boolean duplicates = false; - for (int ii = 0; ii < iArray.length; ii++) { - for (int j = 0; j < iArray.length; j++) { - if (ii == j) - continue; - if (iArray[ii].equals(iArray[j])) { - duplicates = true; - break; - } - } - } - if (duplicates) { - TestUtil.logErr("Wrong collection contents returned " - + "(contains duplicate entries)"); - return true; - } - return false; - } - - public String compareResultList(final List expected, final List actual) { - String reason; - if (expected.equals(actual)) { - reason = "Got expected result list: " + expected; - TestUtil.logTrace(reason); - } else { - reason = "Expecting result list: " + expected + " , actual: " + actual; - throw new RuntimeException(reason); - } - return reason; - } - - public void displayMap(Map map) { - - if (map != null) { - Set> set = map.entrySet(); - - for (Map.Entry me : set) { - if (me.getValue() instanceof String) { - TestUtil.logTrace( - "Map - name:" + me.getKey() + ", value:" + me.getValue()); - } else { - TestUtil.logTrace("Map - name:" + me.getKey() + ", value:" - + me.getValue().getClass().getName()); - } - } - } else { - TestUtil.logTrace("Map passed in to displayMap was null"); - } - } - - public int convertToInt(Object o) { - if (o instanceof Integer) { - return (Integer) o; - } else if (o instanceof BigDecimal) { - return ((BigDecimal) o).intValue(); - } else if (o instanceof Long) { - return ((Long) o).intValue(); - } - throw new IllegalArgumentException( - "convertToInt(): Received type not coded for:" - + o.getClass().getName()); - } - - public boolean findDataInFile(File file, String searchString) { - List list = new ArrayList(); - list.add(searchString); - return findDataInFile(file, list); - } - - public boolean findDataInFile(File file, List searchStrings) { - boolean found = false; - - List fileContents = getFileContent(file); - int fileContentLineCount = 0; - int foundCount = 0; - - // cycle through all the search strings and all the file contents - // until it is found or we exhaust them all - while (!found && foundCount != searchStrings.size() - && fileContentLineCount != fileContents.size()) { - - for (String fileContent : fileContents) { - fileContentLineCount++; - foundCount = 0; - // TestUtil.logTrace("----------------"); - // TestUtil.logTrace("line:"+fileContent); - - for (String searchString : searchStrings) { - TestUtil.logTrace("searchString:" + searchString); - - if (fileContent.toLowerCase() - .indexOf(searchString.toLowerCase()) >= 0) { - TestUtil.logTrace("Found string[" + searchString + "] in line [" - + fileContent + "]"); - foundCount++; - // TestUtil.logTrace("foundCount:"+foundCount); - // } else { - // TestUtil.logTrace("^^^^^^^^^^^^^^^^^^"); - // - // TestUtil.logTrace("index="+fileContent.toLowerCase().indexOf(searchString.toLowerCase())); - // TestUtil.logTrace("fileContent.toLowerCase["+fileContent.toLowerCase()+"], - // searchString.toLowerCase["+searchString.toLowerCase()+"]"); - // TestUtil.logTrace("^^^^^^^^^^^^^^^^^^"); - - } - } - // TestUtil.logTrace("----------------"); - // - // TestUtil.logTrace("foundCount:"+foundCount+", - // searchStrings.size():"+searchStrings.size()); - - if (foundCount == searchStrings.size()) { - found = true; - break; - } - } - } - // TestUtil.logTrace("foundCount:"+foundCount+", - // searchStrings.size():"+searchStrings.size()); - // TestUtil.logTrace("fileContentLineCount:"+fileContentLineCount+", - // fileContents.size():"+fileContents.size()); - // TestUtil.logTrace("found:"+found); - - if (!found) { - if (searchStrings.size() > 1) { - StringBuffer sb = new StringBuffer(); - int count = 0; - for (String s : searchStrings) { - sb.append(s); - count++; - if (count != searchStrings.size()) { - sb.append(" and "); - } - } - TestUtil.logErr("Entries:" + sb.toString() + ", not found in file:" - + file.toString()); - for (String s : fileContents) { - TestUtil.logErr("File line[" + s + "]"); - } - - } else { - TestUtil.logErr("Entry:" + searchStrings.get(0) + ", not found in file:" - + file.toString()); - - } - } - - return found; - } - - public List getFileContent(File file) { - List list = new ArrayList(); - try { - if (file.exists()) { - TestUtil.logTrace("found file:" + file.getAbsolutePath()); - if (file.length() > 0) { - BufferedReader input = new BufferedReader(new FileReader(file)); - try { - String line = null; - while ((line = input.readLine()) != null) { - TestUtil.logTrace("read line:" + line); - line = line.trim(); - list.add(line); - } - - } finally { - input.close(); - } - } else { - TestUtil.logErr("File is empty: " + file.getAbsolutePath()); - } - } else { - TestUtil.logErr( - "Specified file " + file.getAbsolutePath() + " does not exist"); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - return list; - } - - public void deleteItem(File file) { - if (file.exists()) { - TestUtil.logTrace("item:" + file.getAbsolutePath() + " exists"); - if (file.isDirectory()) { - // item is a directory - File[] files = file.listFiles(); - if (files != null) { - for (File f : files) { - deleteItem(f); - } - // delete the empty directory - if (file.delete()) { - TestUtil - .logTrace("directory: " + file.getAbsolutePath() + " deleted"); - if (file.exists()) { - TestUtil - .logErr("directory still exists even after calling delete"); - } - } else { - TestUtil.logErr( - "Could not delete directory: " + file.getAbsolutePath()); - } - - } else { - TestUtil.logErr("listFiles returned null"); - } - } else { - // item is a file - if (file.delete()) { - TestUtil.logTrace("file: " + file.getAbsolutePath() + " deleted"); - if (file.exists()) { - TestUtil.logErr("file still exists even after calling delete"); - } - } else { - TestUtil.logErr("Could not delete file: " + file.getAbsolutePath()); - } - } - } else { - TestUtil.logTrace("file:" + file.getAbsolutePath() + " does not exist"); - } - } - - public String convertToURI(String path) { - String sURI = null; - try { - sURI = new File(path).toURI().toASCIIString(); - TestUtil.logTrace("URI=" + sURI); - } catch (Exception ue) { - TestUtil.logErr("Received unexpected exception for path:" + path, ue); - } - return sURI; - } + /** + * Name of a property defined in ts.jte, to denote whether tests run in + * JakartaEE or Java SE mode. + */ + transient public static final String MODE_PROP = "platform.mode"; + + /** + * Denotes that tests are running in Java EE mode. This is the only valid + * non-null value for this property. + */ + transient public static final String JAVAEE_MODE = "jakartaEE"; + + /** + * Denotes that tests are running in Java SE mode. This is the only valid + * non-null value for this property. + */ + transient public static final String STANDALONE_MODE = "standalone"; + + /** + * Name of a property defined in ts.jte, to specify the name of the persistence + * unit used in the testsuite. It must be consistent with the value in + * persistence.xml + */ + transient public static final String PERSISTENCE_UNIT_NAME_PROP = "persistence.unit.name"; + + transient public static final String SECOND_PERSISTENCE_UNIT_NAME_PROP = "persistence.unit.name.2"; + + /** + * Name of the property in ts.jte that specifies an absolute path to the + * properties file that contains properties for initializing + * EntityManagerFactory, including both standard and provider-specific + * properties. + */ + transient public static final String JAVAX_PERSISTENCE_PROVIDER = "jakarta.persistence.provider"; + + transient public static final String JAVAX_PERSISTENCE_JDBC_DRIVER = "jakarta.persistence.jdbc.driver"; + + transient public static final String JAVAX_PERSISTENCE_JDBC_URL = "jakarta.persistence.jdbc.url"; + + transient public static final String JAVAX_PERSISTENCE_JDBC_USER = "jakarta.persistence.jdbc.user"; + + transient public static final String JAVAX_PERSISTENCE_JDBC_PASSWORD = "jakarta.persistence.jdbc.password"; + + transient public static final String JPA_PROVIDER_IMPLEMENTATION_SPECIFIC_PROPERTIES = "jpa.provider.implementation.specific.properties"; + + transient public static final String PERSISTENCE_SECOND_LEVEL_CACHING_SUPPORTED = "persistence.second.level.caching.supported"; + + /** + * The current test mode. The only valid non-null value is "standalone". + */ + transient private String mode; + + /** + * Persistence unit name. + */ + private String persistenceUnitName; + + protected String secondPersistenceUnitName; + + protected PMClientBase() { + super(); + } + + protected void removeEntity(Object o) { + if (o != null) { + try { + getEntityManager().remove(o); + } catch (Exception e) { + TestUtil.logErr("removeEntity: Exception caught when removing entity: ", e); + } + } + } + + public String getPersistenceUnitName() { + TestUtil.logTrace("getPersistenceUnitName() - Persistence Unit Name:" + this.persistenceUnitName); + return this.persistenceUnitName; + } + + public String getSecondPersistenceUnitName() { + TestUtil.logTrace( + "getSecondPersistenceUnitName() - Second Persistence Unit Name:" + this.secondPersistenceUnitName); + return secondPersistenceUnitName; + } + + /** + * If a subclass overrides this method, the overriding implementation must call + * super.setup() at the beginning. + */ + public void setup() throws Exception { + TestUtil.logTrace("PMClientBase.setup"); + mode = System.getProperty(MODE_PROP); + persistenceUnitName = System.getProperty(PERSISTENCE_UNIT_NAME_PROP); + TestUtil.logTrace("Persistence Unit Name =" + persistenceUnitName); + secondPersistenceUnitName = System.getProperty(SECOND_PERSISTENCE_UNIT_NAME_PROP); + TestUtil.logTrace("Second Persistence Unit Name =" + secondPersistenceUnitName); + if (JAVAEE_MODE.equalsIgnoreCase(mode)) { + TestUtil.logTrace(MODE_PROP + " is set to " + mode + ", so tests are running in JakartaEE environment."); + } else if (STANDALONE_MODE.equalsIgnoreCase(mode)) { + TestUtil.logTrace( + MODE_PROP + " is set to " + mode + ", so tests are running in J2SE environment standalone mode." + + PERSISTENCE_UNIT_NAME_PROP + " is set to " + persistenceUnitName); + } else { + TestUtil.logMsg("WARNING: " + MODE_PROP + " is set to " + mode + ", an invalid value."); + } + + cachingSupported = Boolean.parseBoolean(System.getProperty(PERSISTENCE_SECOND_LEVEL_CACHING_SUPPORTED, "true")); + } + + public void displayProperties(Properties props) { + TestUtil.logMsg("Current properties:"); + + for (Object entry : props.keySet()) { + if (props.get(entry) instanceof String) { + TestUtil.logTrace("Key:" + (String) entry + ", value:[" + props.get(entry) + "]"); + } else { + TestUtil.logTrace("Key:" + (String) entry + ", value:" + props.get(entry).getClass().getSimpleName()); + + } + } + } + + /** + * In JakartaEE environment, does nothing. In Java SE environment, closes the + * EntityManager if its open, and closes the EntityManagerFactory if its open. + * If a subclass overrides this method, the overriding implementation must call + * super.cleanup() at the end. Also, the cache cleared. + */ + public void cleanup() throws Exception { + closeEMAndEMF(); + } + + /* + * This method is inherited by clients and is used when no super.cleanup() call + * is needed + */ + public void cleanupNoSuper() throws Exception { + } + + /** + * In JakartaEE environment, does nothing. In Java SE environment, closes the + * EntityManager if its open, and closes the EntityManagerFactory if its open. + * Also, the cache cleared. + */ + public void closeEMAndEMF() throws Exception { + + try { + TestUtil.logTrace("Rolling back any existing transaction before closing EMF and EM if one exists."); + if (getEntityTransaction(false) != null && getEntityTransaction(false).isActive()) { + TestUtil.logTrace("An active transaction was found, rolling it back."); + getEntityTransaction(false).rollback(); + } + } catch (Exception fe) { + TestUtil.logMsg("Unexpected exception rolling back TX:", fe); + } + + clearCache(); + + if (isStandAloneMode()) { + TestUtil.logTrace("Closing EM and EMF"); + if (getEntityManager(false) != null && getEntityManager(false).isOpen()) { + getEntityManager(false).close(); + } + + if (getEntityManagerFactory() != null && getEntityManagerFactory().isOpen()) { + getEntityManagerFactory().close(); + } + } + } + + public void clearEMAndEMF() throws Exception { + closeEMAndEMF(); + clearEntityManager(); + clearEntityManagerFactory(); + } + + public void clearEntityManager() { + if (isStandAloneMode()) { + this.em = null; + } + } + + public void clearEntityManagerFactory() { + if (isStandAloneMode()) { + this.emf = null; + } + } + + public void clearCache() throws Exception { + + if (cachingSupported) { + if (getEntityManager() != null && getEntityManager().isOpen()) { + if (getEntityManager().getEntityManagerFactory() != null + && getEntityManager().getEntityManagerFactory().isOpen()) { + + // if the EntityManager is open, clear the context causing all + // managed entities to become detached + TestUtil.logTrace("Clearing context"); + getEntityManager().clear(); + + TestUtil.logTrace("Trying to clear cache via call to EMF.getCache().evictAll()."); + Cache cache = getEntityManager().getEntityManagerFactory().getCache(); + if (cache != null) { + cache.evictAll(); + TestUtil.logTrace("EMF.getCache().evictAll() was executed."); + } else { + TestUtil.logErr("Cache supported is true in ts.jte but getCache() is returning null"); + } + + } else { + TestUtil.logTrace( + "Clearing of cache did not occur because either EntityManagerFactory was null or closed"); + } + } else { + TestUtil.logTrace("Clearing of cache did not occur because either EntityManager was null or closed"); + } + } else { + TestUtil.logTrace("Clearing of cache did not occur because it is not supposed."); + } + } + + public void setEntityManager(jakarta.persistence.EntityManager em) { + this.em = em; + } + + public void setEntityManagerFactory(EntityManagerFactory emf) { + this.jakartaEEemf = emf; + } + + public EntityManager getEntityManager() { + // get exist entity manager and use the default persistence unit name + return getEntityManager(false); + } + + public EntityManager getEntityManager(boolean reInit) { + // If reInit=false then it will return existing EntityManager + // otherwise this returns new EntityManager + if (!reInit) { + if (this.em != null) { + TestUtil.logTrace( + "Using existing entity manager class:" + em.getClass().getName() + " isOpen:" + em.isOpen()); + return this.em; + } + TestUtil.logTrace("getEntityManager: false was specified and EM is null"); + } + TestUtil.logTrace("Need to Initialize EntityManager"); + if (isStandAloneMode()) { + initEntityManager(persistenceUnitName, true); + TestUtil.logTrace("EntityManager class:" + em.getClass().getName() + " isOpen:" + em.isOpen()); + return this.em; + } + throw new IllegalStateException("The test is running in JakartaEE environment, " + + "but PMClientBase.em has not been initialized from the vehicle component."); + } + + public EntityManagerFactory getEntityManagerFactory() { + if (isStandAloneMode()) { + if (emf != null) { + TestUtil.logTrace("EntityManagerFactory class:" + emf.getClass().getName() + " isOpen:" + emf.isOpen()); + } + return emf; + } else { + if (jakartaEEemf != null) { + TestUtil.logTrace("EntityManagerFactory class:" + jakartaEEemf.getClass().getName() + " isOpen:" + + jakartaEEemf.isOpen()); + } + return jakartaEEemf; + } + } + + public void clearEntityTransaction() { + this.et = null; + } + + public void setEntityTransaction(EntityTransaction et) { + this.et = et; + } + + public EntityTransaction getEntityTransaction() { + if (this.et != null) { + TestUtil.logTrace("Transaction class:" + et.getClass().getName() + " isActive():" + et.isActive()); + return this.et; + } + TestUtil.logTrace("Need to get Transaction"); + if (isStandAloneMode()) { + initEntityTransaction(); + if (et != null) { + TestUtil.logTrace("Transaction class:" + et.getClass().getName() + " isActive():" + et.isActive()); + } + return this.et; + } + throw new IllegalStateException("The test is running in JakartaEE environment, " + + "but PMClientBase.et has not been initialized from the vehicle component."); + } + + public EntityTransaction getEntityTransaction(boolean reInit, EntityManager em) { + // If reInit=false then it will return existing EntityTransaction + // otherwise this returns new EntityTransaction + if (!reInit) { + if (this.et != null) { + TestUtil.logTrace("Transaction class:" + et.getClass().getName() + " isActive():" + et.isActive()); + return this.et; + } + } + if (isStandAloneMode()) { + initEntityTransaction(em); + if (et != null) { + TestUtil.logTrace("Transaction class:" + et.getClass().getName() + " isActive():" + et.isActive()); + } + return this.et; + } + throw new IllegalStateException("The test is running in JakartaEE environment, " + + "but PMClientBase.et has not been initialized from the vehicle component."); + } + + public EntityTransaction getEntityTransaction(boolean reInit) { + // If reInit=false then it will return existing EntityTransaction + // otherwise this returns new EntityTransaction + if (!reInit) { + if (this.et != null) { + TestUtil.logTrace("Transaction class:" + et.getClass().getName() + " isActive():" + et.isActive()); + return this.et; + } + } + if (isStandAloneMode()) { + initEntityTransaction(); + if (et != null) { + TestUtil.logTrace("Transaction class:" + et.getClass().getName() + " isActive():" + et.isActive()); + } + return this.et; + } + throw new IllegalStateException("The test is running in JakartaEE environment, " + + "but PMClientBase.et has not been initialized from the vehicle component."); + } + + /** + * Creates EntityManager in JavaSE environment. In JakartaEE environment, + * EntityManager should already have been set from within the vehicle. + */ + protected void initEntityManager(String persistenceUnitName, boolean useProps) { + if (isStandAloneMode()) { + TestUtil.logTrace("in initEntityManager(String, boolean): " + persistenceUnitName); + if (useProps) { + Properties propsMap = getPersistenceUnitProperties(); + TestUtil.logTrace("createEntityManagerFactory(String,Map)"); + emf = Persistence.createEntityManagerFactory(persistenceUnitName, propsMap); + } else { + TestUtil.logTrace("createEntityManagerFactory(String)"); + emf = Persistence.createEntityManagerFactory(persistenceUnitName); + } + Map emfMap = emf.getProperties(); + if (emfMap != null) { + displayMap(emfMap); + } + this.em = emf.createEntityManager(); + } else { + TestUtil.logMsg("The test is running in JakartaEE environment, " + + "the EntityManager is initialized in the vehicle component."); + } + } + + /** + * Creates EntityTransaction in JavaSE environment. In JakartaEE environment, + * EntityManager should already have been set from within the vehicle. + */ + protected void initEntityTransaction() { + EntityTransaction delegate = getEntityManager().getTransaction(); + this.et = delegate; + } + + /** + * Creates EntityTransaction in JavaSE environment. In JakartaEE environment, + * EntityManager should already have been set from within the vehicle. + */ + protected void initEntityTransaction(EntityManager em) { + EntityTransaction delegate = em.getTransaction(); + this.et = delegate; + } + + public boolean isInContainer() { + return inContainer; + } + + public void setInContainer(boolean inContainer) { + this.inContainer = inContainer; + } + + /* + * Properties needed for Standalone TCK persistence.xml + */ + protected Properties getPersistenceUnitProperties() { + Properties jpaProps = new Properties(); + jpaProps.put(JAVAX_PERSISTENCE_PROVIDER, myProps.get(JAVAX_PERSISTENCE_PROVIDER)); + jpaProps.put(JAVAX_PERSISTENCE_JDBC_DRIVER, myProps.get(JAVAX_PERSISTENCE_JDBC_DRIVER)); + jpaProps.put(JAVAX_PERSISTENCE_JDBC_URL, myProps.get(JAVAX_PERSISTENCE_JDBC_URL)); + jpaProps.put(JAVAX_PERSISTENCE_JDBC_USER, myProps.get(JAVAX_PERSISTENCE_JDBC_USER)); + jpaProps.put(JAVAX_PERSISTENCE_JDBC_PASSWORD, myProps.get(JAVAX_PERSISTENCE_JDBC_PASSWORD)); + String provider_specific_props = (String) myProps.get(JPA_PROVIDER_IMPLEMENTATION_SPECIFIC_PROPERTIES); + + StringTokenizer st = new StringTokenizer(provider_specific_props, ":"); + while (st.hasMoreTokens()) { + StringTokenizer st1 = new StringTokenizer(st.nextToken(), "="); + String pspName, pspValue; + pspName = pspValue = null; + if (st1.hasMoreTokens()) { + pspName = st1.nextToken(); + } + if (st1.hasMoreTokens()) { + pspValue = st1.nextToken(); + } + jpaProps.put(pspName, pspValue); + + } + checkPersistenceUnitProperties(jpaProps); + return jpaProps; + } + + public boolean isStandAloneMode() { + if (STANDALONE_MODE.equalsIgnoreCase(mode)) { + return true; + } + return false; + } + + /** + * Verifies certain properties that are not applicable in Java SE environment + * are not filtered out, and not passed to + * Persistence.createEntityManagerFactory. + */ + private void checkPersistenceUnitProperties(Properties jpaProps) { + TestUtil.logTrace("persistence unit properites from user: " + jpaProps.toString()); + String provider = jpaProps.getProperty(PROVIDER_PROP); + if (provider == null) { + throw new IllegalStateException(PROVIDER_PROP + " not specified in persistence unit properties file"); + } + String transactionType = jpaProps.getProperty(TRANSACTION_TYPE_PROP); + if (transactionType != null && !RESOURCE_LOCAL.equals(transactionType)) { + throw new IllegalStateException(TRANSACTION_TYPE_PROP + " is set to an unsupported value: " + + transactionType + ". The only portably supported type is " + RESOURCE_LOCAL + + ". Please correct it in persistence unit properties file."); + } + String jtaDataSource = jpaProps.getProperty(JTA_DATASOURCE_PROP); + if (jtaDataSource != null) { + TestUtil.logMsg("WARNING: " + JTA_DATASOURCE_PROP + " is specified as " + jtaDataSource + + ", and it will be passed to the persistence " + + "provider. However, this is in general not supported in " + "Java SE environment"); + // jpaProps.remove(JTA_DATASOURCE_PROP); + } + // String nonJtaDataSource = jpaProps.getProperty(NON_JTA_DATASOURCE_PROP); + // if(nonJtaDataSource == null) { + // throw new IllegalStateException(NON_JTA_DATASOURCE_PROP + " is required " + // + + // "in Java SE environment. It has not been specified. Please " + + // "set it in persistence unit properties file."); + // } + TestUtil.logTrace("persistence unit properites verified: " + jpaProps.toString()); + } + + public Calendar getCalDate() { + return Calendar.getInstance(); + } + + public Calendar getCalDate(final int yy, final int mm, final int dd) { + Calendar cal = new GregorianCalendar(yy, mm, dd); + TestUtil.logTrace("returning date:" + cal); + return cal; + } + + public java.sql.Date getSQLDate(final String sDate) { + Date d = java.sql.Date.valueOf(sDate); + TestUtil.logTrace("returning date:" + d); + return d; + } + + public java.sql.Date getSQLDate(final int yy, final int mm, final int dd) { + Calendar newCal = getCalDate(); + newCal.clear(); + newCal.set(yy, mm, dd); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String sDate = sdf.format(newCal.getTime()); + TestUtil.logTrace("returning date:" + java.sql.Date.valueOf(sDate)); + return java.sql.Date.valueOf(sDate); + } + + public java.sql.Date getSQLDate() { + Calendar calDate = getCalDate(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String sDate = sdf.format(calDate.getTime()); + java.sql.Date d = java.sql.Date.valueOf(sDate); + TestUtil.logTrace("returning date:" + d); + return d; + } + + public java.util.Date getUtilDate() { + java.util.Date d = new java.util.Date(); + TestUtil.logTrace("getPKDate: returning date:" + d); + return d; + } + + public java.util.Date getUtilDate(final String sDate) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + java.util.Date d = null; + try { + d = formatter.parse(sDate); + } catch (ParseException pe) { + TestUtil.logErr("Received unexpected exception:" + pe); + } + TestUtil.logTrace("getPKDate: returning date:" + d); + return d; + } + + public java.sql.Time getTimeData(final String sTime) { + java.sql.Time t = java.sql.Time.valueOf(sTime); + TestUtil.logTrace("getTimeData: returning Time:" + t); + return t; + } + + public java.sql.Time getTimeData(final int hh, final int mm, final int ss) { + Calendar newCal = Calendar.getInstance(); + newCal.clear(); + newCal.set(hh, mm, ss); + SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); + String sDate = sdf.format(newCal.getTime()); + TestUtil.logTrace("getTimeData: returning Time:" + java.sql.Time.valueOf(sDate)); + return java.sql.Time.valueOf(sDate); + } + + public java.sql.Timestamp getTimestampData(final String sDate) { + String tFormat = sDate + " " + "10:10:10"; + java.sql.Timestamp ts = java.sql.Timestamp.valueOf(tFormat); + TestUtil.logTrace("getTimestampData: returning TimeStamp:" + ts); + return ts; + } + + public Timestamp getTimestampData(final int yy, final int mm, final int dd) { + TestUtil.logTrace("Entering getTimestampData"); + Calendar newCal = Calendar.getInstance(); + newCal.clear(); + newCal.set(yy, mm, dd); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String sDate = sdf.format(newCal.getTime()); + TestUtil.logTrace("getTimestampData: returning TimeStamp:" + java.sql.Timestamp.valueOf(sDate)); + return java.sql.Timestamp.valueOf(sDate); + } + + public java.util.Date getPKDate(final int yy, final int mm, final int dd) { + Calendar newCal = Calendar.getInstance(); + newCal.clear(); + newCal.set(yy, mm, dd); + TestUtil.logTrace("getPKDate: returning date:" + newCal.getTime()); + return newCal.getTime(); + } + + public void doFlush() throws PersistenceException { + // TestUtil.logTrace("Entering doFlush method"); + try { + getEntityManager().flush(); + } catch (PersistenceException pe) { + TestUtil.logErr("Unexpected Exception caught while flushing: ", pe); + throw new PersistenceException("Unexpected Exception caught while flushing: " + pe); + } + } + + public boolean checkEntityPK(Collection actualPKS, Collection expectedPKS) { + TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,Collection)"); + return checkEntityPK(actualPKS, expectedPKS, false); + } + + public boolean checkEntityPK(final Collection actualPKS, final Collection expectedPKS, + final boolean allowDups) { + Integer epks2[] = new Integer[expectedPKS.size()]; + TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,Collection, boolean)"); + if (expectedPKS.size() != 0) { + int i = 0; + for (T o : expectedPKS) { + T ref = (T) o; + + try { + if (ref instanceof Integer) { + epks2[i++] = (Integer) ref; + } else if (ref instanceof String) { + epks2[i++] = Integer.valueOf((String) ref); + } else { + Method m = ref.getClass().getMethod("getId"); + Object oo = m.invoke(ref); + if (oo instanceof String) { + epks2[i++] = Integer.valueOf((String) oo); + } else { + epks2[i++] = (Integer) oo; + } + } + } catch (NoSuchMethodException nsme) { + TestUtil.logErr("Unexpected exception thrown", nsme); + } catch (IllegalAccessException iae) { + TestUtil.logErr("Unexpected exception thrown", iae); + } catch (InvocationTargetException ite) { + TestUtil.logErr("Unexpected exception thrown", ite); + } + } + } + return checkEntityPK(actualPKS, epks2, allowDups, true); + } + + public boolean checkEntityPK(final Collection actualPKS, final String expectedPKS[]) { + TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,String[])"); + return checkEntityPK(actualPKS, expectedPKS, false); + } + + public boolean checkEntityPK(Collection actualPKS, String expectedPKS[], boolean allowDups) { + Integer epks2[] = new Integer[expectedPKS.length]; + TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,String[], boolean)"); + if (expectedPKS.length != 0) { + int i = 0; + for (String s : expectedPKS) { + epks2[i++] = Integer.valueOf(s); + } + } + return checkEntityPK(actualPKS, epks2, allowDups, true); + } + + public boolean checkEntityPK(final Collection actualPKS, final Integer expectedPKS[]) { + TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,Integer[])"); + return checkEntityPK(actualPKS, expectedPKS, false, true); + } + + public boolean checkEntityPK(final Collection actualPKS, final Integer expectedPKS[], + final boolean allowDups, boolean sortLists) { + Integer cpks2[] = new Integer[actualPKS.size()]; + String cpks; + String epks; + TestUtil.logTrace("PMClientBase.checkEntityPK(Collection,Integer[], boolean)"); + try { + if (expectedPKS.length == 0) { + epks = "()"; + } else { + if (sortLists) { + Arrays.sort(expectedPKS); + } + epks = createStringVersionOfPKS(expectedPKS); + } + if (actualPKS.size() == 0) { + cpks = "()"; + } else { + + int k = 0; + for (T o : actualPKS) { + T ref = (T) o; + + try { + if (ref instanceof Integer) { + cpks2[k++] = (Integer) ref; + } else if (ref instanceof String) { + cpks2[k++] = Integer.valueOf((String) ref); + } else { + Method m = ref.getClass().getMethod("getId"); + Object oo = m.invoke(ref); + if (oo instanceof String) { + cpks2[k++] = Integer.valueOf((String) oo); + } else { + cpks2[k++] = (Integer) oo; + } + } + // TestUtil.logTrace("cpks2[" + k + "]=" + cpks2[k]); + } catch (NoSuchMethodException nsme) { + TestUtil.logErr("Unexpected exception thrown", nsme); + } catch (IllegalAccessException iae) { + TestUtil.logErr("Unexpected exception thrown", iae); + } catch (InvocationTargetException ite) { + TestUtil.logErr("Unexpected exception thrown", ite); + } + } + } + if (sortLists) { + Arrays.sort(cpks2); + } + cpks = createStringVersionOfPKS(cpks2); + + if (checkWrongSize(expectedPKS, cpks2)) { + TestUtil.logErr("Wrong size returned, expected " + "PKs of " + epks + ", got PKs of " + cpks); + return false; + } + if (!allowDups) { + if (checkDuplicates(cpks2)) { + TestUtil.logErr("Duplicate values returned, expected " + "PKs of " + epks + ", got PKs of " + cpks); + return false; + } + } + if (!Arrays.equals(expectedPKS, cpks2)) { + TestUtil.logErr("Wrong values returned, expected PKs of " + epks + ", got PKs of " + cpks); + return false; + } + + } catch (Exception e) { + TestUtil.logErr("Exception in PMClientBase.checkEntityPK(Collection,Integer[]: ", e); + return false; + } + + return true; + } + + public String createStringVersionOfPKS(final Integer[] iArray) { + StringBuilder sb = new StringBuilder(2); + sb.append("("); + + for (int i = 0; i < iArray.length; i++) { + sb.append(iArray[i]); + if (i < iArray.length - 1) { + sb.append(", "); + } + } + sb.append(")"); + return sb.toString(); + } + + public boolean checkWrongSize(final Integer[] expected, final Integer[] actual) { + TestUtil.logTrace("PMClientbase.checkWrongSize"); + if (expected.length != actual.length) { + TestUtil.logErr( + "Wrong collection size returned (expected " + expected.length + ", got " + actual.length + ")"); + return true; + } + return false; + } + + public boolean checkDuplicates(final Integer[] iArray) { + TestUtil.logTrace("PMClientbase.checkDuplicates"); + boolean duplicates = false; + for (int ii = 0; ii < iArray.length; ii++) { + for (int j = 0; j < iArray.length; j++) { + if (ii == j) + continue; + if (iArray[ii].equals(iArray[j])) { + duplicates = true; + break; + } + } + } + if (duplicates) { + TestUtil.logErr("Wrong collection contents returned " + "(contains duplicate entries)"); + return true; + } + return false; + } + + public String compareResultList(final List expected, final List actual) { + String reason; + if (expected.equals(actual)) { + reason = "Got expected result list: " + expected; + TestUtil.logTrace(reason); + } else { + reason = "Expecting result list: " + expected + " , actual: " + actual; + throw new RuntimeException(reason); + } + return reason; + } + + public void displayMap(Map map) { + + if (map != null) { + Set> set = map.entrySet(); + + for (Map.Entry me : set) { + if (me.getValue() instanceof String) { + TestUtil.logTrace("Map - name:" + me.getKey() + ", value:" + me.getValue()); + } else { + TestUtil.logTrace("Map - name:" + me.getKey() + ", value:" + me.getValue().getClass().getName()); + } + } + } else { + TestUtil.logTrace("Map passed in to displayMap was null"); + } + } + + public int convertToInt(Object o) { + if (o instanceof Integer) { + return (Integer) o; + } else if (o instanceof BigDecimal) { + return ((BigDecimal) o).intValue(); + } else if (o instanceof Long) { + return ((Long) o).intValue(); + } + throw new IllegalArgumentException("convertToInt(): Received type not coded for:" + o.getClass().getName()); + } + + public boolean findDataInFile(File file, String searchString) { + List list = new ArrayList(); + list.add(searchString); + return findDataInFile(file, list); + } + + public boolean findDataInFile(File file, List searchStrings) { + boolean found = false; + + List fileContents = getFileContent(file); + int fileContentLineCount = 0; + int foundCount = 0; + + // cycle through all the search strings and all the file contents + // until it is found or we exhaust them all + while (!found && foundCount != searchStrings.size() && fileContentLineCount != fileContents.size()) { + + for (String fileContent : fileContents) { + fileContentLineCount++; + foundCount = 0; + // TestUtil.logTrace("----------------"); + // TestUtil.logTrace("line:"+fileContent); + + for (String searchString : searchStrings) { + TestUtil.logTrace("searchString:" + searchString); + + if (fileContent.toLowerCase().indexOf(searchString.toLowerCase()) >= 0) { + TestUtil.logTrace("Found string[" + searchString + "] in line [" + fileContent + "]"); + foundCount++; + // TestUtil.logTrace("foundCount:"+foundCount); + // } else { + // TestUtil.logTrace("^^^^^^^^^^^^^^^^^^"); + // + // TestUtil.logTrace("index="+fileContent.toLowerCase().indexOf(searchString.toLowerCase())); + // TestUtil.logTrace("fileContent.toLowerCase["+fileContent.toLowerCase()+"], + // searchString.toLowerCase["+searchString.toLowerCase()+"]"); + // TestUtil.logTrace("^^^^^^^^^^^^^^^^^^"); + + } + } + // TestUtil.logTrace("----------------"); + // + // TestUtil.logTrace("foundCount:"+foundCount+", + // searchStrings.size():"+searchStrings.size()); + + if (foundCount == searchStrings.size()) { + found = true; + break; + } + } + } + // TestUtil.logTrace("foundCount:"+foundCount+", + // searchStrings.size():"+searchStrings.size()); + // TestUtil.logTrace("fileContentLineCount:"+fileContentLineCount+", + // fileContents.size():"+fileContents.size()); + // TestUtil.logTrace("found:"+found); + + if (!found) { + if (searchStrings.size() > 1) { + StringBuffer sb = new StringBuffer(); + int count = 0; + for (String s : searchStrings) { + sb.append(s); + count++; + if (count != searchStrings.size()) { + sb.append(" and "); + } + } + TestUtil.logErr("Entries:" + sb.toString() + ", not found in file:" + file.toString()); + for (String s : fileContents) { + TestUtil.logErr("File line[" + s + "]"); + } + + } else { + TestUtil.logErr("Entry:" + searchStrings.get(0) + ", not found in file:" + file.toString()); + + } + } + + return found; + } + + public List getFileContent(File file) { + List list = new ArrayList(); + try { + if (file.exists()) { + TestUtil.logTrace("found file:" + file.getAbsolutePath()); + if (file.length() > 0) { + BufferedReader input = new BufferedReader(new FileReader(file)); + try { + String line = null; + while ((line = input.readLine()) != null) { + TestUtil.logTrace("read line:" + line); + line = line.trim(); + list.add(line); + } + + } finally { + input.close(); + } + } else { + TestUtil.logErr("File is empty: " + file.getAbsolutePath()); + } + } else { + TestUtil.logErr("Specified file " + file.getAbsolutePath() + " does not exist"); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + return list; + } + + public void deleteItem(File file) { + if (file.exists()) { + TestUtil.logTrace("item:" + file.getAbsolutePath() + " exists"); + if (file.isDirectory()) { + // item is a directory + File[] files = file.listFiles(); + if (files != null) { + for (File f : files) { + deleteItem(f); + } + // delete the empty directory + if (file.delete()) { + TestUtil.logTrace("directory: " + file.getAbsolutePath() + " deleted"); + if (file.exists()) { + TestUtil.logErr("directory still exists even after calling delete"); + } + } else { + TestUtil.logErr("Could not delete directory: " + file.getAbsolutePath()); + } + + } else { + TestUtil.logErr("listFiles returned null"); + } + } else { + // item is a file + if (file.delete()) { + TestUtil.logTrace("file: " + file.getAbsolutePath() + " deleted"); + if (file.exists()) { + TestUtil.logErr("file still exists even after calling delete"); + } + } else { + TestUtil.logErr("Could not delete file: " + file.getAbsolutePath()); + } + } + } else { + TestUtil.logTrace("file:" + file.getAbsolutePath() + " does not exist"); + } + } + + public String convertToURI(String path) { + String sURI = null; + try { + sURI = new File(path).toURI().toASCIIString(); + TestUtil.logTrace("URI=" + sURI); + } catch (Exception ue) { + TestUtil.logErr("Received unexpected exception for path:" + path, ue); + } + return sURI; + } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/common/pluggability/util/LogFileProcessor.java b/jpa/src/main/java/com/sun/ts/tests/jpa/common/pluggability/util/LogFileProcessor.java index 5898ebe040..7c7006b10b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/common/pluggability/util/LogFileProcessor.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/common/pluggability/util/LogFileProcessor.java @@ -24,13 +24,13 @@ import java.io.SequenceInputStream; import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.StringTokenizer; import java.util.Vector; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import org.junit.jupiter.api.BeforeEach; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -70,15 +70,16 @@ public class LogFileProcessor { private Collection appSpecificRecordCollection = null; - public LogFileProcessor(Properties props) { - setup(props); + public LogFileProcessor() { + setup(); } /** * setup method */ - public void setup(Properties p) { - logFileLocation = p.getProperty("log.file.location"); + @BeforeEach + public void setup() { + logFileLocation = System.getProperty("log.file.location"); if (logFileLocation == null) { TestUtil.logErr("LogFileProcessor setup failed "); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/common/schema30/Util.java b/jpa/src/main/java/com/sun/ts/tests/jpa/common/schema30/Util.java index 51e068f473..62b4e71c3c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/common/schema30/Util.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/common/schema30/Util.java @@ -21,7 +21,9 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.Properties; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -62,130 +64,140 @@ public class Util extends PMClientBase { protected final Trim trimRef[] = new Trim[20]; - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupProductData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupProductData() throws Exception { TestUtil.logTrace("setupProductData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createProductData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupProductData failed:", e); + throw new Exception("setupProductData failed:", e); } } - public void setupCustomerData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupCustomerData() throws Exception { TestUtil.logTrace("setupCustomerData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createCustomerData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupCustomerData failed:", e); + throw new Exception("setupCustomerData failed:", e); } } - public void setupPhoneData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupPhoneData() throws Exception { TestUtil.logTrace("setupPhoneData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createCustomerData(); createPhoneData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupCustomerData failed:", e); + throw new Exception("setupCustomerData failed:", e); } } - public void setupAliasData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupAliasData() throws Exception { TestUtil.logTrace("setupAliasData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createCustomerData(); createAliasData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupAliasData failed:", e); + throw new Exception("setupAliasData failed:", e); } } - public void setupAliasOnlyData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupAliasOnlyData() throws Exception { TestUtil.logTrace("setupAliasOnlyData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createAliasOnlyData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupCustomerData failed:", e); + throw new Exception("setupCustomerData failed:", e); } } - public void setupCustAliasProductData(String[] args, Properties p) + @BeforeEach + public void setupCustAliasProductData() throws Exception { TestUtil.logTrace("setupCustAliasProductData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createCustomerData(); createProductData(); createAliasData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupCustomerData failed:", e); + throw new Exception("setupCustomerData failed:", e); } } - public void setupOrderData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupOrderData() throws Exception { TestUtil.logTrace("setupOrderData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createCustomerData(); createProductData(); createOrderData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupCustomerData failed:", e); + throw new Exception("setupCustomerData failed:", e); } } - public void setupDepartmentEmployeeData(String[] args, Properties p) + @BeforeEach + public void setupDepartmentEmployeeData() throws Exception { TestUtil.logTrace("setupDepartmentEmployeeData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createDepartmentEmployeeData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupDepartmentEmployeeData failed:", e); + throw new Exception("setupDepartmentEmployeeData failed:", e); } } - public void setupTrimData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupTrimData() throws Exception { TestUtil.logTrace("setupTrimData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTrimData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setupTrimData failed:", e); + throw new Exception("setupTrimData failed:", e); } } @@ -233,7 +245,7 @@ public void createTrimData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createTrimData failed:", e); + throw new Exception("createTrimData failed:", e); } } @@ -519,7 +531,7 @@ public void createProductData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createProductData failed:", e); + throw new Exception("createProductData failed:", e); } } @@ -765,7 +777,7 @@ public void createCustomerData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createCustomerData failed:", e); + throw new Exception("createCustomerData failed:", e); } } @@ -818,7 +830,7 @@ public void createAliasOnlyData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createAliasOnlyData failed:", e); + throw new Exception("createAliasOnlyData failed:", e); } } @@ -938,7 +950,7 @@ public void createAliasData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createAliasData failed:", e); + throw new Exception("createAliasData failed:", e); } } @@ -1812,7 +1824,7 @@ public void createOrderData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createOrderData failed:", e); + throw new Exception("createOrderData failed:", e); } } @@ -1872,7 +1884,7 @@ public void createDepartmentEmployeeData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createDepartmentEmployeeData failed:", e); + throw new Exception("createDepartmentEmployeeData failed:", e); } } @@ -1937,10 +1949,11 @@ public void createPhoneData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createPhoneData failed:", e); + throw new Exception("createPhoneData failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -1948,11 +1961,13 @@ public void cleanup() throws Exception { super.cleanup(); } + @AfterEach public void cleanupNoData() throws Exception { TestUtil.logTrace("in cleanupNoData"); super.cleanup(); } + @AfterEach public void removeTestData() { TestUtil.logTrace("removeTestData"); if (getEntityTransaction().isActive()) { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/EntityGraph/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/EntityGraph/Client.java index fd089801b5..0b8bce7e4c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/EntityGraph/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/EntityGraph/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -40,42 +43,38 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); - displayMap(p); + super.setup(); + displayMap(new Properties()); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupEmployeeData(String[] args, Properties p) throws Exception { + public void setupEmployeeData() throws Exception { TestUtil.logTrace("setupOrderData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createEmployeeData(); - displayMap(p); + displayMap(new Properties()); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); } + @AfterEach public void cleanupEmployeeData() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -90,6 +89,7 @@ public void cleanupEmployeeData() throws Exception { * * @test_Strategy: Create attribute Nodes and retrieve them */ + @Test public void addAttributeNodesStringArrayTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -122,7 +122,7 @@ public void addAttributeNodesStringArrayTest() throws Exception { } if (!pass) { - throw new Fault("addAttributeNodesStringArrayTest failed"); + throw new Exception("addAttributeNodesStringArrayTest failed"); } } @@ -133,6 +133,7 @@ public void addAttributeNodesStringArrayTest() throws Exception { * * @test_Strategy: Create attribute Node that does not exist */ + @Test public void addAttributeNodesStringArrayIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -147,7 +148,7 @@ public void addAttributeNodesStringArrayIllegalArgumentExceptionTest() TestUtil.logTrace("Received expected IllegalArgumentException"); } if (!pass) { - throw new Fault( + throw new Exception( "addAttributeNodesStringArrayIllegalArgumentExceptionTest failed"); } } @@ -159,6 +160,7 @@ public void addAttributeNodesStringArrayIllegalArgumentExceptionTest() * * @test_Strategy: Create attribute Nodes via Attribute[] and retrieve them */ + @Test public void addAttributeNodesAttributeArrayTest() throws Exception { boolean pass = false; @@ -201,7 +203,7 @@ public void addAttributeNodesAttributeArrayTest() throws Exception { } if (!pass) { - throw new Fault("addAttributeNodesAttributeArrayTest failed"); + throw new Exception("addAttributeNodesAttributeArrayTest failed"); } } @@ -213,6 +215,7 @@ public void addAttributeNodesAttributeArrayTest() throws Exception { * @test_Strategy: Use createEntityGraph to create the named entity graphs in * the Employee entity */ + @Test public void createEntityGraphStringTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -242,7 +245,7 @@ public void createEntityGraphStringTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("createEntityGraphStringTest failed"); + throw new Exception("createEntityGraphStringTest failed"); } } @@ -254,6 +257,7 @@ public void createEntityGraphStringTest() throws Exception { * @test_Strategy: Use getEntityGraph to get the named entity graphs in the * Employee entity */ + @Test public void getEntityGraphStringTest() throws Exception { boolean pass = false; @@ -266,7 +270,7 @@ public void getEntityGraphStringTest() throws Exception { } if (!pass) { - throw new Fault("getEntityGraphStringTest failed"); + throw new Exception("getEntityGraphStringTest failed"); } } @@ -278,6 +282,7 @@ public void getEntityGraphStringTest() throws Exception { * @test_Strategy: Use getName to get the name of the named entity graph in * the Employee entity */ + @Test public void entityGraphGetNameTest() throws Exception { boolean pass = false; @@ -296,7 +301,7 @@ public void entityGraphGetNameTest() throws Exception { } if (!pass) { - throw new Fault("entityGraphGetNameTest failed"); + throw new Exception("entityGraphGetNameTest failed"); } } @@ -308,6 +313,7 @@ public void entityGraphGetNameTest() throws Exception { * @test_Strategy: Use getName to get the name of the named entity graph in * the Employee2 entity that has no name */ + @Test public void entityGraphGetNameNoNameExistsTest() throws Exception { boolean pass = false; @@ -327,7 +333,7 @@ public void entityGraphGetNameNoNameExistsTest() throws Exception { } if (!pass) { - throw new Fault("entityGraphGetNameNoNameExistsTest failed"); + throw new Exception("entityGraphGetNameNoNameExistsTest failed"); } } @@ -338,6 +344,7 @@ public void entityGraphGetNameNoNameExistsTest() throws Exception { * * @test_Strategy: Use getName to get the name of the entity graph */ + @Test public void getNameTest() throws Exception { boolean pass = false; @@ -352,7 +359,7 @@ public void getNameTest() throws Exception { } if (!pass) { - throw new Fault("getNameTest failed"); + throw new Exception("getNameTest failed"); } } @@ -363,6 +370,7 @@ public void getNameTest() throws Exception { * * @test_Strategy: get entity graph that does not exist */ + @Test public void getEntityGraphStringIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -374,7 +382,7 @@ public void getEntityGraphStringIllegalArgumentExceptionTest() throws Exception TestUtil.logTrace("Received expected IllegalArgumentException"); } if (!pass) { - throw new Fault( + throw new Exception( "getEntityGraphStringIllegalArgumentExceptionTest failed"); } } @@ -387,6 +395,7 @@ public void getEntityGraphStringIllegalArgumentExceptionTest() throws Exception * @test_Strategy: Use getEntityGraph to get the named entity graphs in the * Employee entity */ + @Test public void getEntityGraphsClassTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -422,7 +431,7 @@ public void getEntityGraphsClassTest() throws Exception { } if (!pass) { - throw new Fault("getEntityGraphsClassTest failed"); + throw new Exception("getEntityGraphsClassTest failed"); } } @@ -433,6 +442,7 @@ public void getEntityGraphsClassTest() throws Exception { * * @test_Strategy: add an entity graph as a named entitygraph */ + @Test public void addNamedEntityGraphStringEntityGraphTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -536,7 +546,7 @@ public void addNamedEntityGraphStringEntityGraphTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("addNamedEntityGraphStringEntityGraphTest failed"); + throw new Exception("addNamedEntityGraphStringEntityGraphTest failed"); } } @@ -547,6 +557,7 @@ public void addNamedEntityGraphStringEntityGraphTest() throws Exception { * * @test_Strategy: get entity graphs from a non entity class */ + @Test public void getEntityGraphsClassIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -558,7 +569,7 @@ public void getEntityGraphsClassIllegalArgumentExceptionTest() throws Exception TestUtil.logTrace("Received expected IllegalArgumentException"); } if (!pass) { - throw new Fault( + throw new Exception( "getEntityGraphsClassIllegalArgumentExceptionTest failed"); } } @@ -572,6 +583,7 @@ public void getEntityGraphsClassIllegalArgumentExceptionTest() throws Exception * @test_Strategy: test that various data contained in the annotations is * returnable */ + @Test public void annotationsTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -603,7 +615,7 @@ public void annotationsTest() throws Exception { } if (!pass) { - throw new Fault("annotationsTest failed"); + throw new Exception("annotationsTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/Client.java index 197d3a3226..95b63c4f13 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,24 +20,13 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -import java.util.Properties; -import java.util.Set; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.SetupMethod; +import org.junit.jupiter.api.AfterEach; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; -import jakarta.persistence.FlushModeType; -import jakarta.persistence.LockModeType; -import jakarta.persistence.NoResultException; -import jakarta.persistence.NonUniqueResultException; -import jakarta.persistence.Parameter; -import jakarta.persistence.ParameterMode; -import jakarta.persistence.Query; import jakarta.persistence.StoredProcedureQuery; -import jakarta.persistence.TemporalType; -import jakarta.persistence.TransactionRequiredException; public class Client extends PMClientBase { @@ -62,48 +51,8 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* - * setup() is called before each test - * - * @class.setup_props: jdbc.db; - */ - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - createEmployeeTestData(); - dataBaseName = p.getProperty("jdbc.db"); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - /* - * setupEmployee2Data() is called before each test - * - * @class.setup_props: jdbc.db; - */ - public void setupEmployee2Data(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - createEmployee2TestData(); - dataBaseName = p.getProperty("jdbc.db"); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -240,2564 +189,7 @@ public boolean verifyListEmployees(List expected, return result; } - /* - * @testName: executeTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1557; PERSISTENCE:SPEC:1515; - * PERSISTENCE:SPEC:1566; PERSISTENCE:SPEC:1568; PERSISTENCE:SPEC:1565; - * PERSISTENCE:SPEC:1572; PERSISTENCE:SPEC:1576; PERSISTENCE:SPEC:1577; - * PERSISTENCE:SPEC:1578; PERSISTENCE:SPEC:1580; - * - * @test_Strategy: - * - */ - public void executeTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - boolean pass3 = false; - - try { - getEntityTransaction().begin(); - try { - TestUtil.logMsg("Testing using name,class"); - clearCache(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(1, void.class, - ParameterMode.REF_CURSOR); - } - TestUtil.logTrace("executing:" + spq.toString()); - if (spq.execute()) { - - List listOfList = getResultSetsFromStoredProcedure(spq); - if (listOfList.size() == 1) { - List expected = new ArrayList(); - for (Employee e : empRef) { - expected.add(e.getId()); - } - pass1 = verifyEmployeeIds(expected, listOfList); - } else { - TestUtil.logErr( - "Did not get the correct number of result sets returned, expected: 1, actual:" - + listOfList.size()); - } - } else { - TestUtil.logErr("Expected execute() to return true, actual: false"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - try { - TestUtil.logMsg("Testing using name,result mapping"); - clearCache(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdFNameLNameFromRS", - "id-firstname-lastname"); - spq.registerStoredProcedureParameter(1, Integer.class, - ParameterMode.IN); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(2, void.class, - ParameterMode.REF_CURSOR); - } - spq.setParameter(1, 1); - if (spq.execute()) { - - List listOfList = getResultSetsFromStoredProcedure(spq); - if (listOfList.size() == 1) { - List expected = new ArrayList(); - expected.add(new Employee(emp0.getId(), emp0.getFirstName(), - emp0.getLastName())); - pass2 = verifyListOfListEmployees(expected, listOfList); - } else { - TestUtil.logErr( - "Did not get the correct number of result sets returned, expected: 1, actual:" - + listOfList.size()); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - try { - TestUtil.logMsg("Testing using named stored procedure"); - clearCache(); - StoredProcedureQuery spq; - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace( - "Calling refcursor specific named stored procedure query"); - spq = getEntityManager().createNamedStoredProcedureQuery( - "get-id-firstname-lastname-refcursor"); - } else { - spq = getEntityManager() - .createNamedStoredProcedureQuery("get-id-firstname-lastname"); - } - spq.setParameter(1, 1); - if (spq.execute()) { - List listOfList = getResultSetsFromStoredProcedure(spq); - if (listOfList.size() == 1) { - List expected = new ArrayList(); - expected.add(new Employee(emp0.getId(), emp0.getFirstName(), - emp0.getLastName())); - pass3 = verifyListOfListEmployees(expected, listOfList); - } else { - TestUtil.logErr( - "Did not get the correct number of result sets returned, expected: 1, actual:" - + listOfList.size()); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass1 || !pass2 || !pass3) { - throw new Fault("executeTest failed"); - } - - } - - /* - * @testName: getOutputParameterValueIntTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1547; PERSISTENCE:SPEC:1569; - * PERSISTENCE:SPEC:1570; PERSISTENCE:SPEC:1583; - * - * @test_Strategy: - * - */ - public void getOutputParameterValueIntTest() throws Exception { - boolean pass2 = false; - boolean pass4 = false; - boolean pass6 = false; - - Object oActual = null; - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Get the value from an OUT only parameter"); - StoredProcedureQuery spq3 = getEntityManager() - .createStoredProcedureQuery("GetEmpOneFirstNameFromOut"); - spq3.registerStoredProcedureParameter(1, String.class, ParameterMode.OUT); - if (!spq3.execute()) { - - oActual = spq3.getOutputParameterValue(1); - if (oActual instanceof String) { - String actual = (String) oActual; - if (actual.equals(emp0.getFirstName())) { - TestUtil.logTrace("Received expected result:" + actual); - pass6 = true; - } else { - TestUtil.logErr("Expected result: " + emp0.getFirstName() - + ", actual:" + actual); - } - } else { - TestUtil.logErr("Did not get instance of String, instead:" + oActual); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - try { - TestUtil.logMsg("Get the value from an IN and OUT parameter"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq1.setParameter(1, 1); - if (!spq1.execute()) { - - oActual = spq1.getOutputParameterValue(2); - if (oActual instanceof String) { - String actual = (String) oActual; - if (actual.equals(emp0.getFirstName())) { - TestUtil.logTrace("Received expected result:" + actual); - pass2 = true; - } else { - TestUtil.logErr("Expected result: " + emp0.getFirstName() - + ", actual:" + actual); - } - } else { - TestUtil.logErr("Did not get instance of String, instead:" + oActual); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - try { - TestUtil.logMsg("Get the value from an INOUT parameter"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq2.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq2.setParameter(1, "1"); - - if (!spq2.execute()) { - - oActual = spq2.getOutputParameterValue(1); - if (oActual instanceof String) { - String actual = (String) oActual; - if (actual.equals(emp0.getLastName())) { - TestUtil.logTrace("Received expected result:" + actual); - pass4 = true; - } else { - TestUtil.logErr("Expected result: " + emp0.getLastName() - + ", actual:" + actual); - } - } else { - TestUtil.logErr("Expected Integer to be returned, actual:" + oActual); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass2 || !pass4 || !pass6) { - throw new Fault("getOutputParameterValueIntTest failed"); - } - - } - - /* - * @testName: getOutputParameterValueIntIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1548; PERSISTENCE:SPEC:1302.4; - * - * @test_Strategy: - * - */ - public void getOutputParameterValueIntIllegalArgumentExceptionTest() - throws Exception { - boolean pass2 = false; - boolean pass4 = false; - - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Get a value that does not exist"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq1.setParameter(1, 1); - - if (!spq1.execute()) { - try { - spq1.getOutputParameterValue(99); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - if (getEntityTransaction().getRollbackOnly() != true) { - pass2 = true; - TestUtil.logTrace("Transaction was not marked for rollback"); - } else { - TestUtil.logErr( - "Transaction was marked for rollback and should not have been"); - } - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - TestUtil.logMsg("Get the value from an IN parameter"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq2.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq2.setParameter(1, "1"); - - if (!spq2.execute()) { - try { - spq2.getOutputParameterValue(99); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass4 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass2 || !pass4) { - throw new Fault( - "getOutputParameterValueIntIllegalArgumentExceptionTest failed"); - } - - } - - /* - * @testName: getFirstResultTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1585; PERSISTENCE:JAVADOC:3482; - * PERSISTENCE:SPEC:1515; - * - * @test_Strategy: - * - */ - public void getFirstResultTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - boolean pass3 = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(1, void.class, - ParameterMode.REF_CURSOR); - } - int num = spq.getFirstResult(); - if (num == 0) { - TestUtil - .logTrace("Received expected first result when none is set:" + num); - pass1 = true; - } else { - TestUtil - .logErr("Expected first result when none is set: 0, actual:" + num); - } - - List actual = spq.getResultList(); - num = spq.getFirstResult(); - if (num == 0) { - TestUtil.logTrace( - "Received expected first result:" + num + " after getResultList"); - pass2 = true; - } else { - TestUtil.logErr( - "Expected first result: 0, actual:" + num + " after getResultList"); - } - if (actual.size() > 0) { - pass3 = verifyListEmployees(empRef, actual); - } else { - TestUtil.logErr("getResultList() returned 0 results"); - } - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass1 || !pass2 || !pass3) { - throw new Fault("getFirstResultTest failed"); - } - - } - - /* - * @testName: getMaxResultsTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1590; - * - * @test_Strategy: - * - */ - public void getMaxResultsTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - boolean pass3 = false; - - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(1, void.class, - ParameterMode.REF_CURSOR); - } - int num = spq.getMaxResults(); - if (num == Integer.MAX_VALUE) { - TestUtil.logTrace("Received expected max result:" + num); - pass1 = true; - } else { - TestUtil.logErr( - "Expected max result: " + Integer.MAX_VALUE + ", actual:" + num); - } - List actual = spq.getResultList(); - num = spq.getMaxResults(); - if (num == Integer.MAX_VALUE) { - TestUtil.logTrace( - "Received expected max result:" + num + " after getResultList"); - pass2 = true; - } else { - TestUtil.logErr("Expected max result:" + Integer.MAX_VALUE + ", actual:" - + num + " after getResultList"); - } - if (actual.size() > 0) { - pass3 = verifyListEmployees(empRef, actual); - } else { - TestUtil.logErr("getResultList() returned 0 results"); - } - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass1 || !pass2 || !pass3) { - throw new Fault("getMaxResultsTest failed"); - } - - } - - /* - * @testName: getSingleResultTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:3482; PERSISTENCE:SPEC:1515; - * - * @test_Strategy: Get single result from returned resultset. - * - */ - public void getSingleResultTest() throws Exception { - boolean pass = false; - - try { - getEntityTransaction().begin(); - clearCache(); - - StoredProcedureQuery spq = getEntityManager().createStoredProcedureQuery( - "GetEmpIdFNameLNameFromRS", "id-firstname-lastname"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(2, void.class, - ParameterMode.REF_CURSOR); - } - spq.setParameter(1, 1); - Employee expected = new Employee(emp0.getId(), emp0.getFirstName(), - emp0.getLastName()); - Object o = spq.getSingleResult(); - if (o instanceof Employee) { - Employee actual = (Employee) o; - if (actual.equals(expected)) { - TestUtil.logTrace("Received expected result:" + actual); - pass = true; - } else { - TestUtil.logErr("Expected result:" + expected + ", actual:" + actual); - } - } else { - TestUtil.logErr("Did not get Integer result:" + o); - } - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass) { - throw new Fault("getSingleResultTest failed"); - } - - } - - /* - * @testName: getSingleResultNoResultExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:3483 - * - * @test_Strategy: Get single result from returned resultset that is empty - * - */ - public void getSingleResultNoResultExceptionTest() throws Exception { - boolean pass = false; - - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdFNameLNameFromRS"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(2, void.class, - ParameterMode.REF_CURSOR); - } - spq.setParameter(1, 99); - try { - spq.getSingleResult(); - TestUtil.logErr("Did not throw NoResultException"); - } catch (NoResultException nre) { - TestUtil.logTrace("Received expected NoResultException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass) { - throw new Fault("getSingleResultNoResultExceptionTest failed"); - } - - } - - /* - * @testName: getSingleResultNonUniqueResultExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:3484 - * - * @test_Strategy: Get single result from returned resultset that contains - * multiple values - * - */ - public void getSingleResultNonUniqueResultExceptionTest() throws Exception { - boolean pass = false; - - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(1, void.class, - ParameterMode.REF_CURSOR); - } - try { - spq.getSingleResult(); - TestUtil.logErr("Did not throw NonUniqueResultException"); - } catch (NonUniqueResultException nure) { - TestUtil.logTrace("Received expected NonUniqueResultException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass) { - throw new Fault("getSingleResultNonUniqueResultExceptionTest failed"); - } - - } - - /* - * @testName: setgetFlushModeTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1586; PERSISTENCE:JAVADOC:1559; - * - * @test_Strategy: Set and Get the various flushModes of a Query - */ - - public void setgetFlushModeTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - - try { - TestUtil.logMsg("Testing StoredProcedureQuery"); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(1, void.class, - ParameterMode.REF_CURSOR); - } - FlushModeType fmt = spq.getFlushMode(); - if (fmt != null) { - if (fmt.equals(getEntityManager().getFlushMode())) { - TestUtil.logTrace("Setting mode to returned default mode"); - spq.setFlushMode(fmt); - TestUtil.logTrace("Setting mode to FlushModeType.COMMIT"); - spq.setFlushMode(FlushModeType.COMMIT); - fmt = spq.getFlushMode(); - if (fmt.equals(FlushModeType.COMMIT)) { - TestUtil.logTrace("Setting mode to FlushModeType.AUTO"); - spq.setFlushMode(FlushModeType.AUTO); - fmt = spq.getFlushMode(); - if (fmt.equals(FlushModeType.AUTO)) { - TestUtil.logTrace("Query object returned from setFlushMode"); - Query q = spq.setFlushMode(FlushModeType.COMMIT); - fmt = q.getFlushMode(); - if (fmt.equals(FlushModeType.COMMIT)) { - TestUtil.logTrace( - "Received expected Query FlushModeType:" + fmt.name()); - pass1 = true; - } else { - TestUtil.logErr("Expected a value of:" - + FlushModeType.COMMIT.name() + ", actual:" + fmt.name()); - } - } else { - TestUtil.logErr("Expected a value of:" + FlushModeType.AUTO.name() - + ", actual:" + fmt.name()); - } - } else { - TestUtil.logErr("Expected a default value of:" - + FlushModeType.COMMIT.name() + ", actual:" + fmt.name()); - } - } else { - TestUtil.logErr("Expected EntityManager value of:" - + getEntityManager().getFlushMode() + ", actual:" + fmt.name()); - } - } else { - TestUtil.logErr("getFlushMode return null"); - } - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing Query object returned from setFlushMode"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); - - TestUtil.logTrace("Setting mode to FlushModeType.AUTO"); - Query q = spq2.setFlushMode(FlushModeType.AUTO); - FlushModeType fmt = q.getFlushMode(); - if (fmt.equals(FlushModeType.AUTO)) { - TestUtil.logTrace("Received expected value of:" + fmt.name()); - pass2 = true; - } else { - TestUtil.logErr("Expected a value of:" + FlushModeType.AUTO.name() - + ", actual:" + fmt.name()); - } - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass1 || !pass2) - throw new Fault("setgetFlushModeTest failed"); - } - - /* - * @testName: setLockModeIllegalStateExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1637; - * - * @test_Strategy: - */ - - public void setLockModeIllegalStateExceptionTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("UpdateEmpSalaryColumn"); - try { - spq.setLockMode(LockModeType.PESSIMISTIC_READ); - TestUtil.logErr("Did not throw IllegalStateException"); - } catch (IllegalStateException ise) { - TestUtil.logTrace("Received expected IllegalStateException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass) - throw new Fault("setLockModeIllegalStateExceptionTest failed"); - } - /* - * @testName: getLockModeIllegalStateExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1589; - * - * @test_Strategy: - */ - - public void getLockModeIllegalStateExceptionTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("UpdateEmpSalaryColumn"); - try { - spq.getLockMode(); - TestUtil.logErr("Did not throw IllegalStateException"); - } catch (IllegalStateException ise) { - TestUtil.logTrace("Received expected IllegalStateException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass) - throw new Fault("getLockModeIllegalStateExceptionTest failed"); - } - - /* - * @testName: setGetParameterIntTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1597; PERSISTENCE:JAVADOC:1574; - * - * @test_Strategy: - */ - - public void setGetParameterIntTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Testing StoredProcedureQuery"); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - Parameter p = spq.getParameter(1); - int pos = p.getPosition(); - if (pos == 1) { - TestUtil.logTrace("Received expected parameter:" + pos); - pass1 = true; - } else { - TestUtil.logErr("Expected position: 1, actual:" + pos); - } - - TestUtil.logMsg("Testing Query object returned from getParameter"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - Query q = spq2.setParameter(1, 1); - p = q.getParameter(1); - pos = p.getPosition(); - if (pos == 1) { - TestUtil.logTrace("Received expected parameter:" + pos); - pass2 = true; - } else { - TestUtil.logErr("Expected position: 1, actual:" + pos); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass1 || !pass2) - throw new Fault("setGetParameterIntTest failed"); - } - - // disabling this test since Store Procedures with named parameters - // isn't supported by all DB's at this time - /* - * testName: setGetParameterStringTest assertion_ids: - * PERSISTENCE:JAVADOC:1549; PERSISTENCE:JAVADOC:1558; - * PERSISTENCE:JAVADOC:1568; PERSISTENCE:JAVADOC:1591; test_Strategy: - */ - - /* - * public void setGetParameterStringTest() throws Exception { boolean pass1 = - * false; boolean pass2 = false; boolean pass3 = false; try { - * getEntityTransaction().begin(); - * - * TestUtil.logMsg("Testing StoredProcedureQuery"); StoredProcedureQuery spq = - * getEntityManager().createStoredProcedureQuery("GetEmpFirstNameFromOut"); - * spq.registerStoredProcedureParameter("IN_PARAM", Integer.class, - * ParameterMode.IN); spq.registerStoredProcedureParameter("OUT_PARAM", - * String.class, ParameterMode.OUT); spq.setParameter("IN_PARAM", 1); - * - * Parameter p = spq.getParameter("OUT_PARAM"); Integer pos = p.getPosition(); - * if (pos == null){ TestUtil.logTrace("Received expected null"); pass1 = - * true; } else { TestUtil.logErr("Expected position: null, actual:" + pos); } - * - * spq.execute(); Object oActual = spq.getOutputParameterValue("OUT_PARAM"); - * if (oActual instanceof String) { String actual = (String) oActual; if - * (actual.equals(emp0.getFirstName())) { - * TestUtil.logTrace("Received expected result:" + actual); pass2 = true; } - * else { TestUtil.logErr("Expected result: " + emp0.getFirstName() + - * ", actual:" + actual); } } else { - * TestUtil.logErr("Did not get instance of String, instead:" + - * oActual.getClass()); } getEntityTransaction().commit(); - * - * } catch (Exception e) { TestUtil.logErr("Caught exception: ", e); } - * - * if (!pass1 || !pass2 ) throw new Fault("setGetParameterStringTest failed"); - * } - */ - - /* - * @testName: getParameterStringExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1609; PERSISTENCE:JAVADOC:1569; - * - * @test_Strategy: - */ - - public void getParameterStringExceptionTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - TestUtil.logMsg("Testing StoredProcedureQuery "); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter("ID", Integer.class, - ParameterMode.IN); - spq.registerStoredProcedureParameter("FIRSTNAME", String.class, - ParameterMode.OUT); - spq.setParameter("ID", 1); - try { - spq.getParameter("DOESNOTEXIST"); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (IllegalStateException ise) { - TestUtil.logTrace("Received expected IllegalStateException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg("Testing Query object returned from getParameter"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq2.registerStoredProcedureParameter("ID", Integer.class, - ParameterMode.IN); - spq2.registerStoredProcedureParameter("FIRSTNAME", String.class, - ParameterMode.OUT); - Query q = spq2.setParameter("ID", 1); - try { - q.getParameter("DOESNOTEXIST"); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (IllegalStateException ise) { - TestUtil.logTrace("Received expected IllegalStateException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1 || !pass2) - throw new Fault("getParameterStringExceptionTest failed"); - } - - /* - * @testName: getParameterIntIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1598; - * - * @test_Strategy: - */ - - public void getParameterIntIllegalArgumentExceptionTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - TestUtil.logMsg("Testing StoredProcedureQuery "); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - try { - spq.getParameter(99); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg("Testing Query object returned from getParameter"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - Query q = spq2.setParameter(1, 1); - try { - q.getParameter(99); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1 || !pass2) - throw new Fault("getParameterIntIllegalArgumentExceptionTest failed"); - } - - /* - * @testName: setParameterParameterObjectTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1562; - * - * @test_Strategy: - */ - - public void setParameterParameterObjectTest() throws Exception { - boolean pass2 = false; - boolean pass4 = false; - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Testing StoredProcedureQuery "); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 99); - Parameter p = spq.getParameter(1); - spq.setParameter(p, 1); - - if (!spq.execute()) { - Object oActual = spq.getOutputParameterValue(2); - if (oActual instanceof String) { - String actual = (String) oActual; - if (actual.equals(emp0.getFirstName())) { - TestUtil.logTrace("Received expected result:" + actual); - pass2 = true; - } else { - TestUtil.logErr("Expected result: " + emp0.getFirstName() - + ", actual:" + actual); - } - } else { - TestUtil.logErr( - "Did not get instance of String, instead:" + oActual.getClass()); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Testing Query object returned from setParameter"); - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - Query q = spq2; - q.setParameter(1, 99); - Parameter p = q.getParameter(1); - q.setParameter(p, 1); - StoredProcedureQuery spq3 = (StoredProcedureQuery) q; - if (!spq3.execute()) { - Object oActual = spq3.getOutputParameterValue(2); - if (oActual instanceof String) { - String actual = (String) oActual; - if (actual.equals(emp0.getFirstName())) { - TestUtil.logTrace("Received expected result:" + actual); - pass4 = true; - } else { - TestUtil.logErr("Expected result: " + emp0.getFirstName() - + ", actual:" + actual); - } - } else { - TestUtil.logErr("Did not get instance of String, instead:" + oActual); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - - if (!pass2 || !pass4) - throw new Fault("setParameterParameterObjectTest failed"); - - } - - /* - * @testName: setParameterParameterObjectIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1563; - * - * @test_Strategy: call setParameter(Parameter, Object) using parameter from - * different query. - */ - - public void setParameterParameterObjectIllegalArgumentExceptionTest() - throws Exception { - boolean pass1 = false; - try { - getEntityTransaction().begin(); - - TestUtil.logTrace("Get parameter from other stored procedure"); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq.setParameter(1, "INOUT"); - // Parameter to be used in next StoredProcedure - Parameter p = spq.getParameter(1); - - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - - try { - spq2.setParameter(p, 1); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1) - throw new Fault( - "setParameterParameterObjectIllegalArgumentExceptionTest failed"); - } - - /* - * @testName: setParameterIntObjectIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1575; - * - * @test_Strategy: - */ - public void setParameterIntObjectIllegalArgumentExceptionTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - boolean pass3 = false; - boolean pass4 = false; - try { - getEntityTransaction().begin(); - TestUtil.logMsg( - "Testing StoredProcedureQuery with incorrect position specified"); - - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - try { - spq1.setParameter(99, 1); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil - .logMsg("Testing StoredProcedureQuery with incorrect type specified"); - - StoredProcedureQuery spq2 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - try { - spq2.setParameter(1, new java.util.Date()); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg("Testing Query object with incorrect position specified"); - StoredProcedureQuery spq3 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq3.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq3.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - Query q1 = spq3.setParameter(1, 1); - try { - spq3.setParameter(99, 1); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass3 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg("Testing Query object with incorrect type specified"); - StoredProcedureQuery spq4 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq4.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq4.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - Query q2 = spq4.setParameter(1, 1); - try { - q2.setParameter(1, new java.util.Date()); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass4 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1 || !pass2 || !pass3 || !pass4) - throw new Fault( - "setParameterIntObjectIllegalArgumentExceptionTest failed"); - } - - /* - * @testName: getParametersTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1597; PERSISTENCE:JAVADOC:1603; - * - * @test_Strategy: - */ - - public void getParametersTest() throws Exception { - boolean pass1 = false; - boolean pass3 = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - Set> p1 = spq.getParameters(); - if (p1.size() == 0) { - TestUtil - .logTrace("Received expected number of parameters when non exist:" - + p1.size()); - pass1 = true; - } else { - TestUtil.logErr( - "Expected number of parameters when non exist: 0, actual:" + p1); - } - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - - if (!spq.execute()) { - Set> p2 = spq.getParameters(); - if (p2.size() == 2) { - TestUtil - .logTrace("Received expected number of parameters:" + p2.size()); - pass3 = true; - } else { - TestUtil - .logErr("Expected number of parameters: 2, actual:" + p2.size()); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass1 || !pass3) - throw new Fault("getParametersTest failed"); - - } - - /* - * @testName: setParameterIntCalendarTemporalTypeTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1576; - * - * @test_Strategy: - */ - @SetupMethod(name = "setupEmployee2Data") - public void setParameterIntCalendarTemporalTypeTest() throws Exception { - boolean pass2 = false; - boolean pass4 = false; - try { - getEntityTransaction().begin(); - try { - TestUtil.logMsg("Testing StoredProcedureQuery object"); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - spq.registerStoredProcedureParameter(2, Integer.class, - ParameterMode.OUT); - spq.setParameter(1, calDate, TemporalType.DATE); - - if (!spq.execute()) { - Object o = spq.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == emp2.getId()) { - TestUtil.logTrace("Received expected id:" + actual); - pass2 = true; - } else { - TestUtil.logErr( - "Expected id: " + emp2.getId() + ", actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing Query object"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, Integer.class, - ParameterMode.OUT); - Query q = spq1; - q.setParameter(1, getCalDate(), TemporalType.DATE); - StoredProcedureQuery spq2 = (StoredProcedureQuery) q; - if (!spq2.execute()) { - Object o = spq2.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == 5) { - TestUtil.logTrace("Received expected id:" + actual); - pass4 = true; - } else { - TestUtil.logErr("Expected id: 5, actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass2 || !pass4) - throw new Fault("setParameterIntCalendarTemporalTypeTest failed"); - - } - - /* - * @testName: setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1577; - * - * @test_Strategy: - */ - @SetupMethod(name = "setupEmployee2Data") - public void setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest() - throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - TestUtil.logMsg( - "Testing StoredProcedureQuery with incorrect position specified"); - - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - try { - spq1.setParameter(99, getCalDate(), TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg("Testing Query object with incorrect position specified"); - StoredProcedureQuery spq3 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq3.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - Query q1 = spq3.setParameter(1, getCalDate(), TemporalType.DATE); - try { - q1.setParameter(99, getCalDate()); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - if (!pass1 || !pass2) - throw new Fault( - "setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest failed"); - - } - - /* - * @testName: setParameterIntDateTemporalTypeTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1578; - * - * @test_Strategy: - */ - - public void setParameterIntDateTemporalTypeTest() throws Exception { - boolean pass2 = false; - boolean pass4 = false; - try { - getEntityTransaction().begin(); - try { - TestUtil.logMsg("Testing StoredProcedureQuery"); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, Integer.class, - ParameterMode.OUT); - spq.setParameter(1, utilDate, TemporalType.DATE); - - if (!spq.execute()) { - - Object o = spq.getOutputParameterValue(2); - if (o instanceof Integer) { - Integer actual = (Integer) o; - if (actual == 1) { - TestUtil.logTrace("Received expected id:" + actual); - pass2 = true; - } else { - TestUtil.logErr("Expected id: 1, actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing Query object"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, Integer.class, - ParameterMode.OUT); - Query q = spq1; - q.setParameter(1, utilDate, TemporalType.DATE); - StoredProcedureQuery spq2 = (StoredProcedureQuery) q; - - if (!spq2.execute()) { - - Object o = spq2.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == 1) { - TestUtil.logTrace("Received expected id:" + actual); - pass4 = true; - } else { - TestUtil.logErr("Expected id: 1, actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass2 || !pass4) - throw new Fault("setParameterIntDateTemporalTypeTest failed"); - - } - - /* - * @testName: setParameterIntDateTemporalTypeIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1579; - * - * @test_Strategy: - */ - - public void setParameterIntDateTemporalTypeIllegalArgumentExceptionTest() - throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - TestUtil.logMsg( - "Testing StoredProcedureQuery with incorrect position specified"); - - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - try { - spq1.setParameter(99, utilDate, TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg("Testing Query object with incorrect position specified"); - StoredProcedureQuery spq3 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq3.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - Query q1 = spq3.setParameter(1, getUtilDate()); - try { - q1.setParameter(99, utilDate, TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1 || !pass2) - throw new Fault( - "setParameterIntDateTemporalTypeIllegalArgumentExceptionTest failed"); - } - - /* - * @testName: setParameterParameterCalendarTemporalTypeTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1564; PERSISTENCE:SPEC:1576; - * - * @test_Strategy: - */ - @SetupMethod(name = "setupEmployee2Data") - public void setParameterParameterCalendarTemporalTypeTest() throws Exception { - boolean pass2 = false; - boolean pass3 = false; - boolean pass5 = false; - try { - TestUtil.logMsg("Testing StoredProcedure"); - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq.registerStoredProcedureParameter(1, Calendar.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, Integer.class, ParameterMode.OUT); - - spq.setParameter(1, getCalDate(), TemporalType.DATE); - Parameter p = spq.getParameter(1); - spq.setParameter(p, calDate, TemporalType.DATE); - - if (!spq.execute()) { - Object o = spq.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == emp2.getId()) { - TestUtil.logTrace("Received expected id:" + actual); - pass2 = true; - } else { - TestUtil - .logErr("Expected id: " + emp2.getId() + ", actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - try { - getEntityTransaction().begin(); - TestUtil.logMsg("Testing Query object"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, Integer.class, - ParameterMode.OUT); - spq1.setParameter(1, getCalDate(), TemporalType.DATE); - Query q = spq1; - - Parameter p = q.getParameter(1); - q.setParameter(p, calDate, TemporalType.DATE); - Parameter p2 = q.getParameter(1); - if (p.getPosition().equals(p2.getPosition()) - && p.getParameterType().equals(p2.getParameterType())) { - TestUtil.logTrace("Received expected parameter"); - pass3 = true; - } else { - TestUtil.logErr("Expected parameter:" + p + ", actual:" + p2); - } - - StoredProcedureQuery spq2 = (StoredProcedureQuery) q; - - if (!spq2.execute()) { - Object o = spq2.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == emp2.getId()) { - TestUtil.logTrace("Received expected id:" + actual); - pass5 = true; - } else { - TestUtil - .logErr("Expected id: " + emp2.getId() + ", actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - - if (!pass2 || !pass3 || !pass5) - throw new Fault("setParameterParameterCalendarTemporalTypeTest failed"); - } - - /* - * @testName: - * setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1565; - * - * @test_Strategy: - */ - @SetupMethod(name = "setupEmployee2Data") - public void setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest() - throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - TestUtil.logTrace("Get parameter from other stored procedure"); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq.setParameter(1, "INOUT"); - // Parameter to be used in next StoredProcedure - Parameter p = spq.getParameter(1); - - TestUtil.logMsg( - "Testing StoredProcedureQuery with parameter specified from another query"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - spq1.setParameter(1, getCalDate(), TemporalType.DATE); - try { - spq1.setParameter(p, getCalDate(), TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg( - "Testing Query object with parameter specified from another query"); - StoredProcedureQuery spq3 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq3.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - Query q1 = spq3.setParameter(1, getCalDate()); - try { - q1.setParameter(p, getCalDate(), TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1 || !pass2) - throw new Fault( - "setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest failed"); - } - - /* - * @testName: setParameterParameterDateTemporalTypeTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1566; - * - * @test_Strategy: - */ - public void setParameterParameterDateTemporalTypeTest() throws Exception { - boolean pass2 = false; - boolean pass3 = false; - boolean pass5 = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, Integer.class, ParameterMode.OUT); - spq.setParameter(1, getUtilDate(), TemporalType.DATE); - - Parameter p = spq.getParameter(1); - spq.setParameter(p, utilDate, TemporalType.DATE); - - if (!spq.execute()) { - Object o = spq.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == 1) { - TestUtil.logTrace("Received expected id:" + actual); - pass2 = true; - } else { - TestUtil.logErr("Expected id: 1, actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Testing Query object"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, Integer.class, - ParameterMode.OUT); - spq1.setParameter(1, getCalDate().getTime(), TemporalType.DATE); - - Query q = spq1; - - // override the previously set parameter - Parameter p = q.getParameter(1); - q.setParameter(p, utilDate, TemporalType.DATE); - - Parameter p2 = q.getParameter(1); - if (p.getPosition().equals(p2.getPosition()) - && p.getParameterType().equals(p2.getParameterType())) { - TestUtil.logTrace("Received expected parameter"); - pass3 = true; - } else { - TestUtil.logErr("Expected parameter:" + p + ", actual:" + p2); - } - StoredProcedureQuery spq2 = (StoredProcedureQuery) q; - if (!spq2.execute()) { - - Object o = spq2.getOutputParameterValue(2); - if (o instanceof Integer) { - int actual = (Integer) o; - if (actual == emp0.getId()) { - TestUtil.logTrace("Received expected id:" + actual); - pass5 = true; - } else { - TestUtil.logErr("Expected id: 1, actual:" + actual); - } - - } else { - TestUtil.logErr("Did not get instance of Integer back:" + o); - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - - if (!pass2 || !pass3 || !pass5) - throw new Fault("setParameterParameterDateTemporalTypeTest failed"); - } - - /* - * @testName: - * setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1567; - * - * @test_Strategy: - */ - - public void setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest() - throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - TestUtil.logTrace("Get parameter from other stored procedure"); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq.setParameter(1, "INOUT"); - // Parameter to be used in next StoredProcedure - Parameter p = spq.getParameter(1); - TestUtil.logMsg( - "Testing StoredProcedureQuery with parameter specified from another query"); - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); - spq1.setParameter(1, getUtilDate(), TemporalType.DATE); - try { - spq1.setParameter(p, getUtilDate(), TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass1 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - TestUtil.logMsg( - "Testing Query object with parameter specified from another query"); - StoredProcedureQuery spq3 = getEntityManager() - .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); - spq3.registerStoredProcedureParameter(1, Calendar.class, - ParameterMode.IN); - Query q1 = spq3.setParameter(1, getCalDate()); - try { - q1.setParameter(p, getCalDate(), TemporalType.DATE); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - - } catch (Exception e) { - TestUtil.logErr("Caught exception", e); - } - - if (!pass1 || !pass2) - throw new Fault( - "setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest failed"); - } - - /* - * @testName: executeUpdateOfAnUpdateTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1580; PERSISTENCE:JAVADOC:1551; - * PERSISTENCE:SPEC:1516; PERSISTENCE:SPEC:1580; - * - * @test_Strategy: - */ - public void executeUpdateOfAnUpdateTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("UpdateEmpSalaryColumn"); - - spq.executeUpdate(); - int updateCount = spq.getUpdateCount(); - if (updateCount == -1) { - TestUtil.logTrace("Received expected update count:" + updateCount); - pass = true; - } else { - TestUtil.logErr("Expected update count: -1, actual:" + updateCount); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("executeUpdateOfAnUpdateTest failed"); - } - - /* - * @testName: executeUpdateOfADeleteTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1580; PERSISTENCE:JAVADOC:1551; - * PERSISTENCE:SPEC:1516; - * - * @test_Strategy: - */ - public void executeUpdateOfADeleteTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("DeleteAllEmp"); - spq.executeUpdate(); - int updateCount = spq.getUpdateCount(); - if (updateCount == -1) { - TestUtil.logTrace("Received expected update count:" + updateCount); - pass = true; - } else { - TestUtil.logErr("Expected update count: -1, actual:" + updateCount); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("executeUpdateOfADeleteTest failed"); - } - - /* - * @testName: executeUpdateTransactionRequiredExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1582; - * - * @test_Strategy: - */ - public void executeUpdateTransactionRequiredExceptionTest() throws Exception { - boolean pass = false; - try { - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("DeleteAllEmp"); - try { - TestUtil - .logMsg("IsActive returns:" + getEntityTransaction().isActive()); - spq.executeUpdate(); - TestUtil.logErr("Did not throw TransactionRequiredException"); - } catch (TransactionRequiredException tre) { - TestUtil.logTrace("Received expected TransactionRequiredException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("executeUpdateTransactionRequiredExceptionTest failed"); - } - - /* - * @testName: getParameterValueParameterTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1605; PERSISTENCE:JAVADOC:1630; - * - * @test_Strategy: - */ - public void getParameterValueParameterTest() throws Exception { - boolean pass1 = false; - boolean pass3 = false; - try { - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - Parameter p = spq.getParameter(1); - boolean b = spq.isBound(p); - if (b == true) { - TestUtil.logTrace("Received expected from isBound():" + b); - pass1 = true; - } else { - TestUtil.logErr("Expected result from isBound():true, actual:" + b); - } - if (!spq.execute()) { - p = spq.getParameter(1); - Object o = spq.getParameterValue(p); - if (o instanceof Integer) { - TestUtil.logTrace("Received expected parameter type: Integer"); - Integer i = (Integer) o; - if (i.equals(emp0.getId())) { - TestUtil.logTrace("Received expected parameter value:" + i); - pass3 = true; - } else { - TestUtil.logErr("Expected getParameterValue() result: " - + emp0.getId() + ", actual:" + i); - } - - } else { - TestUtil.logErr( - "Did not get instance of Integer from getParameterValue():" + o); - } - - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass1 || !pass3) - throw new Fault("getParameterValueParameterTest failed"); - - } - - /* - * @testName: getParameterValueParameterIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1606; - * - * @test_Strategy: execute getParameterValue using parameter from different - * query - */ - public void getParameterValueParameterIllegalArgumentExceptionTest() - throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq.setParameter(1, "1"); - Parameter p = spq.getParameter(1); - - StoredProcedureQuery spq1 = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq1.setParameter(1, 1); - try { - spq1.getParameterValue(p); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault( - "getParameterValueParameterIllegalArgumentExceptionTest failed"); - - } - - /* - * @testName: getParameterValueParameterIllegalStateExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1607; PERSISTENCE:JAVADOC:1630; - * - * @test_Strategy: - */ - public void getParameterValueParameterIllegalStateExceptionTest() - throws Exception { - boolean pass1 = false; - boolean pass2 = false; - try { - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - Parameter p = spq.getParameter(1); - boolean b = spq.isBound(p); - if (b == true) { - TestUtil.logTrace("Received expected from isBound():" + b); - pass1 = true; - } else { - TestUtil.logErr("Expected result from isBound():true, actual:" + b); - } - Parameter p2 = spq.getParameter(2); - - try { - spq.getParameterValue(p2); - TestUtil.logErr("Did not throw IllegalStateException"); - } catch (IllegalStateException iae) { - TestUtil.logTrace("Received expected IllegalStateException"); - pass2 = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass1 || !pass2) - throw new Fault( - "getParameterValueParameterIllegalStateExceptionTest failed"); - - } - - /* - * @testName: getParameterValueIntTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1611; PERSISTENCE:SPEC:1572; - * - * @test_Strategy: - */ - public void getParameterValueIntTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - boolean pass3 = false; - boolean pass4 = false; - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Testing createStoredProcedureQuery"); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpLastNameFromInOut"); - spq.registerStoredProcedureParameter(1, String.class, - ParameterMode.INOUT); - spq.setParameter(1, "1"); - Object o = spq.getParameterValue(1); - if (o instanceof String) { - TestUtil.logTrace("Received expected parameter type: String"); - String s = (String) o; - if (s.equals("1")) { - TestUtil.logTrace("Received expected parameter value:" + s); - pass1 = true; - } else { - TestUtil - .logErr("Expected getParameterValue() result: 1, actual:" + s); - } - - } else { - TestUtil.logErr( - "Did not get instance of String from getParameterValue():" + o); - } - - if (!spq.execute()) { - o = spq.getParameterValue(1); - if (o instanceof String) { - TestUtil.logTrace("Received expected parameter type: String"); - String s = (String) o; - if (s.equals("1")) { - TestUtil.logTrace("Received expected parameter value:" + s); - pass2 = true; - } else { - TestUtil - .logErr("Expected getParameterValue() result: 1, actual:" + s); - } - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Testing createNamedStoredProcedureQuery"); - StoredProcedureQuery spq = getEntityManager() - .createNamedStoredProcedureQuery("getemplastnamefrominout"); - spq.setParameter(1, "1"); - Object o = spq.getParameterValue(1); - if (o instanceof String) { - TestUtil.logTrace("Received expected parameter type: String"); - String s = (String) o; - if (s.equals("1")) { - TestUtil.logTrace("Received expected parameter value:" + s); - pass3 = true; - } else { - TestUtil - .logErr("Expected getParameterValue() result: 1, actual:" + s); - } - - } else { - TestUtil.logErr( - "Did not get instance of String from getParameterValue():" + o); - } - - if (!spq.execute()) { - o = spq.getParameterValue(1); - if (o instanceof String) { - TestUtil.logTrace("Received expected parameter type: String"); - String s = (String) o; - if (s.equals("1")) { - TestUtil.logTrace("Received expected parameter value:" + s); - pass4 = true; - } else { - TestUtil - .logErr("Expected getParameterValue() result: 1, actual:" + s); - } - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } - - if (!pass1 || !pass2 || !pass3 || !pass4) - throw new Fault("getParameterValueIntTest failed"); - - } - - /* - * @testName: getParameterValueIntIllegalArgumentExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1613; - * - * @test_Strategy: - */ - - public void getParameterValueIntIllegalArgumentExceptionTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - try { - spq.getParameterValue(99); - TestUtil.logErr("Did not throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - TestUtil.logTrace("Received expected IllegalArgumentException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault( - "getParameterValueIntIllegalArgumentExceptionTest failed"); - - } - - /* - * @testName: getParameterValueIntIllegalStateExceptionTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1612; - * - * @test_Strategy: - */ - public void getParameterValueIntIllegalStateExceptionTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - try { - spq.getParameterValue(2); - TestUtil.logErr("Did not throw IllegalStateException"); - } catch (IllegalStateException iae) { - TestUtil.logTrace("Received expected IllegalStateException"); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Caught unexpected exception", e); - } - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("getParameterValueIntIllegalStateExceptionTest failed"); - - } - - /* - * @testName: setHintStringObjectTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:1560; - * - * @test_Strategy: Vendor-specific hints that are not recognized by a provider - * must be silently ignored. - */ - public void setHintStringObjectTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpFirstNameFromOut"); - spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); - spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); - spq.setParameter(1, 1); - spq.getParameterValue(1); - spq.setHint("property.that.is.not.recognized", - "property.that.is.not.recognized"); - spq.execute(); - getEntityTransaction().commit(); - pass = true; - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("setHintStringObjectTest failed"); - - } - - /* - * @testName: xmlOverridesNamedStoredProcedureQueryTest - * - * @assertion_ids: PERSISTENCE:SPEC:2239; PERSISTENCE:SPEC:2241; - * PERSISTENCE:SPEC:2242; - * - * @test_Strategy: verify xml overrides NamedStoredProcedureQuery annotation - */ - public void xmlOverridesNamedStoredProcedureQueryTest() throws Exception { - boolean pass1 = false; - boolean pass2 = false; - - try { - - StoredProcedureQuery spq = getEntityManager() - .createNamedStoredProcedureQuery("tobeoverridden1"); - spq.setParameter(1, 1); - Object o = spq.getParameterValue(1); - if (o instanceof Integer) { - TestUtil.logTrace("Received expected parameter type: Integer"); - Integer i = (Integer) o; - if (i.equals(1)) { - TestUtil.logTrace("Received expected parameter value:" + i); - pass1 = true; - } else { - TestUtil - .logErr("Expected getParameterValue() result: 1, actual:" + i); - } - - } else { - TestUtil.logErr( - "Did not get instance of Integer from getParameterValue():" + o); - } - - if (!spq.execute()) { - o = spq.getOutputParameterValue(2); - if (o instanceof String) { - TestUtil.logTrace("Received expected parameter type: String"); - String s = (String) o; - if (s.equals(emp0.getFirstName())) { - TestUtil.logTrace("Received expected parameter value:" + s); - pass2 = true; - } else { - TestUtil.logErr("Expected getParameterValue() result: " - + emp0.getFirstName() + ", actual:" + s); - } - } - } else { - TestUtil.logErr("Expected execute() to return false, actual: true"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass1 || !pass2) - throw new Fault("xmlOverridesNamedStoredProcedureQueryTest failed"); - - } - - /* - * @testName: xmlOverridesSqlResultSetMappingAnnotationTest - * - * @assertion_ids: PERSISTENCE:SPEC:2243; PERSISTENCE:SPEC:2245; - * PERSISTENCE:SPEC:2246; - * - * @test_Strategy: verify xml overrides SqlResultSetMapping annotation - * - */ - public void xmlOverridesSqlResultSetMappingAnnotationTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - try { - TestUtil.logMsg("Testing using name,result mapping"); - clearCache(); - StoredProcedureQuery spq = getEntityManager() - .createStoredProcedureQuery("GetEmpIdFNameLNameFromRS", - "tobeoverridden2"); - spq.registerStoredProcedureParameter(1, Integer.class, - ParameterMode.IN); - if (dataBaseName.equalsIgnoreCase(ORACLE) - || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { - TestUtil.logTrace("register refcursor parameter"); - spq.registerStoredProcedureParameter(2, void.class, - ParameterMode.REF_CURSOR); - } - spq.setParameter(1, 1); - if (spq.execute()) { - - List listOfList = getResultSetsFromStoredProcedure(spq); - if (listOfList.size() == 1) { - List expected = new ArrayList(); - expected.add(new Employee(emp0.getId(), emp0.getFirstName(), - emp0.getLastName())); - pass = verifyListOfListEmployees(expected, listOfList); - } else { - TestUtil.logErr( - "Did not get the correct number of result sets returned, expected: 1, actual:" - + listOfList.size()); - } - } else { - TestUtil.logErr("Expected execute() to return true, actual: false"); - } - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Received unexpected exception:", ex); - } - - if (!pass) { - throw new Fault("xmlOverridesSqlResultSetMappingAnnotationTest failed"); - } - - } - - private void createEmployeeTestData() { - - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Creating Employees"); - - final Date d2 = getUtilDate("2001-06-27"); - final Date d3 = getUtilDate("2002-07-07"); - final Date d4 = getUtilDate("2003-03-03"); - final Date d5 = getUtilDate(); - - emp0 = new Employee(1, "Alan", "Frechette", utilDate, (float) 35000.0); - empRef.add(emp0); - empRef.add(new Employee(2, "Arthur", "Frechette", d2, (float) 35000.0)); - empRef.add(new Employee(3, "Shelly", "McGowan", d3, (float) 50000.0)); - empRef.add(new Employee(4, "Robert", "Bissett", d4, (float) 55000.0)); - empRef.add(new Employee(5, "Stephen", "DMilla", d5, (float) 25000.0)); - for (Employee e : empRef) { - if (e != null) { - getEntityManager().persist(e); - TestUtil.logTrace("persisted employee:" + e); - } - } - - getEntityManager().flush(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception fe) { - TestUtil.logErr("Unexpected exception rolling back TX:", fe); - } - } - } - - private void createEmployee2TestData() { - - try { - getEntityTransaction().begin(); - - TestUtil.logMsg("Creating Employee2"); - - final Calendar d2 = getCalDate(2001, 06, 27); - final Calendar d3 = getCalDate(2002, 07, 07); - final Calendar d4 = getCalDate(2003, 03, 03); - final Calendar d5 = getCalDate(); - - emp2 = new Employee2(1, "Alan", "Frechette", calDate, (float) 35000.0); - empRef2.add(emp2); - empRef2.add(new Employee2(2, "Arthur", "Frechette", d2, (float) 35000.0)); - empRef2.add(new Employee2(3, "Shelly", "McGowan", d3, (float) 50000.0)); - empRef2.add(new Employee2(4, "Robert", "Bissett", d4, (float) 55000.0)); - empRef2.add(new Employee2(5, "Stephen", "DMilla", d5, (float) 25000.0)); - for (Employee2 e : empRef2) { - if (e != null) { - getEntityManager().persist(e); - TestUtil.logTrace("persisted Employee2:" + e); - } - } - - getEntityManager().flush(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception fe) { - TestUtil.logErr("Unexpected exception rolling back TX:", fe); - } - } - } - - private void removeTestData() { + protected void removeTestData() { TestUtil.logTrace("removeTestData"); if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/Client.java index 4a38bfa70d..d5fff70645 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,1607 +16,27 @@ package com.sun.ts.tests.jpa.core.annotations.access.field; -import java.util.Arrays; -import java.util.Properties; -import java.util.GregorianCalendar; +import org.junit.jupiter.api.AfterEach; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; -import com.sun.ts.tests.jpa.core.types.common.Grade; - -import jakarta.persistence.Query; -import jakarta.persistence.TypedQuery; public class Client extends PMClientBase { - private DataTypes d1; + protected DataTypes d1; - private DataTypes2 d2; + protected DataTypes2 d2; final java.util.Date dateId = getPKDate(2006, 04, 15); public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - - super.setup(args, p); - removeTestData(); - createTestData(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); - } - } - - public void setup2(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup2"); - try { - - super.setup(args, p); - removeTestData(); - createTestData2(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); - } - } - - public void setup3(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup3"); - try { - - super.setup(args, p); - removeTestData(); - createTestData3(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); - } - } - - public void setup4(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup3"); - try { - - super.setup(args, p); - removeTestData(); - createTestData4(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); - } - } - - /* - * @testName: fieldTypeTest1 - * - * @assertion_ids: PERSISTENCE:SPEC:511; PERSISTENCE:SPEC:524; - * PERSISTENCE:SPEC:534; PERSISTENCE:SPEC:512; PERSISTENCE:SPEC:525; - * PERSISTENCE:JAVADOC:14; PERSISTENCE:JAVADOC:203; PERSISTENCE:JAVADOC:300; - * PERSISTENCE:SPEC:1239; PERSISTENCE:SPEC:1320; PERSISTENCE:SPEC:1327.4; - * PERSISTENCE:SPEC:1155; PERSISTENCE:SPEC:1976; PERSISTENCE:SPEC:1977; - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: boolean - */ - - public void fieldTypeTest1() throws Exception { - - boolean pass = false; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (!d1.isProperty())) { - d1.setBooleanData(true); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.isProperty()) { - TestUtil.logTrace("Received expected result:" + d1.isProperty()); - pass = true; - } else { - TestUtil.logErr("Expected: true, actual:" + d1.isProperty()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest1 failed"); - } - - /* - * @testName: fieldTypeTest2 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:513; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: byte - */ - - public void fieldTypeTest2() throws Exception { - - boolean pass = false; - byte newByte = (byte) 111; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (d1.getByteData() == (byte) 100)) { - d1.setByteData(newByte); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getByteData() == newByte) { - pass = true; - } else { - TestUtil.logErr("Expected: 100, actual:" + d1.getByteData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest2 failed"); - } - - /* - * @testName: fieldTypeTest3 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: char - */ - - public void fieldTypeTest3() throws Exception { - - boolean pass = false; - final char newChar = 'b'; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getCharacterData() == ('a'))) { - d1.setCharacterData(newChar); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getCharacterData() == newChar) { - pass = true; - } else { - TestUtil.logErr("Expected: a, actual:" + d1.getCharacterData()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest3 failed"); - } - - /* - * @testName: fieldTypeTest4 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: short - */ - - public void fieldTypeTest4() throws Exception { - - boolean pass = false; - final short newShort = (short) 101; - - try { - - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (d1.getShortData() == (short) 100)) { - d1.setShortData(newShort); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getShortData() == newShort) { - pass = true; - } else { - TestUtil.logErr("Expected: 100, actual:" + d1.getShortData()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - pass = false; - } - } - - if (!pass) - throw new Fault("fieldTypeTest4 failed"); - } - - /* - * @testName: fieldTypeTest5 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: int - */ - - public void fieldTypeTest5() throws Exception { - - boolean pass = false; - final int newInt = 500; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (d1.getIntData() == 300)) { - d1.setIntData(newInt); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getIntData() == newInt) { - pass = true; - } else { - TestUtil.logErr("Expected: 300, actual:" + d1.getIntData()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest5 failed"); - } - - /* - * @testName: fieldTypeTest6 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: long - */ - - public void fieldTypeTest6() throws Exception { - - boolean pass = false; - final long newLong = 600L; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (d1.getLongData() == 600L)) { - d1.setLongData(newLong); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getLongData() == newLong) { - pass = true; - } else { - TestUtil.logErr("Expected: 600, actual:" + d1.getLongData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest6 failed"); - } - - /* - * @testName: fieldTypeTest7 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: double - */ - - public void fieldTypeTest7() throws Exception { - - boolean pass = false; - final double newDbl = 80D; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (d1.getDoubleData() == (50D))) { - d1.setDoubleData(newDbl); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getDoubleData() == newDbl) { - pass = true; - } else { - TestUtil.logErr("Expected: 50, actual:" + d1.getDoubleData()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest7 failed"); - } - - /* - * @testName: fieldTypeTest8 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: Java primitive types: float - */ - - public void fieldTypeTest8() throws Exception { - - boolean pass = false; - final float expFloat = 1.0F; - final float floatRange = 2.0F; - final float newFloat = 6.0F; - final float newfloatRange = 7.0F; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if (null != d1) { - - TestUtil.logTrace("float value is: " + d1.getFloatData()); - - if ((d1.getFloatData() >= expFloat) - && (d1.getFloatData() < floatRange)) { - d1.setFloatData(newFloat); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if ((d1.getFloatData() >= newFloat) - && (d1.getFloatData() < newfloatRange)) { - pass = true; - } else { - TestUtil.logErr("Expected: >= " + newFloat + " and < " - + newfloatRange + ", actual:" + d1.getFloatData()); - } - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest8 failed"); - } - - /* - * @testName: fieldTypeTest9 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:529; - * PERSISTENCE:SPEC:556; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent field of an entity may be of the following - * type: enums - * - * With the Enumerated annotation and EnumType.STRING. - */ - - public void fieldTypeTest9() throws Exception { - - boolean pass = false; - - try { - getEntityTransaction().begin(); - TestUtil.logTrace("find DataTypes entity in fieldTypeTest9"); - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - TestUtil.logTrace("DataTypes is not null, setting enumData"); - d1.setEnumData(Grade.B); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - TestUtil.logTrace("Update performed, check results"); - if ((null != d1) && (d1.getEnumData().equals(Grade.B))) { - TestUtil.logTrace("Expected results received"); - pass = true; - } else { - TestUtil.logErr("Expected: " + Grade.B.toString() + ", actual:" - + d1.getEnumData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest9 failed"); - } - - /* - * @testName: fieldTypeTest10 - * - * @assertion_ids: PERSISTENCE:SPEC:536; PERSISTENCE:SPEC:540; - * PERSISTENCE:SPEC:550; PERSISTENCE:SPEC:1090.0; PERSISTENCE:JAVADOC:216; - * PERSISTENCE:JAVADOC:217; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The primary key should be one of the following types: - * java.util.Date - * - * The application must not change the value of the primary key. The behavior - * is undefined if this occurs. - * - * Temporal.TemporalType.DATE - */ - - public void fieldTypeTest10() throws Exception { - - boolean pass = false; - - try { - getEntityTransaction().begin(); - TestUtil.logTrace("FIND D2 IN fieldTypeTest10"); - d2 = getEntityManager().find(DataTypes2.class, dateId); - if (null != d2) { - - TestUtil.logTrace("fieldTypeTest10: Check results"); - if (d2.getId().equals(dateId)) { - TestUtil.logTrace("Got expected PK of:" + d2.getId() + "received"); - pass = true; - } else { - TestUtil.logErr("Expected: " + dateId + ", actual: " + d2.getId()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest10 failed"); - } - - /* - * @testName: fieldTypeTest11 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528; - * PERSISTENCE:SPEC:1089; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: byte[] - * - */ - - public void fieldTypeTest11() throws Exception { - - boolean pass = false; - final byte[] b = { 31, 32, 33, 63, 64, 65 }; - final byte bv = 5; - byte[] a = null; - - try { - getEntityTransaction().begin(); - TestUtil.logTrace("FIND D1 IN fieldTypeTest11"); - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - TestUtil.logTrace("DataType Entity is not null, setting byteData "); - d1.setByteArrayData(b); - a = d1.getByteArrayData(); - a[0] = (byte) (a[0] + bv); - d1.setByteArrayData(b); - getEntityManager().merge(d2); - getEntityManager().flush(); - - TestUtil.logTrace("fieldTypeTest11: Check results"); - if ((null != d2) && (Arrays.equals(d1.getByteArrayData(), a))) { - TestUtil.logTrace("fieldTypeTest11: Expected results received"); - pass = true; - } else { - TestUtil.logErr("Unexpected result in array comparison."); - for (Byte aByte : a) { - TestUtil.logErr("Array a in propertyTest9 equals: " + aByte); - } - for (Byte bByte : b) { - TestUtil.logErr("Array b in propertyTest9 equals: " + bByte); - } - pass = false; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest11 failed"); - } - - /* - * @testName: fieldTypeTest12 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: char[] - * - */ - - public void fieldTypeTest12() throws Exception { - - boolean pass = false; - final char[] charData = new char[] { 'c', 't', 's' }; - - try { - getEntityTransaction().begin(); - TestUtil.logTrace("FIND D1 IN fieldTypeTest12"); - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - TestUtil.logTrace("DataType Entity is not null, setting charData "); - d1.setCharArrayData(charData); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - TestUtil.logTrace("fieldTypeTest12: Check results"); - if ((null != d1) && (Arrays.equals(d1.getCharArrayData(), charData))) { - TestUtil.logTrace("fieldTypeTest12: Expected Results Received"); - pass = true; - } else { - TestUtil.logErr("Expected " + Arrays.toString(charData) + ", actual: " - + Arrays.toString(d1.getCharArrayData())); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest12 failed"); - } - - /* - * @testName: fieldTypeTest13 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: java.sql.Time - */ - - public void fieldTypeTest13() throws Exception { - - boolean pass = false; - final java.sql.Time timeValue = getTimeData(18, 30, 15); - - try { - getEntityTransaction().begin(); - TestUtil.logTrace("FIND D2 IN fieldTypeTest13"); - d2 = getEntityManager().find(DataTypes2.class, dateId); - - if (null != d2) { - TestUtil.logTrace("DataType Entity is not null, setting TimeData "); - d2.setTimeData(timeValue); - - getEntityManager().merge(d2); - getEntityManager().flush(); - - TestUtil.logTrace("fieldTypeTest13: Check results"); - if ((null != d2) && (d2.getTimeData().equals(timeValue))) { - TestUtil.logTrace("fieldTypeTest13: Expected Time Received"); - pass = true; - } else { - TestUtil.logErr( - "Expected " + timeValue + " , actual: " + d2.getTimeData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest13 failed"); - } - - /* - * @testName: fieldTypeTest14 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; - * PERSISTENCE:SPEC:1319 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: java.sql.Timestamp - */ - - public void fieldTypeTest14() throws Exception { - - boolean pass = false; - final java.sql.Timestamp tsValue = getTimestampData(2006, 02, 11); - - try { - getEntityTransaction().begin(); - TestUtil.logTrace("FIND D2 IN fieldTypeTest14"); - d2 = getEntityManager().find(DataTypes2.class, dateId); - - if (null != d2) { - TestUtil - .logTrace("DataType Entity is not null, setting TimestampData "); - d2.setTsData(tsValue); - - getEntityManager().merge(d2); - getEntityManager().flush(); - - TestUtil.logTrace("fieldTypeTest14: Check results"); - if ((null != d2) && (d2.getTsData().equals(tsValue))) { - TestUtil.logTrace("fieldTypeTest14: Expected Timestamp Received"); - pass = true; - } else { - TestUtil - .logErr("Expected " + tsValue + " , actual: " + d2.getTsData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest14 failed"); - } - - /* - * @testName: fieldTypeTest15 - * - * @assertion_ids: PERSISTENCE:SPEC:428; PERSISTENCE:SPEC:529; - * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: enum_expression ::= enum_primary | (subquery) enum_primary - * ::= statefield_path_expression | input parameter | enum_literal - * - * statefield_path_expression - */ - - public void fieldTypeTest15() throws Exception { - - boolean pass = false; - Object result; - Query q; - - try { - - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - d1.setEnumData(Grade.A); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - q = getEntityManager().createQuery( - "SELECT dt FROM DataTypes dt WHERE dt.enumData = com.sun.ts.tests.jpa.core.types.common.Grade.A"); - - result = (DataTypes) q.getSingleResult(); - - if (d1.equals(result)) { - pass = true; - TestUtil.logTrace("Received expected result:" + d1.toString()); - } else { - TestUtil.logErr( - "Expected:" + d1.toString() + ", actual:" + result.toString()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest15 failed"); - } - - /* - * @testName: fieldTypeTest16 - * - * @assertion_ids: PERSISTENCE:SPEC:428; PERSISTENCE:SPEC:529; - * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: enum_expression ::= enum_primary | (subquery) enum_primary - * ::= state_field_path_expression | input parameter | enum_literal - * - * named parameter - */ - - public void fieldTypeTest16() throws Exception { - - boolean pass = false; - Object result; - Query q; - - try { - - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - d1.setEnumData(Grade.A); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - q = getEntityManager() - .createQuery( - "SELECT dt FROM DataTypes dt WHERE dt.enumData = :grade") - .setParameter("grade", Grade.A); - - result = (DataTypes) q.getSingleResult(); - - if (d1.equals(result)) { - pass = true; - TestUtil.logTrace("Received expected result:" + d1.toString()); - } else { - TestUtil.logErr( - "Expected:" + d1.toString() + ", actual:" + result.toString()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest16 failed"); - } - - /* - * @testName: fieldTypeTest17 - * - * @assertion_ids: PERSISTENCE:SPEC:428; PERSISTENCE:SPEC:529; - * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:SPEC:1319 - * - * @test_Strategy: enum_expression ::= enum_primary | (subquery) enum_primary - * ::= state_field_path_expression | input parameter | enum_literal - * - * positional parameters - */ - - public void fieldTypeTest17() throws Exception { - - boolean pass = false; - Object result; - Query q; - final Grade failingGrade = com.sun.ts.tests.jpa.core.types.common.Grade.F; - final Grade incompleteGrade = com.sun.ts.tests.jpa.core.types.common.Grade.INCOMPLETE; - - try { - - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - d1.setEnumData(Grade.C); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - q = getEntityManager().createQuery( - "SELECT dt FROM DataTypes dt WHERE (dt.enumData <> ?1) OR (dt.enumData <> ?2) ") - .setParameter(1, failingGrade).setParameter(2, incompleteGrade); - - result = (DataTypes) q.getSingleResult(); - - if (d1.equals(result)) { - pass = true; - TestUtil.logTrace("Received expected result:" + d1.toString()); - } else { - TestUtil.logErr( - "Expected:" + d1.toString() + ", actual:" + result.toString()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("fieldTypeTest17 failed"); - } - - /* - * @testName: mixedAccessTest - * - * @assertion_ids: PERSISTENCE:SPEC:1327.3; - * - * @test_Strategy: - */ - @SetupMethod(name = "setup2") - public void mixedAccessTest() throws Exception { - - boolean pass = false; - final int newInt = 500; - - try { - getEntityTransaction().begin(); - d1 = getEntityManager().find(DataTypes.class, 1); - if ((null != d1) && (d1.getIntData2() == 300)) { - TestUtil.logMsg("Int value after find=" + d1.getIntData2()); - d1.setIntData2(newInt); - TestUtil.logMsg("Int value after set=" + d1.getIntData2()); - getEntityManager().merge(d1); - getEntityManager().flush(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if (d1.getIntData2() == newInt) { - pass = true; - TestUtil.logTrace("Received expected value:" + d1.getIntData2()); - } else { - TestUtil - .logErr("Expected:" + newInt + ", actual:" + d1.getIntData2()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("mixedAccessTest failed"); - } - - /* - * @testName: transientTest - * - * @assertion_ids: PERSISTENCE:SPEC:1327.2 - * - * @test_Strategy: when transient is specified, verify data isn't persisted - */ - @SetupMethod(name = "setup3") - public void transientTest() throws Exception { - - boolean pass = false; - byte newByte = (byte) 111; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = getEntityManager().find(DataTypes.class, 1); - if (null != d1) { - if ((d1.getTransient() == (byte) 0)) { - TestUtil.logTrace( - "First find returned expected result:" + d1.getTransient()); - d1.setTransient(newByte); - - getEntityManager().merge(d1); - getEntityManager().flush(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if (d1.getTransient() == (byte) 0) { - pass = true; - TestUtil.logTrace( - "Second find returned expected value:" + d1.getTransient()); - } else { - TestUtil - .logErr("Second find expected:0, actual:" + d1.getTransient()); - } - } else { - TestUtil.logErr( - "Expected first find to return:0, actual:" + d1.getTransient()); - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("transientTest failed"); - } - - /* - * @testName: testExtractDateYear - * - * @assertion_ids: PERSISTENCE:SPEC:2519.1 - * - * @test_Strategy: SELECT EXTRACT(YEAR FROM d.id) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateYear() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(YEAR FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long y = q1.getSingleResult().longValue(); - System.out.println("DATETIME -- YEAR: " + y); - if (y != TD4_YEAR) { - throw new Fault("EXTRACT(YEAR FROM date) returned wrong value: expeted " + TD4_YEAR + " but got " + y); - } - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateQuarter - * - * @assertion_ids: PERSISTENCE:SPEC:2519.2 - * - * @test_Strategy: SELECT EXTRACT(QUARTER FROM d.id) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateQuarter() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(QUARTER FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long q = q1.getSingleResult().longValue(); - if (q != TD4_QUARTER) { - throw new Fault("EXTRACT(QUARTER FROM date) returned wrong value: expeted " + TD4_QUARTER + " but got " + q); - } - System.out.println("DATETIME -- QUARTER: " + q); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateMonth - * - * @assertion_ids: PERSISTENCE:SPEC:2519.3 - * - * @test_Strategy: SELECT EXTRACT(MONTH FROM d.id) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateMonth() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MONTH FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long m = q1.getSingleResult().longValue(); - if (m != TD4_MONTH) { - throw new Fault("EXTRACT(MONTH FROM date) returned wrong value: expeted " + TD4_MONTH + " but got " + m); - } - System.out.println("DATETIME -- MONTH: " + m); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateDay - * - * @assertion_ids: PERSISTENCE:SPEC:2519.5 - * - * @test_Strategy: SELECT EXTRACT(DAY FROM d.id) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateDay() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(DAY FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long d = q1.getSingleResult().longValue(); - if (d != TD4_DAY) { - throw new Fault("EXTRACT(DAY FROM date) returned wrong value: expeted " + TD4_DAY + " but got " + d); - } - System.out.println("DATETIME -- DAY: " + d); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractTimeHour - * - * @assertion_ids: PERSISTENCE:SPEC:2519.6 - * - * @test_Strategy: SELECT EXTRACT(HOUR FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractTimeHour() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(HOUR FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long h = q1.getSingleResult().longValue(); - if (h != TD4_HOUR) { - throw new Fault("EXTRACT(HOUR FROM time) returned wrong value: expeted " + TD4_HOUR + " but got " + h); - } - System.out.println("DATETIME -- HOUR: " + h); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractTimeMinute - * - * @assertion_ids: PERSISTENCE:SPEC:2519.7 - * - * @test_Strategy: SELECT EXTRACT(MINUTE FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractTimeMinute() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MINUTE FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long m = q1.getSingleResult().longValue(); - if (m != TD4_MINUTE) { - throw new Fault("EXTRACT(MINUTE FROM time) returned wrong value: expeted " + TD4_MINUTE + " but got " + m); - } - System.out.println("DATETIME -- MINUTE: " + m); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractTimeSecond - * - * @assertion_ids: PERSISTENCE:SPEC:2519.8 - * - * @test_Strategy: SELECT EXTRACT(SECOND FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractTimeSecond() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(SECOND FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long s = q1.getSingleResult().longValue(); - if (s != TD4_SECOND) { - throw new Fault("EXTRACT(SECOND FROM time) returned wrong value: expeted " + TD4_SECOND + " but got " + s); - } - System.out.println("DATETIME -- SECOND: " + s); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeYear - * - * @assertion_ids: PERSISTENCE:SPEC:2519.1 - * - * @test_Strategy: SELECT EXTRACT(YEAR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeYear() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(YEAR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long y = q1.getSingleResult().longValue(); - System.out.println("DATETIME -- YEAR: " + y); - if (y != TD4_YEAR) { - throw new Fault("EXTRACT(YEAR FROM timestamp) returned wrong value: expeted " + TD4_YEAR + " but got " + y); - } - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeQuarter - * - * @assertion_ids: PERSISTENCE:SPEC:2519.2 - * - * @test_Strategy: SELECT EXTRACT(QUARTER FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeQuarter() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(QUARTER FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long q = q1.getSingleResult().longValue(); - if (q != TD4_QUARTER) { - throw new Fault("EXTRACT(QUARTER FROM timestamp) returned wrong value: expeted " + TD4_QUARTER + " but got " + q); - } - System.out.println("DATETIME -- QUARTER: " + q); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeMonth - * - * @assertion_ids: PERSISTENCE:SPEC:2519.3 - * - * @test_Strategy: SELECT EXTRACT(MONTH FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeMonth() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MONTH FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long m = q1.getSingleResult().longValue(); - if (m != TD4_MONTH) { - throw new Fault("EXTRACT(MONTH FROM timestamp) returned wrong value: expeted " + TD4_MONTH + " but got " + m); - } - System.out.println("DATETIME -- MONTH: " + m); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeDay - * - * @assertion_ids: PERSISTENCE:SPEC:2519.5 - * - * @test_Strategy: SELECT EXTRACT(DAY FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeDay() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(DAY FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long d = q1.getSingleResult().longValue(); - if (d != TD4_DAY) { - throw new Fault("EXTRACT(DAY FROM timestamp) returned wrong value: expeted " + TD4_DAY + " but got " + d); - } - System.out.println("DATETIME -- DAY: " + d); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeHour - * - * @assertion_ids: PERSISTENCE:SPEC:2519.6 - * - * @test_Strategy: SELECT EXTRACT(HOUR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeHour() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(HOUR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long h = q1.getSingleResult().longValue(); - if (h != TD4_HOUR) { - throw new Fault("EXTRACT(HOUR FROM timestamp) returned wrong value: expeted " + TD4_HOUR + " but got " + h); - } - System.out.println("DATETIME -- HOUR: " + h); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeMinute - * - * @assertion_ids: PERSISTENCE:SPEC:2519.7 - * - * @test_Strategy: SELECT EXTRACT(MINUTE FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeMinute() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MINUTE FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long m = q1.getSingleResult().longValue(); - if (m != TD4_MINUTE) { - throw new Fault("EXTRACT(MINUTE FROM timestamp) returned wrong value: expeted " + TD4_MINUTE + " but got " + m); - } - System.out.println("DATETIME -- MINUTE: " + m); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - /* - * @testName: testExtractDateTimeSecond - * - * @assertion_ids: PERSISTENCE:SPEC:2519.8 - * - * @test_Strategy: SELECT EXTRACT(SECOND FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id - */ - @SetupMethod(name = "setup4") - public void testExtractDateTimeSecond() throws Exception { - try { - TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(SECOND FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); - q1.setParameter("id", t4Date()); - long s = q1.getSingleResult().longValue(); - if (s != TD4_SECOND) { - throw new Fault("EXTRACT(SECOND FROM timestamp) returned wrong value: expeted " + TD4_SECOND + " but got " + s); - } - System.out.println("DATETIME -- SECOND: " + s); - } catch (Exception ex) { - throw new Fault(ex); - } - } - - - // Methods used for Tests - - public void createTestData() { - TestUtil.logTrace("createTestData"); - - try { - getEntityTransaction().begin(); - char[] cArray = { 'a' }; - byte[] bArray = { (byte) 100 }; - d1 = new DataTypes(1, false, (byte) 100, 'a', (short) 100, 300, 600L, 50D, - 1.0F, cArray, bArray); - - TestUtil.logTrace("dateId is: " + dateId); - d2 = new DataTypes2(dateId); - - getEntityManager().persist(d1); - getEntityManager().persist(d2); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception in createTestData:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - } - - public void createTestData2() { - TestUtil.logTrace("createTestData2"); - - try { - getEntityTransaction().begin(); - d1 = new DataTypes(1, 300); - - getEntityManager().persist(d1); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception in createTestData:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - } - - public void createTestData3() { - TestUtil.logTrace("createTestData3"); - - try { - getEntityTransaction().begin(); - d1 = new DataTypes(1, (byte) 5); - - getEntityManager().persist(d1); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception in createTestData:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - } - - private final int TD4_YEAR = 1989; - private final int TD4_QUARTER= 4; - private final int TD4_MONTH = 11; - private final int TD4_DAY = 17; - private final int TD4_HOUR = 11; - private final int TD4_MINUTE = 23; - private final int TD4_SECOND = 36; - - private java.sql.Date t4Date() { - final GregorianCalendar cal = new GregorianCalendar(TD4_YEAR, TD4_MONTH-1, TD4_DAY, TD4_HOUR, TD4_MINUTE, TD4_SECOND); - final java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis()); - return java.sql.Date.valueOf(ts.toLocalDateTime().toLocalDate()); - } - - public void createTestData4() { - TestUtil.logTrace("createTestData4"); - final GregorianCalendar cal = new GregorianCalendar(TD4_YEAR, TD4_MONTH-1, TD4_DAY, TD4_HOUR, TD4_MINUTE, TD4_SECOND); - final java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis()); - final java.sql.Date dt = java.sql.Date.valueOf(ts.toLocalDateTime().toLocalDate()); - final java.sql.Time tm = java.sql.Time.valueOf(ts.toLocalDateTime().toLocalTime()); - - try { - getEntityTransaction().begin(); - DataTypes2 dataTypes2 = new DataTypes2(dt, tm, ts); - getEntityManager().persist(dataTypes2); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception in createTestData:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - } + + + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); @@ -1624,7 +44,7 @@ public void cleanup() throws Exception { super.cleanup(); } - private void removeTestData() { + protected void removeTestData() { TestUtil.logTrace("removeTestData"); if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/mappedsc/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/mappedsc/Client.java index 628944004b..14c4c5a7e6 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/mappedsc/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/mappedsc/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -17,208 +17,200 @@ package com.sun.ts.tests.jpa.core.annotations.access.mappedsc; import java.sql.Date; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; public class Client extends PMClientBase { - private static FullTimeEmployee ftRef[] = new FullTimeEmployee[5]; - - private static PartTimeEmployee ptRef[] = new PartTimeEmployee[5]; - - final private Date d1 = getSQLDate(2000, 2, 14); + private static FullTimeEmployee ftRef[] = new FullTimeEmployee[5]; - final private Date d2 = getSQLDate(2001, 6, 27); + private static PartTimeEmployee ptRef[] = new PartTimeEmployee[5]; - final private Date d3 = getSQLDate(2002, 7, 7); + final private Date d1 = getSQLDate(2000, 2, 14); - final private Date d4 = getSQLDate(2003, 3, 3); + final private Date d2 = getSQLDate(2001, 6, 27); - final private Date d5 = getSQLDate(2004, 4, 10); + final private Date d3 = getSQLDate(2002, 7, 7); - final private Date d6 = getSQLDate(2005, 2, 18); + final private Date d4 = getSQLDate(2003, 3, 3); - final private Date d7 = getSQLDate(2000, 9, 17); + final private Date d5 = getSQLDate(2004, 4, 10); - final private Date d8 = getSQLDate(2001, 11, 14); + final private Date d6 = getSQLDate(2005, 2, 18); - final private Date d9 = getSQLDate(2002, 10, 4); + final private Date d7 = getSQLDate(2000, 9, 17); - final private Date d10 = getSQLDate(2003, 1, 25); + final private Date d8 = getSQLDate(2001, 11, 14); - public Client() { - } + final private Date d9 = getSQLDate(2002, 10, 4); - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } + final private Date d10 = getSQLDate(2003, 1, 25); - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { + public Client() { + } - super.setup(args, p); - removeTestData(); - createTestData(); - TestUtil.logTrace("Done creating test data"); + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } + super.setup(); + removeTestData(); + createTestData(); + TestUtil.logTrace("Done creating test data"); - /* - * @testName: test1 - * - * @assertion_ids: PERSISTENCE:SPEC:593; PERSISTENCE:SPEC:596; - * PERSISTENCE:SPEC:597; PERSISTENCE:SPEC:598; PERSISTENCE:SPEC:599; - * PERSISTENCE:SPEC:1130; PERSISTENCE:SPEC:1131; PERSISTENCE:SPEC:1132; - * PERSISTENCE:SPEC:1133; PERSISTENCE:SPEC:1061; PERSISTENCE:SPEC:1062; - * PERSISTENCE:JAVADOC:4; PERSISTENCE:JAVADOC:5; PERSISTENCE:JAVADOC:6; - * PERSISTENCE:SPEC:1239; - * - * @test_Strategy: An entity may have a mapped superclass which provides - * persistent entity state and mapping information - */ - - public void test1() throws Exception { - - TestUtil.logTrace("Begin test1"); - boolean pass = false; - - try { - FullTimeEmployee ftEmp1 = getEntityManager().find(FullTimeEmployee.class, - 1); - - if (ftEmp1.getFullTimeRep().equals("Mabel Murray")) { - pass = true; - } - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("test1 failed"); - } - - /* - * @testName: test2 - * - * @assertion_ids: PERSISTENCE:SPEC:593; PERSISTENCE:SPEC:596; - * PERSISTENCE:SPEC:597; PERSISTENCE:SPEC:598; PERSISTENCE:SPEC:599; - * PERSISTENCE:SPEC:1130; PERSISTENCE:SPEC:1131; PERSISTENCE:SPEC:1132; - * PERSISTENCE:SPEC:1133; PERSISTENCE:SPEC:1061; PERSISTENCE:SPEC:1062; - * PERSISTENCE:JAVADOC:4; PERSISTENCE:JAVADOC:5; PERSISTENCE:JAVADOC:6; - * PERSISTENCE:SPEC:1239; - * - * @test_Strategy: An entity may have a mapped superclass which provides - * persistent entity state and mapping information but is not an entity - * itself. - */ - - public void test2() throws Exception { - - TestUtil.logTrace("Begin test2"); - boolean pass = false; - - try { - PartTimeEmployee ptEmp1 = getEntityManager().find(PartTimeEmployee.class, - 6); - - if (ptEmp1.getPartTimeRep().equals("John Cleveland")) { - pass = true; - } - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) - throw new Fault("test2 failed"); - } - - public void createTestData() { - TestUtil.logTrace("createTestData"); - - try { - - getEntityTransaction().begin(); - ftRef[0] = new FullTimeEmployee(1, "Jonathan", "Smith", d10, 40000.0F); - ftRef[1] = new FullTimeEmployee(2, "Mary", "Macy", d9, 40000.0F); - ftRef[2] = new FullTimeEmployee(3, "Sid", "Nee", d8, 40000.0F); - ftRef[3] = new FullTimeEmployee(4, "Julie", "OClaire", d7, 60000.0F); - ftRef[4] = new FullTimeEmployee(5, "Steven", "Rich", d6, 60000.0F); - - TestUtil.logTrace("Persist full time employees "); - for (FullTimeEmployee fte : ftRef) { - getEntityManager().persist(fte); - TestUtil.logTrace("persisted employee " + fte); - } - - ptRef[0] = new PartTimeEmployee(6, "Kellie", "Lee", d5, 60000.0F); - ptRef[1] = new PartTimeEmployee(7, "Nicole", "Martin", d4, 60000.0F); - ptRef[2] = new PartTimeEmployee(8, "Mark", "Francis", d3, 60000.0F); - ptRef[3] = new PartTimeEmployee(9, "Will", "Forrest", d2, 60000.0F); - ptRef[4] = new PartTimeEmployee(10, "Katy", "Hughes", d1, 60000.0F); - - TestUtil.logTrace("Persist part time employees "); - for (PartTimeEmployee pte : ptRef) { - getEntityManager().persist(pte); - TestUtil.logTrace("persisted employee " + pte); - } - getEntityTransaction().commit(); - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception creating test data:", re); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception rolling back TX:", re); - } - } - } - - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - private void removeTestData() { - TestUtil.logTrace("removeTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from DEPARTMENT") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from PARTTIMEEMPLOYEE") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from EMPLOYEE") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: test1 + * + * @assertion_ids: PERSISTENCE:SPEC:593; PERSISTENCE:SPEC:596; + * PERSISTENCE:SPEC:597; PERSISTENCE:SPEC:598; PERSISTENCE:SPEC:599; + * PERSISTENCE:SPEC:1130; PERSISTENCE:SPEC:1131; PERSISTENCE:SPEC:1132; + * PERSISTENCE:SPEC:1133; PERSISTENCE:SPEC:1061; PERSISTENCE:SPEC:1062; + * PERSISTENCE:JAVADOC:4; PERSISTENCE:JAVADOC:5; PERSISTENCE:JAVADOC:6; + * PERSISTENCE:SPEC:1239; + * + * @test_Strategy: An entity may have a mapped superclass which provides + * persistent entity state and mapping information + */ + @Test + public void test1() throws Exception { + + TestUtil.logTrace("Begin test1"); + boolean pass = false; + + try { + FullTimeEmployee ftEmp1 = getEntityManager().find(FullTimeEmployee.class, 1); + + if (ftEmp1.getFullTimeRep().equals("Mabel Murray")) { + pass = true; + } + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("test1 failed"); + } + + /* + * @testName: test2 + * + * @assertion_ids: PERSISTENCE:SPEC:593; PERSISTENCE:SPEC:596; + * PERSISTENCE:SPEC:597; PERSISTENCE:SPEC:598; PERSISTENCE:SPEC:599; + * PERSISTENCE:SPEC:1130; PERSISTENCE:SPEC:1131; PERSISTENCE:SPEC:1132; + * PERSISTENCE:SPEC:1133; PERSISTENCE:SPEC:1061; PERSISTENCE:SPEC:1062; + * PERSISTENCE:JAVADOC:4; PERSISTENCE:JAVADOC:5; PERSISTENCE:JAVADOC:6; + * PERSISTENCE:SPEC:1239; + * + * @test_Strategy: An entity may have a mapped superclass which provides + * persistent entity state and mapping information but is not an entity itself. + */ + @Test + public void test2() throws Exception { + + TestUtil.logTrace("Begin test2"); + boolean pass = false; + + try { + PartTimeEmployee ptEmp1 = getEntityManager().find(PartTimeEmployee.class, 6); + + if (ptEmp1.getPartTimeRep().equals("John Cleveland")) { + pass = true; + } + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("test2 failed"); + } + + public void createTestData() { + TestUtil.logTrace("createTestData"); + + try { + + getEntityTransaction().begin(); + ftRef[0] = new FullTimeEmployee(1, "Jonathan", "Smith", d10, 40000.0F); + ftRef[1] = new FullTimeEmployee(2, "Mary", "Macy", d9, 40000.0F); + ftRef[2] = new FullTimeEmployee(3, "Sid", "Nee", d8, 40000.0F); + ftRef[3] = new FullTimeEmployee(4, "Julie", "OClaire", d7, 60000.0F); + ftRef[4] = new FullTimeEmployee(5, "Steven", "Rich", d6, 60000.0F); + + TestUtil.logTrace("Persist full time employees "); + for (FullTimeEmployee fte : ftRef) { + getEntityManager().persist(fte); + TestUtil.logTrace("persisted employee " + fte); + } + + ptRef[0] = new PartTimeEmployee(6, "Kellie", "Lee", d5, 60000.0F); + ptRef[1] = new PartTimeEmployee(7, "Nicole", "Martin", d4, 60000.0F); + ptRef[2] = new PartTimeEmployee(8, "Mark", "Francis", d3, 60000.0F); + ptRef[3] = new PartTimeEmployee(9, "Will", "Forrest", d2, 60000.0F); + ptRef[4] = new PartTimeEmployee(10, "Katy", "Hughes", d1, 60000.0F); + + TestUtil.logTrace("Persist part time employees "); + for (PartTimeEmployee pte : ptRef) { + getEntityManager().persist(pte); + TestUtil.logTrace("persisted employee " + pte); + } + getEntityTransaction().commit(); + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception creating test data:", re); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception rolling back TX:", re); + } + } + } + + @AfterEach + public void cleanup() throws Exception { + TestUtil.logTrace("cleanup"); + removeTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeTestData() { + TestUtil.logTrace("removeTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("Delete from DEPARTMENT").executeUpdate(); + getEntityManager().createNativeQuery("Delete from PARTTIMEEMPLOYEE").executeUpdate(); + getEntityManager().createNativeQuery("Delete from EMPLOYEE").executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/Client.java deleted file mode 100644 index 7c72e74f8e..0000000000 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/Client.java +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.ts.tests.jpa.core.annotations.access.property; - -import java.util.Arrays; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.SetupMethod; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jpa.common.PMClientBase; -import com.sun.ts.tests.jpa.core.types.common.Grade; - -public class Client extends PMClientBase { - - private DataTypes d1; - - private DataTypes2 d2; - - final private java.util.Date dateId = getPKDate(2006, 04, 15); - - public Client() { - } - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - - super.setup(args, p); - removeTestData(); - createTestData(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - public void setup2(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup2"); - try { - - super.setup(args, p); - removeTestData(); - createTestData2(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - /* - * @testName: propertyTypeTest1 - * - * @assertion_ids: PERSISTENCE:SPEC:514; PERSISTENCE:SPEC:515; - * PERSISTENCE:SPEC:516; PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; - * PERSISTENCE:SPEC:534; PERSISTENCE:SPEC:1327.4; PERSISTENCE:SPEC:1153; - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Character - */ - - public void propertyTypeTest1() throws Exception { - - boolean pass = false; - final Character newChar = 'b'; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getCharacterData().equals((char) 'a'))) { - d1.setCharacterData(newChar); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getCharacterData().equals(newChar)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest1 failed"); - } - - /* - * @testName: propertyTypeTest2 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; - * PERSISTENCE:SPEC:533; PERSISTENCE:SPEC:534 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Short - */ - - public void propertyTypeTest2() throws Exception { - - boolean pass = false; - final Short newShort = 101; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getShortData().equals((short) 100))) { - d1.setShortData(newShort); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getShortData().equals(newShort)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest2 failed"); - } - - /* - * @testName: propertyTypeTest3 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Integer - */ - - public void propertyTypeTest3() throws Exception { - - boolean pass = false; - final Integer newInt = 500; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getIntegerData().equals(500))) { - d1.setIntegerData(newInt); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getIntegerData().equals(newInt)) { - pass = true; - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest3 failed"); - } - - /* - * @testName: propertyTypeTest4 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Long - */ - - public void propertyTypeTest4() throws Exception { - - boolean pass = false; - final Long newLong = 600L; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getLongData().equals(300L))) { - d1.setLongData(newLong); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getLongData().equals(newLong)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest4 failed"); - } - - /* - * @testName: propertyTypeTest5 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Double - */ - - public void propertyTypeTest5() throws Exception { - - boolean pass = false; - final Double newDbl = 80D; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getDoubleData().equals(50D))) { - d1.setDoubleData(newDbl); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getDoubleData().equals(newDbl)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest5 failed"); - - } - - /* - * @testName: propertyTypeTest6 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Float - */ - - public void propertyTypeTest6() throws Exception { - - boolean pass = false; - final Float newFloat = 3.0F; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getFloatData().equals(1.0F))) { - d1.setFloatData(newFloat); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getFloatData().equals(newFloat)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest6 failed"); - - } - - /* - * @testName: propertyTypeTest7 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:529; - * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:JAVADOC:72; - * PERSISTENCE:JAVADOC:73 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: enums - * - * Using the Enumerated annotation, with EnumType.ORDINAL. - */ - - public void propertyTypeTest7() throws Exception { - - boolean pass = false; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - TestUtil.logTrace("DataType Entity is not null, setting enumData "); - d1.setEnumData(Grade.C); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - TestUtil.logTrace("Check results"); - if ((null != d1) && (d1.getEnumData().equals(Grade.C))) { - TestUtil - .logTrace("Expected Grade of:" + d1.getEnumData() + "received"); - pass = true; - } else { - TestUtil.logErr("Did not get expected results. Expected C, got: " - + d1.getEnumData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest7 failed"); - } - - /* - * @testName: propertyTypeTest8 - * - * @assertion_ids: PERSISTENCE:SPEC:536; PERSISTENCE:SPEC:540; - * PERSISTENCE:SPEC:550; PERSISTENCE:SPEC:1090.0; PERSISTENCE:SPEC:1079 - * - * @test_Strategy: The primary key should be one of the following types: - * java.util.Date - * - * The application must not change the value of the primary key. The behavior - * is undefined if this occurs. - * - * Temporal.TemporalType.DATE - */ - - public void propertyTypeTest8() throws Exception { - - boolean pass = false; - - try { - getEntityTransaction().begin(); - clearCache(); - d2 = null; - d2 = getEntityManager().find(DataTypes2.class, dateId); - if (null != d2) { - - TestUtil.logTrace("Check results"); - if (d2.getId().equals(dateId)) { - TestUtil.logTrace("Got expected PK of:" + d2.getId() + "received"); - pass = true; - } else { - TestUtil.logErr("Did not get expected results. " + "Expected " - + dateId + ", got: " + d2.getId()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest8 failed"); - } - - /* - * @testName: propertyTypeTest9 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: Byte[] - * - */ - - public void propertyTypeTest9() throws Exception { - - boolean pass = false; - final Byte[] b = { 31, 32, 33, 63, 64, 65 }; - final Byte bv = 5; - Byte[] a = null; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - TestUtil.logTrace("DataType Entity is not null, setting byteData "); - d1.setByteArrayData(b); - a = d1.getByteArrayData(); - a[0] = (byte) (a[0] + bv); - d1.setByteArrayData(b); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - TestUtil.logTrace("Check results"); - if ((null != d1) && (Arrays.equals(d1.getByteArrayData(), a))) { - TestUtil.logTrace("propertyTypeTest9: Expected results received"); - pass = true; - } else { - TestUtil.logErr("Unexpected result in array comparison."); - for (Byte aByte : a) { - TestUtil.logTrace("Array a in propertyTest9 equals: " + aByte); - } - for (Byte bByte : b) { - TestUtil.logTrace("Array b in propertyTest9 equals: " + bByte); - } - pass = false; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest9 failed"); - } - - /* - * @testName: propertyTypeTest10 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: Character[] - * - */ - - public void propertyTypeTest10() throws Exception { - - boolean pass = false; - - try { - getEntityTransaction().begin(); - Character[] charData = new Character[] { (char) 'C', (char) 'T', - (char) 'S' }; - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if (null != d1) { - TestUtil - .logTrace("DataType Entity is not null, setting CharacterData "); - d1.setCharArrayData(charData); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - TestUtil.logTrace("propertyTypeTest10: Check results"); - if ((null != d1) && (Arrays.equals(d1.getCharArrayData(), charData))) { - TestUtil.logTrace("propertyTypeTest10: Expected Results Received"); - pass = true; - } else { - TestUtil.logErr("Did not get expected results. " + "Expected " - + Arrays.toString(charData) + ", got: " - + Arrays.toString(d1.getCharArrayData())); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest10 failed"); - } - - /* - * @testName: propertyTypeTest11 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: java.sql.Time - */ - - public void propertyTypeTest11() throws Exception { - - boolean pass = false; - final java.sql.Time timeValue = getTimeData(18, 30, 15); - - try { - getEntityTransaction().begin(); - clearCache(); - d2 = null; - d2 = getEntityManager().find(DataTypes2.class, dateId); - - if (null != d2) { - TestUtil.logTrace("DataType Entity is not null, setting TimeData "); - d2.setTimeData(timeValue); - - getEntityManager().merge(d2); - getEntityManager().flush(); - - TestUtil.logTrace("propertyTypeTest11: Check results"); - if ((null != d2) && (d2.getTimeData().equals(timeValue))) { - TestUtil.logTrace("propertyTypeTest11: Expected Time Received"); - pass = true; - } else { - TestUtil.logErr("Did not get expected results. " + " Expected " - + timeValue + " , got: " + d2.getTimeData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest11 failed"); - } - - /* - * @testName: propertyTypeTest12 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: java.sql.Timestamp - */ - - public void propertyTypeTest12() throws Exception { - - boolean pass = false; - final java.sql.Timestamp tsValue = getTimestampData(2006, 02, 11); - - try { - getEntityTransaction().begin(); - clearCache(); - d2 = null; - d2 = getEntityManager().find(DataTypes2.class, dateId); - - if (null != d2) { - TestUtil - .logTrace("DataType Entity is not null, setting TimestampData "); - d2.setTsData(tsValue); - - getEntityManager().merge(d2); - getEntityManager().flush(); - - TestUtil.logTrace("propertyTypeTest12: Check results"); - if ((null != d2) && (d2.getTsData().equals(tsValue))) { - TestUtil.logTrace("propertyTypeTest12: Expected Timestamp Received"); - pass = true; - } else { - TestUtil.logErr("Did not get expected results. " + " Expected " - + tsValue + " , got: " + d2.getTsData()); - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest12 failed"); - } - - /* - * @testName: propertyTypeTest13 - * - * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; - * - * @test_Strategy: The persistent property of an entity may be of the - * following type: wrappers of the primitive types: Boolean - */ - - public void propertyTypeTest13() throws Exception { - - boolean pass = false; - final Boolean newBoolean = false; - - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if ((null != d1) && (d1.getBooleanData().equals(true))) { - d1.setBooleanData(newBoolean); - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getBooleanData().equals(newBoolean)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("propertyTypeTest13 failed"); - } - - /* - * @testName: transientTest - * - * @assertion_ids: PERSISTENCE:SPEC:1327.9 - * - * @test_Strategy: when transient is specified, verify data isn't persisted - */ - @SetupMethod(name = "setup2") - public void transientTest() throws Exception { - - boolean pass = false; - final String newString = "NEW_VALUE"; - try { - getEntityTransaction().begin(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - TestUtil.logMsg("d1.toString():" + d1.toString()); - - if (null != d1) { - if (d1.getShouldNotPersist() == null) { - TestUtil.logTrace("Int value after find=" + d1.getShouldNotPersist()); - d1.setShouldNotPersist(newString); - TestUtil.logTrace("Int value after set=" + d1.getShouldNotPersist()); - getEntityManager().merge(d1); - getEntityManager().flush(); - clearCache(); - d1 = null; - d1 = getEntityManager().find(DataTypes.class, 1); - - if (d1.getShouldNotPersist() == null) { - pass = true; - TestUtil.logTrace("Received expected null value"); - } else { - TestUtil - .logErr("Expected:null, actual:" + d1.getShouldNotPersist()); - } - getEntityTransaction().commit(); - - } else { - TestUtil.logErr("getShouldNotPersist() returned null"); - } - } else { - TestUtil.logErr("find returned null"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - if (!pass) - throw new Fault("transientTest failed"); - } - - // Methods used for Tests - - public void createTestData() { - TestUtil.logTrace("createTestData"); - - try { - getEntityTransaction().begin(); - Character[] cArray = { 'a' }; - Byte[] bArray = { (byte) 100 }; - d1 = new DataTypes(1, true, 'a', (short) 100, 500, 300L, 50D, 1.0F, - cArray, bArray); - - d2 = new DataTypes2(dateId); - - getEntityManager().persist(d1); - getEntityManager().persist(d2); - - getEntityManager().flush(); - - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception in createTestData:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - } - - public void createTestData2() { - TestUtil.logTrace("createTestData2"); - - try { - getEntityTransaction().begin(); - - d1 = new DataTypes(1, "INITIAL_VALUE"); - - getEntityManager().persist(d1); - - getEntityManager().flush(); - - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception in createTestData:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception during Rollback:", re); - } - } - - } - - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - private void removeTestData() { - TestUtil.logTrace("removeTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from DATATYPES") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from DATATYPES2") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } -} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT1.java new file mode 100644 index 0000000000..38f8489b0c --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT1.java @@ -0,0 +1,802 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.access.property; + +import java.util.Arrays; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.core.types.common.Grade; + +public class ClientIT1 extends Client { + + + public ClientIT1() { + } + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + + super.setup(); + removeTestData(); + createTestData(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: propertyTypeTest1 + * + * @assertion_ids: PERSISTENCE:SPEC:514; PERSISTENCE:SPEC:515; + * PERSISTENCE:SPEC:516; PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; + * PERSISTENCE:SPEC:534; PERSISTENCE:SPEC:1327.4; PERSISTENCE:SPEC:1153; + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Character + */ + @Test + public void propertyTypeTest1() throws Exception { + + boolean pass = false; + final Character newChar = 'b'; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getCharacterData().equals((char) 'a'))) { + d1.setCharacterData(newChar); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getCharacterData().equals(newChar)) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest1 failed"); + } + + /* + * @testName: propertyTypeTest2 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; + * PERSISTENCE:SPEC:533; PERSISTENCE:SPEC:534 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Short + */ + @Test + public void propertyTypeTest2() throws Exception { + + boolean pass = false; + final Short newShort = 101; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getShortData().equals((short) 100))) { + d1.setShortData(newShort); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getShortData().equals(newShort)) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest2 failed"); + } + + /* + * @testName: propertyTypeTest3 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Integer + */ + @Test + public void propertyTypeTest3() throws Exception { + + boolean pass = false; + final Integer newInt = 500; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getIntegerData().equals(500))) { + d1.setIntegerData(newInt); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getIntegerData().equals(newInt)) { + pass = true; + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest3 failed"); + } + + /* + * @testName: propertyTypeTest4 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Long + */ + @Test + public void propertyTypeTest4() throws Exception { + + boolean pass = false; + final Long newLong = 600L; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getLongData().equals(300L))) { + d1.setLongData(newLong); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getLongData().equals(newLong)) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest4 failed"); + } + + /* + * @testName: propertyTypeTest5 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Double + */ + @Test + public void propertyTypeTest5() throws Exception { + + boolean pass = false; + final Double newDbl = 80D; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getDoubleData().equals(50D))) { + d1.setDoubleData(newDbl); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getDoubleData().equals(newDbl)) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest5 failed"); + + } + + /* + * @testName: propertyTypeTest6 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Float + */ + @Test + public void propertyTypeTest6() throws Exception { + + boolean pass = false; + final Float newFloat = 3.0F; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getFloatData().equals(1.0F))) { + d1.setFloatData(newFloat); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getFloatData().equals(newFloat)) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest6 failed"); + + } + + /* + * @testName: propertyTypeTest7 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:529; + * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:JAVADOC:72; + * PERSISTENCE:JAVADOC:73 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: enums + * + * Using the Enumerated annotation, with EnumType.ORDINAL. + */ + @Test + public void propertyTypeTest7() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + TestUtil.logTrace("DataType Entity is not null, setting enumData "); + d1.setEnumData(Grade.C); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + TestUtil.logTrace("Check results"); + if ((null != d1) && (d1.getEnumData().equals(Grade.C))) { + TestUtil.logTrace("Expected Grade of:" + d1.getEnumData() + "received"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results. Expected C, got: " + d1.getEnumData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest7 failed"); + } + + /* + * @testName: propertyTypeTest8 + * + * @assertion_ids: PERSISTENCE:SPEC:536; PERSISTENCE:SPEC:540; + * PERSISTENCE:SPEC:550; PERSISTENCE:SPEC:1090.0; PERSISTENCE:SPEC:1079 + * + * @test_Strategy: The primary key should be one of the following types: + * java.util.Date + * + * The application must not change the value of the primary key. The behavior is + * undefined if this occurs. + * + * Temporal.TemporalType.DATE + */ + @Test + public void propertyTypeTest8() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + clearCache(); + d2 = null; + d2 = getEntityManager().find(DataTypes2.class, dateId); + if (null != d2) { + + TestUtil.logTrace("Check results"); + if (d2.getId().equals(dateId)) { + TestUtil.logTrace("Got expected PK of:" + d2.getId() + "received"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results. " + "Expected " + dateId + ", got: " + d2.getId()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest8 failed"); + } + + /* + * @testName: propertyTypeTest9 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: Byte[] + * + */ + @Test + public void propertyTypeTest9() throws Exception { + + boolean pass = false; + final Byte[] b = { 31, 32, 33, 63, 64, 65 }; + final Byte bv = 5; + Byte[] a = null; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + TestUtil.logTrace("DataType Entity is not null, setting byteData "); + d1.setByteArrayData(b); + a = d1.getByteArrayData(); + a[0] = (byte) (a[0] + bv); + d1.setByteArrayData(b); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + TestUtil.logTrace("Check results"); + if ((null != d1) && (Arrays.equals(d1.getByteArrayData(), a))) { + TestUtil.logTrace("propertyTypeTest9: Expected results received"); + pass = true; + } else { + TestUtil.logErr("Unexpected result in array comparison."); + for (Byte aByte : a) { + TestUtil.logTrace("Array a in propertyTest9 equals: " + aByte); + } + for (Byte bByte : b) { + TestUtil.logTrace("Array b in propertyTest9 equals: " + bByte); + } + pass = false; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest9 failed"); + } + + /* + * @testName: propertyTypeTest10 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: Character[] + * + */ + @Test + public void propertyTypeTest10() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + Character[] charData = new Character[] { (char) 'C', (char) 'T', (char) 'S' }; + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + TestUtil.logTrace("DataType Entity is not null, setting CharacterData "); + d1.setCharArrayData(charData); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + TestUtil.logTrace("propertyTypeTest10: Check results"); + if ((null != d1) && (Arrays.equals(d1.getCharArrayData(), charData))) { + TestUtil.logTrace("propertyTypeTest10: Expected Results Received"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results. " + "Expected " + Arrays.toString(charData) + + ", got: " + Arrays.toString(d1.getCharArrayData())); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest10 failed"); + } + + /* + * @testName: propertyTypeTest11 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: java.sql.Time + */ + @Test + public void propertyTypeTest11() throws Exception { + + boolean pass = false; + final java.sql.Time timeValue = getTimeData(18, 30, 15); + + try { + getEntityTransaction().begin(); + clearCache(); + d2 = null; + d2 = getEntityManager().find(DataTypes2.class, dateId); + + if (null != d2) { + TestUtil.logTrace("DataType Entity is not null, setting TimeData "); + d2.setTimeData(timeValue); + + getEntityManager().merge(d2); + getEntityManager().flush(); + + TestUtil.logTrace("propertyTypeTest11: Check results"); + if ((null != d2) && (d2.getTimeData().equals(timeValue))) { + TestUtil.logTrace("propertyTypeTest11: Expected Time Received"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results. " + " Expected " + timeValue + " , got: " + + d2.getTimeData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest11 failed"); + } + + /* + * @testName: propertyTypeTest12 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527 + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: java.sql.Timestamp + */ + @Test + public void propertyTypeTest12() throws Exception { + + boolean pass = false; + final java.sql.Timestamp tsValue = getTimestampData(2006, 02, 11); + + try { + getEntityTransaction().begin(); + clearCache(); + d2 = null; + d2 = getEntityManager().find(DataTypes2.class, dateId); + + if (null != d2) { + TestUtil.logTrace("DataType Entity is not null, setting TimestampData "); + d2.setTsData(tsValue); + + getEntityManager().merge(d2); + getEntityManager().flush(); + + TestUtil.logTrace("propertyTypeTest12: Check results"); + if ((null != d2) && (d2.getTsData().equals(tsValue))) { + TestUtil.logTrace("propertyTypeTest12: Expected Timestamp Received"); + pass = true; + } else { + TestUtil.logErr( + "Did not get expected results. " + " Expected " + tsValue + " , got: " + d2.getTsData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest12 failed"); + } + + /* + * @testName: propertyTypeTest13 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; + * + * @test_Strategy: The persistent property of an entity may be of the following + * type: wrappers of the primitive types: Boolean + */ + @Test + public void propertyTypeTest13() throws Exception { + + boolean pass = false; + final Boolean newBoolean = false; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getBooleanData().equals(true))) { + d1.setBooleanData(newBoolean); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getBooleanData().equals(newBoolean)) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("propertyTypeTest13 failed"); + } + + + // Methods used for Tests + + public void createTestData() { + TestUtil.logTrace("createTestData"); + + try { + getEntityTransaction().begin(); + Character[] cArray = { 'a' }; + Byte[] bArray = { (byte) 100 }; + d1 = new DataTypes(1, true, 'a', (short) 100, 500, 300L, 50D, 1.0F, cArray, bArray); + + d2 = new DataTypes2(dateId); + + getEntityManager().persist(d1); + getEntityManager().persist(d2); + + getEntityManager().flush(); + + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + + + } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/assocoverride/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/assocoverride/Client.java index f35ef78a4c..39028cadb5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/assocoverride/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/assocoverride/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -17,172 +17,162 @@ package com.sun.ts.tests.jpa.core.annotations.assocoverride; import java.sql.Date; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; public class Client extends PMClientBase { - private static PartTimeEmployee ptRef[] = new PartTimeEmployee[5]; - - private static Address aRef[] = new Address[5]; - - final private Date d1 = getSQLDate(2000, 2, 14); - - final private Date d2 = getSQLDate(2001, 6, 27); - - final private Date d3 = getSQLDate(2002, 7, 7); - - final private Date d4 = getSQLDate(2003, 3, 3); - - final private Date d5 = getSQLDate(2004, 4, 10); - - public Client() { - } - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - - super.setup(args, p); - removeTestData(); - createTestData(); - TestUtil.logTrace("Done creating test data"); - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - /* - * @testName: associationOverride - * - * @assertion_ids: PERSISTENCE:SPEC:593; PERSISTENCE:SPEC:596; - * PERSISTENCE:SPEC:597; PERSISTENCE:SPEC:598; PERSISTENCE:SPEC:599; - * PERSISTENCE:SPEC:1130; PERSISTENCE:SPEC:1131; PERSISTENCE:SPEC:1132; - * PERSISTENCE:SPEC:1133; PERSISTENCE:SPEC:1061; PERSISTENCE:SPEC:1062; - * PERSISTENCE:JAVADOC:4; PERSISTENCE:JAVADOC:5; PERSISTENCE:JAVADOC:6; - * PERSISTENCE:JAVADOC:2; PERSISTENCE:JAVADOC:1; PERSISTENCE:SPEC:1964; - * PERSISTENCE:SPEC:1965; PERSISTENCE:SPEC:1969; - * - * @test_Strategy: An entity may have a mapped superclass which provides - * persistent entity state and mapping information. Use AssociationOverride - * annotation - */ - public void associationOverride() throws Exception { - - TestUtil.logTrace("Begin AssociationOverride"); - boolean pass = false; - - try { - PartTimeEmployee ptEmp1 = getEntityManager().find(PartTimeEmployee.class, - 6); - - if (ptEmp1.getAddress().getStreet().equals("1 Network Drive")) { - pass = true; - } - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - if (!pass) { - throw new Fault("test2 failed"); - } - } - - public void createTestData() { - - try { - - getEntityTransaction().begin(); - - ptRef[0] = new PartTimeEmployee(6, "Kellie", "Lee", d5, 60000.0F); - ptRef[1] = new PartTimeEmployee(7, "Nicole", "Martin", d4, 60000.0F); - ptRef[2] = new PartTimeEmployee(8, "Mark", "Francis", d3, 60000.0F); - ptRef[3] = new PartTimeEmployee(9, "Will", "Forrest", d2, 60000.0F); - ptRef[4] = new PartTimeEmployee(10, "Katy", "Hughes", d1, 60000.0F); - - // create Addresses - aRef[0] = new Address("100", "1 Network Drive", "Burlington", "MA", - "01803"); - aRef[1] = new Address("200", "4150 Network Drive", "Santa Clara", "CA", - "95054"); - aRef[2] = new Address("300", "2 Network Drive", "Burlington", "MA", - "01803"); - aRef[3] = new Address("400", "5150 Network Drive", "Santa Clara", "CA", - "95054"); - aRef[4] = new Address("500", "3 Network Drive", "Burlington", "MA", - "01803"); - - // Set Addresse to Employee - ptRef[0].setAddress(aRef[0]); - ptRef[1].setAddress(aRef[1]); - ptRef[2].setAddress(aRef[2]); - ptRef[3].setAddress(aRef[3]); - ptRef[4].setAddress(aRef[4]); - - TestUtil.logTrace("Persist part time employees "); - for (int i = 0; i < 5; i++) { - getEntityManager().persist(aRef[i]); - TestUtil.logTrace("persisted Address " + aRef[i]); - getEntityManager().persist(ptRef[i]); - TestUtil.logTrace("persisted employee " + ptRef[i]); - } - getEntityTransaction().commit(); - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception creating test data:", re); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception rolling back TX:", re); - } - } - } - - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - private void removeTestData() { - TestUtil.logTrace("removeTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from EMPLOYEE") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from PARTTIMEEMPLOYEE") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from ADDRESS") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } + private static PartTimeEmployee ptRef[] = new PartTimeEmployee[5]; + + private static Address aRef[] = new Address[5]; + + final private Date d1 = getSQLDate(2000, 2, 14); + + final private Date d2 = getSQLDate(2001, 6, 27); + + final private Date d3 = getSQLDate(2002, 7, 7); + + final private Date d4 = getSQLDate(2003, 3, 3); + + final private Date d5 = getSQLDate(2004, 4, 10); + + public Client() { + } + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + + super.setup(); + removeTestData(); + createTestData(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: associationOverride + * + * @assertion_ids: PERSISTENCE:SPEC:593; PERSISTENCE:SPEC:596; + * PERSISTENCE:SPEC:597; PERSISTENCE:SPEC:598; PERSISTENCE:SPEC:599; + * PERSISTENCE:SPEC:1130; PERSISTENCE:SPEC:1131; PERSISTENCE:SPEC:1132; + * PERSISTENCE:SPEC:1133; PERSISTENCE:SPEC:1061; PERSISTENCE:SPEC:1062; + * PERSISTENCE:JAVADOC:4; PERSISTENCE:JAVADOC:5; PERSISTENCE:JAVADOC:6; + * PERSISTENCE:JAVADOC:2; PERSISTENCE:JAVADOC:1; PERSISTENCE:SPEC:1964; + * PERSISTENCE:SPEC:1965; PERSISTENCE:SPEC:1969; + * + * @test_Strategy: An entity may have a mapped superclass which provides + * persistent entity state and mapping information. Use AssociationOverride + * annotation + */ + @Test + public void associationOverride() throws Exception { + + TestUtil.logTrace("Begin AssociationOverride"); + boolean pass = false; + + try { + PartTimeEmployee ptEmp1 = getEntityManager().find(PartTimeEmployee.class, 6); + + if (ptEmp1.getAddress().getStreet().equals("1 Network Drive")) { + pass = true; + } + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("test2 failed"); + } + } + + public void createTestData() { + + try { + + getEntityTransaction().begin(); + + ptRef[0] = new PartTimeEmployee(6, "Kellie", "Lee", d5, 60000.0F); + ptRef[1] = new PartTimeEmployee(7, "Nicole", "Martin", d4, 60000.0F); + ptRef[2] = new PartTimeEmployee(8, "Mark", "Francis", d3, 60000.0F); + ptRef[3] = new PartTimeEmployee(9, "Will", "Forrest", d2, 60000.0F); + ptRef[4] = new PartTimeEmployee(10, "Katy", "Hughes", d1, 60000.0F); + + // create Addresses + aRef[0] = new Address("100", "1 Network Drive", "Burlington", "MA", "01803"); + aRef[1] = new Address("200", "4150 Network Drive", "Santa Clara", "CA", "95054"); + aRef[2] = new Address("300", "2 Network Drive", "Burlington", "MA", "01803"); + aRef[3] = new Address("400", "5150 Network Drive", "Santa Clara", "CA", "95054"); + aRef[4] = new Address("500", "3 Network Drive", "Burlington", "MA", "01803"); + + // Set Addresse to Employee + ptRef[0].setAddress(aRef[0]); + ptRef[1].setAddress(aRef[1]); + ptRef[2].setAddress(aRef[2]); + ptRef[3].setAddress(aRef[3]); + ptRef[4].setAddress(aRef[4]); + + TestUtil.logTrace("Persist part time employees "); + for (int i = 0; i < 5; i++) { + getEntityManager().persist(aRef[i]); + TestUtil.logTrace("persisted Address " + aRef[i]); + getEntityManager().persist(ptRef[i]); + TestUtil.logTrace("persisted employee " + ptRef[i]); + } + getEntityTransaction().commit(); + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception creating test data:", re); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception rolling back TX:", re); + } + } + } + + @AfterEach + public void cleanup() throws Exception { + TestUtil.logTrace("cleanup"); + removeTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeTestData() { + TestUtil.logTrace("removeTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("Delete from EMPLOYEE").executeUpdate(); + getEntityManager().createNativeQuery("Delete from PARTTIMEEMPLOYEE").executeUpdate(); + getEntityManager().createNativeQuery("Delete from ADDRESS").executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/Client.java index c88c8c7e7a..5149007602 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,10 +22,7 @@ import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; -import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,1265 +30,7 @@ public class Client extends PMClientBase { public Client() { } - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - } catch (Exception e) { - throw new Fault("Setup failed:", e); - - } - } - - public void setupData(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setupData"); - try { - super.setup(args, p); - removeTestData(); - createTestData(); - } catch (Exception e) { - throw new Fault("Setup failed:", e); - } - } - - /* - * @testName: persistBasicTest1 - * - * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:614; - * PERSISTENCE:SPEC:671; PERSISTENCE:SPEC:675; PERSISTENCE:SPEC:1069; - * PERSISTENCE:SPEC:1072; PERSISTENCE:SPEC:1073; PERSISTENCE:SPEC:1074; - * PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; PERSISTENCE:SPEC:1077; - * PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; PERSISTENCE:SPEC:1081; - * PERSISTENCE:SPEC:1082; PERSISTENCE:JAVADOC:308; PERSISTENCE:SPEC:1990; - * - * - * @test_Strategy: A new entity bean instance has no persistent identity and - * is not yet associated to a persistent context. - * - * The contains method (used to determine whether an entity instance is in the - * managed state in the current persistence context) returns false: - * - * If the instance is new and the persist method has not been on the entity. - * - * Instantiate an entity and verify the contains method returns false. - */ - public void persistBasicTest1() throws Exception { - - TestUtil.logTrace("Begin persistBasicTest1"); - - boolean pass = false; - A aRef; - try { - - final Integer integer = 1234; - final short basicShort = 12; - final Short basicBigShort = basicShort; - final float basicFloat = 12.3f; - final Float basicBigFloat = basicFloat; - final long basicLong = 1234l; - final Long basicBigLong = basicLong; - final double basicDouble = 1234.5; - final Double basicBigDouble = basicDouble; - final char[] charArray = { 'a', 'b', 'c' }; - final Character[] bigCharacterArray = { 'a', 'b', 'c' }; - final byte[] byteArray = "abc".getBytes(); - final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; - final BigInteger bigInteger = new BigInteger("12345"); - final BigDecimal bigDecimal = new BigDecimal(bigInteger); - final Date date = new Date(); - final long timeInSeconds = date.getTime(); - final Time time = new Time(timeInSeconds); - final Timestamp timeStamp = new Timestamp(timeInSeconds); - final Calendar calendar = Calendar.getInstance(); - - aRef = new A("1", "a1", 1, integer, basicShort, basicBigShort, basicFloat, - basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, - 'a', charArray, bigCharacterArray, byteArray, bigByteArray, - bigInteger, bigDecimal, date, time, timeStamp, calendar); - - getEntityTransaction().begin(); - if (!getInstanceStatus(aRef)) { - pass = true; - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass) { - throw new Fault("persistBasicTest1 failed"); - } - - } - - /* - * @testName: persistBasicTest2 - * - * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:615; - * PERSISTENCE:SPEC:619; PERSISTENCE:SPEC:667; PERSISTENCE:SPEC:669; - * PERSISTENCE:SPEC:1069; PERSISTENCE:SPEC:1073; PERSISTENCE:SPEC:1074; - * PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; PERSISTENCE:SPEC:1077; - * PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; PERSISTENCE:SPEC:1081; - * PERSISTENCE:SPEC:1082; PERSISTENCE:SPEC:1072; - * - * @test_Strategy: The new entity bean instance becomes both managed and - * persistent by invoking the persist method on it. The semantics of the - * persist operation as applied to entity X is as follows: - * - * If X is a new entity, it becomes managed. - * - * Invoke persist on the new entity. Find the entity instance and ensure it is - * managed by calling contains() verifying it returns true. - */ - public void persistBasicTest2() throws Exception { - - TestUtil.logTrace("Begin persistBasicTest2"); - - boolean pass = false; - A aRef; - - try { - TestUtil.logTrace("new A"); - - final Integer integer = 1234; - final short basicShort = 12; - final Short basicBigShort = basicShort; - final float basicFloat = 12.3f; - final Float basicBigFloat = basicFloat; - final long basicLong = 1234l; - final Long basicBigLong = basicLong; - final double basicDouble = 1234.5; - final Double basicBigDouble = basicDouble; - final char[] charArray = { 'a', 'b', 'c' }; - final Character[] bigCharacterArray = { 'a', 'b', 'c' }; - final byte[] byteArray = "abc".getBytes(); - final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; - final BigInteger bigInteger = new BigInteger("12345"); - final BigDecimal bigDecimal = new BigDecimal(bigInteger); - final Date date = new Date(); - final long timeInSeconds = date.getTime(); - final Time time = new Time(timeInSeconds); - final Timestamp timeStamp = new Timestamp(timeInSeconds); - final Calendar calendar = Calendar.getInstance(); - - aRef = new A("2", "a2", 2, integer, basicShort, basicBigShort, basicFloat, - basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, - 'a', charArray, bigCharacterArray, byteArray, bigByteArray, - bigInteger, bigDecimal, date, time, timeStamp, calendar); - - createA(aRef); - - A newA = findA("2"); - - if (newA != null) { - TestUtil.logTrace("A IS NOT NULL"); - } - - getEntityTransaction().begin(); - pass = getInstanceStatus(findA("2")); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass) { - throw new Fault("persistBasicTest2 failed"); - } - - } - - /* - * @testName: persistBasicTest3 - * - * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:618; - * PERSISTENCE:SPEC:620; PERSISTENCE:SPEC:1069; PERSISTENCE:SPEC:1073; - * PERSISTENCE:SPEC:1074; PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; - * PERSISTENCE:SPEC:1077; PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; - * PERSISTENCE:SPEC:1081; PERSISTENCE:SPEC:1082; PERSISTENCE:SPEC:1072; - * - * @test_Strategy: The new entity bean instance becomes both managed and - * persistent by invoking the persist method on it. The semantics of the - * persist operation as applied to entity X is as follows: - * - * The entity X will be entered into the database at or before transaction - * commit or as a result of the flush operation. - * - * Create a new entity instance, invoke flush(), then attempt to access the - * entity by find and invoking a query on it. - * - */ - public void persistBasicTest3() throws Exception { - - TestUtil.logTrace("Begin persistBasicTest3"); - - String aName = null; - boolean pass = false; - Object result; - A a1; - - try { - getEntityTransaction().begin(); - - final Integer integer = 1234; - final short basicShort = 12; - final Short basicBigShort = basicShort; - final float basicFloat = 12.3f; - final Float basicBigFloat = basicFloat; - final long basicLong = 1234l; - final Long basicBigLong = basicLong; - final double basicDouble = 1234.5; - final Double basicBigDouble = basicDouble; - final char[] charArray = { 'a', 'b', 'c' }; - final Character[] bigCharacterArray = { 'a', 'b', 'c' }; - final byte[] byteArray = "abc".getBytes(); - final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; - final BigInteger bigInteger = new BigInteger("12345"); - final BigDecimal bigDecimal = new BigDecimal(bigInteger); - final Date date = new Date(); - final long timeInSeconds = date.getTime(); - final Time time = new Time(timeInSeconds); - final Timestamp timeStamp = new Timestamp(timeInSeconds); - final Calendar calendar = Calendar.getInstance(); - - a1 = new A("3", "a3", 3, integer, basicShort, basicBigShort, basicFloat, - basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, - 'a', charArray, bigCharacterArray, byteArray, bigByteArray, - bigInteger, bigDecimal, date, time, timeStamp, calendar); - - TestUtil.logTrace("Persist Instance"); - getEntityManager().persist(a1); - getEntityManager().flush(); - - TestUtil.logTrace("find By Name"); - result = (A) findByName("a3"); - - TestUtil.logTrace("Check to see that the entities are identical"); - if (result == a1) { - pass = true; - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception fe) { - TestUtil.logErr("Unexpected exception rolling back transaction", fe); - } - } - - if (!pass) { - throw new Fault("persistBasicTest3 failed"); - } - - } - - /* - * @testName: persistBasicTest4 - * - * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:618; - * PERSISTENCE:SPEC:621; PERSISTENCE:SPEC:1069; PERSISTENCE:SPEC:1073; - * PERSISTENCE:SPEC:1074; PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; - * PERSISTENCE:SPEC:1077; PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; - * PERSISTENCE:SPEC:1081; PERSISTENCE:SPEC:1082; PERSISTENCE:SPEC:1072; - * - * @test_Strategy: The new entity bean instance becomes both managed and - * persistent by invoking the persist method on it. The semantics of the - * persist operation as applied to entity X is as follows: - * - * If X is preexisting managed entity, it is ignored by the persist operation. - * - * Invoke persist on an already managed instance. Ensure no exception is - * thrown and that the entity is still persisted and managed. - * - */ - public void persistBasicTest4() throws Exception { - - TestUtil.logTrace("Begin persistBasicTest4"); - - boolean pass = false; - A aRef; - try { - - TestUtil.logTrace("Persist Instance"); - - final Integer integer = 1234; - final short basicShort = 12; - final Short basicBigShort = basicShort; - final float basicFloat = 12.3f; - final Float basicBigFloat = basicFloat; - final long basicLong = 1234l; - final Long basicBigLong = basicLong; - final double basicDouble = 1234.5; - final Double basicBigDouble = basicDouble; - final char[] charArray = { 'a', 'b', 'c' }; - final Character[] bigCharacterArray = { 'a', 'b', 'c' }; - final byte[] byteArray = "abc".getBytes(); - final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; - final BigInteger bigInteger = new BigInteger("12345"); - final BigDecimal bigDecimal = new BigDecimal(bigInteger); - final Date date = new Date(); - final long timeInSeconds = date.getTime(); - final Time time = new Time(timeInSeconds); - final Timestamp timeStamp = new Timestamp(timeInSeconds); - final Calendar calendar = Calendar.getInstance(); - - aRef = new A("4", "a4", 4, integer, basicShort, basicBigShort, basicFloat, - basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, - 'a', charArray, bigCharacterArray, byteArray, bigByteArray, - bigInteger, bigDecimal, date, time, timeStamp, calendar); - - createA(aRef); - - getEntityTransaction().begin(); - TestUtil.logTrace("get Instance Status "); - if (getInstanceStatus(findA("4"))) { - try { - TestUtil.logTrace("entity is managed, try to persist again "); - A newA = findA("4"); - getEntityManager().persist(newA); - TestUtil.logTrace( - "Persist ignored on an already persisted entity as expected"); - pass = true; - } catch (Exception ee) { - TestUtil.logErr("Unexpected exception trying to persist an" - + " already persisted entity", ee); - pass = false; - } - - } else { - TestUtil.logTrace("Instance is not managed. Test Fails."); - pass = false; - } - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected exception rolling back transaction", re); - } - } - - if (!pass) { - throw new Fault("persistBasicTest4 failed"); - } - } - - /* - * @testName: persistBasicTest5 - * - * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:618; - * PERSISTENCE:SPEC:641; PERSISTENCE:SPEC:642; PERSISTENCE:SPEC:1069; - * PERSISTENCE:SPEC:1072; PERSISTENCE:SPEC:1073; PERSISTENCE:SPEC:1074; - * PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; PERSISTENCE:SPEC:1077; - * PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; PERSISTENCE:SPEC:1081; - * PERSISTENCE:SPEC:1082; PERSISTENCE:JAVADOC:8 - * - * @test_Strategy: The flush method can be used for force synchronization. The - * semantics of the flush operation applied to an entity X is as follows: - * - * If X is a managed entity, it is synchronized to the database. - * - * Execute flush on a managed entity and ensure the database reflects the - * change. - * - */ - public void persistBasicTest5() throws Exception { - - TestUtil.logTrace("Begin persistBasicTest5"); - A a2; - A aRef; - - boolean pass = true; - try { - final Integer integer = 1234; - final short basicShort = 12; - final Short basicBigShort = basicShort; - final float basicFloat = 12.3f; - final Float basicBigFloat = basicFloat; - final long basicLong = 1234l; - final Long basicBigLong = basicLong; - final double basicDouble = 1234.5; - final Double basicBigDouble = basicDouble; - final char[] charArray = { 'a', 'b', 'c' }; - final Character[] bigCharacterArray = { 'a', 'b', 'c' }; - final byte[] byteArray = "abc".getBytes(); - final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; - final BigInteger bigInteger = new BigInteger("12345"); - final BigDecimal bigDecimal = new BigDecimal(bigInteger); - final Date date = new Date(); - final long timeInSeconds = date.getTime(); - final Time time = new Time(timeInSeconds); - final Timestamp timeStamp = new Timestamp(timeInSeconds); - final Calendar calendar = Calendar.getInstance(); - - aRef = new A("5", null, 5, integer, basicShort, basicBigShort, basicFloat, - basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, - 'a', charArray, bigCharacterArray, byteArray, bigByteArray, - bigInteger, bigDecimal, date, time, timeStamp, calendar); - - TestUtil.logTrace("Persist Instance"); - createA(aRef); - - getEntityTransaction().begin(); - TestUtil.logTrace("get Instance Status "); - if (getInstanceStatus(findA("5"))) { - try { - TestUtil.logTrace("entity is managed, try to change name and flush "); - a2 = findA("5"); - if (a2.getName() == null) { - TestUtil.logTrace("Received Name as null"); - } else { - TestUtil.logErr("Expected null name, actual:" + a2.getName()); - pass = false; - } - a2.setName("a2"); - getEntityManager().flush(); - if (a2.getName().equals("a2")) { - TestUtil.logTrace("sync to database successful"); - } - } catch (Exception ee) { - TestUtil.logErr( - "Unexpected exception trying to flush a" + "persisted entity", - ee); - pass = false; - } - - } else { - TestUtil.logTrace("Instance is not already persisted. Test Fails."); - pass = false; - } - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected exception rolling back transaction", re); - } - - } - - if (!pass) { - throw new Fault("persistBasicTest5 failed"); - } - } - - /* - * @testName: DoubleOperandResultTypeTests - * - * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.1; - * PERSISTENCE:SPEC:1685; - * - * @test_Strategy: Test various operands result in various types - * - */ - @SetupMethod(name = "setupData") - public void DoubleOperandResultTypeTests() throws Exception { - boolean pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8; - pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = pass7 = pass8 = false; - Object p; - - try { - TestUtil.logMsg("Testing + Double operand:"); - getEntityTransaction().begin(); - double whereValue = 1234.5; - p = getEntityManager().createQuery( - "Select (a.basicBigDouble + 1) From A a where (a.basicBigDouble = ?1)") - .setParameter(1, whereValue).getSingleResult(); - if (p instanceof Double) { - TestUtil.logTrace("Received expected Double type"); - pass1 = true; - } else { - TestUtil - .logErr("Result was not of type Double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - Double operand:"); - getEntityTransaction().begin(); - double whereValue = 1234.0; - p = getEntityManager().createQuery( - "Select (a.basicBigDouble - 1) From A a where (a.basicBigDouble > ?1)") - .setParameter(1, whereValue).getSingleResult(); - if (p instanceof Double) { - TestUtil.logTrace("Received expected Double type"); - pass2 = true; - } else { - TestUtil - .logErr("Result was not of type Double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * Double operand:"); - getEntityTransaction().begin(); - double whereValue = 1235.0; - p = getEntityManager().createQuery( - "Select (a.basicBigDouble * 1) From A a where (a.basicBigDouble < ?1)") - .setParameter(1, whereValue).getSingleResult(); - - if (p instanceof Double) { - TestUtil.logTrace("Received expected Double type"); - pass3 = true; - } else { - TestUtil - .logErr("Result was not of type Double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing / Double operand:"); - getEntityTransaction().begin(); - double whereValue = 1235.0; - p = getEntityManager().createQuery( - "Select (a.basicBigDouble / 1) From A a where (a.basicBigDouble <> ?1)") - .setParameter(1, whereValue).getSingleResult(); - if (p instanceof Double) { - TestUtil.logTrace("Received expected Double type"); - pass4 = true; - } else { - TestUtil - .logErr("Result was not of type Double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing + double operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicDouble + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Double) { - TestUtil.logTrace("Received expected double type"); - pass5 = true; - } else { - TestUtil - .logErr("Result was not of type double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - double operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicDouble - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Double) { - TestUtil.logTrace("Received expected double type"); - pass6 = true; - } else { - TestUtil - .logErr("Result was not of type double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * double operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicDouble * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Double) { - TestUtil.logTrace("Received expected double type"); - pass7 = true; - } else { - TestUtil - .logErr("Result was not of type double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing / double operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicDouble / 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Double) { - TestUtil.logTrace("Received expected double type"); - pass8 = true; - } else { - TestUtil - .logErr("Result was not of type double:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 - || !pass8) - throw new Fault("DoubleOperandResultTypeTests failed"); - } - - /* - * @testName: FloatOperandResultTypeTests - * - * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.2; - * - * @test_Strategy: Test various operands result in various types - * - */ - @SetupMethod(name = "setupData") - public void FloatOperandResultTypeTests() throws Exception { - boolean pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8; - pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = pass7 = pass8 = false; - Object p; - try { - TestUtil.logMsg("Testing + Float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigFloat + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Float) { - TestUtil.logTrace("Received expected Float type"); - pass1 = true; - } else { - TestUtil - .logErr("Result was not of type Float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - Float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigFloat - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Float) { - TestUtil.logTrace("Received expected Float type"); - pass2 = true; - } else { - TestUtil - .logErr("Result was not of type Float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * Float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigFloat * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Float) { - TestUtil.logTrace("Received expected Float type"); - pass3 = true; - } else { - TestUtil - .logErr("Result was not of type Float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing / Float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigFloat / 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Float) { - TestUtil.logTrace("Received expected Float type"); - pass4 = true; - } else { - TestUtil - .logErr("Result was not of type Float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing + float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicFloat + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Float) { - TestUtil.logTrace("Received expected float type"); - pass5 = true; - } else { - TestUtil - .logErr("Result was not of type float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicFloat - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Float) { - TestUtil.logTrace("Received expected float type"); - pass6 = true; - } else { - TestUtil - .logErr("Result was not of type float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicFloat * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Float) { - TestUtil.logTrace("Received expected float type"); - pass7 = true; - } else { - TestUtil - .logErr("Result was not of type float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing / float operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigFloat / 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Float) { - TestUtil.logTrace("Received expected Float type"); - pass8 = true; - } else { - TestUtil - .logErr("Result was not of type Float:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 - || !pass8) - throw new Fault("FloatOperandResultTypeTests failed"); - } - - /* - * @testName: BigDecimalOperandResultTypeTests - * - * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.3; - * - * @test_Strategy: Test various operands result in various types - * - */ - @SetupMethod(name = "setupData") - public void BigDecimalOperandResultTypeTests() throws Exception { - boolean pass1, pass2, pass3, pass4; - pass1 = pass2 = pass3 = pass4 = false; - Object p; - try { - TestUtil.logMsg("Testing + BigDecimal operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigDecimal + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof BigDecimal) { - TestUtil.logTrace("Received expected BigDecimal type"); - pass1 = true; - } else { - TestUtil.logErr( - "Result was not of type BigDecimal:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - BigDecimal operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigDecimal - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof BigDecimal) { - TestUtil.logTrace("Received expected BigDecimal type"); - pass2 = true; - } else { - TestUtil.logErr( - "Result was not of type BigDecimal:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * BigDecimal operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigDecimal * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof BigDecimal) { - TestUtil.logTrace("Received expected BigDecimal type"); - pass3 = true; - } else { - TestUtil.logErr( - "Result was not of type BigDecimal:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing / BigDecimal operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigDecimal / 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof BigDecimal) { - TestUtil.logTrace("Received expected BigDecimal type"); - pass4 = true; - } else { - TestUtil.logErr( - "Result was not of type BigDecimal:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - if (!pass1 || !pass2 || !pass3 || !pass4) - throw new Fault("BigDecimalOperandResultTypeTests failed"); - } - - /* - * @testName: BigIntegerOperandResultTypeTests - * - * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.4; - * - * @test_Strategy: Test various operands result in various types - * - */ - @SetupMethod(name = "setupData") - public void BigIntegerOperandResultTypeTests() throws Exception { - boolean pass1, pass2, pass3; - pass1 = pass2 = pass3 = false; - Object p; - try { - TestUtil.logMsg("Testing + BigInteger operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigInteger + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof BigInteger) { - TestUtil.logTrace("Received expected BigInteger type"); - pass1 = true; - } else { - TestUtil.logErr( - "Result was not of type BigInteger:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - BigInteger operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigInteger - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof BigInteger) { - TestUtil.logTrace("Received expected BigInteger type"); - pass2 = true; - } else { - TestUtil.logErr( - "Result was not of type BigInteger:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * BigInteger operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigInteger * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof BigInteger) { - TestUtil.logTrace("Received expected BigInteger type"); - pass3 = true; - } else { - TestUtil.logErr( - "Result was not of type BigInteger:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass1 || !pass2 || !pass3) - throw new Fault("BigIntegerOperandResultTypeTests failed"); - } - - /* - * @testName: LongOperandResultTypeTests - * - * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.5; - * - * @test_Strategy: Test various operands result in various types - * - */ - @SetupMethod(name = "setupData") - public void LongOperandResultTypeTests() throws Exception { - boolean pass1, pass2, pass3, pass4, pass5, pass6; - pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = false; - Object p; - try { - TestUtil.logMsg("Testing + Long operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigLong + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Long) { - TestUtil.logTrace("Received expected Long type"); - pass1 = true; - } else { - TestUtil - .logErr("Result was not of type Long:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - Long operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigLong - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Long) { - TestUtil.logTrace("Received expected Long type"); - pass2 = true; - } else { - TestUtil - .logErr("Result was not of type Long:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * Long operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigLong * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Long) { - TestUtil.logTrace("Received expected Long type"); - pass3 = true; - } else { - TestUtil - .logErr("Result was not of type Long:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - try { - TestUtil.logMsg("Testing + long operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicLong + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Long) { - TestUtil.logTrace("Received expected long type"); - pass4 = true; - } else { - TestUtil - .logErr("Result was not of type long:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - long operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicLong - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Long) { - TestUtil.logTrace("Received expected long type"); - pass5 = true; - } else { - TestUtil - .logErr("Result was not of type long:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * long operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicLong * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Long) { - TestUtil.logTrace("Received expected long type"); - pass6 = true; - } else { - TestUtil - .logErr("Result was not of type long:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) - throw new Fault("LongOperandResultTypeTests failed"); - } - - /* - * @testName: ShortOperandResultTypeTests - * - * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.6; - * - * @test_Strategy: Test various operands of integral type and verify the - * result of the operation is of type Integer - * - */ - @SetupMethod(name = "setupData") - public void ShortOperandResultTypeTests() throws Exception { - boolean pass1, pass2, pass3, pass4, pass5, pass6; - pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = false; - Object p; - try { - TestUtil.logMsg("Testing + Short operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigShort + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Integer) { - TestUtil.logTrace("Received expected Integer type"); - pass1 = true; - } else { - TestUtil - .logErr("Result was not of type Integer:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - Short operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigShort - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Integer) { - TestUtil.logTrace("Received expected Integer type"); - pass2 = true; - } else { - TestUtil - .logErr("Result was not of type Integer:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * Short operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery( - "Select (a.basicBigShort * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Integer) { - TestUtil.logTrace("Received expected Integer type"); - pass3 = true; - } else { - TestUtil - .logErr("Result was not of type Integer:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing + short operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicShort + 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Integer) { - TestUtil.logTrace("Received expected Integer type"); - pass4 = true; - } else { - TestUtil - .logErr("Result was not of type Integer:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing - short operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicShort - 1) From A a where (a.id = '9')") - .getSingleResult(); - if (p instanceof Integer) { - TestUtil.logTrace("Received expected Integer type"); - pass5 = true; - } else { - TestUtil - .logErr("Result was not of type Integer:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - try { - TestUtil.logMsg("Testing * short operand:"); - getEntityTransaction().begin(); - p = getEntityManager() - .createQuery("Select (a.basicShort * 1) From A a where (a.id = '9')") - .getSingleResult(); - - if (p instanceof Integer) { - TestUtil.logTrace("Received expected Integer type"); - pass6 = true; - } else { - TestUtil - .logErr("Result was not of type Integer:" + p.getClass().getName()); - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Caught exception: ", e); - } - - if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) - throw new Fault("ShortOperandResultTypeTests failed"); - } - - /* - * Business Methods for Test Cases - */ - private void createA(final A a) { - TestUtil.logTrace("Entered createA method"); - getEntityTransaction().begin(); - getEntityManager().persist(a); - // WORKAROUND - getEntityManager().flush(); - getEntityTransaction().commit(); - } - - private A findA(final String id) { - TestUtil.logTrace("Entered findA method"); - return getEntityManager().find(A.class, id); - } - - private Object findByName(final String name) { - TestUtil.logTrace("Entered findByName method"); - return getEntityManager() - .createQuery("select a from A a where a.name = :name") - .setParameter("name", name).getSingleResult(); - } - - private boolean getInstanceStatus(final Object o) { - TestUtil.logTrace("Entered getInstanceStatus method"); - return getEntityManager().contains(o); - } - - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - + public void createTestData() { try { getEntityTransaction().begin(); @@ -1340,7 +79,7 @@ public void createTestData() { } - private void removeTestData() { + protected void removeTestData() { TestUtil.logTrace("removeTestData"); if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/collectiontable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/collectiontable/Client.java index 04fbe3db77..063b9baa49 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/collectiontable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/collectiontable/Client.java @@ -18,10 +18,11 @@ import java.util.Collection; import java.util.HashSet; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +31,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -57,6 +53,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: * */ + @Test public void collectionTable1() throws Exception { TestUtil.logTrace("Begin collectionTable1"); boolean pass = false; @@ -124,7 +121,7 @@ public void collectionTable1() throws Exception { } if (!pass) { - throw new Fault("collectionTable1 failed"); + throw new Exception("collectionTable1 failed"); } } @@ -154,6 +151,7 @@ private void dumpAddresses(final Set
addr) { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/convert/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/convert/Client.java index bf81643d08..8375859b29 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/convert/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/convert/Client.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. + * * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,9 +19,11 @@ import java.util.ArrayList; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -35,20 +38,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { + @AfterEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -61,6 +59,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: */ + @Test public void convertTest() throws Exception { boolean pass = false; try { @@ -99,7 +98,7 @@ public void convertTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("convertTest failed"); + throw new Exception("convertTest failed"); } } @@ -112,6 +111,7 @@ public void convertTest() throws Exception { * @test_Strategy: Converter throws a RuntimeException wrapped by a * PersistenceException during a persist */ + @Test public void convertExceptionDuringPersistTest() throws Exception { boolean pass = false; try { @@ -144,7 +144,7 @@ public void convertExceptionDuringPersistTest() throws Exception { } } if (!pass) { - throw new Fault("convertExceptionDuringPersistTest failed"); + throw new Exception("convertExceptionDuringPersistTest failed"); } } @@ -157,6 +157,7 @@ public void convertExceptionDuringPersistTest() throws Exception { * @test_Strategy: Converter throws a RuntimeException wrapped by a * PersistenceException during a load */ + @Test public void convertExceptionDuringLoadTest() throws Exception { boolean pass = false; try { @@ -208,7 +209,7 @@ public void convertExceptionDuringLoadTest() throws Exception { } } if (!pass) { - throw new Fault("convertExceptionDuringLoadTest failed"); + throw new Exception("convertExceptionDuringLoadTest failed"); } } @@ -222,6 +223,7 @@ public void convertExceptionDuringLoadTest() throws Exception { * * @test_Strategy: Converter throws a RuntimeException during a persist */ + @Test public void convertsTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -278,7 +280,7 @@ public void convertsTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("convertsTest failed"); + throw new Exception("convertsTest failed"); } } @@ -291,6 +293,7 @@ public void convertsTest() throws Exception { * @test_Strategy: Test converter with property access and attributes from * MappedSuperClass */ + @Test public void mappedSuperClassTest() throws Exception { boolean pass = false; try { @@ -332,7 +335,7 @@ public void mappedSuperClassTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("mappedSuperClassTest failed"); + throw new Exception("mappedSuperClassTest failed"); } } @@ -344,6 +347,7 @@ public void mappedSuperClassTest() throws Exception { * * @test_Strategy: Test overriding a converter */ + @Test public void mappedSuperClass2Test() throws Exception { boolean pass = false; try { @@ -382,7 +386,7 @@ public void mappedSuperClass2Test() throws Exception { pass = false; } if (!pass) { - throw new Fault("mappedSuperClass2Test failed"); + throw new Exception("mappedSuperClass2Test failed"); } } @@ -394,6 +398,7 @@ public void mappedSuperClass2Test() throws Exception { * @test_Strategy: Test converters are applied when a JPQL or CriteriaQuery * reads from the DB */ + @Test public void convert2Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -495,7 +500,7 @@ public void convert2Test() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("converts2Test failed"); + throw new Exception("converts2Test failed"); } } @@ -508,6 +513,7 @@ public void convert2Test() throws Exception { * @test_Strategy: Test converters are applied when a JPQL or CriteriaQuery * write to the DB */ + @Test public void convert3Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -620,7 +626,7 @@ public void convert3Test() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("converts3Test failed"); + throw new Exception("converts3Test failed"); } } @@ -631,6 +637,7 @@ public void convert3Test() throws Exception { * * @test_Strategy: Test converter in an embedded entity */ + @Test public void embeddedTest() throws Exception { boolean pass = false; try { @@ -668,7 +675,7 @@ public void embeddedTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("embeddedTest failed"); + throw new Exception("embeddedTest failed"); } } @@ -679,6 +686,7 @@ public void embeddedTest() throws Exception { * * @test_Strategy: Test converter of an element collection of basic type */ + @Test public void elementCollectionBasicType() throws Exception { boolean pass = false; try { @@ -733,10 +741,11 @@ public void elementCollectionBasicType() throws Exception { pass = false; } if (!pass) { - throw new Fault("elementCollectionBasicType failed"); + throw new Exception("elementCollectionBasicType failed"); } } + @AfterAll public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/discriminatorValue/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/discriminatorValue/Client.java index 72bcd1aabd..939b7bc1f7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/discriminatorValue/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/discriminatorValue/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,7 +16,9 @@ package com.sun.ts.tests.jpa.core.annotations.discriminatorValue; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -27,15 +29,16 @@ public Client() { super(); } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -73,6 +76,7 @@ private Product newProduct(final String testName) { * * @test_Strategy: */ + @Test public void integerDiscriminatorValueTest() throws Exception { boolean pass = false; final String testName = "integerDiscriminatorValueTest"; @@ -102,7 +106,7 @@ public void integerDiscriminatorValueTest() throws Exception { } if (!pass) { - throw new Fault("integerDiscriminatorValueTest Failed"); + throw new Exception("integerDiscriminatorValueTest Failed"); } } @@ -113,6 +117,7 @@ public void integerDiscriminatorValueTest() throws Exception { * * @test_Strategy: */ + @Test public void discriminatorValueTest() throws Exception { boolean pass1 = false; final String testName = "discriminatorValueTest"; @@ -156,10 +161,11 @@ public void discriminatorValueTest() throws Exception { } if (!pass1) { - throw new Fault("discriminatorValueTest Failed"); + throw new Exception("discriminatorValueTest Failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/Client.java deleted file mode 100644 index 79f2542232..0000000000 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/Client.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.ts.tests.jpa.core.annotations.elementcollection; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.CleanupMethod; -import com.sun.ts.lib.harness.SetupMethod; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jpa.common.PMClientBase; - -public class Client extends PMClientBase { - - public Client() { - } - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setupA(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeATestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - - } - } - - public void setupCust(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeCustTestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - - } - } - - /* - * @testName: elementCollectionEmbeddableType - * - * @assertion_ids: PERSISTENCE:JAVADOC:318; PERSISTENCE:JAVADOC:319; - * PERSISTENCE:SPEC:2007; - * - * @test_Strategy: ElementCollection of an embeddable class - * - */ - @SetupMethod(name = "setupA") - @CleanupMethod(name = "cleanupA") - public void elementCollectionEmbeddableType() throws Exception { - boolean pass = false; - A aRef = null; - try { - - final Address addr1 = new Address("1 Network Drive", "Burlington", "MA", - "01801"); - final Address addr2 = new Address("Some Address", "Boston", "MA", - "01803"); - - Set
s1 = new HashSet
(); - s1.add(addr1); - s1.add(addr2); - - aRef = new A("1", "bean1", 1); - aRef.setAddress(s1); - TestUtil.logTrace("Persisting A"); - getEntityTransaction().begin(); - getEntityManager().persist(aRef); - getEntityTransaction().commit(); - - getEntityTransaction().begin(); - A newA = findA("1"); - final Set
newAddressSet = newA.getAddress(); - - dumpAddresses(newAddressSet); - - boolean pass1 = false; - boolean pass2 = false; - boolean pass3 = true; - for (Address addr : newAddressSet) { - if (addr != null) { - if (addr.getStreet().equals("1 Network Drive") - && addr.getCity().equals("Burlington") - && addr.getState().equals("MA") - && addr.getZip().equals("01801")) { - pass1 = true; - TestUtil.logTrace("pass1 = " + pass1); - } - if (addr.getStreet().equals("Some Address") - && addr.getCity().equals("Boston") && addr.getState().equals("MA") - && addr.getZip().equals("01803")) { - pass2 = true; - TestUtil.logTrace("pass2 = " + pass2); - } - } else { - TestUtil.logTrace("address=null"); - pass3 = false; - } - } - - if (pass1 && pass2 && pass3) { - pass = true; - } - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception fe) { - TestUtil.logErr("Unexpected exception rolling back TX:", fe); - } - - } - - if (!pass) { - throw new Fault("elementCollectionEmbeddableType failed"); - } - } - - /* - * @testName: elementCollectionBasicType - * - * @assertion_ids: PERSISTENCE:SPEC:2007; - * - * @test_Strategy: ElementCollection of a basic type - */ - @SetupMethod(name = "setupCust") - @CleanupMethod(name = "cleanupCust") - public void elementCollectionBasicType() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - Customer expected = new Customer("1"); - List expectedphones = new ArrayList(); - expectedphones.add("781-442-2010"); - expectedphones.add("781-442-2011"); - expectedphones.add("781-442-2012"); - - expected.setPhones(expectedphones); - TestUtil.logTrace("Persisting Customer:" + expected.toString()); - getEntityManager().persist(expected); - getEntityManager().flush(); - getEntityTransaction().commit(); - clearCache(); - getEntityTransaction().begin(); - TestUtil.logTrace( - "find the previously persisted Customer and Country and verify them"); - Customer cust = getEntityManager().find(Customer.class, expected.getId()); - if (cust != null) { - TestUtil.logTrace("Found Customer: " + cust.toString()); - if (cust.getPhones().containsAll(expectedphones) - && expectedphones.containsAll(cust.getPhones()) - && cust.getPhones().size() == expectedphones.size()) { - TestUtil.logTrace("Received expected Phones:"); - for (String s : cust.getPhones()) { - TestUtil.logTrace("phone:" + s); - } - pass = true; - } else { - TestUtil.logErr("Did not get expected results."); - for (String s : expectedphones) { - TestUtil.logErr("expected:" + s); - } - TestUtil.logErr("actual:"); - for (String s : cust.getPhones()) { - TestUtil.logErr("actual:" + s); - } - } - } else { - TestUtil.logErr("Find returned null Customer"); - } - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred: ", e); - pass = false; - } - if (!pass) { - throw new Fault("elementCollectionBasicType failed"); - } - } - - /* - * @testName: elementCollectionBasicTypeXMLTest - * - * @assertion_ids: PERSISTENCE:SPEC:2008; - * - * @test_Strategy: ElementCollection of a basic type using mapping file to - * define annotation - */ - @SetupMethod(name = "setupCust") - @CleanupMethod(name = "cleanupCust") - public void elementCollectionBasicTypeXMLTest() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - CustomerXML expected = new CustomerXML("1"); - List expectedphones = new ArrayList(); - expectedphones.add("781-442-2010"); - expectedphones.add("781-442-2011"); - expectedphones.add("781-442-2012"); - - expected.setPhones(expectedphones); - TestUtil.logTrace("Persisting Customer:" + expected.toString()); - getEntityManager().persist(expected); - getEntityManager().flush(); - getEntityTransaction().commit(); - clearCache(); - getEntityTransaction().begin(); - TestUtil.logTrace( - "find the previously persisted Customer and Country and verify them"); - CustomerXML cust = getEntityManager().find(CustomerXML.class, - expected.getId()); - if (cust != null) { - TestUtil.logTrace("Found CustomerXML: " + cust.toString()); - if (cust.getPhones().containsAll(expectedphones) - && expectedphones.containsAll(cust.getPhones()) - && cust.getPhones().size() == expectedphones.size()) { - TestUtil.logTrace("Received expected Phones:"); - for (String s : cust.getPhones()) { - TestUtil.logTrace("phone:" + s); - } - pass = true; - } else { - TestUtil.logErr("Did not get expected results."); - for (String s : expectedphones) { - TestUtil.logErr("expected:" + s); - } - TestUtil.logErr("actual:"); - for (String s : cust.getPhones()) { - TestUtil.logErr("actual:" + s); - } - } - } else { - TestUtil.logErr("Find returned null Customer"); - } - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred: ", e); - pass = false; - } - if (!pass) { - throw new Fault("elementCollectionBasicTypeXMLTest failed"); - } - } - /* - * - * Business Methods to set up data for Test Cases - * - */ - - private A findA(final String id) { - return getEntityManager().find(A.class, id); - } - - private void dumpAddresses(final Set
addr) { - TestUtil.logTrace("address Data"); - TestUtil.logTrace("---------------"); - if (addr != null) { - TestUtil.logTrace("size=" + addr.size()); - int elem = 1; - for (Address v : addr) { - TestUtil.logTrace("- Element #" + elem++); - TestUtil.logTrace(" street=" + v.getStreet() + ", city=" + v.getCity() - + ", state=" + v.getState() + ", zip=" + v.getZip()); - } - } else { - TestUtil.logTrace(" address=NULL"); - } - } - - public void cleanupA() throws Exception { - TestUtil.logTrace("cleanup"); - removeATestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - public void cleanupCust() throws Exception { - TestUtil.logTrace("cleanup"); - removeCustTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - private void removeCustTestData() { - TestUtil.logTrace("removeCustTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("DELETE FROM CUST_TABLE") - .executeUpdate(); - getEntityManager().createNativeQuery("DELETE FROM PHONES") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } - - private void removeATestData() { - TestUtil.logTrace("removeATestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from A_ADDRESS") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from AEC").executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } -} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddable/Client.java index 342a7494f1..9570b8c020 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddable/Client.java @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.core.annotations.embeddable; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +31,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -57,6 +54,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: Use Nested embeddable class in Query * */ + @Test public void EM1XMTest() throws Exception { TestUtil.logTrace("Begin EM1XMTest2"); boolean pass = false; @@ -151,7 +149,7 @@ public void EM1XMTest() throws Exception { } if (!pass) { - throw new Fault("EM1XMTest failed"); + throw new Exception("EM1XMTest failed"); } } @@ -160,6 +158,7 @@ private B findB(String id) { return getEntityManager().find(B.class, id); } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddableMapValue/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddableMapValue/Client.java index 7e96c1bd55..3b63c699f1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddableMapValue/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/embeddableMapValue/Client.java @@ -18,9 +18,11 @@ import java.util.HashMap; import java.util.Map; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,20 +34,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -58,6 +56,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: Use Embeddable class in MapValue * */ + @Test public void embeddableMapValue() throws Exception { TestUtil.logTrace("Begin embeddableMapValue"); boolean pass1 = false; @@ -161,6 +160,7 @@ public void embeddableMapValue() throws Exception { } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/entity/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/entity/Client.java index 74d6c73d83..40c5e5090d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/entity/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/entity/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -23,9 +23,11 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,17 +38,13 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); TestUtil.logTrace("Create Test data"); createTestData(); @@ -54,7 +52,7 @@ public void setup(String[] args, Properties p) throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -73,7 +71,7 @@ public void setup(String[] args, Properties p) throws Exception { * executed with the lower case entity name as the abstract schema name. * */ - +@Test public void annotationEntityTest1() throws Exception { TestUtil.logTrace("Begin annotationEntityTest1"); @@ -123,7 +121,7 @@ public void annotationEntityTest1() throws Exception { } if (!pass) - throw new Fault("annotationEntityTest1 failed"); + throw new Exception("annotationEntityTest1 failed"); } /* @@ -141,7 +139,7 @@ public void annotationEntityTest1() throws Exception { * abstract schema name selecting teh * */ - +@Test public void annotationEntityTest2() throws Exception { TestUtil.logTrace("Begin annotationEntityTest2"); @@ -202,7 +200,7 @@ public void annotationEntityTest2() throws Exception { } if (!pass1 || !pass2) - throw new Fault("annotationEntityTest1 failed"); + throw new Exception("annotationEntityTest1 failed"); } /* @@ -243,6 +241,7 @@ private void createTestData() throws Exception { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/id/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/id/Client.java index 6865a5b307..b25d165c1d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/id/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/id/Client.java @@ -18,9 +18,11 @@ import java.math.BigDecimal; import java.math.BigInteger; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -29,19 +31,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -54,6 +52,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: */ + @Test public void FieldIntegerIdTest() throws Exception { boolean pass = false; @@ -92,7 +91,7 @@ public void FieldIntegerIdTest() throws Exception { } if (!pass) - throw new Fault("FieldIntegerIdTest failed"); + throw new Exception("FieldIntegerIdTest failed"); } /* @@ -102,7 +101,7 @@ public void FieldIntegerIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void FieldIntIdTest() throws Exception { boolean pass = false; @@ -140,7 +139,7 @@ public void FieldIntIdTest() throws Exception { } if (!pass) - throw new Fault("FieldIntIdTest failed"); + throw new Exception("FieldIntIdTest failed"); } /* @@ -150,7 +149,7 @@ public void FieldIntIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void FieldBigIntegerIdTest() throws Exception { boolean pass = false; @@ -190,7 +189,7 @@ public void FieldBigIntegerIdTest() throws Exception { } if (!pass) - throw new Fault("FieldBigIntegerIdTest failed"); + throw new Exception("FieldBigIntegerIdTest failed"); } /* @@ -200,7 +199,7 @@ public void FieldBigIntegerIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void FieldBigDecimalIdTest() throws Exception { boolean pass = false; @@ -240,7 +239,7 @@ public void FieldBigDecimalIdTest() throws Exception { } if (!pass) - throw new Fault("FieldBigDecimalIdTest failed"); + throw new Exception("FieldBigDecimalIdTest failed"); } /* @@ -250,7 +249,7 @@ public void FieldBigDecimalIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void FieldStringIdTest() throws Exception { boolean pass = false; @@ -288,7 +287,7 @@ public void FieldStringIdTest() throws Exception { } if (!pass) - throw new Fault("FieldStringIdTest failed"); + throw new Exception("FieldStringIdTest failed"); } /* @@ -298,6 +297,7 @@ public void FieldStringIdTest() throws Exception { * * @test_Strategy: */ +@Test public void FieldSQLDateIdTest() throws Exception { boolean pass = false; @@ -335,7 +335,7 @@ public void FieldSQLDateIdTest() throws Exception { } if (!pass) - throw new Fault("FieldSQLDateIdTest failed"); + throw new Exception("FieldSQLDateIdTest failed"); } /* @@ -345,6 +345,7 @@ public void FieldSQLDateIdTest() throws Exception { * * @test_Strategy: */ +@Test public void FieldUtilDateIdTest() throws Exception { boolean pass = false; @@ -383,7 +384,7 @@ public void FieldUtilDateIdTest() throws Exception { } if (!pass) - throw new Fault("FieldUtilDateIdTest failed"); + throw new Exception("FieldUtilDateIdTest failed"); } /* @@ -393,7 +394,7 @@ public void FieldUtilDateIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void PropertyIntegerIdTest() throws Exception { boolean pass = false; @@ -433,7 +434,7 @@ public void PropertyIntegerIdTest() throws Exception { } if (!pass) - throw new Fault("PropertyIntegerIdTest failed"); + throw new Exception("PropertyIntegerIdTest failed"); } /* @@ -443,7 +444,7 @@ public void PropertyIntegerIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void PropertyIntIdTest() throws Exception { boolean pass = false; @@ -481,7 +482,7 @@ public void PropertyIntIdTest() throws Exception { } if (!pass) - throw new Fault("PropertyIntIdTest failed"); + throw new Exception("PropertyIntIdTest failed"); } /* @@ -491,7 +492,7 @@ public void PropertyIntIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void PropertyBigIntegerIdTest() throws Exception { boolean pass = false; @@ -531,7 +532,7 @@ public void PropertyBigIntegerIdTest() throws Exception { } if (!pass) - throw new Fault("PropertyBigIntegerIdTest failed"); + throw new Exception("PropertyBigIntegerIdTest failed"); } /* @@ -541,7 +542,7 @@ public void PropertyBigIntegerIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void PropertyBigDecimalIdTest() throws Exception { boolean pass = false; @@ -581,7 +582,7 @@ public void PropertyBigDecimalIdTest() throws Exception { } if (!pass) - throw new Fault("PropertyBigDecimalIdTest failed"); + throw new Exception("PropertyBigDecimalIdTest failed"); } /* @@ -591,7 +592,7 @@ public void PropertyBigDecimalIdTest() throws Exception { * * @test_Strategy: */ - +@Test public void PropertyStringIdTest() throws Exception { boolean pass = false; @@ -630,7 +631,7 @@ public void PropertyStringIdTest() throws Exception { } if (!pass) - throw new Fault("PropertyStringIdTest failed"); + throw new Exception("PropertyStringIdTest failed"); } /* @@ -640,6 +641,7 @@ public void PropertyStringIdTest() throws Exception { * * @test_Strategy: */ +@Test public void PropertySQLDateIdTest() throws Exception { boolean pass = false; @@ -678,7 +680,7 @@ public void PropertySQLDateIdTest() throws Exception { } if (!pass) - throw new Fault("PropertySQLDateIdTest failed"); + throw new Exception("PropertySQLDateIdTest failed"); } /* @@ -688,6 +690,7 @@ public void PropertySQLDateIdTest() throws Exception { * * @test_Strategy: */ +@Test public void PropertyUtilDateIdTest() throws Exception { boolean pass = false; @@ -726,9 +729,10 @@ public void PropertyUtilDateIdTest() throws Exception { } if (!pass) - throw new Fault("PropertyUtilDateIdTest failed"); + throw new Exception("PropertyUtilDateIdTest failed"); } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/lob/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/lob/Client.java index 35f7fcf8c4..e5b87d70fc 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/lob/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/lob/Client.java @@ -17,9 +17,11 @@ package com.sun.ts.tests.jpa.core.annotations.lob; import java.util.Arrays; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,24 +34,20 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -62,6 +60,7 @@ public void setup(String[] args, Properties p) throws Exception { * following type: Byte[] * */ + @Test public void lobTest() throws Exception { boolean pass1 = false; @@ -111,7 +110,7 @@ public void lobTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("lobTest failed"); + throw new Exception("lobTest failed"); } } @@ -191,6 +190,7 @@ private Byte[] createLargeByteArray() { } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/Client.java index a7dfdfd7dd..de08d61014 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/Client.java @@ -20,15 +20,6 @@ package com.sun.ts.tests.jpa.core.annotations.mapkey; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,566 +27,17 @@ public class Client extends PMClientBase { public Client() { } + + protected Employee2 empRef2; - private Employee empRef[] = new Employee[10]; - - private Employee2 empRef2; - - private Employee3 empRef3; - - private Employee4 empRef4; - - private static Department deptRef[] = new Department[5]; - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - public void setupCreateTestData(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - createTestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - public void setupCreateTestData2(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - createTestData2(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - /* - * @testName: annotationMapKeyTest1 - * - * @assertion_ids: PERSISTENCE:JAVADOC:114; PERSISTENCE:SPEC:1100; - * PERSISTENCE:SPEC:1101; PERSISTENCE:SPEC:518; PERSISTENCE:SPEC:1980; - * - * @test_Strategy: The MapKey annotation is used to specify the map key for - * associations of type java.util.Map. - * - * The name element designates the name of the persistence property or field - * of the associated entity that is used as the map key. - * - * Execute a query returning Employees objects. - * - */ - @SetupMethod(name = "setupCreateTestData") - public void annotationMapKeyTest1() throws Exception { - - boolean pass = true; - - try { - List expected = new ArrayList(); - List actual = new ArrayList(); - - expected.add(empRef[0].getId()); - expected.add(empRef[2].getId()); - expected.add(empRef[4].getId()); - - getEntityTransaction().begin(); - - TestUtil.logTrace("find Employees belonging to Department: Marketing"); - List l = getEntityManager() - .createQuery( - "Select e from Employee e where e.department.name = 'Marketing'") - .getResultList(); - - for (Object o : l) { - Employee e = (Employee) o; - actual.add(e.getId()); - } - - Collections.sort(actual); - if (expected.equals(actual)) { - TestUtil.logTrace("Received expected employees"); - } else { - TestUtil.logErr("Expected id values were:"); - for (Integer i : expected) { - TestUtil.logErr("id: " + i); - } - TestUtil.logErr("actual id values were:"); - Collections.sort(actual); - for (Integer i : actual) { - TestUtil.logErr("id: " + i); - } - } - - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Unexpected exception occurred", ex); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass) - throw new Fault("annotationMapKeyTest1 failed"); - } - - /* - * @testName: annotationMapKeyTest2 - * - * @assertion_ids: PERSISTENCE:JAVADOC:114; PERSISTENCE:SPEC:1100; - * PERSISTENCE:SPEC:1101 - * - * @test_Strategy: The MapKey annotation is used to specify the map key for - * associations of type java.util.Map. - * - * The name element designates the name of the persistence property or field - * of the associated entity that is used as the map key. - * - * Execute a query returning Employee IDs. - */ - @SetupMethod(name = "setupCreateTestData") - public void annotationMapKeyTest2() throws Exception { - - boolean pass = true; - - try { - List expected = new ArrayList(); - List actual = new ArrayList(); - - expected.add(empRef[1].getId()); - expected.add(empRef[3].getId()); - - getEntityTransaction().begin(); - - TestUtil.logTrace("find Employees belonging to Department: Marketing"); - List l = getEntityManager().createQuery( - "Select e.id from Employee e where e.department.name = 'Administration' ORDER BY e.id DESC") - .getResultList(); - - for (Object o : l) { - Integer i = (Integer) o; - actual.add(i); - } - - Collections.sort(actual); - if (expected.equals(actual)) { - TestUtil.logTrace("Received expected employees"); - } else { - TestUtil.logErr("Expected id values were:"); - for (Integer i : expected) { - TestUtil.logErr("id: " + i); - } - TestUtil.logErr("actual id values were:"); - Collections.sort(actual); - for (Integer i : actual) { - TestUtil.logErr("id: " + i); - } - } - - getEntityTransaction().commit(); - - } catch (Exception ex) { - TestUtil.logErr("Unexpected exception occurred", ex); - pass = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass) - throw new Fault("annotationMapKeyTest2 failed"); - } - - /* - * @testName: joinColumnInsertable - * - * @assertion_ids: PERSISTENCE:JAVADOC:90 - * - * @test_Strategy: The JoinColumn annotation with an attribute of insertable - * used to specify the mapping for the fk column to a second entity Execute a - * query returning Employees objects. - */ - @SetupMethod(name = "setupCreateTestData2") - public void joinColumnInsertable() throws Exception { - boolean pass = true; - - try { - getEntityTransaction().begin(); - clearCache(); - TestUtil.logTrace("find employee2"); - Employee2 emp2 = getEntityManager().find(Employee2.class, 6); - TestUtil - .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); - Department dept = emp2.getDepartment(); - - if (dept == null) { - TestUtil.logTrace("Received expected null department for employee2"); - } else { - pass = false; - TestUtil.logErr("Expected null department, actual:" + dept.getName()); - } - clearCache(); - - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee3"); - Employee3 emp3 = getEntityManager().find(Employee3.class, 7); - TestUtil - .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); - dept = emp3.getDepartment(); - - if (dept != null && dept.getName().equals(deptRef[0].getName())) { - TestUtil.logTrace( - "Received expected department for employee3:" + dept.getName()); - } else { - pass = false; - if (dept != null) { - TestUtil.logErr("Expected department:" + deptRef[0].getName() - + ", actual:" + dept.getName()); - } else { - TestUtil.logErr( - "Expected department:" + deptRef[0].getName() + ", actual:null"); - } - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee4"); - Employee4 emp4 = getEntityManager().find(Employee4.class, 8); - TestUtil - .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); - dept = emp4.getDepartment(); - - if (dept == null) { - TestUtil.logTrace("Received expected null department for employee4"); - } else { - pass = false; - TestUtil.logErr("Expected department: null, actual:" + dept.getName()); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - pass = false; - TestUtil.logErr("Received unexpected exception", e); - } - - if (!pass) { - throw new Fault("joinColumnInsertable Failed"); - } - } - - /* - * @testName: joinColumnUpdatable - * - * @assertion_ids: PERSISTENCE:JAVADOC:96 - * - * @test_Strategy: The JoinColumn annotation with an attribute of updatable - * used to specify the mapping for the fk column to a second entity Execute a - * query returning Employees objects. - */ - @SetupMethod(name = "setupCreateTestData2") - public void joinColumnUpdatable() throws Exception { - boolean pass = true; - - try { - getEntityTransaction().begin(); - clearCache(); - TestUtil.logTrace("find employee2"); - Employee2 emp2 = getEntityManager().find(Employee2.class, 6); - TestUtil - .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); - TestUtil.logTrace("set department to:" + deptRef[1].getId() + ", " - + deptRef[1].getName()); - emp2.setDepartment(deptRef[1]); - getEntityManager().merge(emp2); - getEntityManager().flush(); - clearCache(); - TestUtil.logTrace("find employee2 again"); - emp2 = getEntityManager().find(Employee2.class, 6); - TestUtil - .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); - Department dept = emp2.getDepartment(); - if (dept == null) { - TestUtil.logTrace("Received expected null department"); - } else { - pass = false; - TestUtil.logErr("Expected null department, actual:" + dept.getName()); - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee3"); - Employee3 emp3 = getEntityManager().find(Employee3.class, 7); - TestUtil - .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); - TestUtil.logTrace("Department:" + emp3.getDepartment().getId() + ", " - + emp3.getDepartment().getName()); - TestUtil.logTrace("set department to:" + deptRef[1].getId() + ", " - + deptRef[1].getName()); - emp3.setDepartment(deptRef[1]); - getEntityManager().merge(emp3); - getEntityManager().flush(); - clearCache(); - TestUtil.logTrace("find employee3 again"); - emp3 = getEntityManager().find(Employee3.class, 7); - TestUtil - .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); - dept = emp3.getDepartment(); - if (dept != null && dept.getName().equals(deptRef[0].getName())) { - TestUtil.logTrace("Received expected department:" + dept.getName()); - } else { - pass = false; - if (dept != null) { - TestUtil.logErr("Expected department:" + deptRef[0].getName() - + ", actual:" + dept.getName()); - } else { - TestUtil.logErr( - "Expected department:" + deptRef[0].getName() + ", actual:null"); - } - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee4"); - Employee4 emp4 = getEntityManager().find(Employee4.class, 8); - TestUtil - .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); - if (emp4.getFirstName() != null) { - TestUtil.logErr( - "Expected first name to be null, actual:" + emp4.getFirstName()); - pass = false; - } - if (emp4.getDepartment() != null) { - TestUtil.logErr("Expected Department to be null, actual:" - + emp4.getDepartment().toString()); - pass = false; - } - TestUtil.logTrace("set department to:" + deptRef[1].getId() + ", " - + deptRef[1].getName()); - emp4.setDepartment(deptRef[1]); - getEntityManager().merge(emp4); - getEntityManager().flush(); - clearCache(); - TestUtil.logTrace("find employee4 again"); - emp4 = getEntityManager().find(Employee4.class, 8); - TestUtil - .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); - dept = emp4.getDepartment(); - if (dept != null && dept.getName().equals(deptRef[1].getName())) { - TestUtil.logTrace("Received expected department:" + dept.getName()); - } else { - pass = false; - if (dept != null) { - TestUtil.logErr("Expected " + deptRef[1].getName() - + " department, actual:" + dept.getName()); - } else { - TestUtil.logErr( - "Expected " + deptRef[1].getName() + " department, actual:null"); - } - } - - getEntityTransaction().commit(); - - } catch (Exception e) { - pass = false; - TestUtil.logErr("Received unexpected exception", e); - } - - if (!pass) { - throw new Fault("joinColumnUpdatable Failed"); - } - } - - /* - * @testName: columnInsertable - * - * @assertion_ids: PERSISTENCE:JAVADOC:12 - * - * @test_Strategy: The JoinColumn annotation with an attribute of insertable - * used to specify the mapping for the fk column to a second entity Execute a - * query returning Employees objects. - */ - @SetupMethod(name = "setupCreateTestData2") - public void columnInsertable() throws Exception { - boolean pass = true; - - try { - - getEntityTransaction().begin(); - clearCache(); - TestUtil.logTrace("find employee2"); - Employee2 emp2 = getEntityManager().find(Employee2.class, 6); - String firstName = emp2.getFirstName(); - TestUtil.logTrace("Name:" + firstName + " " + emp2.getLastName()); - - if (firstName == null) { - TestUtil.logTrace("Received expected null firstName"); - } else { - pass = false; - TestUtil.logErr("Expected firstName: null, actual:" + firstName); - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee3"); - Employee3 emp3 = getEntityManager().find(Employee3.class, 7); - firstName = emp3.getFirstName(); - TestUtil.logTrace("Name:" + firstName + " " + emp3.getLastName()); - - if (firstName != null && firstName.equals("Paul")) { - TestUtil.logTrace("Received expected firstName:" + firstName); - } else { - pass = false; - TestUtil.logErr("Expected firstName: Paul, actual: null"); - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee4"); - Employee4 emp4 = getEntityManager().find(Employee4.class, 8); - firstName = emp4.getFirstName(); - TestUtil.logTrace("Name:" + firstName + " " + emp4.getLastName()); - if (firstName == null) { - TestUtil.logTrace("Received expected null firstName"); - } else { - pass = false; - TestUtil.logErr("Expected firstName: null, actual:" + firstName); - } - getEntityTransaction().commit(); - - } catch (Exception e) { - pass = false; - TestUtil.logErr("Received unexpected exception", e); - } - - if (!pass) { - throw new Fault("columnInsertable Failed"); - } - } - - /* - * @testName: columnUpdatable - * - * @assertion_ids: PERSISTENCE:JAVADOC:20 - * - * @test_Strategy: The JoinColumn annotation with an attribute of updatable - * used to specify the mapping for the fk column to a second entity Execute a - * query returning Employees objects. - */ - @SetupMethod(name = "setupCreateTestData2") - public void columnUpdatable() throws Exception { - boolean pass = true; - - try { - getEntityTransaction().begin(); - clearCache(); - TestUtil.logTrace("find employee2"); - Employee2 emp2 = getEntityManager().find(Employee2.class, 6); - TestUtil - .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); - TestUtil.logTrace("set firstName and save"); - emp2.setFirstName("foo"); - getEntityManager().merge(emp2); - getEntityManager().flush(); - clearCache(); - TestUtil.logTrace("find employee2 again"); - emp2 = getEntityManager().find(Employee2.class, 6); - TestUtil - .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); - String firstName = emp2.getFirstName(); - if (firstName == null) { - TestUtil.logTrace("Received expected null firstName"); - } else { - pass = false; - TestUtil.logErr("Expected firstName: null, actual:" + firstName); - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee3"); - Employee3 emp3 = getEntityManager().find(Employee3.class, 7); - TestUtil - .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); - TestUtil.logTrace("set firstName and save"); - emp3.setFirstName("foo"); - getEntityManager().merge(emp3); - getEntityManager().flush(); - clearCache(); - TestUtil.logTrace("find employee3 again"); - emp3 = getEntityManager().find(Employee3.class, 7); - TestUtil - .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); - firstName = emp3.getFirstName(); - if (firstName != null && firstName.equals("Paul")) { - TestUtil.logTrace("Received expected firstName:" + firstName); - } else { - pass = false; - TestUtil.logErr("Expected firstName: Paul, actual: null"); - } - - clearCache(); - TestUtil.logTrace("--------------"); - TestUtil.logTrace("find employee4"); - Employee4 emp4 = getEntityManager().find(Employee4.class, 8); - TestUtil - .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); - TestUtil.logTrace("set firstName and save"); - emp4.setFirstName("foo"); - getEntityManager().merge(emp4); - getEntityManager().flush(); - clearCache(); - TestUtil.logTrace("find employee4 again"); - emp4 = getEntityManager().find(Employee4.class, 8); - TestUtil - .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); - firstName = emp4.getFirstName(); - if (firstName != null && firstName.equals("foo")) { - TestUtil.logTrace("Received expected firstName:" + firstName); - } else { - pass = false; - TestUtil.logErr("Expected firstName: foo, actual: null"); - } - - getEntityTransaction().commit(); + protected Employee3 empRef3; - } catch (Exception e) { - pass = false; - TestUtil.logErr("Received unexpected exception", e); - } + protected Employee4 empRef4; - if (!pass) { - throw new Fault("columnUpdatable Failed"); - } + protected static Department deptRef[] = new Department[5]; + + protected Employee empRef[] = new Employee[10]; - } /* * @@ -635,110 +77,7 @@ public void createTestDataCommon() throws Exception { } } - public void createTestData() throws Exception { - try { - - TestUtil.logTrace("createTestData"); - createTestDataCommon(); - getEntityTransaction().begin(); - - TestUtil.logTrace("Create 5 employees"); - empRef[0] = new Employee(1, "Alan", "Frechette"); - empRef[0].setDepartment(deptRef[0]); - - empRef[1] = new Employee(2, "Arthur", "Frechette"); - empRef[1].setDepartment(deptRef[1]); - - empRef[2] = new Employee(3, "Shelly", "McGowan"); - empRef[2].setDepartment(deptRef[0]); - - empRef[3] = new Employee(4, "Robert", "Bissett"); - empRef[3].setDepartment(deptRef[1]); - - empRef[4] = new Employee(5, "Stephen", "DMilla"); - empRef[4].setDepartment(deptRef[0]); - - Map link = new HashMap(); - link.put(empRef[0].getLastName(), empRef[0]); - link.put(empRef[2].getLastName(), empRef[2]); - link.put(empRef[4].getLastName(), empRef[4]); - deptRef[0].setLastNameEmployees(link); - - Map link1 = new HashMap(); - link1.put(empRef[1].getLastName(), empRef[1]); - link1.put(empRef[3].getLastName(), empRef[3]); - deptRef[1].setLastNameEmployees(link1); - - TestUtil.logTrace("Start to persist employees "); - for (Employee emp : empRef) { - if (emp != null) { - getEntityManager().persist(emp); - TestUtil.logTrace("persisted employee " + emp.getId()); - } - } - - getEntityManager().flush(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception creating test data:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - } - - public void createTestData2() throws Exception { - try { - - TestUtil.logTrace("createTestData2"); - createTestDataCommon(); - getEntityTransaction().begin(); - - // insertable = false, updatable = false - TestUtil.logTrace("Create and persist employee2 "); - empRef2 = new Employee2(6, "John", "Smith"); - empRef2.setDepartment(deptRef[0]); - getEntityManager().persist(empRef2); - - // insertable = true, updatable = false - TestUtil.logTrace("Create and persist employee3 "); - empRef3 = new Employee3(7, "Paul", "Jones"); - empRef3.setDepartment(deptRef[0]); - getEntityManager().persist(empRef3); - - // insertable = false, updatable = true - TestUtil.logTrace("Create and persist employee4 "); - empRef4 = new Employee4(8, "Thomas", "Brady"); - empRef4.setDepartment(deptRef[0]); - getEntityManager().persist(empRef4); - getEntityManager().flush(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception creating test data:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - } - - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - private void removeTestData() { + protected void removeTestData() { TestUtil.logTrace("removeTestData"); if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyclass/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyclass/Client.java index f5089fdaf1..4ae2438a42 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyclass/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyclass/Client.java @@ -18,10 +18,12 @@ import java.util.Hashtable; import java.util.Map; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,21 +36,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -71,6 +69,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: With basic entity requirements, persist/remove an entity. */ + @Test public void mapKeyClass() throws Exception { boolean pass = false; @@ -99,7 +98,7 @@ public void mapKeyClass() throws Exception { } if (!pass) { - throw new Fault("mapKeyClass Failed"); + throw new Exception("mapKeyClass Failed"); } } @@ -159,6 +158,7 @@ public void createEntities() { } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeycolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeycolumn/Client.java index 160ebdc67d..90a90917fa 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeycolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeycolumn/Client.java @@ -25,10 +25,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -45,23 +47,19 @@ public Client() { public Map link = new HashMap(); - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -81,6 +79,7 @@ public void setup(String[] args, Properties p) throws Exception { * Execute a query returning Employees objects. * */ + @Test public void annotationMapKeyColumnTest1() throws Exception { boolean pass = false; @@ -120,7 +119,7 @@ public void annotationMapKeyColumnTest1() throws Exception { } if (!pass) { - throw new Fault("annotationMapKeyColumnTest1 failed"); + throw new Exception("annotationMapKeyColumnTest1 failed"); } } @@ -139,6 +138,7 @@ public void annotationMapKeyColumnTest1() throws Exception { * * Execute a query returning Employee IDs. */ + @Test public void annotationMapKeyColumnTest2() throws Exception { boolean pass = false; @@ -184,7 +184,7 @@ public void annotationMapKeyColumnTest2() throws Exception { } if (!pass) { - throw new Fault("annotationMapKeyColumnTest2 failed"); + throw new Exception("annotationMapKeyColumnTest2 failed"); } } @@ -202,6 +202,7 @@ public void annotationMapKeyColumnTest2() throws Exception { * * Execute a query returning Employees objects. */ + @Test public void annotationMapKeyColumnTest3() throws Exception { boolean pass = false; @@ -255,7 +256,7 @@ public void annotationMapKeyColumnTest3() throws Exception { } if (!pass) { - throw new Fault("annotationMapKeyColumnTest3 Failed"); + throw new Exception("annotationMapKeyColumnTest3 Failed"); } } @@ -269,6 +270,7 @@ public void annotationMapKeyColumnTest3() throws Exception { * insertable=false is used to specify the mapping for the fk column to a * second entity Execute a query returning Employees objects. */ + @Test public void mapKeyColumnInsertableFalseTest() throws Exception { boolean pass = false; try { @@ -300,7 +302,7 @@ public void mapKeyColumnInsertableFalseTest() throws Exception { } if (!pass) { - throw new Fault("mapKeyColumnInsertableFalseTest Failed"); + throw new Exception("mapKeyColumnInsertableFalseTest Failed"); } } @@ -314,6 +316,7 @@ public void mapKeyColumnInsertableFalseTest() throws Exception { * updatable=false is used to specify the mapping for the fk column to a * second entity Execute a query returning Employees objects. */ + @Test public void mapKeyColumnUpdatableFalseTest() throws Exception { boolean pass = false; @@ -358,7 +361,7 @@ public void mapKeyColumnUpdatableFalseTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("mapKeyColumnUpdatableFalseTest Failed"); + throw new Exception("mapKeyColumnUpdatableFalseTest Failed"); } } @@ -371,6 +374,7 @@ public void mapKeyColumnUpdatableFalseTest() throws Exception { * @test_Strategy: * */ + @Test public void criteriaBuilderKeysValuesTest() throws Exception { boolean pass1 = false; @@ -449,7 +453,7 @@ public void criteriaBuilderKeysValuesTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("criteriaBuilderKeysValuesTest failed"); + throw new Exception("criteriaBuilderKeysValuesTest failed"); } } @@ -564,6 +568,7 @@ private void createTestData() throws Exception { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyenumerated/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyenumerated/Client.java index 77ee06fb89..da7c61a335 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyenumerated/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyenumerated/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,14 +16,21 @@ package com.sun.ts.tests.jpa.core.annotations.mapkeyenumerated; -import com.sun.javatest.Status; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jpa.common.PMClientBase; - -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + public class Client extends PMClientBase { private static final long serialVersionUID = 20L; @@ -36,23 +43,19 @@ public Client() { private static Employee3 empRef3[] = new Employee3[5]; private static Employee4 empRef4[] = new Employee4[5]; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -60,11 +63,11 @@ public void setup(String[] args, Properties p) throws Exception { public void setupCust(String[] args, Properties p) throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeCustTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -78,6 +81,7 @@ public void setupCust(String[] args, Properties p) throws Exception { * @test_Strategy: * */ + @Test public void mapKeyEnumeratedTest() throws Exception { boolean pass1 = false; @@ -150,7 +154,7 @@ public void mapKeyEnumeratedTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("mapKeyEnumeratedTest failed"); + throw new Exception("mapKeyEnumeratedTest failed"); } } @@ -161,6 +165,7 @@ public void mapKeyEnumeratedTest() throws Exception { * @test_Strategy: * */ + @Test public void mapKeyEnumeratedDefaultTypeTest() throws Exception { boolean pass1 = false; @@ -231,7 +236,7 @@ public void mapKeyEnumeratedDefaultTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("mapKeyEnumeratedDefaultTypeTest failed"); + throw new Exception("mapKeyEnumeratedDefaultTypeTest failed"); } } @@ -242,6 +247,7 @@ public void mapKeyEnumeratedDefaultTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void mapKeyEnumeratedWithMayKeyAnnotationTest() throws Exception { boolean pass1 = false; @@ -313,7 +319,7 @@ public void mapKeyEnumeratedWithMayKeyAnnotationTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("mapKeyEnumeratedWithMayKeyAnnotationTest failed"); + throw new Exception("mapKeyEnumeratedWithMayKeyAnnotationTest failed"); } } @@ -323,6 +329,7 @@ public void mapKeyEnumeratedWithMayKeyAnnotationTest() throws Exception { * @assertion_ids: PERSISTENCE:SPEC:2052; PERSISTENCE:SPEC:2052.1; * @test_Strategy: */ + @Test public void elementCollectionTest() throws Exception { boolean pass1 = false; @@ -393,7 +400,7 @@ public void elementCollectionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("elementCollectionTest failed"); + throw new Exception("elementCollectionTest failed"); } } @@ -592,6 +599,7 @@ private void createTestData() throws Exception { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyjoincolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyjoincolumn/Client.java index ed52192679..db1efafdc6 100755 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyjoincolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeyjoincolumn/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,10 +18,12 @@ import java.util.Hashtable; import java.util.Map; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,22 +36,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -72,6 +70,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: With basic entity requirements, persist/remove an entity. */ + @Test public void mapKeyJoinColumn() throws Exception { boolean pass = false; @@ -96,7 +95,7 @@ public void mapKeyJoinColumn() throws Exception { } if (!pass) { - throw new Fault("mapKeyJoinColumn Failed"); + throw new Exception("mapKeyJoinColumn Failed"); } } @@ -254,6 +253,7 @@ public void createTestData() { } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeytemporal/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeytemporal/Client.java index 608d590b4c..4d40114a39 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeytemporal/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkeytemporal/Client.java @@ -16,15 +16,23 @@ package com.sun.ts.tests.jpa.core.annotations.mapkeytemporal; -import com.sun.javatest.Status; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jpa.common.PMClientBase; - -import java.util.*; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + public class Client extends PMClientBase { private static final long serialVersionUID = 20L; @@ -43,33 +51,31 @@ public Client() { private static Employee2 empRef2[] = new Employee2[5]; private static Employee4 empRef3[] = new Employee4[5]; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupCust(String[] args, Properties p) throws Exception { + + @BeforeEach + public void setupCust() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeCustTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -80,6 +86,7 @@ public void setupCust(String[] args, Properties p) throws Exception { * @test_Strategy: * */ + @Test public void mapKeyTemporalTest() throws Exception { boolean pass1 = false; @@ -152,7 +159,7 @@ public void mapKeyTemporalTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("mapKeyTemporalTest failed"); + throw new Exception("mapKeyTemporalTest failed"); } } @@ -163,6 +170,7 @@ public void mapKeyTemporalTest() throws Exception { * @test_Strategy: * */ + @Test public void mapKeyEnumeratedWithMayKeyClassAnnotationTest() throws Exception { boolean pass1 = false; @@ -233,7 +241,7 @@ public void mapKeyEnumeratedWithMayKeyClassAnnotationTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("mapKeyEnumeratedWithMayKeyClassAnnotationTest failed"); + throw new Exception("mapKeyEnumeratedWithMayKeyClassAnnotationTest failed"); } } /* @@ -242,6 +250,7 @@ public void mapKeyEnumeratedWithMayKeyClassAnnotationTest() throws Exception { * PERSISTENCE:SPEC:2065.1; * @test_Strategy: */ + @Test public void elementCollectionTest() throws Exception { boolean pass1 = false; @@ -312,7 +321,7 @@ public void elementCollectionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("elementCollectionTest failed"); + throw new Exception("elementCollectionTest failed"); } } /* @@ -467,12 +476,14 @@ private void createTestData() throws Exception { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); } + @AfterEach public void cleanupCust() throws Exception { TestUtil.logTrace("cleanup"); removeCustTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapsid/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapsid/Client.java index b92afb5850..47148a89ea 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapsid/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapsid/Client.java @@ -17,9 +17,11 @@ package com.sun.ts.tests.jpa.core.annotations.mapsid; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +33,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -71,6 +69,7 @@ public void setup(String[] args, Properties p) throws Exception { * cascade=PERSIST and ensure the persist operation is cascaded. * */ + @Test public void persistMX1Test1() throws Exception { TestUtil.logTrace("Begin persistMX1Test1"); boolean pass = false; @@ -131,10 +130,11 @@ public void persistMX1Test1() throws Exception { } if (!pass) { - throw new Fault("persistMX1Test1 failed"); + throw new Exception("persistMX1Test1 failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/nativequery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/nativequery/Client.java index e83db1b52f..69735482a5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/nativequery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/nativequery/Client.java @@ -21,11 +21,12 @@ package com.sun.ts.tests.jpa.core.annotations.nativequery; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,20 +37,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -70,7 +67,7 @@ public void setup(String[] args, Properties p) throws Exception { * * */ - +@Test public void nativeQueryTest2() throws Exception { boolean pass = false; @@ -167,7 +164,7 @@ public void nativeQueryTest2() throws Exception { } if (!pass) - throw new Fault("nativeQueryTest2 failed"); + throw new Exception("nativeQueryTest2 failed"); } /* @@ -186,7 +183,7 @@ public void nativeQueryTest2() throws Exception { * entity fields. The FieldResult annotation is used for this purpose. * */ - +@Test public void nativeQueryTest3() throws Exception { boolean pass = false; List q; @@ -279,7 +276,7 @@ public void nativeQueryTest3() throws Exception { } if (!pass) - throw new Fault("nativeQueryTest3 failed"); + throw new Exception("nativeQueryTest3 failed"); } /* @@ -292,7 +289,7 @@ public void nativeQueryTest3() throws Exception { * return the totalprice as a String * */ - +@Test public void nativeQueryColumnResultTypeTest() throws Exception { boolean pass = false; @@ -389,7 +386,7 @@ public void nativeQueryColumnResultTypeTest() throws Exception { } if (!pass) - throw new Fault("nativeQueryColumnResultTypeTest failed"); + throw new Exception("nativeQueryColumnResultTypeTest failed"); } /* @@ -402,6 +399,7 @@ public void nativeQueryColumnResultTypeTest() throws Exception { * @test_Strategy: Verify jakarta.persistence.ConstructorResult can call a class * constructor passing in arg data and return the class. */ +@Test public void nativeQueryTestConstructorResult() throws Exception { boolean pass = false; @@ -465,7 +463,7 @@ public void nativeQueryTestConstructorResult() throws Exception { } if (!pass) - throw new Fault("nativeQueryTestConstructorResult failed"); + throw new Exception("nativeQueryTestConstructorResult failed"); } /* @@ -477,7 +475,7 @@ public void nativeQueryTestConstructorResult() throws Exception { * constructor passing in arg data and return the class. * */ - +@Test public void nativeQueryTestConstructorResultWithId() throws Exception { boolean pass1 = false; @@ -534,7 +532,7 @@ public void nativeQueryTestConstructorResultWithId() throws Exception { } if (!pass1 || !pass2) - throw new Fault("nativeQueryTestConstructorResultWithId failed"); + throw new Exception("nativeQueryTestConstructorResultWithId failed"); } @@ -547,7 +545,7 @@ public void nativeQueryTestConstructorResultWithId() throws Exception { * constructor passing in arg data except the id and return the class. * */ - +@Test public void nativeQueryTestConstructorResultNoId() throws Exception { boolean pass1 = false; @@ -606,7 +604,7 @@ public void nativeQueryTestConstructorResultNoId() throws Exception { } if (!pass1 || !pass2) - throw new Fault("nativeQueryTestConstructorResultNoId failed"); + throw new Exception("nativeQueryTestConstructorResultNoId failed"); } @@ -618,7 +616,7 @@ public void nativeQueryTestConstructorResultNoId() throws Exception { * @test_Strategy: * */ - +@Test public void createNativeQueryStringTest() throws Exception { boolean pass = false; List q = null; @@ -675,7 +673,7 @@ public void createNativeQueryStringTest() throws Exception { } if (!pass) - throw new Fault("createNativeQueryStringTest failed"); + throw new Exception("createNativeQueryStringTest failed"); } /* @@ -686,7 +684,7 @@ public void createNativeQueryStringTest() throws Exception { * @test_Strategy: Use the createNativeQuery(String,Class) * */ - +@Test public void createNativeQueryResultClassTest() throws Exception { boolean pass = false; List q; @@ -739,7 +737,7 @@ public void createNativeQueryResultClassTest() throws Exception { if (!pass) throw new - Fault("createNativeQueryResultClassTest failed"); + Exception("createNativeQueryResultClassTest failed"); } @@ -751,6 +749,7 @@ public void createNativeQueryResultClassTest() throws Exception { * @test_Strategy: Use the createNativeQuery(String,Class) a TypedQuery * */ +@Test public void createNativeQueryResultClassTQTest() throws Exception { boolean pass = false; List q; @@ -801,7 +800,7 @@ public void createNativeQueryResultClassTQTest() throws Exception { } if (!pass) - throw new Fault("createNativeQueryResultClassTQTest failed"); + throw new Exception("createNativeQueryResultClassTQTest failed"); } /* @@ -813,6 +812,7 @@ public void createNativeQueryResultClassTQTest() throws Exception { * transaction is in effect and verify TransactionRequiredException is thrown * */ +@Test public void executeUpdateTransactionRequiredExceptionTest() throws Exception { boolean pass = false; try { @@ -834,7 +834,7 @@ public void executeUpdateTransactionRequiredExceptionTest() throws Exception { } } if (!pass) - throw new Fault("executeUpdateTransactionRequiredExceptionTest failed"); + throw new Exception("executeUpdateTransactionRequiredExceptionTest failed"); } /* @@ -845,6 +845,7 @@ public void executeUpdateTransactionRequiredExceptionTest() throws Exception { * @test_Strategy: Use the createNativeQuery(String,Class) a TypedQuery * */ +@Test public void setParameterTest() throws Exception { boolean pass = false; List q; @@ -896,7 +897,7 @@ public void setParameterTest() throws Exception { } if (!pass) - throw new Fault("setParameterTest failed"); + throw new Exception("setParameterTest failed"); } /* @@ -907,6 +908,7 @@ public void setParameterTest() throws Exception { * @test_Strategy: * */ +@Test public void getSingleResultTest() throws Exception { boolean pass = false; Object q; @@ -950,9 +952,10 @@ public void getSingleResultTest() throws Exception { } if (!pass) - throw new Fault("getSingleResultTest failed"); + throw new Exception("getSingleResultTest failed"); } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/onexmanyuni/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/onexmanyuni/Client.java index 3048d668e3..76346663c9 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/onexmanyuni/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/onexmanyuni/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.core.annotations.onexmanyuni; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -54,16 +55,12 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); } @@ -81,6 +78,7 @@ public void setup(String[] args, Properties p) throws Exception { * One-to-Many relationship. * */ + @Test public void oneXmanyUniJoinColumn() throws Exception { EntityManager em = getEntityManager(); @@ -110,7 +108,7 @@ public void oneXmanyUniJoinColumn() throws Exception { TestUtil.logTrace("Test Passed"); } catch (Exception e) { - throw new Fault("Test failed" + e); + throw new Exception("Test failed" + e); } finally { em.remove(order1); em.remove(order2); @@ -137,6 +135,7 @@ private Customer1 createCustomer(final long id, final String name) { return customer; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/Client.java deleted file mode 100644 index 30ac110fe5..0000000000 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/Client.java +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.ts.tests.jpa.core.annotations.orderby; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.CleanupMethod; -import com.sun.ts.lib.harness.SetupMethod; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jpa.common.PMClientBase; - -public class Client extends PMClientBase { - - List
addrRef; - - Address addr1 = null; - - Address addr2 = null; - - Address addr3 = null; - - List addrRef2; - - Address2 addr11 = null; - - Address2 addr12 = null; - - Address2 addr13 = null; - - public Client() { - } - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeTestData(); - createTestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - public void setupAddress(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setupAddress"); - try { - super.setup(args, p); - removeAddressData(); - createAddressData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - public void setupCust(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - super.setup(args, p); - removeCustTestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - - } - } - /* - * @testName: orderByTest1 - * - * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; - * PERSISTENCE:SPEC:1106; PERSISTENCE:JAVADOC:145; - * - * @test_Strategy: The OrderBy annotation specifies the ordering of the - * elements of a collection valued association at the point when the - * association is retrieved. - * - * The property name must correspond to that of a persistenct property of the - * associated class. - * - * The property used in the ordering must correspond to columns for which - * comparison operations are supported. - * - * If DESC is specified, the elements will be ordered in descending order. - * - * Retrieve the Collection using getter property accessor. - */ - - public void orderByTest1() throws Exception { - - TestUtil.logTrace("Begin orderByTest1"); - boolean pass1 = true; - boolean pass2 = false; - List resultsList = new ArrayList(); - final String[] expectedResult = new String[] { "Zoe", "Song", "Jie", "Ay" }; - - try { - getEntityTransaction().begin(); - - Employee empChange = getEntityManager().find(Employee.class, 65); - - empChange.setFirstName("Ay"); - getEntityManager().merge(empChange); - getEntityManager().flush(); - - final Insurance newIns = getEntityManager().find(Insurance.class, 60); - getEntityManager().refresh(newIns); - - final List insResult = newIns.getEmployees(); - - if (insResult.size() != 4) { - TestUtil.logTrace( - "orderByTest1: Did not get expected results. Expected: 4, " - + "got: " + insResult.size()); - pass1 = false; - } else if (pass1) { - Iterator i1 = insResult.iterator(); - TestUtil.logTrace("Check Employee Collection for expected first names"); - while (i1.hasNext()) { - Employee e1 = (Employee) i1.next(); - resultsList.add((String) e1.getFirstName()); - TestUtil.logTrace("orderByTest1: got Employee FirstName:" - + (String) e1.getFirstName()); - } - - TestUtil.logTrace( - "Compare first names received with expected first names "); - String[] result = (String[]) (resultsList - .toArray(new String[resultsList.size()])); - pass2 = Arrays.equals(expectedResult, result); - - } - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass2 = false; - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass1 || !pass2) - throw new Fault("orderByTest1 failed"); - } - - /* - * @testName: orderByTest2 - * - * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; - * PERSISTENCE:SPEC:1106; PERSISTENCE:SPEC:1109; PERSISTENCE:SPEC:1110; - * PERSISTENCE:JAVADOC:145; PERSISTENCE:SPEC:653 - * - * @test_Strategy: The OrderBy annotation specifies the ordering of the - * elements of a collection valued association at the point when the - * association is retrieved. - * - * The property name must correspond to that of a persistenct property of the - * associated class. - * - * The property used in the ordering must correspond to columns for which - * comparison operations are supported. - * - * If ASC is specified, the elements will be ordered in ascending order. - * - * Retrieve the Collection using getter property accessor. - */ - - public void orderByTest2() throws Exception { - - TestUtil.logTrace("Begin orderByTest2"); - boolean pass1 = true; - boolean pass2 = false; - List resultsList = new ArrayList(); - final String[] expectedResult = new String[] { "Jie", "Song", "Yay", - "Zoe" }; - - try { - getEntityTransaction().begin(); - - Employee emp2Change = getEntityManager().find(Employee.class, 65); - - emp2Change.setFirstName("Yay"); - getEntityManager().merge(emp2Change); - getEntityManager().flush(); - - final Department newDept = getEntityManager().find(Department.class, 50); - getEntityManager().refresh(newDept); - - final List deptResult = newDept.getEmployees(); - - if (deptResult.size() != 4) { - TestUtil.logTrace( - "orderByTest2: Did not get expected results. Expected: 4, " - + "got: " + deptResult.size()); - pass1 = false; - } else if (pass1) { - Iterator i2 = deptResult.iterator(); - TestUtil.logTrace("Check Employee Collection for expected first names"); - while (i2.hasNext()) { - Employee e2 = (Employee) i2.next(); - resultsList.add((String) e2.getFirstName()); - TestUtil.logTrace("orderByTest2: got Employee FirstName:" - + (String) e2.getFirstName()); - } - - TestUtil.logTrace( - "Compare first names received with expected first names "); - String[] result = (String[]) (resultsList - .toArray(new String[resultsList.size()])); - pass2 = Arrays.equals(expectedResult, result); - - } - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass1 || !pass2) - throw new Fault("orderByTest2 failed"); - } - - /* - * @testName: orderByTest3 - * - * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; - * PERSISTENCE:SPEC:1106; PERSISTENCE:JAVADOC:145 - * - * @test_Strategy: The OrderBy annotation specifies the ordering of the - * elements of a collection valued association at the point when the - * association is retrieved. - * - * If DESC is specified, the elements will be ordered in descending order. - * - * Add to the Collection then retrieve the updated Collection and ensure the - * list is ordered. - * - */ - - public void orderByTest3() throws Exception { - TestUtil.logTrace("Begin orderByTest3"); - boolean pass1 = true; - boolean pass2 = false; - List insResult; - List resultsList = new ArrayList(); - final String[] expectedResult = new String[] { "Zoe", "Song", "Penelope", - "May", "Jie" }; - - try { - getEntityTransaction().begin(); - - Employee emp3Change = getEntityManager().find(Employee.class, 85); - Insurance ins = getEntityManager().find(Insurance.class, 60); - - emp3Change.setInsurance(ins); - getEntityManager().merge(emp3Change); - ins.getEmployees().add(emp3Change); - getEntityManager().merge(ins); - getEntityManager().flush(); - - getEntityManager().refresh(ins); - - insResult = ins.getEmployees(); - - if (insResult.size() != 5) { - TestUtil.logErr("orderByTest3: Expected List Size of 5 " + "got: " - + insResult.size()); - pass1 = false; - } else if (pass1) { - Iterator i3 = insResult.iterator(); - TestUtil.logTrace("Check Employee Collection for expected first names"); - while (i3.hasNext()) { - Employee e3 = (Employee) i3.next(); - resultsList.add((String) e3.getFirstName()); - TestUtil.logTrace("orderByTest3: got Employee FirstName:" - + (String) e3.getFirstName()); - } - - TestUtil.logTrace( - "orderByTest3: Expected size received, check ordering . . ."); - String[] result = (String[]) (resultsList - .toArray(new String[resultsList.size()])); - pass2 = Arrays.equals(expectedResult, result); - - } - - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass1 || !pass2) - throw new Fault("orderByTest3 failed"); - } - - /* - * @testName: orderByTest4 - * - * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; - * PERSISTENCE:SPEC:1106; PERSISTENCE:JAVADOC:145 - * - * @test_Strategy: The OrderBy annotation specifies the ordering of the - * elements of a collection valued association at the point when the - * association is retrieved. - * - * If ASC is specified, the elements will be ordered in ascending order. - * - * Retrieve the Collection, add to the Collection and retrieve it again making - * sure the list is ordered . - * - */ - - public void orderByTest4() throws Exception { - TestUtil.logTrace("Begin orderByTest4"); - boolean pass1 = true; - boolean pass2 = false; - List resultsList = new ArrayList(); - final String[] expectedResult = new String[] { "Jie", "May", "Penelope", - "Song", "Zoe" }; - - try { - getEntityTransaction().begin(); - - Employee emp4Change = getEntityManager().find(Employee.class, 85); - Department dept = getEntityManager().find(Department.class, 50); - - emp4Change.setDepartment(dept); - getEntityManager().merge(emp4Change); - dept.getEmployees().add(emp4Change); - getEntityManager().merge(dept); - getEntityManager().flush(); - - getEntityManager().refresh(dept); - final List deptResult = dept.getEmployees(); - - if (deptResult.size() != 5) { - TestUtil.logErr("orderByTest4: Expected Collection Size of 5 " + "got: " - + deptResult.size()); - pass1 = false; - } else if (pass1) { - Iterator i4 = deptResult.iterator(); - TestUtil.logTrace("Check Employee Collection for expected first names"); - while (i4.hasNext()) { - Employee e4 = (Employee) i4.next(); - resultsList.add((String) e4.getFirstName()); - TestUtil.logTrace("orderByTest4: got Employee FirstName:" - + (String) e4.getFirstName()); - } - - TestUtil.logTrace( - "orderByTest4: Expected size received, check ordering . . ."); - String[] result = (String[]) (resultsList - .toArray(new String[resultsList.size()])); - pass2 = Arrays.equals(expectedResult, result); - } - - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - - if (!pass1 || !pass2) - throw new Fault("orderByTest4 failed"); - } - - /* - * @testName: propertyDotNotationTest - * - * @assertion_ids: PERSISTENCE:SPEC:2089; PERSISTENCE:SPEC:2092; - * PERSISTENCE:SPEC:2091; - * - * @test_Strategy: identifier is the name of the respective property - * - */ - @SetupMethod(name = "setupAddress") - @CleanupMethod(name = "cleanupAddress") - public void propertyDotNotationTest() throws Exception { - boolean pass = false; - - try { - addrRef = new ArrayList
(); - List
expected = new ArrayList
(); - expected.add(addr2); - expected.add(addr3); - expected.add(addr1); - - clearCache(); - A a = getEntityManager().find(A.class, "1"); - - List
actual = a.getAddressList(); - - if (actual.size() == expected.size()) { - int count = 0; - for (int i = 0; i < expected.size(); i++) { - TestUtil.logTrace("Testing - expected[" + expected.get(i) - + "], actual[" + actual.get(i) + "]"); - - if (expected.get(i).equals(actual.get(i))) { - count++; - } - } - if (count == expected.size()) { - pass = true; - } else { - TestUtil - .logErr("count=" + count + ", expected size:" + expected.size()); - for (Address aa : expected) { - TestUtil.logErr("expected:" + aa); - } - TestUtil.logErr("------------"); - for (Address aa : actual) { - TestUtil.logErr("actual:" + aa); - } - } - } else { - TestUtil.logErr("Expected list size:" + expected.size() - + ", actual size:" + actual.size()); - for (Address aa : expected) { - TestUtil.logErr("expected:" + aa); - } - TestUtil.logErr("------------"); - for (Address aa : actual) { - TestUtil.logErr("actual:" + aa); - } - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - if (!pass) { - throw new Fault("propertyDotNotationTest failed"); - } - } - - /* - * @testName: fieldDotNotationTest - * - * @assertion_ids: PERSISTENCE:SPEC:2089; PERSISTENCE:SPEC:2092; - * PERSISTENCE:SPEC:2091; - * - * @test_Strategy: identifier is the name of the respective field - * - */ - @SetupMethod(name = "setupAddress") - @CleanupMethod(name = "cleanupAddress") - public void fieldDotNotationTest() throws Exception { - boolean pass = false; - - try { - addrRef = new ArrayList
(); - List expected = new ArrayList(); - expected.add(addr12); - expected.add(addr13); - expected.add(addr11); - - TestUtil.logTrace("Clearing the cache"); - clearCache(); - A2 a = getEntityManager().find(A2.class, "2"); - - List actual = a.getAddressList(); - - if (actual.size() == expected.size()) { - int count = 0; - for (int i = 0; i < expected.size(); i++) { - TestUtil.logTrace("Testing - expected[" + expected.get(i) - + "], actual[" + actual.get(i) + "]"); - - if (expected.get(i).equals(actual.get(i))) { - count++; - } - } - - if (count == expected.size()) { - pass = true; - } else { - TestUtil.logTrace( - "count=" + count + ", expected size:" + expected.size()); - for (Address2 aa : expected) { - TestUtil.logErr("expected:" + aa); - } - TestUtil.logErr("------------"); - for (Address2 aa : actual) { - TestUtil.logErr("actual:" + aa); - } - } - } else { - TestUtil.logErr("Expected list size:" + expected.size() - + ", actual size:" + actual.size()); - for (Address2 aa : expected) { - TestUtil.logErr("expected:" + aa); - } - TestUtil.logErr("------------"); - for (Address2 aa : actual) { - TestUtil.logErr("actual:" + aa); - } - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - if (!pass) { - throw new Fault("propertyDotNotationTest failed"); - } - } - - /* - * @testName: propertyElementCollectionBasicType - * - * @assertion_ids: PERSISTENCE:SPEC:2090 - * - * @test_Strategy: ElementCollection of a basic type - */ - @SetupMethod(name = "setupCust") - @CleanupMethod(name = "cleanupCust") - public void propertyElementCollectionBasicType() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - Customer expected = new Customer("1"); - List expectedphones = new ArrayList(); - expectedphones.add("781-442-2010"); - expectedphones.add("781-442-2011"); - expectedphones.add("781-442-2012"); - - expected.setPhones(expectedphones); - TestUtil.logTrace("Persisting Customer:" + expected.toString()); - getEntityManager().persist(expected); - getEntityManager().flush(); - getEntityTransaction().commit(); - clearCache(); - getEntityTransaction().begin(); - TestUtil.logTrace( - "find the previously persisted Customer and Country and verify them"); - Customer cust = getEntityManager().find(Customer.class, expected.getId()); - if (cust != null) { - TestUtil.logTrace("Found Customer: " + cust.toString()); - if (cust.getPhones().containsAll(expectedphones) - && expectedphones.containsAll(cust.getPhones()) - && cust.getPhones().size() == expectedphones.size()) { - TestUtil.logTrace("Received expected Phones:"); - for (String s : cust.getPhones()) { - TestUtil.logTrace("phone:" + s); - } - pass = true; - } else { - TestUtil.logErr("Did not get expected results."); - for (String s : expectedphones) { - TestUtil.logErr("expected:" + s); - } - TestUtil.logErr("actual:"); - for (String s : cust.getPhones()) { - TestUtil.logErr("actual:" + s); - } - } - } else { - TestUtil.logErr("Find returned null Customer"); - } - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred: ", e); - pass = false; - } - if (!pass) { - throw new Fault("propertyElementCollectionBasicType failed"); - } - } - - /* - * @testName: fieldElementCollectionBasicType - * - * @assertion_ids: PERSISTENCE:SPEC:2090 - * - * @test_Strategy: ElementCollection of a basic type - */ - @SetupMethod(name = "setupCust") - @CleanupMethod(name = "cleanupCust") - public void fieldElementCollectionBasicType() throws Exception { - boolean pass = false; - try { - getEntityTransaction().begin(); - Customer2 expected = new Customer2("2"); - List expectedphones = new ArrayList(); - expectedphones.add("781-442-2010"); - expectedphones.add("781-442-2011"); - expectedphones.add("781-442-2012"); - - expected.setPhones(expectedphones); - TestUtil.logTrace("Persisting Customer2:" + expected.toString()); - getEntityManager().persist(expected); - getEntityManager().flush(); - getEntityTransaction().commit(); - clearCache(); - getEntityTransaction().begin(); - Customer2 cust = getEntityManager().find(Customer2.class, - expected.getId()); - if (cust != null) { - TestUtil.logTrace("Found Customer2: " + cust.toString()); - if (cust.getPhones().containsAll(expectedphones) - && expectedphones.containsAll(cust.getPhones()) - && cust.getPhones().size() == expectedphones.size()) { - TestUtil.logTrace("Received expected Phones:"); - for (String s : cust.getPhones()) { - TestUtil.logTrace("phone:" + s); - } - pass = true; - } else { - TestUtil.logErr("Did not get expected results."); - for (String s : expectedphones) { - TestUtil.logErr("expected:" + s); - } - TestUtil.logErr("actual:"); - for (String s : cust.getPhones()) { - TestUtil.logErr("actual:" + s); - } - } - } else { - TestUtil.logErr("Find returned null Customer"); - } - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred: ", e); - pass = false; - } - if (!pass) { - throw new Fault("fieldElementCollectionBasicType failed"); - } - } - - private void createTestData() throws Exception { - try { - TestUtil.logTrace("createTestData"); - getEntityTransaction().begin(); - final float salary = 10000.00F; - - Department d1 = new Department(50, "SJSAS Appserver"); - getEntityManager().persist(d1); - - Insurance s1 = new Insurance(60, "United"); - getEntityManager().persist(s1); - - final Employee e1 = new Employee(70, "Jie", "Leng", salary, d1, s1); - final Employee e2 = new Employee(80, "Zoe", "Leng", salary, d1, s1); - final Employee e3 = new Employee(90, "Song", "Leng", salary, d1, s1); - final Employee e4 = new Employee(65, "May", "Leng", salary, d1, s1); - final Employee e5 = new Employee(85, "Penelope", "Leng", salary); - getEntityManager().persist(e1); - getEntityManager().persist(e2); - getEntityManager().persist(e3); - getEntityManager().persist(e4); - getEntityManager().persist(e5); - - List link = new ArrayList(); - link.add(e1); - link.add(e2); - link.add(e3); - link.add(e4); - - d1.setEmployees(link); - getEntityManager().merge(d1); - - s1.setEmployees(link); - getEntityManager().merge(s1); - - TestUtil.logTrace("persisted Entity Data"); - getEntityManager().flush(); - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception creating test data:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - } - - private void createAddressData() throws Exception { - try { - TestUtil.logTrace("createAddressData"); - getEntityTransaction().begin(); - - addr1 = new Address("1 Network Drive", "Burlington", "MA", - new ZipCode("01801")); - addr2 = new Address("634 Goldstar Road", "Peabody", "MA", - new ZipCode("88444")); - addr3 = new Address("3212 Boston Road", "Chelmsford", "MA", - new ZipCode("01824")); - addrRef = new ArrayList
(); - addrRef.add(addr1); - addrRef.add(addr2); - addrRef.add(addr3); - A a1 = new A("1", "b1", addrRef); - - addr11 = new Address2("1 Network Drive", "Burlington", "MA", - new ZipCode2("01801")); - addr12 = new Address2("634 Goldstar Road", "Peabody", "MA", - new ZipCode2("88444")); - addr13 = new Address2("3212 Boston Road", "Chelmsford", "MA", - new ZipCode2("01824")); - addrRef2 = new ArrayList(); - addrRef2.add(addr11); - addrRef2.add(addr12); - addrRef2.add(addr13); - A2 a2 = new A2("2", "b2", addrRef2); - - getEntityManager().persist(a1); - getEntityManager().persist(a2); - - getEntityManager().flush(); - getEntityManager().refresh(a1); - getEntityManager().refresh(a2); - - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Unexpected Exception creating test data:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in rollback:", re); - } - } - } - - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - public void cleanupAddress() throws Exception { - TestUtil.logTrace("cleanup"); - removeAddressData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - public void cleanupCust() throws Exception { - TestUtil.logTrace("cleanup"); - removeCustTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - - private void removeCustTestData() { - TestUtil.logTrace("removeCustTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("DELETE FROM CUST_TABLE") - .executeUpdate(); - getEntityManager().createNativeQuery("DELETE FROM PHONES") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } - - private void removeTestData() { - TestUtil.logTrace("removeTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from EMPLOYEE") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from DEPARTMENT") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from INSURANCE") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } - - private void removeAddressData() { - TestUtil.logTrace("removeAddressData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from COLTAB_ADDRESS") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from COLTAB") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } -} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java index 75d15f009d..fe80a1aa39 100755 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,9 +18,11 @@ import java.util.ArrayList; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -41,35 +43,32 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createStudentTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupEmployee(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupEmployee() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeEmployeeTestData(); createEmployeeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -92,6 +91,7 @@ public void setupEmployee(String[] args, Properties p) throws Exception { * * @test_Strategy: With basic entity requirements, persist/remove an entity. */ + @Test public void orderColumn() throws Exception { boolean pass = false; final String expectedStudentName = "Joseph"; @@ -149,7 +149,7 @@ public void orderColumn() throws Exception { } if (!pass) { - throw new Fault("orderColumn test failed"); + throw new Exception("orderColumn test failed"); } } @@ -164,6 +164,7 @@ public void orderColumn() throws Exception { */ @SetupMethod(name = "setupEmployee") @CleanupMethod(name = "cleanupEmployee") + @Test public void propertyAccessWithNameTest() throws Exception { boolean pass = false; @@ -249,7 +250,7 @@ public void propertyAccessWithNameTest() throws Exception { } if (!pass) { - throw new Fault("propertyAccessWithNameTest test failed"); + throw new Exception("propertyAccessWithNameTest test failed"); } } @@ -264,6 +265,7 @@ public void propertyAccessWithNameTest() throws Exception { */ @SetupMethod(name = "setupEmployee") @CleanupMethod(name = "cleanupEmployee") + @Test public void fieldAccessWithNameTest() throws Exception { boolean pass = false; @@ -349,7 +351,7 @@ public void fieldAccessWithNameTest() throws Exception { } if (!pass) { - throw new Fault("fieldAccessWithNameTest test failed"); + throw new Exception("fieldAccessWithNameTest test failed"); } } @@ -524,6 +526,7 @@ private void createEmployeeTestData() throws Exception { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/Client.java index 565f16c6c6..270b48ebdc 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.core.annotations.tableGenerator; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,61 +37,60 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup2(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup2() throws Exception { TestUtil.logTrace("setup2"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData2(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup3(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup3() throws Exception { TestUtil.logTrace("setup3"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData3(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup4(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup4() throws Exception { TestUtil.logTrace("setup4"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData4(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } /* @@ -101,7 +101,7 @@ public void setup4(String[] args, Properties p) throws Exception { * * @test_Strategy: use a generator specified on an entity */ - +@Test public void generatorOnEntityTest() throws Exception { boolean pass = false; @@ -125,7 +125,7 @@ public void generatorOnEntityTest() throws Exception { } if (!pass) - throw new Fault("generatorOnEntityTest failed"); + throw new Exception("generatorOnEntityTest failed"); } /* @@ -137,6 +137,7 @@ public void generatorOnEntityTest() throws Exception { * @test_Strategy: use a generator specified on a field */ @SetupMethod(name = "setup3") + @Test public void generatorOnFieldTest() throws Exception { boolean pass = false; @@ -160,7 +161,7 @@ public void generatorOnFieldTest() throws Exception { } if (!pass) - throw new Fault("generatorOnFieldTest failed"); + throw new Exception("generatorOnFieldTest failed"); } /* @@ -172,6 +173,7 @@ public void generatorOnFieldTest() throws Exception { * @test_Strategy: use a generator specified on a property */ @SetupMethod(name = "setup2") + @Test public void generatorOnPropertyTest() throws Exception { boolean pass = false; @@ -195,7 +197,7 @@ public void generatorOnPropertyTest() throws Exception { } if (!pass) - throw new Fault("generatorOnPropertyTest failed"); + throw new Exception("generatorOnPropertyTest failed"); } /* @@ -206,6 +208,7 @@ public void generatorOnPropertyTest() throws Exception { * @test_Strategy: Use the generator defined by another entity */ @SetupMethod(name = "setup4") + @Test public void generatorGlobalTest() throws Exception { boolean pass = false; @@ -229,7 +232,7 @@ public void generatorGlobalTest() throws Exception { } if (!pass) - throw new Fault("generatorGlobalTest failed"); + throw new Exception("generatorGlobalTest failed"); } // Methods used for Tests @@ -301,6 +304,7 @@ public void createTestData4() { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/temporal/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/temporal/Client.java index 7309e23924..868e4fd6dd 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/temporal/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/temporal/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,9 +21,11 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -45,22 +47,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setupData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -71,6 +68,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Used with a Basic annotation for field access */ +@Test public void basicFieldTest() throws Exception { boolean pass = false; @@ -90,7 +88,7 @@ public void basicFieldTest() throws Exception { } if (!pass) { - throw new Fault("basicFieldTest failed"); + throw new Exception("basicFieldTest failed"); } } @@ -102,6 +100,7 @@ public void basicFieldTest() throws Exception { * * @test_Strategy: Used with a Basic annotation for property access */ +@Test public void basicPropertyTest() throws Exception { boolean pass = false; try { @@ -122,7 +121,7 @@ public void basicPropertyTest() throws Exception { } if (!pass) { - throw new Fault("basicPropertyTest failed"); + throw new Exception("basicPropertyTest failed"); } } @@ -132,6 +131,7 @@ public void basicPropertyTest() throws Exception { * @assertion_ids: PERSISTENCE:SPEC:2114; PERSISTENCE:SPEC:2114.3; * @test_Strategy: ElementCollection of a basic type */ +@Test public void fieldElementCollectionTemporalTest() throws Exception { boolean pass = false; try { @@ -166,7 +166,7 @@ public void fieldElementCollectionTemporalTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("fieldElementCollectionTemporalTest failed"); + throw new Exception("fieldElementCollectionTemporalTest failed"); } } @@ -175,6 +175,7 @@ public void fieldElementCollectionTemporalTest() throws Exception { * @assertion_ids: PERSISTENCE:SPEC:2114; PERSISTENCE:SPEC:2114.3; * @test_Strategy: ElementCollection of a basic type */ +@Test public void propertyElementCollectionTemporalTest() throws Exception { boolean pass = false; try { @@ -209,7 +210,7 @@ public void propertyElementCollectionTemporalTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("propertyElementCollectionTemporalTest failed"); + throw new Exception("propertyElementCollectionTemporalTest failed"); } } @@ -221,6 +222,7 @@ public void propertyElementCollectionTemporalTest() throws Exception { * * @test_Strategy: Used with a id annotation for field access */ +@Test public void idFieldTest() throws Exception { boolean pass = false; @@ -240,7 +242,7 @@ public void idFieldTest() throws Exception { } if (!pass) { - throw new Fault("idFieldTest failed"); + throw new Exception("idFieldTest failed"); } } @@ -252,6 +254,7 @@ public void idFieldTest() throws Exception { * * @test_Strategy: Used with a id annotation for property access */ +@Test public void idPropertyTest() throws Exception { boolean pass = false; try { @@ -272,12 +275,12 @@ public void idPropertyTest() throws Exception { } if (!pass) { - throw new Fault("idPropertyTest failed"); + throw new Exception("idPropertyTest failed"); } } - +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/Client.java index de809fbe97..7f2519e09d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,7 +20,10 @@ import java.util.Date; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,61 +33,60 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setupIntData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupIntData() throws Exception { TestUtil.logTrace("setupIntData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createIntTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @BeforeEach public void setupShortData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupShortData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createShortTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @BeforeEach public void setupLongData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupLongData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createLongTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @BeforeEach public void setupTimestampData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupTimestampData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTimestampTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -97,6 +99,7 @@ public void setupTimestampData(String[] args, Properties p) throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupIntData") + @Test public void intFieldTest() throws Exception { boolean pass = false; @@ -135,7 +138,7 @@ public void intFieldTest() throws Exception { } if (!pass) { - throw new Fault("intFieldTest failed"); + throw new Exception("intFieldTest failed"); } } @@ -149,6 +152,7 @@ public void intFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupIntData") + @Test public void intPropertyTest() throws Exception { boolean pass = false; try { @@ -187,7 +191,7 @@ public void intPropertyTest() throws Exception { } if (!pass) { - throw new Fault("intPropertyTest failed"); + throw new Exception("intPropertyTest failed"); } } @@ -200,6 +204,7 @@ public void intPropertyTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupIntData") + @Test public void integerFieldTest() throws Exception { boolean pass = false; @@ -238,7 +243,7 @@ public void integerFieldTest() throws Exception { } if (!pass) { - throw new Fault("integerFieldTest failed"); + throw new Exception("integerFieldTest failed"); } } @@ -251,6 +256,7 @@ public void integerFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupIntData") + @Test public void integerPropertyTest() throws Exception { boolean pass = false; try { @@ -289,7 +295,7 @@ public void integerPropertyTest() throws Exception { } if (!pass) { - throw new Fault("integerPropertyTest failed"); + throw new Exception("integerPropertyTest failed"); } } @@ -302,6 +308,7 @@ public void integerPropertyTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupShortData") + @Test public void shortFieldTest() throws Exception { boolean pass = false; @@ -340,7 +347,7 @@ public void shortFieldTest() throws Exception { } if (!pass) { - throw new Fault("shortFieldTest failed"); + throw new Exception("shortFieldTest failed"); } } @@ -353,6 +360,7 @@ public void shortFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupShortData") + @Test public void shortPropertyTest() throws Exception { boolean pass = false; try { @@ -390,7 +398,7 @@ public void shortPropertyTest() throws Exception { } if (!pass) { - throw new Fault("shortPropertyTest failed"); + throw new Exception("shortPropertyTest failed"); } } @@ -403,6 +411,7 @@ public void shortPropertyTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupShortData") + @Test public void shortClassFieldTest() throws Exception { boolean pass = false; @@ -442,7 +451,7 @@ public void shortClassFieldTest() throws Exception { } if (!pass) { - throw new Fault("shortClassFieldTest failed"); + throw new Exception("shortClassFieldTest failed"); } } @@ -455,6 +464,7 @@ public void shortClassFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupShortData") + @Test public void shortClassPropertyTest() throws Exception { boolean pass = false; try { @@ -494,7 +504,7 @@ public void shortClassPropertyTest() throws Exception { } if (!pass) { - throw new Fault("shortClassPropertyTest failed"); + throw new Exception("shortClassPropertyTest failed"); } } @@ -507,6 +517,7 @@ public void shortClassPropertyTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupLongData") + @Test public void longFieldTest() throws Exception { boolean pass = false; @@ -545,7 +556,7 @@ public void longFieldTest() throws Exception { } if (!pass) { - throw new Fault("shortFieldTest failed"); + throw new Exception("shortFieldTest failed"); } } @@ -558,6 +569,7 @@ public void longFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupLongData") + @Test public void longPropertyTest() throws Exception { boolean pass = false; try { @@ -595,7 +607,7 @@ public void longPropertyTest() throws Exception { } if (!pass) { - throw new Fault("shortPropertyTest failed"); + throw new Exception("shortPropertyTest failed"); } } @@ -608,6 +620,7 @@ public void longPropertyTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupLongData") + @Test public void longClassFieldTest() throws Exception { boolean pass = false; @@ -647,7 +660,7 @@ public void longClassFieldTest() throws Exception { } if (!pass) { - throw new Fault("shortClassFieldTest failed"); + throw new Exception("shortClassFieldTest failed"); } } @@ -660,6 +673,7 @@ public void longClassFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupLongData") + @Test public void longClassPropertyTest() throws Exception { boolean pass = false; try { @@ -699,7 +713,7 @@ public void longClassPropertyTest() throws Exception { } if (!pass) { - throw new Fault("shortClassPropertyTest failed"); + throw new Exception("shortClassPropertyTest failed"); } } @@ -712,6 +726,7 @@ public void longClassPropertyTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupTimestampData") + @Test public void timestampFieldTest() throws Exception { boolean pass = false; @@ -757,7 +772,7 @@ public void timestampFieldTest() throws Exception { } if (!pass) { - throw new Fault("timestampFieldTest failed"); + throw new Exception("timestampFieldTest failed"); } } @@ -770,6 +785,7 @@ public void timestampFieldTest() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupTimestampData") + @Test public void timestampPropertyTest() throws Exception { boolean pass = false; try { @@ -815,11 +831,12 @@ public void timestampPropertyTest() throws Exception { } if (!pass) { - throw new Fault("timestampPropertyTest failed"); + throw new Exception("timestampPropertyTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/basic/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/basic/Client.java index 41a4cb827d..54749e7e11 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/basic/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/basic/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,9 +20,10 @@ package com.sun.ts.tests.jpa.core.basic; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,21 +31,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -66,6 +63,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: With basic entity requirements, persist/remove an entity. */ + @Test public void updateOrderTest() throws Exception { boolean pass = true; final int count = 6; @@ -109,7 +107,7 @@ public void updateOrderTest() throws Exception { } } if (!pass) { - throw new Fault("updateOrderTest failed"); + throw new Exception("updateOrderTest failed"); } } @@ -120,6 +118,7 @@ public void updateOrderTest() throws Exception { * * @test_Strategy: Instantiate entity and verify it didn't get persisted */ + @Test public void newEntityTest() throws Exception { boolean pass = false; TestUtil.logTrace("Instantiate an order "); @@ -135,10 +134,11 @@ public void newEntityTest() throws Exception { } if (!pass) { - throw new Fault("newEntityTest failed"); + throw new Exception("newEntityTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/cache/basicTests/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/cache/basicTests/Client.java index 35bd042393..036bda0a54 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/cache/basicTests/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/cache/basicTests/Client.java @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.core.cache.basicTests; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,22 +33,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -69,6 +66,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: With basic entity requirements, persist/remove an entity. */ + @Test public void getcacheTest() throws Exception { Cache cache; boolean pass = false; @@ -113,7 +111,7 @@ public void getcacheTest() throws Exception { pass = true; } if (!pass) { - throw new Fault("getcacheTest failed"); + throw new Exception("getcacheTest failed"); } } @@ -136,6 +134,7 @@ public void getcacheTest() throws Exception { * * @test_Strategy: Persist data, evict class and specific PK */ + @Test public void evictTest1() throws Exception { Cache cache; final int count = 5; @@ -196,7 +195,7 @@ public void evictTest1() throws Exception { pass2 = true; } if (!pass1 || !pass2) { - throw new Fault("evictTest1 failed"); + throw new Exception("evictTest1 failed"); } } @@ -219,6 +218,7 @@ public void evictTest1() throws Exception { * * @test_Strategy: Persist data, evict class */ + @Test public void evictTest2() throws Exception { Cache cache; final int count = 5; @@ -275,7 +275,7 @@ public void evictTest2() throws Exception { pass2 = true; } if (!pass1 || !pass2) { - throw new Fault("evictTest2 failed"); + throw new Exception("evictTest2 failed"); } } @@ -297,6 +297,7 @@ public void evictTest2() throws Exception { * * @test_Strategy: Persist data, evict all */ + @Test public void evictallTest() throws Exception { Cache cache; final int count = 5; @@ -354,11 +355,12 @@ public void evictallTest() throws Exception { pass2 = true; } if (!pass1 || !pass2) { - throw new Fault("evictallTest failed"); + throw new Exception("evictallTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/common/EntityCallbackClientBase.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/common/EntityCallbackClientBase.java index f193690bf2..f97fd7ba43 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/common/EntityCallbackClientBase.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/common/EntityCallbackClientBase.java @@ -38,19 +38,19 @@ protected Object txShouldRollback(Object b, String testName) throws Exception { TestUtil.logTrace("Committing: " + b.getClass().getName() + " changes"); getEntityTransaction().commit(); reason = "Expecting ArithmeticException from callback method, but got none."; - throw new Fault(reason); + throw new Exception(reason); } catch (ArithmeticException e) { reason = "EntityCallbackClientBase: Got expected exception: " + e.toString(); TestUtil.logTrace(reason); if (!getEntityTransaction().isActive()) { reason = "No Transaction was active, even though one was previously started"; - throw new Fault(reason, e); + throw new Exception(reason, e); } } catch (Exception e) { reason = "EntityCallbackClientBase: Expecting ArithmeticException, but got unexpected exception: [" + e.toString() + "]"; - throw new Fault(reason, e); + throw new Exception(reason, e); } TestUtil.logTrace("Clearing cache"); clearCache(); @@ -66,7 +66,7 @@ protected Object txShouldRollback(Object b, String testName) throws Exception { cause = cause.getCause(); } if (cause == null) { - throw new Fault(e); + throw new Exception(e); } } if (p2 == null) { @@ -76,7 +76,7 @@ protected Object txShouldRollback(Object b, String testName) throws Exception { } else { reason = "EntityCallbackClientBase: Unexpected result: found entity with id " + testName; - throw new Fault(reason); + throw new Exception(reason); } return b; } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/inheritance/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/inheritance/Client.java index 61fdd9ad9b..d00f231900 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/inheritance/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/inheritance/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,7 +20,8 @@ package com.sun.ts.tests.jpa.core.callback.inheritance; -import java.util.Properties; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.core.callback.common.Constants; @@ -37,15 +38,16 @@ public Client() { super(); } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -80,6 +82,7 @@ private PricedPartProduct newPricedPartProduct(final String testName) { * * @test_Strategy: */ + @Test public void prePersistTest() throws Exception { String reason; final String testName = Constants.prePersistTest; @@ -93,12 +96,12 @@ public void prePersistTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "PricedPartProduct: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().rollback(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -130,12 +133,12 @@ public void prePersistTest2() throws Exception { TestUtil.logTrace(reason); } else { reason = "PricedPartProduct_2: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -168,13 +171,13 @@ public void preRemoveTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "PricedPartProduct: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } p1 = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -207,13 +210,13 @@ public void preRemoveTest2() throws Exception { TestUtil.logTrace(reason); } else { reason = "PricedPartProduct: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } p2 = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -244,7 +247,7 @@ public void preUpdateTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -277,7 +280,7 @@ public void preUpdateTest2() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest2", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -318,13 +321,13 @@ public void postLoadTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "PricedPartProduct: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -365,13 +368,13 @@ public void postLoadTest2() throws Exception { TestUtil.logTrace(reason); } else { reason = "PricedPartProduct_2: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -431,7 +434,7 @@ public void findProductTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during findProductTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listener/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listener/Client.java index 1ec75afc89..0ea730adc6 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listener/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listener/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,9 +21,11 @@ package com.sun.ts.tests.jpa.core.callback.listener; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.core.callback.common.Constants; import com.sun.ts.tests.jpa.core.callback.common.EntityCallbackClientBase; @@ -44,21 +46,17 @@ public Client() { super(); } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -70,6 +68,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: */ + @Test public void prePersistTest() throws Exception { String reason; final String testName = Constants.prePersistTest; @@ -84,12 +83,12 @@ public void prePersistTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -109,6 +108,7 @@ public void prePersistTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistMultiTest() throws Exception { final String testName = Constants.prePersistMultiTest; try { @@ -120,7 +120,7 @@ public void prePersistMultiTest() throws Exception { compareResultList(Constants.LISTENER_ABC, actual); getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -140,6 +140,7 @@ public void prePersistMultiTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistCascadeTest() throws Exception { String reason; final String testName = Constants.prePersistCascadeTest; @@ -160,7 +161,7 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPrePersistCalled()) { @@ -168,13 +169,13 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -195,6 +196,7 @@ public void prePersistCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistMultiCascadeTest() throws Exception { final String testName = Constants.prePersistMultiCascadeTest; try { @@ -217,7 +219,7 @@ public void prePersistMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -237,6 +239,7 @@ public void prePersistMultiCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveTest() throws Exception { String reason; final String testName = Constants.preRemoveTest; @@ -251,13 +254,13 @@ public void preRemoveTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } product = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -277,6 +280,7 @@ public void preRemoveTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveMultiTest() throws Exception { final String testName = Constants.preRemoveMultiTest; try { @@ -291,7 +295,7 @@ public void preRemoveMultiTest() throws Exception { product = null; getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -311,6 +315,7 @@ public void preRemoveMultiTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveCascadeTest() throws Exception { String reason; final String testName = Constants.preRemoveCascadeTest; @@ -333,7 +338,7 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPreRemoveCalled()) { @@ -341,13 +346,13 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -368,6 +373,7 @@ public void preRemoveCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveMultiCascadeTest() throws Exception { final String testName = Constants.preRemoveMultiCascadeTest; try { @@ -393,7 +399,7 @@ public void preRemoveMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveMultiCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -413,6 +419,7 @@ public void preRemoveMultiCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preUpdateTest() throws Exception { final String testName = Constants.preUpdateTest; try { @@ -425,7 +432,7 @@ public void preUpdateTest() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -445,6 +452,7 @@ public void preUpdateTest() throws Exception { * * @test_Strategy: */ + @Test public void postLoadTest() throws Exception { String reason; final String testName = Constants.postLoadTest; @@ -467,13 +475,13 @@ public void postLoadTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -493,6 +501,7 @@ public void postLoadTest() throws Exception { * * @test_Strategy: */ + @Test public void postLoadMultiTest() throws Exception { final String testName = Constants.postLoadMultiTest; try { @@ -511,7 +520,7 @@ public void postLoadMultiTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -548,6 +557,7 @@ private LineItem newLineItem(final String testName) { return lineItem; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listeneroverride/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listeneroverride/Client.java index 0d4d908cdf..4648444560 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listeneroverride/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/listeneroverride/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,9 +21,11 @@ package com.sun.ts.tests.jpa.core.callback.listeneroverride; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.core.callback.common.Constants; import com.sun.ts.tests.jpa.core.callback.common.EntityCallbackClientBase; @@ -44,21 +46,17 @@ public Client() { super(); } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -70,6 +68,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: */ + @Test public void prePersistTest() throws Exception { String reason; final String testName = Constants.prePersistTest; @@ -84,12 +83,12 @@ public void prePersistTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -109,6 +108,7 @@ public void prePersistTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistMultiTest() throws Exception { final String testName = Constants.prePersistMultiTest; try { @@ -120,7 +120,7 @@ public void prePersistMultiTest() throws Exception { compareResultList(Constants.LISTENER_ABC, actual); getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -139,6 +139,7 @@ public void prePersistMultiTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistCascadeTest() throws Exception { String reason; final String testName = Constants.prePersistCascadeTest; @@ -159,7 +160,7 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPrePersistCalled()) { @@ -167,13 +168,13 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -193,6 +194,7 @@ public void prePersistCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistMultiCascadeTest() throws Exception { final String testName = Constants.prePersistMultiCascadeTest; try { @@ -215,7 +217,7 @@ public void prePersistMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -234,6 +236,7 @@ public void prePersistMultiCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveTest() throws Exception { String reason; final String testName = Constants.preRemoveTest; @@ -248,13 +251,13 @@ public void preRemoveTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } product = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -274,6 +277,7 @@ public void preRemoveTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveMultiTest() throws Exception { final String testName = Constants.preRemoveMultiTest; try { @@ -288,7 +292,7 @@ public void preRemoveMultiTest() throws Exception { product = null; getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -307,6 +311,7 @@ public void preRemoveMultiTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveCascadeTest() throws Exception { String reason; final String testName = Constants.preRemoveCascadeTest; @@ -329,7 +334,7 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPreRemoveCalled()) { @@ -337,13 +342,13 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -363,6 +368,7 @@ public void preRemoveCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveMultiCascadeTest() throws Exception { final String testName = Constants.preRemoveMultiCascadeTest; try { @@ -388,7 +394,7 @@ public void preRemoveMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveMultiCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -407,6 +413,7 @@ public void preRemoveMultiCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preUpdateTest() throws Exception { final String testName = Constants.preUpdateTest; try { @@ -419,7 +426,7 @@ public void preUpdateTest() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -439,6 +446,7 @@ public void preUpdateTest() throws Exception { * * @test_Strategy: */ + @Test public void postLoadTest() throws Exception { String reason; final String testName = Constants.postLoadTest; @@ -458,13 +466,13 @@ public void postLoadTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -484,6 +492,7 @@ public void postLoadTest() throws Exception { * * @test_Strategy: */ + @Test public void postLoadMultiTest() throws Exception { final String testName = Constants.postLoadMultiTest; try { @@ -502,7 +511,7 @@ public void postLoadMultiTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -539,6 +548,7 @@ private LineItem newLineItem(final String testName) { return lineItem; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/method/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/method/Client.java index b665bcc6e2..5eb5731021 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/method/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/method/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,9 +22,11 @@ import java.util.Arrays; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.core.callback.common.Constants; import com.sun.ts.tests.jpa.core.callback.common.EntityCallbackClientBase; @@ -45,21 +47,16 @@ public Client() { super(); } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -70,6 +67,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: */ +@Test public void prePersistTest() throws Exception { String reason; final String testName = Constants.prePersistTest; @@ -83,12 +81,12 @@ public void prePersistTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -108,6 +106,7 @@ public void prePersistTest() throws Exception { * * @test_Strategy: */ +@Test public void prePersistMultiTest() throws Exception { final String testName = Constants.prePersistMultiTest; try { @@ -121,7 +120,7 @@ public void prePersistMultiTest() throws Exception { compareResultList(expected, actual); getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -140,6 +139,7 @@ public void prePersistMultiTest() throws Exception { * * @test_Strategy: */ +@Test public void prePersistCascadeTest() throws Exception { String reason; final String testName = Constants.prePersistCascadeTest; @@ -159,7 +159,7 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPrePersistCalled()) { @@ -167,13 +167,13 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -193,6 +193,7 @@ public void prePersistCascadeTest() throws Exception { * * @test_Strategy: */ +@Test public void prePersistMultiCascadeTest() throws Exception { final String testName = Constants.prePersistMultiCascadeTest; try { @@ -219,7 +220,7 @@ public void prePersistMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -238,6 +239,7 @@ public void prePersistMultiCascadeTest() throws Exception { * * @test_Strategy: */ +@Test public void preRemoveTest() throws Exception { String reason; final String testName = Constants.preRemoveTest; @@ -252,13 +254,13 @@ public void preRemoveTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } product = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -278,6 +280,7 @@ public void preRemoveTest() throws Exception { * * @test_Strategy: */ +@Test public void preRemoveMultiTest() throws Exception { final String testName = Constants.preRemoveMultiTest; try { @@ -294,7 +297,7 @@ public void preRemoveMultiTest() throws Exception { product = null; getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -313,6 +316,7 @@ public void preRemoveMultiTest() throws Exception { * * @test_Strategy: */ +@Test public void preRemoveCascadeTest() throws Exception { String reason; final String testName = Constants.preRemoveCascadeTest; @@ -335,7 +339,7 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPreRemoveCalled()) { @@ -343,13 +347,13 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -369,6 +373,7 @@ public void preRemoveCascadeTest() throws Exception { * * @test_Strategy: */ +@Test public void preRemoveMultiCascadeTest() throws Exception { final String testName = Constants.preRemoveMultiCascadeTest; try { @@ -398,7 +403,7 @@ public void preRemoveMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveMultiCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -417,6 +422,7 @@ public void preRemoveMultiCascadeTest() throws Exception { * * @test_Strategy: */ +@Test public void preUpdateTest() throws Exception { final String testName = Constants.preUpdateTest; try { @@ -429,7 +435,7 @@ public void preUpdateTest() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -448,6 +454,7 @@ public void preUpdateTest() throws Exception { * * @test_Strategy: */ +@Test public void postLoadTest() throws Exception { String reason; final String testName = Constants.postLoadTest; @@ -470,13 +477,13 @@ public void postLoadTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -496,6 +503,7 @@ public void postLoadTest() throws Exception { * * @test_Strategy: */ +@Test public void postLoadMultiTest() throws Exception { final String testName = Constants.postLoadMultiTest; try { @@ -516,7 +524,7 @@ public void postLoadMultiTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -553,6 +561,7 @@ private LineItem newLineItem(final String testName) { return lineItem; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/methodoverride/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/methodoverride/Client.java index 97cb29617a..cc84f9fc0b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/methodoverride/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/methodoverride/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,9 +22,11 @@ import java.util.Arrays; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.core.callback.common.Constants; import com.sun.ts.tests.jpa.core.callback.common.EntityCallbackClientBase; @@ -42,21 +44,17 @@ public Client() { super(); } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -67,6 +65,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: */ + @Test public void prePersistTest() throws Exception { String reason; final String testName = Constants.prePersistTest; @@ -80,12 +79,12 @@ public void prePersistTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -105,6 +104,7 @@ public void prePersistTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistMultiTest() throws Exception { final String testName = Constants.prePersistMultiTest; try { @@ -118,7 +118,7 @@ public void prePersistMultiTest() throws Exception { compareResultList(expected, actual); getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -137,6 +137,7 @@ public void prePersistMultiTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistCascadeTest() throws Exception { String reason; final String testName = Constants.prePersistCascadeTest; @@ -156,7 +157,7 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPrePersistCalled()) { @@ -164,13 +165,13 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -190,6 +191,7 @@ public void prePersistCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void prePersistMultiCascadeTest() throws Exception { final String testName = Constants.prePersistMultiCascadeTest; try { @@ -216,7 +218,7 @@ public void prePersistMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -235,6 +237,7 @@ public void prePersistMultiCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveTest() throws Exception { String reason; final String testName = Constants.preRemoveTest; @@ -249,13 +252,13 @@ public void preRemoveTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } product = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -275,6 +278,7 @@ public void preRemoveTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveMultiTest() throws Exception { final String testName = Constants.preRemoveMultiTest; try { @@ -291,7 +295,7 @@ public void preRemoveMultiTest() throws Exception { product = null; getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -310,6 +314,7 @@ public void preRemoveMultiTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveCascadeTest() throws Exception { String reason; final String testName = Constants.preRemoveCascadeTest; @@ -332,7 +337,7 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPreRemoveCalled()) { @@ -340,13 +345,13 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -366,6 +371,7 @@ public void preRemoveCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preRemoveMultiCascadeTest() throws Exception { final String testName = Constants.preRemoveMultiCascadeTest; try { @@ -395,7 +401,7 @@ public void preRemoveMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveMultiCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -414,6 +420,7 @@ public void preRemoveMultiCascadeTest() throws Exception { * * @test_Strategy: */ + @Test public void preUpdateTest() throws Exception { final String testName = Constants.preUpdateTest; try { @@ -426,7 +433,7 @@ public void preUpdateTest() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -444,7 +451,8 @@ public void preUpdateTest() throws Exception { * @assertion_ids: PERSISTENCE:SPEC:694; PERSISTENCE:SPEC:719 * * @test_Strategy: - */ + */ + @Test public void postLoadTest() throws Exception { String reason; final String testName = Constants.postLoadTest; @@ -464,13 +472,13 @@ public void postLoadTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -490,6 +498,7 @@ public void postLoadTest() throws Exception { * * @test_Strategy: */ + @Test public void postLoadMultiTest() throws Exception { final String testName = Constants.postLoadMultiTest; try { @@ -510,7 +519,7 @@ public void postLoadMultiTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -547,6 +556,7 @@ private LineItem newLineItem(final String testName) { return lineItem; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/xml/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/xml/Client.java index db527dc208..6cb3f31aba 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/xml/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/callback/xml/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -23,9 +23,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.core.callback.common.Constants; import com.sun.ts.tests.jpa.core.callback.common.EntityCallbackClientBase; @@ -48,21 +50,17 @@ public Client() { super(); } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -76,6 +74,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void prePersistTest() throws Exception { String reason; final String testName = Constants.prePersistTest; @@ -90,12 +89,12 @@ public void prePersistTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -117,6 +116,7 @@ public void prePersistTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void prePersistMultiTest() throws Exception { final String testName = Constants.prePersistMultiTest; try { @@ -128,7 +128,7 @@ public void prePersistMultiTest() throws Exception { compareResultList(Constants.LISTENER_AABBCC, actual); getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -151,6 +151,7 @@ public void prePersistMultiTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void prePersistCascadeTest() throws Exception { String reason; final String testName = Constants.prePersistCascadeTest; @@ -171,7 +172,7 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPrePersistCalled()) { @@ -179,13 +180,13 @@ public void prePersistCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -209,6 +210,7 @@ public void prePersistCascadeTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void prePersistMultiCascadeTest() throws Exception { final String testName = Constants.prePersistMultiCascadeTest; try { @@ -231,7 +233,7 @@ public void prePersistMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -252,6 +254,7 @@ public void prePersistMultiCascadeTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void preRemoveTest() throws Exception { String reason; final String testName = Constants.preRemoveTest; @@ -266,13 +269,13 @@ public void preRemoveTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } product = null; getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -294,6 +297,7 @@ public void preRemoveTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void preRemoveMultiTest() throws Exception { final String testName = Constants.preRemoveMultiTest; try { @@ -308,7 +312,7 @@ public void preRemoveMultiTest() throws Exception { product = null; getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -330,6 +334,7 @@ public void preRemoveMultiTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void preRemoveCascadeTest() throws Exception { String reason; final String testName = Constants.preRemoveCascadeTest; @@ -352,7 +357,7 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Order: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } if (lineItem.isPreRemoveCalled()) { @@ -360,13 +365,13 @@ public void preRemoveCascadeTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "LineItem: preRemove was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -389,6 +394,7 @@ public void preRemoveCascadeTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void preRemoveMultiCascadeTest() throws Exception { final String testName = Constants.preRemoveMultiCascadeTest; try { @@ -414,7 +420,7 @@ public void preRemoveMultiCascadeTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during preRemoveMultiCascadeTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -435,6 +441,7 @@ public void preRemoveMultiCascadeTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void preUpdateTest() throws Exception { final String testName = Constants.preUpdateTest; try { @@ -447,7 +454,7 @@ public void preUpdateTest() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception caught during preUpdateTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -469,6 +476,7 @@ public void preUpdateTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void postLoadTest() throws Exception { String reason; final String testName = Constants.postLoadTest; @@ -491,13 +499,13 @@ public void postLoadTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Product: postLoad was not called even after the query result was returned."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during postLoadTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -519,6 +527,7 @@ public void postLoadTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void postLoadMultiTest() throws Exception { final String testName = Constants.postLoadMultiTest; try { @@ -537,7 +546,7 @@ public void postLoadMultiTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -558,6 +567,7 @@ public void postLoadMultiTest() throws Exception { * @test_Strategy: xml elements are used to define behavior instead of * annotations */ + @Test public void prePersistRuntimeExceptionTest() throws Exception { final String testName = Constants.prePersistRuntimeExceptionTest; try { @@ -573,7 +583,7 @@ public void prePersistRuntimeExceptionTest() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistRuntimeExceptionTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -592,6 +602,7 @@ public void prePersistRuntimeExceptionTest() throws Exception { * * @test_Strategy: make use of the default listener defined in the orm.xml */ + @Test public void prePersistDefaultListenerTest() throws Exception { String reason; final String testName = Constants.prePersistDefaultListenerTest; @@ -606,12 +617,12 @@ public void prePersistDefaultListenerTest() throws Exception { TestUtil.logTrace(reason); } else { reason = "Customer: prePersist was not called."; - throw new Fault(reason); + throw new Exception(reason); } getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Exception caught during prePersistTest", e); - throw new Fault(e); + throw new Exception(e); } finally { try { if (getEntityTransaction().isActive()) { @@ -653,6 +664,7 @@ private Customer newCustomer(final String testName) { return customer; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/Client.java index a56ce1f016..6f4129ed6f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/Client.java @@ -25,9 +25,11 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Properties; import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.schema30.Address; @@ -72,14 +74,15 @@ public class Client extends Util { - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -92,6 +95,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: * */ + @Test public void createQuery() throws Exception { boolean pass = false; @@ -109,7 +113,7 @@ public void createQuery() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createQuery Test failed"); + throw new Exception("createQuery Test failed"); } } @@ -122,6 +126,7 @@ public void createQuery() throws Exception { * @test_Strategy: * */ + @Test public void createQuery2() throws Exception { boolean pass = false; @@ -139,7 +144,7 @@ public void createQuery2() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createQuery2 Test failed"); + throw new Exception("createQuery2 Test failed"); } } @@ -152,6 +157,7 @@ public void createQuery2() throws Exception { * @test_Strategy: * */ + @Test public void createTuple() throws Exception { boolean pass = false; @@ -169,7 +175,7 @@ public void createTuple() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createTuple Test failed"); + throw new Exception("createTuple Test failed"); } } @@ -188,6 +194,7 @@ public void createTuple() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void construct() throws Exception { boolean pass = false; @@ -240,7 +247,7 @@ public void construct() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("construct Test failed"); + throw new Exception("construct Test failed"); } } @@ -254,6 +261,7 @@ public void construct() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void tupleIntTest() throws Exception { boolean pass1 = true; boolean pass2 = false; @@ -325,7 +333,7 @@ public void tupleIntTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("tupleIntTest test failed"); + throw new Exception("tupleIntTest test failed"); } } @@ -339,6 +347,7 @@ public void tupleIntTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void tupleToArrayTest() throws Exception { boolean pass = false; @@ -408,7 +417,7 @@ public void tupleToArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("tupleToArrayTest test failed"); + throw new Exception("tupleToArrayTest test failed"); } } @@ -422,6 +431,7 @@ public void tupleToArrayTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void tupleIntClassTest() throws Exception { boolean pass1 = true; boolean pass2 = false; @@ -491,7 +501,7 @@ public void tupleIntClassTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("tupleIntClassTest test failed"); + throw new Exception("tupleIntClassTest test failed"); } } @@ -507,6 +517,7 @@ public void tupleIntClassTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleGetIntIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -561,7 +572,7 @@ public void tupleGetIntIllegalArgumentExceptionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("tupleGetIntIllegalArgumentExceptionTest failed"); + throw new Exception("tupleGetIntIllegalArgumentExceptionTest failed"); } } @@ -576,6 +587,7 @@ public void tupleGetIntIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void tupleGetIntClassIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -637,7 +649,7 @@ public void tupleGetIntClassIllegalArgumentExceptionTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("tupleGetIntClassIllegalArgumentExceptionTest failed"); + throw new Exception("tupleGetIntClassIllegalArgumentExceptionTest failed"); } } @@ -653,6 +665,7 @@ public void tupleGetIntClassIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleGetElementsGetTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -745,7 +758,7 @@ public void tupleGetElementsGetTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("tupleGetElementsGetTest failed"); + throw new Exception("tupleGetElementsGetTest failed"); } } @@ -759,6 +772,7 @@ public void tupleGetElementsGetTest() throws Exception { * WHERE (ID = 1) */ @SetupMethod(name = "setupCustAliasProductData") + @Test public void tupleGetTupleElementIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -850,7 +864,7 @@ public void tupleGetTupleElementIllegalArgumentExceptionTest() throws Exception getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "tupleGetTupleElementIllegalArgumentExceptionTest failed"); } } @@ -865,6 +879,7 @@ public void tupleGetTupleElementIllegalArgumentExceptionTest() throws Exception * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleGetStringTest() throws Exception { boolean pass1 = true; boolean pass2 = false; @@ -938,7 +953,7 @@ public void tupleGetStringTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("tupleGetStringTest failed"); + throw new Exception("tupleGetStringTest failed"); } } @@ -953,6 +968,7 @@ public void tupleGetStringTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleGetStringIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -1010,7 +1026,7 @@ public void tupleGetStringIllegalArgumentExceptionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("tupleGetStringIllegalArgumentExceptionTest failed"); + throw new Exception("tupleGetStringIllegalArgumentExceptionTest failed"); } } @@ -1025,6 +1041,7 @@ public void tupleGetStringIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleGetStringClassIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1094,7 +1111,7 @@ public void tupleGetStringClassIllegalArgumentExceptionTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("tupleGetStringClassIllegalArgumentExceptionTest failed"); + throw new Exception("tupleGetStringClassIllegalArgumentExceptionTest failed"); } } @@ -1108,6 +1125,7 @@ public void tupleGetStringClassIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleGetStringClassTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -1183,7 +1201,7 @@ public void tupleGetStringClassTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3) { - throw new Fault("tupleGetStringClassTest failed"); + throw new Exception("tupleGetStringClassTest failed"); } } @@ -1198,6 +1216,7 @@ public void tupleGetStringClassTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void tupleElementGetAliasTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1251,7 +1270,7 @@ public void tupleElementGetAliasTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("tupleElementGetAliasTest failed"); + throw new Exception("tupleElementGetAliasTest failed"); } } @@ -1265,6 +1284,7 @@ public void tupleElementGetAliasTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void tupleElementGetJavaTypeTest() throws Exception { boolean pass = false; @@ -1295,7 +1315,7 @@ public void tupleElementGetJavaTypeTest() throws Exception { } if (!pass) { - throw new Fault("tupleElementGetJavaTypeTest failed"); + throw new Exception("tupleElementGetJavaTypeTest failed"); } } @@ -1310,6 +1330,7 @@ public void tupleElementGetJavaTypeTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void tupleSelectionArrayTest() throws Exception { boolean pass = false; @@ -1370,7 +1391,7 @@ public void tupleSelectionArrayTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("tupleSelectionArrayTest failed"); + throw new Exception("tupleSelectionArrayTest failed"); } } @@ -1381,6 +1402,7 @@ public void tupleSelectionArrayTest() throws Exception { * * @test_Strategy: */ + @Test public void tupleSelectionArrayIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1427,7 +1449,7 @@ public void tupleSelectionArrayIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass1 || !pass2) { - throw new Fault("tupleSelectionArrayIllegalArgumentExceptionTest failed"); + throw new Exception("tupleSelectionArrayIllegalArgumentExceptionTest failed"); } } @@ -1444,6 +1466,7 @@ public void tupleSelectionArrayIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void array() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -1516,7 +1539,7 @@ public void array() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3) { - throw new Fault("array test failed"); + throw new Exception("array test failed"); } } @@ -1530,6 +1553,7 @@ public void array() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void arrayIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1570,7 +1594,7 @@ public void arrayIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("arrayIllegalArgumentExceptionTest failed"); + throw new Exception("arrayIllegalArgumentExceptionTest failed"); } } @@ -1584,6 +1608,7 @@ public void arrayIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void constructIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1624,7 +1649,7 @@ public void constructIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("constructIllegalArgumentExceptionTest failed"); + throw new Exception("constructIllegalArgumentExceptionTest failed"); } } @@ -1637,6 +1662,7 @@ public void constructIllegalArgumentExceptionTest() throws Exception { * @test_Strategy: Select p from Product p where p.whouse = "WH5" */ @SetupMethod(name = "setupProductData") + @Test public void primaryKeyJoinColumnTest() throws Exception { boolean pass = false; @@ -1669,7 +1695,7 @@ public void primaryKeyJoinColumnTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("primaryKeyJoinColumnTest failed"); + throw new Exception("primaryKeyJoinColumnTest failed"); } } @@ -1683,6 +1709,7 @@ public void primaryKeyJoinColumnTest() throws Exception { * hardware.Product.modeNumber */ @SetupMethod(name = "setupProductData") + @Test public void asc() throws Exception { final int expectedModelNumber = 40; final int expectedResultSize = 10; @@ -1722,7 +1749,7 @@ public void asc() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("asc Test failed"); + throw new Exception("asc Test failed"); } } @@ -1735,6 +1762,7 @@ public void asc() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void desc() throws Exception { final int expectedModelNumber = 104; final int expectedResultSize = 10; @@ -1774,7 +1802,7 @@ public void desc() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("desc Test failed"); + throw new Exception("desc Test failed"); } } @@ -1788,6 +1816,7 @@ public void desc() throws Exception { * AVG(o.totalPrice) FROM Order o */ @SetupMethod(name = "setupOrderData") + @Test public void avg() throws Exception { boolean pass = false; @@ -1822,7 +1851,7 @@ public void avg() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("avg test failed"); + throw new Exception("avg test failed"); } } @@ -1836,6 +1865,7 @@ public void avg() throws Exception { * Sum(p.price) FROM Product p */ @SetupMethod(name = "setupProductData") + @Test public void sumExpTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1878,7 +1908,7 @@ public void sumExpTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("sumExpTest failed"); + throw new Exception("sumExpTest failed"); } } @@ -1891,6 +1921,7 @@ public void sumExpTest() throws Exception { * sum(p.price,100) FROM Product p WHERE p.id = 1 */ @SetupMethod(name = "setupProductData") + @Test public void sumExpNumTest() throws Exception { boolean pass = false; @@ -1929,7 +1960,7 @@ public void sumExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sumExpNumTest failed"); + throw new Exception("sumExpNumTest failed"); } } @@ -1942,6 +1973,7 @@ public void sumExpNumTest() throws Exception { * sum(100,p.price) FROM Product p WHERE p.id = 1 */ @SetupMethod(name = "setupProductData") + @Test public void sumNumExpTest() throws Exception { boolean pass = false; @@ -1981,7 +2013,7 @@ public void sumNumExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sumNumExpTest failed"); + throw new Exception("sumNumExpTest failed"); } } @@ -1994,6 +2026,7 @@ public void sumNumExpTest() throws Exception { * sum(p.quantity,p.quantity) FROM Product p WHERE p.id = 1 */ @SetupMethod(name = "setupProductData") + @Test public void sumExpExpTest() throws Exception { boolean pass = false; @@ -2033,7 +2066,7 @@ public void sumExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sumExpExpTest failed"); + throw new Exception("sumExpExpTest failed"); } } @@ -2047,6 +2080,7 @@ public void sumExpExpTest() throws Exception { * MAX(l.quantity) FROM LineItem l */ @SetupMethod(name = "setupOrderData") + @Test public void max() throws Exception { boolean pass1, pass2; pass1 = pass2 = false; @@ -2129,7 +2163,7 @@ public void max() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("max test failed"); + throw new Exception("max test failed"); } } @@ -2143,6 +2177,7 @@ public void max() throws Exception { * DISTINCT MIN(l.quantity) FROM LineItem l */ @SetupMethod(name = "setupOrderData") + @Test public void min() throws Exception { boolean pass1, pass2; pass1 = pass2 = false; @@ -2225,7 +2260,7 @@ public void min() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("max test failed"); + throw new Exception("max test failed"); } } @@ -2238,6 +2273,7 @@ public void min() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void greatest() throws Exception { boolean pass = false; @@ -2279,7 +2315,7 @@ public void greatest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("greatest test failed"); + throw new Exception("greatest test failed"); } } @@ -2292,6 +2328,7 @@ public void greatest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void least() throws Exception { boolean pass = false; @@ -2335,7 +2372,7 @@ public void least() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("least test failed"); + throw new Exception("least test failed"); } } @@ -2348,6 +2385,7 @@ public void least() throws Exception { * (o.id) From Order o */ @SetupMethod(name = "setupOrderData") + @Test public void count() throws Exception { boolean pass = false; @@ -2383,7 +2421,7 @@ public void count() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("count test failed"); + throw new Exception("count test failed"); } } @@ -2395,6 +2433,7 @@ public void count() throws Exception { * @test_Strategy: Select DISTINCT Count(c.home.city) from Customer c */ @SetupMethod(name = "setupCustomerData") + @Test public void countDistinct() throws Exception { boolean pass = false; @@ -2439,7 +2478,7 @@ public void countDistinct() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("countDistinct test failed"); + throw new Exception("countDistinct test failed"); } } @@ -2457,6 +2496,7 @@ public void countDistinct() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void exists() throws Exception { boolean pass = false; @@ -2517,7 +2557,7 @@ public void exists() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("exists test failed"); + throw new Exception("exists test failed"); } } @@ -2534,6 +2574,7 @@ public void exists() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void subqueryFromEntityTypeTest() throws Exception { boolean pass = false; @@ -2593,7 +2634,7 @@ public void subqueryFromEntityTypeTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryFromEntityTypeTest failed"); + throw new Exception("subqueryFromEntityTypeTest failed"); } } @@ -2612,6 +2653,7 @@ public void subqueryFromEntityTypeTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void all() throws Exception { boolean pass = false; @@ -2677,7 +2719,7 @@ public void all() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("all test failed"); + throw new Exception("all test failed"); } } @@ -2694,6 +2736,7 @@ public void all() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void some() throws Exception { boolean pass = false; @@ -2772,7 +2815,7 @@ public void some() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("some test failed"); + throw new Exception("some test failed"); } } @@ -2789,6 +2832,7 @@ public void some() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void any() throws Exception { boolean pass = false; @@ -2869,7 +2913,7 @@ public void any() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("any test failed"); + throw new Exception("any test failed"); } } @@ -2883,6 +2927,7 @@ public void any() throws Exception { * '11345' */ @SetupMethod(name = "setupCustomerData") + @Test public void andPredicates() throws Exception { boolean pass = false; @@ -2950,7 +2995,7 @@ public void andPredicates() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("andPredicates test failed"); + throw new Exception("andPredicates test failed"); } } @@ -2965,6 +3010,7 @@ public void andPredicates() throws Exception { * c.home.zip = '02155' */ @SetupMethod(name = "setupCustomerData") + @Test public void orPredicates() throws Exception { boolean pass = false; @@ -3041,7 +3087,7 @@ public void orPredicates() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("orPredicates test failed"); + throw new Exception("orPredicates test failed"); } } @@ -3057,6 +3103,7 @@ public void orPredicates() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void notPredicate() throws Exception { boolean pass = false; @@ -3107,7 +3154,7 @@ public void notPredicate() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notPredicate test failed"); + throw new Exception("notPredicate test failed"); } } @@ -3123,6 +3170,7 @@ public void notPredicate() throws Exception { * Note: cbuilder.conjunction() always returns true */ @SetupMethod(name = "setupOrderData") + @Test public void conjunction() throws Exception { boolean pass = false; @@ -3179,7 +3227,7 @@ public void conjunction() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("conjunction test failed"); + throw new Exception("conjunction test failed"); } } @@ -3195,6 +3243,7 @@ public void conjunction() throws Exception { * Note: cbuilder.disjunction() always returns false */ @SetupMethod(name = "setupOrderData") + @Test public void disjunction() throws Exception { boolean pass = false; @@ -3251,7 +3300,7 @@ public void disjunction() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("disjunction test failed"); + throw new Exception("disjunction test failed"); } } @@ -3267,6 +3316,7 @@ public void disjunction() throws Exception { * Note: cbuilder.conjunction() always returns true */ @SetupMethod(name = "setupOrderData") + @Test public void isTrue() throws Exception { boolean pass = false; @@ -3322,7 +3372,7 @@ public void isTrue() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isTrue test failed"); + throw new Exception("isTrue test failed"); } } @@ -3338,6 +3388,7 @@ public void isTrue() throws Exception { * Note: cbuilder.disjunction() always returns false */ @SetupMethod(name = "setupOrderData") + @Test public void isFalse() throws Exception { boolean pass = false; @@ -3391,7 +3442,7 @@ public void isFalse() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isFalse test failed"); + throw new Exception("isFalse test failed"); } } @@ -3407,6 +3458,7 @@ public void isFalse() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void isNull() throws Exception { boolean pass = false; @@ -3450,7 +3502,7 @@ public void isNull() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isNull test failed"); + throw new Exception("isNull test failed"); } } @@ -3465,6 +3517,7 @@ public void isNull() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void isNotNull() throws Exception { boolean pass = false; @@ -3516,7 +3569,7 @@ public void isNotNull() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isNotNull test failed"); + throw new Exception("isNotNull test failed"); } @@ -3532,6 +3585,7 @@ public void isNotNull() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void equalExpObjectTest() throws Exception { boolean pass = false; int j = 0; @@ -3587,7 +3641,7 @@ public void equalExpObjectTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("equalExpObjectTest failed"); + throw new Exception("equalExpObjectTest failed"); } } @@ -3602,6 +3656,7 @@ public void equalExpObjectTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void equalExpExpTest() throws Exception { boolean pass = false; @@ -3657,7 +3712,7 @@ public void equalExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("equalExpExpTest failed"); + throw new Exception("equalExpExpTest failed"); } } @@ -3672,6 +3727,7 @@ public void equalExpExpTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void notEqualExpObjectTest() throws Exception { boolean pass = false; @@ -3727,7 +3783,7 @@ public void notEqualExpObjectTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notEqualExpObjectTest test failed"); + throw new Exception("notEqualExpObjectTest test failed"); } } @@ -3742,6 +3798,7 @@ public void notEqualExpObjectTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void notEqualExpExpTest() throws Exception { boolean pass = false; @@ -3797,7 +3854,7 @@ public void notEqualExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notEqualExpExpTest test failed"); + throw new Exception("notEqualExpExpTest test failed"); } } @@ -3814,6 +3871,7 @@ public void notEqualExpExpTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void sumAsDoubleTest() throws Exception { boolean pass = false; double expected = 217.5d; @@ -3863,7 +3921,7 @@ public void sumAsDoubleTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sumAsDoubleTest failed"); + throw new Exception("sumAsDoubleTest failed"); } } @@ -3880,6 +3938,7 @@ public void sumAsDoubleTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void sumAsLongTest() throws Exception { boolean pass = false; long expected = 435; @@ -3926,7 +3985,7 @@ public void sumAsLongTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sumAsLongTest failed"); + throw new Exception("sumAsLongTest failed"); } } @@ -3940,6 +3999,7 @@ public void sumAsLongTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void greaterThanExpNumTest() throws Exception { boolean pass = false; @@ -3989,7 +4049,7 @@ public void greaterThanExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("greaterThanExpNumTest failed"); + throw new Exception("greaterThanExpNumTest failed"); } } @@ -4003,6 +4063,7 @@ public void greaterThanExpNumTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void greaterThanExpExpTest() throws Exception { boolean pass = false; @@ -4053,7 +4114,7 @@ public void greaterThanExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("greaterThanExpExpTest failed"); + throw new Exception("greaterThanExpExpTest failed"); } } @@ -4067,6 +4128,7 @@ public void greaterThanExpExpTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void greaterThanOrEqualToExpNumTest() throws Exception { boolean pass = false; @@ -4124,7 +4186,7 @@ public void greaterThanOrEqualToExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("greaterThanOrEqualToExpNumTest failed"); + throw new Exception("greaterThanOrEqualToExpNumTest failed"); } } @@ -4138,6 +4200,7 @@ public void greaterThanOrEqualToExpNumTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void greaterThanOrEqualToExpExpTest() throws Exception { boolean pass = false; @@ -4194,7 +4257,7 @@ public void greaterThanOrEqualToExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("greaterThanOrEqualToExpExpTest failed"); + throw new Exception("greaterThanOrEqualToExpExpTest failed"); } } @@ -4210,6 +4273,7 @@ public void greaterThanOrEqualToExpExpTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void lessThanExpNumTest() throws Exception { boolean pass = false; @@ -4274,7 +4338,7 @@ public void lessThanExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("lessThanExpNumTest failed"); + throw new Exception("lessThanExpNumTest failed"); } } @@ -4290,6 +4354,7 @@ public void lessThanExpNumTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void lessThanExpExpTest() throws Exception { boolean pass = false; @@ -4354,7 +4419,7 @@ public void lessThanExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("lessThanExpExpTest failed"); + throw new Exception("lessThanExpExpTest failed"); } } @@ -4368,6 +4433,7 @@ public void lessThanExpExpTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void lessThanOrEqualToExpNumTest() throws Exception { boolean pass = false; @@ -4433,7 +4499,7 @@ public void lessThanOrEqualToExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("lessThanOrEqualToExpNumTest failed"); + throw new Exception("lessThanOrEqualToExpNumTest failed"); } } @@ -4447,6 +4513,7 @@ public void lessThanOrEqualToExpNumTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void lessThanOrEqualToExpExpTest() throws Exception { boolean pass = false; @@ -4511,7 +4578,7 @@ public void lessThanOrEqualToExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("lessThanOrEqualToExpExpTest failed"); + throw new Exception("lessThanOrEqualToExpExpTest failed"); } } @@ -4525,6 +4592,7 @@ public void lessThanOrEqualToExpExpTest() throws Exception { * :date1 AND :date6 */ @SetupMethod(name = "setupProductData") + @Test public void between() throws Exception { boolean pass = false; @@ -4584,7 +4652,7 @@ public void between() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("between test failed"); + throw new Exception("between test failed"); } } @@ -4597,6 +4665,7 @@ public void between() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void gtExpNumTest() throws Exception { boolean pass = false; @@ -4647,7 +4716,7 @@ public void gtExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("gtExpNumTest failed"); + throw new Exception("gtExpNumTest failed"); } } @@ -4661,6 +4730,7 @@ public void gtExpNumTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void gtExpExpTest() throws Exception { boolean pass = false; @@ -4712,7 +4782,7 @@ public void gtExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("gtExpExpTest failed"); + throw new Exception("gtExpExpTest failed"); } } @@ -4726,6 +4796,7 @@ public void gtExpExpTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void geExpNumTest() throws Exception { boolean pass = false; @@ -4784,7 +4855,7 @@ public void geExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("geExpNumTest failed"); + throw new Exception("geExpNumTest failed"); } } @@ -4798,6 +4869,7 @@ public void geExpNumTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void geExpExpTest() throws Exception { boolean pass = false; @@ -4856,7 +4928,7 @@ public void geExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("geExpExpTest failed"); + throw new Exception("geExpExpTest failed"); } } @@ -4870,6 +4942,7 @@ public void geExpExpTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void ltExpNumTest() throws Exception { boolean pass = false; @@ -4933,7 +5006,7 @@ public void ltExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("ltExpNumTest failed"); + throw new Exception("ltExpNumTest failed"); } } @@ -4947,6 +5020,7 @@ public void ltExpNumTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void ltExpExpTest() throws Exception { boolean pass = false; @@ -5010,7 +5084,7 @@ public void ltExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("ltExpExpTest failed"); + throw new Exception("ltExpExpTest failed"); } } @@ -5024,6 +5098,7 @@ public void ltExpExpTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void leExpNumTest() throws Exception { boolean pass = false; @@ -5089,7 +5164,7 @@ public void leExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("leExpNumTest failed"); + throw new Exception("leExpNumTest failed"); } } @@ -5103,6 +5178,7 @@ public void leExpNumTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void leExpExpTest() throws Exception { boolean pass = false; @@ -5168,7 +5244,7 @@ public void leExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("leExpExpTest failed"); + throw new Exception("leExpExpTest failed"); } } @@ -5181,6 +5257,7 @@ public void leExpExpTest() throws Exception { * @test_Strategy: SELECT NEG(p.quantity) From Product p where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void neg() throws Exception { boolean pass = false; @@ -5222,7 +5299,7 @@ public void neg() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("neg test failed"); + throw new Exception("neg test failed"); } } @@ -5238,6 +5315,7 @@ public void neg() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void abs() throws Exception { boolean pass = false; @@ -5290,7 +5368,7 @@ public void abs() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("abs test failed"); + throw new Exception("abs test failed"); } } @@ -5304,6 +5382,7 @@ public void abs() throws Exception { * @test_Strategy: SELECT p.quantity *10F From Product p where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void prodExpNumTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -5354,7 +5433,7 @@ public void prodExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("prodExpNumTest failed"); + throw new Exception("prodExpNumTest failed"); } } @@ -5366,6 +5445,7 @@ public void prodExpNumTest() throws Exception { * @test_Strategy: SELECT 10 * p.quantity From Product p where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void prodNumExpTest() throws Exception { boolean pass = false; @@ -5407,7 +5487,7 @@ public void prodNumExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("prodNumExpTest failed"); + throw new Exception("prodNumExpTest failed"); } } @@ -5420,6 +5500,7 @@ public void prodNumExpTest() throws Exception { * p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void prodExpExpTest() throws Exception { boolean pass = false; @@ -5463,7 +5544,7 @@ public void prodExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("prodExpExpTest failed"); + throw new Exception("prodExpExpTest failed"); } } @@ -5476,6 +5557,7 @@ public void prodExpExpTest() throws Exception { * p.quantity=5 */ @SetupMethod(name = "setupProductData") + @Test public void diffExpNumberTest() throws Exception { boolean pass = false; @@ -5519,7 +5601,7 @@ public void diffExpNumberTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("diffExpNumberTest failed"); + throw new Exception("diffExpNumberTest failed"); } } @@ -5532,6 +5614,7 @@ public void diffExpNumberTest() throws Exception { * p.quantity=5 */ @SetupMethod(name = "setupProductData") + @Test public void diffNumberExpTest() throws Exception { boolean pass = false; @@ -5574,7 +5657,7 @@ public void diffNumberExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("diffNumberExpTest failed"); + throw new Exception("diffNumberExpTest failed"); } } @@ -5587,6 +5670,7 @@ public void diffNumberExpTest() throws Exception { * p.quantity=5 */ @SetupMethod(name = "setupProductData") + @Test public void diffExpExpTest() throws Exception { boolean pass = false; @@ -5631,7 +5715,7 @@ public void diffExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("diffExpExpTest failed"); + throw new Exception("diffExpExpTest failed"); } } @@ -5644,6 +5728,7 @@ public void diffExpExpTest() throws Exception { * = 5 */ @SetupMethod(name = "setupProductData") + @Test public void quotExpNumTest() throws Exception { boolean pass = false; @@ -5684,7 +5769,7 @@ public void quotExpNumTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("quotExpNumTest failed"); + throw new Exception("quotExpNumTest failed"); } } @@ -5697,6 +5782,7 @@ public void quotExpNumTest() throws Exception { * = 5 */ @SetupMethod(name = "setupProductData") + @Test public void quotNumExpTest() throws Exception { boolean pass = false; @@ -5736,7 +5822,7 @@ public void quotNumExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("quotNumExpTest failed"); + throw new Exception("quotNumExpTest failed"); } } @@ -5749,6 +5835,7 @@ public void quotNumExpTest() throws Exception { * = 5 */ @SetupMethod(name = "setupProductData") + @Test public void quotExpExpTest() throws Exception { boolean pass = false; @@ -5790,7 +5877,7 @@ public void quotExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("quotExpExpTest failed"); + throw new Exception("quotExpExpTest failed"); } } @@ -5803,6 +5890,7 @@ public void quotExpExpTest() throws Exception { * p.quantity */ @SetupMethod(name = "setupProductData") + @Test public void modExpIntTest() throws Exception { boolean pass = false; @@ -5848,7 +5936,7 @@ public void modExpIntTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("modExpIntTest failed"); + throw new Exception("modExpIntTest failed"); } } @@ -5861,6 +5949,7 @@ public void modExpIntTest() throws Exception { * p.quantity */ @SetupMethod(name = "setupProductData") + @Test public void modExpExpTest() throws Exception { boolean pass = false; @@ -5906,7 +5995,7 @@ public void modExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("modExpExpTest failed"); + throw new Exception("modExpExpTest failed"); } } @@ -5919,6 +6008,7 @@ public void modExpExpTest() throws Exception { * p.quantity */ @SetupMethod(name = "setupProductData") + @Test public void modIntExpTest() throws Exception { boolean pass = false; @@ -5964,7 +6054,7 @@ public void modIntExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("modIntExpTest failed"); + throw new Exception("modIntExpTest failed"); } } @@ -5976,6 +6066,7 @@ public void modIntExpTest() throws Exception { * @test_Strategy: SELECT SQRT(p.quantity) From Product p where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void sqrt() throws Exception { boolean pass = false; @@ -6018,7 +6109,7 @@ public void sqrt() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sqrt test failed"); + throw new Exception("sqrt test failed"); } } @@ -6031,6 +6122,7 @@ public void sqrt() throws Exception { * p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void toLong() throws Exception { boolean pass = false; @@ -6073,7 +6165,7 @@ public void toLong() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toLong test failed"); + throw new Exception("toLong test failed"); } } @@ -6086,6 +6178,7 @@ public void toLong() throws Exception { * p.partNumber = 373767373 */ @SetupMethod(name = "setupProductData") + @Test public void toInteger() throws Exception { boolean pass = false; @@ -6127,7 +6220,7 @@ public void toInteger() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toInteger test failed"); + throw new Exception("toInteger test failed"); } } @@ -6139,6 +6232,7 @@ public void toInteger() throws Exception { * @test_Strategy: SELECT p.quantity *1/2 From Product p where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void toFloat() throws Exception { boolean pass = false; @@ -6181,7 +6275,7 @@ public void toFloat() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toFloat test failed"); + throw new Exception("toFloat test failed"); } } @@ -6195,6 +6289,7 @@ public void toFloat() throws Exception { * p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void toDouble() throws Exception { boolean pass = false; @@ -6235,7 +6330,7 @@ public void toDouble() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toDouble test failed"); + throw new Exception("toDouble test failed"); } } @@ -6248,6 +6343,7 @@ public void toDouble() throws Exception { * where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void toBigDecimal() throws Exception { final BigDecimal expectedResult = new BigDecimal("50.5"); boolean pass = false; @@ -6290,7 +6386,7 @@ public void toBigDecimal() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toBigDecimal test failed"); + throw new Exception("toBigDecimal test failed"); } } @@ -6303,6 +6399,7 @@ public void toBigDecimal() throws Exception { * From Product p where p.quantity = 5 */ @SetupMethod(name = "setupProductData") + @Test public void toBigInteger() throws Exception { boolean pass = false; @@ -6344,7 +6441,7 @@ public void toBigInteger() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toBigInteger test failed"); + throw new Exception("toBigInteger test failed"); } } @@ -6356,6 +6453,7 @@ public void toBigInteger() throws Exception { * @test_Strategy: SELECT ToString(p.id) From Product p where p.id ='1' */ @SetupMethod(name = "setupProductData") + @Test public void toStringTest() throws Exception { boolean pass = false; @@ -6395,7 +6493,7 @@ public void toStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("toStringTest test failed"); + throw new Exception("toStringTest test failed"); } } @@ -6407,6 +6505,7 @@ public void toStringTest() throws Exception { * @test_Strategy: SELECT p.quantity From Product p where 5 = p.quantity */ @SetupMethod(name = "setupProductData") + @Test public void literal() throws Exception { boolean pass = false; @@ -6447,7 +6546,7 @@ public void literal() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("literal test failed"); + throw new Exception("literal test failed"); } } @@ -6458,6 +6557,7 @@ public void literal() throws Exception { * * @test_Strategy: */ + @Test public void literalIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -6473,7 +6573,7 @@ public void literalIllegalArgumentExceptionTest() throws Exception { } if (!pass) { - throw new Fault("literalIllegalArgumentExceptionTest failed"); + throw new Exception("literalIllegalArgumentExceptionTest failed"); } } @@ -6491,6 +6591,7 @@ public void literalIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void parameter() throws Exception { boolean pass = false; @@ -6576,7 +6677,7 @@ public void parameter() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("parameter test failed"); + throw new Exception("parameter test failed"); } } @@ -6594,6 +6695,7 @@ public void parameter() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void parameterCaseSensitiveTest() throws Exception { boolean pass = false; @@ -6664,7 +6766,7 @@ public void parameterCaseSensitiveTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("parameterCaseSensitiveTest test failed"); + throw new Exception("parameterCaseSensitiveTest test failed"); } } @@ -6679,6 +6781,7 @@ public void parameterCaseSensitiveTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void criteriaBuilderValuesTest() throws Exception { boolean pass = false; @@ -6742,7 +6845,7 @@ public void criteriaBuilderValuesTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("criteriaBuilderValuesTest failed"); + throw new Exception("criteriaBuilderValuesTest failed"); } } @@ -6758,6 +6861,7 @@ public void criteriaBuilderValuesTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void criteriaBuilderIn1Test() throws Exception { boolean pass = false; @@ -6820,7 +6924,7 @@ public void criteriaBuilderIn1Test() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("criteriaBuilderIn1Test failed"); + throw new Exception("criteriaBuilderIn1Test failed"); } } @@ -6838,6 +6942,7 @@ public void criteriaBuilderIn1Test() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void criteriaBuilderIn2Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -6900,7 +7005,7 @@ public void criteriaBuilderIn2Test() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3) { - throw new Fault("criteriaBuilderIn2Test failed"); + throw new Exception("criteriaBuilderIn2Test failed"); } } @@ -6915,6 +7020,7 @@ public void criteriaBuilderIn2Test() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void criteriaBuilderInValueTest() throws Exception { boolean pass = false; @@ -6975,7 +7081,7 @@ public void criteriaBuilderInValueTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("criteriaBuilderInValueTest failed"); + throw new Exception("criteriaBuilderInValueTest failed"); } } @@ -6990,6 +7096,7 @@ public void criteriaBuilderInValueTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void expressionInObjectArrayTest() throws Exception { boolean pass = false; @@ -7034,7 +7141,7 @@ public void expressionInObjectArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("expressionInObjectArrayTest failed"); + throw new Exception("expressionInObjectArrayTest failed"); } } @@ -7048,6 +7155,7 @@ public void expressionInObjectArrayTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void expressionInExpressionArrayTest() throws Exception { boolean pass = false; @@ -7093,7 +7201,7 @@ public void expressionInExpressionArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("expressionInExpressionArrayTest failed"); + throw new Exception("expressionInExpressionArrayTest failed"); } } @@ -7108,6 +7216,7 @@ public void expressionInExpressionArrayTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void expressionInExpressionTest() throws Exception { boolean pass = false; @@ -7151,7 +7260,7 @@ public void expressionInExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("expressionInExpressionTest failed"); + throw new Exception("expressionInExpressionTest failed"); } } @@ -7166,6 +7275,7 @@ public void expressionInExpressionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void expressionInCollectionTest() throws Exception { boolean pass = false; @@ -7212,7 +7322,7 @@ public void expressionInCollectionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("expressionInCollectionTest failed"); + throw new Exception("expressionInCollectionTest failed"); } } @@ -7227,6 +7337,7 @@ public void expressionInCollectionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void parameterExpressionIsNullTest() throws Exception { boolean pass = false; @@ -7267,7 +7378,7 @@ public void parameterExpressionIsNullTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("parameterExpressionIsNullTest failed"); + throw new Exception("parameterExpressionIsNullTest failed"); } } @@ -7282,6 +7393,7 @@ public void parameterExpressionIsNullTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void parameterExpressionIsNotNullTest() throws Exception { boolean pass = false; @@ -7328,7 +7440,7 @@ public void parameterExpressionIsNotNullTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("parameterExpressionIsNotNullTest failed"); + throw new Exception("parameterExpressionIsNotNullTest failed"); } } @@ -7341,6 +7453,7 @@ public void parameterExpressionIsNotNullTest() throws Exception { * @test_Strategy: Select c fRoM Customer c where c.aliases IS EMPTY */ @SetupMethod(name = "setupAliasData") + @Test public void isEmpty() throws Exception { boolean pass = false; @@ -7384,7 +7497,7 @@ public void isEmpty() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isEmpty test failed"); + throw new Exception("isEmpty test failed"); } } @@ -7397,6 +7510,7 @@ public void isEmpty() throws Exception { * EMPTY */ @SetupMethod(name = "setupAliasData") + @Test public void isNotEmpty() throws Exception { boolean pass = false; @@ -7440,7 +7554,7 @@ public void isNotEmpty() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isNotEmpty test failed"); + throw new Exception("isNotEmpty test failed"); } } @@ -7452,6 +7566,7 @@ public void isNotEmpty() throws Exception { * @test_Strategy: Select size(c.aliases) from Customer c where c.id ="3" */ @SetupMethod(name = "setupAliasData") + @Test public void sizeCollectionTest() throws Exception { boolean pass = false; @@ -7486,7 +7601,7 @@ public void sizeCollectionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sizeCollectionTest failed"); + throw new Exception("sizeCollectionTest failed"); } } @@ -7498,6 +7613,7 @@ public void sizeCollectionTest() throws Exception { * @test_Strategy: Select size(c.aliases) fRoM Customer c where c.id ="3" */ @SetupMethod(name = "setupAliasData") + @Test public void sizeExpTest() throws Exception { boolean pass = false; @@ -7536,7 +7652,7 @@ public void sizeExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("sizeExpTest failed"); + throw new Exception("sizeExpTest failed"); } } @@ -7549,6 +7665,7 @@ public void sizeExpTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void isMember() throws Exception { boolean pass = false; @@ -7592,7 +7709,7 @@ public void isMember() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isMember test failed"); + throw new Exception("isMember test failed"); } } @@ -7607,6 +7724,7 @@ public void isMember() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void isNotMember() throws Exception { boolean pass = false; @@ -7651,7 +7769,7 @@ public void isNotMember() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isNotMember test failed"); + throw new Exception("isNotMember test failed"); } @@ -7669,6 +7787,7 @@ public void isNotMember() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void likeExpStringTest() throws Exception { boolean pass = false; @@ -7722,7 +7841,7 @@ public void likeExpStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("likeExpStringTest failed"); + throw new Exception("likeExpStringTest failed"); } } @@ -7739,6 +7858,7 @@ public void likeExpStringTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void likeExpExpTest() throws Exception { boolean pass = false; @@ -7792,7 +7912,7 @@ public void likeExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("likeExpExpTest failed"); + throw new Exception("likeExpExpTest failed"); } } @@ -7808,6 +7928,7 @@ public void likeExpExpTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void notLikeExpStringTest() throws Exception { boolean pass = false; @@ -7865,7 +7986,7 @@ public void notLikeExpStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notLikeExpStringTest failed"); + throw new Exception("notLikeExpStringTest failed"); } } @@ -7881,6 +8002,7 @@ public void notLikeExpStringTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void notLikeExpExpTest() throws Exception { boolean pass = false; @@ -7938,7 +8060,7 @@ public void notLikeExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notLikeExpExpTest failed"); + throw new Exception("notLikeExpExpTest failed"); } } @@ -7954,6 +8076,7 @@ public void notLikeExpExpTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void notLikeExpExpExpTest() throws Exception { boolean pass = false; @@ -8011,7 +8134,7 @@ public void notLikeExpExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notLikeExpExpExpTest failed"); + throw new Exception("notLikeExpExpExpTest failed"); } } @@ -8027,6 +8150,7 @@ public void notLikeExpExpExpTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void notLikeExpExpCharTest() throws Exception { boolean pass = false; @@ -8084,7 +8208,7 @@ public void notLikeExpExpCharTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notLikeExpExpCharTest failed"); + throw new Exception("notLikeExpExpCharTest failed"); } } @@ -8100,6 +8224,7 @@ public void notLikeExpExpCharTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void notLikeExpStringExpTest() throws Exception { boolean pass = false; @@ -8157,7 +8282,7 @@ public void notLikeExpStringExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notLikeExpStringExpTest failed"); + throw new Exception("notLikeExpStringExpTest failed"); } } @@ -8173,6 +8298,7 @@ public void notLikeExpStringExpTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void notLikeExpStringCharTest() throws Exception { boolean pass = false; @@ -8230,7 +8356,7 @@ public void notLikeExpStringCharTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("notLikeExpStringCharTest failed"); + throw new Exception("notLikeExpStringCharTest failed"); } } @@ -8247,6 +8373,7 @@ public void notLikeExpStringCharTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void concatExpStringTest() throws Exception { boolean pass = false; @@ -8297,7 +8424,7 @@ public void concatExpStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("concatExpStringTest failed"); + throw new Exception("concatExpStringTest failed"); } } @@ -8314,6 +8441,7 @@ public void concatExpStringTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void concatStringExpTest() throws Exception { boolean pass = false; @@ -8364,7 +8492,7 @@ public void concatStringExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("concatStringExpTest failed"); + throw new Exception("concatStringExpTest failed"); } } @@ -8381,6 +8509,7 @@ public void concatStringExpTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void concatExpExpTest() throws Exception { boolean pass = false; @@ -8438,7 +8567,7 @@ public void concatExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("concatExpExpTest failed"); + throw new Exception("concatExpExpTest failed"); } } @@ -8452,6 +8581,7 @@ public void concatExpExpTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void substringExpIntTest() throws Exception { boolean pass = false; @@ -8497,7 +8627,7 @@ public void substringExpIntTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("substringExpIntTest failed"); + throw new Exception("substringExpIntTest failed"); } } @@ -8511,6 +8641,7 @@ public void substringExpIntTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void substringExpExpTest() throws Exception { boolean pass = false; @@ -8557,7 +8688,7 @@ public void substringExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("substringExpExpTest failed"); + throw new Exception("substringExpExpTest failed"); } } @@ -8572,6 +8703,7 @@ public void substringExpExpTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void substringExpIntIntTest() throws Exception { boolean pass = false; @@ -8618,7 +8750,7 @@ public void substringExpIntIntTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("substringExpIntIntTest failed"); + throw new Exception("substringExpIntIntTest failed"); } } @@ -8633,6 +8765,7 @@ public void substringExpIntIntTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void substringExpExpExpTest() throws Exception { boolean pass = false; @@ -8679,7 +8812,7 @@ public void substringExpExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("substringExpExpExpTest failed"); + throw new Exception("substringExpExpExpTest failed"); } } @@ -8693,6 +8826,7 @@ public void substringExpExpExpTest() throws Exception { * * */ + @Test public void trimspecTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -8721,7 +8855,7 @@ public void trimspecTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass1 || !pass2) { - throw new Fault("trimspecTest failed"); + throw new Exception("trimspecTest failed"); } } @@ -8736,6 +8870,7 @@ public void trimspecTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void trimBothExpTest() throws Exception { boolean pass = false; final String expectedResult = "David R. Vincent"; @@ -8775,7 +8910,7 @@ public void trimBothExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("trimBothExpTest failed"); + throw new Exception("trimBothExpTest failed"); } } @@ -8791,6 +8926,7 @@ public void trimBothExpTest() throws Exception { * */ @SetupMethod(name = "setupTrimData") + @Test public void trimExpTest() throws Exception { boolean pass = false; final String expected = " David R. Vincent "; @@ -8842,7 +8978,7 @@ public void trimExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("trimExpTest failed"); + throw new Exception("trimExpTest failed"); } } @@ -8899,7 +9035,7 @@ public void trimExpTest() throws Exception { * * getEntityTransaction().commit(); * - * if (!pass) { throw new Fault("trimLeadingExpTest failed"); + * if (!pass) { throw new Exception("trimLeadingExpTest failed"); * * } } */ @@ -8914,6 +9050,7 @@ public void trimExpTest() throws Exception { * */ @SetupMethod(name = "setupTrimData") + @Test public void trimTrailingCharExpTest() throws Exception { boolean pass = false; final String expected = " David R. Vincent "; @@ -8966,7 +9103,7 @@ public void trimTrailingCharExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("trimTrailingCharExpTest failed"); + throw new Exception("trimTrailingCharExpTest failed"); } } @@ -8980,6 +9117,7 @@ public void trimTrailingCharExpTest() throws Exception { * M. Presley' */ @SetupMethod(name = "setupCustomerData") + @Test public void lower() throws Exception { final String expectedResult = "lisa m. presley"; boolean pass = false; @@ -9019,7 +9157,7 @@ public void lower() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("lower test failed"); + throw new Exception("lower test failed"); } @@ -9034,6 +9172,7 @@ public void lower() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void upper() throws Exception { final String expectedResult = "IRIS"; boolean pass = false; @@ -9076,7 +9215,7 @@ public void upper() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("upper test failed"); + throw new Exception("upper test failed"); } } @@ -9090,6 +9229,7 @@ public void upper() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void length() throws Exception { boolean pass = false; @@ -9135,7 +9275,7 @@ public void length() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("length test failed"); + throw new Exception("length test failed"); } } @@ -9149,6 +9289,7 @@ public void length() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void locateExpStringTest() throws Exception { boolean pass = false; @@ -9194,7 +9335,7 @@ public void locateExpStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("locateExpStringTest failed"); + throw new Exception("locateExpStringTest failed"); } } @@ -9208,6 +9349,7 @@ public void locateExpStringTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void locateExpExpTest() throws Exception { boolean pass = false; @@ -9253,7 +9395,7 @@ public void locateExpExpTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("locateExpExpTest failed"); + throw new Exception("locateExpExpTest failed"); } } @@ -9266,6 +9408,7 @@ public void locateExpExpTest() throws Exception { * @test_Strategy: SELECT current_date() From Product p where p.id = "1" */ @SetupMethod(name = "setupProductData") + @Test public void currentDate() throws Exception { boolean pass = false; @@ -9298,7 +9441,7 @@ public void currentDate() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("currentDate test failed"); + throw new Exception("currentDate test failed"); } } @@ -9310,6 +9453,7 @@ public void currentDate() throws Exception { * @test_Strategy: SELECT current_time() From Product p where p.id = "1" */ @SetupMethod(name = "setupProductData") + @Test public void currentTime() throws Exception { boolean pass = false; @@ -9342,7 +9486,7 @@ public void currentTime() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("currentTimes test failed"); + throw new Exception("currentTimes test failed"); } } @@ -9354,6 +9498,7 @@ public void currentTime() throws Exception { * @test_Strategy: SELECT current_timestamp() From Product p where p.id = "1" */ @SetupMethod(name = "setupProductData") + @Test public void currentTimestamp() throws Exception { boolean pass = false; @@ -9386,7 +9531,7 @@ public void currentTimestamp() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("currentTimestamp test failed"); + throw new Exception("currentTimestamp test failed"); } } @@ -9397,6 +9542,7 @@ public void currentTimestamp() throws Exception { * * @test_Strategy: */ + @Test public void createCriteriaDeleteTest() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); @@ -9414,7 +9560,7 @@ public void createCriteriaDeleteTest() throws Exception { } if (!pass) { - throw new Fault("createCriteriaDeleteTest test failed"); + throw new Exception("createCriteriaDeleteTest test failed"); } } @@ -9425,6 +9571,7 @@ public void createCriteriaDeleteTest() throws Exception { * * @test_Strategy: */ + @Test public void createCriteriaUpdateTest() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); @@ -9442,7 +9589,7 @@ public void createCriteriaUpdateTest() throws Exception { } if (!pass) { - throw new Fault("createCriteriaUpdateTest test failed"); + throw new Exception("createCriteriaUpdateTest test failed"); } } @@ -9455,6 +9602,7 @@ public void createCriteriaUpdateTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void expressionAliasTest() throws Exception { boolean pass = false; @@ -9482,7 +9630,7 @@ public void expressionAliasTest() throws Exception { } if (!pass) { - throw new Fault("expressionAliasTest failed"); + throw new Exception("expressionAliasTest failed"); } } @@ -9497,6 +9645,7 @@ public void expressionAliasTest() throws Exception { * */ @SetupMethod(name = "setupProductData") + @Test public void treatPathClassTest() throws Exception { boolean pass = false; @@ -9545,7 +9694,7 @@ public void treatPathClassTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("treatPathClassTest failed"); + throw new Exception("treatPathClassTest failed"); } } @@ -9559,6 +9708,7 @@ public void treatPathClassTest() throws Exception { * l.quantity > 5 */ @SetupMethod(name = "setupOrderData") + @Test public void joinOnExpressionTest() throws Exception { boolean pass = false; @@ -9595,11 +9745,11 @@ public void joinOnExpressionTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Caught exception: ", e); - throw new Fault("queryTest61 failed", e); + throw new Exception("queryTest61 failed", e); } if (!pass) - throw new Fault("joinOnExpressionTest failed"); + throw new Exception("joinOnExpressionTest failed"); } /* @@ -9611,6 +9761,7 @@ public void joinOnExpressionTest() throws Exception { * (l.quantity > 5 AND l.quantity < 9) */ @SetupMethod(name = "setupOrderData") + @Test public void joinOnPredicateArrayTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -9674,11 +9825,11 @@ public void joinOnPredicateArrayTest() throws Exception { getEntityTransaction().commit(); } catch (Exception e) { TestUtil.logErr("Caught exception: ", e); - throw new Fault("queryTest61 failed", e); + throw new Exception("queryTest61 failed", e); } if (!pass1 || !pass2 || !pass3) - throw new Fault("joinOnPredicateArrayTest failed"); + throw new Exception("joinOnPredicateArrayTest failed"); } /* @@ -9694,6 +9845,7 @@ public void joinOnPredicateArrayTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void nullifExpressionExpressionTest() throws Exception { boolean pass = false; @@ -9778,7 +9930,7 @@ public void nullifExpressionExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("nullifExpressionExpressionTest failed"); + throw new Exception("nullifExpressionExpressionTest failed"); } } @@ -9794,6 +9946,7 @@ public void nullifExpressionExpressionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void nullifExpressionObjectTest() throws Exception { boolean pass = false; @@ -9876,7 +10029,7 @@ public void nullifExpressionObjectTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("nullifExpressionObjectTest failed"); + throw new Exception("nullifExpressionObjectTest failed"); } } @@ -9891,6 +10044,7 @@ public void nullifExpressionObjectTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void locateExpressionExpressionExpressionTest() throws Exception { boolean pass = false; @@ -9943,7 +10097,7 @@ public void locateExpressionExpressionExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("locateExpressionExpressionExpressionTest failed"); + throw new Exception("locateExpressionExpressionExpressionTest failed"); } } @@ -9958,6 +10112,7 @@ public void locateExpressionExpressionExpressionTest() throws Exception { * */ @SetupMethod(name = "setupAliasOnlyData") + @Test public void locateExpressionStringIntTest() throws Exception { boolean pass = false; @@ -10008,7 +10163,7 @@ public void locateExpressionStringIntTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("locateExpressionExpressionExpressionTest failed"); + throw new Exception("locateExpressionExpressionExpressionTest failed"); } } @@ -10020,6 +10175,7 @@ public void locateExpressionStringIntTest() throws Exception { * * @test_Strategy: */ + @Test public void coalesceTest() throws Exception { boolean pass = false; @@ -10037,7 +10193,7 @@ public void coalesceTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("coalesceTest failed"); + throw new Exception("coalesceTest failed"); } } @@ -10055,6 +10211,7 @@ public void coalesceTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void selectMultiSelectTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -10171,7 +10328,7 @@ public void selectMultiSelectTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("selectMultiSelectTest test failed"); + throw new Exception("selectMultiSelectTest test failed"); } } @@ -10187,6 +10344,7 @@ public void selectMultiSelectTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void multiRootTest() throws Exception { boolean pass = true; @@ -10244,7 +10402,7 @@ public void multiRootTest() throws Exception { } if (!pass) { - throw new Fault("multiRootTest test failed"); + throw new Exception("multiRootTest test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaDelete/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaDelete/Client.java index 162dd4bd33..8734f8ba14 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaDelete/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaDelete/Client.java @@ -19,7 +19,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Properties; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.schema30.Product; @@ -38,15 +40,16 @@ public class Client extends Util { - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createProductData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("setup failed:", e); + throw new Exception("setup failed:", e); } } @@ -59,6 +62,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: DELETE FROM Product p */ + @Test public void fromClassTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -95,7 +99,7 @@ public void fromClassTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("fromClassTest failed"); + throw new Exception("fromClassTest failed"); } } @@ -106,6 +110,7 @@ public void fromClassTest() throws Exception { * * @test_Strategy: DELETE FROM Product p */ + @Test public void fromEntityTypeTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -148,7 +153,7 @@ public void fromEntityTypeTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("fromEntityTypeTest failed"); + throw new Exception("fromEntityTypeTest failed"); } } @@ -160,6 +165,7 @@ public void fromEntityTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void getRootTest() throws Exception { boolean pass = false; @@ -181,7 +187,7 @@ public void getRootTest() throws Exception { } if (!pass) { - throw new Fault("getRootTest failed"); + throw new Exception("getRootTest failed"); } } @@ -192,6 +198,7 @@ public void getRootTest() throws Exception { * * @test_Strategy: DELETE FROM Product p where p.id in (1,2,3) */ + @Test public void whereExpressionTest() throws Exception { boolean pass2 = false; boolean pass3 = true; @@ -272,7 +279,7 @@ public void whereExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("whereExpressionTest failed"); + throw new Exception("whereExpressionTest failed"); } } @@ -283,6 +290,7 @@ public void whereExpressionTest() throws Exception { * * @test_Strategy: DELETE FROM Product p where p.id in (2) */ + @Test public void wherePredicateArrayTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -357,7 +365,7 @@ public void wherePredicateArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("wherePredicateArrayTest failed"); + throw new Exception("wherePredicateArrayTest failed"); } } @@ -372,6 +380,7 @@ public void wherePredicateArrayTest() throws Exception { * PRODUCT hardprod where hardprod.id = '1'). * */ + @Test public void subquery() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -438,7 +447,7 @@ public void subquery() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("exists test failed"); + throw new Exception("exists test failed"); } } @@ -451,6 +460,7 @@ public void subquery() throws Exception { * FROM SoftwareProduct WHERE p.quantity > 100) * */ + @Test public void modifiedQueryTest() throws Exception { int passDeletedCount1 = 0; int passUnDeletedCount1 = 0; @@ -564,7 +574,7 @@ public void modifiedQueryTest() throws Exception { getEntityTransaction().commit(); if (passDeletedCount1 != 4 || passUnDeletedCount1 != 6 || passDeletedCount2 != 7 || passUnDeletedCount2 != 3) { - throw new Fault("modifiedQueryTest failed"); + throw new Exception("modifiedQueryTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/Client.java index cbc29a39bd..4e259721b0 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/Client.java @@ -30,6 +30,8 @@ import java.util.Properties; import java.util.Set; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.schema30.Address_; @@ -67,25 +69,25 @@ public class Client extends Util { - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } public void setupAData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupData"); try { - super.setup(args, p); + super.setup(); removeATestData(); createATestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -100,6 +102,7 @@ public void setupAData(String[] args, Properties p) throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void fromClass() throws Exception { boolean pass = false; final Double expectedTotalPrice = 4500.0D; @@ -144,7 +147,7 @@ public void fromClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("fromClass failed"); + throw new Exception("fromClass failed"); } } @@ -160,6 +163,7 @@ public void fromClass() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void fromEntityType() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -215,7 +219,7 @@ public void fromEntityType() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("fromEntityType failed"); + throw new Exception("fromEntityType failed"); } } @@ -231,6 +235,7 @@ public void fromEntityType() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void select() throws Exception { boolean pass = false; final Double expectedTotalPrice = 4500.0D; @@ -274,7 +279,7 @@ public void select() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("select test failed"); + throw new Exception("select test failed"); } } @@ -287,6 +292,7 @@ public void select() throws Exception { * @test_Strategy: */ @SetupMethod(name = "setupAliasData") + @Test public void selectIllegalArgumentException() throws Exception { boolean pass = false; @@ -314,7 +320,7 @@ public void selectIllegalArgumentException() throws Exception { } if (!pass) { - throw new Fault("selectIllegalArgumentException failed"); + throw new Exception("selectIllegalArgumentException failed"); } } @@ -329,6 +335,7 @@ public void selectIllegalArgumentException() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void multiselect() throws Exception { boolean pass = false; final int expectedResultSize = 20; @@ -368,7 +375,7 @@ public void multiselect() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("multiselect test failed"); + throw new Exception("multiselect test failed"); } } @@ -381,6 +388,7 @@ public void multiselect() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void multiselectListTest() throws Exception { boolean pass = false; final int expectedResultSize = 20; @@ -424,7 +432,7 @@ public void multiselectListTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("multiselectListTest failed"); + throw new Exception("multiselectListTest failed"); } } @@ -438,6 +446,7 @@ public void multiselectListTest() throws Exception { * */ @SetupMethod(name = "setupAliasData") + @Test public void multiselectIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -509,7 +518,7 @@ public void multiselectIllegalArgumentExceptionTest() throws Exception { } } if (!pass1 || !pass2 || !pass3) { - throw new Fault("multiselectIllegalArgumentExceptionTest failed"); + throw new Exception("multiselectIllegalArgumentExceptionTest failed"); } } @@ -525,6 +534,7 @@ public void multiselectIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void where() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManagerFactory().getCriteriaBuilder(); @@ -564,7 +574,7 @@ public void where() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("where test failed"); + throw new Exception("where test failed"); } } @@ -578,6 +588,7 @@ public void where() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void createQueryCriteriaUpdateTest() throws Exception { boolean pass = false; String expected = "foobar"; @@ -612,7 +623,7 @@ public void createQueryCriteriaUpdateTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createQueryCriteriaUpdateTest failed"); + throw new Exception("createQueryCriteriaUpdateTest failed"); } } @@ -627,6 +638,7 @@ public void createQueryCriteriaUpdateTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void createQueryCriteriaDeleteTest() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManagerFactory().getCriteriaBuilder(); @@ -657,7 +669,7 @@ public void createQueryCriteriaDeleteTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createQueryCriteriaDeleteTest failed"); + throw new Exception("createQueryCriteriaDeleteTest failed"); } } @@ -672,6 +684,7 @@ public void createQueryCriteriaDeleteTest() throws Exception { * results */ @SetupMethod(name = "setupOrderData") + @Test public void wherePredicateArrayTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -744,7 +757,7 @@ public void wherePredicateArrayTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("wherePredicateArrayTest failed"); + throw new Exception("wherePredicateArrayTest failed"); } } @@ -758,6 +771,7 @@ public void wherePredicateArrayTest() throws Exception { * Select c FROM Customer c where customer.name = 'Karen R. Tegan' */ @SetupMethod(name = "setupCustomerData") + @Test public void fromGetStringTest() throws Exception { boolean pass = false; @@ -792,7 +806,7 @@ public void fromGetStringTest() throws Exception { } if (!pass) { - throw new Fault("fromGetStringTest failed"); + throw new Exception("fromGetStringTest failed"); } } @@ -803,6 +817,7 @@ public void fromGetStringTest() throws Exception { * * @test_Strategy: Verify get(String) returns an exception for a basic type */ + @Test public void fromGetStringIllegalStateExceptionTest() throws Exception { boolean pass = false; @@ -826,7 +841,7 @@ public void fromGetStringIllegalStateExceptionTest() throws Exception { } if (!pass) { - throw new Fault("fromGetStringIllegalStateExceptionTest failed"); + throw new Exception("fromGetStringIllegalStateExceptionTest failed"); } } @@ -837,6 +852,7 @@ public void fromGetStringIllegalStateExceptionTest() throws Exception { * * @test_Strategy: Verify get(String) returns an exception for a basic type */ + @Test public void pathGetStringIllegalStateExceptionTest() throws Exception { boolean pass = false; @@ -861,7 +877,7 @@ public void pathGetStringIllegalStateExceptionTest() throws Exception { } if (!pass) { - throw new Fault("pathGetStringIllegalStateExceptionTest failed"); + throw new Exception("pathGetStringIllegalStateExceptionTest failed"); } } @@ -873,6 +889,7 @@ public void pathGetStringIllegalStateExceptionTest() throws Exception { * @test_Strategy: Verify get(String) returns an exception * */ + @Test public void fromGetStringIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -896,7 +913,7 @@ public void fromGetStringIllegalArgumentExceptionTest() throws Exception { } if (!pass) { - throw new Fault("fromGetStringIllegalArgumentExceptionTest failed"); + throw new Exception("fromGetStringIllegalArgumentExceptionTest failed"); } } @@ -908,6 +925,7 @@ public void fromGetStringIllegalArgumentExceptionTest() throws Exception { * @test_Strategy: Verify getModel() returns correct result. * */ + @Test public void fromGetModelTest() throws Exception { boolean pass = false; @@ -931,7 +949,7 @@ public void fromGetModelTest() throws Exception { } if (!pass) { - throw new Fault("fromGetModelTest failed"); + throw new Exception("fromGetModelTest failed"); } } @@ -944,6 +962,7 @@ public void fromGetModelTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void fromGetParentPathTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -993,7 +1012,7 @@ public void fromGetParentPathTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fromGetParentPathTest failed"); + throw new Exception("fromGetParentPathTest failed"); } } @@ -1006,6 +1025,7 @@ public void fromGetParentPathTest() throws Exception { * c GROUP BY c.country.code ORDER BY c.country.code" */ @SetupMethod(name = "setupCustomerData") + @Test public void groupBy() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1083,7 +1103,7 @@ public void groupBy() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("groupBy failed"); + throw new Exception("groupBy failed"); } } @@ -1099,6 +1119,7 @@ public void groupBy() throws Exception { * c.country.code, c.id" */ @SetupMethod(name = "setupCustomerData") + @Test public void groupByExpArrayTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1202,7 +1223,7 @@ public void groupByExpArrayTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("groupByExpArrayTest failed"); + throw new Exception("groupByExpArrayTest failed"); } } @@ -1219,6 +1240,7 @@ public void groupByExpArrayTest() throws Exception { * Customer c GROUP BY c.country.code, c.id ORDER BY c.country.code, c.id" */ @SetupMethod(name = "setupCustomerData") + @Test public void groupByListTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1338,7 +1360,7 @@ public void groupByListTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("groupByListTest failed"); + throw new Exception("groupByListTest failed"); } } @@ -1354,6 +1376,7 @@ public void groupByListTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void having() throws Exception { boolean pass = false; final Long expectedGBR = 2L; @@ -1406,7 +1429,7 @@ public void having() throws Exception { } if (!pass) { - throw new Fault("having failed"); + throw new Exception("having failed"); } } @@ -1421,6 +1444,7 @@ public void having() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void distinct() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1637,7 +1661,7 @@ public void distinct() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3) { - throw new Fault("distinct test failed"); + throw new Exception("distinct test failed"); } } @@ -1652,6 +1676,7 @@ public void distinct() throws Exception { * NULL ORDER BY c.work.zip ASC */ @SetupMethod(name = "setupCustomerData") + @Test public void orderBy() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1703,7 +1728,7 @@ public void orderBy() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("orderBy failed"); + throw new Exception("orderBy failed"); } } @@ -1714,6 +1739,7 @@ public void orderBy() throws Exception { * * @test_Strategy: */ + @Test public void pathGetIllegalArgumentException() throws Exception { boolean pass = false; @@ -1731,7 +1757,7 @@ public void pathGetIllegalArgumentException() throws Exception { } if (!pass) { - throw new Fault("pathGetIllegalArgumentException failed"); + throw new Exception("pathGetIllegalArgumentException failed"); } } @@ -1744,6 +1770,7 @@ public void pathGetIllegalArgumentException() throws Exception { * NULL ORDER BY c.work.zip ASC */ @SetupMethod(name = "setupCustomerData") + @Test public void orderReverseTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1798,7 +1825,7 @@ public void orderReverseTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("orderReverseTest failed"); + throw new Exception("orderReverseTest failed"); } } @@ -1811,6 +1838,7 @@ public void orderReverseTest() throws Exception { * NULL ORDER BY c.work.zip ASC */ @SetupMethod(name = "setupCustomerData") + @Test public void getOrderList() throws Exception { boolean pass = false; @@ -1843,7 +1871,7 @@ public void getOrderList() throws Exception { } if (!pass) { - throw new Fault("getOrderList failed"); + throw new Exception("getOrderList failed"); } } @@ -1857,6 +1885,7 @@ public void getOrderList() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void getParameters() throws Exception { boolean pass = false; final Double expectedTotalPrice = 4500.0D; @@ -1894,7 +1923,7 @@ public void getParameters() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getParameters test failed"); + throw new Exception("getParameters test failed"); } } @@ -1909,6 +1938,7 @@ public void getParameters() throws Exception { * CriteriaAPI and verify a IllegalStateException is thrown * */ + @Test public void executeUpdateIllegalStateException1Test() throws Exception { boolean pass = false; @@ -1939,7 +1969,7 @@ public void executeUpdateIllegalStateException1Test() throws Exception { } if (!pass) - throw new Fault("executeUpdateIllegalStateException1Test failed"); + throw new Exception("executeUpdateIllegalStateException1Test failed"); } /* @@ -1952,6 +1982,7 @@ public void executeUpdateIllegalStateException1Test() throws Exception { * Select p from Product p where TYPE(p) = HardwareProduct */ @SetupMethod(name = "setupProductData") + @Test public void typeTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -1993,7 +2024,7 @@ public void typeTest() throws Exception { } if (!pass) { - throw new Fault("typeTest failed"); + throw new Exception("typeTest failed"); } } @@ -2009,6 +2040,7 @@ public void typeTest() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void modifiedQueryTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -2082,7 +2114,7 @@ public void modifiedQueryTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("modifiedQueryTest test failed"); + throw new Exception("modifiedQueryTest test failed"); } } @@ -2097,6 +2129,7 @@ public void modifiedQueryTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void distinctNotSpecifiedTest() throws Exception { boolean pass = false; Integer expectedPKs[]; @@ -2161,7 +2194,7 @@ public void distinctNotSpecifiedTest() throws Exception { } if (!pass) - throw new Fault("distinctNotSpecifiedTest failed"); + throw new Exception("distinctNotSpecifiedTest failed"); } /* @@ -2174,6 +2207,7 @@ public void distinctNotSpecifiedTest() throws Exception { * */ @SetupMethod(name = "setupAData") + @Test public void DoubleOperandResultTypeTests() throws Exception { boolean pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8; pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = pass7 = pass8 = false; @@ -2380,7 +2414,7 @@ public void DoubleOperandResultTypeTests() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 || !pass8) - throw new Fault("DoubleOperandResultTypeTests failed"); + throw new Exception("DoubleOperandResultTypeTests failed"); } /* @@ -2392,6 +2426,7 @@ public void DoubleOperandResultTypeTests() throws Exception { * */ @SetupMethod(name = "setupAData") + @Test public void FloatOperandResultTypeTests() throws Exception { boolean pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8; pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = pass7 = pass8 = false; @@ -2590,7 +2625,7 @@ public void FloatOperandResultTypeTests() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 || !pass8) - throw new Fault("FloatOperandResultTypeTests failed"); + throw new Exception("FloatOperandResultTypeTests failed"); } /* @@ -2602,6 +2637,7 @@ public void FloatOperandResultTypeTests() throws Exception { * */ @SetupMethod(name = "setupAData") + @Test public void BigDecimalOperandResultTypeTests() throws Exception { boolean pass1, pass2, pass3, pass4; pass1 = pass2 = pass3 = pass4 = false; @@ -2708,7 +2744,7 @@ public void BigDecimalOperandResultTypeTests() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass1 || !pass2 || !pass3 || !pass4) - throw new Fault("BigDecimalOperandResultTypeTests failed"); + throw new Exception("BigDecimalOperandResultTypeTests failed"); } /* @@ -2720,6 +2756,7 @@ public void BigDecimalOperandResultTypeTests() throws Exception { * */ @SetupMethod(name = "setupAData") + @Test public void BigIntegerOperandResultTypeTests() throws Exception { boolean pass1, pass2, pass3; pass1 = pass2 = pass3 = false; @@ -2801,7 +2838,7 @@ public void BigIntegerOperandResultTypeTests() throws Exception { } if (!pass1 || !pass2 || !pass3) - throw new Fault("BigIntegerOperandResultTypeTests failed"); + throw new Exception("BigIntegerOperandResultTypeTests failed"); } /* @@ -2813,6 +2850,7 @@ public void BigIntegerOperandResultTypeTests() throws Exception { * */ @SetupMethod(name = "setupAData") + @Test public void LongOperandResultTypeTests() throws Exception { boolean pass1, pass2, pass3, pass4, pass5, pass6; pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = false; @@ -2964,7 +3002,7 @@ public void LongOperandResultTypeTests() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) - throw new Fault("LongOperandResultTypeTests failed"); + throw new Exception("LongOperandResultTypeTests failed"); } /* @@ -2977,6 +3015,7 @@ public void LongOperandResultTypeTests() throws Exception { * */ @SetupMethod(name = "setupAData") + @Test public void ShortOperandResultTypeTests() throws Exception { boolean pass1, pass2, pass3, pass4, pass5, pass6; pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = false; @@ -3127,7 +3166,7 @@ public void ShortOperandResultTypeTests() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) - throw new Fault("ShortOperandResultTypeTests failed"); + throw new Exception("ShortOperandResultTypeTests failed"); } /* @@ -3139,6 +3178,7 @@ public void ShortOperandResultTypeTests() throws Exception { * d.lastNameEmployees WHERE d.id = 1 */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void resultContainsFetchReference() throws Exception { boolean pass = false; @@ -3181,7 +3221,7 @@ public void resultContainsFetchReference() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("resultContainsFetchReference test failed"); + throw new Exception("resultContainsFetchReference test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaUpdate/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaUpdate/Client.java index ebbf617b6a..61aa9f11bc 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaUpdate/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaUpdate/Client.java @@ -18,7 +18,9 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Properties; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.schema30.Product; @@ -40,15 +42,16 @@ public class Client extends Util { public Client() { } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createProductData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -62,7 +65,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: UPDATE Product SET QUANTITY = 0 * */ - + @Test public void fromClassGetRootSetStringObjectTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -122,7 +125,7 @@ public void fromClassGetRootSetStringObjectTest() throws Exception { } getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("fromClassGetRootSetStringObjectTest failed"); + throw new Exception("fromClassGetRootSetStringObjectTest failed"); } } @@ -133,6 +136,7 @@ public void fromClassGetRootSetStringObjectTest() throws Exception { * * @test_Strategy: UPDATE Product SET QUANTITY = 0 */ + @Test public void fromEntityTypeSetStringObjectTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -191,7 +195,7 @@ public void fromEntityTypeSetStringObjectTest() throws Exception { } getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("fromEntityTypeSetStringObjectTest failed"); + throw new Exception("fromEntityTypeSetStringObjectTest failed"); } } @@ -202,6 +206,7 @@ public void fromEntityTypeSetStringObjectTest() throws Exception { * * @test_Strategy: UPDATE Product p SET p.quantity = 0 WHERE p.id in (1,2,3) */ + @Test public void whereExpressionTest() throws Exception { boolean pass2 = false; boolean pass3 = true; @@ -289,7 +294,7 @@ public void whereExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("whereExpressionTest failed"); + throw new Exception("whereExpressionTest failed"); } } @@ -301,6 +306,7 @@ public void whereExpressionTest() throws Exception { * * @test_Strategy: UPDATE Product p SET p.quantity = 0 WHERE p.id in (2) */ + @Test public void wherePredicateArrayTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -387,7 +393,7 @@ public void wherePredicateArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("wherePredicateArrayTest failed"); + throw new Exception("wherePredicateArrayTest failed"); } } @@ -399,7 +405,7 @@ public void wherePredicateArrayTest() throws Exception { * @test_Strategy: UPDATE Product SET QUANTITY = 0 * */ - + @Test public void setSingularAttributeObjectTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -463,7 +469,7 @@ public void setSingularAttributeObjectTest() throws Exception { } getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("setSingularAttributeObjectTest failed"); + throw new Exception("setSingularAttributeObjectTest failed"); } } @@ -475,7 +481,7 @@ public void setSingularAttributeObjectTest() throws Exception { * @test_Strategy: UPDATE Product p SET p.quantity = prod(p.quantity,0) * */ - + @Test public void setSingularAttributeExpressionTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -541,7 +547,7 @@ public void setSingularAttributeExpressionTest() throws Exception { } getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("setSingularAttributeExpressionTest failed"); + throw new Exception("setSingularAttributeExpressionTest failed"); } } @@ -553,7 +559,7 @@ public void setSingularAttributeExpressionTest() throws Exception { * @test_Strategy: UPDATE Product SET QUANTITY = 0 * */ - + @Test public void setPathObjectTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -614,7 +620,7 @@ public void setPathObjectTest() throws Exception { } getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("setPathObjectTest failed"); + throw new Exception("setPathObjectTest failed"); } } @@ -626,7 +632,7 @@ public void setPathObjectTest() throws Exception { * @test_Strategy: UPDATE Product p SET p.quantity = prod(p.quantity,0) * */ - + @Test public void setPathExpressionTest() throws Exception { boolean pass1 = false; boolean pass2 = true; @@ -686,7 +692,7 @@ public void setPathExpressionTest() throws Exception { } getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("setPathExpressionTest failed"); + throw new Exception("setPathExpressionTest failed"); } } @@ -701,6 +707,7 @@ public void setPathExpressionTest() throws Exception { * hardProd From PRODUCT hardprod where hardprod.id = '1'). * */ + @Test public void subquery() throws Exception { boolean pass = false; @@ -756,7 +763,7 @@ public void subquery() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("exists test failed"); + throw new Exception("exists test failed"); } } @@ -770,6 +777,7 @@ public void subquery() throws Exception { * p.quantity > 100) * */ + @Test public void modifiedQueryTest() throws Exception { int passModifiedCount1 = 0; int passUnModifiedCount1 = 0; @@ -884,7 +892,7 @@ public void modifiedQueryTest() throws Exception { getEntityTransaction().commit(); if (passModifiedCount1 != 4 || passUnModifiedCount1 != 6 || passModifiedCount2 != 7 || passUnModifiedCount2 != 3) { - throw new Fault("modifiedQueryTest failed"); + throw new Exception("modifiedQueryTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/Client.java index f7225abcb9..7641458c71 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/Client.java @@ -18,7 +18,9 @@ import java.util.ArrayList; import java.util.List; -import java.util.Properties; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -50,14 +52,15 @@ public class Client extends Util { /* Test setup */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -72,6 +75,7 @@ public void setup(String[] args, Properties p) throws Exception { * SELECT c FROM Customer c JOIN c.work o WHERE (o.id in (4)) */ @SetupMethod(name = "setupCustomerData") + @Test public void joinStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -106,7 +110,7 @@ public void joinStringTest() throws Exception { } if (!pass) { - throw new Fault("joinStringTest failed"); + throw new Exception("joinStringTest failed"); } } @@ -121,6 +125,7 @@ public void joinStringTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.work o WHERE (o.id in (4)) */ @SetupMethod(name = "setupCustomerData") + @Test public void joinStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -155,7 +160,7 @@ public void joinStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinStringJoinTypeTest failed"); + throw new Exception("joinStringJoinTypeTest failed"); } } @@ -167,6 +172,7 @@ public void joinStringJoinTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void joinStringIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -218,7 +224,7 @@ public void joinStringIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinStringIllegalArgumentExceptionTest failed"); + throw new Exception("joinStringIllegalArgumentExceptionTest failed"); } } @@ -233,6 +239,7 @@ public void joinStringIllegalArgumentExceptionTest() throws Exception { * SELECT c FROM Customer c JOIN c.work o WHERE (o.id in (4)) */ @SetupMethod(name = "setupCustomerData") + @Test public void joinSingularAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -267,7 +274,7 @@ public void joinSingularAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinSingularAttributeTest failed"); + throw new Exception("joinSingularAttributeTest failed"); } } @@ -282,6 +289,7 @@ public void joinSingularAttributeTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.work o WHERE (o.id in (4)) */ @SetupMethod(name = "setupCustomerData") + @Test public void joinSingularAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -317,7 +325,7 @@ public void joinSingularAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSingularAttributeJoinTypeTest failed"); + throw new Exception("joinSingularAttributeJoinTypeTest failed"); } } @@ -332,6 +340,7 @@ public void joinSingularAttributeJoinTypeTest() throws Exception { * SELECT c FROM Customer c JOIN c.orders o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -364,7 +373,7 @@ public void joinCollectionAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionAttributeTest failed"); + throw new Exception("joinCollectionAttributeTest failed"); } } @@ -379,6 +388,7 @@ public void joinCollectionAttributeTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.orders o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -412,7 +422,7 @@ public void joinCollectionAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionAttributeJoinTypeTest failed"); + throw new Exception("joinCollectionAttributeJoinTypeTest failed"); } } @@ -427,6 +437,7 @@ public void joinCollectionAttributeJoinTypeTest() throws Exception { * SELECT c FROM Customer c JOIN c.orders o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -459,7 +470,7 @@ public void joinCollectionStringTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionStringTest failed"); + throw new Exception("joinCollectionStringTest failed"); } } @@ -474,6 +485,7 @@ public void joinCollectionStringTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.orders o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -507,7 +519,7 @@ public void joinCollectionStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionStringJoinTypeTest failed"); + throw new Exception("joinCollectionStringJoinTypeTest failed"); } } @@ -519,6 +531,7 @@ public void joinCollectionStringJoinTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void joinCollectionIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -570,7 +583,7 @@ public void joinCollectionIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinCollectionIllegalArgumentExceptionTest failed"); + throw new Exception("joinCollectionIllegalArgumentExceptionTest failed"); } } @@ -585,6 +598,7 @@ public void joinCollectionIllegalArgumentExceptionTest() throws Exception { * SELECT c FROM Customer c JOIN c.orders2 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -617,7 +631,7 @@ public void joinSetAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetAttributeTest failed"); + throw new Exception("joinSetAttributeTest failed"); } } @@ -632,6 +646,7 @@ public void joinSetAttributeTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.orders2 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -665,7 +680,7 @@ public void joinSetAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetAttributeJoinTypeTest failed"); + throw new Exception("joinSetAttributeJoinTypeTest failed"); } } @@ -680,6 +695,7 @@ public void joinSetAttributeJoinTypeTest() throws Exception { * SELECT c FROM Customer c JOIN c.orders2 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -712,7 +728,7 @@ public void joinSetStringTest() throws Exception { } if (!pass) { - throw new Fault("joinSetStringTest failed"); + throw new Exception("joinSetStringTest failed"); } } @@ -727,6 +743,7 @@ public void joinSetStringTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.orders o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -760,7 +777,7 @@ public void joinSetStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetStringJoinTypeTest failed"); + throw new Exception("joinSetStringJoinTypeTest failed"); } } @@ -772,6 +789,7 @@ public void joinSetStringJoinTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void joinSetIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -821,7 +839,7 @@ public void joinSetIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinSetIllegalArgumentExceptionTest failed"); + throw new Exception("joinSetIllegalArgumentExceptionTest failed"); } } @@ -836,6 +854,7 @@ public void joinSetIllegalArgumentExceptionTest() throws Exception { * SELECT c FROM Customer c JOIN c.orders3 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -868,7 +887,7 @@ public void joinListAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinListAttributeTest failed"); + throw new Exception("joinListAttributeTest failed"); } } @@ -883,6 +902,7 @@ public void joinListAttributeTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.orders3 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -916,7 +936,7 @@ public void joinListAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinListAttributeJoinTypeTest failed"); + throw new Exception("joinListAttributeJoinTypeTest failed"); } } @@ -927,6 +947,7 @@ public void joinListAttributeJoinTypeTest() throws Exception { * * @test_Strategy: */ + @Test public void joinListIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -977,7 +998,7 @@ public void joinListIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinListIllegalArgumentExceptionTest failed"); + throw new Exception("joinListIllegalArgumentExceptionTest failed"); } } @@ -992,6 +1013,7 @@ public void joinListIllegalArgumentExceptionTest() throws Exception { * SELECT c FROM Customer c JOIN c.orders3 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1024,7 +1046,7 @@ public void joinListStringTest() throws Exception { } if (!pass) { - throw new Fault("joinListStringTest failed"); + throw new Exception("joinListStringTest failed"); } } @@ -1039,6 +1061,7 @@ public void joinListStringTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.orders3 o WHERE (o.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1072,7 +1095,7 @@ public void joinListStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinListStringJoinTypeTest failed"); + throw new Exception("joinListStringJoinTypeTest failed"); } } @@ -1088,6 +1111,7 @@ public void joinListStringJoinTypeTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1122,7 +1146,7 @@ public void joinMapAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapAttributeTest failed"); + throw new Exception("joinMapAttributeTest failed"); } } @@ -1139,6 +1163,7 @@ public void joinMapAttributeTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1172,7 +1197,7 @@ public void joinMapAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapAttributeJoinTypeTest failed"); + throw new Exception("joinMapAttributeJoinTypeTest failed"); } } @@ -1189,6 +1214,7 @@ public void joinMapAttributeJoinTypeTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapStringTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -1239,7 +1265,7 @@ public void joinMapStringTest() throws Exception { } if (!pass) { - throw new Fault("joinMapStringTest failed"); + throw new Exception("joinMapStringTest failed"); } } @@ -1255,6 +1281,7 @@ public void joinMapStringTest() throws Exception { * d.lastNameEmployees e WHERE (e.id = 1) */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapStringJoinTypeTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -1305,7 +1332,7 @@ public void joinMapStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapStringJoinTypeTest failed"); + throw new Exception("joinMapStringJoinTypeTest failed"); } } @@ -1316,6 +1343,7 @@ public void joinMapStringJoinTypeTest() throws Exception { * * @test_Strategy: */ + @Test public void joinMapIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1366,7 +1394,7 @@ public void joinMapIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinMapIllegalArgumentExceptionTest failed"); + throw new Exception("joinMapIllegalArgumentExceptionTest failed"); } } @@ -1377,6 +1405,7 @@ public void joinMapIllegalArgumentExceptionTest() throws Exception { * * @test_Strategy: */ + @Test public void fromGetCorrelationParentIllegalStateExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1408,7 +1437,7 @@ public void fromGetCorrelationParentIllegalStateExceptionTest() throws Exception } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "fromGetCorrelationParentIllegalStateExceptionTest failed"); } } @@ -1421,6 +1450,7 @@ public void fromGetCorrelationParentIllegalStateExceptionTest() throws Exception * @test_Strategy: */ @SetupMethod(name = "setupCustomerData") + @Test public void fromGetCorrelationParentTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1488,7 +1518,7 @@ public void fromGetCorrelationParentTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("fromGetCorrelationParentTest failed"); + throw new Exception("fromGetCorrelationParentTest failed"); } } @@ -1502,7 +1532,7 @@ public void fromGetCorrelationParentTest() throws Exception { * SELECT d.lastNameEmployees FROM DEPARTMENT d WHERE d.ID = 1 */ @SetupMethod(name = "setupDepartmentEmployeeData") - + @Test public void fromGetMapAttributeTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -1550,7 +1580,7 @@ public void fromGetMapAttributeTest() throws Exception { } if (!pass) { - throw new Fault("fromGetMapAttributeTest failed"); + throw new Exception("fromGetMapAttributeTest failed"); } } @@ -1564,6 +1594,7 @@ public void fromGetMapAttributeTest() throws Exception { * SELECT d.lastNameEmployees FROM DEPARTMENT d WHERE d.ID = 1 */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void pathGetMapAttributeTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -1612,7 +1643,7 @@ public void pathGetMapAttributeTest() throws Exception { } if (!pass) { - throw new Fault("pathGetMapAttributeTest failed"); + throw new Exception("pathGetMapAttributeTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/Client.java index 0954348200..3a1abb3fbc 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -19,9 +19,11 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.Set; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.schema30.CreditCard; @@ -56,14 +58,15 @@ public class Client extends Util { /* Test setup */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -79,6 +82,7 @@ public void setup(String[] args, Properties p) throws Exception { * 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinStringTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -162,7 +166,7 @@ public void joinStringTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("joinStringTest failed"); + throw new Exception("joinStringTest failed"); } } @@ -179,6 +183,7 @@ public void joinStringTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void joinStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -214,7 +219,7 @@ public void joinStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinStringJoinTypeTest failed"); + throw new Exception("joinStringJoinTypeTest failed"); } } @@ -226,6 +231,7 @@ public void joinStringJoinTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void joinStringIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -279,7 +285,7 @@ public void joinStringIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinStringIllegalArgumentExceptionTest failed"); + throw new Exception("joinStringIllegalArgumentExceptionTest failed"); } } @@ -294,6 +300,7 @@ public void joinStringIllegalArgumentExceptionTest() throws Exception { * SELECT c FROM Customer c JOIN c.work o WHERE (o.id in (4)) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSingularAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -329,7 +336,7 @@ public void joinSingularAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinSingularAttributeTest failed"); + throw new Exception("joinSingularAttributeTest failed"); } } @@ -345,6 +352,7 @@ public void joinSingularAttributeTest() throws Exception { * SELECT c FROM Customer c INNER JOIN c.work o WHERE (o.id in (4)) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSingularAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -381,7 +389,7 @@ public void joinSingularAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSingularAttributeJoinTypeTest failed"); + throw new Exception("joinSingularAttributeJoinTypeTest failed"); } } @@ -398,6 +406,7 @@ public void joinSingularAttributeJoinTypeTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionAttributeTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -443,7 +452,7 @@ public void joinCollectionAttributeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinCollectionAttributeTest failed"); + throw new Exception("joinCollectionAttributeTest failed"); } } @@ -460,6 +469,7 @@ public void joinCollectionAttributeTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -495,7 +505,7 @@ public void joinCollectionAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionAttributeJoinTypeTest failed"); + throw new Exception("joinCollectionAttributeJoinTypeTest failed"); } } @@ -512,6 +522,7 @@ public void joinCollectionAttributeJoinTypeTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -553,7 +564,7 @@ public void joinCollectionStringTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionStringTest failed"); + throw new Exception("joinCollectionStringTest failed"); } } @@ -569,6 +580,7 @@ public void joinCollectionStringTest() throws Exception { * (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinCollectionStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -603,7 +615,7 @@ public void joinCollectionStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionStringJoinTypeTest failed"); + throw new Exception("joinCollectionStringJoinTypeTest failed"); } } @@ -615,6 +627,7 @@ public void joinCollectionStringJoinTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void joinCollectionIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -668,7 +681,7 @@ public void joinCollectionIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinCollectionIllegalArgumentExceptionTest failed"); + throw new Exception("joinCollectionIllegalArgumentExceptionTest failed"); } } @@ -685,6 +698,7 @@ public void joinCollectionIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -718,7 +732,7 @@ public void joinSetAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetAttributeTest failed"); + throw new Exception("joinSetAttributeTest failed"); } } @@ -734,6 +748,7 @@ public void joinSetAttributeTest() throws Exception { * (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -768,7 +783,7 @@ public void joinSetAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetAttributeJoinTypeTest failed"); + throw new Exception("joinSetAttributeJoinTypeTest failed"); } } @@ -784,6 +799,7 @@ public void joinSetAttributeJoinTypeTest() throws Exception { * = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -817,7 +833,7 @@ public void joinSetStringTest() throws Exception { } if (!pass) { - throw new Fault("joinSetStringTest failed"); + throw new Exception("joinSetStringTest failed"); } } @@ -833,6 +849,7 @@ public void joinSetStringTest() throws Exception { * (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinSetStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -867,7 +884,7 @@ public void joinSetStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetStringJoinTypeTest failed"); + throw new Exception("joinSetStringJoinTypeTest failed"); } } @@ -880,6 +897,7 @@ public void joinSetStringJoinTypeTest() throws Exception { * @test_Strategy: * */ + @Test public void joinSetIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -931,7 +949,7 @@ public void joinSetIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinSetIllegalArgumentExceptionTest failed"); + throw new Exception("joinSetIllegalArgumentExceptionTest failed"); } } @@ -947,6 +965,7 @@ public void joinSetIllegalArgumentExceptionTest() throws Exception { * (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -987,7 +1006,7 @@ public void joinListAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinListAttributeTest failed"); + throw new Exception("joinListAttributeTest failed"); } } @@ -1003,6 +1022,7 @@ public void joinListAttributeTest() throws Exception { * where (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1037,7 +1057,7 @@ public void joinListAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinListAttributeJoinTypeTest failed"); + throw new Exception("joinListAttributeJoinTypeTest failed"); } } @@ -1048,6 +1068,7 @@ public void joinListAttributeJoinTypeTest() throws Exception { * * @test_Strategy: */ + @Test public void joinListIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1100,7 +1121,7 @@ public void joinListIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinListIllegalArgumentExceptionTest failed"); + throw new Exception("joinListIllegalArgumentExceptionTest failed"); } } @@ -1116,6 +1137,7 @@ public void joinListIllegalArgumentExceptionTest() throws Exception { * (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListStringTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1157,7 +1179,7 @@ public void joinListStringTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinListStringTest failed"); + throw new Exception("joinListStringTest failed"); } } @@ -1173,6 +1195,7 @@ public void joinListStringTest() throws Exception { * where (l.id = 1) */ @SetupMethod(name = "setupOrderData") + @Test public void joinListStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1207,7 +1230,7 @@ public void joinListStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinListStringJoinTypeTest failed"); + throw new Exception("joinListStringJoinTypeTest failed"); } } @@ -1225,6 +1248,7 @@ public void joinListStringJoinTypeTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapAttributeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1270,7 +1294,7 @@ public void joinMapAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapAttributeTest failed"); + throw new Exception("joinMapAttributeTest failed"); } } @@ -1287,6 +1311,7 @@ public void joinMapAttributeTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapAttributeJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1324,7 +1349,7 @@ public void joinMapAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapAttributeJoinTypeTest failed"); + throw new Exception("joinMapAttributeJoinTypeTest failed"); } } @@ -1341,6 +1366,7 @@ public void joinMapAttributeJoinTypeTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapStringTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1385,7 +1411,7 @@ public void joinMapStringTest() throws Exception { } if (!pass) { - throw new Fault("joinMapStringTest failed"); + throw new Exception("joinMapStringTest failed"); } } @@ -1402,6 +1428,7 @@ public void joinMapStringTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void joinMapStringJoinTypeTest() throws Exception { boolean pass = false; String expectedPKs[]; @@ -1439,7 +1466,7 @@ public void joinMapStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapStringJoinTypeTest failed"); + throw new Exception("joinMapStringJoinTypeTest failed"); } } @@ -1450,6 +1477,7 @@ public void joinMapStringJoinTypeTest() throws Exception { * * @test_Strategy: */ + @Test public void joinMapIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1505,7 +1533,7 @@ public void joinMapIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinMapIllegalArgumentExceptionTest failed"); + throw new Exception("joinMapIllegalArgumentExceptionTest failed"); } } @@ -1523,6 +1551,7 @@ public void joinMapIllegalArgumentExceptionTest() throws Exception { * */ @SetupMethod(name = "setupOrderData") + @Test public void pluralJoinTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1592,7 +1621,7 @@ public void pluralJoinTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("pluralJoinTest failed"); + throw new Exception("pluralJoinTest failed"); } } @@ -1605,6 +1634,7 @@ public void pluralJoinTest() throws Exception { * the results were accurately returned. */ @SetupMethod(name = "setupOrderData") + @Test public void pluralJoinOnExpressionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1650,7 +1680,7 @@ public void pluralJoinOnExpressionTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("pluralJoinOnExpressionTest failed"); + throw new Exception("pluralJoinOnExpressionTest failed"); } } @@ -1663,6 +1693,7 @@ public void pluralJoinOnExpressionTest() throws Exception { * the results were accurately returned. */ @SetupMethod(name = "setupOrderData") + @Test public void pluralJoinOnPredicateArrayTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1708,7 +1739,7 @@ public void pluralJoinOnPredicateArrayTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("pluralJoinOnPredicateArrayTest failed"); + throw new Exception("pluralJoinOnPredicateArrayTest failed"); } } @@ -1721,6 +1752,7 @@ public void pluralJoinOnPredicateArrayTest() throws Exception { * o.ID) where (l.QUANTITY > 5)) */ @SetupMethod(name = "setupOrderData") + @Test public void collectionJoinOnExpressionTest() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); @@ -1756,7 +1788,7 @@ public void collectionJoinOnExpressionTest() throws Exception { } if (!pass) - throw new Fault("collectionJoinOnExpressionTest failed"); + throw new Exception("collectionJoinOnExpressionTest failed"); } /* @@ -1768,6 +1800,7 @@ public void collectionJoinOnExpressionTest() throws Exception { * o.ID) where ((l.QUANTITY > 5) AND (l.QUANTITY < 8)) */ @SetupMethod(name = "setupOrderData") + @Test public void collectionJoinOnPredicateArrayTest() throws Exception { boolean pass = false; @@ -1804,7 +1837,7 @@ public void collectionJoinOnPredicateArrayTest() throws Exception { } if (!pass) - throw new Fault("collectionJoinOnPredicateArrayTest failed"); + throw new Exception("collectionJoinOnPredicateArrayTest failed"); } /* @@ -1816,6 +1849,7 @@ public void collectionJoinOnPredicateArrayTest() throws Exception { * o.ID) where (l.QUANTITY > 5) */ @SetupMethod(name = "setupOrderData") + @Test public void listJoinOnExpressionTest() throws Exception { boolean pass = false; @@ -1852,7 +1886,7 @@ public void listJoinOnExpressionTest() throws Exception { } if (!pass) - throw new Fault("listJoinOnExpressionTest failed"); + throw new Exception("listJoinOnExpressionTest failed"); } /* @@ -1864,6 +1898,7 @@ public void listJoinOnExpressionTest() throws Exception { * o.ID) where ((l.QUANTITY > 5) AND (l.QUANTITY < 8)) */ @SetupMethod(name = "setupOrderData") + @Test public void listJoinOnPredicateArrayTest() throws Exception { boolean pass = false; @@ -1900,7 +1935,7 @@ public void listJoinOnPredicateArrayTest() throws Exception { } if (!pass) - throw new Fault("listJoinOnPredicateArrayTest failed"); + throw new Exception("listJoinOnPredicateArrayTest failed"); } /* @@ -1912,6 +1947,7 @@ public void listJoinOnPredicateArrayTest() throws Exception { * o.ID) where (l.QUANTITY > 5) */ @SetupMethod(name = "setupOrderData") + @Test public void setJoinOnExpressionTest() throws Exception { boolean pass = false; @@ -1948,7 +1984,7 @@ public void setJoinOnExpressionTest() throws Exception { } if (!pass) - throw new Fault("setJoinOnExpressionTest failed"); + throw new Exception("setJoinOnExpressionTest failed"); } /* @@ -1960,6 +1996,7 @@ public void setJoinOnExpressionTest() throws Exception { * o.ID) where ((l.QUANTITY > 5) AND (l.QUANTITY < 8)) */ @SetupMethod(name = "setupOrderData") + @Test public void setJoinOnPredicateArrayTest() throws Exception { boolean pass = false; @@ -1996,7 +2033,7 @@ public void setJoinOnPredicateArrayTest() throws Exception { } if (!pass) - throw new Fault("setJoinOnPredicateArrayTest failed"); + throw new Exception("setJoinOnPredicateArrayTest failed"); } /* @@ -2011,6 +2048,7 @@ public void setJoinOnPredicateArrayTest() throws Exception { * */ @SetupMethod(name = "setupDepartmentEmployeeData") + @Test public void mapJoinValueTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -2073,7 +2111,7 @@ public void mapJoinValueTest() throws Exception { } if (!pass) { - throw new Fault("mapJoinValueTest failed"); + throw new Exception("mapJoinValueTest failed"); } } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/Client.java index a87a66a212..b824838304 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/Client.java @@ -17,7 +17,6 @@ package com.sun.ts.tests.jpa.core.criteriaapi.Root; import java.util.List; -import java.util.Properties; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -45,14 +44,14 @@ public class Client extends Util { /* Test setup */ - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -101,7 +100,7 @@ public void joinStringTest() throws Exception { } if (!pass) { - throw new Fault("joinStringTest failed"); + throw new Exception("joinStringTest failed"); } } @@ -150,7 +149,7 @@ public void joinStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinStringJoinTypeTest failed"); + throw new Exception("joinStringJoinTypeTest failed"); } } @@ -213,7 +212,7 @@ public void joinStringIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinStringIllegalArgumentExceptionTest failed"); + throw new Exception("joinStringIllegalArgumentExceptionTest failed"); } } @@ -262,7 +261,7 @@ public void joinSingularAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinSingularAttributeTest failed"); + throw new Exception("joinSingularAttributeTest failed"); } } @@ -312,7 +311,7 @@ public void joinSingularAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSingularAttributeJoinTypeTest failed"); + throw new Exception("joinSingularAttributeJoinTypeTest failed"); } } @@ -359,7 +358,7 @@ public void joinCollectionAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionAttributeTest failed"); + throw new Exception("joinCollectionAttributeTest failed"); } } @@ -407,7 +406,7 @@ public void joinCollectionAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionAttributeJoinTypeTest failed"); + throw new Exception("joinCollectionAttributeJoinTypeTest failed"); } } @@ -454,7 +453,7 @@ public void joinCollectionStringTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionStringTest failed"); + throw new Exception("joinCollectionStringTest failed"); } } @@ -502,7 +501,7 @@ public void joinCollectionStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinCollectionStringJoinTypeTest failed"); + throw new Exception("joinCollectionStringJoinTypeTest failed"); } } @@ -565,7 +564,7 @@ public void joinCollectionIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinCollectionIllegalArgumentExceptionTest failed"); + throw new Exception("joinCollectionIllegalArgumentExceptionTest failed"); } } @@ -612,7 +611,7 @@ public void joinSetAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetAttributeTest failed"); + throw new Exception("joinSetAttributeTest failed"); } } @@ -660,7 +659,7 @@ public void joinSetAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetAttributeJoinTypeTest failed"); + throw new Exception("joinSetAttributeJoinTypeTest failed"); } } @@ -707,7 +706,7 @@ public void joinSetStringTest() throws Exception { } if (!pass) { - throw new Fault("joinSetStringTest failed"); + throw new Exception("joinSetStringTest failed"); } } @@ -755,7 +754,7 @@ public void joinSetStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinSetStringJoinTypeTest failed"); + throw new Exception("joinSetStringJoinTypeTest failed"); } } @@ -816,7 +815,7 @@ public void joinSetIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinSetIllegalArgumentExceptionTest failed"); + throw new Exception("joinSetIllegalArgumentExceptionTest failed"); } } @@ -863,7 +862,7 @@ public void joinListAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinListAttributeTest failed"); + throw new Exception("joinListAttributeTest failed"); } } @@ -911,7 +910,7 @@ public void joinListAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinListAttributeJoinTypeTest failed"); + throw new Exception("joinListAttributeJoinTypeTest failed"); } } @@ -974,7 +973,7 @@ public void joinListIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinListIllegalArgumentExceptionTest failed"); + throw new Exception("joinListIllegalArgumentExceptionTest failed"); } } @@ -1021,7 +1020,7 @@ public void joinListStringTest() throws Exception { } if (!pass) { - throw new Fault("joinListStringTest failed"); + throw new Exception("joinListStringTest failed"); } } @@ -1069,7 +1068,7 @@ public void joinListStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinListStringJoinTypeTest failed"); + throw new Exception("joinListStringJoinTypeTest failed"); } } @@ -1118,7 +1117,7 @@ public void joinMapAttributeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapAttributeTest failed"); + throw new Exception("joinMapAttributeTest failed"); } } @@ -1167,7 +1166,7 @@ public void joinMapAttributeJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapAttributeJoinTypeTest failed"); + throw new Exception("joinMapAttributeJoinTypeTest failed"); } } @@ -1216,7 +1215,7 @@ public void joinMapStringTest() throws Exception { } if (!pass) { - throw new Fault("joinMapStringTest failed"); + throw new Exception("joinMapStringTest failed"); } } @@ -1266,7 +1265,7 @@ public void joinMapStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("joinMapStringJoinTypeTest failed"); + throw new Exception("joinMapStringJoinTypeTest failed"); } } @@ -1327,7 +1326,7 @@ public void joinMapIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("joinMapIllegalArgumentExceptionTest failed"); + throw new Exception("joinMapIllegalArgumentExceptionTest failed"); } } @@ -1369,7 +1368,7 @@ public void rootGetCorrelationParentIllegalStateExceptionTest() throws Exception } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "rootGetCorrelationParentIllegalStateExceptionTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/Client.java index 2d3f1c273e..70e75ed9fa 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/Client.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Set; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -92,6 +94,7 @@ public class Client extends Util { * */ @SetupMethod(name = "setupOrderData") + @Test public void queryTest1() throws Exception { boolean pass = false; String expectedPKs[]; @@ -132,7 +135,7 @@ public void queryTest1() throws Exception { } if (!pass) { - throw new Fault("queryTest1 failed"); + throw new Exception("queryTest1 failed"); } } @@ -147,6 +150,7 @@ public void queryTest1() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void queryTest2() throws Exception { boolean pass = false; String expectedPKs[]; @@ -182,7 +186,7 @@ public void queryTest2() throws Exception { } if (!pass) { - throw new Fault("queryTest2 failed"); + throw new Exception("queryTest2 failed"); } } @@ -198,6 +202,7 @@ public void queryTest2() throws Exception { * the results were accurately returned. */ @SetupMethod(name = "setupAliasData") + @Test public void queryTest3() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -258,7 +263,7 @@ public void queryTest3() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("queryTest3 failed"); + throw new Exception("queryTest3 failed"); } } @@ -274,6 +279,7 @@ public void queryTest3() throws Exception { * */ @SetupMethod(name = "setupCustomerData") + @Test public void queryTest4() throws Exception { boolean pass = false; Customer c; @@ -316,7 +322,7 @@ public void queryTest4() throws Exception { } if (!pass) { - throw new Fault("queryTest4 failed"); + throw new Exception("queryTest4 failed"); } } @@ -376,7 +382,7 @@ public void queryTest5() throws Exception { } if (!pass) { - throw new Fault("queryTest5 failed"); + throw new Exception("queryTest5 failed"); } } @@ -440,7 +446,7 @@ public void queryTest6() throws Exception { } if (!pass) { - throw new Fault("queryTest6 failed"); + throw new Exception("queryTest6 failed"); } } @@ -493,7 +499,7 @@ public void queryTest7() throws Exception { } if (!pass) { - throw new Fault("queryTest7 failed"); + throw new Exception("queryTest7 failed"); } } @@ -546,7 +552,7 @@ public void queryTest8() throws Exception { } if (!pass) { - throw new Fault("queryTest8 failed"); + throw new Exception("queryTest8 failed"); } } @@ -603,7 +609,7 @@ public void queryTest9() throws Exception { } if (!pass) { - throw new Fault("queryTest9 failed"); + throw new Exception("queryTest9 failed"); } } @@ -672,7 +678,7 @@ public void queryTest10() throws Exception { } if (!pass) { - throw new Fault("queryTest10 failed"); + throw new Exception("queryTest10 failed"); } } @@ -726,7 +732,7 @@ public void queryTest11() throws Exception { } if (!pass) { - throw new Fault("queryTest11 failed"); + throw new Exception("queryTest11 failed"); } } @@ -779,7 +785,7 @@ public void queryTest12() throws Exception { } if (!pass) { - throw new Fault("queryTest12 failed"); + throw new Exception("queryTest12 failed"); } } @@ -841,7 +847,7 @@ public void queryTest13() throws Exception { } if (!pass) { - throw new Fault("queryTest13 failed"); + throw new Exception("queryTest13 failed"); } } @@ -899,7 +905,7 @@ public void queryTest14() throws Exception { } if (!pass) { - throw new Fault("queryTest14 failed"); + throw new Exception("queryTest14 failed"); } } @@ -947,7 +953,7 @@ public void queryTest15() throws Exception { } if (!pass) { - throw new Fault("queryTest15 failed"); + throw new Exception("queryTest15 failed"); } } @@ -996,7 +1002,7 @@ public void queryTest16() throws Exception { } if (!pass) { - throw new Fault("queryTest16 failed"); + throw new Exception("queryTest16 failed"); } } @@ -1062,7 +1068,7 @@ public void queryTest17() throws Exception { } if (!pass) { - throw new Fault("queryTest17 failed"); + throw new Exception("queryTest17 failed"); } } @@ -1112,7 +1118,7 @@ public void queryTest18() throws Exception { } if (!pass) { - throw new Fault("queryTest18 failed"); + throw new Exception("queryTest18 failed"); } } @@ -1179,7 +1185,7 @@ public void queryTest19() throws Exception { } if (!pass) { - throw new Fault("queryTest19 failed"); + throw new Exception("queryTest19 failed"); } } @@ -1235,7 +1241,7 @@ public void queryTest20() throws Exception { } if (!pass) { - throw new Fault("queryTest20 failed"); + throw new Exception("queryTest20 failed"); } } @@ -1295,7 +1301,7 @@ public void queryTest21() throws Exception { } if (!pass) { - throw new Fault("queryTest21 failed"); + throw new Exception("queryTest21 failed"); } } @@ -1342,7 +1348,7 @@ public void queryTest22() throws Exception { } if (!pass) { - throw new Fault("queryTest22 failed"); + throw new Exception("queryTest22 failed"); } } @@ -1409,7 +1415,7 @@ public void queryTest23() throws Exception { } if (!pass) { - throw new Fault("queryTest23 failed"); + throw new Exception("queryTest23 failed"); } } @@ -1458,7 +1464,7 @@ public void queryTest24() throws Exception { } if (!pass) { - throw new Fault("queryTest24 failed"); + throw new Exception("queryTest24 failed"); } } @@ -1512,7 +1518,7 @@ public void queryTest25() throws Exception { } if (!pass) { - throw new Fault("queryTest25 failed"); + throw new Exception("queryTest25 failed"); } } @@ -1567,7 +1573,7 @@ public void queryTest26() throws Exception { } if (!pass) { - throw new Fault("queryTest26 failed"); + throw new Exception("queryTest26 failed"); } } @@ -1625,7 +1631,7 @@ public void queryTest27() throws Exception { } if (!pass) { - throw new Fault("queryTest27 failed"); + throw new Exception("queryTest27 failed"); } } @@ -1677,7 +1683,7 @@ public void queryTest28() throws Exception { } if (!pass) { - throw new Fault("queryTest28 failed"); + throw new Exception("queryTest28 failed"); } } @@ -1740,7 +1746,7 @@ public void queryTest29() throws Exception { } if (!pass) { - throw new Fault("queryTest29 failed"); + throw new Exception("queryTest29 failed"); } } @@ -1823,7 +1829,7 @@ public void queryTest30() throws Exception { } if (!pass) { - throw new Fault("queryTest30 failed"); + throw new Exception("queryTest30 failed"); } } @@ -1874,7 +1880,7 @@ public void queryTest31() throws Exception { } if (!pass) { - throw new Fault("queryTest31 failed"); + throw new Exception("queryTest31 failed"); } } @@ -1926,7 +1932,7 @@ public void likeExpExpCharTest() throws Exception { } if (!pass) { - throw new Fault("likeExpExpCharTest failed"); + throw new Exception("likeExpExpCharTest failed"); } } @@ -1978,7 +1984,7 @@ public void likeExpExpExpTest() throws Exception { } if (!pass) { - throw new Fault("likeExpExpExpTest failed"); + throw new Exception("likeExpExpExpTest failed"); } } @@ -2030,7 +2036,7 @@ public void likeExpStringExpTest() throws Exception { } if (!pass) { - throw new Fault("likeExpStringExpTest failed"); + throw new Exception("likeExpStringExpTest failed"); } } @@ -2082,7 +2088,7 @@ public void queryTest32() throws Exception { } if (!pass) { - throw new Fault("queryTest32 failed"); + throw new Exception("queryTest32 failed"); } } @@ -2156,7 +2162,7 @@ public void queryTest33() throws Exception { } if (!pass) { - throw new Fault("queryTest33 failed"); + throw new Exception("queryTest33 failed"); } } @@ -2208,7 +2214,7 @@ public void queryTest34() throws Exception { } if (!pass) { - throw new Fault("queryTest34 failed"); + throw new Exception("queryTest34 failed"); } } @@ -2267,7 +2273,7 @@ public void queryTest35() throws Exception { } if (!pass) { - throw new Fault("queryTest35 failed"); + throw new Exception("queryTest35 failed"); } } @@ -2318,7 +2324,7 @@ public void queryTest36() throws Exception { } if (!pass) { - throw new Fault("queryTest36 failed"); + throw new Exception("queryTest36 failed"); } } @@ -2406,7 +2412,7 @@ public void queryTest37() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest37 failed"); + throw new Exception("queryTest37 failed"); } } @@ -2456,7 +2462,7 @@ public void queryTest38() throws Exception { } if (!pass) { - throw new Fault("queryTest38 failed"); + throw new Exception("queryTest38 failed"); } } @@ -2508,7 +2514,7 @@ public void queryTest39() throws Exception { } if (!pass) { - throw new Fault("queryTest39 failed"); + throw new Exception("queryTest39 failed"); } } @@ -2600,7 +2606,7 @@ public void queryTest40() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest40 failed"); + throw new Exception("queryTest40 failed"); } } @@ -2712,7 +2718,7 @@ public void queryTest41() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest41 failed"); + throw new Exception("queryTest41 failed"); } } @@ -2782,7 +2788,7 @@ public void queryTest42() throws Exception { } if (!pass) { - throw new Fault("queryTest42 failed"); + throw new Exception("queryTest42 failed"); } } @@ -2835,7 +2841,7 @@ public void queryTest43() throws Exception { } if (!pass) { - throw new Fault("queryTest43 failed"); + throw new Exception("queryTest43 failed"); } } @@ -2886,7 +2892,7 @@ public void queryTest44() throws Exception { } if (!pass) { - throw new Fault("queryTest44 failed"); + throw new Exception("queryTest44 failed"); } } @@ -2954,7 +2960,7 @@ public void queryTest45() throws Exception { } if (!pass) { - throw new Fault("queryTest45 failed"); + throw new Exception("queryTest45 failed"); } } @@ -3002,7 +3008,7 @@ public void queryTest47() throws Exception { } if (!pass) { - throw new Fault("queryTest47 failed"); + throw new Exception("queryTest47 failed"); } } @@ -3054,7 +3060,7 @@ public void queryTest48() throws Exception { } if (!pass) { - throw new Fault("queryTest48 failed"); + throw new Exception("queryTest48 failed"); } } @@ -3117,7 +3123,7 @@ public void queryTest49() throws Exception { } if (!pass) { - throw new Fault("queryTest49 failed"); + throw new Exception("queryTest49 failed"); } } @@ -3170,7 +3176,7 @@ public void queryTest50() throws Exception { } if (!pass) { - throw new Fault("queryTest50 failed"); + throw new Exception("queryTest50 failed"); } } @@ -3217,7 +3223,7 @@ public void queryTest51() throws Exception { } if (!pass) { - throw new Fault("queryTest51 failed"); + throw new Exception("queryTest51 failed"); } } @@ -3268,7 +3274,7 @@ public void queryTest52() throws Exception { } if (!pass) { - throw new Fault("queryTest52 failed"); + throw new Exception("queryTest52 failed"); } } @@ -3334,7 +3340,7 @@ public void queryTest53() throws Exception { } if (!pass) { - throw new Fault("queryTest53 failed"); + throw new Exception("queryTest53 failed"); } } @@ -3379,7 +3385,7 @@ public void queryTest54() throws Exception { } if (!pass) { - throw new Fault("queryTest54 failed"); + throw new Exception("queryTest54 failed"); } } @@ -3436,7 +3442,7 @@ public void queryTest55() throws Exception { } if (!pass) { - throw new Fault("queryTest55 failed"); + throw new Exception("queryTest55 failed"); } } @@ -3512,7 +3518,7 @@ public void queryTest56() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest56 failed"); + throw new Exception("queryTest56 failed"); } } @@ -3556,7 +3562,7 @@ public void queryTest58() throws Exception { } if (!pass) { - throw new Fault("queryTest58 failed"); + throw new Exception("queryTest58 failed"); } } @@ -3605,7 +3611,7 @@ public void queryTest59() throws Exception { } if (!pass) { - throw new Fault("queryTest59 failed"); + throw new Exception("queryTest59 failed"); } } @@ -3653,7 +3659,7 @@ public void queryTest60() throws Exception { } if (!pass) { - throw new Fault("queryTest60 failed"); + throw new Exception("queryTest60 failed"); } } @@ -3706,7 +3712,7 @@ public void queryTest61() throws Exception { } if (!pass) { - throw new Fault("queryTest61 failed"); + throw new Exception("queryTest61 failed"); } } @@ -3759,7 +3765,7 @@ public void queryTest62() throws Exception { } if (!pass) { - throw new Fault("queryTest62 failed"); + throw new Exception("queryTest62 failed"); } } @@ -3812,7 +3818,7 @@ public void queryTest63() throws Exception { } if (!pass) { - throw new Fault("queryTest63 failed"); + throw new Exception("queryTest63 failed"); } } @@ -3885,7 +3891,7 @@ public void queryTest64() throws Exception { } if (!pass) { - throw new Fault("queryTest64 failed"); + throw new Exception("queryTest64 failed"); } } @@ -3930,7 +3936,7 @@ public void queryTest65() throws Exception { } if (!pass) { - throw new Fault("queryTest65 failed"); + throw new Exception("queryTest65 failed"); } } @@ -3972,7 +3978,7 @@ public void queryTest66() throws Exception { } if (!pass) { - throw new Fault("queryTest66 failed"); + throw new Exception("queryTest66 failed"); } } @@ -4015,7 +4021,7 @@ public void queryTest67() throws Exception { } if (!pass) { - throw new Fault("queryTest67 failed"); + throw new Exception("queryTest67 failed"); } } @@ -4057,7 +4063,7 @@ public void queryTest68() throws Exception { } if (!pass) { - throw new Fault("queryTest68 failed"); + throw new Exception("queryTest68 failed"); } } @@ -4118,7 +4124,7 @@ public void queryTest69() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest69 failed"); + throw new Exception("queryTest69 failed"); } } @@ -4162,7 +4168,7 @@ public void queryTest70() throws Exception { } if (!pass) { - throw new Fault("queryTest70 failed"); + throw new Exception("queryTest70 failed"); } } @@ -4202,7 +4208,7 @@ public void queryTest71() throws Exception { } if (!pass) { - throw new Fault("queryTest71 failed"); + throw new Exception("queryTest71 failed"); } } @@ -4253,7 +4259,7 @@ public void test_leftouterjoin_1xM() throws Exception { } if (!pass) { - throw new Fault("test_leftouterjoin_1xM failed"); + throw new Exception("test_leftouterjoin_1xM failed"); } } @@ -4336,7 +4342,7 @@ public void test_leftouterjoin_Mx1() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("test_leftouterjoin_Mx1 failed"); + throw new Exception("test_leftouterjoin_Mx1 failed"); } } @@ -4419,7 +4425,7 @@ public void test_leftouterjoin_MxM() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("test_leftouterjoin_MxM failed"); + throw new Exception("test_leftouterjoin_MxM failed"); } } @@ -4467,7 +4473,7 @@ public void test_upperStringExpression() throws Exception { } if (!pass) { - throw new Fault("test_upperStringExpression failed"); + throw new Exception("test_upperStringExpression failed"); } } @@ -4515,7 +4521,7 @@ public void test_lowerStringExpression() throws Exception { } if (!pass) { - throw new Fault("test_lowerStringExpression failed"); + throw new Exception("test_lowerStringExpression failed"); } } @@ -4567,7 +4573,7 @@ public void test_groupBy() throws Exception { } if (!pass) { - throw new Fault("test_groupBy failed"); + throw new Exception("test_groupBy failed"); } } @@ -4619,7 +4625,7 @@ public void test_groupBy_1() throws Exception { } if (!pass) { - throw new Fault("test_groupBy_1 failed"); + throw new Exception("test_groupBy_1 failed"); } } @@ -4670,7 +4676,7 @@ public void test_innerjoin_1x1() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_1x1 failed"); + throw new Exception("test_innerjoin_1x1 failed"); } } @@ -4725,7 +4731,7 @@ public void test_innerjoin_1xM() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_1xM failed"); + throw new Exception("test_innerjoin_1xM failed"); } } @@ -4777,7 +4783,7 @@ public void test_innerjoin_Mx1() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_Mx1 failed"); + throw new Exception("test_innerjoin_Mx1 failed"); } } @@ -4827,7 +4833,7 @@ public void test_innerjoin_MxM() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_MxM failed"); + throw new Exception("test_innerjoin_MxM failed"); } } @@ -4878,7 +4884,7 @@ public void fetchFetchSingularAttributeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fetchFetchSingularAttributeTest failed"); + throw new Exception("fetchFetchSingularAttributeTest failed"); } } @@ -4925,7 +4931,7 @@ public void fetchFetchSingularAttributeJoinTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fetchFetchSingularAttributeJoinTypeTest failed"); + throw new Exception("fetchFetchSingularAttributeJoinTypeTest failed"); } } @@ -4975,7 +4981,7 @@ public void fetchFetchPluralAttributeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fetchFetchPluralAttributeTest failed"); + throw new Exception("fetchFetchPluralAttributeTest failed"); } } @@ -5025,7 +5031,7 @@ public void fetchFetchPluralAttributeJoinTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fetchFetchPluralAttributeJoinTypeTest failed"); + throw new Exception("fetchFetchPluralAttributeJoinTypeTest failed"); } } @@ -5071,7 +5077,7 @@ public void fetchFetchStringTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fetchFetchStringTest failed"); + throw new Exception("fetchFetchStringTest failed"); } } @@ -5118,7 +5124,7 @@ public void fetchFetchStringJoinTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("fetchFetchStringJoinTypeTest failed"); + throw new Exception("fetchFetchStringJoinTypeTest failed"); } } @@ -5156,7 +5162,7 @@ public void fetchFetchStringIllegalArgumentExceptionTest() throws Exception { } if (!pass) { - throw new Fault("fetchFetchStringIllegalArgumentExceptionTest failed"); + throw new Exception("fetchFetchStringIllegalArgumentExceptionTest failed"); } } @@ -5195,7 +5201,7 @@ public void fetchFetchStringJoinTypeIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "fetchFetchStringJoinTypeIllegalArgumentExceptionTest failed"); } } @@ -5271,7 +5277,7 @@ public void fetchTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("fetchTest failed"); + throw new Exception("fetchTest failed"); } } @@ -5321,7 +5327,7 @@ public void fetchGetParentTest() throws Exception { } if (!pass) { - throw new Fault("fetchGetParentTest failed"); + throw new Exception("fetchGetParentTest failed"); } } @@ -5396,7 +5402,7 @@ public void test_fetchjoin_1x1() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_1x1 failed"); + throw new Exception("test_fetchjoin_1x1 failed"); } } @@ -5445,7 +5451,7 @@ public void fetchSingularAttributeJoinType1X1Test() throws Exception { } if (!pass) { - throw new Fault("fetchSingularAttributeJoinType1X1Test failed"); + throw new Exception("fetchSingularAttributeJoinType1X1Test failed"); } } @@ -5496,7 +5502,7 @@ public void test_fetchjoin_1xM() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_1xM failed"); + throw new Exception("test_fetchjoin_1xM failed"); } } @@ -5545,7 +5551,7 @@ public void fetchPluralAttribute1xMTest() throws Exception { } if (!pass) { - throw new Fault("fetchPluralAttribute1xMTest failed"); + throw new Exception("fetchPluralAttribute1xMTest failed"); } } @@ -5594,7 +5600,7 @@ public void fetchPluralAttributeJoinType1xMTest() throws Exception { } if (!pass) { - throw new Fault("fetchPluralAttributeJoinType1xMTest failed"); + throw new Exception("fetchPluralAttributeJoinType1xMTest failed"); } } @@ -5642,7 +5648,7 @@ public void test_fetchjoin_Mx1() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_Mx1 failed"); + throw new Exception("test_fetchjoin_Mx1 failed"); } } @@ -5691,7 +5697,7 @@ public void test_fetchjoin_Mx1_1() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_Mx1_1 failed"); + throw new Exception("test_fetchjoin_Mx1_1 failed"); } } @@ -5741,7 +5747,7 @@ public void test_fetchjoin_MxM() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_MxM failed"); + throw new Exception("test_fetchjoin_MxM failed"); } } @@ -5804,7 +5810,7 @@ public void test_betweenDates() throws Exception { } if (!pass) - throw new Fault("test_betweenDates failed"); + throw new Exception("test_betweenDates failed"); } /* @@ -5864,7 +5870,7 @@ public void test_notBetweenArithmetic() throws Exception { } if (!pass) { - throw new Fault("test_notBetweenArithmetic failed"); + throw new Exception("test_notBetweenArithmetic failed"); } } @@ -5919,7 +5925,7 @@ public void test_notBetweenDates() throws Exception { } if (!pass) - throw new Fault("test_notBetweenDates failed"); + throw new Exception("test_notBetweenDates failed"); } /* @@ -5968,7 +5974,7 @@ public void test_ANDconditionTT() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionTT failed"); + throw new Exception("test_ANDconditionTT failed"); } } @@ -6014,7 +6020,7 @@ public void test_ANDconditionTF() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionTF failed"); + throw new Exception("test_ANDconditionTF failed"); } } @@ -6060,7 +6066,7 @@ public void test_ANDconditionFT() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionFT failed"); + throw new Exception("test_ANDconditionFT failed"); } } @@ -6109,7 +6115,7 @@ public void test_ANDconditionFF() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionFF failed"); + throw new Exception("test_ANDconditionFF failed"); } } @@ -6159,7 +6165,7 @@ public void test_ORconditionTT() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionTT failed"); + throw new Exception("test_ORconditionTT failed"); } } @@ -6207,7 +6213,7 @@ public void test_ORconditionTF() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionTF failed"); + throw new Exception("test_ORconditionTF failed"); } } @@ -6260,7 +6266,7 @@ public void test_ORconditionFT() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionFT failed"); + throw new Exception("test_ORconditionFT failed"); } } @@ -6308,7 +6314,7 @@ public void test_ORconditionFF() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionFF failed"); + throw new Exception("test_ORconditionFF failed"); } } @@ -6360,7 +6366,7 @@ public void test_groupByWhereClause() throws Exception { } if (!pass) { - throw new Fault("test_groupByWhereClause failed"); + throw new Exception("test_groupByWhereClause failed"); } } @@ -6420,7 +6426,7 @@ public void test_groupByHaving() throws Exception { } if (!pass) { - throw new Fault("test_groupByHaving failed"); + throw new Exception("test_groupByHaving failed"); } } @@ -6475,7 +6481,7 @@ public void substringHavingExpressionTest() throws Exception { } if (!pass) { - throw new Fault(" substringHavingExpressionTest failed"); + throw new Exception(" substringHavingExpressionTest failed"); } } @@ -6536,7 +6542,7 @@ public void substringHavingExpressionPredicateArrayTest() throws Exception { } if (!pass) { - throw new Fault("substringHavingExpressionPredicateArrayTest failed"); + throw new Exception("substringHavingExpressionPredicateArrayTest failed"); } } @@ -6587,7 +6593,7 @@ public void test_concatHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_concatHavingClause failed"); + throw new Exception("test_concatHavingClause failed"); } } @@ -6643,7 +6649,7 @@ public void test_lowerHavingClause() throws Exception { } if (!pass1 || !pass2) { - throw new Fault(" test_lowerHavingClause failed"); + throw new Exception(" test_lowerHavingClause failed"); } } @@ -6699,7 +6705,7 @@ public void test_upperHavingClause() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("test_upperHavingClause failed"); + throw new Exception("test_upperHavingClause failed"); } } @@ -6750,7 +6756,7 @@ public void test_lengthHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_lengthHavingClause failed"); + throw new Exception("test_lengthHavingClause failed"); } } @@ -6801,7 +6807,7 @@ public void test_locateHavingClause() throws Exception { } if (!pass) { - throw new Fault(" test_locateHavingClause failed"); + throw new Exception(" test_locateHavingClause failed"); } } @@ -6846,7 +6852,7 @@ public void test_locateHavingClause() throws Exception { * * } * - * if (!pass) { throw new Fault(" test_trimHavingClause_01 failed"); } } + * if (!pass) { throw new Exception(" test_trimHavingClause_01 failed"); } } */ /* @@ -6888,7 +6894,7 @@ public void test_locateHavingClause() throws Exception { * * } * - * if (!pass) { throw new Fault("test_trimHavingClause_02 failed"); } } + * if (!pass) { throw new Exception("test_trimHavingClause_02 failed"); } } */ /* @@ -6932,7 +6938,7 @@ public void test_locateHavingClause() throws Exception { * * } * - * if (!pass) { throw new Fault("test_trimHavingClause_03 failed"); } } + * if (!pass) { throw new Exception("test_trimHavingClause_03 failed"); } } */ /* @@ -6976,7 +6982,7 @@ public void test_ABSHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_ABSHavingClause failed"); + throw new Exception("test_ABSHavingClause failed"); } } @@ -7024,7 +7030,7 @@ public void test_SQRTWhereClause() throws Exception { } if (!pass) { - throw new Fault(" test_SQRTWhereClause failed"); + throw new Exception(" test_SQRTWhereClause failed"); } } @@ -7087,7 +7093,7 @@ public void subQueryGetSelectionGetParentTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("subQueryGetSelectionGetParentTest failed"); + throw new Exception("subQueryGetSelectionGetParentTest failed"); } } @@ -7203,7 +7209,7 @@ public void subQueryHavingExpressionTest() throws Exception { } if (!pass1 || !pass2 | !pass3) { - throw new Fault("subQueryHavingExpressionTest failed"); + throw new Exception("subQueryHavingExpressionTest failed"); } } @@ -7285,7 +7291,7 @@ public void subQueryHavingPredicateArrayTest() throws Exception { } if (!pass) { - throw new Fault("subQueryHavingPredicateArrayTest failed"); + throw new Exception("subQueryHavingPredicateArrayTest failed"); } } @@ -7348,7 +7354,7 @@ public void subQuerySelectExpressionTest() throws Exception { } if (!pass) { - throw new Fault("subQuerySelectExpressionTest failed"); + throw new Exception("subQuerySelectExpressionTest failed"); } } @@ -7414,7 +7420,7 @@ public void subQueryWhereExpressionTest() throws Exception { } if (!pass) { - throw new Fault("subQueryWhereExpressionTest failed"); + throw new Exception("subQueryWhereExpressionTest failed"); } } @@ -7496,7 +7502,7 @@ public void subQueryWherePredicateArrayTest() throws Exception { } if (!pass) { - throw new Fault("subQueryWherePredicateArrayTest failed"); + throw new Exception("subQueryWherePredicateArrayTest failed"); } } @@ -7608,7 +7614,7 @@ public void subQueryDistinctTest() throws Exception { } if (!pass1 || !pass2 || !pass4 || !pass5 || !pass6) { - throw new Fault("subQueryDistinctTest failed"); + throw new Exception("subQueryDistinctTest failed"); } } @@ -7674,7 +7680,7 @@ public void getCorrelatedJoinsTest() throws Exception { } if (!pass) { - throw new Fault(" getCorrelatedJoinsTest failed"); + throw new Exception(" getCorrelatedJoinsTest failed"); } } @@ -7731,7 +7737,7 @@ public void test_subquery_exists_02() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_exists_02 failed"); + throw new Exception(" test_subquery_exists_02 failed"); } } @@ -7784,7 +7790,7 @@ public void test_subquery_like() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_like failed"); + throw new Exception(" test_subquery_like failed"); } } @@ -7846,7 +7852,7 @@ public void test_subquery_in() throws Exception { } if (!pass) { - throw new Fault("test_subquery_in failed"); + throw new Exception("test_subquery_in failed"); } } @@ -7902,7 +7908,7 @@ public void test_subquery_between() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_between failed"); + throw new Exception(" test_subquery_between failed"); } } @@ -7972,7 +7978,7 @@ public void test_subquery_join() throws Exception { } if (!pass1 || !pass2) { - throw new Fault(" test_subquery_join failed"); + throw new Exception(" test_subquery_join failed"); } } @@ -8024,7 +8030,7 @@ public void getCorrelationParentIllegalStateExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getCorrelationParentIllegalStateExceptionTest failed"); + throw new Exception("getCorrelationParentIllegalStateExceptionTest failed"); } } @@ -8100,7 +8106,7 @@ public void subquerySetJoinTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("subquerySetJoinTest failed"); + throw new Exception("subquerySetJoinTest failed"); } } @@ -8155,7 +8161,7 @@ public void subqueryListJoinTest() throws Exception { } if (!pass) { - throw new Fault("subqueryListJoinTest failed"); + throw new Exception("subqueryListJoinTest failed"); } } @@ -8210,7 +8216,7 @@ public void subqueryCollectionJoinTest() throws Exception { } if (!pass) { - throw new Fault("subqueryCollectionJoinTest failed"); + throw new Exception("subqueryCollectionJoinTest failed"); } } @@ -8268,7 +8274,7 @@ public void test_subquery_ALL_GT() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_ALL_GT failed"); + throw new Exception(" test_subquery_ALL_GT failed"); } } @@ -8321,7 +8327,7 @@ public void test_subquery_ALL_LT() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_LT failed"); + throw new Exception("test_subquery_ALL_LT failed"); } } @@ -8374,7 +8380,7 @@ public void test_subquery_ALL_EQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_EQ failed"); + throw new Exception("test_subquery_ALL_EQ failed"); } } @@ -8431,7 +8437,7 @@ public void test_subquery_ALL_LTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_LTEQ failed"); + throw new Exception("test_subquery_ALL_LTEQ failed"); } } @@ -8486,7 +8492,7 @@ public void test_subquery_ALL_GTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_GTEQ failed"); + throw new Exception("test_subquery_ALL_GTEQ failed"); } } @@ -8556,7 +8562,7 @@ public void test_subquery_ALL_NOTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_NOTEQ failed"); + throw new Exception("test_subquery_ALL_NOTEQ failed"); } } @@ -8625,7 +8631,7 @@ public void test_subquery_ANY_GT() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ANY_GT failed"); + throw new Exception("test_subquery_ANY_GT failed"); } } @@ -8696,7 +8702,7 @@ public void test_subquery_ANY_LT() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ANY_LT failed"); + throw new Exception("test_subquery_ANY_LT failed"); } } @@ -8751,7 +8757,7 @@ public void test_subquery_ANY_EQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ANY_EQ failed"); + throw new Exception("test_subquery_ANY_EQ failed"); } } @@ -8823,7 +8829,7 @@ public void test_subquery_SOME_LTEQ() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_SOME_LTEQ failed"); + throw new Exception(" test_subquery_SOME_LTEQ failed"); } } @@ -8896,7 +8902,7 @@ public void test_subquery_SOME_GTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_SOME_GTEQ failed"); + throw new Exception("test_subquery_SOME_GTEQ failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/Client.java index 85bbcbc43e..6e188f2a11 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/Client.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Properties; import java.util.Set; import com.sun.ts.lib.harness.SetupMethod; @@ -46,14 +45,14 @@ public class Client extends Util { - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -105,7 +104,7 @@ public void predicateIsNegatedTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("predicateIsNegatedTest failed"); + throw new Exception("predicateIsNegatedTest failed"); } } @@ -174,7 +173,7 @@ public void predicateBooleanOperatorTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("predicateBooleanOperatorTest failed"); + throw new Exception("predicateBooleanOperatorTest failed"); } } @@ -243,7 +242,7 @@ public void predicateGetOperatorTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("predicateGetOperatorTest failed"); + throw new Exception("predicateGetOperatorTest failed"); } } @@ -368,7 +367,7 @@ public void predicateGetExpressionsTest() throws Exception { } if (!pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("predicateGetExpressionsTest failed"); + throw new Exception("predicateGetExpressionsTest failed"); } } @@ -437,7 +436,7 @@ public void predicateIsNotNullTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("predicateIsNotNullTest failed"); + throw new Exception("predicateIsNotNullTest failed"); } } @@ -487,7 +486,7 @@ public void predicateIsNullTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("predicateIsNullTest failed"); + throw new Exception("predicateIsNullTest failed"); } } @@ -537,7 +536,7 @@ public void pathInObjectArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("pathInObjectArrayTest failed"); + throw new Exception("pathInObjectArrayTest failed"); } } @@ -587,7 +586,7 @@ public void pathInExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("pathInExpressionTest failed"); + throw new Exception("pathInExpressionTest failed"); } } @@ -640,7 +639,7 @@ public void pathInExpressionArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("pathInExpressionArrayTest failed"); + throw new Exception("pathInExpressionArrayTest failed"); } } @@ -693,7 +692,7 @@ public void pathInCollectionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("pathInCollectionTest failed"); + throw new Exception("pathInCollectionTest failed"); } } @@ -761,7 +760,7 @@ public void pathIsNotNullTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("pathIsNotNullTest failed"); + throw new Exception("pathIsNotNullTest failed"); } } @@ -809,7 +808,7 @@ public void pathIsNullTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("pathIsNullTest failed"); + throw new Exception("pathIsNullTest failed"); } } @@ -883,7 +882,7 @@ public void compoundSelectionGetCompoundSelectionItemsTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("compoundSelectionGetCompoundSelectionItemsTest failed"); + throw new Exception("compoundSelectionGetCompoundSelectionItemsTest failed"); } } @@ -953,7 +952,7 @@ public void selectionGetCompoundSelectionItemsTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("selectionGetCompoundSelectionItemsTest failed"); + throw new Exception("selectionGetCompoundSelectionItemsTest failed"); } } @@ -985,7 +984,7 @@ public void selectionGetCompoundSelectionItemsIllegalStateExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "selectionGetCompoundSelectionItemsIllegalStateExceptionTest failed"); } } @@ -1014,7 +1013,7 @@ public void expressionIsCompoundSelectionTest() throws Exception { "Expected isCompoundSelection() to return: false, actual:" + actual); } if (!pass) { - throw new Fault("expressionGetCompoundSelectionItemsTest failed"); + throw new Exception("expressionGetCompoundSelectionItemsTest failed"); } } @@ -1043,7 +1042,7 @@ public void expressionGetCompoundSelectionItemsIllegalStateExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "expressionGetCompoundSelectionItemsIllegalStateExceptionTest failed"); } } @@ -1101,7 +1100,7 @@ public void subqueryInObjectArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryInObjectArrayTest failed"); + throw new Exception("subqueryInObjectArrayTest failed"); } } @@ -1158,7 +1157,7 @@ public void subqueryInExpressionArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryInExpressionArrayTest failed"); + throw new Exception("subqueryInExpressionArrayTest failed"); } } @@ -1215,7 +1214,7 @@ public void subqueryInExpressionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryInExpressionTest failed"); + throw new Exception("subqueryInExpressionTest failed"); } } @@ -1274,7 +1273,7 @@ public void subqueryInCollectionTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryInCollectionTest failed"); + throw new Exception("subqueryInCollectionTest failed"); } } @@ -1327,7 +1326,7 @@ public void subqueryIsNotNull() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryIsNotNull test failed"); + throw new Exception("subqueryIsNotNull test failed"); } @@ -1381,7 +1380,7 @@ public void subqueryIsNull() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("subqueryIsNull test failed"); + throw new Exception("subqueryIsNull test failed"); } @@ -1432,7 +1431,7 @@ public void pathGetPluralAttributeTest() throws Exception { } if (!pass) { - throw new Fault("pathGetPluralAttributeTest failed"); + throw new Exception("pathGetPluralAttributeTest failed"); } } @@ -1482,7 +1481,7 @@ public void subquery() throws Exception { } if (!pass) { - throw new Fault("subquery failed"); + throw new Exception("subquery failed"); } } @@ -1601,7 +1600,7 @@ public void subqueryGroupByExpressionTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("subqueryGroupByExpressionTest failed"); + throw new Exception("subqueryGroupByExpressionTest failed"); } } @@ -1666,7 +1665,7 @@ public void subqueryGroupByExpressionArrayTest() throws Exception { } if (!pass) { - throw new Fault("subqueryGroupByExpressionArrayTest failed"); + throw new Exception("subqueryGroupByExpressionArrayTest failed"); } } @@ -1732,7 +1731,7 @@ public void subqueryGroupByListTest() throws Exception { } if (!pass) { - throw new Fault("subqueryGroupByListTest failed"); + throw new Exception("subqueryGroupByListTest failed"); } } @@ -1802,7 +1801,7 @@ public void getRoots() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getRoots test failed"); + throw new Exception("getRoots test failed"); } } @@ -1879,7 +1878,7 @@ public void getSelection() throws Exception { TestUtil.logErr("Caught unexpected exception ", e); } if (!pass1 || !pass2 || !pass3) { - throw new Fault("getSelection failed"); + throw new Exception("getSelection failed"); } } @@ -1964,7 +1963,7 @@ public void getGroupList() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getGroupList failed"); + throw new Exception("getGroupList failed"); } } @@ -2032,7 +2031,7 @@ public void getGroupRestriction() throws Exception { } if (!pass) { - throw new Fault("getGroupRestriction failed"); + throw new Exception("getGroupRestriction failed"); } } @@ -2069,7 +2068,7 @@ public void isDistinct() throws Exception { } if (!pass) { - throw new Fault("isDistinct test failed"); + throw new Exception("isDistinct test failed"); } } @@ -2166,7 +2165,7 @@ public void getResultType() throws Exception { TestUtil.logErr("Caught exception getGroupRestriction: " + e); } if (!pass1 || !pass2 || !pass3) { - throw new Fault("getResultType test failed"); + throw new Exception("getResultType test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/parameter/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/parameter/Client.java index 100a70d832..399ecdfa24 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/parameter/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/parameter/Client.java @@ -41,26 +41,26 @@ public class Client extends PMClientBase { final java.sql.Date d1 = getSQLDate("2000-02-14"); - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } public void setupEmployee(String[] args, Properties p) throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -201,7 +201,7 @@ public void parameterTest1() throws Exception { if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 || !pass8 || !pass9) { - throw new Fault("parameterTest1 test failed"); + throw new Exception("parameterTest1 test failed"); } @@ -278,7 +278,7 @@ public void parameterTest2() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("parameterTest2 test failed"); + throw new Exception("parameterTest2 test failed"); } } @@ -355,7 +355,7 @@ public void parameterTest3() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("parameterTest3 test failed"); + throw new Exception("parameterTest3 test failed"); } } @@ -424,7 +424,7 @@ public void parameterTest4() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("parameterTest4 test failed"); + throw new Exception("parameterTest4 test failed"); } @@ -493,7 +493,7 @@ public void parameterExpressionInObjectArrayTest() throws Exception { } if (!pass) { - throw new Fault("parameterExpressionInObjectArrayTest test failed"); + throw new Exception("parameterExpressionInObjectArrayTest test failed"); } } @@ -562,7 +562,7 @@ public void parameterExpressionInExpressionArrayTest() throws Exception { } if (!pass) { - throw new Fault("parameterExpressionInExpressionArrayTest test failed"); + throw new Exception("parameterExpressionInExpressionArrayTest test failed"); } } @@ -632,7 +632,7 @@ public void parameterExpressionInCollectionTest() throws Exception { } if (!pass) { - throw new Fault("parameterExpressionInCollectionTest test failed"); + throw new Exception("parameterExpressionInCollectionTest test failed"); } } @@ -700,7 +700,7 @@ public void parameterExpressionInExpressionTest() throws Exception { } if (!pass) { - throw new Fault("parameterExpressionInExpressionTest test failed"); + throw new Exception("parameterExpressionInExpressionTest test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/Client.java index 4ec1aaf892..ab41a90f1e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/Client.java @@ -20,7 +20,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Properties; import java.util.Set; import com.sun.ts.lib.harness.SetupMethod; @@ -56,14 +55,14 @@ public class Client extends Util { /* Test setup */ - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -115,7 +114,7 @@ public void queryTest1() throws Exception { } if (!pass) { - throw new Fault("queryTest1 failed"); + throw new Exception("queryTest1 failed"); } } @@ -163,7 +162,7 @@ public void queryTest2() throws Exception { } if (!pass) { - throw new Fault("queryTest2 failed"); + throw new Exception("queryTest2 failed"); } } @@ -213,7 +212,7 @@ public void queryTest3() throws Exception { } if (!pass) { - throw new Fault("queryTest3 failed"); + throw new Exception("queryTest3 failed"); } } @@ -270,7 +269,7 @@ public void queryTest4() throws Exception { } if (!pass) { - throw new Fault("queryTest4 failed"); + throw new Exception("queryTest4 failed"); } } @@ -328,7 +327,7 @@ public void queryTest5() throws Exception { } if (!pass) { - throw new Fault("queryTest5 failed"); + throw new Exception("queryTest5 failed"); } } @@ -391,7 +390,7 @@ public void queryTest6() throws Exception { } if (!pass) { - throw new Fault("queryTest6 failed"); + throw new Exception("queryTest6 failed"); } } @@ -436,7 +435,7 @@ public void queryTest7() throws Exception { } if (!pass) { - throw new Fault("queryTest7 failed"); + throw new Exception("queryTest7 failed"); } } @@ -487,7 +486,7 @@ public void queryTest8() throws Exception { } if (!pass) { - throw new Fault("queryTest8 failed"); + throw new Exception("queryTest8 failed"); } } @@ -542,7 +541,7 @@ public void queryTest9() throws Exception { } if (!pass) { - throw new Fault("queryTest9 failed"); + throw new Exception("queryTest9 failed"); } } @@ -610,7 +609,7 @@ public void queryTest10() throws Exception { } if (!pass) { - throw new Fault("queryTest10 failed"); + throw new Exception("queryTest10 failed"); } } @@ -663,7 +662,7 @@ public void queryTest11() throws Exception { } if (!pass) { - throw new Fault("queryTest11 failed"); + throw new Exception("queryTest11 failed"); } } @@ -716,7 +715,7 @@ public void queryTest12() throws Exception { } if (!pass) { - throw new Fault("queryTest12 failed"); + throw new Exception("queryTest12 failed"); } } @@ -778,7 +777,7 @@ public void queryTest13() throws Exception { } if (!pass) { - throw new Fault("queryTest13 failed"); + throw new Exception("queryTest13 failed"); } } @@ -835,7 +834,7 @@ public void queryTest14() throws Exception { } if (!pass) { - throw new Fault("queryTest14 failed"); + throw new Exception("queryTest14 failed"); } } @@ -882,7 +881,7 @@ public void queryTest15() throws Exception { } if (!pass) { - throw new Fault("queryTest15 failed"); + throw new Exception("queryTest15 failed"); } } @@ -928,7 +927,7 @@ public void queryTest16() throws Exception { } if (!pass) { - throw new Fault("queryTest16 failed"); + throw new Exception("queryTest16 failed"); } } @@ -991,7 +990,7 @@ public void queryTest17() throws Exception { } if (!pass) { - throw new Fault("queryTest17 failed"); + throw new Exception("queryTest17 failed"); } } @@ -1039,7 +1038,7 @@ public void queryTest18() throws Exception { } if (!pass) { - throw new Fault("queryTest18 failed"); + throw new Exception("queryTest18 failed"); } } @@ -1104,7 +1103,7 @@ public void queryTest19() throws Exception { } if (!pass) { - throw new Fault("queryTest19 failed"); + throw new Exception("queryTest19 failed"); } } @@ -1158,7 +1157,7 @@ public void queryTest20() throws Exception { } if (!pass) { - throw new Fault("queryTest20 failed"); + throw new Exception("queryTest20 failed"); } } @@ -1216,7 +1215,7 @@ public void queryTest21() throws Exception { } if (!pass) { - throw new Fault("queryTest21 failed"); + throw new Exception("queryTest21 failed"); } } @@ -1262,7 +1261,7 @@ public void queryTest22() throws Exception { } if (!pass) { - throw new Fault("queryTest22 failed"); + throw new Exception("queryTest22 failed"); } } @@ -1328,7 +1327,7 @@ public void queryTest23() throws Exception { } if (!pass) { - throw new Fault("queryTest23 failed"); + throw new Exception("queryTest23 failed"); } } @@ -1376,7 +1375,7 @@ public void queryTest24() throws Exception { } if (!pass) { - throw new Fault("queryTest24 failed"); + throw new Exception("queryTest24 failed"); } } @@ -1429,7 +1428,7 @@ public void queryTest25() throws Exception { } if (!pass) { - throw new Fault("queryTest25 failed"); + throw new Exception("queryTest25 failed"); } } @@ -1483,7 +1482,7 @@ public void queryTest26() throws Exception { } if (!pass) { - throw new Fault("queryTest26 failed"); + throw new Exception("queryTest26 failed"); } } @@ -1539,7 +1538,7 @@ public void queryTest27() throws Exception { } if (!pass) { - throw new Fault("queryTest27 failed"); + throw new Exception("queryTest27 failed"); } } @@ -1589,7 +1588,7 @@ public void queryTest28() throws Exception { } if (!pass) { - throw new Fault("queryTest28 failed"); + throw new Exception("queryTest28 failed"); } } @@ -1637,7 +1636,7 @@ public void queryTest29() throws Exception { } if (!pass) { - throw new Fault("queryTest29 failed"); + throw new Exception("queryTest29 failed"); } } @@ -1686,7 +1685,7 @@ public void queryTest30() throws Exception { } if (!pass) { - throw new Fault("queryTest30 failed"); + throw new Exception("queryTest30 failed"); } } @@ -1736,7 +1735,7 @@ public void queryTest31() throws Exception { } if (!pass) { - throw new Fault("queryTest31 failed"); + throw new Exception("queryTest31 failed"); } } @@ -1787,7 +1786,7 @@ public void queryTest32() throws Exception { } if (!pass) { - throw new Fault("queryTest32 failed"); + throw new Exception("queryTest32 failed"); } } @@ -1859,7 +1858,7 @@ public void queryTest33() throws Exception { } if (!pass) { - throw new Fault("queryTest33 failed"); + throw new Exception("queryTest33 failed"); } } @@ -1909,7 +1908,7 @@ public void queryTest34() throws Exception { } if (!pass) { - throw new Fault("queryTest34 failed"); + throw new Exception("queryTest34 failed"); } } @@ -1966,7 +1965,7 @@ public void queryTest35() throws Exception { } if (!pass) { - throw new Fault("queryTest35 failed"); + throw new Exception("queryTest35 failed"); } } @@ -2015,7 +2014,7 @@ public void queryTest36() throws Exception { } if (!pass) { - throw new Fault("queryTest36 failed"); + throw new Exception("queryTest36 failed"); } } @@ -2097,7 +2096,7 @@ public void queryTest37() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest37 failed"); + throw new Exception("queryTest37 failed"); } } @@ -2145,7 +2144,7 @@ public void queryTest38() throws Exception { } if (!pass) { - throw new Fault("queryTest38 failed"); + throw new Exception("queryTest38 failed"); } } @@ -2198,7 +2197,7 @@ public void queryTest39() throws Exception { } if (!pass) { - throw new Fault("queryTest39 failed"); + throw new Exception("queryTest39 failed"); } } @@ -2289,7 +2288,7 @@ public void queryTest40() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest40 failed"); + throw new Exception("queryTest40 failed"); } } @@ -2425,7 +2424,7 @@ public void queryTest41() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest41 failed"); + throw new Exception("queryTest41 failed"); } } @@ -2492,7 +2491,7 @@ public void queryTest42() throws Exception { } if (!pass) { - throw new Fault("queryTest42 failed"); + throw new Exception("queryTest42 failed"); } } @@ -2543,7 +2542,7 @@ public void queryTest43() throws Exception { } if (!pass) { - throw new Fault("queryTest43 failed"); + throw new Exception("queryTest43 failed"); } } @@ -2592,7 +2591,7 @@ public void queryTest44() throws Exception { } if (!pass) { - throw new Fault("queryTest44 failed"); + throw new Exception("queryTest44 failed"); } } @@ -2658,7 +2657,7 @@ public void queryTest45() throws Exception { } if (!pass) { - throw new Fault("queryTest45 failed"); + throw new Exception("queryTest45 failed"); } } @@ -2702,7 +2701,7 @@ public void queryTest47() throws Exception { } if (!pass) { - throw new Fault("queryTest47 failed"); + throw new Exception("queryTest47 failed"); } } @@ -2749,7 +2748,7 @@ public void queryTest48() throws Exception { } if (!pass) { - throw new Fault("queryTest48 failed"); + throw new Exception("queryTest48 failed"); } } @@ -2810,7 +2809,7 @@ public void queryTest49() throws Exception { } if (!pass) { - throw new Fault("queryTest49 failed"); + throw new Exception("queryTest49 failed"); } } @@ -2861,7 +2860,7 @@ public void queryTest50() throws Exception { } if (!pass) { - throw new Fault("queryTest50 failed"); + throw new Exception("queryTest50 failed"); } } @@ -2907,7 +2906,7 @@ public void queryTest51() throws Exception { } if (!pass) { - throw new Fault("queryTest51 failed"); + throw new Exception("queryTest51 failed"); } } @@ -2956,7 +2955,7 @@ public void queryTest52() throws Exception { } if (!pass) { - throw new Fault("queryTest52 failed"); + throw new Exception("queryTest52 failed"); } } @@ -3021,7 +3020,7 @@ public void queryTest53() throws Exception { } if (!pass) { - throw new Fault("queryTest53 failed"); + throw new Exception("queryTest53 failed"); } } @@ -3066,7 +3065,7 @@ public void queryTest54() throws Exception { } if (!pass) { - throw new Fault("queryTest54 failed"); + throw new Exception("queryTest54 failed"); } } @@ -3120,7 +3119,7 @@ public void queryTest55() throws Exception { } if (!pass) { - throw new Fault("queryTest55 failed"); + throw new Exception("queryTest55 failed"); } } @@ -3194,7 +3193,7 @@ public void queryTest56() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest56 failed"); + throw new Exception("queryTest56 failed"); } } @@ -3236,7 +3235,7 @@ public void queryTest58() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest58 failed"); + throw new Exception("queryTest58 failed"); } } @@ -3283,7 +3282,7 @@ public void queryTest59() throws Exception { } if (!pass) { - throw new Fault("queryTest59 failed"); + throw new Exception("queryTest59 failed"); } } @@ -3350,7 +3349,7 @@ public void queryTest60() throws Exception { } if (!pass) { - throw new Fault("queryTest60 failed"); + throw new Exception("queryTest60 failed"); } } @@ -3401,7 +3400,7 @@ public void queryTest61() throws Exception { } if (!pass) { - throw new Fault("queryTest61 failed"); + throw new Exception("queryTest61 failed"); } } @@ -3452,7 +3451,7 @@ public void queryTest62() throws Exception { } if (!pass) { - throw new Fault("queryTest62 failed"); + throw new Exception("queryTest62 failed"); } } @@ -3503,7 +3502,7 @@ public void queryTest63() throws Exception { } if (!pass) { - throw new Fault("queryTest63 failed"); + throw new Exception("queryTest63 failed"); } } @@ -3574,7 +3573,7 @@ public void queryTest64() throws Exception { } if (!pass) { - throw new Fault("queryTest64 failed"); + throw new Exception("queryTest64 failed"); } } @@ -3618,7 +3617,7 @@ public void queryTest65() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest65 failed"); + throw new Exception("queryTest65 failed"); } } @@ -3659,7 +3658,7 @@ public void queryTest66() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest66 failed"); + throw new Exception("queryTest66 failed"); } } @@ -3701,7 +3700,7 @@ public void queryTest67() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest67 failed"); + throw new Exception("queryTest67 failed"); } } @@ -3742,7 +3741,7 @@ public void queryTest68() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest68 failed"); + throw new Exception("queryTest68 failed"); } } @@ -3802,7 +3801,7 @@ public void queryTest69() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryTest69 failed"); + throw new Exception("queryTest69 failed"); } } @@ -3844,7 +3843,7 @@ public void queryTest70() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest70 failed"); + throw new Exception("queryTest70 failed"); } } @@ -3882,7 +3881,7 @@ public void queryTest71() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("queryTest71 failed"); + throw new Exception("queryTest71 failed"); } } @@ -3931,7 +3930,7 @@ public void test_leftouterjoin_1xM() throws Exception { } if (!pass) { - throw new Fault("test_leftouterjoin_1xM failed"); + throw new Exception("test_leftouterjoin_1xM failed"); } } @@ -4011,7 +4010,7 @@ public void test_leftouterjoin_Mx1() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("test_leftouterjoin_Mx1 failed"); + throw new Exception("test_leftouterjoin_Mx1 failed"); } } @@ -4089,7 +4088,7 @@ public void test_leftouterjoin_MxM() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("test_leftouterjoin_MxM failed"); + throw new Exception("test_leftouterjoin_MxM failed"); } } @@ -4138,7 +4137,7 @@ public void test_upperStringExpression() throws Exception { } if (!pass) { - throw new Fault("test_upperStringExpression failed"); + throw new Exception("test_upperStringExpression failed"); } } @@ -4187,7 +4186,7 @@ public void test_lowerStringExpression() throws Exception { } if (!pass) { - throw new Fault("test_lowerStringExpression failed"); + throw new Exception("test_lowerStringExpression failed"); } } @@ -4237,7 +4236,7 @@ public void test_groupBy() throws Exception { } if (!pass) { - throw new Fault("test_groupBy failed"); + throw new Exception("test_groupBy failed"); } } @@ -4286,7 +4285,7 @@ public void test_groupBy_1() throws Exception { } if (!pass) { - throw new Fault("test_groupBy_1 failed"); + throw new Exception("test_groupBy_1 failed"); } } @@ -4335,7 +4334,7 @@ public void test_innerjoin_1x1() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_1x1 failed"); + throw new Exception("test_innerjoin_1x1 failed"); } } @@ -4388,7 +4387,7 @@ public void test_innerjoin_1xM() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_1xM failed"); + throw new Exception("test_innerjoin_1xM failed"); } } @@ -4439,7 +4438,7 @@ public void test_innerjoin_Mx1() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_Mx1 failed"); + throw new Exception("test_innerjoin_Mx1 failed"); } } @@ -4488,7 +4487,7 @@ public void test_innerjoin_MxM() throws Exception { } if (!pass) { - throw new Fault("test_innerjoin_MxM failed"); + throw new Exception("test_innerjoin_MxM failed"); } } @@ -4538,7 +4537,7 @@ public void test_fetchjoin_1x1() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_1x1 failed"); + throw new Exception("test_fetchjoin_1x1 failed"); } } @@ -4586,7 +4585,7 @@ public void test_fetchjoin_1xM() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_1xM failed"); + throw new Exception("test_fetchjoin_1xM failed"); } } @@ -4632,7 +4631,7 @@ public void test_fetchjoin_Mx1() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_Mx1 failed"); + throw new Exception("test_fetchjoin_Mx1 failed"); } } @@ -4680,7 +4679,7 @@ public void test_fetchjoin_Mx1_1() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_Mx1_1 failed"); + throw new Exception("test_fetchjoin_Mx1_1 failed"); } } @@ -4729,7 +4728,7 @@ public void test_fetchjoin_MxM() throws Exception { } if (!pass) { - throw new Fault("test_fetchjoin_MxM failed"); + throw new Exception("test_fetchjoin_MxM failed"); } } @@ -4792,7 +4791,7 @@ public void test_betweenDates() throws Exception { } if (!pass) - throw new Fault("test_betweenDates failed"); + throw new Exception("test_betweenDates failed"); } /* @@ -4851,7 +4850,7 @@ public void test_notBetweenArithmetic() throws Exception { } if (!pass) { - throw new Fault("test_notBetweenArithmetic failed"); + throw new Exception("test_notBetweenArithmetic failed"); } } @@ -4905,7 +4904,7 @@ public void test_notBetweenDates() throws Exception { } if (!pass) - throw new Fault("test_notBetweenDates failed"); + throw new Exception("test_notBetweenDates failed"); } /* @@ -4951,7 +4950,7 @@ public void test_ANDconditionTT() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionTT failed"); + throw new Exception("test_ANDconditionTT failed"); } } @@ -4995,7 +4994,7 @@ public void test_ANDconditionTF() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionTF failed"); + throw new Exception("test_ANDconditionTF failed"); } } @@ -5039,7 +5038,7 @@ public void test_ANDconditionFT() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionFT failed"); + throw new Exception("test_ANDconditionFT failed"); } } @@ -5084,7 +5083,7 @@ public void test_ANDconditionFF() throws Exception { } if (!pass) { - throw new Fault("test_ANDconditionFF failed"); + throw new Exception("test_ANDconditionFF failed"); } } @@ -5135,7 +5134,7 @@ public void test_ORconditionTT() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionTT failed"); + throw new Exception("test_ORconditionTT failed"); } } @@ -5184,7 +5183,7 @@ public void test_ORconditionTF() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionTF failed"); + throw new Exception("test_ORconditionTF failed"); } } @@ -5238,7 +5237,7 @@ public void test_ORconditionFT() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionFT failed"); + throw new Exception("test_ORconditionFT failed"); } } @@ -5283,7 +5282,7 @@ public void test_ORconditionFF() throws Exception { } if (!pass) { - throw new Fault("test_ORconditionFF failed"); + throw new Exception("test_ORconditionFF failed"); } } @@ -5332,7 +5331,7 @@ public void test_groupByWhereClause() throws Exception { } if (!pass) { - throw new Fault("test_groupByWhereClause failed"); + throw new Exception("test_groupByWhereClause failed"); } } @@ -5391,7 +5390,7 @@ public void test_groupByHaving() throws Exception { } if (!pass) { - throw new Fault("test_groupByHaving failed"); + throw new Exception("test_groupByHaving failed"); } } @@ -5444,7 +5443,7 @@ public void test_substringHavingClause() throws Exception { } if (!pass) { - throw new Fault(" test_substringHavingClause failed"); + throw new Exception(" test_substringHavingClause failed"); } } @@ -5492,7 +5491,7 @@ public void test_concatHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_concatHavingClause failed"); + throw new Exception("test_concatHavingClause failed"); } } @@ -5542,7 +5541,7 @@ public void test_lowerHavingClause() throws Exception { } if (!pass) { - throw new Fault(" test_lowerHavingClause failed"); + throw new Exception(" test_lowerHavingClause failed"); } } @@ -5593,7 +5592,7 @@ public void test_upperHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_upperHavingClause failed"); + throw new Exception("test_upperHavingClause failed"); } } @@ -5648,7 +5647,7 @@ public void test_lengthHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_lengthHavingClause failed"); + throw new Exception("test_lengthHavingClause failed"); } } @@ -5697,7 +5696,7 @@ public void test_locateHavingClause() throws Exception { } if (!pass) { - throw new Fault(" test_locateHavingClause failed"); + throw new Exception(" test_locateHavingClause failed"); } } @@ -5741,7 +5740,7 @@ public void test_locateHavingClause() throws Exception { * getEntityTransaction().commit(); } catch (Exception e) { * TestUtil.logErr("Caught unexpected exception", e); } * - * if (!pass) { throw new Fault(" test_trimHavingClause_01 failed"); } } + * if (!pass) { throw new Exception(" test_trimHavingClause_01 failed"); } } */ /* @@ -5785,7 +5784,7 @@ public void test_locateHavingClause() throws Exception { * getEntityTransaction().commit(); } catch (Exception e) { * TestUtil.logErr("Caught unexpected exception", e); } * - * if (!pass) { throw new Fault("test_trimHavingClause_02 failed"); } } + * if (!pass) { throw new Exception("test_trimHavingClause_02 failed"); } } */ /* @@ -5832,7 +5831,7 @@ public void test_locateHavingClause() throws Exception { * getEntityTransaction().commit(); } catch (Exception e) { * TestUtil.logErr("Caught unexpected exception", e); } * - * if (!pass) { throw new Fault("test_trimHavingClause_03 failed"); } } + * if (!pass) { throw new Exception("test_trimHavingClause_03 failed"); } } */ /* @@ -5875,7 +5874,7 @@ public void test_ABSHavingClause() throws Exception { } if (!pass) { - throw new Fault("test_ABSHavingClause failed"); + throw new Exception("test_ABSHavingClause failed"); } } @@ -5921,7 +5920,7 @@ public void test_SQRTWhereClause() throws Exception { } if (!pass) { - throw new Fault(" test_SQRTWhereClause failed"); + throw new Exception(" test_SQRTWhereClause failed"); } } @@ -5973,7 +5972,7 @@ public void test_subquery_exists_01() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_exists_01 failed"); + throw new Exception(" test_subquery_exists_01 failed"); } } @@ -6027,7 +6026,7 @@ public void test_subquery_exists_02() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_exists_02 failed"); + throw new Exception(" test_subquery_exists_02 failed"); } } @@ -6078,7 +6077,7 @@ public void test_subquery_like() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_like failed"); + throw new Exception(" test_subquery_like failed"); } } @@ -6162,7 +6161,7 @@ public void test_subquery_in() throws Exception { } if (!pass) { - throw new Fault("test_subquery_in failed"); + throw new Exception("test_subquery_in failed"); } } @@ -6237,7 +6236,7 @@ public void fromIsCorrelatedTest() throws Exception { } if (!pass) { - throw new Fault("fromIsCorrelatedTest failed"); + throw new Exception("fromIsCorrelatedTest failed"); } } @@ -6291,7 +6290,7 @@ public void test_subquery_between() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_between failed"); + throw new Exception(" test_subquery_between failed"); } } @@ -6347,7 +6346,7 @@ public void test_subquery_join() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_join failed"); + throw new Exception(" test_subquery_join failed"); } } @@ -6402,7 +6401,7 @@ public void test_subquery_ALL_GT() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_ALL_GT failed"); + throw new Exception(" test_subquery_ALL_GT failed"); } } @@ -6453,7 +6452,7 @@ public void test_subquery_ALL_LT() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_LT failed"); + throw new Exception("test_subquery_ALL_LT failed"); } } @@ -6504,7 +6503,7 @@ public void test_subquery_ALL_EQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_EQ failed"); + throw new Exception("test_subquery_ALL_EQ failed"); } } @@ -6559,7 +6558,7 @@ public void test_subquery_ALL_LTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_LTEQ failed"); + throw new Exception("test_subquery_ALL_LTEQ failed"); } } @@ -6612,7 +6611,7 @@ public void test_subquery_ALL_GTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_GTEQ failed"); + throw new Exception("test_subquery_ALL_GTEQ failed"); } } @@ -6679,7 +6678,7 @@ public void test_subquery_ALL_NOTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ALL_NOTEQ failed"); + throw new Exception("test_subquery_ALL_NOTEQ failed"); } } @@ -6746,7 +6745,7 @@ public void test_subquery_ANY_GT() throws Exception { TestUtil.logErr("Caught unexpected exception", e); } if (!pass) { - throw new Fault("test_subquery_ANY_GT failed"); + throw new Exception("test_subquery_ANY_GT failed"); } } @@ -6815,7 +6814,7 @@ public void test_subquery_ANY_LT() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ANY_LT failed"); + throw new Exception("test_subquery_ANY_LT failed"); } } @@ -6868,7 +6867,7 @@ public void test_subquery_ANY_EQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_ANY_EQ failed"); + throw new Exception("test_subquery_ANY_EQ failed"); } } @@ -6938,7 +6937,7 @@ public void test_subquery_SOME_LTEQ() throws Exception { } if (!pass) { - throw new Fault(" test_subquery_SOME_LTEQ failed"); + throw new Exception(" test_subquery_SOME_LTEQ failed"); } } @@ -7009,7 +7008,7 @@ public void test_subquery_SOME_GTEQ() throws Exception { } if (!pass) { - throw new Fault("test_subquery_SOME_GTEQ failed"); + throw new Exception("test_subquery_SOME_GTEQ failed"); } } @@ -7094,7 +7093,7 @@ public void joinTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("joinTest failed"); + throw new Exception("joinTest failed"); } } @@ -7143,7 +7142,7 @@ public void fetchStringTest() throws Exception { } if (!pass) { - throw new Fault("fetchStringTest failed"); + throw new Exception("fetchStringTest failed"); } } @@ -7217,7 +7216,7 @@ public void fetchStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("fetchStringJoinTypeTest failed"); + throw new Exception("fetchStringJoinTypeTest failed"); } } @@ -7264,7 +7263,7 @@ public void fetchStringAndStringJoinTypeIllegalArgumentException() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "fetchStringAndStringJoinTypeIllegalArgumentException failed"); } } @@ -7312,7 +7311,7 @@ public void isNullOneToOneTest() throws Exception { } if (!pass) { - throw new Fault("isNullOneToOneTest failed"); + throw new Exception("isNullOneToOneTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1a/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1a/Client.java index 67f3f12a04..4c82be3fba 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1a/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1a/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex1a; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -118,7 +111,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DTDTest failed"); + throw new Exception("DTDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1b/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1b/Client.java index 2aad84db4e..a576787e83 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1b/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex1b/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex1b; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -114,7 +107,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2a/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2a/Client.java index e7fb0d06b8..1c07d2abef 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2a/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2a/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex2a; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -115,7 +108,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2b/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2b/Client.java index b41aa205ea..5e095837a1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2b/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex2b/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex2b; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -132,7 +125,7 @@ public void DIDTest() throws Exception { } if (!(pass1 && pass2)) { - throw new Fault("DTDTest failed"); + throw new Exception("DTDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3a/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3a/Client.java index 6660168e4a..9afa8899c4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3a/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3a/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex3a; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -117,7 +110,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DTDTest failed"); + throw new Exception("DTDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3b/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3b/Client.java index 51dd01bef8..bdb00e9572 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3b/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex3b/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex3b; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -144,7 +137,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4a/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4a/Client.java index df95b9b698..d865d72a4f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4a/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4a/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex4a; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -108,7 +101,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DTDTest failed"); + throw new Exception("DTDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4b/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4b/Client.java index 544f7f2b43..4bd8cad531 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4b/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex4b/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex4b; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -111,7 +104,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DTDTest failed"); + throw new Exception("DTDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5a/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5a/Client.java index 2e63e10e70..713bd387bc 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5a/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5a/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex5a; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -111,7 +104,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5b/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5b/Client.java index 56781a4c4e..73f1548120 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5b/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex5b/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex5b; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -131,7 +124,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6a/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6a/Client.java index 0401d9e602..b5a28537e7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6a/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6a/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex6a; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -111,7 +104,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6b/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6b/Client.java index 1dfeb38f5f..15a95f3064 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6b/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/derivedid/ex6b/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.derivedid.ex6b; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -132,7 +125,7 @@ public void DIDTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/Client.java index 898b9032d0..797d5cf26d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -23,7 +23,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -66,30 +69,23 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* + /* * setup() is called before each test * * @class.setup_props: jdbc.db; */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); - dataBaseName = p.getProperty("jdbc.db"); + dataBaseName = System.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -98,20 +94,20 @@ public void setup(String[] args, Properties p) throws Exception { * * @class.setup_props: jdbc.db; */ - public void setupOrderData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupOrderData() throws Exception { TestUtil.logTrace("setupOrderData"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createOrderData(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); - dataBaseName = p.getProperty("jdbc.db"); + dataBaseName = System.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -120,28 +116,30 @@ public void setupOrderData(String[] args, Properties p) throws Exception { * * @class.setup_props: jdbc.db; */ - public void setupEmployeeData(String[] args, Properties p) throws Exception { + @Test + public void setupEmployeeData() throws Exception { TestUtil.logTrace("setupOrderData"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createEmployeeData(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); - dataBaseName = p.getProperty("jdbc.db"); + dataBaseName = System.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); } + @AfterEach public void cleanupData() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -285,6 +283,7 @@ public boolean verifyListEmployees(List expected, * @test_Strategy: Create EntityManager in try with resources block * and verify whether it's open inside and outside of the try block. */ + @Test public void autoCloseableTest() throws Exception { EntityManager em = null; try (final EntityManagerFactory emfLocal @@ -292,20 +291,20 @@ public void autoCloseableTest() throws Exception { try (final EntityManager emLocal = emfLocal.createEntityManager()) { em = emLocal; if (em == null) { - throw new Fault("autoCloseableTest failed: createEntityManager() returned null"); + throw new Exception("autoCloseableTest failed: createEntityManager() returned null"); } if (!em.isOpen()) { - throw new Fault("autoCloseableTest failed: EntityManager isOpen() returned false in try block"); + throw new Exception("autoCloseableTest failed: EntityManager isOpen() returned false in try block"); } } finally { if (em != null && em.isOpen()) { - throw new Fault("autoCloseableTest failed: EntityManager isOpen() returned true outside try block"); + throw new Exception("autoCloseableTest failed: EntityManager isOpen() returned true outside try block"); } } - } catch (Fault f) { + } catch (Exception f) { throw f; } catch (Throwable t) { - throw new Fault("autoCloseableTest failed with Exception", t); + throw new Exception("autoCloseableTest failed with Exception", t); } } @@ -316,6 +315,7 @@ public void autoCloseableTest() throws Exception { * * @test_Strategy: Merge new entity */ + @Test public void mergeTest() throws Exception { boolean pass = false; @@ -337,7 +337,7 @@ public void mergeTest() throws Exception { } if (!pass) { - throw new Fault("mergeTest failed"); + throw new Exception("mergeTest failed"); } } @@ -348,6 +348,7 @@ public void mergeTest() throws Exception { * * @test_Strategy: Call EntityManager.merge() method */ + @Test public void mergeExceptionsTest() throws Exception { boolean pass = false; @@ -401,7 +402,7 @@ public void mergeExceptionsTest() throws Exception { } if (!pass) { - throw new Fault("mergeExceptionsTest failed"); + throw new Exception("mergeExceptionsTest failed"); } } @@ -415,6 +416,7 @@ public void mergeExceptionsTest() throws Exception { */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void persistExceptionsTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -468,7 +470,7 @@ public void persistExceptionsTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("persistExceptionsTest failed"); + throw new Exception("persistExceptionsTest failed"); } } @@ -479,6 +481,7 @@ public void persistExceptionsTest() throws Exception { * * @test_Strategy: Call EntityManager.remove() method */ + @Test public void removeExceptionsTest() throws Exception { boolean pass = false; TestUtil.logMsg("Testing findClassObjectIllegalStateException"); @@ -504,7 +507,7 @@ public void removeExceptionsTest() throws Exception { } } if (!pass) { - throw new Fault("removeExceptionsTest failed"); + throw new Exception("removeExceptionsTest failed"); } } @@ -515,6 +518,7 @@ public void removeExceptionsTest() throws Exception { * * @test_Strategy: Call EntityManager.lock() method */ + @Test public void lockIllegalStateExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -565,7 +569,7 @@ public void lockIllegalStateExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("lockIllegalStateExceptionTest failed"); + throw new Exception("lockIllegalStateExceptionTest failed"); } } @@ -576,6 +580,7 @@ public void lockIllegalStateExceptionTest() throws Exception { * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshInvalidObjectIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -600,7 +605,7 @@ public void refreshInvalidObjectIllegalArgumentExceptionTest() throws Exception } if (!pass) { - throw new Fault( + throw new Exception( "refreshInvalidObjectIllegalArgumentExceptionTest failed"); } } @@ -612,6 +617,7 @@ public void refreshInvalidObjectIllegalArgumentExceptionTest() throws Exception * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshNonManagedObjectIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -637,7 +643,7 @@ public void refreshNonManagedObjectIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshNonManagedObjectIllegalArgumentExceptionTest failed"); } } @@ -651,6 +657,7 @@ public void refreshNonManagedObjectIllegalArgumentExceptionTest() */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void refreshRemovedObjectEntityNotFoundExceptionTest() throws Exception { boolean pass = false; try { @@ -680,7 +687,7 @@ public void refreshRemovedObjectEntityNotFoundExceptionTest() throws Exception { } if (!pass) { - throw new Fault("refreshRemovedObjectEntityNotFoundExceptionTest failed"); + throw new Exception("refreshRemovedObjectEntityNotFoundExceptionTest failed"); } } @@ -691,6 +698,7 @@ public void refreshRemovedObjectEntityNotFoundExceptionTest() throws Exception { * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshInvalidObjectMapIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -717,7 +725,7 @@ public void refreshInvalidObjectMapIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshInvalidObjectMapIllegalArgumentExceptionTest failed"); } } @@ -729,6 +737,7 @@ public void refreshInvalidObjectMapIllegalArgumentExceptionTest() * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshNonManagedObjectMapIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -755,7 +764,7 @@ public void refreshNonManagedObjectMapIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshNonManagedObjectMapIllegalArgumentExceptionTest failed"); } } @@ -769,6 +778,7 @@ public void refreshNonManagedObjectMapIllegalArgumentExceptionTest() */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void refreshRemovedObjectMapEntityNotFoundExceptionTest() throws Exception { boolean pass = false; @@ -800,7 +810,7 @@ public void refreshRemovedObjectMapEntityNotFoundExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshRemovedObjectMapEntityNotFoundExceptionTest failed"); } } @@ -812,6 +822,7 @@ public void refreshRemovedObjectMapEntityNotFoundExceptionTest() * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshInvalidObjectLockModeTypeIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -836,7 +847,7 @@ public void refreshInvalidObjectLockModeTypeIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshInvalidObjectLockModeTypeIllegalArgumentExceptionTest failed"); } } @@ -848,6 +859,7 @@ public void refreshInvalidObjectLockModeTypeIllegalArgumentExceptionTest() * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshNonManagedObjectLockModeTypeIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -872,7 +884,7 @@ public void refreshNonManagedObjectLockModeTypeIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshNonManagedObjectLockModeTypeIllegalArgumentExceptionTest failed"); } } @@ -886,6 +898,7 @@ public void refreshNonManagedObjectLockModeTypeIllegalArgumentExceptionTest() */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void refreshRemovedObjectLockModeTypeEntityNotFoundExceptionTest() throws Exception { boolean pass = false; @@ -917,7 +930,7 @@ public void refreshRemovedObjectLockModeTypeEntityNotFoundExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshRemovedObjectLockModeTypeEntityNotFoundExceptionTest failed"); } } @@ -929,6 +942,7 @@ public void refreshRemovedObjectLockModeTypeEntityNotFoundExceptionTest() * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshInvalidObjectLockModeTypeMapIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -955,7 +969,7 @@ public void refreshInvalidObjectLockModeTypeMapIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshInvalidObjectLockModeTypeMapIllegalArgumentExceptionTest failed"); } } @@ -968,6 +982,7 @@ public void refreshInvalidObjectLockModeTypeMapIllegalArgumentExceptionTest() * * @test_Strategy: Call EntityManager.refresh() method */ + @Test public void refreshNonManagedObjectLockModeTypeMapIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -994,7 +1009,7 @@ public void refreshNonManagedObjectLockModeTypeMapIllegalArgumentExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshNonManagedObjectLockModeTypeMapIllegalArgumentExceptionTest failed"); } } @@ -1008,6 +1023,7 @@ public void refreshNonManagedObjectLockModeTypeMapIllegalArgumentExceptionTest() */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void refreshRemovedObjectLockModeTypeMapEntityNotFoundExceptionTest() throws Exception { boolean pass = false; @@ -1040,7 +1056,7 @@ public void refreshRemovedObjectLockModeTypeMapEntityNotFoundExceptionTest() } if (!pass) { - throw new Fault( + throw new Exception( "refreshRemovedObjectLockModeTypeMapEntityNotFoundExceptionTest failed"); } } @@ -1053,6 +1069,7 @@ public void refreshRemovedObjectLockModeTypeMapEntityNotFoundExceptionTest() * @test_Strategy: Call EntityManager.contains() method passing an Object that * is not an Entity */ + @Test public void containsIllegalArgumentException() throws Exception { boolean pass = false; @@ -1078,7 +1095,7 @@ public void containsIllegalArgumentException() throws Exception { } if (!pass) { - throw new Fault("containsIllegalArgumentException failed"); + throw new Exception("containsIllegalArgumentException failed"); } } @@ -1095,6 +1112,7 @@ public void containsIllegalArgumentException() throws Exception { * type not assignable to the specified type, verify IllegalArgumentException * is thrown. */ + @Test public void createNamedQueryIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false, pass2 = false; TestUtil.logMsg("Testing TypedQuery version"); @@ -1131,7 +1149,7 @@ public void createNamedQueryIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("createNamedQueryIllegalArgumentExceptionTest failed"); + throw new Exception("createNamedQueryIllegalArgumentExceptionTest failed"); } } @@ -1149,6 +1167,7 @@ public void createNamedQueryIllegalArgumentExceptionTest() throws Exception { * EntityManager.createQuery(CriteriaQuery) with an invalid CriteriaQuery * verify IllegalArgumentException is thrown.* */ + @Test public void createQueryIllegalArgumentExceptionTest() throws Exception { boolean pass1 = false, pass2 = false, pass3 = false; TestUtil.logTrace("Testing String version"); @@ -1208,7 +1227,7 @@ public void createQueryIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("createQueryIllegalArgumentExceptionTest failed"); + throw new Exception("createQueryIllegalArgumentExceptionTest failed"); } } @@ -1220,6 +1239,7 @@ public void createQueryIllegalArgumentExceptionTest() throws Exception { * @test_Strategy: Call EntityManager.detach(String), verify * IllegalArgumentException is thrown */ + @Test public void detachIllegalArgumentExceptionTest() throws Exception { boolean pass = false; try { @@ -1242,7 +1262,7 @@ public void detachIllegalArgumentExceptionTest() throws Exception { } if (!pass) { - throw new Fault("detachIllegalArgumentExceptionTest failed"); + throw new Exception("detachIllegalArgumentExceptionTest failed"); } } @@ -1253,6 +1273,7 @@ public void detachIllegalArgumentExceptionTest() throws Exception { * * @test_Strategy: Get EntityManagerFactory */ + @Test public void getEntityManagerFactoryTest() throws Exception { boolean pass = false; try { @@ -1267,7 +1288,7 @@ public void getEntityManagerFactoryTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getEntityManagerFactoryTest failed"); + throw new Exception("getEntityManagerFactoryTest failed"); } } @@ -1279,6 +1300,7 @@ public void getEntityManagerFactoryTest() throws Exception { * @test_Strategy: Get a MetaModel Object from the EntityManager an make sure * it is not null */ + @Test public void emGetMetamodelTest() throws Exception { boolean pass = false; try { @@ -1293,7 +1315,7 @@ public void emGetMetamodelTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("emGetMetamodelTest failed"); + throw new Exception("emGetMetamodelTest failed"); } } @@ -1305,6 +1327,7 @@ public void emGetMetamodelTest() throws Exception { * @test_Strategy: Set a standard property in the EntityManager and retrieve * it. */ + @Test public void setPropertyTest() throws Exception { boolean foundKey = false; boolean foundValue = false; @@ -1366,7 +1389,7 @@ public void setPropertyTest() throws Exception { } } if (!foundKey || !foundValue) { - throw new Fault("setPropertyTest failed"); + throw new Exception("setPropertyTest failed"); } } @@ -1379,6 +1402,7 @@ public void setPropertyTest() throws Exception { * be used to create a query * */ + @Test public void getCriteriaBuilderTest() throws Exception { boolean pass = false; try { @@ -1401,7 +1425,7 @@ public void getCriteriaBuilderTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getCriteriaBuilderTest failed"); + throw new Exception("getCriteriaBuilderTest failed"); } } @@ -1413,6 +1437,7 @@ public void getCriteriaBuilderTest() throws Exception { * @test_Strategy: * */ + @Test public void isJoinedToTransactionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1435,7 +1460,7 @@ public void isJoinedToTransactionTest() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2) { - throw new Fault("isJoinedToTransactionTest failed"); + throw new Exception("isJoinedToTransactionTest failed"); } } @@ -1450,6 +1475,7 @@ public void isJoinedToTransactionTest() throws Exception { */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createStoredProcedureQueryStringTest() throws Exception { boolean pass = false; @@ -1480,7 +1506,7 @@ public void createStoredProcedureQueryStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createStoredProcedureQueryStringTest failed"); + throw new Exception("createStoredProcedureQueryStringTest failed"); } } @@ -1493,6 +1519,7 @@ public void createStoredProcedureQueryStringTest() throws Exception { * @test_Strategy: * */ + @Test public void createStoredProcedureQueryStringIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -1520,7 +1547,7 @@ public void createStoredProcedureQueryStringIllegalArgumentExceptionTest() if (!pass) { TestUtil.logErr(msg.toString()); - throw new Fault( + throw new Exception( "createStoredProcedureQueryStringIllegalArgumentExceptionTest failed"); } @@ -1536,6 +1563,7 @@ public void createStoredProcedureQueryStringIllegalArgumentExceptionTest() */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createStoredProcedureQueryStringClassArrayTest() throws Exception { boolean pass = false; getEntityTransaction().begin(); @@ -1572,7 +1600,7 @@ public void createStoredProcedureQueryStringClassArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createStoredProcedureQueryStringClassArrayTest failed"); + throw new Exception("createStoredProcedureQueryStringClassArrayTest failed"); } } @@ -1586,6 +1614,7 @@ public void createStoredProcedureQueryStringClassArrayTest() throws Exception { * @test_Strategy: * */ + @Test public void createStoredProcedureQueryStringClassArrayIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -1614,7 +1643,7 @@ public void createStoredProcedureQueryStringClassArrayIllegalArgumentExceptionTe if (!pass) { TestUtil.logErr(msg.toString()); - throw new Fault( + throw new Exception( "createStoredProcedureQueryStringClassArrayIllegalArgumentExceptionTest failed"); } @@ -1630,6 +1659,7 @@ public void createStoredProcedureQueryStringClassArrayIllegalArgumentExceptionTe */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createStoredProcedureQueryStringStringArrayTest() throws Exception { boolean pass = false; @@ -1670,7 +1700,7 @@ public void createStoredProcedureQueryStringStringArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createStoredProcedureQueryStringStringArrayTest failed"); + throw new Exception("createStoredProcedureQueryStringStringArrayTest failed"); } } @@ -1684,6 +1714,7 @@ public void createStoredProcedureQueryStringStringArrayTest() throws Exception { * @test_Strategy: * */ + @Test public void createStoredProcedureQueryStringStringArrayIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -1712,7 +1743,7 @@ public void createStoredProcedureQueryStringStringArrayIllegalArgumentExceptionT if (!pass) { TestUtil.logErr(msg.toString()); - throw new Fault( + throw new Exception( "createStoredProcedureQueryStringStringArrayIllegalArgumentExceptionTest failed"); } @@ -1731,6 +1762,7 @@ public void createStoredProcedureQueryStringStringArrayIllegalArgumentExceptionT */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createNamedStoredProcedureQueryStringTest() throws Exception { boolean pass = false; getEntityTransaction().begin(); @@ -1770,7 +1802,7 @@ public void createNamedStoredProcedureQueryStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createNamedStoredProcedureQueryStringTest failed"); + throw new Exception("createNamedStoredProcedureQueryStringTest failed"); } } @@ -1784,6 +1816,7 @@ public void createNamedStoredProcedureQueryStringTest() throws Exception { * @test_Strategy: * */ + @Test public void createNamedStoredProcedureQueryStringIllegalArgumentExceptionTest() throws Exception { boolean pass = false; @@ -1799,7 +1832,7 @@ public void createNamedStoredProcedureQueryStringIllegalArgumentExceptionTest() getEntityTransaction().rollback(); if (!pass) { - throw new Fault( + throw new Exception( "createNamedStoredProcedureQueryStringIllegalArgumentExceptionTest failed"); } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager2/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager2/Client.java index 10495e963b..240b52cbec 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager2/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager2/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,7 +20,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -56,30 +59,23 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - /* * setup() is called before each test * * @class.setup_props: jdbc.db; */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); - dataBaseName = p.getProperty("jdbc.db"); + dataBaseName = System.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -88,28 +84,30 @@ public void setup(String[] args, Properties p) throws Exception { * * @class.setup_props: jdbc.db; */ - public void setupOrderData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupOrderData() throws Exception { TestUtil.logTrace("setupOrderData"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createOrderData(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); - dataBaseName = p.getProperty("jdbc.db"); + dataBaseName = System.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); } + @AfterEach public void cleanupData() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -126,6 +124,7 @@ public void cleanupData() throws Exception { * @test_Strategy: Call EntityManager.find() method with various invalid * argument combinations and verify various exceptions are thrown */ + @Test public void findExceptionsTest() throws Exception { int pass = 0; TestUtil.logMsg("Testing findClassObjectIllegalArgumentException"); @@ -441,7 +440,7 @@ public void findExceptionsTest() throws Exception { } if (pass != 14) { - throw new Fault("findExceptionsTest failed"); + throw new Exception("findExceptionsTest failed"); } } @@ -453,6 +452,7 @@ public void findExceptionsTest() throws Exception { * @test_Strategy: Call EntityManager.flush() method with various invalid * argument combinations and verify various exceptions are thrown */ + @Test public void flushExceptionsTest() throws Exception { boolean pass = false; try { @@ -467,7 +467,7 @@ public void flushExceptionsTest() throws Exception { } if (!pass) { - throw new Fault("flushExceptionsTest failed"); + throw new Exception("flushExceptionsTest failed"); } } @@ -481,6 +481,7 @@ public void flushExceptionsTest() throws Exception { */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void lockTransactionRequiredExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -515,7 +516,7 @@ public void lockTransactionRequiredExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("lockTransactionRequiredExceptionTest failed"); + throw new Exception("lockTransactionRequiredExceptionTest failed"); } } @@ -527,6 +528,7 @@ public void lockTransactionRequiredExceptionTest() throws Exception { * @test_Strategy: Call EntityManager.contains(Class) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback1Test() throws Exception { boolean pass = false; @@ -555,7 +557,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback1Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback1Test failed"); } } @@ -568,6 +570,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback1Test() * @test_Strategy: Call EntityManager.createNamedQuery(String) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback2Test() throws Exception { boolean pass = false; @@ -597,7 +600,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback2Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback2Test failed"); } } @@ -610,6 +613,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback2Test() * @test_Strategy: Call EntityManager.createNamedQuery(String,Class) that * causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback3Test() throws Exception { boolean pass = false; @@ -640,7 +644,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback3Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback3Test failed"); } } @@ -653,6 +657,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback3Test() * @test_Strategy: Call EntityManager.createNamedStoredProcedureQuery(String) * that causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback4Test() throws Exception { boolean pass = false; @@ -682,7 +687,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback4Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback4Test failed"); } } @@ -695,6 +700,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback4Test() * @test_Strategy: Call EntityManager.createQuery(CriteriaDelete) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback5Test() throws Exception { boolean pass = false; @@ -734,7 +740,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback5Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback5Test failed"); } } @@ -747,6 +753,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback5Test() * @test_Strategy: Call EntityManager.createQuery(CriteriaQuery) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback6Test() throws Exception { boolean pass = false; @@ -780,7 +787,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback6Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback6Test failed"); } } @@ -793,6 +800,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback6Test() * @test_Strategy: Call EntityManager.createQuery(CriteriaUpdate) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback7Test() throws Exception { boolean pass = false; @@ -835,7 +843,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback7Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback7Test failed"); } } @@ -848,6 +856,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback7Test() * @test_Strategy: Call EntityManager.createQuery(String) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback8Test() throws Exception { boolean pass = false; @@ -876,7 +885,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback8Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback8Test failed"); } } @@ -889,6 +898,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback8Test() * @test_Strategy: Call EntityManager.createQuery(String,Class) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback9Test() throws Exception { boolean pass = false; @@ -917,7 +927,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback9Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback9Test failed"); } } @@ -930,6 +940,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback9Test() * @test_Strategy: Call EntityManager.createStoredProcedureQuery(String) that * causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback10Test() throws Exception { boolean pass = false; @@ -962,7 +973,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback10Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback10Test failed"); } } @@ -975,6 +986,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback10Test() * @test_Strategy: Call EntityManager.createStoredProcedureQuery(String,Class) * that causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback11Test() throws Exception { boolean pass = false; @@ -1007,7 +1019,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback11Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback11Test failed"); } } @@ -1021,6 +1033,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback11Test() * EntityManager.createStoredProcedureQuery(String,String) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback12Test() throws Exception { boolean pass = false; @@ -1053,7 +1066,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback12Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback12Test failed"); } } @@ -1066,6 +1079,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback12Test() * @test_Strategy: Call EntityManager.detach(Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback13Test() throws Exception { boolean pass = false; @@ -1095,7 +1109,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback13Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback13Test failed"); } } @@ -1108,6 +1122,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback13Test() * @test_Strategy: Call EntityManager.find(Class,Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback14Test() throws Exception { boolean pass = false; @@ -1136,7 +1151,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback14Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback14Test failed"); } } @@ -1149,6 +1164,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback14Test() * @test_Strategy: Call EntityManager.find(Class,Object,LockModeType) that * causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback15Test() throws Exception { boolean pass = false; @@ -1178,7 +1194,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback15Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback15Test failed"); } } @@ -1191,6 +1207,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback15Test() * @test_Strategy: Call EntityManager.find(Class,Object,LockModeType,Map) that * causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback16Test() throws Exception { boolean pass = false; @@ -1220,7 +1237,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback16Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback16Test failed"); } } @@ -1233,6 +1250,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback16Test() * @test_Strategy: Call EntityManager.find(Class,Object,Map) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback17Test() throws Exception { boolean pass = false; @@ -1261,7 +1279,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback17Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback17Test failed"); } } @@ -1274,6 +1292,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback17Test() * @test_Strategy: Call EntityManager. getLockMode(Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback21Test() throws Exception { boolean pass = false; @@ -1302,7 +1321,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback21Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback21Test failed"); } } @@ -1315,6 +1334,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback21Test() * @test_Strategy: Call EntityManager.getReference(Class,Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback23Test() throws Exception { boolean pass = false; @@ -1343,7 +1363,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback23Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback23Test failed"); } } @@ -1356,6 +1376,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback23Test() * @test_Strategy: Call EntityManager.lock(Object,LockModeType) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback24Test() throws Exception { boolean pass = false; @@ -1384,7 +1405,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback24Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback24Test failed"); } } @@ -1397,6 +1418,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback24Test() * @test_Strategy: Call EntityManager.lock(Object,LockModeType,Map() that * causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback25Test() throws Exception { boolean pass = false; @@ -1425,7 +1447,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback25Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback25Test failed"); } } @@ -1438,6 +1460,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback25Test() * @test_Strategy: Call EntityManager.merge(Class) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback26Test() throws Exception { boolean pass = false; @@ -1466,7 +1489,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback26Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback26Test failed"); } } @@ -1479,6 +1502,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback26Test() * @test_Strategy: Call EntityManager.persist(Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback27Test() throws Exception { boolean pass = false; @@ -1507,7 +1531,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback27Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback27Test failed"); } } @@ -1520,6 +1544,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback27Test() * @test_Strategy: Call EntityManager.refresh(Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback28Test() throws Exception { boolean pass = false; @@ -1548,7 +1573,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback28Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback28Test failed"); } } @@ -1561,6 +1586,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback28Test() * @test_Strategy: Call EntityManager.refresh(Object,LockModeType) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback29Test() throws Exception { boolean pass = false; @@ -1589,7 +1615,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback29Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback29Test failed"); } } @@ -1602,6 +1628,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback29Test() * @test_Strategy: Call EntityManager.refresh(Object,LockModeType,Map) that * causes RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback30Test() throws Exception { boolean pass = false; @@ -1630,7 +1657,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback30Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback30Test failed"); } } @@ -1643,6 +1670,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback30Test() * @test_Strategy: Call EntityManager.refresh(Object,Map) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback31Test() throws Exception { boolean pass = false; @@ -1671,7 +1699,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback31Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback31Test failed"); } } @@ -1684,6 +1712,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback31Test() * @test_Strategy: Call EntityManager.remove(Object) that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback32Test() throws Exception { boolean pass = false; @@ -1712,7 +1741,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback32Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback32Test failed"); } @@ -1727,6 +1756,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback32Test() */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void refreshTransactionRequiredExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1779,7 +1809,7 @@ public void refreshTransactionRequiredExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("refreshTransactionRequiredExceptionTest failed"); + throw new Exception("refreshTransactionRequiredExceptionTest failed"); } } @@ -1792,6 +1822,7 @@ public void refreshTransactionRequiredExceptionTest() throws Exception { */ @SetupMethod(name = "setupOrderData") @CleanupMethod(name = "cleanupData") + @Test public void lockTransactionRequiredException2Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1843,7 +1874,7 @@ public void lockTransactionRequiredException2Test() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("lockTransactionRequiredException2Test failed"); + throw new Exception("lockTransactionRequiredException2Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/Client.java index 1ae32eb65d..3e441fdc4a 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/Client.java @@ -20,7 +20,9 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -45,46 +47,41 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } + @BeforeEach public void setupNoData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupNoData"); - this.props = p; try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createOrderTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupMember(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupMember() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createMemberTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -108,24 +105,25 @@ public void cleanup() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoData") + @Test public void autoCloseableTest() throws Exception { EntityManagerFactory emf = null; try (final EntityManagerFactory emfLocal = Persistence.createEntityManagerFactory(getPersistenceUnitName(), getPersistenceUnitProperties())) { emf = emfLocal; if (emf == null) { - throw new Fault("autoCloseableTest failed: createEntityManagerFactory(String) returned null"); + throw new Exception("autoCloseableTest failed: createEntityManagerFactory(String) returned null"); } if (!emf.isOpen()) { - throw new Fault("autoCloseableTest failed: EntityManagerFactory isOpen() returned false in try block"); + throw new Exception("autoCloseableTest failed: EntityManagerFactory isOpen() returned false in try block"); } - } catch (Fault f) { + } catch (Exception f) { throw f; } catch (Throwable t) { - throw new Fault("autoCloseableTest failed with Exception", t); + throw new Exception("autoCloseableTest failed with Exception", t); } finally { if (emf != null && emf.isOpen()) { - throw new Fault("autoCloseableTest failed: EntityManagerFactory isOpen() returned true outside try block"); + throw new Exception("autoCloseableTest failed: EntityManagerFactory isOpen() returned true outside try block"); } } } @@ -140,6 +138,7 @@ public void autoCloseableTest() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoData") + @Test public void getMetamodelTest() throws Exception { boolean pass = false; try { @@ -154,7 +153,7 @@ public void getMetamodelTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getMetamodelTest failed"); + throw new Exception("getMetamodelTest failed"); } } @@ -168,6 +167,7 @@ public void getMetamodelTest() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoData") + @Test public void getPersistenceUnitUtil() throws Exception { boolean pass = false; try { @@ -182,7 +182,7 @@ public void getPersistenceUnitUtil() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getPersistenceUnitUtil failed"); + throw new Exception("getPersistenceUnitUtil failed"); } } @@ -197,6 +197,7 @@ public void getPersistenceUnitUtil() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoData") + @Test public void getCriteriaBuilderTest() throws Exception { boolean pass = false; try { @@ -220,7 +221,7 @@ public void getCriteriaBuilderTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getCriteriaBuilderTest failed"); + throw new Exception("getCriteriaBuilderTest failed"); } } @@ -233,6 +234,7 @@ public void getCriteriaBuilderTest() throws Exception { * @test_Strategy: Test that max result of addNamedQuery is retained or can be * overridden */ + @Test public void addNamedQueryMaxResultTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -657,7 +659,7 @@ public void addNamedQueryMaxResultTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7) { - throw new Fault("addNamedQueryMaxResultTest failed"); + throw new Exception("addNamedQueryMaxResultTest failed"); } } @@ -670,7 +672,7 @@ public void addNamedQueryMaxResultTest() throws Exception { * @test_Strategy: Test that flush mode of addNamedQuery is retained or can be * overridden */ - + @Test public void addNamedQueryFlushModeTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1054,7 +1056,7 @@ public void addNamedQueryFlushModeTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7) { - throw new Fault("addNamedQueryFlushModeTest failed"); + throw new Exception("addNamedQueryFlushModeTest failed"); } } @@ -1068,6 +1070,7 @@ public void addNamedQueryFlushModeTest() throws Exception { * overridden */ @SetupMethod(name = "setupMember") + @Test public void addNamedQueryLockModeTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1387,7 +1390,7 @@ public void addNamedQueryLockModeTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5) { - throw new Fault("addNamedQueryLockModeTest failed"); + throw new Exception("addNamedQueryLockModeTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactoryCloseExceptions/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactoryCloseExceptions/Client.java index b21e24c610..70c30f15b0 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactoryCloseExceptions/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactoryCloseExceptions/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,6 +20,10 @@ import java.util.Map; import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,17 +37,18 @@ public class Client extends PMClientBase { public Client() { } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { super.cleanup(); } @@ -61,6 +66,7 @@ public void nullCleanup() throws Exception { * @test_Strategy: Close the EntityManagerFactory, then call various methods */ @CleanupMethod(name = "nullCleanup") + @Test public void exceptionsTest() throws Exception { int passCount = 0; Map myMap = new HashMap(); @@ -171,7 +177,7 @@ public void exceptionsTest() throws Exception { TestUtil.logErr("Could not obtain an EntityManagerFactory"); } if (passCount != 8) { - throw new Fault("exceptionsTest failed"); + throw new Exception("exceptionsTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityTransaction/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityTransaction/Client.java index b743d88468..10e88a357c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityTransaction/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entityTransaction/Client.java @@ -18,7 +18,10 @@ import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,23 +34,19 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { // Nothing to cleanup TestUtil.logTrace("done cleanup, calling super.cleanup"); @@ -61,6 +60,7 @@ public void cleanup() throws Exception { * * @test_Strategy: Call begin twice and verify IllegalStateException is thrown */ + @Test public void beginIllegalStateExceptionTest() throws Exception { boolean pass = false; try { @@ -91,7 +91,7 @@ public void beginIllegalStateExceptionTest() throws Exception { } if (!pass) { - throw new Fault("beginIllegalStateExceptionTest failed"); + throw new Exception("beginIllegalStateExceptionTest failed"); } } @@ -103,6 +103,7 @@ public void beginIllegalStateExceptionTest() throws Exception { * @test_Strategy: Call commit without an active transaction verify * IllegalStateException is thrown */ + @Test public void commitIllegalStateExceptionTest() throws Exception { boolean pass = false; try { @@ -132,7 +133,7 @@ public void commitIllegalStateExceptionTest() throws Exception { } if (!pass) { - throw new Fault("commitIllegalStateExceptionTest failed"); + throw new Exception("commitIllegalStateExceptionTest failed"); } } @@ -144,6 +145,7 @@ public void commitIllegalStateExceptionTest() throws Exception { * @test_Strategy: Call getRollbackOnly without an active transaction verify * IllegalStateException is thrown */ + @Test public void getRollbackOnlyIllegalStateExceptionTest() throws Exception { boolean pass = false; try { @@ -173,7 +175,7 @@ public void getRollbackOnlyIllegalStateExceptionTest() throws Exception { } if (!pass) { - throw new Fault("getRollbackOnlyIllegalStateExceptionTest failed"); + throw new Exception("getRollbackOnlyIllegalStateExceptionTest failed"); } } @@ -185,6 +187,7 @@ public void getRollbackOnlyIllegalStateExceptionTest() throws Exception { * @test_Strategy: Call rollback without an active transaction verify * IllegalStateException is thrown */ + @Test public void rollbackIllegalStateExceptionTest() throws Exception { boolean pass = false; @@ -214,7 +217,7 @@ public void rollbackIllegalStateExceptionTest() throws Exception { } } if (!pass) { - throw new Fault("rollbackIllegalStateExceptionTest failed"); + throw new Exception("rollbackIllegalStateExceptionTest failed"); } } @@ -226,6 +229,7 @@ public void rollbackIllegalStateExceptionTest() throws Exception { * @test_Strategy: Call setRollbackOnly without an active transaction verify * IllegalStateException is thrown */ + @Test public void setRollbackOnlyIllegalStateExceptionTest() throws Exception { boolean pass = false; try { @@ -255,7 +259,7 @@ public void setRollbackOnlyIllegalStateExceptionTest() throws Exception { } if (!pass) { - throw new Fault("setRollbackOnlyIllegalStateExceptionTest failed"); + throw new Exception("setRollbackOnlyIllegalStateExceptionTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/apitests/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/apitests/Client.java index 4bc2597a80..ad9cffc34d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/apitests/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/apitests/Client.java @@ -21,9 +21,7 @@ package com.sun.ts.tests.jpa.core.entitytest.apitests; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,25 +32,20 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * setup() is called before each test */ - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -91,7 +84,7 @@ public void entityAPITest1() throws Exception { } if (!pass) - throw new Fault("entityAPITest1 failed"); + throw new Exception("entityAPITest1 failed"); } /* @@ -129,7 +122,7 @@ public void entityAPITest2() throws Exception { } if (!pass) - throw new Fault("entityAPITest2 failed"); + throw new Exception("entityAPITest2 failed"); } /* @@ -165,7 +158,7 @@ public void entityAPITest3() throws Exception { } if (!pass) - throw new Fault("entityAPITest3 failed"); + throw new Exception("entityAPITest3 failed"); } /* @@ -207,7 +200,7 @@ public void entityAPITest4() throws Exception { } if (!pass) - throw new Fault("entityAPITest4 failed"); + throw new Exception("entityAPITest4 failed"); } @@ -260,7 +253,7 @@ public void getReferenceExceptionsTest() throws Exception { } if (!pass1 || !pass2 || !pass3) - throw new Fault("getReferenceExceptionsTest failed"); + throw new Exception("getReferenceExceptionsTest failed"); } /* @@ -299,7 +292,7 @@ public void getReferenceTest() throws Exception { } if (!pass) - throw new Fault("getReferenceTest failed"); + throw new Exception("getReferenceTest failed"); } @@ -339,7 +332,7 @@ public void entityAPITest8() throws Exception { } if (!pass) - throw new Fault("entityAPITest8 failed"); + throw new Exception("entityAPITest8 failed"); } @@ -379,7 +372,7 @@ public void entityAPITest10() throws Exception { } if (!pass) - throw new Fault("entityAPITest10 failed"); + throw new Exception("entityAPITest10 failed"); } @@ -423,7 +416,7 @@ public void entityAPITest12() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) - throw new Fault("entityAPITest12 failed"); + throw new Exception("entityAPITest12 failed"); } /* @@ -469,7 +462,7 @@ public void entityAPITest13() throws Exception { pass = false; } if (!pass) - throw new Fault("entityAPITest13 failed"); + throw new Exception("entityAPITest13 failed"); } /* @@ -511,7 +504,7 @@ public void entityAPITest14() throws Exception { pass = false; } if (!pass) - throw new Fault("entityAPITest14 failed"); + throw new Exception("entityAPITest14 failed"); } /* @@ -559,7 +552,7 @@ public void entityAPITest15() throws Exception { } if (!pass) - throw new Fault("entityAPITest15 failed"); + throw new Exception("entityAPITest15 failed"); } /* @@ -612,7 +605,7 @@ public void entityAPITest16() throws Exception { } if (!pass) - throw new Fault("entityAPITest16 failed"); + throw new Exception("entityAPITest16 failed"); } /* @@ -650,7 +643,7 @@ public void entityAPITest17() throws Exception { } if (!pass) - throw new Fault("entityAPITest17 failed"); + throw new Exception("entityAPITest17 failed"); } /* @@ -693,7 +686,7 @@ public void entityAPITest18() throws Exception { } if (!pass) - throw new Fault("entityAPITest18 failed"); + throw new Exception("entityAPITest18 failed"); } /* @@ -731,7 +724,7 @@ public void xmlOverridesNamedNativeQueryTest() throws Exception { } if (!pass) - throw new Fault("xmlOverridesNamedNativeQueryTest failed"); + throw new Exception("xmlOverridesNamedNativeQueryTest failed"); } /* @@ -769,7 +762,7 @@ public void xmlNamedNativeQueryTest() throws Exception { } if (!pass) - throw new Fault("xmlNamedNativeQueryTest failed"); + throw new Exception("xmlNamedNativeQueryTest failed"); } /* @@ -807,7 +800,7 @@ public void xmlOverridesNamedQueryTest() throws Exception { } if (!pass) - throw new Fault("xmlOverridesNamedQueryTest failed"); + throw new Exception("xmlOverridesNamedQueryTest failed"); } /* @@ -845,7 +838,7 @@ public void xmlNamedQueryTest() throws Exception { } if (!pass) - throw new Fault("xmlNamedQueryTest failed"); + throw new Exception("xmlNamedQueryTest failed"); } /* @@ -881,7 +874,7 @@ public void namedNativeQueryInMappedSuperClass() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) - throw new Fault("namedNativeQueryInMappedSuperClass failed"); + throw new Exception("namedNativeQueryInMappedSuperClass failed"); } /* @@ -917,7 +910,7 @@ public void namedQueryInMappedSuperClass() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) - throw new Fault("namedQueryInMappedSuperClass failed"); + throw new Exception("namedQueryInMappedSuperClass failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/bigdecimal/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/bigdecimal/Client.java index d3523ff6ad..21096d116a 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/bigdecimal/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/bigdecimal/Client.java @@ -22,9 +22,7 @@ import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +31,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -124,7 +117,7 @@ public void persistBasicTest1() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest1 failed"); + throw new Exception("persistBasicTest1 failed"); } } @@ -209,7 +202,7 @@ public void persistBasicTest2() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest2 failed"); + throw new Exception("persistBasicTest2 failed"); } } @@ -297,7 +290,7 @@ public void persistBasicTest3() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest3 failed"); + throw new Exception("persistBasicTest3 failed"); } } @@ -395,7 +388,7 @@ public void persistBasicTest4() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest4 failed"); + throw new Exception("persistBasicTest4 failed"); } } @@ -495,7 +488,7 @@ public void persistBasicTest5() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest5 failed"); + throw new Exception("persistBasicTest5 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/biginteger/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/biginteger/Client.java index 42e05942a8..6cf57b5e89 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/biginteger/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/biginteger/Client.java @@ -22,9 +22,7 @@ import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +31,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -124,7 +117,7 @@ public void persistBasicTest1() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest1 failed"); + throw new Exception("persistBasicTest1 failed"); } } @@ -209,7 +202,7 @@ public void persistBasicTest2() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest2 failed"); + throw new Exception("persistBasicTest2 failed"); } } @@ -296,7 +289,7 @@ public void persistBasicTest3() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest3 failed"); + throw new Exception("persistBasicTest3 failed"); } } @@ -393,7 +386,7 @@ public void persistBasicTest4() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest4 failed"); + throw new Exception("persistBasicTest4 failed"); } } @@ -493,7 +486,7 @@ public void persistBasicTest5() throws Exception { } if (!pass) { - throw new Fault("persistBasicTest5 failed"); + throw new Exception("persistBasicTest5 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXmany/Client.java index 61e42fc33c..49524a9ec9 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXmany/Client.java @@ -21,10 +21,8 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +31,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -116,7 +109,7 @@ public void cascadeAllMXMTest1() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest1 failed"); + throw new Exception("cascadeAllMXMTest1 failed"); } } @@ -196,7 +189,7 @@ public void cascadeAllMXMTest2() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest2 failed"); + throw new Exception("cascadeAllMXMTest2 failed"); } } @@ -253,7 +246,7 @@ public void cascadeAllMXMTest3() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest3 failed"); + throw new Exception("cascadeAllMXMTest3 failed"); } } @@ -325,7 +318,7 @@ public void cascadeAllMXMTest4() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest4 failed"); + throw new Exception("cascadeAllMXMTest4 failed"); } } @@ -394,7 +387,7 @@ public void cascadeAllMXMTest5() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest5 failed"); + throw new Exception("cascadeAllMXMTest5 failed"); } } @@ -445,7 +438,7 @@ public void cascadeAllMXMTest6() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest6 failed"); + throw new Exception("cascadeAllMXMTest6 failed"); } } @@ -499,7 +492,7 @@ && getEntityManager().contains(b3) } if (!pass) { - throw new Fault("cascadeAllMXMTest7 failed"); + throw new Exception("cascadeAllMXMTest7 failed"); } } @@ -541,7 +534,7 @@ public void cascadeAllMXMTest8() throws Exception { } if (pass) { - throw new Fault("cascadeAllMXMTest8 failed"); + throw new Exception("cascadeAllMXMTest8 failed"); } } @@ -591,7 +584,7 @@ public void cascadeAllMXMTest9() throws Exception { if (!pass1 && !pass2 && !pass) { TestUtil.logErr("pass=" + pass + ", pass1=" + pass1 + ", pass2=" + pass2); - throw new Fault("cascadeAllMXMTest9 failed"); + throw new Exception("cascadeAllMXMTest9 failed"); } } @@ -656,7 +649,7 @@ public void cascadeAllMXMTest10() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest10 failed"); + throw new Exception("cascadeAllMXMTest10 failed"); } } @@ -712,7 +705,7 @@ public void cascadeAllMXMTest11() throws Exception { } if (!pass) { - throw new Fault("cascadeAllMXMTest11 failed"); + throw new Exception("cascadeAllMXMTest11 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXone/Client.java index cb411e3de5..1a96422f9b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/manyXone/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.cascadeall.manyXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -117,7 +109,7 @@ public void cascadeAllMX1Test1() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test1 failed"); + throw new Exception("cascadeAllMX1Test1 failed"); } /* @@ -189,7 +181,7 @@ public void cascadeAllMX1Test2() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test2 failed"); + throw new Exception("cascadeAllMX1Test2 failed"); } /* @@ -256,7 +248,7 @@ public void cascadeAllMX1Test3() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test3 failed"); + throw new Exception("cascadeAllMX1Test3 failed"); } /* @@ -305,7 +297,7 @@ public void cascadeAllMX1Test4() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test4 failed"); + throw new Exception("cascadeAllMX1Test4 failed"); } /* @@ -344,7 +336,7 @@ public void cascadeAllMX1Test5() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test5 failed"); + throw new Exception("cascadeAllMX1Test5 failed"); } /* @@ -378,7 +370,7 @@ public void cascadeAllMX1Test6() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test6 failed"); + throw new Exception("cascadeAllMX1Test6 failed"); } /* @@ -440,7 +432,7 @@ public void cascadeAllMX1Test7() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test7 failed"); + throw new Exception("cascadeAllMX1Test7 failed"); } /* @@ -493,7 +485,7 @@ public void cascadeAllMX1Test8() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test8 failed"); + throw new Exception("cascadeAllMX1Test8 failed"); } /* @@ -540,7 +532,7 @@ public void cascadeAllMX1Test9() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test9 failed"); + throw new Exception("cascadeAllMX1Test9 failed"); } /* @@ -596,7 +588,7 @@ public void cascadeAllMX1Test10() throws Exception { } if (!pass) - throw new Fault("cascadeAllMX1Test10 failed"); + throw new Exception("cascadeAllMX1Test10 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXmany/Client.java index 838743cbb0..d0653c8773 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXmany/Client.java @@ -22,10 +22,8 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,20 +32,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -118,7 +111,7 @@ public void cascadeAll1XMTest1() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest1 failed"); + throw new Exception("cascadeAll1XMTest1 failed"); } /* @@ -181,7 +174,7 @@ public void cascadeAll1XMTest2() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest2 failed"); + throw new Exception("cascadeAll1XMTest2 failed"); } /* @@ -240,7 +233,7 @@ public void cascadeAll1XMTest3() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest3 failed"); + throw new Exception("cascadeAll1XMTest3 failed"); } /* @@ -282,7 +275,7 @@ public void cascadeAll1XMTest4() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest4 failed"); + throw new Exception("cascadeAll1XMTest4 failed"); } /* @@ -345,7 +338,7 @@ public void cascadeAll1XMTest5() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest5 failed"); + throw new Exception("cascadeAll1XMTest5 failed"); } /* @@ -398,7 +391,7 @@ public void cascadeAll1XMTest6() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest6 failed"); + throw new Exception("cascadeAll1XMTest6 failed"); } /* @@ -447,7 +440,7 @@ public void cascadeAll1XMTest7() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest7 failed"); + throw new Exception("cascadeAll1XMTest7 failed"); } /* @@ -493,7 +486,7 @@ public void cascadeAll1XMTest8() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest8 failed"); + throw new Exception("cascadeAll1XMTest8 failed"); } /* @@ -549,7 +542,7 @@ public void cascadeAll1XMTest9() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest9 failed"); + throw new Exception("cascadeAll1XMTest9 failed"); } /* @@ -639,7 +632,7 @@ public void cascadeAll1XMTest10() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest10 failed"); + throw new Exception("cascadeAll1XMTest10 failed"); } /* @@ -716,7 +709,7 @@ public void cascadeAll1XMTest11() throws Exception { } if (!pass) - throw new Fault("cascadeAll1XMTest11 failed"); + throw new Exception("cascadeAll1XMTest11 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXone/Client.java index 943e0a191c..dfc4fede60 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/cascadeall/oneXone/Client.java @@ -19,9 +19,6 @@ */ package com.sun.ts.tests.jpa.core.entitytest.cascadeall.oneXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +27,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -106,7 +98,7 @@ public void cascadeAll1X1Test1() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test1 failed"); + throw new Exception("cascadeAll1X1Test1 failed"); } } @@ -175,7 +167,7 @@ public void cascadeAll1X1Test2() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test2 failed"); + throw new Exception("cascadeAll1X1Test2 failed"); } } @@ -235,7 +227,7 @@ public void cascadeAll1X1Test3() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test3 failed"); + throw new Exception("cascadeAll1X1Test3 failed"); } } @@ -283,7 +275,7 @@ public void cascadeAll1X1Test4() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test4 failed"); + throw new Exception("cascadeAll1X1Test4 failed"); } } @@ -329,7 +321,7 @@ public void cascadeAll1X1Test5() throws Exception { if (pass1 || pass2 || !pass) { TestUtil.logErr("pass=" + pass + ", pass1=" + pass1 + ", pass2=" + pass2); - throw new Fault("cascadeAll1X1Test5 failed"); + throw new Exception("cascadeAll1X1Test5 failed"); } } @@ -399,7 +391,7 @@ public void cascadeAll1X1Test6() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test6 failed"); + throw new Exception("cascadeAll1X1Test6 failed"); } } @@ -449,7 +441,7 @@ public void cascadeAll1X1Test7() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test7 failed"); + throw new Exception("cascadeAll1X1Test7 failed"); } } @@ -523,7 +515,7 @@ public void cascadeAll1X1Test8() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test8 failed"); + throw new Exception("cascadeAll1X1Test8 failed"); } } @@ -582,7 +574,7 @@ public void cascadeAll1X1Test9() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test9 failed"); + throw new Exception("cascadeAll1X1Test9 failed"); } } @@ -648,7 +640,7 @@ public void cascadeAll1X1Test10() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1X1Test10 failed"); + throw new Exception("cascadeAll1X1Test10 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/basic/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/basic/Client.java index 20f591a04e..1136f0679e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/basic/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/basic/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.detach.basic; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,19 +28,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -122,7 +114,7 @@ public void detachBasicTest1() throws Exception { } if (!pass) - throw new Fault("detachBasicTest1 failed"); + throw new Exception("detachBasicTest1 failed"); } /* @@ -186,7 +178,7 @@ public void detachBasicTest2() throws Exception { } if (!pass) - throw new Fault("detachBasicTest2 failed"); + throw new Exception("detachBasicTest2 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXmany/Client.java index dc770aff75..fde7d9e057 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXmany/Client.java @@ -22,9 +22,7 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +31,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -157,7 +150,7 @@ public void detachMXMTest1() throws Exception { } if (!pass1 || !pass2) - throw new Fault("detachMXMTest1 failed"); + throw new Exception("detachMXMTest1 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXone/Client.java index e4f9527f52..e54645fa47 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/manyXone/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.detach.manyXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +30,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -131,7 +123,7 @@ public void detachMX1Test1() throws Exception { } if (!pass) - throw new Fault("detachMX1Test1 failed"); + throw new Exception("detachMX1Test1 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXmany/Client.java index e8f1e61109..747d361585 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXmany/Client.java @@ -22,10 +22,8 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,20 +34,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -131,7 +124,7 @@ public void detach1XMTest1() throws Exception { } if (!pass) - throw new Fault("detach1XMTest1 failed"); + throw new Exception("detach1XMTest1 failed"); } /* @@ -211,7 +204,7 @@ public void detach1XMTest2() throws Exception { } if (!pass) - throw new Fault("detach1XMTest2 failed"); + throw new Exception("detach1XMTest2 failed"); } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXone/Client.java index b19ab1df35..d5e01dc807 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/detach/oneXone/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.detach.oneXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +30,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -126,7 +118,7 @@ public void detach1X1Test1() throws Exception { } if (!pass) - throw new Fault("detach1X1Test1 failed"); + throw new Exception("detach1X1Test1 failed"); } /* @@ -194,7 +186,7 @@ public void detach1X1Test2() throws Exception { } if (!pass) - throw new Fault("detach1X1Test2 failed"); + throw new Exception("detach1X1Test2 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/basic/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/basic/Client.java index e498315c96..ac44464b8b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/basic/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/basic/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.persist.basic; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,19 +28,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -98,7 +90,7 @@ public void persistBasicTest1() throws Exception { } if (!pass) - throw new Fault("persistBasicTest1 failed"); + throw new Exception("persistBasicTest1 failed"); } @@ -153,7 +145,7 @@ public void persistBasicTest2() throws Exception { } if (!pass) - throw new Fault("persistBasicTest2 failed"); + throw new Exception("persistBasicTest2 failed"); } @@ -211,7 +203,7 @@ public void persistBasicTest3() throws Exception { } if (!pass) - throw new Fault("persistBasicTest3 failed"); + throw new Exception("persistBasicTest3 failed"); } @@ -278,7 +270,7 @@ public void persistBasicTest4() throws Exception { } if (!pass) - throw new Fault("persistBasicTest4 failed"); + throw new Exception("persistBasicTest4 failed"); } /* @@ -348,7 +340,7 @@ public void persistBasicTest5() throws Exception { } if (!pass) - throw new Fault("persistBasicTest5 failed"); + throw new Exception("persistBasicTest5 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXmany/Client.java index 29bad1b9a5..72a462f126 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXmany/Client.java @@ -21,10 +21,8 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +31,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -119,7 +112,7 @@ public void persistMXMTest1() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest1 failed"); + throw new Exception("persistMXMTest1 failed"); } } @@ -208,7 +201,7 @@ public void persistMXMTest2() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest2 failed"); + throw new Exception("persistMXMTest2 failed"); } } @@ -266,7 +259,7 @@ public void persistMXMTest4() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest4 failed"); + throw new Exception("persistMXMTest4 failed"); } } @@ -338,7 +331,7 @@ public void persistMXMTest5() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest5 failed"); + throw new Exception("persistMXMTest5 failed"); } } @@ -403,7 +396,7 @@ public void persistMXMTest6() throws Exception { } } if (!pass) { - throw new Fault("persistMXMTest6 failed"); + throw new Exception("persistMXMTest6 failed"); } } @@ -455,7 +448,7 @@ public void persistMXMTest7() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest7 failed"); + throw new Exception("persistMXMTest7 failed"); } } @@ -510,7 +503,7 @@ && getEntityManager().contains(b3) } if (!pass) { - throw new Fault("persistMXMTest8 failed"); + throw new Exception("persistMXMTest8 failed"); } } @@ -560,7 +553,7 @@ public void persistMXMTest9() throws Exception { } } if (pass) { - throw new Fault("persistMXMTest9 failed"); + throw new Exception("persistMXMTest9 failed"); } } @@ -619,7 +612,7 @@ public void persistMXMTest10() throws Exception { if (!pass1 && !pass2 && !pass) { TestUtil.logErr("pass=" + pass + ", pass1=" + pass1 + ", pass2=" + pass2); - throw new Fault("persistMXMTest10 failed"); + throw new Exception("persistMXMTest10 failed"); } } @@ -683,7 +676,7 @@ public void persistMXMTest11() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest11 failed"); + throw new Exception("persistMXMTest11 failed"); } } @@ -740,7 +733,7 @@ public void persistMXMTest12() throws Exception { } if (!pass) { - throw new Fault("persistMXMTest12 failed"); + throw new Exception("persistMXMTest12 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXone/Client.java index 7bed8ff6bf..27375d7ed5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/manyXone/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.persist.manyXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -119,7 +111,7 @@ public void persistMX1Test1() throws Exception { } if (!pass) - throw new Fault("persistMX1Test1 failed"); + throw new Exception("persistMX1Test1 failed"); } /* @@ -195,7 +187,7 @@ public void persistMX1Test2() throws Exception { } if (!pass) - throw new Fault("persistMX1Test2 failed"); + throw new Exception("persistMX1Test2 failed"); } /* @@ -263,7 +255,7 @@ public void persistMX1Test3() throws Exception { } if (!pass) - throw new Fault("persistMX1Test3 failed"); + throw new Exception("persistMX1Test3 failed"); } /* @@ -314,7 +306,7 @@ public void persistMX1Test4() throws Exception { } if (!pass) - throw new Fault("persistMX1Test4 failed"); + throw new Exception("persistMX1Test4 failed"); } /* @@ -362,7 +354,7 @@ public void persistMX1Test5() throws Exception { } if (!pass) - throw new Fault("persistMX1Test5 failed"); + throw new Exception("persistMX1Test5 failed"); } /* @@ -406,7 +398,7 @@ public void persistMX1Test6() throws Exception { } if (!pass) - throw new Fault("persistMX1Test6 failed"); + throw new Exception("persistMX1Test6 failed"); } /* @@ -471,7 +463,7 @@ public void persistMX1Test7() throws Exception { } if (!pass) - throw new Fault("persistMX1Test7 failed"); + throw new Exception("persistMX1Test7 failed"); } /* @@ -526,7 +518,7 @@ public void persistMX1Test8() throws Exception { } if (!pass) - throw new Fault("persistMX1Test8 failed"); + throw new Exception("persistMX1Test8 failed"); } /* @@ -574,7 +566,7 @@ public void persistMX1Test9() throws Exception { } if (!pass) - throw new Fault("persistMX1Test9 failed"); + throw new Exception("persistMX1Test9 failed"); } /* @@ -632,7 +624,7 @@ public void persistMX1Test10() throws Exception { } if (!pass) - throw new Fault("persistMX1Test10 failed"); + throw new Exception("persistMX1Test10 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmany/Client.java index 040ed74438..59168d9dec 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmany/Client.java @@ -22,10 +22,8 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,20 +32,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -120,7 +113,7 @@ public void persist1XMTest1() throws Exception { } if (!pass) - throw new Fault("persist1XMTest1 failed"); + throw new Exception("persist1XMTest1 failed"); } /* @@ -199,7 +192,7 @@ public void persist1XMTest3() throws Exception { } if (!pass) - throw new Fault("persist1XMTest3 failed"); + throw new Exception("persist1XMTest3 failed"); } /* @@ -277,7 +270,7 @@ public void persist1XMTest4() throws Exception { } if (!pass) - throw new Fault("persist1XMTest4 failed"); + throw new Exception("persist1XMTest4 failed"); } /* @@ -336,7 +329,7 @@ public void persist1XMTest5() throws Exception { } if (!pass) - throw new Fault("persist1XMTest5 failed"); + throw new Exception("persist1XMTest5 failed"); } /* @@ -395,7 +388,7 @@ public void persist1XMTest6() throws Exception { } if (!pass) - throw new Fault("persist1XMTest6 failed"); + throw new Exception("persist1XMTest6 failed"); } /* @@ -441,7 +434,7 @@ public void persist1XMTest7() throws Exception { } if (!pass) - throw new Fault("persist1XMTest7 failed"); + throw new Exception("persist1XMTest7 failed"); } /* @@ -480,7 +473,7 @@ public void persist1XMTest7IllegalStateException() throws Exception { } if (!pass) - throw new Fault("persist1XMTest7IllegalStateException failed"); + throw new Exception("persist1XMTest7IllegalStateException failed"); } /* @@ -529,7 +522,7 @@ public void persist1XMTest8() throws Exception { } if (pass) - throw new Fault("persist1XMTest8 failed"); + throw new Exception("persist1XMTest8 failed"); } /* @@ -572,7 +565,7 @@ public void persist1XMTest9() throws Exception { } if (!pass) - throw new Fault("persist1XMTest9 failed"); + throw new Exception("persist1XMTest9 failed"); } /* @@ -639,7 +632,7 @@ public void persist1XMTest10() throws Exception { } if (!pass) - throw new Fault("persist1XMTest10 failed"); + throw new Exception("persist1XMTest10 failed"); } /* @@ -704,7 +697,7 @@ public void persist1XMTest11() throws Exception { } if (!pass) - throw new Fault("persist1XMTest11 failed"); + throw new Exception("persist1XMTest11 failed"); } /* @@ -758,7 +751,7 @@ public void persist1XMTest12() throws Exception { } if (!pass) - throw new Fault("persist1XMTest12 failed"); + throw new Exception("persist1XMTest12 failed"); } /* @@ -807,7 +800,7 @@ public void persist1XMTest13() throws Exception { } if (!pass) - throw new Fault("persist1XMTest13 failed"); + throw new Exception("persist1XMTest13 failed"); } /* @@ -853,7 +846,7 @@ public void persist1XMTest14() throws Exception { } if (!pass) - throw new Fault("persist1XMTest14 failed"); + throw new Exception("persist1XMTest14 failed"); } /* @@ -911,7 +904,7 @@ public void persist1XMTest15() throws Exception { } if (!pass) - throw new Fault("persist1XMTest15 failed"); + throw new Exception("persist1XMTest15 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmanyFetchEager/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmanyFetchEager/Client.java index 8a198a2e91..1c63bcbeb7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmanyFetchEager/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXmanyFetchEager/Client.java @@ -19,9 +19,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -114,7 +107,7 @@ public void persist1XMTest1() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest1 failed"); + throw new Exception("persist1XMTest1 failed"); } } @@ -175,7 +168,7 @@ public void persist1XMTest2() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest2 failed"); + throw new Exception("persist1XMTest2 failed"); } } @@ -255,7 +248,7 @@ public void persist1XMTest3() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest3 failed"); + throw new Exception("persist1XMTest3 failed"); } } @@ -335,7 +328,7 @@ public void persist1XMTest4() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest4 failed"); + throw new Exception("persist1XMTest4 failed"); } } @@ -395,7 +388,7 @@ public void persist1XMTest5() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest5 failed"); + throw new Exception("persist1XMTest5 failed"); } } @@ -455,7 +448,7 @@ public void persist1XMTest6() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest6 failed"); + throw new Exception("persist1XMTest6 failed"); } } @@ -501,7 +494,7 @@ public void persist1XMTest7() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest7 failed"); + throw new Exception("persist1XMTest7 failed"); } } @@ -548,7 +541,7 @@ public void persist1XMTest7IllegalStateException() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest7IllegalStateException failed"); + throw new Exception("persist1XMTest7IllegalStateException failed"); } } @@ -597,7 +590,7 @@ public void persist1XMTest8() throws Exception { } if (pass) { - throw new Fault("persist1XMTest8 failed"); + throw new Exception("persist1XMTest8 failed"); } } @@ -640,7 +633,7 @@ public void persist1XMTest9() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest9 failed"); + throw new Exception("persist1XMTest9 failed"); } } @@ -707,7 +700,7 @@ public void persist1XMTest10() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest10 failed"); + throw new Exception("persist1XMTest10 failed"); } } @@ -772,7 +765,7 @@ public void persist1XMTest11() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest11 failed"); + throw new Exception("persist1XMTest11 failed"); } } @@ -825,7 +818,7 @@ public void persist1XMTest12() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest12 failed"); + throw new Exception("persist1XMTest12 failed"); } } @@ -874,7 +867,7 @@ public void persist1XMTest13() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest13 failed"); + throw new Exception("persist1XMTest13 failed"); } } @@ -920,7 +913,7 @@ public void persist1XMTest14() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest14 failed"); + throw new Exception("persist1XMTest14 failed"); } } @@ -978,7 +971,7 @@ public void persist1XMTest15() throws Exception { } if (!pass) { - throw new Fault("persist1XMTest15 failed"); + throw new Exception("persist1XMTest15 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXone/Client.java index cb6f38b5f3..48b39f1ced 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/persist/oneXone/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.persist.oneXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -112,7 +104,7 @@ public void persist1X1Test1() throws Exception { } if (!pass) - throw new Fault("persist1X1Test1 failed"); + throw new Exception("persist1X1Test1 failed"); } /* @@ -184,7 +176,7 @@ public void persist1X1Test2() throws Exception { } if (!pass) - throw new Fault("persist1X1Test2 failed"); + throw new Exception("persist1X1Test2 failed"); } /* @@ -235,7 +227,7 @@ public void persist1X1Test3() throws Exception { } if (!pass) - throw new Fault("persist1X1Test3 failed"); + throw new Exception("persist1X1Test3 failed"); } /* @@ -295,7 +287,7 @@ public void persist1X1Test4() throws Exception { } if (!pass) - throw new Fault("persist1X1Test4 failed"); + throw new Exception("persist1X1Test4 failed"); } /* @@ -358,7 +350,7 @@ public void persist1X1Test5() throws Exception { } if (!pass) - throw new Fault("persist1X1Test5 failed"); + throw new Exception("persist1X1Test5 failed"); } /* @@ -405,7 +397,7 @@ public void persist1X1Test6() throws Exception { } if (!pass) - throw new Fault("persist1X1Test6 failed"); + throw new Exception("persist1X1Test6 failed"); } /* @@ -449,7 +441,7 @@ public void persist1X1Test7() throws Exception { } if (!pass) - throw new Fault("persist1X1Test7 failed"); + throw new Exception("persist1X1Test7 failed"); } /* @@ -495,7 +487,7 @@ public void persist1X1Test8() throws Exception { } if (!pass) - throw new Fault("persist1X1Test8 failed"); + throw new Exception("persist1X1Test8 failed"); } /* @@ -538,7 +530,7 @@ public void persist1X1Test9() throws Exception { } if (pass) - throw new Fault("persist1X1Test9 failed"); + throw new Exception("persist1X1Test9 failed"); } /* @@ -584,7 +576,7 @@ public void persist1X1Test10() throws Exception { if (pass1 || pass2 || !pass) { TestUtil.logErr("pass=" + pass + ", pass1=" + pass1 + ", pass2=" + pass2); - throw new Fault("persist1X1Test10 failed"); + throw new Exception("persist1X1Test10 failed"); } } @@ -654,7 +646,7 @@ public void persist1X1Test11() throws Exception { } if (!pass) - throw new Fault("persist1X1Test11 failed"); + throw new Exception("persist1X1Test11 failed"); } /* @@ -711,7 +703,7 @@ public void persist1X1Test12() throws Exception { } if (!pass) - throw new Fault("persist1X1Test12 failed"); + throw new Exception("persist1X1Test12 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/basic/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/basic/Client.java index 5045c0422d..7ac2337403 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/basic/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/basic/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.remove.basic; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -95,7 +87,7 @@ public void removeBasicTest1() throws Exception { } if (!pass) - throw new Fault("removeBasicTest1 failed"); + throw new Exception("removeBasicTest1 failed"); } /* @@ -135,7 +127,7 @@ public void removeBasicTest2() throws Exception { } if (!pass) - throw new Fault("removeBasicTest2 failed"); + throw new Exception("removeBasicTest2 failed"); } /* @@ -194,7 +186,7 @@ public void removeBasicTest3() throws Exception { } if (!pass) - throw new Fault("removeBasicTest3 failed"); + throw new Exception("removeBasicTest3 failed"); } /* @@ -258,7 +250,7 @@ public void removeBasicTest4() throws Exception { } if (!pass) - throw new Fault("removeBasicTest4 failed"); + throw new Exception("removeBasicTest4 failed"); } /* @@ -304,7 +296,7 @@ public void removeBasicTest5() throws Exception { } if (!pass) - throw new Fault("removeBasicTest5 failed"); + throw new Exception("removeBasicTest5 failed"); } /* @@ -363,7 +355,7 @@ public void removeMergeBasicTest() throws Exception { } } if (!pass) - throw new Fault("removeMergeBasicTest failed, reason: " + reason); + throw new Exception("removeMergeBasicTest failed, reason: " + reason); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXmany/Client.java index d7ee30f129..b33b2a5de0 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXmany/Client.java @@ -22,10 +22,8 @@ import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,20 +32,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -118,7 +111,7 @@ public void remove1XMTest1() throws Exception { } if (!pass) - throw new Fault("remove1XMTest1 failed"); + throw new Exception("remove1XMTest1 failed"); } /* @@ -190,7 +183,7 @@ public void remove1XMTest2() throws Exception { } if (!pass) - throw new Fault("remove1XMTest2 failed"); + throw new Exception("remove1XMTest2 failed"); } /* @@ -276,7 +269,7 @@ public void remove1XMTest3() throws Exception { } if (!pass) - throw new Fault("remove1XMTest3 failed"); + throw new Exception("remove1XMTest3 failed"); } /* @@ -347,7 +340,7 @@ public void remove1XMTest4() throws Exception { } if (!pass) - throw new Fault("remove1XMTest4 failed"); + throw new Exception("remove1XMTest4 failed"); } /* @@ -431,7 +424,7 @@ public void remove1XMTest5() throws Exception { } } if (!pass) - throw new Fault("remove1XMTest5 failed"); + throw new Exception("remove1XMTest5 failed"); } /* @@ -508,7 +501,7 @@ public void remove1XMTest6() throws Exception { } } if (!pass) - throw new Fault("remove1XMTest6 failed"); + throw new Exception("remove1XMTest6 failed"); } /* @@ -587,7 +580,7 @@ public void remove1XMTest7() throws Exception { } if (!pass) - throw new Fault("remove1XMTest7 failed"); + throw new Exception("remove1XMTest7 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXone/Client.java index e8ff4d7a26..87db5517b0 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/entitytest/remove/oneXone/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.entitytest.remove.oneXone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -104,7 +96,7 @@ public void remove1X1Test1() throws Exception { } if (!pass) - throw new Fault("remove1X1Test1 failed"); + throw new Exception("remove1X1Test1 failed"); } /* @@ -154,7 +146,7 @@ public void remove1X1Test2() throws Exception { } if (pass) - throw new Fault("remove1X1Test2 failed"); + throw new Exception("remove1X1Test2 failed"); } /* @@ -225,7 +217,7 @@ public void remove1X1Test3() throws Exception { } if (!pass) - throw new Fault("remove1X1Test3 failed"); + throw new Exception("remove1X1Test3 failed"); } /* @@ -280,7 +272,7 @@ public void remove1X1Test4() throws Exception { } if (!pass) - throw new Fault("remove1X1Test4 failed"); + throw new Exception("remove1X1Test4 failed"); } /* @@ -342,7 +334,7 @@ public void remove1X1Test5() throws Exception { } if (!pass) - throw new Fault("remove1X1Test5 failed"); + throw new Exception("remove1X1Test5 failed"); } /* @@ -403,7 +395,7 @@ public void remove1X1Test6() throws Exception { } if (!pass) - throw new Fault("remove1X1Test6 failed"); + throw new Exception("remove1X1Test6 failed"); } /* @@ -461,7 +453,7 @@ public void remove1X1Test7() throws Exception { } if (!pass) - throw new Fault("remove1X1Test7 failed"); + throw new Exception("remove1X1Test7 failed"); } /* @@ -517,7 +509,7 @@ public void remove1X1Test8() throws Exception { } if (!pass) - throw new Fault("remove1X1Test8 failed"); + throw new Exception("remove1X1Test8 failed"); } /* @@ -583,7 +575,7 @@ public void remove1X1Test9() throws Exception { } if (!pass) - throw new Fault("remove1X1Test9 failed"); + throw new Exception("remove1X1Test9 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/enums/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/enums/Client.java index 508d4204d5..01c17b452a 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/enums/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/enums/Client.java @@ -22,9 +22,7 @@ import java.util.Arrays; import java.util.Collection; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -62,20 +60,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -124,7 +117,7 @@ public void accessTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("accessTypeValueOfTest failed"); + throw new Exception("accessTypeValueOfTest failed"); } } @@ -175,7 +168,7 @@ public void accessTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("accessTypeValuesTest failed"); + throw new Exception("accessTypeValuesTest failed"); } } @@ -226,7 +219,7 @@ public void cacheRetrieveModeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("cacheRetrieveModeValueOfTest failed"); + throw new Exception("cacheRetrieveModeValueOfTest failed"); } } @@ -279,7 +272,7 @@ public void cacheRetrieveModeValuesTest() throws Exception { } if (!pass) { - throw new Fault("cacheRetrieveModeValuesTest failed"); + throw new Exception("cacheRetrieveModeValuesTest failed"); } } @@ -335,7 +328,7 @@ public void cacheStoreModeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("cacheStoreModeValueOfTest failed"); + throw new Exception("cacheStoreModeValueOfTest failed"); } } @@ -393,7 +386,7 @@ public void cacheStoreModeValuesTest() throws Exception { } if (!pass) { - throw new Fault("cacheStoreModeValuesTest failed"); + throw new Exception("cacheStoreModeValuesTest failed"); } } @@ -467,7 +460,7 @@ public void cascadeTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("cascadeTypeValueOfTest failed"); + throw new Exception("cascadeTypeValueOfTest failed"); } } @@ -543,7 +536,7 @@ public void cascadeTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("cascadeTypeValuesTest failed"); + throw new Exception("cascadeTypeValuesTest failed"); } } @@ -600,7 +593,7 @@ public void discriminatorTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("discriminatorTypeValueOfTest failed"); + throw new Exception("discriminatorTypeValueOfTest failed"); } } @@ -660,7 +653,7 @@ public void discriminatorTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("discriminatorTypeValuesTest failed"); + throw new Exception("discriminatorTypeValuesTest failed"); } } @@ -710,7 +703,7 @@ public void enumTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("enumTypeValueOfTest failed"); + throw new Exception("enumTypeValueOfTest failed"); } } @@ -761,7 +754,7 @@ public void enumTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("enumTypeValuesTest failed"); + throw new Exception("enumTypeValuesTest failed"); } } @@ -811,7 +804,7 @@ public void fetchTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("fetchTypeValueOfTest failed"); + throw new Exception("fetchTypeValueOfTest failed"); } } @@ -862,7 +855,7 @@ public void fetchTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("fetchTypeValuesTest failed"); + throw new Exception("fetchTypeValuesTest failed"); } } /* @@ -911,7 +904,7 @@ public void flushModeTypeValueOfTest() throws Exception { } if (!pass) - throw new Fault("flushModeTypeValueOfTest failed"); + throw new Exception("flushModeTypeValueOfTest failed"); } /* * @testName: flushModeTypeValuesTest @@ -962,7 +955,7 @@ public void flushModeTypeValuesTest() throws Exception { } if (!pass) - throw new Fault("flushModeTypeValuesTest failed"); + throw new Exception("flushModeTypeValuesTest failed"); } /* @@ -1020,7 +1013,7 @@ public void setgetFlushModeEntityManagerTest() throws Exception { } if (!pass) - throw new Fault("setgetFlushModeEntityManagerTest failed"); + throw new Exception("setgetFlushModeEntityManagerTest failed"); } /* * @testName: setgetFlushModeTest @@ -1071,7 +1064,7 @@ public void setgetFlushModeTest() throws Exception { } if (!pass) - throw new Fault("setgetFlushModeTest failed"); + throw new Exception("setgetFlushModeTest failed"); } /* * @testName: setgetFlushModeTQTest @@ -1121,7 +1114,7 @@ public void setgetFlushModeTQTest() throws Exception { } if (!pass) - throw new Fault("setgetFlushModeTQTest failed"); + throw new Exception("setgetFlushModeTQTest failed"); } /* @@ -1188,7 +1181,7 @@ public void generationTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("generationTypeValueOfTest failed"); + throw new Exception("generationTypeValueOfTest failed"); } } @@ -1257,7 +1250,7 @@ public void generationTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("generationTypeValuesTest failed"); + throw new Exception("generationTypeValuesTest failed"); } } @@ -1314,7 +1307,7 @@ public void inheritanceTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("inheritanceTypeValueOfTest failed"); + throw new Exception("inheritanceTypeValueOfTest failed"); } } @@ -1371,7 +1364,7 @@ public void inheritanceTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("inheritanceTypeValuesTest failed"); + throw new Exception("inheritanceTypeValuesTest failed"); } } @@ -1452,7 +1445,7 @@ public void lockModeTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("lockModeTypeValueOfTest failed"); + throw new Exception("lockModeTypeValueOfTest failed"); } } @@ -1544,7 +1537,7 @@ public void lockModeTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("lockModeTypeValuesTest failed"); + throw new Exception("lockModeTypeValuesTest failed"); } } @@ -1595,7 +1588,7 @@ public void persistenceContextTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("persistenceContextTypeValueOfTest failed"); + throw new Exception("persistenceContextTypeValueOfTest failed"); } } @@ -1647,7 +1640,7 @@ public void persistenceContextTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("persistenceContextTypeValuesTest failed"); + throw new Exception("persistenceContextTypeValuesTest failed"); } } @@ -1697,7 +1690,7 @@ public void pessimisticLockScopeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("pessimisticLockScopeValueOfTest failed"); + throw new Exception("pessimisticLockScopeValueOfTest failed"); } } @@ -1750,7 +1743,7 @@ public void pessimisticLockScopeValuesTest() throws Exception { } if (!pass) { - throw new Fault("pessimisticLockScopeValuesTest failed"); + throw new Exception("pessimisticLockScopeValuesTest failed"); } } @@ -1817,7 +1810,7 @@ public void sharedCacheModeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("sharedCacheModeValueOfTest failed"); + throw new Exception("sharedCacheModeValueOfTest failed"); } } @@ -1887,7 +1880,7 @@ public void sharedCacheModeValuesTest() throws Exception { } if (!pass) { - throw new Fault("sharedCacheModeValuesTest failed"); + throw new Exception("sharedCacheModeValuesTest failed"); } } @@ -1943,7 +1936,7 @@ public void validationModeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("validationModeValueOfTest failed"); + throw new Exception("validationModeValueOfTest failed"); } } @@ -2001,7 +1994,7 @@ public void validationModeValuesTest() throws Exception { } if (!pass) { - throw new Fault("validationModeValuesTest failed"); + throw new Exception("validationModeValuesTest failed"); } } @@ -2051,7 +2044,7 @@ public void temporalTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("temporalTypeValuesTest failed"); + throw new Exception("temporalTypeValuesTest failed"); } } @@ -2108,7 +2101,7 @@ public void temporalTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("temporalTypeValueOfTest failed"); + throw new Exception("temporalTypeValueOfTest failed"); } } @@ -2158,7 +2151,7 @@ public void joinTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("joinTypeValuesTest failed"); + throw new Exception("joinTypeValuesTest failed"); } } @@ -2214,7 +2207,7 @@ public void joinTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("joinTypeValueOfTest failed"); + throw new Exception("joinTypeValueOfTest failed"); } } @@ -2293,7 +2286,7 @@ public void persistentAttributeTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("persistentAttributeTypeValuesTest failed"); + throw new Exception("persistentAttributeTypeValuesTest failed"); } } @@ -2381,7 +2374,7 @@ public void persistentAttributeTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("persistentAttributeTypeValueOfTest failed"); + throw new Exception("persistentAttributeTypeValueOfTest failed"); } } @@ -2433,7 +2426,7 @@ public void bindableTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("bindableTypeValuesTest failed"); + throw new Exception("bindableTypeValuesTest failed"); } } @@ -2488,7 +2481,7 @@ public void bindableTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("bindableTypeValueOfTest failed"); + throw new Exception("bindableTypeValueOfTest failed"); } } @@ -2545,7 +2538,7 @@ public void collectionTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("collectionTypeValuesTest failed"); + throw new Exception("collectionTypeValuesTest failed"); } } @@ -2607,7 +2600,7 @@ public void collectionTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("collectionTypeValueOfTest failed"); + throw new Exception("collectionTypeValueOfTest failed"); } } @@ -2663,7 +2656,7 @@ public void persistenceTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("persistenceTypeValuesTest failed"); + throw new Exception("persistenceTypeValuesTest failed"); } } @@ -2725,7 +2718,7 @@ public void persistenceTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("persistenceTypeValueOfTest failed"); + throw new Exception("persistenceTypeValueOfTest failed"); } } @@ -2776,7 +2769,7 @@ public void loadStateValuesTest() throws Exception { } if (!pass) { - throw new Fault("loadStateValuesTest failed"); + throw new Exception("loadStateValuesTest failed"); } } @@ -2831,7 +2824,7 @@ public void loadStateValueOfTest() throws Exception { } if (!pass) { - throw new Fault("loadStateValueOfTest failed"); + throw new Exception("loadStateValueOfTest failed"); } } @@ -2880,7 +2873,7 @@ public void persistenceUnitTransactionTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("persistenceUnitTransactionTypeValuesTest failed"); + throw new Exception("persistenceUnitTransactionTypeValuesTest failed"); } } @@ -2932,7 +2925,7 @@ public void persistenceUnitTransactionTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("persistenceUnitTransactionTypeValueOfTest failed"); + throw new Exception("persistenceUnitTransactionTypeValueOfTest failed"); } } @@ -2990,7 +2983,7 @@ public void parameterModeValuesTest() throws Exception { } if (!pass) { - throw new Fault("parameterModeValuesTest failed"); + throw new Exception("parameterModeValuesTest failed"); } } @@ -3051,7 +3044,7 @@ public void parameterModeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("parameterModeValueOfTest failed"); + throw new Exception("parameterModeValueOfTest failed"); } } @@ -3102,7 +3095,7 @@ public void synchronizationTypeValueOfTest() throws Exception { } if (!pass) { - throw new Fault("synchronizationTypeValueOfTest failed"); + throw new Exception("synchronizationTypeValueOfTest failed"); } } @@ -3154,7 +3147,7 @@ public void synchronizationTypeValuesTest() throws Exception { } if (!pass) { - throw new Fault("synchronizationTypeValuesTest failed"); + throw new Exception("synchronizationTypeValuesTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/exceptions/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/exceptions/Client.java index fd51c40411..c387832d46 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/exceptions/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/exceptions/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.exceptions; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -40,21 +37,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); TestUtil.logTrace("Cleanup data"); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -94,7 +86,7 @@ public void TransactionRequiredExceptionTest() throws Exception { } if (!pass) - throw new Fault("TransactionRequiredExceptionTest failed"); + throw new Exception("TransactionRequiredExceptionTest failed"); } /* * @testName: TransactionRequiredException2Test @@ -150,7 +142,7 @@ public void TransactionRequiredException2Test() throws Exception { } if (!pass) - throw new Fault("TransactionRequiredException2Test failed"); + throw new Exception("TransactionRequiredException2Test failed"); } /* @@ -194,7 +186,7 @@ public void exceptionTest2() throws Exception { } if (!pass) - throw new Fault("exceptionTest2 failed"); + throw new Exception("exceptionTest2 failed"); } @@ -250,7 +242,7 @@ public void exceptionTest3() throws Exception { } if (!pass) - throw new Fault("exceptionTest3 failed"); + throw new Exception("exceptionTest3 failed"); } /* @@ -305,7 +297,7 @@ public void exceptionTest4() throws Exception { } if (!pass) - throw new Fault("exceptionTest4 failed"); + throw new Exception("exceptionTest4 failed"); } /* @@ -350,7 +342,7 @@ public void exceptionTest5() throws Exception { } if (!pass) - throw new Fault("exceptionTest5 failed"); + throw new Exception("exceptionTest5 failed"); } /* @@ -397,7 +389,7 @@ public void exceptionTest6() throws Exception { } if (!pass) - throw new Fault("exceptionTest6 failed"); + throw new Exception("exceptionTest6 failed"); } /* @@ -521,7 +513,7 @@ public void RollbackExceptionTest() throws Exception { } if (!pass) - throw new Fault("RollbackExceptionTest failed"); + throw new Exception("RollbackExceptionTest failed"); } /* @@ -649,7 +641,7 @@ public void EntityExistsExceptionTest() throws Exception { } if (!pass) - throw new Fault("EntityExistsExceptionTest failed"); + throw new Exception("EntityExistsExceptionTest failed"); } /* @@ -706,7 +698,7 @@ public void EntityNotFoundExceptionTest() throws Exception { } if (!pass) - throw new Fault("EntityNotFoundExceptionTest failed"); + throw new Exception("EntityNotFoundExceptionTest failed"); } /* @@ -909,7 +901,7 @@ public void OptimisticLockExceptionTest() throws Exception { } if (!pass) - throw new Fault("OptimisticLockExceptionTest failed"); + throw new Exception("OptimisticLockExceptionTest failed"); } /* @@ -1037,7 +1029,7 @@ public void PersistenceExceptionTest() throws Exception { } if (!pass) - throw new Fault("PersistenceExceptionTest failed"); + throw new Exception("PersistenceExceptionTest failed"); } /* @@ -1240,7 +1232,7 @@ public void LockTimeoutExceptionTest() throws Exception { } if (!pass) - throw new Fault("LockTimeoutExceptionTest failed"); + throw new Exception("LockTimeoutExceptionTest failed"); } /* @@ -1442,7 +1434,7 @@ public void PessimisticLockExceptionTest() throws Exception { } if (!pass) - throw new Fault("PessimisticLockExceptionTest failed"); + throw new Exception("PessimisticLockExceptionTest failed"); } /* @@ -1646,7 +1638,7 @@ public void QueryTimeoutExceptionTest() throws Exception { } if (!pass) - throw new Fault("QueryTimeoutExceptionTest failed"); + throw new Exception("QueryTimeoutExceptionTest failed"); } /* @@ -1703,7 +1695,7 @@ public void NonUniqueResultExceptionTest() throws Exception { } if (!pass) - throw new Fault("NonUniqueResultExceptionTest failed"); + throw new Exception("NonUniqueResultExceptionTest failed"); } /* * @testName: NoResultExceptionTest @@ -1754,7 +1746,7 @@ public void NoResultExceptionTest() throws Exception { } if (!pass) - throw new Fault("NoResultExceptionTest failed"); + throw new Exception("NoResultExceptionTest failed"); } public void cleanup() throws Exception { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/abstractentity/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/abstractentity/Client.java index 7d9a4dad4c..6423c96401 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/abstractentity/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/abstractentity/Client.java @@ -23,9 +23,7 @@ import java.sql.Date; import java.util.Iterator; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -58,23 +56,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -111,7 +104,7 @@ public void abstractEntityTest1() throws Exception { } if (!pass) - throw new Fault("abstractEntityTest1 failed"); + throw new Exception("abstractEntityTest1 failed"); } /* @@ -146,7 +139,7 @@ public void abstractEntityTest2() throws Exception { } if (!pass) - throw new Fault("abstractEntityTest2 failed"); + throw new Exception("abstractEntityTest2 failed"); } /* @@ -219,7 +212,7 @@ public void abstractEntityTest3() throws Exception { } if (!pass1 || !pass2) - throw new Fault("abstractEntityTest3 failed"); + throw new Exception("abstractEntityTest3 failed"); } public void createTestData() { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/annotation/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/annotation/Client.java index ab530be836..2cbfb88297 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/annotation/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/annotation/Client.java @@ -21,9 +21,7 @@ package com.sun.ts.tests.jpa.core.inheritance.mappedsc.annotation; import java.sql.Date; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -56,24 +54,19 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -108,7 +101,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -142,7 +135,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } public void createTestData() { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/descriptors/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/descriptors/Client.java index d86a56f51a..ae385268da 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/descriptors/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/mappedsc/descriptors/Client.java @@ -21,9 +21,7 @@ package com.sun.ts.tests.jpa.core.inheritance.mappedsc.descriptors; import java.sql.Date; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -56,22 +54,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -105,7 +98,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -138,7 +131,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } public void createTestData() { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/nonentity/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/nonentity/Client.java index 0f1fe3f1f2..8a07a41f4c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/nonentity/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/inheritance/nonentity/Client.java @@ -21,9 +21,7 @@ package com.sun.ts.tests.jpa.core.inheritance.nonentity; import java.sql.Date; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -56,22 +54,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -117,7 +110,7 @@ public void nonEntityTest1() throws Exception { } if (!pass) - throw new Fault("nonEntityTest1 failed, reason: " + reason); + throw new Exception("nonEntityTest1 failed, reason: " + reason); } /* @@ -160,7 +153,7 @@ public void nonEntityTest2() throws Exception { } if (!pass) - throw new Fault("nonEntityTest2 failed, reason: " + reason); + throw new Exception("nonEntityTest2 failed, reason: " + reason); } /* @@ -206,7 +199,7 @@ public void nonEntityTest3() throws Exception { } if (!pass) - throw new Fault("nonEntityTest3 failed, reason: " + reason); + throw new Exception("nonEntityTest3 failed, reason: " + reason); } public void createTestData() { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/entitymanager/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/entitymanager/Client.java index e2d4912968..6702e30e3b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/entitymanager/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/entitymanager/Client.java @@ -18,9 +18,7 @@ import java.util.HashMap; import java.util.Map; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,16 +29,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); TestUtil.logTrace("Cleanup data"); removeTestData(); TestUtil.logTrace("Create Test data"); @@ -49,7 +42,7 @@ public void setup(String[] args, Properties p) throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -107,7 +100,7 @@ public void findTest1() throws Exception { } if (!pass) { - throw new Fault("findTest1 failed"); + throw new Exception("findTest1 failed"); } } @@ -173,7 +166,7 @@ public void findTest2() throws Exception { } if (!pass) { - throw new Fault("findTest2 failed"); + throw new Exception("findTest2 failed"); } } @@ -225,7 +218,7 @@ public void findTest3() throws Exception { } if (!pass) { - throw new Fault("findTest3 failed"); + throw new Exception("findTest3 failed"); } } @@ -276,7 +269,7 @@ public void findTest4() throws Exception { } if (!pass) { - throw new Fault("findTest4 failed"); + throw new Exception("findTest4 failed"); } } @@ -325,7 +318,7 @@ public void lockTest1() throws Exception { } if (!pass) { - throw new Fault("lockTest1 failed"); + throw new Exception("lockTest1 failed"); } } @@ -379,7 +372,7 @@ public void lockTest2() throws Exception { } if (!pass) { - throw new Fault("lockTest2 failed"); + throw new Exception("lockTest2 failed"); } } @@ -429,7 +422,7 @@ public void refreshTest1() throws Exception { } if (!pass) { - throw new Fault("refreshTest1 failed"); + throw new Exception("refreshTest1 failed"); } } @@ -485,7 +478,7 @@ public void refreshTest2() throws Exception { } if (!pass) { - throw new Fault("refreshTest2 failed"); + throw new Exception("refreshTest2 failed"); } } @@ -537,7 +530,7 @@ public void refreshTest3() throws Exception { } if (!pass) { - throw new Fault("refreshTest3 failed"); + throw new Exception("refreshTest3 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/query/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/query/Client.java index 3a458ddd5b..51cf6c85ce 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/query/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/lock/query/Client.java @@ -18,9 +18,7 @@ import java.sql.Date; import java.util.Collection; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -37,16 +35,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); TestUtil.logTrace("Create Test Data"); removeTestData(); @@ -55,7 +48,7 @@ public void setup(String[] args, Properties p) throws Exception { } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -241,7 +234,7 @@ public void getResultListTest1() throws Exception { } if (!pass) { - throw new Fault("getResultListTest1 failed"); + throw new Exception("getResultListTest1 failed"); } } @@ -280,7 +273,7 @@ public void getLockModeNONSELECTIllegalStateExceptionTest() throws Exception { } } if (!pass) { - throw new Fault("getLockModeNONSELECTIllegalStateExceptionTest failed"); + throw new Exception("getLockModeNONSELECTIllegalStateExceptionTest failed"); } } @@ -326,7 +319,7 @@ public void getLockModeObjectIllegalArgumentExceptionTest() throws Exception { } if (!pass) { - throw new Fault("getLockModeObjectIllegalArgumentExceptionTest failed"); + throw new Exception("getLockModeObjectIllegalArgumentExceptionTest failed"); } } @@ -390,7 +383,7 @@ public void getLockModeObjectTransactionRequiredException1Test() } if (!pass) { - throw new Fault( + throw new Exception( "getLockModeObjectTransactionRequiredException1Test failed"); } } @@ -451,7 +444,7 @@ public void getLockModeObjectIllegalArgumentException1Test() throws Exception { } if (!pass) { - throw new Fault("getLockModeObjectIllegalArgumentException1Test failed"); + throw new Exception("getLockModeObjectIllegalArgumentException1Test failed"); } } /* @@ -502,7 +495,7 @@ public void setLockModeIllegalStateException() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setLockModeIllegalStateException failed"); + throw new Exception("setLockModeIllegalStateException failed"); } } @@ -559,7 +552,7 @@ public void getResultListTest2() throws Exception { } if (!pass) { - throw new Fault("getResultListTest2 failed"); + throw new Exception("getResultListTest2 failed"); } } @@ -612,7 +605,7 @@ public void getSingleResultTest() throws Exception { } if (!pass) { - throw new Fault("getSingleResultTest failed"); + throw new Exception("getSingleResultTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/attribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/attribute/Client.java index 6c8567cac1..40a394c2d0 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/attribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/attribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.attribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +28,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -88,7 +80,7 @@ public void getName() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getName Test failed"); + throw new Exception("getName Test failed"); } } @@ -132,7 +124,7 @@ public void getPersistentAttributeType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPersistentAttributeType Test failed"); + throw new Exception("getPersistentAttributeType Test failed"); } } @@ -179,7 +171,7 @@ public void getDeclaringType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaringType Test failed"); + throw new Exception("getDeclaringType Test failed"); } } @@ -219,7 +211,7 @@ public void getJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaType Test failed"); + throw new Exception("getJavaType Test failed"); } } @@ -262,7 +254,7 @@ public void getJavaMember() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaMember Test failed"); + throw new Exception("getJavaMember Test failed"); } } @@ -304,7 +296,7 @@ public void isAssociation() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isAssociation Test failed"); + throw new Exception("isAssociation Test failed"); } } @@ -346,7 +338,7 @@ public void isCollection() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isCollection Test failed"); + throw new Exception("isCollection Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/basictype/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/basictype/Client.java index 90a3fcb88b..42e540c4b1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/basictype/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/basictype/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.basictype; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +30,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -90,7 +82,7 @@ public void getJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaType Test failed"); + throw new Exception("getJavaType Test failed"); } } @@ -134,7 +126,7 @@ public void getPersistenceType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPersistenceType failed"); + throw new Exception("getPersistenceType failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/bindable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/bindable/Client.java index ec5ceaa48c..80b74aaa1f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/bindable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/bindable/Client.java @@ -16,10 +16,8 @@ package com.sun.ts.tests.jpa.core.metamodelapi.bindable; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,20 +30,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -84,7 +77,7 @@ public void getBindableType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableType failed"); + throw new Exception("getBindableType failed"); } } @@ -128,7 +121,7 @@ public void getBindableJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableJavaType failed"); + throw new Exception("getBindableJavaType failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/collectionattribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/collectionattribute/Client.java index 0a30699491..8e6b8cb32d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/collectionattribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/collectionattribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.collectionattribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,19 +29,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -94,7 +86,7 @@ public void getCollectionType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionType Test failed"); + throw new Exception("getCollectionType Test failed"); } } @@ -140,7 +132,7 @@ public void getElementType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getElementType Test failed"); + throw new Exception("getElementType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/embeddabletype/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/embeddabletype/Client.java index 945feda4dc..1fdad70e3f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/embeddabletype/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/embeddabletype/Client.java @@ -21,10 +21,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -42,20 +40,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -123,7 +116,7 @@ public void embeddableTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("embeddableTest failed"); + throw new Exception("embeddableTest failed"); } } @@ -168,7 +161,7 @@ public void getAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getAttribute failed"); + throw new Exception("getAttribute failed"); } } @@ -209,7 +202,7 @@ public void getAttributeIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getAttributeIllegalArgumentException failed"); + throw new Exception("getAttributeIllegalArgumentException failed"); } } @@ -288,7 +281,7 @@ public void getAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getAttributes failed"); + throw new Exception("getAttributes failed"); } } @@ -334,7 +327,7 @@ public void getCollectionStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionStringClass failed"); + throw new Exception("getCollectionStringClass failed"); } } @@ -374,7 +367,7 @@ public void getCollectionStringClassIllegalArgumentException() throws Exception getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getCollectionStringClassIllegalArgumentException failed"); } } @@ -420,7 +413,7 @@ public void getCollectionString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionString failed"); + throw new Exception("getCollectionString failed"); } } @@ -460,7 +453,7 @@ public void getCollectionStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionStringIllegalArgumentException failed"); + throw new Exception("getCollectionStringIllegalArgumentException failed"); } } @@ -505,7 +498,7 @@ public void getDeclaredAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredAttribute failed"); + throw new Exception("getDeclaredAttribute failed"); } } @@ -545,7 +538,7 @@ public void getDeclaredAttributeIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredAttributeIllegalArgumentException failed"); + throw new Exception("getDeclaredAttributeIllegalArgumentException failed"); } } @@ -624,7 +617,7 @@ public void getDeclaredAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredAttributes failed"); + throw new Exception("getDeclaredAttributes failed"); } } @@ -670,7 +663,7 @@ public void getDeclaredCollectionStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredCollectionStringClass failed"); + throw new Exception("getDeclaredCollectionStringClass failed"); } } @@ -711,7 +704,7 @@ public void getDeclaredCollectionStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredCollectionStringClassIllegalArgumentException failed"); } } @@ -758,7 +751,7 @@ public void getDeclaredCollectionString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredCollectionString failed"); + throw new Exception("getDeclaredCollectionString failed"); } } @@ -799,7 +792,7 @@ public void getDeclaredCollectionStringIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredCollectionStringIllegalArgumentException failed"); } } @@ -846,7 +839,7 @@ public void getDeclaredListStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredListStringClass failed"); + throw new Exception("getDeclaredListStringClass failed"); } } @@ -887,7 +880,7 @@ public void getDeclaredListStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredListStringClassIllegalArgumentException failed"); } } @@ -933,7 +926,7 @@ public void getDeclaredListString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredListString failed"); + throw new Exception("getDeclaredListString failed"); } } @@ -973,7 +966,7 @@ public void getDeclaredListStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredListStringIllegalArgumentException failed"); + throw new Exception("getDeclaredListStringIllegalArgumentException failed"); } } @@ -1019,7 +1012,7 @@ public void getDeclaredMapStringClassClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredMapStringClassClass failed"); + throw new Exception("getDeclaredMapStringClassClass failed"); } } @@ -1060,7 +1053,7 @@ public void getDeclaredMapStringClassClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredMapStringClassClassIllegalArgumentException failed"); } } @@ -1106,7 +1099,7 @@ public void getDeclaredMapString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredMapString failed"); + throw new Exception("getDeclaredMapString failed"); } } @@ -1146,7 +1139,7 @@ public void getDeclaredMapStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredMapStringIllegalArgumentException failed"); + throw new Exception("getDeclaredMapStringIllegalArgumentException failed"); } } @@ -1191,7 +1184,7 @@ public void getDeclaredSetStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSetStringClass failed"); + throw new Exception("getDeclaredSetStringClass failed"); } } @@ -1231,7 +1224,7 @@ public void getDeclaredSetStringClassIllegalArgumentException() throws Exception getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSetStringClassIllegalArgumentException failed"); } } @@ -1277,7 +1270,7 @@ public void getDeclaredSetString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSetString failed"); + throw new Exception("getDeclaredSetString failed"); } } @@ -1317,7 +1310,7 @@ public void getDeclaredSetStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSetStringIllegalArgumentException failed"); + throw new Exception("getDeclaredSetStringIllegalArgumentException failed"); } } @@ -1363,7 +1356,7 @@ public void getDeclaredSingularAttributeStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSingularAttributeStringClass failed"); + throw new Exception("getDeclaredSingularAttributeStringClass failed"); } } @@ -1405,7 +1398,7 @@ public void getDeclaredSingularAttributeStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSingularAttributeStringClassIllegalArgumentException failed"); } } @@ -1452,7 +1445,7 @@ public void getDeclaredSingularAttributeString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSingularAttributeString failed"); + throw new Exception("getDeclaredSingularAttributeString failed"); } } @@ -1494,7 +1487,7 @@ public void getDeclaredSingularAttributeStringIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSingularAttributeStringIllegalArgumentException failed"); } } @@ -1571,7 +1564,7 @@ public void getDeclaredSingularAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSingularAttributes failed"); + throw new Exception("getDeclaredSingularAttributes failed"); } } @@ -1616,7 +1609,7 @@ public void getListStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListStringClass failed"); + throw new Exception("getListStringClass failed"); } } @@ -1656,7 +1649,7 @@ public void getListStringClassIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListStringClassIllegalArgumentException failed"); + throw new Exception("getListStringClassIllegalArgumentException failed"); } } @@ -1701,7 +1694,7 @@ public void getListString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListString failed"); + throw new Exception("getListString failed"); } } @@ -1741,7 +1734,7 @@ public void getListStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListStringIllegalArgumentException failed"); + throw new Exception("getListStringIllegalArgumentException failed"); } } @@ -1787,7 +1780,7 @@ public void getMapStringClassClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapStringClassClass failed"); + throw new Exception("getMapStringClassClass failed"); } } @@ -1827,7 +1820,7 @@ public void getMapStringClassClassIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapStringClassClassIllegalArgumentException failed"); + throw new Exception("getMapStringClassClassIllegalArgumentException failed"); } } @@ -1872,7 +1865,7 @@ public void getMapString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapString failed"); + throw new Exception("getMapString failed"); } } @@ -1912,7 +1905,7 @@ public void getMapStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapStringIllegalArgumentException failed"); + throw new Exception("getMapStringIllegalArgumentException failed"); } } @@ -1988,7 +1981,7 @@ public void getPluralAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPluralAttributes failed"); + throw new Exception("getPluralAttributes failed"); } } @@ -2033,7 +2026,7 @@ public void getSetStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetStringClass failed"); + throw new Exception("getSetStringClass failed"); } } @@ -2073,7 +2066,7 @@ public void getSetStringClassIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetStringClassIllegalArgumentException failed"); + throw new Exception("getSetStringClassIllegalArgumentException failed"); } } @@ -2118,7 +2111,7 @@ public void getSetString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetString failed"); + throw new Exception("getSetString failed"); } } @@ -2158,7 +2151,7 @@ public void getSetStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetStringIllegalArgumentException failed"); + throw new Exception("getSetStringIllegalArgumentException failed"); } } @@ -2204,7 +2197,7 @@ public void getSingularAttributeStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSingularAttributeStringClass failed"); + throw new Exception("getSingularAttributeStringClass failed"); } } @@ -2246,7 +2239,7 @@ public void getSingularAttributeStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getSingularAttributeStringClassIllegalArgumentException failed"); } } @@ -2292,7 +2285,7 @@ public void getSingularAttributeString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSingularAttributeString failed"); + throw new Exception("getSingularAttributeString failed"); } } @@ -2334,7 +2327,7 @@ public void getSingularAttributeStringIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getSingularAttributeStringIllegalArgumentException failed"); } } @@ -2410,7 +2403,7 @@ public void getSingularAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSingularAttributes failed"); + throw new Exception("getSingularAttributes failed"); } } @@ -2485,7 +2478,7 @@ public void getDeclaredPluralAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredPluralAttributes failed"); + throw new Exception("getDeclaredPluralAttributes failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/entitytype/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/entitytype/Client.java index cfb2f17d3d..f2168caf3c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/entitytype/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/entitytype/Client.java @@ -18,10 +18,8 @@ import java.util.Date; import java.util.HashSet; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -37,20 +35,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -89,7 +82,7 @@ public void getName() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getName failed"); + throw new Exception("getName failed"); } } /* @@ -131,7 +124,7 @@ public void getDeclaredId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredId failed"); + throw new Exception("getDeclaredId failed"); } } @@ -173,7 +166,7 @@ public void getDeclaredIdIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredIdIllegalArgumentException failed"); + throw new Exception("getDeclaredIdIllegalArgumentException failed"); } } @@ -213,7 +206,7 @@ public void getDeclaredVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredVersion failed"); + throw new Exception("getDeclaredVersion failed"); } } @@ -254,7 +247,7 @@ public void getDeclaredVersionIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredVersionIllegalArgumentException failed"); + throw new Exception("getDeclaredVersionIllegalArgumentException failed"); } } @@ -295,7 +288,7 @@ public void getId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getId failed"); + throw new Exception("getId failed"); } } @@ -337,7 +330,7 @@ public void getIdIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdIllegalArgumentException failed"); + throw new Exception("getIdIllegalArgumentException failed"); } } @@ -408,7 +401,7 @@ public void getIdClassAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdClassAttributes failed"); + throw new Exception("getIdClassAttributes failed"); } } @@ -449,7 +442,7 @@ public void getIdClassAttributesIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdClassAttributesIllegalArgumentException failed"); + throw new Exception("getIdClassAttributesIllegalArgumentException failed"); } } @@ -489,7 +482,7 @@ public void getIdType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdType failed"); + throw new Exception("getIdType failed"); } } @@ -529,7 +522,7 @@ public void getSupertype() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSupertype failed"); + throw new Exception("getSupertype failed"); } } @@ -569,7 +562,7 @@ public void getVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getVersion failed"); + throw new Exception("getVersion failed"); } } @@ -610,7 +603,7 @@ public void getVersionIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getVersionIllegalArgumentException failed"); + throw new Exception("getVersionIllegalArgumentException failed"); } } @@ -653,7 +646,7 @@ public void hasSingleIdAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("hasSingleIdAttribute failed"); + throw new Exception("hasSingleIdAttribute failed"); } } @@ -695,7 +688,7 @@ public void hasVersionAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("hasVersionAttribute failed"); + throw new Exception("hasVersionAttribute failed"); } } @@ -739,7 +732,7 @@ public void getBindableJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableJavaType failed"); + throw new Exception("getBindableJavaType failed"); } } @@ -783,7 +776,7 @@ public void getBindableType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableType failed"); + throw new Exception("getBindableType failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/identifiabletype/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/identifiabletype/Client.java index 64f3d9919c..e7547938c1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/identifiabletype/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/identifiabletype/Client.java @@ -21,10 +21,8 @@ import java.util.Date; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -44,20 +42,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -98,7 +91,7 @@ public void getId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getId failed"); + throw new Exception("getId failed"); } } @@ -140,7 +133,7 @@ public void getIdIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdIllegalArgumentException failed"); + throw new Exception("getIdIllegalArgumentException failed"); } } @@ -180,7 +173,7 @@ public void getVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getVersion failed"); + throw new Exception("getVersion failed"); } } @@ -221,7 +214,7 @@ public void getVersionIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getVersionIllegalArgumentException failed"); + throw new Exception("getVersionIllegalArgumentException failed"); } } @@ -264,7 +257,7 @@ public void getDeclaredId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredId failed"); + throw new Exception("getDeclaredId failed"); } } @@ -306,7 +299,7 @@ public void getDeclaredIdIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredIdIllegalArgumentException failed"); + throw new Exception("getDeclaredIdIllegalArgumentException failed"); } } @@ -351,7 +344,7 @@ public void getDeclaredVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredVersion failed"); + throw new Exception("getDeclaredVersion failed"); } } @@ -396,7 +389,7 @@ public void getDeclaredVersionIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredVersionIllegalArgumentException failed"); + throw new Exception("getDeclaredVersionIllegalArgumentException failed"); } } @@ -438,7 +431,7 @@ public void getSupertype() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSupertype failed"); + throw new Exception("getSupertype failed"); } } @@ -482,7 +475,7 @@ public void hasSingleIdAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("hasSingleIdAttribute failed"); + throw new Exception("hasSingleIdAttribute failed"); } } @@ -525,7 +518,7 @@ public void hasVersionAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("hasVersionAttribute failed"); + throw new Exception("hasVersionAttribute failed"); } } @@ -567,7 +560,7 @@ public void getIdClassAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdClassAttributes failed"); + throw new Exception("getIdClassAttributes failed"); } } @@ -608,7 +601,7 @@ public void getIdClassAttributesIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdClassAttributesIllegalArgumentException failed"); + throw new Exception("getIdClassAttributesIllegalArgumentException failed"); } } @@ -655,7 +648,7 @@ public void getIdType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdType failed"); + throw new Exception("getIdType failed"); } } @@ -700,7 +693,7 @@ public void getAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getAttribute failed"); + throw new Exception("getAttribute failed"); } } @@ -741,7 +734,7 @@ public void getAttributeIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getAttributeIllegalArgumentException failed"); + throw new Exception("getAttributeIllegalArgumentException failed"); } } @@ -824,7 +817,7 @@ public void getAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getAttributes failed"); + throw new Exception("getAttributes failed"); } } @@ -870,7 +863,7 @@ public void getCollectionStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionStringClass failed"); + throw new Exception("getCollectionStringClass failed"); } } @@ -910,7 +903,7 @@ public void getCollectionStringClassIllegalArgumentException() throws Exception getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getCollectionStringClassIllegalArgumentException failed"); } } @@ -956,7 +949,7 @@ public void getCollectionString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionString failed"); + throw new Exception("getCollectionString failed"); } } @@ -996,7 +989,7 @@ public void getCollectionStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionStringIllegalArgumentException failed"); + throw new Exception("getCollectionStringIllegalArgumentException failed"); } } @@ -1041,7 +1034,7 @@ public void getDeclaredAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredAttribute failed"); + throw new Exception("getDeclaredAttribute failed"); } } @@ -1081,7 +1074,7 @@ public void getDeclaredAttributeIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredAttributeIllegalArgumentException failed"); + throw new Exception("getDeclaredAttributeIllegalArgumentException failed"); } } @@ -1159,7 +1152,7 @@ public void getDeclaredAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredAttributes failed"); + throw new Exception("getDeclaredAttributes failed"); } } @@ -1205,7 +1198,7 @@ public void getDeclaredCollectionStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredCollectionStringClass failed"); + throw new Exception("getDeclaredCollectionStringClass failed"); } } @@ -1246,7 +1239,7 @@ public void getDeclaredCollectionStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredCollectionStringClassIllegalArgumentException failed"); } } @@ -1293,7 +1286,7 @@ public void getDeclaredCollectionString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredCollectionString failed"); + throw new Exception("getDeclaredCollectionString failed"); } } @@ -1334,7 +1327,7 @@ public void getDeclaredCollectionStringIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredCollectionStringIllegalArgumentException failed"); } } @@ -1381,7 +1374,7 @@ public void getDeclaredListStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredListStringClass failed"); + throw new Exception("getDeclaredListStringClass failed"); } } @@ -1422,7 +1415,7 @@ public void getDeclaredListStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredListStringClassIllegalArgumentException failed"); } } @@ -1468,7 +1461,7 @@ public void getDeclaredListString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredListString failed"); + throw new Exception("getDeclaredListString failed"); } } @@ -1508,7 +1501,7 @@ public void getDeclaredListStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredListStringIllegalArgumentException failed"); + throw new Exception("getDeclaredListStringIllegalArgumentException failed"); } } @@ -1554,7 +1547,7 @@ public void getDeclaredMapStringClassClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredMapStringClassClass failed"); + throw new Exception("getDeclaredMapStringClassClass failed"); } } @@ -1596,7 +1589,7 @@ public void getDeclaredMapStringClassClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredMapStringClassClassIllegalArgumentException failed"); } } @@ -1642,7 +1635,7 @@ public void getDeclaredMapString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredMapString failed"); + throw new Exception("getDeclaredMapString failed"); } } @@ -1682,7 +1675,7 @@ public void getDeclaredMapStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredMapStringIllegalArgumentException failed"); + throw new Exception("getDeclaredMapStringIllegalArgumentException failed"); } } @@ -1727,7 +1720,7 @@ public void getDeclaredSetStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSetStringClass failed"); + throw new Exception("getDeclaredSetStringClass failed"); } } @@ -1767,7 +1760,7 @@ public void getDeclaredSetStringClassIllegalArgumentException() throws Exception getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSetStringClassIllegalArgumentException failed"); } } @@ -1813,7 +1806,7 @@ public void getDeclaredSetString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSetString failed"); + throw new Exception("getDeclaredSetString failed"); } } @@ -1853,7 +1846,7 @@ public void getDeclaredSetStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSetStringIllegalArgumentException failed"); + throw new Exception("getDeclaredSetStringIllegalArgumentException failed"); } } @@ -1899,7 +1892,7 @@ public void getDeclaredSingularAttributeStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSingularAttributeStringClass failed"); + throw new Exception("getDeclaredSingularAttributeStringClass failed"); } } @@ -1941,7 +1934,7 @@ public void getDeclaredSingularAttributeStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSingularAttributeStringClassIllegalArgumentException failed"); } } @@ -1988,7 +1981,7 @@ public void getDeclaredSingularAttributeString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSingularAttributeString failed"); + throw new Exception("getDeclaredSingularAttributeString failed"); } } @@ -2030,7 +2023,7 @@ public void getDeclaredSingularAttributeStringIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSingularAttributeStringIllegalArgumentException failed"); } } @@ -2107,7 +2100,7 @@ public void getDeclaredSingularAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredSingularAttributes failed"); + throw new Exception("getDeclaredSingularAttributes failed"); } } @@ -2152,7 +2145,7 @@ public void getListStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListStringClass failed"); + throw new Exception("getListStringClass failed"); } } @@ -2192,7 +2185,7 @@ public void getListStringClassIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListStringClassIllegalArgumentException failed"); + throw new Exception("getListStringClassIllegalArgumentException failed"); } } @@ -2237,7 +2230,7 @@ public void getListString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListString failed"); + throw new Exception("getListString failed"); } } @@ -2277,7 +2270,7 @@ public void getListStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getListStringIllegalArgumentException failed"); + throw new Exception("getListStringIllegalArgumentException failed"); } } @@ -2323,7 +2316,7 @@ public void getMapStringClassClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapStringClassClass failed"); + throw new Exception("getMapStringClassClass failed"); } } @@ -2363,7 +2356,7 @@ public void getMapStringClassClassIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapStringClassClassIllegalArgumentException failed"); + throw new Exception("getMapStringClassClassIllegalArgumentException failed"); } } @@ -2408,7 +2401,7 @@ public void getMapString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapString failed"); + throw new Exception("getMapString failed"); } } @@ -2448,7 +2441,7 @@ public void getMapStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getMapStringIllegalArgumentException failed"); + throw new Exception("getMapStringIllegalArgumentException failed"); } } @@ -2528,7 +2521,7 @@ public void getPluralAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPluralAttributes failed"); + throw new Exception("getPluralAttributes failed"); } } @@ -2604,7 +2597,7 @@ public void getDeclaredPluralAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredPluralAttributes failed"); + throw new Exception("getDeclaredPluralAttributes failed"); } } @@ -2649,7 +2642,7 @@ public void getSetStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetStringClass failed"); + throw new Exception("getSetStringClass failed"); } } @@ -2689,7 +2682,7 @@ public void getSetStringClassIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetStringClassIllegalArgumentException failed"); + throw new Exception("getSetStringClassIllegalArgumentException failed"); } } @@ -2734,7 +2727,7 @@ public void getSetString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetString failed"); + throw new Exception("getSetString failed"); } } @@ -2774,7 +2767,7 @@ public void getSetStringIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSetStringIllegalArgumentException failed"); + throw new Exception("getSetStringIllegalArgumentException failed"); } } @@ -2820,7 +2813,7 @@ public void getSingularAttributeStringClass() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSingularAttributeStringClass failed"); + throw new Exception("getSingularAttributeStringClass failed"); } } @@ -2862,7 +2855,7 @@ public void getSingularAttributeStringClassIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getSingularAttributeStringClassIllegalArgumentException failed"); } } @@ -2908,7 +2901,7 @@ public void getSingularAttributeString() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSingularAttributeString failed"); + throw new Exception("getSingularAttributeString failed"); } } @@ -2950,7 +2943,7 @@ public void getSingularAttributeStringIllegalArgumentException() getEntityTransaction().commit(); if (!pass) { - throw new Fault( + throw new Exception( "getSingularAttributeStringIllegalArgumentException failed"); } } @@ -3026,7 +3019,7 @@ public void getSingularAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSingularAttributes failed"); + throw new Exception("getSingularAttributes failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/listattribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/listattribute/Client.java index b8414253b0..b76058cad2 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/listattribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/listattribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.listattribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +30,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -89,7 +81,7 @@ public void getList() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getList Test failed"); + throw new Exception("getList Test failed"); } } @@ -140,7 +132,7 @@ public void getCollectionType() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getCollectionType Test failed"); + throw new Exception("getCollectionType Test failed"); } } @@ -185,7 +177,7 @@ public void getDeclaredList() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredList Test failed"); + throw new Exception("getDeclaredList Test failed"); } } @@ -230,7 +222,7 @@ public void getList2() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getList2 Test failed"); + throw new Exception("getList2 Test failed"); } } @@ -275,7 +267,7 @@ public void getDeclaredList2() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredList2 Test failed"); + throw new Exception("getDeclaredList2 Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/managedtype/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/managedtype/Client.java index 02c5647db6..a4c73b525e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/managedtype/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/managedtype/Client.java @@ -18,10 +18,8 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -41,20 +39,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -91,7 +84,7 @@ public void managedtype() throws Exception { pass = false; } if (!pass) { - throw new Fault("managedtype failed"); + throw new Exception("managedtype failed"); } } @@ -153,7 +146,7 @@ public void getAttributes() throws Exception { pass = false; } if (!pass) { - throw new Fault("getAttributes failed"); + throw new Exception("getAttributes failed"); } } @@ -215,7 +208,7 @@ public void getDeclaredAttributes() throws Exception { pass = false; } if (!pass) { - throw new Fault("getDeclaredAttributes failed"); + throw new Exception("getDeclaredAttributes failed"); } } @@ -263,7 +256,7 @@ public void getSingularAttributeStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getSingularAttributeStringClassTest failed"); + throw new Exception("getSingularAttributeStringClassTest failed"); } } @@ -327,7 +320,7 @@ public void getSingularAttributeStringClassIllegalArgumentExceptionTest() TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getSingularAttributeStringClassIllegalArgumentExceptionTest failed"); } } @@ -376,7 +369,7 @@ public void getSingularAttributeStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getSingularAttributeStringTest failed"); + throw new Exception("getSingularAttributeStringTest failed"); } } @@ -423,7 +416,7 @@ public void getSingularAttributeStringIllegalArgumentExceptionTest() TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getSingularAttributeStringIllegalArgumentExceptionTest failed"); } } @@ -472,7 +465,7 @@ public void getDeclaredSingularAttributeStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredSingularAttributeStringClassTest failed"); + throw new Exception("getDeclaredSingularAttributeStringClassTest failed"); } } @@ -537,7 +530,7 @@ public void getDeclaredSingularAttributeStringClassIllegalArgumentExceptionTest( TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSingularAttributeStringClassIllegalArgumentExceptionTest failed"); } } @@ -586,7 +579,7 @@ public void getDeclaredSingularAttributeStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredSingularAttributeStringTest failed"); + throw new Exception("getDeclaredSingularAttributeStringTest failed"); } } @@ -631,7 +624,7 @@ public void getDeclaredSingularAttributeStringIllegalArgumentExceptionTest() TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSingularAttributeStringIllegalArgumentExceptionTest failed"); } } @@ -695,7 +688,7 @@ public void getDeclaredSingularAttributes() throws Exception { pass = false; } if (!pass) { - throw new Fault("getDeclaredSingularAttributes failed"); + throw new Exception("getDeclaredSingularAttributes failed"); } } @@ -758,7 +751,7 @@ public void getSingularAttributes() throws Exception { pass = false; } if (!pass) { - throw new Fault("getSingularAttributes failed"); + throw new Exception("getSingularAttributes failed"); } } @@ -812,7 +805,7 @@ public void getCollectionStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getCollectionStringTest failed"); + throw new Exception("getCollectionStringTest failed"); } } @@ -858,7 +851,7 @@ public void getCollectionStringIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getCollectionStringIllegalArgumentExceptionTest failed"); + throw new Exception("getCollectionStringIllegalArgumentExceptionTest failed"); } } @@ -912,7 +905,7 @@ public void getCollectionStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getCollectionStringClassTest failed"); + throw new Exception("getCollectionStringClassTest failed"); } } @@ -978,7 +971,7 @@ public void getCollectionStringClassIllegalArgumentExceptionTest() TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getCollectionStringClassIllegalArgumentExceptionTest failed"); } } @@ -1032,7 +1025,7 @@ public void getSetStringClassTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("getSetStringClassTest failed"); + throw new Exception("getSetStringClassTest failed"); } } @@ -1095,7 +1088,7 @@ public void getSetStringClassIllegalArgumentExceptionTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("getSetStringClassIllegalArgumentExceptionTest failed"); + throw new Exception("getSetStringClassIllegalArgumentExceptionTest failed"); } } @@ -1146,7 +1139,7 @@ public void getSetStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getSetStringTest failed"); + throw new Exception("getSetStringTest failed"); } } @@ -1190,7 +1183,7 @@ public void getSetStringIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getSetStringIllegalArgumentExceptionTest failed"); + throw new Exception("getSetStringIllegalArgumentExceptionTest failed"); } } @@ -1243,7 +1236,7 @@ public void getListStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getListStringClassTest failed"); + throw new Exception("getListStringClassTest failed"); } } @@ -1309,7 +1302,7 @@ public void getListStringClassIllegalArgumentExceptionTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("getListStringClassIllegalArgumentExceptionTest failed"); + throw new Exception("getListStringClassIllegalArgumentExceptionTest failed"); } } @@ -1361,7 +1354,7 @@ public void getListStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getListStringTest failed"); + throw new Exception("getListStringTest failed"); } } @@ -1407,7 +1400,7 @@ public void getListStringIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getListStringIllegalArgumentExceptionTest failed"); + throw new Exception("getListStringIllegalArgumentExceptionTest failed"); } } @@ -1460,7 +1453,7 @@ public void getMapStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getMapStringClassTest failed"); + throw new Exception("getMapStringClassTest failed"); } } @@ -1524,7 +1517,7 @@ public void getMapStringClassIllegalArgumentExceptionTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("getMapStringClassIllegalArgumentExceptionTest failed"); + throw new Exception("getMapStringClassIllegalArgumentExceptionTest failed"); } } @@ -1576,7 +1569,7 @@ public void getMapStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getMapStringTest failed"); + throw new Exception("getMapStringTest failed"); } } @@ -1621,7 +1614,7 @@ public void getMapStringIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getMapStringIllegalArgumentExceptionTest failed"); + throw new Exception("getMapStringIllegalArgumentExceptionTest failed"); } } @@ -1676,7 +1669,7 @@ public void getDeclaredCollectionStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredCollectionStringClassTest failed"); + throw new Exception("getDeclaredCollectionStringClassTest failed"); } } @@ -1743,7 +1736,7 @@ public void getDeclaredCollectionStringClassIllegalArgumentExceptionTest() pass = false; } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredCollectionStringClassIllegalArgumentExceptionTest failed"); } } @@ -1798,7 +1791,7 @@ public void getDeclaredCollectionStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredCollectionStringTest failed"); + throw new Exception("getDeclaredCollectionStringTest failed"); } } @@ -1846,7 +1839,7 @@ public void getDeclaredCollectionStringIllegalArgumentExceptionTest() TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredCollectionStringIllegalArgumentExceptionTest failed"); } } @@ -1899,7 +1892,7 @@ public void getDeclaredSetStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredSetStringClassTest failed"); + throw new Exception("getDeclaredSetStringClassTest failed"); } } @@ -1965,7 +1958,7 @@ public void getDeclaredSetStringClassIllegalArgumentExceptionTest() pass = false; } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSetStringClassIllegalArgumentExceptionTest failed"); } } @@ -2018,7 +2011,7 @@ public void getDeclaredSetStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredSetStringTest failed"); + throw new Exception("getDeclaredSetStringTest failed"); } } @@ -2063,7 +2056,7 @@ public void getDeclaredSetStringIllegalArgumentExceptionTest() throws Exception TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredSetStringIllegalArgumentExceptionTest failed"); } } @@ -2118,7 +2111,7 @@ public void getDeclaredListStringClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredListStringClassTest failed"); + throw new Exception("getDeclaredListStringClassTest failed"); } } @@ -2186,7 +2179,7 @@ public void getDeclaredListStringClassIllegalArgumentExceptionTest() pass = false; } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredListStringClassIllegalArgumentExceptionTest failed"); } } @@ -2240,7 +2233,7 @@ public void getDeclaredListStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredListStringTest failed"); + throw new Exception("getDeclaredListStringTest failed"); } } @@ -2287,7 +2280,7 @@ public void getDeclaredListStringIllegalArgumentExceptionTest() throws Exception TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredListStringIllegalArgumentExceptionTest failed"); } } @@ -2341,7 +2334,7 @@ public void getDeclaredMapStringClassClassTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredMapStringClassClassTest failed"); + throw new Exception("getDeclaredMapStringClassClassTest failed"); } } @@ -2408,7 +2401,7 @@ public void getDeclaredMapStringClassClassIllegalArgumentExceptionTest() pass = false; } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredMapStringClassClassIllegalArgumentExceptionTest failed"); } } @@ -2461,7 +2454,7 @@ public void getDeclaredMapStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredMapStringTest failed"); + throw new Exception("getDeclaredMapStringTest failed"); } } @@ -2506,7 +2499,7 @@ public void getDeclaredMapStringIllegalArgumentExceptionTest() throws Exception TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredMapStringIllegalArgumentExceptionTest failed"); } } @@ -2568,7 +2561,7 @@ public void getPluralAttributes() throws Exception { pass = false; } if (!pass) { - throw new Fault("getPluralAttributes failed"); + throw new Exception("getPluralAttributes failed"); } } @@ -2629,7 +2622,7 @@ public void getDeclaredPluralAttributes() throws Exception { pass = false; } if (!pass) { - throw new Fault("getDeclaredPluralAttributes failed"); + throw new Exception("getDeclaredPluralAttributes failed"); } } @@ -2682,7 +2675,7 @@ public void getAttribute() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getAttribute failed"); + throw new Exception("getAttribute failed"); } } @@ -2726,7 +2719,7 @@ public void getAttributeIllegalArgumentException() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getAttributeIllegalArgumentException failed"); + throw new Exception("getAttributeIllegalArgumentException failed"); } } @@ -2777,7 +2770,7 @@ public void getDeclaredAttribute() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("getDeclaredAttribute failed"); + throw new Exception("getDeclaredAttribute failed"); } } @@ -2822,7 +2815,7 @@ public void getDeclaredAttributeIllegalArgumentExceptionTest() throws Exception TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault( + throw new Exception( "getDeclaredAttributeIllegalArgumentExceptionTest failed"); } @@ -2858,7 +2851,7 @@ public void getPersistenceType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPersistenceType Test failed"); + throw new Exception("getPersistenceType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mapattribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mapattribute/Client.java index 14a64fca44..198e5a1cb4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mapattribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mapattribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.mapattribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +30,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -90,7 +82,7 @@ public void getJavaKeyType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaKeyType Test failed"); + throw new Exception("getJavaKeyType Test failed"); } } @@ -135,7 +127,7 @@ public void getKeyType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getKeyType Test failed"); + throw new Exception("getKeyType Test failed"); } } @@ -186,7 +178,7 @@ public void getCollectionType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionType Test failed"); + throw new Exception("getCollectionType Test failed"); } } @@ -237,7 +229,7 @@ public void getElementType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getElementType Test failed"); + throw new Exception("getElementType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mappedsuperclasstype/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mappedsuperclasstype/Client.java index 13f5d77170..af4597359c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mappedsuperclasstype/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/mappedsuperclasstype/Client.java @@ -21,10 +21,8 @@ import java.util.Date; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -40,20 +38,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -98,7 +91,7 @@ public void mappedSuperclassType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("mappedSuperclassType failed"); + throw new Exception("mappedSuperclassType failed"); } } @@ -150,7 +143,7 @@ public void getDeclaredId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredId failed"); + throw new Exception("getDeclaredId failed"); } } @@ -198,7 +191,7 @@ public void getDeclaredIdIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredIdIllegalArgumentException failed"); + throw new Exception("getDeclaredIdIllegalArgumentException failed"); } } @@ -250,7 +243,7 @@ public void getDeclaredVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredVersion failed"); + throw new Exception("getDeclaredVersion failed"); } } @@ -298,7 +291,7 @@ public void getDeclaredVersionIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaredVersionIllegalArgumentException failed"); + throw new Exception("getDeclaredVersionIllegalArgumentException failed"); } } @@ -350,7 +343,7 @@ public void getId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getId failed"); + throw new Exception("getId failed"); } } @@ -398,7 +391,7 @@ public void getIdIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdIllegalArgumentException failed"); + throw new Exception("getIdIllegalArgumentException failed"); } } @@ -477,7 +470,7 @@ public void getIdClassAttributes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdClassAttributes failed"); + throw new Exception("getIdClassAttributes failed"); } } @@ -525,7 +518,7 @@ public void getIdClassAttributesIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getIdClassAttributesIllegalArgumentException failed"); + throw new Exception("getIdClassAttributesIllegalArgumentException failed"); } } @@ -573,7 +566,7 @@ public void getIdType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getId failed"); + throw new Exception("getId failed"); } } @@ -618,7 +611,7 @@ public void getVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getVersion failed"); + throw new Exception("getVersion failed"); } } @@ -665,7 +658,7 @@ public void getVersionIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getVersionIllegalArgumentException failed"); + throw new Exception("getVersionIllegalArgumentException failed"); } } @@ -712,7 +705,7 @@ public void hasSingleIdAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("hasSingleIdAttribute failed"); + throw new Exception("hasSingleIdAttribute failed"); } } @@ -759,7 +752,7 @@ public void hasVersionAttribute() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("hasVersionAttribute failed"); + throw new Exception("hasVersionAttribute failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/metamodel/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/metamodel/Client.java index 8c50ed0a64..50e991e798 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/metamodel/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/metamodel/Client.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Properties; import java.util.Set; import com.sun.ts.lib.util.TestUtil; @@ -35,14 +34,14 @@ public class Client extends PMClientBase { public Client() { } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -64,7 +63,7 @@ public void getMetamodel() throws Exception { } if (!pass) { - throw new Fault("getMetamodeltest failed"); + throw new Exception("getMetamodeltest failed"); } } @@ -97,7 +96,7 @@ public void getEntities() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getEntities Test failed"); + throw new Exception("getEntities Test failed"); } } @@ -134,7 +133,7 @@ public void getManagedTypes() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getManagedTypes Test failed"); + throw new Exception("getManagedTypes Test failed"); } } @@ -171,7 +170,7 @@ public void getEmbeddables() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getEmbeddables Test failed"); + throw new Exception("getEmbeddables Test failed"); } } @@ -264,7 +263,7 @@ public void managedType() throws Exception { getEntityTransaction().commit(); if (!pass1 || !pass2 || !pass3) { - throw new Fault("managedType Test failed"); + throw new Exception("managedType Test failed"); } } @@ -298,7 +297,7 @@ public void managedTypeIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("managedTypeIllegalArgumentException failed"); + throw new Exception("managedTypeIllegalArgumentException failed"); } } @@ -334,7 +333,7 @@ public void entity() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("entity Test failed"); + throw new Exception("entity Test failed"); } } @@ -367,7 +366,7 @@ public void entityIllegalArgumentException() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("entityIllegalArgumentException failed"); + throw new Exception("entityIllegalArgumentException failed"); } } @@ -470,7 +469,7 @@ public void embeddableIllegalArgumentException() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("embeddableIllegalArgumentException failed"); + throw new Exception("embeddableIllegalArgumentException failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/pluralattribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/pluralattribute/Client.java index d1ea6e4a50..fd5d123403 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/pluralattribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/pluralattribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.pluralattribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,19 +30,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -95,7 +87,7 @@ public void getCollectionType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionType Test failed"); + throw new Exception("getCollectionType Test failed"); } } @@ -140,7 +132,7 @@ public void getElementType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getElementType Test failed"); + throw new Exception("getElementType Test failed"); } } @@ -182,7 +174,7 @@ public void isCollection() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isCollection Test failed"); + throw new Exception("isCollection Test failed"); } } @@ -224,7 +216,7 @@ public void isAssociation() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isAssociation Test failed"); + throw new Exception("isAssociation Test failed"); } } @@ -268,7 +260,7 @@ public void getPersistentAttributeType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPersistentAttributeType Test failed"); + throw new Exception("getPersistentAttributeType Test failed"); } } @@ -309,7 +301,7 @@ public void getName() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getName Test failed"); + throw new Exception("getName Test failed"); } } @@ -351,7 +343,7 @@ public void getJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaType Test failed"); + throw new Exception("getJavaType Test failed"); } } @@ -395,7 +387,7 @@ public void getJavaMember() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaMember Test failed"); + throw new Exception("getJavaMember Test failed"); } } @@ -442,7 +434,7 @@ public void getBindableType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableType Test failed"); + throw new Exception("getBindableType Test failed"); } } @@ -486,7 +478,7 @@ public void getBindableJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableJavaType Test failed"); + throw new Exception("getBindableJavaType Test failed"); } } @@ -537,7 +529,7 @@ public void getDeclaringType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaringType Test failed"); + throw new Exception("getDeclaringType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/setattribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/setattribute/Client.java index 1c404fc621..cfe5487583 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/setattribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/setattribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.setattribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -84,7 +76,7 @@ public void getSet() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getSet Test failed"); + throw new Exception("getSet Test failed"); } } @@ -125,7 +117,7 @@ public void getCollectionType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getCollectionType Test failed"); + throw new Exception("getCollectionType Test failed"); } } @@ -168,7 +160,7 @@ public void getElementType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getElementType Test failed"); + throw new Exception("getElementType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/singularattribute/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/singularattribute/Client.java index f890abeda1..7d6fd57ccb 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/singularattribute/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/singularattribute/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.singularattribute; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,20 +31,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -89,7 +81,7 @@ public void isId() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isId Test failed"); + throw new Exception("isId Test failed"); } } @@ -132,7 +124,7 @@ public void isVersion() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isVersion Test failed"); + throw new Exception("isVersion Test failed"); } } @@ -175,7 +167,7 @@ public void isOptional() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isOptional Test failed"); + throw new Exception("isOptional Test failed"); } } @@ -221,7 +213,7 @@ public void getType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getType Test failed"); + throw new Exception("getType Test failed"); } } @@ -264,7 +256,7 @@ public void isCollection() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isCollection Test failed"); + throw new Exception("isCollection Test failed"); } } @@ -307,7 +299,7 @@ public void isAssociation() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("isAssociation Test failed"); + throw new Exception("isAssociation Test failed"); } } @@ -352,7 +344,7 @@ public void getPersistentAttributeType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPersistentAttributeType Test failed"); + throw new Exception("getPersistentAttributeType Test failed"); } } @@ -394,7 +386,7 @@ public void getName() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getName Test failed"); + throw new Exception("getName Test failed"); } } @@ -437,7 +429,7 @@ public void getJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaType Test failed"); + throw new Exception("getJavaType Test failed"); } } @@ -482,7 +474,7 @@ public void getJavaMember() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaMember Test failed"); + throw new Exception("getJavaMember Test failed"); } } @@ -531,7 +523,7 @@ public void getDeclaringType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getDeclaringType Test failed"); + throw new Exception("getDeclaringType Test failed"); } } @@ -579,7 +571,7 @@ public void getBindableType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableType Test failed"); + throw new Exception("getBindableType Test failed"); } } @@ -624,7 +616,7 @@ public void getBindableJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getBindableJavaType Test failed"); + throw new Exception("getBindableJavaType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/type/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/type/Client.java index f8e2b9a78d..205de9afc7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/type/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/metamodelapi/type/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.metamodelapi.type; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -80,7 +72,7 @@ public void getPersistenceType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getPersistenceType Test failed"); + throw new Exception("getPersistenceType Test failed"); } } @@ -115,7 +107,7 @@ public void getEmbeddablePersistenceType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getEmbeddablePersistenceType Test failed"); + throw new Exception("getEmbeddablePersistenceType Test failed"); } } @@ -151,7 +143,7 @@ public void getJavaType() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("getJavaType Test failed"); + throw new Exception("getJavaType Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/nestedembedding/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/nestedembedding/Client.java index 320db1518b..7a23071f80 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/nestedembedding/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/nestedembedding/Client.java @@ -19,10 +19,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -163,7 +156,7 @@ public void NE1XMTest1() throws Exception { } if (!pass) { - throw new Fault("cascadeAll1XMTest1 failed"); + throw new Exception("cascadeAll1XMTest1 failed"); } } @@ -250,7 +243,7 @@ public void NE1XMTest2() throws Exception { } if (!pass) { - throw new Fault("NE1XMTest2 failed"); + throw new Exception("NE1XMTest2 failed"); } } @@ -336,7 +329,7 @@ public void NE1XMTest3() throws Exception { } if (!pass) { - throw new Fault("NE1XMTest3 failed"); + throw new Exception("NE1XMTest3 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/attributeoverride/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/attributeoverride/Client.java index 1bc93d7559..f1fb40d5b7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/attributeoverride/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/attributeoverride/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.override.attributeoverride; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,16 +34,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -81,11 +74,11 @@ public void testNoAttributeOverrideAnnotation() throws Exception { if (result.size() == 1) { TestUtil.logTrace("test Overriding Attributes passed"); } else { - throw new Fault( + throw new Exception( "Expected the size to be 1 " + " but it is -" + result.size()); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoAttributeOverrideAnnotation" + e); } finally { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/callbacklistener/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/callbacklistener/Client.java index f5c324c774..f4ea5f4c1e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/callbacklistener/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/callbacklistener/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.override.callbacklistener; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.core.override.util.CallBackCounts; @@ -28,21 +25,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -80,10 +72,10 @@ public void postLoad() throws Exception { if (pass3) { TestUtil.logTrace("testOverrideCallBackMethods Passed"); } else { - throw new Fault("Test failed while testing postLoad method"); + throw new Exception("Test failed while testing postLoad method"); } } catch (Exception e) { - throw new Fault("Exception thrown while testing postLoad" + e); + throw new Exception("Exception thrown while testing postLoad" + e); } } @@ -120,11 +112,11 @@ public void preAndPostPersist() throws Exception { if (pass1) { TestUtil.logTrace("testOverrideCallBackMethods Passed"); } else { - throw new Fault("Test failed while testing prepersist and " + throw new Exception("Test failed while testing prepersist and " + "postpersist methods"); } } catch (Exception e) { - throw new Fault("Exception thrown while testing preAndPostPersist" + e); + throw new Exception("Exception thrown while testing preAndPostPersist" + e); } } @@ -162,11 +154,11 @@ public void preAndPostRemove() throws Exception { if (pass2) { TestUtil.logTrace("testOverrideCallBackMethods Passed"); } else { - throw new Fault( + throw new Exception( "Test failed while testing preremove and " + "postremove methods"); } } catch (Exception e) { - throw new Fault("Exception thrown while testing preAndPostRemove" + e); + throw new Exception("Exception thrown while testing preAndPostRemove" + e); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/embeddable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/embeddable/Client.java index 01025c137a..618fc11bf1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/embeddable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/embeddable/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.override.embeddable; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -53,16 +50,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -103,16 +95,16 @@ public void testOverrideTransient() throws Exception { if (retrievePublisher.getLocation() == null) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("The Location fields was expected to be empty, " + throw new Exception("The Location fields was expected to be empty, " + "expected Length - null, actual - " + "" + retrievePublisher.getLocation()); } } else { - throw new Fault( + throw new Exception( "Incorrect BookStore object obtained from the" + " database"); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testOverrideTransient" + e); } finally { getEntityManager().remove(bookstore); @@ -156,12 +148,12 @@ public void testOverrideEmbeddable() throws Exception { && retrieveApplicant.getAddress().equals(APPLICANT_ADDRESS)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("Expected Complaint Number COMPLAINT_NUMBER to be" + throw new Exception("Expected Complaint Number COMPLAINT_NUMBER to be" + " retrieved; complaint in DB - " + retrieveComplaint.getComplaintNumber()); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testOverrideEmbeddable" + e); } finally { getEntityManager().remove(complaint); @@ -203,11 +195,11 @@ public void testOverrideEmbedded() throws Exception { && retrieveFilm.getFilmCode().equals(FILM_CODE)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("Expected MovieTicket(FILM_NAME)" + throw new Exception("Expected MovieTicket(FILM_NAME)" + " to be retrieved; film in DB - " + retrieveFilm.getFilmName()); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testOverrideEmbedded" + e); } finally { getEntityManager().remove(ticket); @@ -256,12 +248,12 @@ public void testMetadataCompleteness() throws Exception { && retrievePublisher1.getState().equals(PUBLISHER1_STATE)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("Publisher1's name and state were not persisted " + throw new Exception("Publisher1's name and state were not persisted " + "as expected -- metadata-complete=true is not" + " read from orm.xml"); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testMetadataCompleteness" + e); } finally { getEntityManager().remove(book); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entity/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entity/Client.java index 15c7c5e7b4..1c85bf15ab 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entity/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entity/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.override.entity; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,16 +28,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -80,11 +73,11 @@ public void testNameOnlyInXML() throws Exception { if (result.size() == 1) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault( + throw new Exception( "Expected the size to be 1 " + " but it is -" + result.size()); } } catch (Exception e) { - throw new Fault("Exception thrown while testing testNameOnlyInXML" + e); + throw new Exception("Exception thrown while testing testNameOnlyInXML" + e); } finally { getEntityManager().remove(entity); getEntityTransaction().commit(); @@ -119,7 +112,7 @@ public void testNameOnlyInAnnotation() throws Exception { if (result.size() == 0) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault( + throw new Exception( "Expected the size to be 0 " + " but it is -" + result.size()); } } @@ -152,7 +145,7 @@ public void testNameOverride() throws Exception { if (result.size() == 0) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault( + throw new Exception( "Expected the size to be 0 " + " but it is -" + result.size()); } } @@ -193,11 +186,11 @@ public void testNoEntityAnnotation() throws Exception { if (result.size() == 1) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault( + throw new Exception( "Expected the size to be 1 " + " but it is -" + result.size()); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoEntityAnnotation" + e); } finally { getEntityManager().remove(entity); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entitylistener/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entitylistener/Client.java index 92caecbb58..6ad3a44329 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entitylistener/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/entitylistener/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.override.entitylistener; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.core.override.util.CallBackCounts; @@ -30,21 +27,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -84,15 +76,15 @@ public void testOverrideEntityListener() throws Exception { if ((pass1 && pass2) == true) { TestUtil.logTrace("testOverrideEntityListener Passed"); } else if (pass1 == true) { - throw new Fault("Test failed while testing preremove and " + throw new Exception("Test failed while testing preremove and " + "postremove methods in testOverrideEntityListener "); } else if (pass2 == true) { - throw new Fault("Test failed while testing prepersist and " + throw new Exception("Test failed while testing prepersist and " + "postpersist methods in testOverrideEntityListener "); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testOverrideEntityListener" + e); } @@ -128,10 +120,10 @@ public void testEntityListenerXML() throws Exception { if (pass == true) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("TestEntityListenerXML method failed"); + throw new Exception("TestEntityListenerXML method failed"); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testEntityListenerXML" + e); } finally { getEntityManager().remove(entity); @@ -168,10 +160,10 @@ public void testNoEntityListener() throws Exception { if (pass == true) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("TestNoEntityListener method failed"); + throw new Exception("TestNoEntityListener method failed"); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoEntityListener" + e); } finally { getEntityManager().remove(entity); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/joincolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/joincolumn/Client.java index b60380d156..719d591909 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/joincolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/joincolumn/Client.java @@ -18,10 +18,8 @@ import java.util.HashSet; import java.util.List; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -106,16 +104,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -161,11 +154,11 @@ public void testNoJoinColumnAnnotation() throws Exception { if (result.size() == 2) { TestUtil.logTrace("testNoJoinColumnAnnotation passed"); } else { - throw new Fault( + throw new Exception( "Expected the size to be 1 " + " but it is -" + result.size()); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoJoinColumnAnnotation" + e); } finally { getEntityManager().remove(regal); @@ -222,7 +215,7 @@ public void testNoJoinTableAnnotation() throws Exception { TestUtil.logTrace("testNoJoinTableAnnotation passed"); } catch (Exception e) { - throw new Fault(" Test failed -" + e); + throw new Exception(" Test failed -" + e); } finally { getEntityManager().remove(mathCourse); getEntityManager().remove(chemCourse); @@ -273,7 +266,7 @@ public void testOverrideJoinColumns() throws Exception { TestUtil.logTrace("Test Passed"); } catch (Exception e) { - throw new Fault("test failed" + e); + throw new Exception("test failed" + e); } finally { getEntityManager().remove(cubicle); getEntityManager().remove(equipment1); @@ -326,7 +319,7 @@ public void testOverrideJoinTable() throws Exception { TestUtil.logTrace("Test Passed"); } catch (Exception e) { - throw new Fault("Test failed" + e); + throw new Exception("Test failed" + e); } finally { getEntityManager().remove(order1); getEntityManager().remove(order2); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/manytomany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/manytomany/Client.java index be3165b4dc..6cc4c335e2 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/manytomany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/manytomany/Client.java @@ -17,10 +17,8 @@ package com.sun.ts.tests.jpa.core.override.manytomany; import java.util.HashSet; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -49,17 +47,12 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } @Override - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -114,14 +107,14 @@ public void testNoManyToManyAnnotation() throws Exception { && retrieveScience.getStudents().size() == 2) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("Expected many to many relationship between course " + throw new Exception("Expected many to many relationship between course " + "and student to have been set. Expected 2 students in Math " + "and 2 in Science, Actual - " + retrieveMath.getStudents().size() + " - " + retrieveScience.getStudents().size()); } getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoManyToManyAnnotation" + e); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/mapkey/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/mapkey/Client.java index 4bc584e52b..d7742767ca 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/mapkey/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/mapkey/Client.java @@ -21,9 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -102,16 +100,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -168,12 +161,12 @@ public void testNoOrderByAnnotation() throws Exception { if (employeeList.equals(actualList)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("The expected Employee List is not equal to the " + throw new Exception("The expected Employee List is not equal to the " + "actual List read from the DB"); } getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testOrderByAnnotation" + e); } } @@ -225,7 +218,7 @@ public void testOverrideMapKey() throws Exception { && (retrieveLocations.get(CITY_CODE).getId() == CITY_ID)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("Expected to read the relationship as a Map with keys" + throw new Exception("Expected to read the relationship as a Map with keys" + " - " + LOCATION_CODE + " and " + CITY_CODE + "; Actual Locations Found - " + retrieveLocations.get(LOCATION_CODE).getId() + " and " @@ -233,7 +226,7 @@ public void testOverrideMapKey() throws Exception { } getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault("Exception thrown while testing testOverrideMapKey" + e); + throw new Exception("Exception thrown while testing testOverrideMapKey" + e); } } @@ -285,7 +278,7 @@ public void testNoMapKeyAnnotation() throws Exception { && (retrieveCustomers.get(CUSTOMER2_NAME).getId() == CUSTOMER2_ID)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault("Expected to read relationship as a Map with " + throw new Exception("Expected to read relationship as a Map with " + "customers - " + CUSTOMER1_ID + " and " + CUSTOMER2_ID + "Actual Customers in the Map - " + retrieveCustomers.get(CUSTOMER1_NAME).getId() + " and " @@ -293,7 +286,7 @@ public void testNoMapKeyAnnotation() throws Exception { } getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoMapKeyAnnotation" + e); } } @@ -352,12 +345,12 @@ public void testOverrideOrderBy() throws Exception { if (consumer1Orders.equals(actualRetailOrders)) { TestUtil.logTrace("Test Passed"); } else { - throw new Fault( + throw new Exception( "The expected Orders List is not equal to the actual List read from the DB"); } getEntityTransaction().commit(); } catch (Exception e) { - throw new Fault("Exception thrown while testing testOverrideOrderBy" + e); + throw new Exception("Exception thrown while testing testOverrideOrderBy" + e); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/nocallbacklistener/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/nocallbacklistener/Client.java index 3774dae208..c909b7012d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/nocallbacklistener/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/nocallbacklistener/Client.java @@ -17,9 +17,7 @@ package com.sun.ts.tests.jpa.core.override.nocallbacklistener; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.core.override.util.CallBackCounts; @@ -31,20 +29,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -111,16 +104,16 @@ public void testNoCallBackListener() throws Exception { if (pass1 && pass2 && pass3) { TestUtil.logTrace("testOverrideCallBackMethods Passed"); } else { - throw new Fault("Test failed while testing prePersist" + throw new Exception("Test failed while testing prePersist" + ", postPersist, preremove and " + "postremove methods and also the post Load method"); } } catch (Exception e) { - throw new Fault( + throw new Exception( "Exception thrown while testing testNoCallBackListener" + e); } } else { - throw new Fault("getResultList returned a null list"); + throw new Exception("getResultList returned a null list"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/table/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/table/Client.java index 0340120c4f..0d3a25ba8b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/table/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/override/table/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.override.table; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -29,16 +26,11 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception:test failed ", e); @@ -66,7 +58,7 @@ public void testNoTableAnnotation() throws Exception { TestUtil.logTrace("Test Passed"); } catch (Exception e) { TestUtil.logErr("test failed"); - throw new Fault(e); + throw new Exception(e); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtil/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtil/Client.java index c3a1110525..ed8e8ab2a0 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtil/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtil/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.persistenceUtil; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,19 +27,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -64,7 +56,7 @@ public void getPersistenceUtilTest() throws Exception { } if (!pass) { - throw new Fault("getPersistenceUtilTest failed"); + throw new Exception("getPersistenceUtilTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtilUtil/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtilUtil/Client.java index 7d103ad6a9..596f269585 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtilUtil/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/persistenceUtilUtil/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.persistenceUtilUtil; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -29,19 +26,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -64,7 +56,7 @@ public void getPersistenceUtilUtilTest() throws Exception { } if (!pass) { - throw new Fault("getPersistenceUtilUtilTest failed"); + throw new Exception("getPersistenceUtilUtilTest failed"); } } @@ -114,7 +106,7 @@ public void getIdentifierTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("getIdentifierTest failed"); + throw new Exception("getIdentifierTest failed"); } } @@ -140,7 +132,7 @@ public void getIdentifierIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getIdentifierIllegalArgumentExceptionTest failed"); + throw new Exception("getIdentifierIllegalArgumentExceptionTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/Client.java index 02fecf2b7c..a446b01a90 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/Client.java @@ -28,7 +28,6 @@ import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -59,34 +58,29 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } public void setupNoData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Unexpected Exception caught in Setup: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Unexpected Exception caught in Setup: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -94,13 +88,13 @@ public void setup(String[] args, Properties p) throws Exception { public void setupDataTypes2(String[] args, Properties p) throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createDataTypes2Data(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Unexpected Exception caught in Setup: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -290,7 +284,7 @@ public void setFirstResultTest() throws Exception { if (!pass1 || !pass2 || !pass3 || !pass4 || !pass11 || !pass12 || !pass13 || !pass14) { - throw new Fault("setFirstResultTest failed"); + throw new Exception("setFirstResultTest failed"); } } @@ -340,7 +334,7 @@ public void setFirstResultIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setFirstResultIllegalArgumentExceptionTest failed"); + throw new Exception("setFirstResultIllegalArgumentExceptionTest failed"); } } @@ -401,7 +395,7 @@ public void getParameterTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getParameterTest failed"); + throw new Exception("getParameterTest failed"); } } @@ -449,7 +443,7 @@ public void getParameterIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getParameterIllegalArgumentExceptionTest failed"); + throw new Exception("getParameterIllegalArgumentExceptionTest failed"); } } @@ -495,7 +489,7 @@ public void getParameterIllegalArgumentException2Test() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault("getParameterIllegalArgumentException2Test failed"); + throw new Exception("getParameterIllegalArgumentException2Test failed"); } } @@ -560,7 +554,7 @@ public void getParameterIntClassTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault("getParameterIntClassTest failed"); + throw new Exception("getParameterIntClassTest failed"); } } @@ -610,7 +604,7 @@ public void getParameterIntIllegalArgumentExceptionTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault("getParameterIntIllegalArgumentExceptionTest failed"); + throw new Exception("getParameterIntIllegalArgumentExceptionTest failed"); } } @@ -659,7 +653,7 @@ public void getParameterIntIllegalArgumentException2Test() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault("getParameterIntIllegalArgumentException2Test failed"); + throw new Exception("getParameterIntIllegalArgumentException2Test failed"); } } @@ -729,7 +723,7 @@ public void getParameterValueParameterTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getParameterValueParameterTest failed"); + throw new Exception("getParameterValueParameterTest failed"); } } @@ -789,7 +783,7 @@ public void getParameterValueParameterIllegalArgumentExceptionTest() TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "getParameterValueParameterIllegalArgumentExceptionTest failed"); } } @@ -862,7 +856,7 @@ public void getParameterValueParameterIllegalStateExceptionTest() TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault( + throw new Exception( "getParameterValueParameterIllegalStateExceptionTest failed"); } } @@ -940,7 +934,7 @@ public void setParameterParameterObjectIllegalArgumentExceptionTest() TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault( + throw new Exception( "setParameterParameterObjectIllegalArgumentExceptionTest failed"); } } @@ -1019,7 +1013,7 @@ public void setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTes TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault( + throw new Exception( "setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest failed"); } } @@ -1098,7 +1092,7 @@ public void setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest() TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault( + throw new Exception( "setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest failed"); } } @@ -1157,7 +1151,7 @@ public void getParameterValueStringTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getParameterValueStringTest failed"); + throw new Exception("getParameterValueStringTest failed"); } } @@ -1208,7 +1202,7 @@ public void getParameterValueStringIllegalArgumentExceptionTest() TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "getParameterValueStringIllegalArgumentExceptionTest failed"); } } @@ -1257,7 +1251,7 @@ public void getParameterValueStringIllegalStateExceptionTest() throws Exception } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "getParameterValueStringIllegalStateExceptionTest failed"); } } @@ -1314,7 +1308,7 @@ public void getParameterValueIntTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getParameterValueIntTest failed"); + throw new Exception("getParameterValueIntTest failed"); } } @@ -1364,7 +1358,7 @@ public void getParameterValueIntIllegalArgumentExceptionTest() throws Exception } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "getParameterValueIntIllegalArgumentExceptionTest failed"); } } @@ -1411,7 +1405,7 @@ public void getParameterValueIntIllegalStateExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getParameterValueIntIllegalStateExceptionTest failed"); + throw new Exception("getParameterValueIntIllegalStateExceptionTest failed"); } } @@ -1500,7 +1494,7 @@ public void setParameter1Test() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameter1Test failed"); + throw new Exception("setParameter1Test failed"); } } @@ -1551,7 +1545,7 @@ public void setParameter2Test() throws Exception { } if (!pass) { - throw new Fault("setParameter2Test failed"); + throw new Exception("setParameter2Test failed"); } } @@ -1601,7 +1595,7 @@ public void setParameterStringObject1IllegalArgumentExceptionTest() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "setParameterStringObject1IllegalArgumentExceptionTest failed"); } } @@ -1653,7 +1647,7 @@ public void setParameterStringObject2IllegalArgumentExceptionTest() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "setParameterStringObject2IllegalArgumentExceptionTest failed"); } } @@ -1744,7 +1738,7 @@ public void setParameterStringDateTemporalTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameterStringDateTemporalTypeTest failed"); + throw new Exception("setParameterStringDateTemporalTypeTest failed"); } } @@ -1796,7 +1790,7 @@ public void setParameterStringDateTemporalTypeIllegalArgumentExceptionTest() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "setParameterStringDateTemporalTypeIllegalArgumentExceptionTest failed"); } } @@ -1885,7 +1879,7 @@ public void setParameterStringCalendarTemporalTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameterStringCalendarTemporalTypeTest failed"); + throw new Exception("setParameterStringCalendarTemporalTypeTest failed"); } } @@ -1939,7 +1933,7 @@ public void setParameterStringCalendarTemporalTypeTestIllegalArgumentExceptionTe } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "setParameterStringCalendarTemporalTypeTestIllegalArgumentExceptionTest failed"); } } @@ -2027,7 +2021,7 @@ public void setParameterIntObjectTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameterIntObjectTest failed"); + throw new Exception("setParameterIntObjectTest failed"); } } @@ -2111,7 +2105,7 @@ public void setParameterIntObjectIllegalArgumentExceptionTest() throws Exception } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault( + throw new Exception( "setParameterIntObjectIllegalArgumentExceptionTest failed"); } } @@ -2198,7 +2192,7 @@ public void setParameterIntDateTemporalTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameterIntDateTemporalTypeTest failed"); + throw new Exception("setParameterIntDateTemporalTypeTest failed"); } } @@ -2249,7 +2243,7 @@ public void setParameterIntDateTemporalTypeIllegalArgumentException1Test() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "setParameterIntDateTemporalTypeIllegalArgumentException1Test failed"); } } @@ -2338,7 +2332,7 @@ public void setParameterIntCalendarTemporalTypeTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameterIntCalendarTemporalTypeTest failed"); + throw new Exception("setParameterIntCalendarTemporalTypeTest failed"); } } @@ -2388,7 +2382,7 @@ public void setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest failed"); } } @@ -2490,7 +2484,7 @@ public void setParameter7Test() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameter7Test failed"); + throw new Exception("setParameter7Test failed"); } } @@ -2563,7 +2557,7 @@ public void setParameterParameterCalendarTemporalTypeTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault("setParameterParameterCalendarTemporalTypeTest failed"); + throw new Exception("setParameterParameterCalendarTemporalTypeTest failed"); } } @@ -2638,7 +2632,7 @@ public void setParameterParameterDateTemporalTypeTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass1 || !pass2) { - throw new Fault("setParameterParameterDateTemporalTypeTest failed"); + throw new Exception("setParameterParameterDateTemporalTypeTest failed"); } } @@ -2728,7 +2722,7 @@ public void setParameter8Test() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setParameter8Test failed"); + throw new Exception("setParameter8Test failed"); } } @@ -2796,7 +2790,7 @@ public void getSingleResultNoResultExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getSingleResultNoResultExceptionTest failed"); + throw new Exception("getSingleResultNoResultExceptionTest failed"); } } @@ -2865,7 +2859,7 @@ public void getSingleResultTransactionRequiredException() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getSingleResultTransactionRequiredException failed"); + throw new Exception("getSingleResultTransactionRequiredException failed"); } } @@ -2935,7 +2929,7 @@ public void getSingleResultNonUniqueResultExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getSingleResultNonUniqueResultExceptionTest failed"); + throw new Exception("getSingleResultNonUniqueResultExceptionTest failed"); } } @@ -3005,7 +2999,7 @@ public void isBoundTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("isBoundTest failed"); + throw new Exception("isBoundTest failed"); } } @@ -3075,7 +3069,7 @@ public void setFirstResult() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setFirstResult failed"); + throw new Exception("setFirstResult failed"); } } @@ -3130,7 +3124,7 @@ public void queryAPITest11() throws Exception { } if (!pass) { - throw new Fault("queryAPITest11 failed"); + throw new Exception("queryAPITest11 failed"); } } @@ -3184,7 +3178,7 @@ public void queryAPITest12() throws Exception { } if (!pass) { - throw new Fault("queryAPITest12 failed"); + throw new Exception("queryAPITest12 failed"); } } @@ -3232,7 +3226,7 @@ public void setFirstResultIllegalArgumentException() throws Exception { getEntityTransaction().rollback(); if (!pass1 || !pass2) { - throw new Fault("setFirstResultIllegalArgumentException failed"); + throw new Exception("setFirstResultIllegalArgumentException failed"); } } @@ -3348,7 +3342,7 @@ public void setGetMaxResultsTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setGetMaxResultsTest failed"); + throw new Exception("setGetMaxResultsTest failed"); } } @@ -3413,7 +3407,7 @@ public void setMaxResultsIllegalArgumentExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("setMaxResultsIllegalArgumentExceptionTest failed"); + throw new Exception("setMaxResultsIllegalArgumentExceptionTest failed"); } } @@ -3466,7 +3460,7 @@ public void getResultListTransactionRequiredExceptionTest() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("getResultListTransactionRequiredExceptionTest failed"); + throw new Exception("getResultListTransactionRequiredExceptionTest failed"); } } @@ -3515,7 +3509,7 @@ public void setMaxResults() throws Exception { } if (!pass) { - throw new Fault("setMaxResults failed"); + throw new Exception("setMaxResults failed"); } } @@ -3556,7 +3550,7 @@ public void queryAPITest16() throws Exception { } if (!pass1) { - throw new Fault("queryAPITest16 failed"); + throw new Exception("queryAPITest16 failed"); } } @@ -3598,7 +3592,7 @@ public void queryAPITest17() throws Exception { } if (!pass) { - throw new Fault("queryAPITest17 failed"); + throw new Exception("queryAPITest17 failed"); } } @@ -3672,7 +3666,7 @@ public void getSingleResultTest() throws Exception { } } if (!pass1 || !pass2) { - throw new Fault("getSingleResultTest failed"); + throw new Exception("getSingleResultTest failed"); } } @@ -3724,7 +3718,7 @@ public void getSingleResultIllegalStateException() throws Exception { TestUtil.logErr("Unexpected Exception in while rolling back TX:", re); } if (!pass1 || !pass2) { - throw new Fault("getSingleResultIllegalStateException failed"); + throw new Exception("getSingleResultIllegalStateException failed"); } } @@ -3794,7 +3788,7 @@ public void executeUpdateIllegalStateException() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("executeUpdateIllegalStateException failed"); + throw new Exception("executeUpdateIllegalStateException failed"); } } @@ -3834,7 +3828,7 @@ public void executeUpdateTransactionRequiredExceptionTest() throws Exception { } if (!pass1) { - throw new Fault("executeUpdateTransactionRequiredExceptionTest failed"); + throw new Exception("executeUpdateTransactionRequiredExceptionTest failed"); } } @@ -3881,7 +3875,7 @@ public void queryAPITest21() throws Exception { } if (!pass) { - throw new Fault("queryAPITest21 failed"); + throw new Exception("queryAPITest21 failed"); } } @@ -3938,7 +3932,7 @@ public void queryAPITest22() throws Exception { } if (!pass) { - throw new Fault("queryAPITest22 failed"); + throw new Exception("queryAPITest22 failed"); } } @@ -3985,7 +3979,7 @@ public void queryAPITest23() throws Exception { } if (!pass) { - throw new Fault("queryAPITest23 failed"); + throw new Exception("queryAPITest23 failed"); } } @@ -4066,7 +4060,7 @@ public void queryAPITest24() throws Exception { } if (!pass) { - throw new Fault("queryAPITest24 failed"); + throw new Exception("queryAPITest24 failed"); } } @@ -4121,7 +4115,7 @@ public void queryAPITest25() throws Exception { } if (!pass) { - throw new Fault("queryAPITest25 failed"); + throw new Exception("queryAPITest25 failed"); } } @@ -4185,7 +4179,7 @@ public void queryAPITest27() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryAPITest27 failed"); + throw new Exception("queryAPITest27 failed"); } } @@ -4290,7 +4284,7 @@ public void queryAPITest28() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("queryAPITest28 failed"); + throw new Exception("queryAPITest28 failed"); } } @@ -4376,7 +4370,7 @@ public void queryAPITest29() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("queryAPITest29 failed"); + throw new Exception("queryAPITest29 failed"); } } @@ -4428,7 +4422,7 @@ public void getResultListIllegalStateException() throws Exception { TestUtil.logErr("Unexpected Exception while rolling back TX:", re); } if (!pass1 || !pass2) { - throw new Fault("getResultListIllegalStateException failed"); + throw new Exception("getResultListIllegalStateException failed"); } } @@ -4567,7 +4561,7 @@ public void noTransactionLockModeTypeNoneTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("noTransactionLockModeTypeNoneTest failed"); + throw new Exception("noTransactionLockModeTypeNoneTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/Client.java index 1403f98406..e9d5013477 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/Client.java @@ -22,10 +22,8 @@ import java.sql.Date; import java.util.List; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.schema30.CreditCard; @@ -47,22 +45,17 @@ public class Client extends Util { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* Test setup */ - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -196,7 +189,7 @@ public void flushModeTest1() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) - throw new Fault("flushModeTest1 failed"); + throw new Exception("flushModeTest1 failed"); } /* @@ -243,7 +236,7 @@ public void flushModeTest2() throws Exception { } if (!pass) - throw new Fault("flushModeTest2 failed"); + throw new Exception("flushModeTest2 failed"); } /* @@ -289,7 +282,7 @@ public void flushModeTest3() throws Exception { } if (!pass) - throw new Fault("flushModeTest3 failed"); + throw new Exception("flushModeTest3 failed"); } /* @@ -338,7 +331,7 @@ public void flushModeTest4() throws Exception { } if (!pass) - throw new Fault("flushModeTest4 failed"); + throw new Exception("flushModeTest4 failed"); } /* @@ -381,7 +374,7 @@ public void flushModeTest5() throws Exception { } if (!pass) - throw new Fault("flushModeTest5 failed"); + throw new Exception("flushModeTest5 failed"); } /* @@ -433,7 +426,7 @@ public void flushModeTest6() throws Exception { } if (!pass) - throw new Fault("flushModeTest6 failed"); + throw new Exception("flushModeTest6 failed"); } /* @@ -478,7 +471,7 @@ public void flushModeTest7() throws Exception { } if (!pass) - throw new Fault("flushModeTest7 failed"); + throw new Exception("flushModeTest7 failed"); } /* @@ -519,7 +512,7 @@ public void secondaryTablesValueTest() throws Exception { } if (!pass) - throw new Fault("secondaryTablesValueTest failed"); + throw new Exception("secondaryTablesValueTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/Client.java index 8e4fc01b8b..e3fd4a7a28 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/Client.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.Properties; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -43,14 +42,14 @@ public class Client extends Util { /* Test setup */ - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("Entering Setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -99,7 +98,7 @@ public void queryTest1() throws Exception { } if (!pass) - throw new Fault("queryTest1 failed"); + throw new Exception("queryTest1 failed"); } /* @@ -140,7 +139,7 @@ public void queryTest2() throws Exception { } if (!pass) - throw new Fault("queryTest2 failed"); + throw new Exception("queryTest2 failed"); } /* @@ -183,7 +182,7 @@ public void queryTest3() throws Exception { } if (!pass) - throw new Fault("queryTest3 failed"); + throw new Exception("queryTest3 failed"); } /* @@ -228,7 +227,7 @@ public void queryTest4() throws Exception { } if (!pass) - throw new Fault("queryTest4 failed"); + throw new Exception("queryTest4 failed"); } /* @@ -277,7 +276,7 @@ public void queryTest5() throws Exception { } if (!pass) - throw new Fault("queryTest5 failed"); + throw new Exception("queryTest5 failed"); } /* @@ -324,7 +323,7 @@ public void queryTest6() throws Exception { } if (!pass) - throw new Fault("queryTest6 failed"); + throw new Exception("queryTest6 failed"); } /* @@ -366,7 +365,7 @@ public void queryTest7() throws Exception { } if (!pass) - throw new Fault("queryTest7 failed"); + throw new Exception("queryTest7 failed"); } /* @@ -411,7 +410,7 @@ public void queryTest8() throws Exception { } if (!pass) - throw new Fault("queryTest8 failed"); + throw new Exception("queryTest8 failed"); } /* @@ -459,7 +458,7 @@ public void queryTest9() throws Exception { } if (!pass) - throw new Fault("queryTest9 failed"); + throw new Exception("queryTest9 failed"); } /* @@ -508,7 +507,7 @@ public void queryTest10() throws Exception { } if (!pass) - throw new Fault("queryTest10 failed"); + throw new Exception("queryTest10 failed"); } /* @@ -552,7 +551,7 @@ public void queryTest11() throws Exception { } if (!pass) - throw new Fault("queryTest11 failed"); + throw new Exception("queryTest11 failed"); } /* @@ -598,7 +597,7 @@ public void queryTest12() throws Exception { } if (!pass) - throw new Fault("queryTest12 failed"); + throw new Exception("queryTest12 failed"); } /* @@ -653,7 +652,7 @@ public void queryTest13() throws Exception { } if (!pass) - throw new Fault("queryTest13 failed"); + throw new Exception("queryTest13 failed"); } /* @@ -704,7 +703,7 @@ public void queryTest14() throws Exception { } if (!pass) - throw new Fault("queryTest14 failed"); + throw new Exception("queryTest14 failed"); } /* @@ -746,7 +745,7 @@ public void queryTest15() throws Exception { } if (!pass) - throw new Fault("queryTest15 failed"); + throw new Exception("queryTest15 failed"); } /* @@ -786,7 +785,7 @@ public void queryTest16() throws Exception { } if (!pass) - throw new Fault("queryTest16 failed"); + throw new Exception("queryTest16 failed"); } /* @@ -843,7 +842,7 @@ public void queryTest17() throws Exception { } if (!pass) - throw new Fault("queryTest17 failed"); + throw new Exception("queryTest17 failed"); } /* @@ -884,7 +883,7 @@ public void queryTest18() throws Exception { } if (!pass) - throw new Fault("queryTest18 failed"); + throw new Exception("queryTest18 failed"); } /* @@ -942,7 +941,7 @@ public void queryTest19() throws Exception { } if (!pass) - throw new Fault("queryTest19 failed"); + throw new Exception("queryTest19 failed"); } /* @@ -990,7 +989,7 @@ public void queryTest20() throws Exception { } if (!pass) - throw new Fault("queryTest20 failed"); + throw new Exception("queryTest20 failed"); } /* @@ -1042,7 +1041,7 @@ public void queryTest21() throws Exception { } if (!pass) - throw new Fault("queryTest21 failed"); + throw new Exception("queryTest21 failed"); } /* @@ -1081,7 +1080,7 @@ public void queryTest22() throws Exception { } if (!pass) - throw new Fault("queryTest22 failed"); + throw new Exception("queryTest22 failed"); } /* @@ -1140,7 +1139,7 @@ public void queryTest23() throws Exception { } if (!pass) - throw new Fault("queryTest23 failed"); + throw new Exception("queryTest23 failed"); } /* @@ -1180,7 +1179,7 @@ public void queryTest24() throws Exception { } if (!pass) - throw new Fault("queryTest24 failed"); + throw new Exception("queryTest24 failed"); } /* @@ -1221,7 +1220,7 @@ public void queryTest25() throws Exception { } if (!pass) - throw new Fault("queryTest25 failed"); + throw new Exception("queryTest25 failed"); } /* @@ -1268,7 +1267,7 @@ public void queryTest26() throws Exception { } if (!pass) - throw new Fault("queryTest26 failed"); + throw new Exception("queryTest26 failed"); } /* @@ -1343,7 +1342,7 @@ public void queryTest27() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest27 failed"); + throw new Exception("queryTest27 failed"); } /* @@ -1386,7 +1385,7 @@ public void queryTest28() throws Exception { } if (!pass) - throw new Fault("queryTest28 failed"); + throw new Exception("queryTest28 failed"); } /* @@ -1425,7 +1424,7 @@ public void queryTest29() throws Exception { } if (!pass) - throw new Fault("queryTest29 failed"); + throw new Exception("queryTest29 failed"); } /* @@ -1465,7 +1464,7 @@ public void queryTest30() throws Exception { } if (!pass) - throw new Fault("queryTest30 failed"); + throw new Exception("queryTest30 failed"); } /* @@ -1507,7 +1506,7 @@ public void queryTest31() throws Exception { } if (!pass) - throw new Fault("queryTest31 failed"); + throw new Exception("queryTest31 failed"); } /* @@ -1549,7 +1548,7 @@ public void queryTest32() throws Exception { } if (!pass) - throw new Fault("queryTest32 failed"); + throw new Exception("queryTest32 failed"); } /* @@ -1612,7 +1611,7 @@ public void queryTest33() throws Exception { } if (!pass) - throw new Fault("queryTest33 failed"); + throw new Exception("queryTest33 failed"); } /* @@ -1655,7 +1654,7 @@ public void queryTest34() throws Exception { } if (!pass) - throw new Fault("queryTest34 failed"); + throw new Exception("queryTest34 failed"); } /* @@ -1705,7 +1704,7 @@ public void queryTest35() throws Exception { } if (!pass) - throw new Fault("queryTest35 failed"); + throw new Exception("queryTest35 failed"); } /* @@ -1746,7 +1745,7 @@ public void queryTest36() throws Exception { } if (!pass) - throw new Fault("queryTest36 failed"); + throw new Exception("queryTest36 failed"); } /* @@ -1818,7 +1817,7 @@ public void queryTest37() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest37 failed"); + throw new Exception("queryTest37 failed"); } /* @@ -1883,7 +1882,7 @@ public void queryTest38() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest38 failed"); + throw new Exception("queryTest38 failed"); } /* @@ -1946,7 +1945,7 @@ public void queryTest39() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest39 failed"); + throw new Exception("queryTest39 failed"); } /* @@ -2024,7 +2023,7 @@ public void queryTest40() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest40 failed"); + throw new Exception("queryTest40 failed"); } /* @@ -2107,7 +2106,7 @@ public void queryTest41() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest41 failed"); + throw new Exception("queryTest41 failed"); } /* @@ -2168,7 +2167,7 @@ public void queryTest42() throws Exception { } if (!pass) - throw new Fault("queryTest42 failed"); + throw new Exception("queryTest42 failed"); } /* @@ -2208,7 +2207,7 @@ public void queryTest43() throws Exception { } if (!pass) - throw new Fault("queryTest43 failed"); + throw new Exception("queryTest43 failed"); } /* @@ -2250,7 +2249,7 @@ public void queryTest44() throws Exception { } if (!pass) - throw new Fault("queryTest44 failed"); + throw new Exception("queryTest44 failed"); } /* @@ -2309,7 +2308,7 @@ public void queryTest45() throws Exception { } if (!pass) - throw new Fault("queryTest45 failed"); + throw new Exception("queryTest45 failed"); } /* @@ -2346,7 +2345,7 @@ public void queryTest47() throws Exception { } if (!pass) - throw new Fault("queryTest47 failed"); + throw new Exception("queryTest47 failed"); } /* @@ -2386,7 +2385,7 @@ public void queryTest48() throws Exception { } if (!pass) - throw new Fault("queryTest48 failed"); + throw new Exception("queryTest48 failed"); } /* @@ -2440,7 +2439,7 @@ public void queryTest49() throws Exception { } if (!pass) - throw new Fault("queryTest49 failed"); + throw new Exception("queryTest49 failed"); } /* @@ -2484,7 +2483,7 @@ public void queryTest50() throws Exception { } if (!pass) - throw new Fault("queryTest50 failed"); + throw new Exception("queryTest50 failed"); } /* @@ -2522,7 +2521,7 @@ public void queryTest51() throws Exception { } if (!pass) - throw new Fault("queryTest51 failed"); + throw new Exception("queryTest51 failed"); } /* @@ -2563,7 +2562,7 @@ public void queryTest52() throws Exception { } if (!pass) - throw new Fault("queryTest52 failed"); + throw new Exception("queryTest52 failed"); } /* @@ -2616,7 +2615,7 @@ public void queryTest53() throws Exception { } if (!pass) - throw new Fault("queryTest53 failed"); + throw new Exception("queryTest53 failed"); } /* @@ -2654,7 +2653,7 @@ public void queryTest54() throws Exception { } if (!pass) - throw new Fault("queryTest54 failed"); + throw new Exception("queryTest54 failed"); } /* @@ -2698,7 +2697,7 @@ public void queryTest55() throws Exception { } if (!pass) - throw new Fault("queryTest55 failed"); + throw new Exception("queryTest55 failed"); } /* @@ -2767,7 +2766,7 @@ public void queryTest56() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest56 failed"); + throw new Exception("queryTest56 failed"); } /* @@ -2802,7 +2801,7 @@ public void queryTest58() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass) - throw new Fault("queryTest58 failed"); + throw new Exception("queryTest58 failed"); } /* @@ -2844,7 +2843,7 @@ public void queryTest59() throws Exception { } if (!pass) - throw new Fault("queryTest59 failed"); + throw new Exception("queryTest59 failed"); } /* @@ -2904,7 +2903,7 @@ public void queryTest60() throws Exception { } if (!pass) - throw new Fault("queryTest60 failed"); + throw new Exception("queryTest60 failed"); } /* @@ -2949,7 +2948,7 @@ public void queryTest61() throws Exception { } if (!pass) - throw new Fault("queryTest61 failed"); + throw new Exception("queryTest61 failed"); } /* @@ -2996,7 +2995,7 @@ public void queryTest62() throws Exception { } if (!pass) - throw new Fault("queryTest62 failed"); + throw new Exception("queryTest62 failed"); } /* @@ -3043,7 +3042,7 @@ public void queryTest63() throws Exception { } if (!pass) - throw new Fault("queryTest63 failed"); + throw new Exception("queryTest63 failed"); } /* @@ -3109,7 +3108,7 @@ public void queryTest64() throws Exception { } if (!pass) - throw new Fault("queryTest64 failed"); + throw new Exception("queryTest64 failed"); } @@ -3186,7 +3185,7 @@ public void queryTest65() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass1 || !pass2) - throw new Fault("queryTest65 failed"); + throw new Exception("queryTest65 failed"); } /* @@ -3262,7 +3261,7 @@ public void queryTest66() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass1 || !pass2) - throw new Fault("queryTest66 failed"); + throw new Exception("queryTest66 failed"); } /* @@ -3301,7 +3300,7 @@ public void queryTest67() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass) - throw new Fault("queryTest67 failed"); + throw new Exception("queryTest67 failed"); } /* @@ -3338,7 +3337,7 @@ public void queryTest68() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass) - throw new Fault("queryTest68 failed"); + throw new Exception("queryTest68 failed"); } /* @@ -3399,7 +3398,7 @@ public void queryTest69() throws Exception { } if (!pass1 || !pass2) - throw new Fault("queryTest69 failed"); + throw new Exception("queryTest69 failed"); } @@ -3438,7 +3437,7 @@ public void queryTest70() throws Exception { TestUtil.logErr("Caught exception queryTest70: ", e); } if (!pass) - throw new Fault("queryTest70 failed"); + throw new Exception("queryTest70 failed"); } /* @@ -3471,7 +3470,7 @@ public void queryTest71() throws Exception { } if (!pass) - throw new Fault("queryTest71 failed"); + throw new Exception("queryTest71 failed"); } /* @@ -3514,7 +3513,7 @@ public void test_leftouterjoin_1xM() throws Exception { } if (!pass) - throw new Fault("test_leftouterjoin_1x1 failed"); + throw new Exception("test_leftouterjoin_1x1 failed"); } /* @@ -3582,7 +3581,7 @@ public void test_leftouterjoin_Mx1() throws Exception { } if (!pass1 || !pass2) - throw new Fault("test_leftouterjoin_Mx1 failed"); + throw new Exception("test_leftouterjoin_Mx1 failed"); } /* @@ -3652,7 +3651,7 @@ public void test_leftouterjoin_MxM() throws Exception { } if (!pass1 || !pass2) - throw new Fault("test_leftouterjoin_MxM failed"); + throw new Exception("test_leftouterjoin_MxM failed"); } /* @@ -3697,7 +3696,7 @@ public void test_upperStringExpression() throws Exception { } if (!pass) - throw new Fault("test_upperStringExpression failed"); + throw new Exception("test_upperStringExpression failed"); } /* @@ -3742,7 +3741,7 @@ public void test_lowerStringExpression() throws Exception { } if (!pass) - throw new Fault("test_lowerStringExpression failed"); + throw new Exception("test_lowerStringExpression failed"); } /* @@ -3789,7 +3788,7 @@ public void test_groupBy() throws Exception { } if (!pass) - throw new Fault("test_groupBy failed"); + throw new Exception("test_groupBy failed"); } /* @@ -3833,7 +3832,7 @@ public void test_groupBy_1() throws Exception { } if (!pass) - throw new Fault("test_groupBy_1 failed"); + throw new Exception("test_groupBy_1 failed"); } /* @@ -3878,7 +3877,7 @@ public void test_innerjoin_1x1() throws Exception { } if (!pass) - throw new Fault("test_innerjoin_1x1 failed"); + throw new Exception("test_innerjoin_1x1 failed"); } /* @@ -3927,7 +3926,7 @@ public void test_innerjoin_1xM() throws Exception { } if (!pass) - throw new Fault("test_innerjoin_1xM failed"); + throw new Exception("test_innerjoin_1xM failed"); } /* @@ -3968,7 +3967,7 @@ public void test_innerjoin_Mx1() throws Exception { } if (!pass) - throw new Fault("test_innerjoin_Mx1 failed"); + throw new Exception("test_innerjoin_Mx1 failed"); } /* @@ -4009,7 +4008,7 @@ public void test_innerjoin_MxM() throws Exception { } if (!pass) - throw new Fault("test_innerjoin_MxM failed"); + throw new Exception("test_innerjoin_MxM failed"); } /* @@ -4054,7 +4053,7 @@ public void test_fetchjoin_1x1() throws Exception { } if (!pass) - throw new Fault("test_fetchjoin_1x1 failed"); + throw new Exception("test_fetchjoin_1x1 failed"); } /* @@ -4097,7 +4096,7 @@ public void test_fetchjoin_1xM() throws Exception { } if (!pass) - throw new Fault("test_fetchjoin_1xM failed"); + throw new Exception("test_fetchjoin_1xM failed"); } /* @@ -4138,7 +4137,7 @@ public void test_fetchjoin_Mx1() throws Exception { } if (!pass) - throw new Fault("test_fetchjoin_Mx1 failed"); + throw new Exception("test_fetchjoin_Mx1 failed"); } /* @@ -4180,7 +4179,7 @@ public void test_fetchjoin_Mx1_1() throws Exception { } if (!pass) - throw new Fault("test_fetchjoin_Mx1_1 failed"); + throw new Exception("test_fetchjoin_Mx1_1 failed"); } /* @@ -4225,7 +4224,7 @@ public void test_fetchjoin_MxM() throws Exception { } if (!pass) - throw new Fault("test_fetchjoin_MxM failed"); + throw new Exception("test_fetchjoin_MxM failed"); } /* @@ -4277,7 +4276,7 @@ public void test_betweenDates() throws Exception { } if (!pass) - throw new Fault("test_betweenDates failed"); + throw new Exception("test_betweenDates failed"); } /* @@ -4331,7 +4330,7 @@ public void test_notBetweenArithmetic() throws Exception { } if (!pass) - throw new Fault("test_notBetweenArithmetic failed"); + throw new Exception("test_notBetweenArithmetic failed"); } /* @@ -4375,7 +4374,7 @@ public void test_notBetweenDates() throws Exception { } if (!pass) - throw new Fault("test_notBetweenDates failed"); + throw new Exception("test_notBetweenDates failed"); } /* @@ -4415,7 +4414,7 @@ public void test_ANDconditionTT() throws Exception { } if (!pass) - throw new Fault("test_ANDconditionTT failed"); + throw new Exception("test_ANDconditionTT failed"); } /* @@ -4452,7 +4451,7 @@ public void test_ANDconditionTF() throws Exception { } if (!pass) - throw new Fault("test_ANDconditionTF failed"); + throw new Exception("test_ANDconditionTF failed"); } /* @@ -4489,7 +4488,7 @@ public void test_ANDconditionFT() throws Exception { } if (!pass) - throw new Fault("test_ANDconditionFT failed"); + throw new Exception("test_ANDconditionFT failed"); } /* @@ -4526,7 +4525,7 @@ public void test_ANDconditionFF() throws Exception { } if (!pass) - throw new Fault("test_ANDconditionFF failed"); + throw new Exception("test_ANDconditionFF failed"); } /* @@ -4568,7 +4567,7 @@ public void test_ORconditionTT() throws Exception { } if (!pass) - throw new Fault("test_ORconditionTT failed"); + throw new Exception("test_ORconditionTT failed"); } /* @@ -4608,7 +4607,7 @@ public void test_ORconditionTF() throws Exception { } if (!pass) - throw new Fault("test_ORconditionTF failed"); + throw new Exception("test_ORconditionTF failed"); } /* @@ -4654,7 +4653,7 @@ public void test_ORconditionFT() throws Exception { } if (!pass) - throw new Fault("test_ORconditionFT failed"); + throw new Exception("test_ORconditionFT failed"); } /* @@ -4691,7 +4690,7 @@ public void test_ORconditionFF() throws Exception { } if (!pass) - throw new Fault("test_ORconditionFF failed"); + throw new Exception("test_ORconditionFF failed"); } /* @@ -4735,7 +4734,7 @@ public void test_groupByWhereClause() throws Exception { } if (!pass) - throw new Fault("test_groupByWhereClause failed"); + throw new Exception("test_groupByWhereClause failed"); } /* @@ -4793,7 +4792,7 @@ public void test_groupByHaving() throws Exception { } if (!pass) - throw new Fault("test_groupByHaving failed"); + throw new Exception("test_groupByHaving failed"); } /* @@ -4838,7 +4837,7 @@ public void test_substringHavingClause() throws Exception { } if (!pass) - throw new Fault(" test_substringHavingClause failed"); + throw new Exception(" test_substringHavingClause failed"); } /* @@ -4880,7 +4879,7 @@ public void test_concatHavingClause() throws Exception { } if (!pass) - throw new Fault("test_concatHavingClause failed"); + throw new Exception("test_concatHavingClause failed"); } /* @@ -4924,7 +4923,7 @@ public void test_lowerHavingClause() throws Exception { } if (!pass) - throw new Fault(" test_lowerHavingClause failed"); + throw new Exception(" test_lowerHavingClause failed"); } /* @@ -4969,7 +4968,7 @@ public void test_upperHavingClause() throws Exception { } if (!pass) - throw new Fault("test_upperHavingClause failed"); + throw new Exception("test_upperHavingClause failed"); } /* @@ -5017,7 +5016,7 @@ public void test_lengthHavingClause() throws Exception { } if (!pass) - throw new Fault("test_lengthHavingClause failed"); + throw new Exception("test_lengthHavingClause failed"); } /* @@ -5063,7 +5062,7 @@ public void test_locateHavingClause() throws Exception { } if (!pass) - throw new Fault(" test_locateHavingClause failed"); + throw new Exception(" test_locateHavingClause failed"); } /* @@ -5102,7 +5101,7 @@ public void test_locateHavingClause() throws Exception { * getEntityTransaction().commit(); } catch (Exception e) { * TestUtil.logErr("Caught exception:", e); } * - * if (!pass) throw new Fault(" test_trimHavingClause_01 failed"); } + * if (!pass) throw new Exception(" test_trimHavingClause_01 failed"); } * */ @@ -5142,7 +5141,7 @@ public void test_locateHavingClause() throws Exception { * getEntityTransaction().commit(); } catch (Exception e) { * TestUtil.logErr("Caught exception:", e); } * - * if (!pass) throw new Fault("test_trimHavingClause_02 failed"); } + * if (!pass) throw new Exception("test_trimHavingClause_02 failed"); } */ /* @@ -5184,7 +5183,7 @@ public void test_locateHavingClause() throws Exception { * getEntityTransaction().commit(); } catch (Exception e) { * TestUtil.logErr("Caught exception:", e); } * - * if (!pass) throw new Fault("test_trimHavingClause_03 failed"); } + * if (!pass) throw new Exception("test_trimHavingClause_03 failed"); } * */ @@ -5223,7 +5222,7 @@ public void test_ABSHavingClause() throws Exception { } if (!pass) - throw new Fault("test_ABSHavingClause failed"); + throw new Exception("test_ABSHavingClause failed"); } /* @@ -5263,7 +5262,7 @@ public void test_SQRTWhereClause() throws Exception { } if (!pass) - throw new Fault(" test_SQRTWhereClause failed"); + throw new Exception(" test_SQRTWhereClause failed"); } @@ -5302,7 +5301,7 @@ public void test_subquery_exists_01() throws Exception { } if (!pass) - throw new Fault(" test_subquery_exists_01 failed"); + throw new Exception(" test_subquery_exists_01 failed"); } /* @@ -5346,7 +5345,7 @@ public void test_subquery_exists_02() throws Exception { } if (!pass) - throw new Fault(" test_subquery_exists_02 failed"); + throw new Exception(" test_subquery_exists_02 failed"); } /* @@ -5388,7 +5387,7 @@ public void test_subquery_like() throws Exception { } if (!pass) - throw new Fault(" test_subquery_like failed"); + throw new Exception(" test_subquery_like failed"); } /* @@ -5437,7 +5436,7 @@ public void test_subquery_in() throws Exception { } if (!pass) - throw new Fault("test_subquery_in failed"); + throw new Exception("test_subquery_in failed"); } /* @@ -5482,7 +5481,7 @@ public void test_subquery_between() throws Exception { } if (!pass) - throw new Fault(" test_subquery_between failed"); + throw new Exception(" test_subquery_between failed"); } @@ -5529,7 +5528,7 @@ public void test_subquery_join() throws Exception { } if (!pass) - throw new Fault(" test_subquery_join failed"); + throw new Exception(" test_subquery_join failed"); } /* @@ -5574,7 +5573,7 @@ public void test_subquery_ALL_GT() throws Exception { } if (!pass) - throw new Fault(" test_subquery_ALL_GT failed"); + throw new Exception(" test_subquery_ALL_GT failed"); } /* @@ -5615,7 +5614,7 @@ public void test_subquery_ALL_LT() throws Exception { } if (!pass) - throw new Fault("test_subquery_ALL_LT failed"); + throw new Exception("test_subquery_ALL_LT failed"); } /* @@ -5658,7 +5657,7 @@ public void test_subquery_ALL_EQ() throws Exception { } if (!pass) - throw new Fault("test_subquery_ALL_EQ failed"); + throw new Exception("test_subquery_ALL_EQ failed"); } @@ -5704,7 +5703,7 @@ public void test_subquery_ALL_LTEQ() throws Exception { } if (!pass) - throw new Fault("test_subquery_ALL_LTEQ failed"); + throw new Exception("test_subquery_ALL_LTEQ failed"); } /* @@ -5747,7 +5746,7 @@ public void test_subquery_ALL_GTEQ() throws Exception { } if (!pass) - throw new Fault("test_subquery_ALL_GTEQ failed"); + throw new Exception("test_subquery_ALL_GTEQ failed"); } /* @@ -5806,7 +5805,7 @@ public void test_subquery_ALL_NOTEQ() throws Exception { } if (!pass) - throw new Fault("test_subquery_ALL_NOTEQ failed"); + throw new Exception("test_subquery_ALL_NOTEQ failed"); } /* @@ -5863,7 +5862,7 @@ public void test_subquery_ANY_GT() throws Exception { TestUtil.logErr("Caught exception:", e); } if (!pass) - throw new Fault("test_subquery_ANY_GT failed"); + throw new Exception("test_subquery_ANY_GT failed"); } /* @@ -5922,7 +5921,7 @@ public void test_subquery_ANY_LT() throws Exception { } if (!pass) - throw new Fault("test_subquery_ANY_LT failed"); + throw new Exception("test_subquery_ANY_LT failed"); } /* @@ -5967,7 +5966,7 @@ public void test_subquery_ANY_EQ() throws Exception { } if (!pass) - throw new Fault("test_subquery_ANY_EQ failed"); + throw new Exception("test_subquery_ANY_EQ failed"); } /* @@ -6027,7 +6026,7 @@ public void test_subquery_SOME_LTEQ() throws Exception { } if (!pass) - throw new Fault(" test_subquery_SOME_LTEQ failed"); + throw new Exception(" test_subquery_SOME_LTEQ failed"); } /* @@ -6088,7 +6087,7 @@ public void test_subquery_SOME_GTEQ() throws Exception { } if (!pass) - throw new Fault("test_subquery_SOME_GTEQ failed"); + throw new Exception("test_subquery_SOME_GTEQ failed"); } /* @@ -6131,7 +6130,7 @@ public void fetchStringJoinTypeTest() throws Exception { } if (!pass) { - throw new Fault("fetchStringJoinTypeTest failed"); + throw new Exception("fetchStringJoinTypeTest failed"); } } @@ -6185,7 +6184,7 @@ public void treatJoinClassTest() throws Exception { } if (!pass) { - throw new Fault("treatJoinClassTest failed"); + throw new Exception("treatJoinClassTest failed"); } } @@ -6235,7 +6234,7 @@ public void treatInWhereClauseTest() throws Exception { } if (!pass) { - throw new Fault("treatInWhereClauseTest failed"); + throw new Exception("treatInWhereClauseTest failed"); } } @@ -6285,7 +6284,7 @@ public void appropriateSuffixesTest() throws Exception { } if (!pass) { - throw new Fault("appropriateSuffixesTest failed"); + throw new Exception("appropriateSuffixesTest failed"); } } @@ -6335,7 +6334,7 @@ public void sqlApproximateNumericLiteralTest() throws Exception { } if (!pass) { - throw new Fault("sqlApproximateNumericLiteralTest failed"); + throw new Exception("sqlApproximateNumericLiteralTest failed"); } } @@ -6384,7 +6383,7 @@ public void joinOnExpressionTest() throws Exception { } if (!pass) - throw new Fault("joinOnExpressionTest failed"); + throw new Exception("joinOnExpressionTest failed"); } /* @@ -6484,7 +6483,7 @@ public void aggregateFunctionsWithNoValuesTest() throws Exception { TestUtil.logErr("Caught exception: ", e); } if (!pass) - throw new Fault("aggregateFunctionsWithNoValuesTest failed"); + throw new Exception("aggregateFunctionsWithNoValuesTest failed"); } /* @@ -6524,7 +6523,7 @@ public void primaryKeyJoinColumnTest() throws Exception { } if (!pass) { - throw new Fault("primaryKeyJoinColumnTest failed"); + throw new Exception("primaryKeyJoinColumnTest failed"); } } @@ -6566,7 +6565,7 @@ public void typeTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("primaryKeyJoinColumnTest failed"); + throw new Exception("primaryKeyJoinColumnTest failed"); } } @@ -6605,7 +6604,7 @@ public void subqueryVariableOverridesQueryVariableTest() throws Exception { } if (!pass) - throw new Fault("subqueryVariableOverridesQueryVariableTest failed"); + throw new Exception("subqueryVariableOverridesQueryVariableTest failed"); } /* @@ -6658,7 +6657,7 @@ public void longIdentifierNameTest() throws Exception { } if (!pass1 || !pass2) - throw new Fault("longIdentifierNameTest failed"); + throw new Exception("longIdentifierNameTest failed"); } /* @@ -6708,7 +6707,7 @@ public void underscoreIdentifierNameTest() throws Exception { } if (!pass1 || !pass2) - throw new Fault("underscoreIdentifierNameTest failed"); + throw new Exception("underscoreIdentifierNameTest failed"); } /* @@ -6759,7 +6758,7 @@ public void dollarsignIdentifierNameTest() throws Exception { } if (!pass1 || !pass2) - throw new Fault("dollarsignIdentifierNameTest failed"); + throw new Exception("dollarsignIdentifierNameTest failed"); } /* @@ -6801,7 +6800,7 @@ public void entityTypeLiteralTest() throws Exception { } if (!pass) - throw new Fault("entityTypeLiteralTest failed"); + throw new Exception("entityTypeLiteralTest failed"); } /* @@ -6868,7 +6867,7 @@ public void scalarExpressionsTest() throws Exception { } if (!pass1 || !pass2) - throw new Fault("scalarExpressionsTest failed"); + throw new Exception("scalarExpressionsTest failed"); } /* @@ -6927,7 +6926,7 @@ public void distinctNotSpecifiedTest() throws Exception { } if (!pass) - throw new Fault("distinctNotSpecifiedTest failed"); + throw new Exception("distinctNotSpecifiedTest failed"); } /* @@ -6969,7 +6968,7 @@ public void resultVariableTest() throws Exception { } if (!pass) - throw new Fault("resultVariableTest failed"); + throw new Exception("resultVariableTest failed"); } /* @@ -7042,7 +7041,7 @@ public void embeddableNotManagedTest() throws Exception { } if (!pass1 || !pass2) - throw new Fault("embeddableNotManagedTest failed"); + throw new Exception("embeddableNotManagedTest failed"); } @@ -7088,7 +7087,7 @@ public void resultContainsFetchReference() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("resultContainsFetchReference test failed"); + throw new Exception("resultContainsFetchReference test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/parameter/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/parameter/Client.java index 881fd9eb70..bac2940a46 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/parameter/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/query/parameter/Client.java @@ -21,7 +21,6 @@ import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -37,31 +36,26 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); getEntityManager(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } public void setupEmployee(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupEmployee"); try { - super.setup(args, p); + super.setup(); createEmployeeData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -181,7 +175,7 @@ public void parameterTest1() throws Exception { if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 || !pass8) { - throw new Fault("parameterTest1 failed"); + throw new Exception("parameterTest1 failed"); } } @@ -300,7 +294,7 @@ public void parameterTestTQ1() throws Exception { if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 || !pass8) { - throw new Fault("parameterTestTQ1 failed"); + throw new Exception("parameterTestTQ1 failed"); } } @@ -375,7 +369,7 @@ public void parameterTest2() throws Exception { } if (pass1 != 2 || pass2 != 2 || pass3 != 2) { - throw new Fault("parameterTest2 failed"); + throw new Exception("parameterTest2 failed"); } } @@ -446,7 +440,7 @@ public void parameterTQTest2() throws Exception { + sParameters.size()); } if (pass1 != 2 || pass2 != 2 || pass3 != 2) { - throw new Fault("parameterTQTest2 failed"); + throw new Exception("parameterTQTest2 failed"); } } @@ -494,7 +488,7 @@ public void parameterTest4() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("parameterTest4 failed"); + throw new Exception("parameterTest4 failed"); } } @@ -543,7 +537,7 @@ public void parameterTest5() throws Exception { } if (!pass1 || !pass2) { - throw new Fault("parameterTest5 failed"); + throw new Exception("parameterTest5 failed"); } } @@ -609,7 +603,7 @@ public void getParametersTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getParametersTest failed"); + throw new Exception("getParametersTest failed"); } } @@ -676,7 +670,7 @@ public void getParametersTQTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getParametersTQTest failed"); + throw new Exception("getParametersTQTest failed"); } } @@ -716,7 +710,7 @@ public void getParametersNoParametersTest() throws Exception { } if (!pass) { - throw new Fault("getParametersNoParametersTest failed"); + throw new Exception("getParametersNoParametersTest failed"); } } @@ -758,7 +752,7 @@ public void parameterPositionalTest() throws Exception { TestUtil.logErr("Caught exception:", e); } if (!pass) - throw new Fault("parameterPositionalTest failed"); + throw new Exception("parameterPositionalTest failed"); } /* @@ -805,7 +799,7 @@ public void parameterUpdateTest() throws Exception { TestUtil.logErr("Caught exception:", e); } if (!pass) - throw new Fault("parameterUpdateTest failed"); + throw new Exception("parameterUpdateTest failed"); } /* @@ -844,7 +838,7 @@ public void parameterCaseTest() throws Exception { TestUtil.logErr("Caught exception:", e); } if (!pass) - throw new Fault("parameterCaseTest failed"); + throw new Exception("parameterCaseTest failed"); } /* @@ -882,7 +876,7 @@ public void parameterNamedParameterTwiceTest() throws Exception { TestUtil.logErr("Caught exception:", e); } if (!pass) - throw new Fault("parameterNamedParameterTwiceTest failed"); + throw new Exception("parameterNamedParameterTwiceTest failed"); } public void createEmployeeData() throws Exception { @@ -907,7 +901,7 @@ public void createEmployeeData() throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("createDepartmentEmployeeData failed:", e); + throw new Exception("createDepartmentEmployeeData failed:", e); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/annotations/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/annotations/Client.java index f9376d0de8..9167152da4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/annotations/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/annotations/Client.java @@ -23,10 +23,8 @@ import java.math.BigDecimal; import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -49,21 +47,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -128,7 +121,7 @@ public void annotationMappingTest1() throws Exception { } if (!pass) - throw new Fault("annotationMappingTest1 failed"); + throw new Exception("annotationMappingTest1 failed"); } /* @@ -192,7 +185,7 @@ public void annotationMappingPersistTest1() throws Exception { } if (!pass) - throw new Fault("annotationMappingPersistTest1 failed"); + throw new Exception("annotationMappingPersistTest1 failed"); } /* @@ -330,7 +323,7 @@ public void annotationMappingTest2() throws Exception { } if (!pass2) - throw new Fault("annotationMappingTest2 failed"); + throw new Exception("annotationMappingTest2 failed"); } /* @@ -428,7 +421,7 @@ public void annotationMappingTest3() throws Exception { } if (!pass) - throw new Fault("annotationMappingTest3 failed"); + throw new Exception("annotationMappingTest3 failed"); } /* @@ -501,7 +494,7 @@ public void annotationMappingTest4() throws Exception { } if (!pass) - throw new Fault("annotationMappingTest4 failed"); + throw new Exception("annotationMappingTest4 failed"); } /* @@ -581,7 +574,7 @@ public void annotationMappingTest5() throws Exception { } if (!pass) - throw new Fault("annotationMappingTest5 failed"); + throw new Exception("annotationMappingTest5 failed"); } /* @@ -745,7 +738,7 @@ public void annotationMappingTest6() throws Exception { } if (!pass1 || !pass2) - throw new Fault("annotationMappingTest6 failed"); + throw new Exception("annotationMappingTest6 failed"); } /* @@ -963,7 +956,7 @@ public void annotationMappingTest7() throws Exception { } if (!pass1 || !pass2) - throw new Fault("annotationMappingTest7 failed"); + throw new Exception("annotationMappingTest7 failed"); } /* @@ -1113,7 +1106,7 @@ public void annotationMappingTest8() throws Exception { } if (!pass1 || !pass2) - throw new Fault("annotationMappingTest8 failed"); + throw new Exception("annotationMappingTest8 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxmany/Client.java index 4f2a1dfb51..2381b90e69 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxmany/Client.java @@ -17,10 +17,8 @@ package com.sun.ts.tests.jpa.core.relationship.bidirmanyxmany; import java.util.Collection; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,21 +30,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -163,7 +156,7 @@ public void biDirMXMTest1() throws Exception { } if (!pass) { - throw new Fault("biDirMXMTest1 failed"); + throw new Exception("biDirMXMTest1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxone/Client.java index 9445bd54fe..e842a30e5d 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidirmanyxone/Client.java @@ -18,9 +18,7 @@ import java.util.ArrayList; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,21 +30,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -146,7 +139,7 @@ public void biDirMX1Test1() throws Exception { } if (!pass) { - throw new Fault("biDirMX1Test1 failed"); + throw new Exception("biDirMX1Test1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexmany/Client.java index f5c33b79c2..02757f7064 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexmany/Client.java @@ -16,10 +16,8 @@ package com.sun.ts.tests.jpa.core.relationship.bidironexmany; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,21 +29,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -185,7 +178,7 @@ public void biDir1XMTest1() throws Exception { } if (!pass) { - throw new Fault("biDir1XMTest1 failed"); + throw new Exception("biDir1XMTest1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexone/Client.java index 95d7e32d75..744e05b034 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/bidironexone/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.relationship.bidironexone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,21 +27,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -109,7 +101,7 @@ public void biDir1X1Test1() throws Exception { } if (!pass) { - throw new Fault("biDir1X1Test1 failed"); + throw new Exception("biDir1X1Test1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/defaults/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/defaults/Client.java index 8ea723be9a..996d1b7a1e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/defaults/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/defaults/Client.java @@ -22,10 +22,8 @@ import java.math.BigDecimal; import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -48,21 +46,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -125,7 +118,7 @@ public void mappingTest1() throws Exception { } if (!pass) - throw new Fault("mappingTest1 failed"); + throw new Exception("mappingTest1 failed"); } /* @@ -260,7 +253,7 @@ public void mappingTest2() throws Exception { } if (!pass2) - throw new Fault("mappingTest2 failed"); + throw new Exception("mappingTest2 failed"); } /* @@ -356,7 +349,7 @@ public void mappingTest3() throws Exception { } if (!pass) - throw new Fault("mappingTest3 failed"); + throw new Exception("mappingTest3 failed"); } /* @@ -428,7 +421,7 @@ public void mappingTest4() throws Exception { } if (!pass) - throw new Fault("mappingTest4 failed"); + throw new Exception("mappingTest4 failed"); } /* @@ -507,7 +500,7 @@ public void mappingTest5() throws Exception { } if (!pass) - throw new Fault("mappingTest5 failed"); + throw new Exception("mappingTest5 failed"); } /* @@ -665,7 +658,7 @@ public void mappingTest6() throws Exception { } if (!pass1 || !pass2) - throw new Fault("mappingTest6 failed"); + throw new Exception("mappingTest6 failed"); } /* @@ -881,7 +874,7 @@ public void mappingTest7() throws Exception { } if (!pass1 || !pass2) - throw new Fault("mappingTest7 failed"); + throw new Exception("mappingTest7 failed"); } /* @@ -1028,7 +1021,7 @@ public void mappingTest8() throws Exception { } if (!pass1 || !pass2) - throw new Fault("mappingTest8 failed"); + throw new Exception("mappingTest8 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/descriptors/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/descriptors/Client.java index 1427593380..5419f984cb 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/descriptors/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/descriptors/Client.java @@ -22,10 +22,8 @@ import java.math.BigDecimal; import java.util.Collection; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -48,22 +46,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -125,7 +118,7 @@ public void descriptorMappingTest1() throws Exception { } if (!pass) - throw new Fault("descriptorMappingTest1 failed"); + throw new Exception("descriptorMappingTest1 failed"); } /* @@ -260,7 +253,7 @@ public void descriptorMappingTest2() throws Exception { } if (!pass2) - throw new Fault("descriptorMappingTest2 failed"); + throw new Exception("descriptorMappingTest2 failed"); } /* @@ -356,7 +349,7 @@ public void descriptorMappingTest3() throws Exception { } if (!pass) - throw new Fault("descriptorMappingTest3 failed"); + throw new Exception("descriptorMappingTest3 failed"); } /* @@ -428,7 +421,7 @@ public void descriptorMappingTest4() throws Exception { } if (!pass) - throw new Fault("descriptorMappingTest4 failed"); + throw new Exception("descriptorMappingTest4 failed"); } /* @@ -508,7 +501,7 @@ public void descriptorMappingTest5() throws Exception { } if (!pass) - throw new Fault("descriptorMappingTest5 failed"); + throw new Exception("descriptorMappingTest5 failed"); } /* @@ -666,7 +659,7 @@ public void descriptorMappingTest6() throws Exception { } if (!pass1 || !pass2) - throw new Fault("descriptorMappingTest6 failed"); + throw new Exception("descriptorMappingTest6 failed"); } /* @@ -882,7 +875,7 @@ public void descriptorMappingTest7() throws Exception { } if (!pass1 || !pass2) - throw new Fault("descriptorMappingTest7 failed"); + throw new Exception("descriptorMappingTest7 failed"); } /* @@ -1029,7 +1022,7 @@ public void descriptorMappingTest8() throws Exception { } if (!pass1 || !pass2) - throw new Fault("descriptorMappingTest8 failed"); + throw new Exception("descriptorMappingTest8 failed"); } /* diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxmany/Client.java index 646550129b..7c22f22410 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxmany/Client.java @@ -17,10 +17,8 @@ package com.sun.ts.tests.jpa.core.relationship.unimanyxmany; import java.util.Collection; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,20 +30,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -150,7 +143,7 @@ public void uniMXMTest1() throws Exception { } if (!pass) { - throw new Fault("uniMXMTest1 failed"); + throw new Exception("uniMXMTest1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxone/Client.java index aecd5b12de..74f61ea968 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unimanyxone/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.relationship.unimanyxone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +27,15 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -133,7 +125,7 @@ public void uniMX1Test1() throws Exception { } if (!pass) { - throw new Fault("uniMX1Test1 failed"); + throw new Exception("uniMX1Test1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexmany/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexmany/Client.java index ff9d3d7a9f..4adf1bf639 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexmany/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexmany/Client.java @@ -17,10 +17,8 @@ package com.sun.ts.tests.jpa.core.relationship.unionexmany; import java.util.Collection; -import java.util.Properties; import java.util.Vector; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,21 +31,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -126,7 +119,7 @@ public void uni1XMTest1() throws Exception { } if (!pass) { - throw new Fault("uni1XMTest1 failed"); + throw new Exception("uni1XMTest1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexone/Client.java index e81b288d9e..573f6cfd8b 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/relationship/unionexone/Client.java @@ -16,9 +16,6 @@ package com.sun.ts.tests.jpa.core.relationship.unionexone; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,21 +28,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -95,7 +87,7 @@ public void uni1X1Test1() throws Exception { } if (!pass) { - throw new Fault("uni1X1Test1 failed"); + throw new Exception("uni1X1Test1 failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/auto/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/auto/Client.java index c77887e935..a962a320d2 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/auto/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/auto/Client.java @@ -20,9 +20,6 @@ package com.sun.ts.tests.jpa.core.types.auto; -import java.util.Properties; - -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -49,23 +46,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -139,7 +131,7 @@ public void autoTypeTest1() throws Exception { } if (!pass) - throw new Fault("autoTypeTest1 failed"); + throw new Exception("autoTypeTest1 failed"); } /* @@ -200,7 +192,7 @@ public void autoTypeTest2() throws Exception { } if (!pass) - throw new Fault("autoTypeTest2 failed"); + throw new Exception("autoTypeTest2 failed"); } /* @@ -261,7 +253,7 @@ public void autoTypeTest3() throws Exception { } if (!pass) - throw new Fault("autoTypeTest3 failed"); + throw new Exception("autoTypeTest3 failed"); } /* @@ -322,7 +314,7 @@ public void autoTypeTest4() throws Exception { } if (!pass) - throw new Fault("autoTypeTest4 failed"); + throw new Exception("autoTypeTest4 failed"); } /* @@ -383,7 +375,7 @@ public void autoTypeTest5() throws Exception { } if (!pass) - throw new Fault("autoTypeTest5 failed"); + throw new Exception("autoTypeTest5 failed"); } /* @@ -444,7 +436,7 @@ public void autoTypeTest6() throws Exception { } if (!pass) - throw new Fault("autoTypeTest6 failed"); + throw new Exception("autoTypeTest6 failed"); } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/field/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/field/Client.java index 2fea12695b..5a3415dc40 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/field/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/field/Client.java @@ -18,10 +18,8 @@ import java.util.Arrays; import java.util.List; -import java.util.Properties; import java.util.UUID; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.core.types.common.Grade; @@ -41,22 +39,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -108,7 +101,7 @@ public void fieldTypeTest1() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest1 failed"); + throw new Exception("fieldTypeTest1 failed"); } /* @@ -159,7 +152,7 @@ public void fieldTypeTest2() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest2 failed"); + throw new Exception("fieldTypeTest2 failed"); } /* @@ -210,7 +203,7 @@ public void fieldTypeTest3() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest3 failed"); + throw new Exception("fieldTypeTest3 failed"); } /* @@ -261,7 +254,7 @@ public void fieldTypeTest4() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest4 failed"); + throw new Exception("fieldTypeTest4 failed"); } /* @@ -311,7 +304,7 @@ public void fieldTypeTest5() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest5 failed"); + throw new Exception("fieldTypeTest5 failed"); } /* @@ -362,7 +355,7 @@ public void fieldTypeTest6() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest6 failed"); + throw new Exception("fieldTypeTest6 failed"); } /* @@ -412,7 +405,7 @@ public void fieldTypeTest7() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest7 failed"); + throw new Exception("fieldTypeTest7 failed"); } /* @@ -471,7 +464,7 @@ public void fieldTypeTest8() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest8 failed"); + throw new Exception("fieldTypeTest8 failed"); } /* @@ -528,7 +521,7 @@ public void fieldTypeTest9() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest9 failed"); + throw new Exception("fieldTypeTest9 failed"); } /* @@ -583,7 +576,7 @@ public void fieldTypeTest10() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest10 failed"); + throw new Exception("fieldTypeTest10 failed"); } /* @@ -651,7 +644,7 @@ public void fieldTypeTest11() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest11 failed"); + throw new Exception("fieldTypeTest11 failed"); } /* @@ -709,7 +702,7 @@ public void fieldTypeTest12() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest12 failed"); + throw new Exception("fieldTypeTest12 failed"); } /* @@ -765,7 +758,7 @@ public void fieldTypeTest13() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest13 failed"); + throw new Exception("fieldTypeTest13 failed"); } /* @@ -822,7 +815,7 @@ public void fieldTypeTest14() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest14 failed"); + throw new Exception("fieldTypeTest14 failed"); } /* @@ -885,7 +878,7 @@ public void fieldTypeTest15() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest15 failed"); + throw new Exception("fieldTypeTest15 failed"); } /* @@ -950,7 +943,7 @@ public void fieldTypeTest16() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest16 failed"); + throw new Exception("fieldTypeTest16 failed"); } /* @@ -1016,7 +1009,7 @@ public void fieldTypeTest17() throws Exception { } if (!pass) - throw new Fault("fieldTypeTest17 failed"); + throw new Exception("fieldTypeTest17 failed"); } /* @@ -1038,15 +1031,15 @@ public void testCreateUUIDType() throws Exception { UUIDType fromDb = getEntityManager().find(UUIDType.class, id); System.out.println("UUID: " + fromDb.getId().toString()); if (fromDb == null) { - throw new Fault("testCreateUUIDType: no UUID was found in database"); + throw new Exception("testCreateUUIDType: no UUID was found in database"); } if (!id.equals(fromDb.getId())) { - throw new Fault("testCreateUUIDType: UUID returned from database " + fromDb.getId() + throw new Exception("testCreateUUIDType: UUID returned from database " + fromDb.getId() + " does not match expected value " + id); } } catch (Exception ex) { TestUtil.logErr("Caught exception: ", ex); - throw new Fault("Caught exception: ", ex); + throw new Exception("Caught exception: ", ex); } finally { if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); @@ -1213,7 +1206,7 @@ public void scalarExpressionsTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5) - throw new Fault("scalarExpressionsTest failed"); + throw new Exception("scalarExpressionsTest failed"); } // Methods used for Tests diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/Client.java index 575168355d..b2dd695fd1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,790 +20,20 @@ package com.sun.ts.tests.jpa.core.types.generator; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; public class Client extends PMClientBase { - private DataTypes d0; - - private DataTypes d1; - - private DataTypes d2; - - private DataTypes d3; - - private DataTypes d4; - - private DataTypes d5; - - private DataTypes d6; - - private DataTypes2 d10; - - private DataTypes3 d11; - - private DataTypes4 d12; - - private boolean supports_sequence = false; + protected boolean supports_sequence = false; public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* - * @class.setup_props: db.supports.sequence; - */ - - public void setup(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setup"); - try { - - super.setup(args, p); - String s = p.getProperty("db.supports.sequence"); - if (s != null) { - supports_sequence = Boolean.parseBoolean(s); - TestUtil.logMsg("db.supports.sequence:" + supports_sequence); - if (supports_sequence) { - removeTestData(); - createTestData(); - } - } else { - TestUtil.logErr( - "The property db.supports.sequence is not defined in the ts.jte, this must be corrected before running tests"); - throw new Fault("setupDataTypes2 failed"); - - } - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); - } - } - - /* - * @class.setup_props: db.supports.sequence; - */ - - public void setupDataTypes2(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setupDataTypes2"); - try { - - super.setup(args, p); - String s = p.getProperty("db.supports.sequence"); - if (s != null) { - supports_sequence = Boolean.parseBoolean(s); - TestUtil.logMsg("db.supports.sequence:" + supports_sequence); - if (supports_sequence) { - removeTestData(); - createDataTypes2Data(); - } - } else { - TestUtil.logErr( - "The property db.supports.sequence is not defined in the ts.jte, this must be corrected before running tests"); - throw new Fault("setupDataTypes2 failed"); - - } - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("setupDataTypes2 failed:", e); - } - } - - /* - * @class.setup_props: db.supports.sequence; - */ - - public void setupDataTypes3(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setupDataTypes3"); - try { - - super.setup(args, p); - String s = p.getProperty("db.supports.sequence"); - if (s != null) { - supports_sequence = Boolean.parseBoolean(s); - TestUtil.logMsg("db.supports.sequence:" + supports_sequence); - if (supports_sequence) { - removeTestData(); - createDataTypes3Data(); - } - } else { - TestUtil.logErr( - "The property db.supports.sequence is not defined in the ts.jte, this must be corrected before running tests"); - throw new Fault("setupDataTypes3 failed"); - - } - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("setupDataTypes3 failed:", e); - } - } - - /* - * @class.setup_props: db.supports.sequence; - */ - - public void setupDataTypes4(String[] args, Properties p) throws Exception { - TestUtil.logTrace("setupDataTypes4"); - try { - - super.setup(args, p); - String s = p.getProperty("db.supports.sequence"); - if (s != null) { - supports_sequence = Boolean.parseBoolean(s); - TestUtil.logMsg("db.supports.sequence:" + supports_sequence); - if (supports_sequence) { - removeTestData(); - createDataTypes4Data(); - } - } else { - TestUtil.logErr( - "The property db.supports.sequence is not defined in the ts.jte, this must be corrected before running tests"); - throw new Fault("setupDataTypes4 failed"); - - } - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Fault("setupDataTypes4 failed:", e); - } - } - /* - * @testName: generatorTypeTest1 - * - * @assertion_ids: PERSISTENCE:JAVADOC:82; PERSISTENCE:JAVADOC:83; - * PERSISTENCE:SPEC:1051; PERSISTENCE:SPEC:1052; PERSISTENCE:SPEC:1057; - * PERSISTENCE:JAVADOC:206; PERSISTENCE:JAVADOC:209; PERSISTENCE:JAVADOC:210; - * PERSISTENCE:JAVADOC:211; PERSISTENCE:JAVADOC:213; PERSISTENCE:JAVADOC:215; - * PERSISTENCE:JAVADOC:81; PERSISTENCE:SPEC:1136; PERSISTENCE:JAVADOC:208; - * PERSISTENCE:SPEC:2158; PERSISTENCE:SPEC:2189; PERSISTENCE:SPEC:2023; - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.TABLE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database strategy table to - * ensure uniqueness. - * - * Using GenerationType.TABLE, access a persisted entity and modify its' data. - */ - - public void generatorTypeTest1() throws Exception { - - boolean pass = false; - if (supports_sequence) { - - final Character newChar = 'b'; - - try { - getEntityTransaction().begin(); - int id = d0.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - d1 = getEntityManager().find(DataTypes.class, id); - - if (null != d1) { - if (d1.getCharacterData().equals('a')) { - d1.setCharacterData(newChar); - } - - getEntityManager().merge(d1); - getEntityManager().flush(); - - if (d1.getCharacterData().equals(newChar)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("EntityManager.find returned null result"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - pass = true; - } - if (!pass) - throw new Fault("generatorTypeTest1 failed"); - } - - /* - * @testName: generatorTypeTest2 - * - * @assertion_ids: PERSISTENCE:JAVADOC:82; PERSISTENCE:JAVADOC:83; - * PERSISTENCE:SPEC:1051; PERSISTENCE:SPEC:1052; PERSISTENCE:SPEC:1057 - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.TABLE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database strategy table to - * ensure uniqueness. - * - * Using GenerationType.TABLE, access a persisted entity and modify its' data. - */ - - public void generatorTypeTest2() throws Exception { - - boolean pass = false; - if (supports_sequence) { - - final Short newShort = (short) 101; - - try { - getEntityTransaction().begin(); - int id = d0.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - d2 = getEntityManager().find(DataTypes.class, id); - - if (null != d2) { - if (d2.getShortData().equals((short) 100)) { - d2.setShortData(newShort); - } - - getEntityManager().merge(d2); - getEntityManager().flush(); - - if (d2.getShortData().equals(newShort)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("EntityManager.find returned null result"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - pass = true; - } - if (!pass) - throw new Fault("generatorTypeTest2 failed"); - } - - /* - * @testName: generatorTypeTest3 - * - * @assertion_ids: PERSISTENCE:JAVADOC:82; PERSISTENCE:JAVADOC:83; - * PERSISTENCE:SPEC:1051; PERSISTENCE:SPEC:1052; PERSISTENCE:SPEC:1057 - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.TABLE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database strategy table to - * ensure uniqueness. - * - * Using GenerationType.TABLE, access a persisted entity and modify its' data. - */ - - public void generatorTypeTest3() throws Exception { - - boolean pass = false; - if (supports_sequence) { - - final Integer newInt = 500; - - try { - getEntityTransaction().begin(); - int id = d0.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - d3 = getEntityManager().find(DataTypes.class, id); - - if (null != d3) { - if (d3.getIntegerData().equals(500)) { - d3.setIntegerData(newInt); - } - - getEntityManager().merge(d3); - getEntityManager().flush(); - - if (d3.getIntegerData().equals(newInt)) { - pass = true; - } - getEntityTransaction().commit(); - } else { - TestUtil.logErr("EntityManager.find returned null result"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - pass = true; - } - if (!pass) - throw new Fault("generatorTypeTest3 failed"); - } - - /* - * @testName: generatorTypeTest4 - * - * @assertion_ids: PERSISTENCE:JAVADOC:82; PERSISTENCE:JAVADOC:83; - * PERSISTENCE:SPEC:1051; PERSISTENCE:SPEC:1052; PERSISTENCE:SPEC:1057 - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.TABLE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database strategy table to - * ensure uniqueness. - * - * Using GenerationType.TABLE, access a persisted entity and modify its' data. - */ - - public void generatorTypeTest4() throws Exception { - - boolean pass = false; - if (supports_sequence) { - - final Long newLong = 600L; - - try { - getEntityTransaction().begin(); - int id = d0.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - d4 = getEntityManager().find(DataTypes.class, id); - - if (null != d4) { - if (d4.getLongData().equals(300L)) { - d4.setLongData(newLong); - } - - getEntityManager().merge(d4); - getEntityManager().flush(); - - if (d4.getLongData().equals(newLong)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("EntityManager.find returned null result"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - pass = true; - } - if (!pass) - throw new Fault("generatorTypeTest4 failed"); - } - - /* - * @testName: generatorTypeTest5 - * - * @assertion_ids: PERSISTENCE:JAVADOC:82; PERSISTENCE:JAVADOC:83; - * PERSISTENCE:SPEC:1051; PERSISTENCE:SPEC:1052; PERSISTENCE:SPEC:1057 - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.TABLE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database strategy table to - * ensure uniqueness. - * - * Using GenerationType.TABLE, access a persisted entity and modify its' data. - */ - - public void generatorTypeTest5() throws Exception { - - boolean pass = false; - if (supports_sequence) { - - final Double newDbl = 80D; - - try { - getEntityTransaction().begin(); - int id = d0.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - d5 = getEntityManager().find(DataTypes.class, id); - - if (null != d5) { - if (d5.getDoubleData().equals(50D)) { - d5.setDoubleData(newDbl); - } - - getEntityManager().merge(d5); - getEntityManager().flush(); - - if (d5.getDoubleData().equals(newDbl)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("EntityManager.find returned null result"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - pass = true; - } - if (!pass) - throw new Fault("generatorTypeTest5 failed"); - } - - /* - * @testName: generatorTypeTest6 - * - * @assertion_ids: PERSISTENCE:JAVADOC:82; PERSISTENCE:JAVADOC:83; - * PERSISTENCE:SPEC:1051; PERSISTENCE:SPEC:1052; PERSISTENCE:SPEC:1057 - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.TABLE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database strategy table to - * ensure uniqueness. - * - * Using GenerationType.TABLE, access a persisted entity and modify its' data. - */ - - public void generatorTypeTest6() throws Exception { - - boolean pass = false; - if (supports_sequence) { - - final Float newFloat = 3.0F; - - try { - getEntityTransaction().begin(); - int id = d0.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - d6 = getEntityManager().find(DataTypes.class, id); - - if (null != d6) { - if (d6.getFloatData().equals(1.0F)) { - d6.setFloatData(newFloat); - } - - getEntityManager().merge(d6); - getEntityManager().flush(); - - if (d6.getFloatData().equals(newFloat)) { - pass = true; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("EntityManager.find returned null result"); - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - pass = true; - } - if (!pass) - throw new Fault("generatorTypeTest6 failed"); - - } - - /* - * @testName: generatorTypeSequenceTest - * - * @assertion_ids: PERSISTENCE:JAVADOC:194; PERSISTENCE:JAVADOC:195; - * PERSISTENCE:JAVADOC:196; PERSISTENCE:SPEC:2107.2; PERSISTENCE:SPEC:2106; - * - * @test_Strategy: The GeneratedValue annotation provides for the - * specification of generation strategies for the values of primary keys. - * GenerationType.SEQUENCE, indicates the persistence provider must assign - * primary keys for the entity using an underlying database sequence generator - * to ensure uniqueness. - * - * Using GenerationType.SEQUENCE, access a persisted entity and modify its' - * data. - */ - @SetupMethod(name = "setupDataTypes2") - public void generatorTypeSequenceTest() throws Exception { - - boolean pass = true; - if (supports_sequence) { - final Float newFloat = 3.0F; - - try { - getEntityTransaction().begin(); - int id = d10.getId(); - TestUtil.logTrace("Doing a find of id: " + id); - DataTypes2 d = getEntityManager().find(DataTypes2.class, id); - - if (null != d) { - Float f = d.getFloatData(); - if (f.equals(d10.getFloatData())) { - TestUtil.logTrace("find returned correct float value:" + f); - d.setFloatData(newFloat); - } else { - TestUtil.logErr( - "find did not return correct float value, expected: 1.0, actual:" - + f); - pass = false; - } - - getEntityManager().merge(d); - getEntityManager().flush(); - f = d.getFloatData(); - if (f.equals(newFloat)) { - TestUtil.logTrace("Successfully set float value to:" + newFloat); - } else { - TestUtil.logErr("Could not update float value, expected: " - + newFloat + ", actual:" + f); - pass = false; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null result"); - pass = false; - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - } - if (!pass) - throw new Fault("generatorTypeSequenceTest failed"); - - } - - /* - * @testName: sequenceGeneratorOnEntityTest - * - * @assertion_ids: PERSISTENCE:SPEC:2107; PERSISTENCE:SPEC:2107.1; - * - * @test_Strategy: A sequence generator may be specified on the entity class - */ - @SetupMethod(name = "setupDataTypes3") - - public void sequenceGeneratorOnEntityTest() throws Exception { - - boolean pass = true; - if (supports_sequence) { - final Integer newInt = 1000; - - try { - getEntityTransaction().begin(); - clearCache(); - TestUtil.logMsg("Doing a find of id: " + d11.getId()); - DataTypes3 d = getEntityManager().find(DataTypes3.class, d11.getId()); - - if (d != null) { - Integer i = d.getIntegerData(); - if (i.equals(d11.getIntegerData())) { - TestUtil.logTrace("find returned correct Integer value:" + i); - d.setIntegerData(newInt); - } else { - TestUtil - .logErr("find did not return correct Integer value, expected: " - + d11.getIntegerData() + ", actual:" + i); - pass = false; - } - - getEntityManager().merge(d); - getEntityManager().flush(); - clearCache(); - TestUtil.logMsg("Doing a find of merged data for id: " + d.getId()); - DataTypes3 d2 = getEntityManager().find(DataTypes3.class, d.getId()); - i = d2.getIntegerData(); - if (i.equals(d2.getIntegerData())) { - TestUtil - .logTrace("find returned correct merged Integer value:" + i); - } else { - TestUtil - .logErr("find did not return correct Integer value, expected: " - + d.getIntegerData() + ", actual:" + i); - pass = false; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null result"); - pass = false; - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - } - if (!pass) - throw new Fault("sequenceGeneratorOnEntityTest failed"); - - } - - /* - * @testName: sequenceGeneratorOnPropertyTest - * - * @assertion_ids: PERSISTENCE:SPEC:2107; PERSISTENCE:SPEC:2107.3; - * - * @test_Strategy: A sequence generator may be specified on the primary key - * property - */ - @SetupMethod(name = "setupDataTypes4") - public void sequenceGeneratorOnPropertyTest() throws Exception { - - boolean pass = true; - if (supports_sequence) { - final Integer newInt = 1000; - - try { - getEntityTransaction().begin(); - clearCache(); - TestUtil.logMsg("Doing a find of id: " + d12.getId()); - DataTypes4 d = getEntityManager().find(DataTypes4.class, d12.getId()); - - if (d != null) { - Integer i = d.getIntegerData(); - if (i.equals(d12.getIntegerData())) { - TestUtil.logTrace("find returned correct Integer value:" + i); - d.setIntegerData(newInt); - } else { - TestUtil - .logErr("find did not return correct Integer value, expected: " - + d12.getIntegerData() + ", actual:" + i); - pass = false; - } - - getEntityManager().merge(d); - getEntityManager().flush(); - clearCache(); - TestUtil.logMsg("Doing a find of merged data for id: " + d.getId()); - DataTypes4 d2 = getEntityManager().find(DataTypes4.class, d.getId()); - i = d2.getIntegerData(); - if (i.equals(d2.getIntegerData())) { - TestUtil - .logTrace("find returned correct merged Integer value:" + i); - } else { - TestUtil - .logErr("find did not return correct Integer value, expected: " - + d.getIntegerData() + ", actual:" + i); - pass = false; - } - - getEntityTransaction().commit(); - } else { - TestUtil.logErr("find returned null result"); - pass = false; - } - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - pass = false; - } - } else { - TestUtil.logMsg( - "WARNING: Test not run because db.supports.sequence set to false in ts.jte"); - } - if (!pass) - throw new Fault("sequenceGeneratorOnEntityTest failed"); - - } - - // Methods used for Tests - - public void createTestData() { - try { - getEntityTransaction().begin(); - - TestUtil.logTrace("in createTestData"); - - TestUtil.logTrace("new DataType"); - d0 = new DataTypes('a', (short) 100, 500, 300L, 50D, 1.0F); - TestUtil.logTrace("Persist DataType"); - getEntityManager().persist(d0); - TestUtil.logTrace("DataType id:" + d0.getId()); - - getEntityManager().flush(); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } - - public void createDataTypes2Data() { - try { - getEntityTransaction().begin(); - - TestUtil.logTrace("in createDataTypes2Data"); - - TestUtil.logTrace("new DataType2"); - d10 = new DataTypes2('a', (short) 100, 500, 300L, 50D, 1.0F); - TestUtil.logTrace("Persist DataType2"); - getEntityManager().persist(d10); - TestUtil.logTrace("DataType2 id:" + d10.getId()); - - getEntityManager().flush(); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } - - public void createDataTypes3Data() { - try { - getEntityTransaction().begin(); - - TestUtil.logTrace("in createDataTypes3Data"); - - TestUtil.logTrace("new DataType3"); - d11 = new DataTypes3(500); - TestUtil.logTrace("Persist DataType3"); - getEntityManager().persist(d11); - TestUtil.logTrace("DataType3 id:" + d11.getId()); - - getEntityManager().flush(); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } - - public void createDataTypes4Data() { - try { - getEntityTransaction().begin(); - - TestUtil.logTrace("in createDataTypes4Data"); - - TestUtil.logTrace("new DataType4"); - d12 = new DataTypes4(500); - TestUtil.logTrace("Persist DataType4"); - getEntityManager().persist(d12); - TestUtil.logTrace("DataType4 id:" + d12.getId()); - - getEntityManager().flush(); - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Unexpected exception occurred", e); - } - } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -811,7 +41,7 @@ public void cleanup() throws Exception { super.cleanup(); } - private void removeTestData() { + protected void removeTestData() { TestUtil.logTrace("removeTestData"); if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/primarykey/compound/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/primarykey/compound/Client.java index 06ef2d5b9a..fe58b4670c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/primarykey/compound/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/primarykey/compound/Client.java @@ -20,9 +20,10 @@ package com.sun.ts.tests.jpa.core.types.primarykey.compound; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -43,16 +44,12 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("Entering setup"); - super.setup(args, p); + super.setup(); removeTestData(); } @@ -79,6 +76,7 @@ public void setup(String[] args, Properties p) throws Exception { * There should be only one EmbeddedId annotation and no Id * annotations when the EmbeddedId annotation is used. */ + @Test public void testCompoundPK1() throws Exception { TestBean bean1; @@ -143,12 +141,12 @@ public void testCompoundPK1() throws Exception { pass = true; } if (!pass) { - throw new Fault("[testCompoundPK1] bean2 and bean4 PK should match!"); + throw new Exception("[testCompoundPK1] bean2 and bean4 PK should match!"); } } catch (Exception e) { TestUtil.logErr("[testCompoundPK1] Caught exception: " + e); - throw new Fault("testCompoundPK1 test failed: " + e, e); + throw new Exception("testCompoundPK1 test failed: " + e, e); } finally { try { if (getEntityTransaction().isActive()) { @@ -188,6 +186,7 @@ public void testCompoundPK1() throws Exception { * also be applied to such field or properties. This entity * uses the @Id annotations on the primary key properties. */ + @Test public void testCompoundPK2() throws Exception { TestBean2 bean1; @@ -230,12 +229,12 @@ public void testCompoundPK2() throws Exception { pass = true; } if (!pass) { - throw new Fault("[testCompoundPK2] bean2 and bean4 PK should match!"); + throw new Exception("[testCompoundPK2] bean2 and bean4 PK should match!"); } } catch (Exception e) { TestUtil.logErr("[testCompoundPK2] Caught exception: " + e); - throw new Fault("testCompoundPK2 test failed: " + e, e); + throw new Exception("testCompoundPK2 test failed: " + e, e); } finally { try { if (getEntityTransaction().isActive()) { @@ -273,6 +272,7 @@ public void testCompoundPK2() throws Exception { * When using the @IdClass annotion, the @Id annotation must * also be applied to such fields. */ + @Test public void testCompoundPK3() throws Exception { TestBean3 bean1; @@ -315,12 +315,12 @@ public void testCompoundPK3() throws Exception { pass = true; } if (!pass) { - throw new Fault("[testCompoundPK3] bean2 and bean4 PK should match!"); + throw new Exception("[testCompoundPK3] bean2 and bean4 PK should match!"); } } catch (Exception e) { TestUtil.logErr("[testCompoundPK3] Caught exception: " + e); - throw new Fault("testCompoundPK3 test failed: " + e, e); + throw new Exception("testCompoundPK3 test failed: " + e, e); } finally { try { if (getEntityTransaction().isActive()) { @@ -335,6 +335,7 @@ public void testCompoundPK3() throws Exception { /* testCompoundPK3 pass */ } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/property/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/property/Client.java index c7e4467f1c..5c48b036a7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/property/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/types/property/Client.java @@ -19,9 +19,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -41,34 +43,31 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { TestUtil.logErr("Unexpected exception occurred", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupCust(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupCust() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeCustTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -83,7 +82,7 @@ public void setupCust(String[] args, Properties p) throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: wrappers of the primitive types: Character */ - +@Test public void propertyTypeTest1() throws Exception { boolean pass = false; @@ -124,7 +123,7 @@ public void propertyTypeTest1() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest1 failed"); + throw new Exception("propertyTypeTest1 failed"); } /* @@ -136,7 +135,7 @@ public void propertyTypeTest1() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: wrappers of the primitive types: Short */ - +@Test public void propertyTypeTest2() throws Exception { boolean pass = false; @@ -176,7 +175,7 @@ public void propertyTypeTest2() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest2 failed"); + throw new Exception("propertyTypeTest2 failed"); } /* @@ -188,7 +187,7 @@ public void propertyTypeTest2() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: wrappers of the primitive types: Integer */ - +@Test public void propertyTypeTest3() throws Exception { boolean pass = false; @@ -227,7 +226,7 @@ public void propertyTypeTest3() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest3 failed"); + throw new Exception("propertyTypeTest3 failed"); } /* @@ -239,7 +238,7 @@ public void propertyTypeTest3() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: wrappers of the primitive types: Long */ - +@Test public void propertyTypeTest4() throws Exception { boolean pass = false; @@ -279,7 +278,7 @@ public void propertyTypeTest4() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest4 failed"); + throw new Exception("propertyTypeTest4 failed"); } /* @@ -291,7 +290,7 @@ public void propertyTypeTest4() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: wrappers of the primitive types: Double */ - +@Test public void propertyTypeTest5() throws Exception { boolean pass = false; @@ -331,7 +330,7 @@ public void propertyTypeTest5() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest5 failed"); + throw new Exception("propertyTypeTest5 failed"); } @@ -344,7 +343,7 @@ public void propertyTypeTest5() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: wrappers of the primitive types: Float */ - +@Test public void propertyTypeTest6() throws Exception { boolean pass = false; @@ -384,7 +383,7 @@ public void propertyTypeTest6() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest6 failed"); + throw new Exception("propertyTypeTest6 failed"); } @@ -400,7 +399,7 @@ public void propertyTypeTest6() throws Exception { * * Using the Enumerated annotation, with EnumType.ORDINAL. */ - +@Test public void propertyTypeTest7() throws Exception { boolean pass = false; @@ -445,7 +444,7 @@ public void propertyTypeTest7() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest7 failed"); + throw new Exception("propertyTypeTest7 failed"); } /* @@ -463,7 +462,7 @@ public void propertyTypeTest7() throws Exception { * * Temporal.TemporalType.DATE */ - +@Test public void propertyTypeTest8() throws Exception { boolean pass = false; @@ -501,7 +500,7 @@ public void propertyTypeTest8() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest8 failed"); + throw new Exception("propertyTypeTest8 failed"); } /* @@ -514,7 +513,7 @@ public void propertyTypeTest8() throws Exception { * following type: Byte[] * */ - +@Test public void propertyTypeTest9() throws Exception { boolean pass = false; @@ -570,7 +569,7 @@ public void propertyTypeTest9() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest9 failed"); + throw new Exception("propertyTypeTest9 failed"); } /* @@ -583,7 +582,7 @@ public void propertyTypeTest9() throws Exception { * following type: Character[] * */ - +@Test public void propertyTypeTest10() throws Exception { boolean pass = false; @@ -630,7 +629,7 @@ public void propertyTypeTest10() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest10 failed"); + throw new Exception("propertyTypeTest10 failed"); } /* @@ -642,7 +641,7 @@ public void propertyTypeTest10() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: java.sql.Time */ - +@Test public void propertyTypeTest11() throws Exception { boolean pass = false; @@ -687,7 +686,7 @@ public void propertyTypeTest11() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest11 failed"); + throw new Exception("propertyTypeTest11 failed"); } /* @@ -699,7 +698,7 @@ public void propertyTypeTest11() throws Exception { * @test_Strategy: The persistent property of an entity may be of the * following type: java.sql.Timestamp */ - +@Test public void propertyTypeTest12() throws Exception { boolean pass = false; @@ -745,7 +744,7 @@ public void propertyTypeTest12() throws Exception { } if (!pass) - throw new Fault("propertyTypeTest12 failed"); + throw new Exception("propertyTypeTest12 failed"); } /* @@ -756,6 +755,7 @@ public void propertyTypeTest12() throws Exception { * @test_Strategy: Test various scalar expressions test * */ +@Test public void scalarExpressionsTest() throws Exception { boolean pass1, pass2, pass3, pass4, pass5; pass1 = pass2 = pass3 = pass4 = pass5 = false; @@ -908,7 +908,7 @@ public void scalarExpressionsTest() throws Exception { } if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5) - throw new Fault("scalarExpressionsTest failed"); + throw new Exception("scalarExpressionsTest failed"); } /* @@ -920,6 +920,7 @@ public void scalarExpressionsTest() throws Exception { */ @SetupMethod(name = "setupCust") @CleanupMethod(name = "cleanupCust") + @Test public void elementCollectionTest() throws Exception { boolean pass = false; try { @@ -972,7 +973,7 @@ public void elementCollectionTest() throws Exception { pass = false; } if (!pass) { - throw new Fault("elementCollectionTest failed"); + throw new Exception("elementCollectionTest failed"); } } @@ -1012,6 +1013,7 @@ public void createTestData() { } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -1019,6 +1021,7 @@ public void cleanup() throws Exception { super.cleanup(); } + @AfterEach public void cleanupCust() throws Exception { TestUtil.logTrace("cleanup"); removeCustTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/versioning/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/versioning/Client.java index 884764bc19..6d62ea0fd4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/versioning/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/versioning/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,9 +21,11 @@ package com.sun.ts.tests.jpa.core.versioning; import java.math.BigInteger; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,21 +34,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -65,7 +62,7 @@ public void setup(String[] args, Properties p) throws Exception { * positive test with sequential tx * */ - +@Test public void versionTest1() throws Exception { TestUtil.logTrace("Begin versionTest1"); @@ -147,9 +144,10 @@ public void versionTest1() throws Exception { } if (!pass1 || !pass2 || !pass3) - throw new Fault("versionTest1 failed"); + throw new Exception("versionTest1 failed"); } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManager/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManager/Client.java index 83c870d2db..d083b1f3ec 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManager/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManager/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,7 +20,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -37,27 +40,22 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); @@ -71,6 +69,7 @@ public void cleanup() throws Exception { * * @test_Strategy: Create an EntityManagerFactory via SynchronizationType,Map */ + @Test public void createEntityManagerSynchronizationTypeMapTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -101,7 +100,7 @@ public void createEntityManagerSynchronizationTypeMapTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass1 || !pass2) { - throw new Fault("createEntityManagerSynchronizationTypeMapTest failed"); + throw new Exception("createEntityManagerSynchronizationTypeMapTest failed"); } } @@ -112,6 +111,7 @@ public void createEntityManagerSynchronizationTypeMapTest() throws Exception { * * @test_Strategy: Create an EntityManagerFactory via SynchronizationType */ + @Test public void createEntityManagerSynchronizationTypeTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -142,7 +142,7 @@ public void createEntityManagerSynchronizationTypeTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass1 || !pass2) { - throw new Fault("createEntityManagerSynchronizationTypeTest failed"); + throw new Exception("createEntityManagerSynchronizationTypeTest failed"); } } @@ -154,6 +154,7 @@ public void createEntityManagerSynchronizationTypeTest() throws Exception { * @test_Strategy: Call EntityManager.joinTransaction() method when no * transaction exists */ + @Test public void joinTransactionTransactionRequiredExceptionTest() throws Exception { boolean pass = false; try { @@ -168,7 +169,7 @@ public void joinTransactionTransactionRequiredExceptionTest() throws Exception { } if (!pass) { - throw new Fault("joinTransactionTransactionRequiredExceptionTest failed"); + throw new Exception("joinTransactionTransactionRequiredExceptionTest failed"); } } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManagerFactory/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManagerFactory/Client.java index 37add03cbf..c946ec579f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManagerFactory/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/entityManagerFactory/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,7 +18,10 @@ import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -35,40 +38,37 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - com.sun.ts.tests.jpa.core.entityManagerFactory.Client theTests = new com.sun.ts.tests.jpa.core.entityManagerFactory.Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - + @BeforeEach public void setupNoData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupNoData"); this.props = p; try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createOrderTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanupNoData() throws Exception { super.cleanup(); } + @AfterEach public void cleanup() throws Exception { removeTestData(); TestUtil.logTrace("done cleanup, calling super.cleanup"); @@ -87,6 +87,7 @@ public void cleanup() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoData") + @Test public void createEntityManagerFactoryStringTest() throws Exception { boolean pass = false; @@ -103,7 +104,7 @@ public void createEntityManagerFactoryStringTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("createEntityManagerFactoryStringTest failed"); + throw new Exception("createEntityManagerFactoryStringTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/annotation/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/annotation/Client.java index 1c2113c2d2..2df8a50e09 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/annotation/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/annotation/Client.java @@ -20,10 +20,10 @@ package com.sun.ts.tests.jpa.ee.packaging.appclient.annotation; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; import com.sun.ts.lib.util.TestUtil; import jakarta.persistence.EntityManager; @@ -31,7 +31,7 @@ import jakarta.persistence.EntityTransaction; import jakarta.persistence.PersistenceUnit; -public class Client extends EETest { +public class Client { private static final Coffee cRef[] = new Coffee[5]; @@ -42,37 +42,33 @@ public class Client extends EETest { private EntityTransaction et; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - public void setup(final String[] args, final Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { try { if (emf != null) { em = emf.createEntityManager(); } else { TestUtil.logErr("EMF is null"); - throw new Fault("Setup Failed!"); + throw new Exception("Setup Failed!"); } if (em != null) { et = em.getTransaction(); } else { TestUtil.logErr("EM is null"); - throw new Fault("Setup Failed!"); + throw new Exception("Setup Failed!"); } if (et == null) { TestUtil.logErr("ET is null"); - throw new Fault("Setup Failed!"); + throw new Exception("Setup Failed!"); } removeTestData(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } @@ -99,7 +95,7 @@ public void setup(final String[] args, final Properties p) throws Exception { * Create entities, persist them, then find. * */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -156,10 +152,11 @@ public void test1() throws Exception { } } if (!pass) { - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/descriptor/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/descriptor/Client.java index 1be3361e24..3d3f1e1711 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/descriptor/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/appclient/descriptor/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -20,10 +20,9 @@ package com.sun.ts.tests.jpa.ee.packaging.appclient.descriptor; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; @@ -31,7 +30,7 @@ import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.EntityTransaction; -public class Client extends EETest { +public class Client { private static final Coffee cRef[] = new Coffee[5]; @@ -45,38 +44,33 @@ public class Client extends EETest { private static final String emfRef = "java:comp/env/persistence/MyPersistenceUnit"; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - - public void setup(final String[] args, final Properties p) throws Exception { +@AfterEach + public void setup() throws Exception { try { TestUtil.logTrace("Obtain naming context"); nctx = new TSNamingContext(); if (nctx == null) { TestUtil.logErr("NCTX is null"); - throw new Fault("Setup Failed!"); + throw new Exception("Setup Failed!"); } emf = (EntityManagerFactory) nctx.lookup(emfRef); if (emf != null) { em = emf.createEntityManager(); } else { TestUtil.logErr("EMF is null"); - throw new Fault("Setup Failed!"); + throw new Exception("Setup Failed!"); } if (em == null) { TestUtil.logErr("EM is null"); - throw new Fault("Setup Failed!"); + throw new Exception("Setup Failed!"); } removeTestData(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } @@ -109,7 +103,7 @@ public void setup(final String[] args, final Properties p) throws Exception { * Create entities, persist them, then find. * */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -179,9 +173,10 @@ public void test1() throws Exception { } } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/descriptor/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/descriptor/Client.java index e41fd74add..a54bf22ca4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/descriptor/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/descriptor/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,12 +22,13 @@ import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; -public class Client extends EETest { +public class Client { public static final String StatefulRef = "java:comp/env/ejb/Stateful3Bean"; @@ -39,17 +40,13 @@ public class Client extends EETest { private Properties props; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - public void setup(final String[] args, final Properties p) throws Exception { + @AfterEach + public void setup() throws Exception { try { TSNamingContext nctx = new TSNamingContext(); TestUtil.logTrace("Look up bean: " + StatefulRef); @@ -58,11 +55,9 @@ public void setup(final String[] args, final Properties p) throws Exception { TestUtil.logTrace("Look up bean: " + StatelessRef); bean1 = (Stateless3IF) nctx.lookup(StatelessRef); - props = p; - cleanup(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } @@ -84,7 +79,7 @@ public void setup(final String[] args, final Properties p) throws Exception { * persist, then find. * */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -101,7 +96,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -126,7 +121,7 @@ public void test1() throws Exception { * context. * */ - +@Test public void test2() throws Exception { TestUtil.logTrace("Begin test2"); @@ -143,7 +138,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } /* @@ -163,7 +158,7 @@ public void test2() throws Exception { * IllegalStateException is thrown. * */ - +@Test public void test3() throws Exception { TestUtil.logTrace("Begin test3"); @@ -180,7 +175,7 @@ public void test3() throws Exception { } if (!pass) - throw new Fault("test3 failed"); + throw new Exception("test3 failed"); } /* @@ -203,7 +198,7 @@ public void test3() throws Exception { * getTransaction() and ensure IllegalStateException is thrown. * */ - +@Test public void test4() throws Exception { TestUtil.logTrace("Begin test4"); @@ -220,7 +215,7 @@ public void test4() throws Exception { } if (!pass) - throw new Fault("test4 failed"); + throw new Exception("test4 failed"); } /* @@ -232,7 +227,7 @@ public void test4() throws Exception { * Application-Managed Entity Manager. * */ - +@Test public void test5() throws Exception { TestUtil.logTrace("Begin test5"); @@ -249,7 +244,7 @@ public void test5() throws Exception { } if (!pass) - throw new Fault("test5 failed"); + throw new Exception("test5 failed"); } /* @@ -262,7 +257,7 @@ public void test5() throws Exception { * file is automatically loaded into the persistence unit. * */ - +@Test public void test6() throws Exception { TestUtil.logTrace("Begin test6"); @@ -279,9 +274,10 @@ public void test6() throws Exception { } if (!pass) - throw new Fault("test6 failed"); + throw new Exception("test6 failed"); } +@AfterEach public void cleanup() throws Exception { try { bean.removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/exclude/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/exclude/Client.java index 57eb31e00e..05c180f6a4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/exclude/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/exclude/Client.java @@ -22,35 +22,28 @@ import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import jakarta.ejb.EJB; -public class Client extends EETest { +public class Client { @EJB(beanName = "Stateful3Bean") private static Stateful3IF bean; private Properties props; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - - public void setup(String[] args, Properties p) throws Exception { - try { - props = p; - } catch (Exception e) { - throw new Fault("Setup Failed!", e); - } +@BeforeEach + public void setup() throws Exception { + } /* @@ -95,7 +88,7 @@ public void setup(String[] args, Properties p) throws Exception { * and modified. * */ - +@Test public void test1() throws Exception { // TODO need to add converter classes boolean pass = false; @@ -110,7 +103,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -134,7 +127,7 @@ public void test1() throws Exception { * "is not an entity". * */ - +@Test public void test2() throws Exception { boolean pass = false; @@ -146,9 +139,10 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } +@AfterEach public void cleanup() throws Exception { try { bean.removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/resource_local/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/resource_local/Client.java index d34dd6416e..50efb5d78f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/resource_local/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/resource_local/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,12 +22,14 @@ import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TSNamingContext; import com.sun.ts.lib.util.TestUtil; -public class Client extends EETest { +public class Client { private Stateless3IF bean = null; @@ -35,25 +37,20 @@ public class Client extends EETest { public static final String MyStateless3Bean = "java:comp/env/ejb/Stateless3Bean"; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { try { - props = p; TSNamingContext nctx = new TSNamingContext(); bean = (Stateless3IF) nctx.lookup(MyStateless3Bean); TestUtil.logTrace("Looked up Bean: " + bean); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } @@ -87,7 +84,7 @@ public void setup(String[] args, Properties p) throws Exception { * * begin() starts a resource_transaction */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -102,7 +99,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -114,7 +111,7 @@ public void test1() throws Exception { * * begin() throws an IllegalStateException if isActive() is true */ - +@Test public void test2() throws Exception { TestUtil.logTrace("Begin test2"); @@ -129,7 +126,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } /* @@ -141,7 +138,7 @@ public void test2() throws Exception { * * commit() commits the current transaction */ - +@Test public void test3() throws Exception { TestUtil.logTrace("Begin test3"); @@ -156,7 +153,7 @@ public void test3() throws Exception { } if (!pass) - throw new Fault("test3 failed"); + throw new Exception("test3 failed"); } /* @@ -168,7 +165,7 @@ public void test3() throws Exception { * * commit() throws an IllegalStateException if isActive() is false */ - +@Test public void test4() throws Exception { TestUtil.logTrace("Begin test4"); @@ -183,7 +180,7 @@ public void test4() throws Exception { } if (!pass) - throw new Fault("test4 failed"); + throw new Exception("test4 failed"); } /* @@ -196,7 +193,7 @@ public void test4() throws Exception { * * commit() throws a RollbackException if commit fails */ - +@Test public void test5() throws Exception { TestUtil.logTrace("Begin test5"); @@ -211,7 +208,7 @@ public void test5() throws Exception { } if (!pass) - throw new Fault("test5 failed"); + throw new Exception("test5 failed"); } /* @@ -223,7 +220,7 @@ public void test5() throws Exception { * * rollback() rolls back the current transaction */ - +@Test public void test6() throws Exception { TestUtil.logTrace("Begin test6"); @@ -238,7 +235,7 @@ public void test6() throws Exception { } if (!pass) - throw new Fault("test6 failed"); + throw new Exception("test6 failed"); } /* @@ -251,7 +248,7 @@ public void test6() throws Exception { * setRollbackOnly() marks the current transaction so the only outcome is for * the transaction to be rolled back */ - +@Test public void test7() throws Exception { TestUtil.logTrace("Begin test7"); @@ -266,7 +263,7 @@ public void test7() throws Exception { } if (!pass) - throw new Fault("test7 failed"); + throw new Exception("test7 failed"); } /* @@ -278,7 +275,7 @@ public void test7() throws Exception { * * setRollbackOnly throws IllegalStateException if isActive() is false */ - +@Test public void test8() throws Exception { TestUtil.logTrace("Begin test8"); @@ -293,7 +290,7 @@ public void test8() throws Exception { } if (!pass) - throw new Fault("test8 failed"); + throw new Exception("test8 failed"); } /* @@ -307,7 +304,7 @@ public void test8() throws Exception { * rollback test getRollbackOnly when isActive() is true and TX has been * marked for rollback, so getRollbackOnly will return true */ - +@Test public void test9() throws Exception { TestUtil.logTrace("Begin test9"); @@ -322,7 +319,7 @@ public void test9() throws Exception { } if (!pass) - throw new Fault("test9 failed"); + throw new Exception("test9 failed"); } /* @@ -334,7 +331,7 @@ public void test9() throws Exception { * * getRollbackOnly throws IllegalStateException if isActive() is false */ - +@Test public void test10() throws Exception { TestUtil.logTrace("Begin test10"); @@ -349,7 +346,7 @@ public void test10() throws Exception { } if (!pass) - throw new Fault("test10 failed"); + throw new Exception("test10 failed"); } /* @@ -362,7 +359,7 @@ public void test10() throws Exception { * getRollbackOnly will return false * */ - +@Test public void test11() throws Exception { TestUtil.logTrace("Begin test11"); @@ -377,7 +374,7 @@ public void test11() throws Exception { } if (!pass) - throw new Fault("test11 failed"); + throw new Exception("test11 failed"); } /* @@ -391,7 +388,7 @@ public void test11() throws Exception { * isActive() indicates whether a transaction is in progress Try when TX is * active */ - +@Test public void test12() throws Exception { TestUtil.logTrace("Begin test12"); @@ -406,7 +403,7 @@ public void test12() throws Exception { } if (!pass) - throw new Fault("test12 failed"); + throw new Exception("test12 failed"); } /* @@ -419,7 +416,7 @@ public void test12() throws Exception { * isActive() indicates whether a transaction is in progress Try when TX is * not active */ - +@Test public void test13() throws Exception { TestUtil.logTrace("Begin test13"); @@ -434,7 +431,7 @@ public void test13() throws Exception { } if (!pass) - throw new Fault("test13 failed"); + throw new Exception("test13 failed"); } /* @@ -449,7 +446,7 @@ public void test13() throws Exception { * runtime throws an exception defined to cause a transaction rollback, it * must mark the transaction for rollback. */ - +@Test public void test14() throws Exception { TestUtil.logTrace("Begin test14"); @@ -464,7 +461,7 @@ public void test14() throws Exception { } if (!pass) - throw new Fault("test14 failed"); + throw new Exception("test14 failed"); } /* @@ -479,7 +476,7 @@ public void test14() throws Exception { * * */ - +@Test public void test15() throws Exception { TestUtil.logTrace("Begin test15"); @@ -494,9 +491,10 @@ public void test15() throws Exception { } if (!pass) - throw new Fault("test15 failed"); + throw new Exception("test15 failed"); } +@AfterEach public void cleanup() throws Exception { try { bean.removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/standalone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/standalone/Client.java index 122cc186be..3b7deee36f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/standalone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/ejb/standalone/Client.java @@ -22,36 +22,31 @@ import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import jakarta.ejb.EJB; -public class Client extends EETest { +public class Client { @EJB(name = "ejb/Stateful3Bean", beanInterface = Stateful3IF.class) private static Stateful3IF bean; private Properties props; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - - public void setup(String[] args, Properties p) throws Exception { +@AfterEach + public void setup() throws Exception { try { - props = p; bean.init(props); cleanup(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } @@ -83,7 +78,7 @@ public void setup(String[] args, Properties p) throws Exception { * content. Create entities, persist them, then find. * */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -98,9 +93,9 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } - +@AfterEach public void cleanup() throws Exception { try { bean.removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/jar/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/jar/Client.java index b1f4d3c6c9..235b04861e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/jar/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/jar/Client.java @@ -16,9 +16,9 @@ package com.sun.ts.tests.jpa.ee.packaging.jar; -import java.util.Properties; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -27,24 +27,19 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -57,7 +52,7 @@ public void setup(String[] args, Properties p) throws Exception { * entities persist, then find. * */ - +@Test public void JarFileElementsTest() throws Exception { boolean pass = true; final int count = 2; @@ -109,10 +104,11 @@ public void JarFileElementsTest() throws Exception { } } if (!pass) { - throw new Fault("JarFileElementsTest failed"); + throw new Exception("JarFileElementsTest failed"); } } +@BeforeEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/scope/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/scope/Client.java index 4746589e69..fae500777e 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/scope/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/scope/Client.java @@ -20,9 +20,8 @@ package com.sun.ts.tests.jpa.ee.packaging.web.scope; -import java.io.PrintWriter; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.tests.jpa.ee.util.AbstractUrlClient; public class Client extends AbstractUrlClient { @@ -31,30 +30,9 @@ public class Client extends AbstractUrlClient { public static final String CONTEXT_ROOT = "/jpa_ee_packaging_web_scope"; - /** - * Entry point for different-VM execution. It should delegate to method - * run(String[], PrintWriter, PrintWriter), and this method should not contain - * any test configuration. - */ - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, new PrintWriter(System.out), - new PrintWriter(System.err)); - s.exit(); - } - - /** - * Entry point for same-VM execution. In different-VM execution, the main - * method delegates to this method. - */ - public Status run(String args[], PrintWriter out, PrintWriter err) { - setServletName(SERVLET_NAME); - setContextRoot(CONTEXT_ROOT); - return super.run(args, out, err); - } /* - * @class.setup_props: webServerHost; webServerPort; ts_home; + * @class.setup_props: webServerHost; webServerPort; */ /* @@ -74,7 +52,7 @@ public Status run(String args[], PrintWriter out, PrintWriter err) { * Client -> SERVLET -> ENTITY -> DB * */ - +@Test public void test1() throws Exception { TEST_PROPS.setProperty(APITEST, "test1"); invoke(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/standalone/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/standalone/Client.java index 4a5ca46267..03fa430135 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/standalone/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/packaging/web/standalone/Client.java @@ -20,9 +20,8 @@ package com.sun.ts.tests.jpa.ee.packaging.web.standalone; -import java.io.PrintWriter; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.tests.jpa.ee.util.AbstractUrlClient; public class Client extends AbstractUrlClient { @@ -31,30 +30,9 @@ public class Client extends AbstractUrlClient { public static final String CONTEXT_ROOT = "/jpa_ee_packaging_web_standalone"; - /** - * Entry point for different-VM execution. It should delegate to method - * run(String[], PrintWriter, PrintWriter), and this method should not contain - * any test configuration. - */ - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, new PrintWriter(System.out), - new PrintWriter(System.err)); - s.exit(); - } - - /** - * Entry point for same-VM execution. In different-VM execution, the main - * method delegates to this method. - */ - public Status run(String args[], PrintWriter out, PrintWriter err) { - setServletName(SERVLET_NAME); - setContextRoot(CONTEXT_ROOT); - return super.run(args, out, err); - } /* - * @class.setup_props: webServerHost; webServerPort; ts_home; + * @class.setup_props: webServerHost; webServerPort; */ /* @@ -78,7 +56,7 @@ public Status run(String args[], PrintWriter out, PrintWriter err) { * Client -> SERVLET -> ENTITY -> DB * */ - +@Test public void test1() throws Exception { TEST_PROPS.setProperty(APITEST, "test1"); invoke(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/jta/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/jta/Client.java index 9a7ceefb9d..fe2edb3077 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/jta/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/jta/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.common.pluggability.altprovider.implementation.EntityManagerFactoryImpl; @@ -51,25 +54,21 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: log.file.location; */ - public void setup(String[] args, Properties props) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - super.setup(args, props); - logProcessor = new LogFileProcessor(props); + super.setup(); + logProcessor = new LogFileProcessor(); if (logProcessor.fetchLog()) { currentSeqNum = logProcessor.getCurrentSequenceNumber(); getEntityManager(); } else { - throw new Fault("Could not fetch log file"); + throw new Exception("Could not fetch log file"); } } @@ -81,13 +80,14 @@ public void setup(String[] args, Properties props) throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void createEMF() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called createContainerEntityManagerFactory(PersistenceUnitInfo, Map)" }; logProcessor.fetchLog(); boolean pass = logProcessor.verifyLogContains(expected); if (!pass) { - throw new Fault("createEMF failed"); + throw new Exception("createEMF failed"); } } @@ -98,6 +98,7 @@ public void createEMF() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceProviderClassName() throws Exception { boolean pass1 = false; @@ -118,7 +119,7 @@ public void getPersistenceProviderClassName() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceProviderClassName failed"); + throw new Exception("getPersistenceProviderClassName failed"); } } @@ -129,6 +130,7 @@ public void getPersistenceProviderClassName() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceUnitNameTest() throws Exception { boolean pass1 = false; @@ -159,7 +161,7 @@ public void getPersistenceUnitNameTest() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceUnitNameTest failed"); + throw new Exception("getPersistenceUnitNameTest failed"); } } @@ -170,6 +172,7 @@ public void getPersistenceUnitNameTest() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getTransactionType() throws Exception { boolean pass1 = false; @@ -193,7 +196,7 @@ public void getTransactionType() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getTransactionType failed"); + throw new Exception("getTransactionType failed"); } } @@ -204,6 +207,7 @@ public void getTransactionType() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getManagedClassNames() throws Exception { boolean pass1 = false; List expected = new ArrayList(); @@ -235,7 +239,7 @@ public void getManagedClassNames() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected1, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getManagedClassNames failed"); + throw new Exception("getManagedClassNames failed"); } } @@ -246,6 +250,7 @@ public void getManagedClassNames() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getJarFileUrls() throws Exception { boolean pass1 = false; @@ -275,7 +280,7 @@ public void getJarFileUrls() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getJarFileUrls failed"); + throw new Exception("getJarFileUrls failed"); } } @@ -285,6 +290,7 @@ public void getJarFileUrls() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceUnitRootUrl() throws Exception { boolean pass1 = false; @@ -306,7 +312,7 @@ public void getPersistenceUnitRootUrl() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceUnitRootUrl failed"); + throw new Exception("getPersistenceUnitRootUrl failed"); } } @@ -316,6 +322,7 @@ public void getPersistenceUnitRootUrl() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceXMLSchemaVersion() throws Exception { boolean pass1 = false; @@ -337,7 +344,7 @@ public void getPersistenceXMLSchemaVersion() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceXMLSchemaVersion failed"); + throw new Exception("getPersistenceXMLSchemaVersion failed"); } } @@ -347,6 +354,7 @@ public void getPersistenceXMLSchemaVersion() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getProperties() throws Exception { boolean pass1 = true; @@ -399,7 +407,7 @@ public void getProperties() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getProperties failed"); + throw new Exception("getProperties failed"); } } @@ -409,6 +417,7 @@ public void getProperties() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getSharedCacheMode() throws Exception { boolean pass1 = false; @@ -430,7 +439,7 @@ public void getSharedCacheMode() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getSharedCacheMode failed"); + throw new Exception("getSharedCacheMode failed"); } } @@ -440,6 +449,7 @@ public void getSharedCacheMode() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getValidationMode() throws Exception { boolean pass1 = false; @@ -460,7 +470,7 @@ public void getValidationMode() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getValidationMode failed"); + throw new Exception("getValidationMode failed"); } } @@ -470,6 +480,7 @@ public void getValidationMode() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getClassLoader() throws Exception { boolean pass1 = false; getClassObjects(); @@ -489,7 +500,7 @@ public void getClassLoader() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getClassLoader failed"); + throw new Exception("getClassLoader failed"); } } @@ -499,6 +510,7 @@ public void getClassLoader() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getNewTempClassLoader() throws Exception { boolean pass1 = false; getClassObjects(); @@ -518,7 +530,7 @@ public void getNewTempClassLoader() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getNewTempClassLoader failed"); + throw new Exception("getNewTempClassLoader failed"); } } @@ -528,6 +540,7 @@ public void getNewTempClassLoader() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getMappingFileNames() throws Exception { boolean pass1 = false; List expected = new ArrayList(); @@ -563,7 +576,7 @@ public void getMappingFileNames() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected1, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getMappingFileNames failed"); + throw new Exception("getMappingFileNames failed"); } } @@ -573,6 +586,7 @@ public void getMappingFileNames() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getJtaDataSource() throws Exception { boolean pass1 = false; @@ -591,7 +605,7 @@ public void getJtaDataSource() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getJtaDataSource failed"); + throw new Exception("getJtaDataSource failed"); } } @@ -601,6 +615,7 @@ public void getJtaDataSource() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void excludeUnlistedClasses() throws Exception { boolean pass1 = false; @@ -619,7 +634,7 @@ public void excludeUnlistedClasses() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("excludeUnlistedClasses failed"); + throw new Exception("excludeUnlistedClasses failed"); } } @@ -629,6 +644,7 @@ public void excludeUnlistedClasses() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getProviderUtil() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called getProviderUtil()" }; @@ -637,7 +653,7 @@ public void getProviderUtil() throws Exception { logProcessor.fetchLog(); boolean pass = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass) { - throw new Fault("getProviderUtil failed"); + throw new Exception("getProviderUtil failed"); } } @@ -647,6 +663,7 @@ public void getProviderUtil() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void isLoaded() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called isLoaded()" }; @@ -656,7 +673,7 @@ public void isLoaded() throws Exception { boolean pass = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass) { - throw new Fault("isLoaded failed"); + throw new Exception("isLoaded failed"); } } @@ -668,6 +685,7 @@ public void getClassObjects() { puInfo = emfImpl.puInfo; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); TestUtil.logTrace("calling super.cleanup"); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/resource_local/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/resource_local/Client.java index c9e729e458..85081e3c90 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/resource_local/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/pluggability/contracts/resource_local/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.common.pluggability.altprovider.implementation.EntityManagerFactoryImpl; @@ -51,25 +54,21 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: log.file.location; */ - public void setup(String[] args, Properties props) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - super.setup(args, props); - logProcessor = new LogFileProcessor(props); + super.setup(); + logProcessor = new LogFileProcessor(); if (logProcessor.fetchLog()) { currentSeqNum = logProcessor.getCurrentSequenceNumber(); getEntityManager(); } else { - throw new Fault("Could not fetch log file"); + throw new Exception("Could not fetch log file"); } } @@ -80,13 +79,14 @@ public void setup(String[] args, Properties props) throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void createEMF() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called createContainerEntityManagerFactory(PersistenceUnitInfo, Map)" }; logProcessor.fetchLog(); boolean pass = logProcessor.verifyLogContains(expected); if (!pass) { - throw new Fault("createEMF failed"); + throw new Exception("createEMF failed"); } } @@ -97,6 +97,7 @@ public void createEMF() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceProviderClassName() throws Exception { boolean pass1 = false; @@ -117,7 +118,7 @@ public void getPersistenceProviderClassName() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceProviderClassName failed"); + throw new Exception("getPersistenceProviderClassName failed"); } } @@ -128,6 +129,7 @@ public void getPersistenceProviderClassName() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceUnitNameTest() throws Exception { boolean pass1 = false; @@ -156,7 +158,7 @@ public void getPersistenceUnitNameTest() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceUnitNameTest failed"); + throw new Exception("getPersistenceUnitNameTest failed"); } } @@ -167,6 +169,7 @@ public void getPersistenceUnitNameTest() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getTransactionType() throws Exception { boolean pass1 = false; @@ -190,7 +193,7 @@ public void getTransactionType() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getTransactionType failed"); + throw new Exception("getTransactionType failed"); } } @@ -201,6 +204,7 @@ public void getTransactionType() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getManagedClassNames() throws Exception { boolean pass1 = false; List expected = new ArrayList(); @@ -233,7 +237,7 @@ public void getManagedClassNames() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected1, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getManagedClassNames failed"); + throw new Exception("getManagedClassNames failed"); } } @@ -244,6 +248,7 @@ public void getManagedClassNames() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getJarFileUrls() throws Exception { boolean pass1 = false; @@ -273,7 +278,7 @@ public void getJarFileUrls() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getJarFileUrls failed"); + throw new Exception("getJarFileUrls failed"); } } @@ -283,6 +288,7 @@ public void getJarFileUrls() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceUnitRootUrl() throws Exception { boolean pass1 = false; @@ -304,7 +310,7 @@ public void getPersistenceUnitRootUrl() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceUnitRootUrl failed"); + throw new Exception("getPersistenceUnitRootUrl failed"); } } @@ -314,6 +320,7 @@ public void getPersistenceUnitRootUrl() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceXMLSchemaVersion() throws Exception { boolean pass1 = false; @@ -335,7 +342,7 @@ public void getPersistenceXMLSchemaVersion() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getPersistenceXMLSchemaVersion failed"); + throw new Exception("getPersistenceXMLSchemaVersion failed"); } } @@ -345,6 +352,7 @@ public void getPersistenceXMLSchemaVersion() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getProperties() throws Exception { boolean pass1 = true; @@ -396,7 +404,7 @@ public void getProperties() throws Exception { // verify log does NOT contain the string boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getProperties failed"); + throw new Exception("getProperties failed"); } } @@ -406,6 +414,7 @@ public void getProperties() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getSharedCacheMode() throws Exception { boolean pass1 = false; @@ -427,7 +436,7 @@ public void getSharedCacheMode() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getSharedCacheMode failed"); + throw new Exception("getSharedCacheMode failed"); } } @@ -437,6 +446,7 @@ public void getSharedCacheMode() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getValidationMode() throws Exception { boolean pass1 = false; @@ -457,7 +467,7 @@ public void getValidationMode() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getValidationMode failed"); + throw new Exception("getValidationMode failed"); } } @@ -467,6 +477,7 @@ public void getValidationMode() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getClassLoader() throws Exception { boolean pass1 = false; getClassObjects(); @@ -486,7 +497,7 @@ public void getClassLoader() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getClassLoader failed"); + throw new Exception("getClassLoader failed"); } } @@ -496,6 +507,7 @@ public void getClassLoader() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getNewTempClassLoader() throws Exception { boolean pass1 = false; getClassObjects(); @@ -515,7 +527,7 @@ public void getNewTempClassLoader() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getNewTempClassLoader failed"); + throw new Exception("getNewTempClassLoader failed"); } } @@ -525,6 +537,7 @@ public void getNewTempClassLoader() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getMappingFileNames() throws Exception { boolean pass1 = false; List expected = new ArrayList(); @@ -560,7 +573,7 @@ public void getMappingFileNames() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected1, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getMappingFileNames failed"); + throw new Exception("getMappingFileNames failed"); } } @@ -570,6 +583,7 @@ public void getMappingFileNames() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getNonJtaDataSource() throws Exception { boolean pass1 = false; String expected[] = { LOGMESSAGE_PREFIX @@ -586,7 +600,7 @@ public void getNonJtaDataSource() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("getNonJtaDataSource failed"); + throw new Exception("getNonJtaDataSource failed"); } } @@ -596,6 +610,7 @@ public void getNonJtaDataSource() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void excludeUnlistedClasses() throws Exception { boolean pass1 = false; @@ -614,7 +629,7 @@ public void excludeUnlistedClasses() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass1 || pass2) { - throw new Fault("excludeUnlistedClasses failed"); + throw new Exception("excludeUnlistedClasses failed"); } } @@ -624,6 +639,7 @@ public void excludeUnlistedClasses() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getProviderUtil() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called getProviderUtil()" }; @@ -633,7 +649,7 @@ public void getProviderUtil() throws Exception { boolean pass = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass) { - throw new Fault("getProviderUtil failed"); + throw new Exception("getProviderUtil failed"); } } @@ -643,6 +659,7 @@ public void getProviderUtil() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void isLoaded() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called isLoaded()" }; @@ -652,7 +669,7 @@ public void isLoaded() throws Exception { boolean pass = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass) { - throw new Fault("isLoaded failed"); + throw new Exception("isLoaded failed"); } } @@ -662,6 +679,7 @@ public void isLoaded() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void isLoadedWithoutReference() throws Exception { String expected[] = { @@ -673,7 +691,7 @@ public void isLoadedWithoutReference() throws Exception { boolean pass = logProcessor.verifyLogContains(expected, currentSeqNum); if (!pass) { - throw new Fault("isLoadedWithoutReference failed"); + throw new Exception("isLoadedWithoutReference failed"); } } @@ -684,6 +702,7 @@ public void getClassObjects() { puInfo = emfImpl.puInfo; } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); TestUtil.logTrace("calling super.cleanup"); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/am/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/am/Client.java index 969d36bc66..2ba703ba81 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/am/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/am/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,13 +22,15 @@ import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import jakarta.ejb.EJB; -public class Client extends EETest { +public class Client { @EJB(name = "ejb/Stateful3Bean", beanInterface = Stateful3IF.class) private static Stateful3IF statefulBean; @@ -41,22 +43,13 @@ public class Client extends EETest { private Properties props; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - public void setup(String[] args, Properties p) throws Exception { - try { - props = p; - } catch (Exception e) { - throw new Fault("Setup Failed!", e); - } + @BeforeEach + public void setup() throws Exception { } /* @@ -76,7 +69,7 @@ public void setup(String[] args, Properties p) throws Exception { * Inject entity manager factory, but open and close each entity manager * within the business method. */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -94,7 +87,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -112,7 +105,7 @@ public void test1() throws Exception { * within the business method. * */ - +@Test public void test2() throws Exception { TestUtil.logTrace("Begin test2"); @@ -129,7 +122,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } /* @@ -144,7 +137,7 @@ public void test2() throws Exception { * merged is a stale copy of the entity. * */ - +@Test public void test3() throws Exception { TestUtil.logTrace("Begin test3"); @@ -159,7 +152,7 @@ public void test3() throws Exception { } if (!pass) - throw new Fault("test3 failed"); + throw new Exception("test3 failed"); } /* @@ -179,7 +172,7 @@ public void test3() throws Exception { * Remove annotation. * */ - +@Test public void test4() throws Exception { TestUtil.logTrace("Begin test4"); @@ -194,7 +187,7 @@ public void test4() throws Exception { } if (!pass) - throw new Fault("test4 failed"); + throw new Exception("test4 failed"); } /* @@ -205,7 +198,7 @@ public void test4() throws Exception { * @test_Strategy: Test the @PersistenceUnits and verify that a managed entity * from one PU is not accessible in the other PU and visa versa. */ - +@Test public void test5() throws Exception { boolean pass = false; @@ -219,9 +212,10 @@ public void test5() throws Exception { } if (!pass) - throw new Fault("test5 failed"); + throw new Exception("test5 failed"); } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete"); } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/extended/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/extended/Client.java index 72bc528cf1..5a6aa509f4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/extended/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/extended/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,35 +22,27 @@ import java.util.Properties; -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.EETest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import jakarta.ejb.EJB; -public class Client extends EETest { +public class Client { @EJB(name = "ejb/Stateful3Bean", beanInterface = Stateful3IF.class) private static Stateful3IF bean; private Properties props; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: */ - - public void setup(String[] args, Properties p) throws Exception { - try { - props = p; - } catch (Exception e) { - throw new Fault("Setup Failed!", e); - } +@BeforeEach + public void setup() throws Exception { } /* @@ -67,7 +59,7 @@ public void setup(String[] args, Properties p) throws Exception { * with extended persistence context and call local business method to create * entities. Find entity after persist. */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -83,7 +75,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -98,7 +90,7 @@ public void test1() throws Exception { * entitymanager and ensure the IllegalStateException is thrown. * */ - +@Test public void test2() throws Exception { TestUtil.logTrace("Begin test2"); @@ -114,7 +106,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } /* @@ -136,7 +128,7 @@ public void test2() throws Exception { * Once created verify that the entity is identical when finding in first bean * or from second bean. */ - +@Test public void test3() throws Exception { TestUtil.logTrace("Begin test3"); @@ -151,7 +143,7 @@ public void test3() throws Exception { } if (!pass) - throw new Fault("test3 failed"); + throw new Exception("test3 failed"); } /* @@ -172,7 +164,7 @@ public void test3() throws Exception { * of the transaction boundaries. * */ - +@Test public void test4() throws Exception { TestUtil.logTrace("Begin test4"); @@ -188,7 +180,7 @@ public void test4() throws Exception { } if (!pass) - throw new Fault("test4 failed"); + throw new Exception("test4 failed"); } /* @@ -205,7 +197,7 @@ public void test4() throws Exception { * visible to the current TX. * */ - +@Test public void test5() throws Exception { TestUtil.logTrace("Begin test5"); @@ -221,7 +213,7 @@ public void test5() throws Exception { } if (!pass) - throw new Fault("test5 failed"); + throw new Exception("test5 failed"); } /* @@ -244,7 +236,7 @@ public void test5() throws Exception { * appropriate behavior as defined above. * */ - +@Test public void test6() throws Exception { TestUtil.logTrace("Begin test6"); @@ -267,7 +259,7 @@ public void test6() throws Exception { } if (!pass) - throw new Fault("test6 failed"); + throw new Exception("test6 failed"); } /* @@ -283,7 +275,7 @@ public void test6() throws Exception { * * */ - +@Test public void test7() throws Exception { TestUtil.logTrace("Begin test7"); @@ -299,9 +291,10 @@ public void test7() throws Exception { } if (!pass) - throw new Fault("test7 failed"); + throw new Exception("test7 failed"); } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete"); } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/jta/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/jta/Client.java index 90ccbf0a71..330a6c3552 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/jta/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/ee/propagation/cm/jta/Client.java @@ -20,9 +20,8 @@ package com.sun.ts.tests.jpa.ee.propagation.cm.jta; -import java.io.PrintWriter; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.tests.jpa.ee.util.AbstractUrlClient; public class Client extends AbstractUrlClient { @@ -31,32 +30,8 @@ public class Client extends AbstractUrlClient { public static final String CONTEXT_ROOT = "/jpa_ee_propagation_cm_jta_web"; - /** - * Entry point for different-VM execution. It should delegate to method - * run(String[], PrintWriter, PrintWriter), and this method should not contain - * any test configuration. - */ - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, new PrintWriter(System.out), - new PrintWriter(System.err)); - s.exit(); - } - - /** - * Entry point for same-VM execution. In different-VM execution, the main - * method delegates to this method. - */ - - public Status run(String args[], PrintWriter out, PrintWriter err) { - setServletName(SERVLET_NAME); - setContextRoot(CONTEXT_ROOT); - return super.run(args, out, err); - } - /* - * @class.setup_props: webServerHost; webServerPort; ts_home; + * @class.setup_props: webServerHost; webServerPort; */ /* @@ -82,7 +57,7 @@ public Status run(String args[], PrintWriter out, PrintWriter err) { * From the stateful bean, find the Account entity and ensure the entities are * identical. */ - +@Test public void test1() throws Exception { TEST_PROPS.setProperty(APITEST, "test1"); invoke(); @@ -116,7 +91,7 @@ public void test1() throws Exception { * * @PersistenceContexts() annotation. */ - +@Test public void test1a() throws Exception { TEST_PROPS.setProperty(APITEST, "test1a"); invoke(); @@ -141,7 +116,7 @@ public void test1a() throws Exception { * Create account entities, modify the data, and ensure the updates are * available after transaction commit. */ - +@Test public void test2() throws Exception { TEST_PROPS.setProperty(APITEST, "test2"); invoke(); @@ -164,7 +139,7 @@ public void test2() throws Exception { * With a container-managed transaction-scoped persistence context, ensure the * appropriate behavior as defined above. */ - +@Test public void test3() throws Exception { TEST_PROPS.setProperty(APITEST, "test3"); invoke(); @@ -180,7 +155,7 @@ public void test3() throws Exception { * For JTA entity manager call getTransaction() and verify that * IllegalStateException is thrown */ - +@Test public void getTransactionIllegalStateException() throws Exception { TEST_PROPS.setProperty(APITEST, "getTransactionIllegalStateException"); invoke(); @@ -196,7 +171,7 @@ public void getTransactionIllegalStateException() throws Exception { * For JTA entity manager call close() and verify that IllegalStateException * is thrown */ - +@Test public void closeObjectTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, "closeObjectTransactionRequiredExceptionTest"); @@ -213,7 +188,7 @@ public void closeObjectTransactionRequiredExceptionTest() throws Exception { * For JTA entity manager call merge() and verify that * TransactionRequiredException is thrown */ - +@Test public void mergeObjectTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, "mergeObjectTransactionRequiredExceptionTest"); @@ -229,7 +204,7 @@ public void mergeObjectTransactionRequiredExceptionTest() throws Exception { * For JTA entity manager call persist() and verify that * TransactionRequiredException is thrown */ - +@Test public void persistObjectTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, "persistObjectTransactionRequiredExceptionTest"); @@ -246,7 +221,7 @@ public void persistObjectTransactionRequiredExceptionTest() throws Exception { * For JTA entity manager call refresh() and verify that * TransactionRequiredException is thrown */ - +@Test public void refreshObjectTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, "refreshObjectTransactionRequiredExceptionTest"); @@ -263,7 +238,7 @@ public void refreshObjectTransactionRequiredExceptionTest() throws Exception { * For JTA entity manager call refresh() and verify that * TransactionRequiredException is thrown */ - +@Test public void refreshObjectMapTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, "refreshObjectMapTransactionRequiredExceptionTest"); @@ -280,7 +255,7 @@ public void refreshObjectMapTransactionRequiredExceptionTest() throws Exception * For JTA entity manager call refresh() and verify that * TransactionRequiredException is thrown */ - +@Test public void refreshObjectLockModeTypeTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, @@ -297,7 +272,7 @@ public void refreshObjectLockModeTypeTransactionRequiredExceptionTest() * For JTA entity manager call refresh() and verify that * TransactionRequiredException is thrown */ - +@Test public void refreshObjectLockModeTypeMapTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, @@ -314,7 +289,7 @@ public void refreshObjectLockModeTypeMapTransactionRequiredExceptionTest() * For JTA entity manager call remove() and verify that * TransactionRequiredException is thrown */ - +@Test public void removeObjectTransactionRequiredExceptionTest() throws Exception { TEST_PROPS.setProperty(APITEST, "removeObjectTransactionRequiredExceptionTest"); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/datetime/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/datetime/Client.java index fc1758dfce..8663560bfe 100755 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/datetime/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/datetime/Client.java @@ -26,7 +26,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -43,17 +46,13 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } @Override - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logMsg("Setup: JPA 2.2 Java 8 date and time types test"); try { - super.setup(args, p); + super.setup(); Properties props = getPersistenceUnitProperties(); props.put("jakarta.persistence.schema-generation.database.action", @@ -64,15 +63,16 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg(" - executing persistence schema generation"); Persistence.generateSchema(getPersistenceUnitName(), props); clearEMAndEMF(); - } catch (Fault e) { + } catch (Exception e) { TestUtil.logErr("caught Exception: ", e); - throw new Fault(" ! JPA 2.2 Java 8 date and time types test setup failed", + throw new Exception(" ! JPA 2.2 Java 8 date and time types test setup failed", e); } verifySchema(); } @Override + @AfterEach public void cleanup() throws Exception { TestUtil.logMsg("Cleanup: JPA 2.2 Java 8 date and time types test"); Properties props = getPersistenceUnitProperties(); @@ -149,6 +149,7 @@ private static LocalDateTime initLocalDateTime() { * * @throws com.sun.ts.lib.harness.EETest.Fault when test failed */ + @Test public void dateTimeTest() throws Exception { TestUtil.logMsg("Test: JPA 2.2 Java 8 date and time types"); verifySchema(); @@ -223,7 +224,7 @@ public void dateTimeTest() throws Exception { "--------------------------------------------------------------------------------"); if (!(createResult && allFindResult && localDateResult && localTimeResult && localDateTimeResult && offsetTimeResult && offsetDateTimeResult)) { - throw new Fault( + throw new Exception( "dateTimeTest (JPA 2.2 Java 8 date and time types test) failed"); } } @@ -404,7 +405,7 @@ private void verifySchema() throws Exception { e.getId()); if (result == null) { TestUtil.logErr(" ! no entity was found"); - throw new Fault("dateTimeTest: Schema verification failed"); + throw new Exception("dateTimeTest: Schema verification failed"); } getEntityTransaction().begin(); result = getEntityManager().merge(result); @@ -415,7 +416,7 @@ private void verifySchema() throws Exception { if (getEntityTransaction().isActive()) { getEntityTransaction().rollback(); } - throw new Fault("dateTimeTest: Schema verification failed"); + throw new Exception("dateTimeTest: Schema verification failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/generators/tablegenerators/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/generators/tablegenerators/Client.java index 2f0ca46f83..20bebdc9c5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/generators/tablegenerators/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/generators/tablegenerators/Client.java @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.jpa22.generators.tablegenerators; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,22 +31,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -56,7 +52,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: use a generator specified on an entity */ - +@Test public void generatorOnEntityTest() throws Exception { boolean pass = false; @@ -80,7 +76,7 @@ public void generatorOnEntityTest() throws Exception { } if (!pass) - throw new Fault("generatorOnEntityTest failed"); + throw new Exception("generatorOnEntityTest failed"); } // Methods used for Tests @@ -100,7 +96,7 @@ public void createTestData() { TestUtil.logErr("Unexpected exception occurred", e); } } - +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/query/stream/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/query/stream/Client.java index 2468be6f6a..a32f5385c9 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/query/stream/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/query/stream/Client.java @@ -16,15 +16,21 @@ package com.sun.ts.tests.jpa.jpa22.query.stream; -import com.sun.javatest.Status; +import java.sql.Date; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; -import jakarta.persistence.*; -import java.sql.Date; - -import java.util.*; -import java.util.stream.Stream; +import jakarta.persistence.Query; +import jakarta.persistence.TypedQuery; public class Client extends PMClientBase { private static final long serialVersionUID = 22L; @@ -38,22 +44,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Unexpected Exception caught in Setup: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -69,6 +70,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: iterateStream */ +@Test public void getResultStreamTest() throws Exception { List expected = new LinkedList<>(); for (int i = 1; i != 22; i++) @@ -85,7 +87,7 @@ public void getResultStreamTest() throws Exception { try { s1.forEach(this::checkPK); } catch (RuntimeException e) { - throw new Fault(e.getMessage()); + throw new Exception(e.getMessage()); } ObjectCounter oc = new ObjectCounter(); @@ -103,6 +105,7 @@ public void getResultStreamTest() throws Exception { * * @test_Strategy: iterateStream */ +@Test public void getTypedResultStreamTest() throws Exception { List expected = Arrays.asList(empRef); @@ -119,7 +122,7 @@ public void getTypedResultStreamTest() throws Exception { try { s1.forEach(this::checkPK); } catch (RuntimeException e) { - throw new Fault(e.getMessage()); + throw new Exception(e.getMessage()); } ObjectCounter oc = new ObjectCounter(); @@ -301,7 +304,7 @@ private void createTestData() throws Exception { } } - +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); @@ -341,7 +344,7 @@ private void removeTestData() { private void assertTrue(boolean condition, String message) throws Exception { if (!condition) - throw new Fault(message); + throw new Exception(message); } static class ObjectCounter { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/attroverride/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/attroverride/Client.java index fadc13987e..2563e26ae5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/attroverride/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/attroverride/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -17,9 +17,11 @@ package com.sun.ts.tests.jpa.jpa22.repeatable.attroverride; import java.sql.Date; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -57,24 +59,19 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); TestUtil.logTrace("Done creating test data"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -86,7 +83,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: use core/annotations/mappedsc without @AttributeOverrides */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -105,7 +102,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -116,7 +113,7 @@ public void test1() throws Exception { * * @test_Strategy: use core/annotations/mappedsc without @AttributeOverrides */ - +@Test public void test2() throws Exception { TestUtil.logTrace("Begin test2"); @@ -135,7 +132,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } public void createTestData() { @@ -181,6 +178,7 @@ public void createTestData() { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/convert/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/convert/Client.java index 88cd02e8cc..b9324a7b36 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/convert/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/convert/Client.java @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.jpa22.repeatable.convert; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -29,20 +30,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -54,6 +51,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: try @Convert works when annotated multiple times * without @Converts */ + @Test public void convertsTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -110,10 +108,11 @@ public void convertsTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("convertsTest failed"); + throw new Exception("convertsTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/joincolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/joincolumn/Client.java index d73354839a..cfcc86afd2 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/joincolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/joincolumn/Client.java @@ -17,9 +17,11 @@ package com.sun.ts.tests.jpa.jpa22.repeatable.joincolumn; import java.util.List; -import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +32,16 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -54,6 +52,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: follow up test core/derivedod/ex2a but without @JoinColumns */ + @Test public void didTest() throws Exception { boolean pass = false; @@ -113,10 +112,11 @@ public void didTest() throws Exception { } if (!pass) { - throw new Fault("DIDTest failed"); + throw new Exception("DIDTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/mapkeyjoincolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/mapkeyjoincolumn/Client.java index 9c7ae0bb42..f5aeaae411 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/mapkeyjoincolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/mapkeyjoincolumn/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,10 +18,12 @@ import java.util.Hashtable; import java.util.Map; -import java.util.Properties; import java.util.Set; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,22 +38,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -63,6 +61,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: follow core/annotations/mapkeyclass test but * without @mapkeyjoincolumns */ + @Test public void mapKeyJoinColumnTest() throws Exception { boolean pass = false; @@ -87,7 +86,7 @@ public void mapKeyJoinColumnTest() throws Exception { } if (!pass) { - throw new Fault("mapKeyJoinColumn Failed"); + throw new Exception("mapKeyJoinColumn Failed"); } } @@ -245,6 +244,7 @@ public void createTestData() { } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedentitygraph/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedentitygraph/Client.java index 8a2d83b86e..84719899df 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedentitygraph/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedentitygraph/Client.java @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -38,42 +41,40 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); - displayMap(p); + super.setup(); + displayMap(new Properties()); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupEmployeeData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupEmployeeData() throws Exception { TestUtil.logTrace("setupOrderData"); try { - super.setup(args, p); + super.setup(); removeTestData(); createEmployeeData(); - displayMap(p); + displayMap(new Properties()); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); } + @AfterEach public void cleanupEmployeeData() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -88,6 +89,7 @@ public void cleanupEmployeeData() throws Exception { * @test_Strategy: Use getName to get the name of the named entity graph in * the Employee2 entity that has no name */ + @Test public void entityGraphGetNameNoNameExistsTest() throws Exception { boolean pass = false; @@ -107,7 +109,7 @@ public void entityGraphGetNameNoNameExistsTest() throws Exception { } if (!pass) { - throw new Fault("entityGraphGetNameNoNameExistsTest failed"); + throw new Exception("entityGraphGetNameNoNameExistsTest failed"); } } @@ -118,6 +120,7 @@ public void entityGraphGetNameNoNameExistsTest() throws Exception { * * @test_Strategy: Use getName to get the name of the entity graph */ + @Test public void getNameTest() throws Exception { boolean pass = false; @@ -132,7 +135,7 @@ public void getNameTest() throws Exception { } if (!pass) { - throw new Fault("getNameTest failed"); + throw new Exception("getNameTest failed"); } } @@ -144,6 +147,7 @@ public void getNameTest() throws Exception { * @test_Strategy: Use getEntityGraph to get the named entity graphs in the * Employee entity */ + @Test public void getEntityGraphsClassTest() throws Exception { boolean pass = false; List expected = new ArrayList(); @@ -179,7 +183,7 @@ public void getEntityGraphsClassTest() throws Exception { } if (!pass) { - throw new Fault("getEntityGraphsClassTest failed"); + throw new Exception("getEntityGraphsClassTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namednativequery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namednativequery/Client.java index 20e3b815f8..80502eb7bd 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namednativequery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namednativequery/Client.java @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.jpa22.repeatable.namednativequery; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -28,16 +29,12 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); TestUtil.logTrace("Cleanup data"); removeTestData(); TestUtil.logTrace("Create Test data"); @@ -46,7 +43,7 @@ public void setup(String[] args, Properties p) throws Exception { } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -61,6 +58,7 @@ public void setup(String[] args, Properties p) throws Exception { * find(Class entityClass, Object PK, LockModeType lck) * */ + @Test public void findTest() throws Exception { TestUtil.logTrace("Begin findTest1"); @@ -89,7 +87,7 @@ public void findTest() throws Exception { } if (!pass) { - throw new Fault("findTest1 failed"); + throw new Exception("findTest1 failed"); } } @@ -131,6 +129,7 @@ private void createTestData() throws Exception { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); @@ -164,6 +163,6 @@ private void removeTestData() { private void assertTrue(boolean b, String message) throws Exception { if (!b) - throw new Fault(message); + throw new Exception(message); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedstoredprocedurequery/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedstoredprocedurequery/Client.java index 93f2086e9d..c3cc3108ff 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedstoredprocedurequery/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/repeatable/namedstoredprocedurequery/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -23,7 +23,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -52,30 +55,24 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * setup() is called before each test * * @class.setup_props: jdbc.db; */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); map.putAll(getEntityManager().getProperties()); map.put("foo", "bar"); displayMap(map); - dataBaseName = p.getProperty("jdbc.db"); + dataBaseName = System.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -84,11 +81,12 @@ public void setup(String[] args, Properties p) throws Exception { * * @class.setup_props: jdbc.db; */ + @BeforeEach public void setupEmployeeData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupOrderData"); this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createEmployeeData(); map.putAll(getEntityManager().getProperties()); @@ -97,15 +95,17 @@ public void setupEmployeeData(String[] args, Properties p) throws Exception { dataBaseName = p.getProperty("jdbc.db"); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup complete, calling super.cleanup"); super.cleanup(); } + @AfterEach public void cleanupData() throws Exception { TestUtil.logTrace("Cleanup data"); removeTestData(); @@ -123,6 +123,7 @@ public void cleanupData() throws Exception { */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createStoredProcedureQueryStringTest() throws Exception { boolean pass = false; @@ -153,7 +154,7 @@ public void createStoredProcedureQueryStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createStoredProcedureQueryStringTest failed"); + throw new Exception("createStoredProcedureQueryStringTest failed"); } } @@ -170,6 +171,7 @@ public void createStoredProcedureQueryStringTest() throws Exception { */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createStoredProcedureQueryStringClassArrayTest() throws Exception { boolean pass = false; getEntityTransaction().begin(); @@ -206,7 +208,7 @@ public void createStoredProcedureQueryStringClassArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createStoredProcedureQueryStringClassArrayTest failed"); + throw new Exception("createStoredProcedureQueryStringClassArrayTest failed"); } } @@ -223,6 +225,7 @@ public void createStoredProcedureQueryStringClassArrayTest() throws Exception { */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createStoredProcedureQueryStringStringArrayTest() throws Exception { boolean pass = false; @@ -263,7 +266,7 @@ public void createStoredProcedureQueryStringStringArrayTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createStoredProcedureQueryStringStringArrayTest failed"); + throw new Exception("createStoredProcedureQueryStringStringArrayTest failed"); } } @@ -281,6 +284,7 @@ public void createStoredProcedureQueryStringStringArrayTest() throws Exception { */ @SetupMethod(name = "setupEmployeeData") @CleanupMethod(name = "cleanupData") + @Test public void createNamedStoredProcedureQueryStringTest() throws Exception { boolean pass = false; getEntityTransaction().begin(); @@ -320,7 +324,7 @@ public void createNamedStoredProcedureQueryStringTest() throws Exception { getEntityTransaction().commit(); if (!pass) { - throw new Fault("createNamedStoredProcedureQueryStringTest failed"); + throw new Exception("createNamedStoredProcedureQueryStringTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/generators/sequencegenerators/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/generators/sequencegenerators/Client.java index c014ec1b64..7c1c4ad532 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/generators/sequencegenerators/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/generators/sequencegenerators/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,26 +36,24 @@ public class Client extends PMClientBase { private static final long serialVersionUID = 22L; String schemaGenerationDir = null; + String sTestCase = "testcase"; + boolean supportSequence; public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: db.supports.sequence; */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); - supportSequence = Boolean.valueOf(p.getProperty("db.supports.sequence")); + super.setup(); + supportSequence = Boolean.valueOf(System.getProperty("db.supports.sequence")); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -67,12 +68,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -83,6 +84,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @SequenceGenerator annotation */ + @Test public void sequenceGeneratorTest() throws Exception { if (!supportSequence) { TestUtil.logMsg( @@ -215,10 +217,11 @@ public void sequenceGeneratorTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1a || !pass1b || !pass2a || !pass2b || !pass3 || !pass4) { - throw new Fault("sequenceGeneratorTest failed"); + throw new Exception("sequenceGeneratorTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/repeatable/secondarytable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/repeatable/secondarytable/Client.java index c3be06b12c..7747d60082 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/repeatable/secondarytable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/jpa22/se/repeatable/secondarytable/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.jpa22.se.repeatable.secondarytable; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,22 +35,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -61,6 +58,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: follow se/cache/inherit but without @SecondaryTables */ + @Test public void subClassInheritsCacheableTrue() throws Exception { Cache cache; boolean pass1 = false; @@ -139,11 +137,12 @@ public void subClassInheritsCacheableTrue() throws Exception { pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("subClassInheritsCacheableTrue failed"); + throw new Exception("subClassInheritsCacheableTrue failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/inherit/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/inherit/Client.java index aeaa41eecd..5b15443515 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/inherit/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/inherit/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.se.cache.inherit; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,22 +33,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -60,6 +57,7 @@ public void setup(String[] args, Properties p) throws Exception { * ENABLE_SELECTIVE persist some entities with various Cachable values and * verify the behavior of whether or not each is retained or not in the cache. */ + @Test public void subClassInheritsCacheableTrue() throws Exception { Cache cache; boolean pass1 = false; @@ -138,7 +136,7 @@ public void subClassInheritsCacheableTrue() throws Exception { pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("subClassInheritsCacheableTrue failed"); + throw new Exception("subClassInheritsCacheableTrue failed"); } } @@ -152,6 +150,7 @@ public void subClassInheritsCacheableTrue() throws Exception { * ENABLE_SELECTIVE persist some entities with various Cachable values and * verify the behavior of whether or not each is retained or not in the cache. */ + @Test public void subClassInheritsCacheableFalse() throws Exception { Cache cache; boolean pass1 = false; @@ -230,11 +229,12 @@ public void subClassInheritsCacheableFalse() throws Exception { pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("subClassInheritsCacheableFalse failed"); + throw new Exception("subClassInheritsCacheableFalse failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/all/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/all/Client.java index a1c429ecd4..026479eaea 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/all/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/all/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,10 @@ import java.sql.SQLException; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.DriverManagerConnection; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -41,25 +44,21 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.testArgs: -ap tssql.stmt */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { // displayMap(p); - super.setup(args, p); + super.setup(); removeTestData(); - jpaprops = p; + jpaprops = null; } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -71,6 +70,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: Using the xml shared-cache-mode element with a value of ALL * persist an entity and verify it is in the cache */ + @Test public void containsTest() throws Exception { Cache cache; boolean pass = false; @@ -113,7 +113,7 @@ public void containsTest() throws Exception { pass = true; } if (!pass) { - throw new Fault("containsTest failed"); + throw new Exception("containsTest failed"); } } @@ -127,6 +127,7 @@ public void containsTest() throws Exception { * and a Persistence Context property of CacheStoreMode.BYPASS, persist an * entity and verify it is not in the cache */ + @Test public void cacheStoreModeBYPASSTest() throws Exception { Cache cache; boolean pass1, pass2, pass3; @@ -197,7 +198,7 @@ public void cacheStoreModeBYPASSTest() throws Exception { pass1 = pass2 = pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("cacheStoreModeBYPASSTest failed"); + throw new Exception("cacheStoreModeBYPASSTest failed"); } } @@ -211,6 +212,7 @@ public void cacheStoreModeBYPASSTest() throws Exception { * and a Persistence Context property of CacheStoreMode.USE, persist an entity * and verify it is in the cache */ + @Test public void cacheStoreModeUSETest() throws Exception { Cache cache; boolean pass1, pass2, pass3; @@ -282,7 +284,7 @@ public void cacheStoreModeUSETest() throws Exception { pass1 = pass2 = pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("cacheStoreModeUSETest failed"); + throw new Exception("cacheStoreModeUSETest failed"); } } @@ -296,6 +298,7 @@ public void cacheStoreModeUSETest() throws Exception { * and a Persistence Context property of CacheStoreMode.REFRESH, persist an * entity and verify it is in the cache */ + @Test public void cacheStoreModeREFRESHTest() throws Exception { Cache cache; boolean pass1, pass2, pass3; @@ -367,7 +370,7 @@ public void cacheStoreModeREFRESHTest() throws Exception { pass1 = pass2 = pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("cacheStoreModeREFRESHTest failed"); + throw new Exception("cacheStoreModeREFRESHTest failed"); } } @@ -381,6 +384,7 @@ public void cacheStoreModeREFRESHTest() throws Exception { * and a Persistence Context property of CacheRetrieveMode.BYPASS and * CacheStoreMode.BYPASS, persist an entity and verify it is not in the cache */ + @Test public void cacheRetrieveModeBYPASSTest() throws Exception { Cache cache; boolean pass1, pass2; @@ -438,7 +442,7 @@ public void cacheRetrieveModeBYPASSTest() throws Exception { pass1 = pass2 = true; } if (!pass1 || !pass2) { - throw new Fault("cacheRetrieveModeBYPASSTest failed"); + throw new Exception("cacheRetrieveModeBYPASSTest failed"); } } @@ -452,6 +456,7 @@ public void cacheRetrieveModeBYPASSTest() throws Exception { * and a Persistence Context property of CacheRetrieveMode.USE and * CacheStoreMode.BYPASS, persist an entity and verify it is in the cache */ + @Test public void cacheRetrieveModeUSETest() throws Exception { Cache cache; boolean pass1, pass2; @@ -508,7 +513,7 @@ public void cacheRetrieveModeUSETest() throws Exception { pass1 = pass2 = true; } if (!pass1 || !pass2) { - throw new Fault("cacheRetrieveModeUSETest failed"); + throw new Exception("cacheRetrieveModeUSETest failed"); } } @@ -553,7 +558,6 @@ public void cacheRetrieveModeUSETest() throws Exception { * * } */ - public int[] selectDataVIAJDBC(Properties p, int id) { int[] params = new int[2]; displayMap(p); @@ -618,6 +622,7 @@ public void createDataVIAJDBC(Properties p) { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/disableselective/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/disableselective/Client.java index 3e57fabd8d..1f9103b266 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/disableselective/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/disableselective/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.se.cache.xml.disableselective; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,22 +33,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -61,6 +58,7 @@ public void setup(String[] args, Properties p) throws Exception { * DISABLE_SELECTIVE persist some entities with various Cachable values and * verify the behavior of whether or not each is retained or not in the cache. */ + @Test public void containsTest() throws Exception { Cache cache; boolean pass1 = false; @@ -119,11 +117,12 @@ public void containsTest() throws Exception { pass2 = true; } if (!pass1 || !pass2) { - throw new Fault("containsTest failed"); + throw new Exception("containsTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/enableselective/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/enableselective/Client.java index 8d80770b1f..6cd2c2d493 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/enableselective/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/enableselective/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.se.cache.xml.enableselective; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,22 +33,17 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -61,6 +57,7 @@ public void setup(String[] args, Properties p) throws Exception { * ENABLE_SELECTIVE persist some entities with various Cachable values and * verify the behavior of whether or not each is retained or not in the cache. */ +@Test public void containsTest() throws Exception { Cache cache; boolean pass1 = false; @@ -133,11 +130,12 @@ public void containsTest() throws Exception { pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("containsTest failed"); + throw new Exception("containsTest failed"); } } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/none/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/none/Client.java index 94e61a2936..dff82e07d4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/none/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/cache/xml/none/Client.java @@ -16,9 +16,10 @@ package com.sun.ts.tests.jpa.se.cache.xml.none; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,22 +33,18 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -59,6 +56,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: Using the xml shared-cache-mode element with a value of * NONE persist an entity and verify it is not the cache */ + @Test public void containsTest() throws Exception { Cache cache; boolean pass = false; @@ -101,11 +99,12 @@ public void containsTest() throws Exception { pass = true; } if (!pass) { - throw new Fault("containsTest failed"); + throw new Exception("containsTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/descriptor/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/descriptor/Client.java index 86f01ac445..766af02801 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/descriptor/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/descriptor/Client.java @@ -20,9 +20,10 @@ package com.sun.ts.tests.jpa.se.descriptor; -import java.util.Properties; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.sun.javatest.Status; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -30,20 +31,16 @@ public class Client extends PMClientBase { private static final B bRef[] = new B[5]; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { try { - super.setup(args, p); + super.setup(); removeTestData(); createTestData(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } @@ -62,7 +59,7 @@ public void setup(String[] args, Properties p) throws Exception { * persist, then find. * */ - +@Test public void test1() throws Exception { boolean pass = false; try { @@ -83,7 +80,7 @@ public void test1() throws Exception { } if (!pass) { - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } } @@ -109,6 +106,7 @@ public void createTestData() { } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManager/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManager/Client.java index 0d97a8219d..32c75ad0de 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManager/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManager/Client.java @@ -22,7 +22,10 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -50,21 +53,14 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -73,11 +69,12 @@ public void setup(String[] args, Properties p) throws Exception { * * @class.setup_props: jdbc.db; */ + @BeforeEach public void setupOrderData(String[] args, Properties p) throws Exception { TestUtil.logTrace("setupOrderData"); this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createOrderData(); map.putAll(getEntityManager().getProperties()); @@ -85,15 +82,17 @@ public void setupOrderData(String[] args, Properties p) throws Exception { displayMap(map); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); super.cleanup(); } + @AfterEach public void cleanupData() throws Exception { TestUtil.logTrace("cleanupData"); removeTestData(); @@ -108,6 +107,7 @@ public void cleanupData() throws Exception { * @test_Strategy: Call EntityManager.persist() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void persistAfterClose() throws Exception { boolean pass = false; @@ -132,7 +132,7 @@ public void persistAfterClose() throws Exception { } if (!pass) { - throw new Fault("persistAfterClose failed"); + throw new Exception("persistAfterClose failed"); } } @@ -144,6 +144,7 @@ public void persistAfterClose() throws Exception { * @test_Strategy: Call EntityManager.merge() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void mergeAfterClose() throws Exception { boolean pass = false; @@ -167,7 +168,7 @@ public void mergeAfterClose() throws Exception { } if (!pass) { - throw new Fault("mergeAfterClose failed"); + throw new Exception("mergeAfterClose failed"); } } @@ -179,6 +180,7 @@ public void mergeAfterClose() throws Exception { * @test_Strategy: Call EntityManager.remove() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void removeAfterClose() throws Exception { boolean pass = false; @@ -203,7 +205,7 @@ public void removeAfterClose() throws Exception { } if (!pass) { - throw new Fault("removeAfterClose failed"); + throw new Exception("removeAfterClose failed"); } } @@ -215,6 +217,7 @@ public void removeAfterClose() throws Exception { * @test_Strategy: Call EntityManager.find() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void findAfterClose() throws Exception { boolean pass = false; @@ -238,7 +241,7 @@ public void findAfterClose() throws Exception { } if (!pass) { - throw new Fault("findAfterClose failed"); + throw new Exception("findAfterClose failed"); } } @@ -250,6 +253,7 @@ public void findAfterClose() throws Exception { * @test_Strategy: Call EntityManager.getReference() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void getReferenceAfterClose() throws Exception { boolean pass = false; @@ -273,7 +277,7 @@ public void getReferenceAfterClose() throws Exception { } if (!pass) { - throw new Fault("getReferenceAfterClose failed"); + throw new Exception("getReferenceAfterClose failed"); } } @@ -285,6 +289,7 @@ public void getReferenceAfterClose() throws Exception { * @test_Strategy: Call EntityManager.flush() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void flushAfterClose() throws Exception { boolean pass = false; @@ -308,7 +313,7 @@ public void flushAfterClose() throws Exception { } if (!pass) { - throw new Fault("flushAfterClose failed"); + throw new Exception("flushAfterClose failed"); } } @@ -320,6 +325,7 @@ public void flushAfterClose() throws Exception { * @test_Strategy: Call EntityManager.setFlushMode() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void setFlushModeAfterClose() throws Exception { boolean pass = false; @@ -343,7 +349,7 @@ public void setFlushModeAfterClose() throws Exception { } if (!pass) { - throw new Fault("setFlushModeAfterClose failed"); + throw new Exception("setFlushModeAfterClose failed"); } } @@ -355,6 +361,7 @@ public void setFlushModeAfterClose() throws Exception { * @test_Strategy: Call EntityManager.getFlushMode() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void getFlushModeAfterClose() throws Exception { boolean pass = false; @@ -378,7 +385,7 @@ public void getFlushModeAfterClose() throws Exception { } if (!pass) { - throw new Fault("getFlushModeAfterClose failed"); + throw new Exception("getFlushModeAfterClose failed"); } } @@ -390,6 +397,7 @@ public void getFlushModeAfterClose() throws Exception { * @test_Strategy: Call EntityManager.lock() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void lockAfterClose() throws Exception { boolean pass = false; @@ -414,7 +422,7 @@ public void lockAfterClose() throws Exception { } if (!pass) { - throw new Fault("lockAfterClose failed"); + throw new Exception("lockAfterClose failed"); } } @@ -426,6 +434,7 @@ public void lockAfterClose() throws Exception { * @test_Strategy: Call EntityManager.refresh() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void refreshAfterClose() throws Exception { boolean pass = false; @@ -450,7 +459,7 @@ public void refreshAfterClose() throws Exception { } if (!pass) { - throw new Fault("refreshAfterClose failed"); + throw new Exception("refreshAfterClose failed"); } } @@ -462,7 +471,7 @@ public void refreshAfterClose() throws Exception { * @test_Strategy: Call EntityManager.clear() method after calling * EntityManager.close()and expect IllegalStateException */ - + @Test public void clearAfterClose() throws Exception { boolean pass = false; @@ -487,7 +496,7 @@ public void clearAfterClose() throws Exception { } if (!pass) { - throw new Fault("clearAfterClose failed"); + throw new Exception("clearAfterClose failed"); } } @@ -499,6 +508,7 @@ public void clearAfterClose() throws Exception { * @test_Strategy: Call EntityManager.contains() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void containsAfterClose() throws Exception { boolean pass = false; @@ -523,7 +533,7 @@ public void containsAfterClose() throws Exception { } if (!pass) { - throw new Fault("containsAfterClose failed"); + throw new Exception("containsAfterClose failed"); } } @@ -535,6 +545,7 @@ public void containsAfterClose() throws Exception { * @test_Strategy: Call EntityManager.createQuery() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void createQueryAfterClose() throws Exception { boolean pass = false; @@ -559,7 +570,7 @@ public void createQueryAfterClose() throws Exception { } if (!pass) { - throw new Fault("createQueryAfterClose failed"); + throw new Exception("createQueryAfterClose failed"); } } @@ -571,6 +582,7 @@ public void createQueryAfterClose() throws Exception { * @test_Strategy: Call EntityManager.createNamedQuery() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void createNamedQueryAfterClose() throws Exception { boolean pass = false; @@ -594,7 +606,7 @@ public void createNamedQueryAfterClose() throws Exception { } if (!pass) { - throw new Fault("createNamedQueryAfterClose failed"); + throw new Exception("createNamedQueryAfterClose failed"); } } @@ -606,6 +618,7 @@ public void createNamedQueryAfterClose() throws Exception { * @test_Strategy: Call EntityManager.createNativeQuery() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void createNativeQueryAfterClose() throws Exception { boolean pass = false; @@ -630,7 +643,7 @@ public void createNativeQueryAfterClose() throws Exception { } if (!pass) { - throw new Fault("createNativeQueryAfterClose failed"); + throw new Exception("createNativeQueryAfterClose failed"); } } @@ -642,6 +655,7 @@ public void createNativeQueryAfterClose() throws Exception { * @test_Strategy: Call EntityManager.joinTransaction() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void joinTransactionAfterClose() throws Exception { boolean pass = false; @@ -665,7 +679,7 @@ public void joinTransactionAfterClose() throws Exception { } if (!pass) { - throw new Fault("joinTransactionAfterClose failed"); + throw new Exception("joinTransactionAfterClose failed"); } } @@ -677,6 +691,7 @@ public void joinTransactionAfterClose() throws Exception { * @test_Strategy: Call EntityManager.getDelegate() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void getDelegateAfterClose() throws Exception { boolean pass = false; @@ -700,7 +715,7 @@ public void getDelegateAfterClose() throws Exception { } if (!pass) { - throw new Fault("getDelegateAfterClose failed"); + throw new Exception("getDelegateAfterClose failed"); } } @@ -712,6 +727,7 @@ public void getDelegateAfterClose() throws Exception { * @test_Strategy: Call EntityManager.close() method after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void closeAfterClose() throws Exception { boolean pass = false; @@ -735,7 +751,7 @@ public void closeAfterClose() throws Exception { } if (!pass) { - throw new Fault("closeAfterClose failed"); + throw new Exception("closeAfterClose failed"); } } @@ -746,6 +762,7 @@ public void closeAfterClose() throws Exception { * * @test_Strategy: Get EntityManagerFactory from closed EntityManager */ + @Test public void getEntityManagerFactoryIllegalStateExceptionTest() throws Exception { boolean pass = false; getEntityManager().close(); @@ -759,7 +776,7 @@ public void getEntityManagerFactoryIllegalStateExceptionTest() throws Exception TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault( + throw new Exception( "getEntityManagerFactoryIllegalStateExceptionTest failed"); } } @@ -771,6 +788,7 @@ public void getEntityManagerFactoryIllegalStateExceptionTest() throws Exception * * @test_Strategy: Close the EntityManager, then call em.getMetaModel() */ + @Test public void emGetMetamodelIllegalStateExceptionTest() throws Exception { boolean pass = false; @@ -785,7 +803,7 @@ public void emGetMetamodelIllegalStateExceptionTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("emGetMetamodelIllegalStateExceptionTest failed"); + throw new Exception("emGetMetamodelIllegalStateExceptionTest failed"); } } @@ -798,6 +816,7 @@ public void emGetMetamodelIllegalStateExceptionTest() throws Exception { * closed and verify exception is thrown * */ + @Test public void getCriteriaBuilderIllegalStateExceptionTest() throws Exception { boolean pass = false; @@ -812,7 +831,7 @@ public void getCriteriaBuilderIllegalStateExceptionTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getCriteriaBuilderIllegalStateExceptionTest failed"); + throw new Exception("getCriteriaBuilderIllegalStateExceptionTest failed"); } } @@ -824,6 +843,7 @@ public void getCriteriaBuilderIllegalStateExceptionTest() throws Exception { * @test_Strategy: Call EntityManager.createNamedQuery(String, Class) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose1Test() throws Exception { boolean pass = false; @@ -847,7 +867,7 @@ public void entityManagerMethodsAfterClose1Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose1Test failed"); + throw new Exception("entityManagerMethodsAfterClose1Test failed"); } } @@ -859,6 +879,7 @@ public void entityManagerMethodsAfterClose1Test() throws Exception { * @test_Strategy: Call EntityManager.createNamedStoredProcedureQuery(String) * after calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose2Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -881,7 +902,7 @@ public void entityManagerMethodsAfterClose2Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose2Test failed"); + throw new Exception("entityManagerMethodsAfterClose2Test failed"); } } @@ -894,6 +915,7 @@ public void entityManagerMethodsAfterClose2Test() throws Exception { * @test_Strategy: Call EntityManager.createNativeQuery(String,Class) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose3Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -917,7 +939,7 @@ public void entityManagerMethodsAfterClose3Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose3Test failed"); + throw new Exception("entityManagerMethodsAfterClose3Test failed"); } } @@ -930,6 +952,7 @@ public void entityManagerMethodsAfterClose3Test() throws Exception { * @test_Strategy: Call EntityManager.createNativeQuery(String, String) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose4Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -953,7 +976,7 @@ public void entityManagerMethodsAfterClose4Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose4Test failed"); + throw new Exception("entityManagerMethodsAfterClose4Test failed"); } } @@ -967,6 +990,7 @@ public void entityManagerMethodsAfterClose4Test() throws Exception { * @test_Strategy: Call EntityManager.createQuery(CriteriaDelete) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose5Test() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); @@ -991,7 +1015,7 @@ public void entityManagerMethodsAfterClose5Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose5Test failed"); + throw new Exception("entityManagerMethodsAfterClose5Test failed"); } } @@ -1004,6 +1028,7 @@ public void entityManagerMethodsAfterClose5Test() throws Exception { * @test_Strategy: Call EntityManager.createQuery(CriteriaQuery) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose6Test() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); @@ -1028,7 +1053,7 @@ public void entityManagerMethodsAfterClose6Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose6Test failed"); + throw new Exception("entityManagerMethodsAfterClose6Test failed"); } } @@ -1041,6 +1066,7 @@ public void entityManagerMethodsAfterClose6Test() throws Exception { * @test_Strategy: Call EntityManager.createQuery(CriteriaUpdate) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose7Test() throws Exception { boolean pass = false; CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); @@ -1065,7 +1091,7 @@ public void entityManagerMethodsAfterClose7Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose7Test failed"); + throw new Exception("entityManagerMethodsAfterClose7Test failed"); } } @@ -1078,6 +1104,7 @@ public void entityManagerMethodsAfterClose7Test() throws Exception { * @test_Strategy: Call EntityManager.createQuery(String, Class) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose8Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1100,7 +1127,7 @@ public void entityManagerMethodsAfterClose8Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose8Test failed"); + throw new Exception("entityManagerMethodsAfterClose8Test failed"); } } @@ -1113,6 +1140,7 @@ public void entityManagerMethodsAfterClose8Test() throws Exception { * @test_Strategy: Call EntityManager.createStoredProcedureQuery(String) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose9Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1135,7 +1163,7 @@ public void entityManagerMethodsAfterClose9Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose9Test failed"); + throw new Exception("entityManagerMethodsAfterClose9Test failed"); } } @@ -1148,6 +1176,7 @@ public void entityManagerMethodsAfterClose9Test() throws Exception { * @test_Strategy: Call EntityManager.createStoredProcedureQuery(String, * Class) after calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose10Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1171,7 +1200,7 @@ public void entityManagerMethodsAfterClose10Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose10Test failed"); + throw new Exception("entityManagerMethodsAfterClose10Test failed"); } } @@ -1184,6 +1213,7 @@ public void entityManagerMethodsAfterClose10Test() throws Exception { * @test_Strategy: Call EntityManager.createStoredProcedureQuery(String, * String) after calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose11Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1207,7 +1237,7 @@ public void entityManagerMethodsAfterClose11Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose11Test failed"); + throw new Exception("entityManagerMethodsAfterClose11Test failed"); } } @@ -1220,6 +1250,7 @@ public void entityManagerMethodsAfterClose11Test() throws Exception { * @test_Strategy: Call EntityManager.detach(Object) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose12Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1245,7 +1276,7 @@ public void entityManagerMethodsAfterClose12Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose12Test failed"); + throw new Exception("entityManagerMethodsAfterClose12Test failed"); } } @@ -1258,6 +1289,7 @@ public void entityManagerMethodsAfterClose12Test() throws Exception { * @test_Strategy: Call EntityManager.find(Class, Object, LockModeType) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose13Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1280,7 +1312,7 @@ public void entityManagerMethodsAfterClose13Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose13Test failed"); + throw new Exception("entityManagerMethodsAfterClose13Test failed"); } } @@ -1293,6 +1325,7 @@ public void entityManagerMethodsAfterClose13Test() throws Exception { * @test_Strategy: Call EntityManager.find(Class, Object, LockModeType, Map) * after calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose14Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1315,7 +1348,7 @@ public void entityManagerMethodsAfterClose14Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose14Test failed"); + throw new Exception("entityManagerMethodsAfterClose14Test failed"); } } @@ -1328,6 +1361,7 @@ public void entityManagerMethodsAfterClose14Test() throws Exception { * @test_Strategy: Call EntityManager.find(Class, Object, Map) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose15Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1350,7 +1384,7 @@ public void entityManagerMethodsAfterClose15Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose15Test failed"); + throw new Exception("entityManagerMethodsAfterClose15Test failed"); } } @@ -1363,6 +1397,7 @@ public void entityManagerMethodsAfterClose15Test() throws Exception { * @test_Strategy: Call EntityManager.getCriteriaBuilder() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose16Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1385,7 +1420,7 @@ public void entityManagerMethodsAfterClose16Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose16Test failed"); + throw new Exception("entityManagerMethodsAfterClose16Test failed"); } } @@ -1398,6 +1433,7 @@ public void entityManagerMethodsAfterClose16Test() throws Exception { * @test_Strategy: Call EntityManager.getEntityManagerFactory() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose17Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1420,7 +1456,7 @@ public void entityManagerMethodsAfterClose17Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose17Test failed"); + throw new Exception("entityManagerMethodsAfterClose17Test failed"); } } @@ -1433,6 +1469,7 @@ public void entityManagerMethodsAfterClose17Test() throws Exception { * @test_Strategy: Call EntityManager.getLockMode(Object) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose18Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1458,7 +1495,7 @@ public void entityManagerMethodsAfterClose18Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose18Test failed"); + throw new Exception("entityManagerMethodsAfterClose18Test failed"); } } @@ -1471,6 +1508,7 @@ public void entityManagerMethodsAfterClose18Test() throws Exception { * @test_Strategy: Call EntityManager.getMetamodel() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose19Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1493,7 +1531,7 @@ public void entityManagerMethodsAfterClose19Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose19Test failed"); + throw new Exception("entityManagerMethodsAfterClose19Test failed"); } } @@ -1506,6 +1544,7 @@ public void entityManagerMethodsAfterClose19Test() throws Exception { * @test_Strategy: Call EntityManager.isJoinedToTransaction() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose20Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1528,7 +1567,7 @@ public void entityManagerMethodsAfterClose20Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose20Test failed"); + throw new Exception("entityManagerMethodsAfterClose20Test failed"); } } @@ -1541,6 +1580,7 @@ public void entityManagerMethodsAfterClose20Test() throws Exception { * @test_Strategy: Call EntityManager.lock(Object, LockModeType, Map) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose21Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1566,7 +1606,7 @@ public void entityManagerMethodsAfterClose21Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose21Test failed"); + throw new Exception("entityManagerMethodsAfterClose21Test failed"); } } @@ -1579,6 +1619,7 @@ public void entityManagerMethodsAfterClose21Test() throws Exception { * @test_Strategy: Call EntityManager.refresh(java.lang.Object, LockModeType) * after calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose22Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1604,7 +1645,7 @@ public void entityManagerMethodsAfterClose22Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose22Test failed"); + throw new Exception("entityManagerMethodsAfterClose22Test failed"); } } @@ -1617,6 +1658,7 @@ public void entityManagerMethodsAfterClose22Test() throws Exception { * @test_Strategy: Call EntityManager.refresh(Object, LockModeType, Map) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void entityManagerMethodsAfterClose23Test() throws Exception { boolean pass = false; getEntityManager().close(); @@ -1642,7 +1684,7 @@ public void entityManagerMethodsAfterClose23Test() throws Exception { } if (!pass) { - throw new Fault("entityManagerMethodsAfterClose23Test failed"); + throw new Exception("entityManagerMethodsAfterClose23Test failed"); } } @@ -1655,6 +1697,7 @@ public void entityManagerMethodsAfterClose23Test() throws Exception { * @test_Strategy: Call EntityManager.refresh(Object, Map, T) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void queryMethodsAfterClose28Test() throws Exception { boolean pass = false; @@ -2846,7 +2917,7 @@ public void queryMethodsAfterClose28Test() throws Exception { } } if (!pass) { - throw new Fault("queryMethodsAfterClose28Test failed"); + throw new Exception("queryMethodsAfterClose28Test failed"); } } @@ -2860,6 +2931,7 @@ public void queryMethodsAfterClose28Test() throws Exception { * @test_Strategy: Call Query.setParameter(String, Calendar, TemporalType) * after calling EntityManager.close()and expect IllegalStateException */ + @Test public void queryMethodsAfterClose29Test() throws Exception { boolean pass = false; @@ -2884,7 +2956,7 @@ public void queryMethodsAfterClose29Test() throws Exception { } } if (!pass) { - throw new Fault("queryMethodsAfterClose29Test failed"); + throw new Exception("queryMethodsAfterClose29Test failed"); } } @@ -2898,6 +2970,7 @@ public void queryMethodsAfterClose29Test() throws Exception { * @test_Strategy: Call Query.setParameter(String, Date, TemporalType) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void queryMethodsAfterClose30Test() throws Exception { boolean pass = false; @@ -2922,7 +2995,7 @@ public void queryMethodsAfterClose30Test() throws Exception { } } if (!pass) { - throw new Fault("queryMethodsAfterClose30Test failed"); + throw new Exception("queryMethodsAfterClose30Test failed"); } } @@ -2936,6 +3009,7 @@ public void queryMethodsAfterClose30Test() throws Exception { * @test_Strategy: Call Query.setParameter(String, Object) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void queryMethodsAfterClose31Test() throws Exception { boolean pass = false; @@ -2961,7 +3035,7 @@ public void queryMethodsAfterClose31Test() throws Exception { } if (!pass) { - throw new Fault("queryMethodsAfterClose31Test failed"); + throw new Exception("queryMethodsAfterClose31Test failed"); } } @@ -2974,6 +3048,7 @@ public void queryMethodsAfterClose31Test() throws Exception { * @test_Strategy: Call TypedQuery.getResultList() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose1Test() throws Exception { boolean pass = false; @@ -3004,7 +3079,7 @@ public void typedQueryMethodsAfterClose1Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose1Test failed"); + throw new Exception("typedQueryMethodsAfterClose1Test failed"); } } @@ -3017,6 +3092,7 @@ public void typedQueryMethodsAfterClose1Test() throws Exception { * @test_Strategy: Call TypedQuery.getResultList() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose2Test() throws Exception { boolean pass = false; @@ -3048,7 +3124,7 @@ public void typedQueryMethodsAfterClose2Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose2Test failed"); + throw new Exception("typedQueryMethodsAfterClose2Test failed"); } } @@ -3061,6 +3137,7 @@ public void typedQueryMethodsAfterClose2Test() throws Exception { * @test_Strategy: Call TypedQuery.setFirstResult(int) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose3Test() throws Exception { boolean pass = false; @@ -3092,7 +3169,7 @@ public void typedQueryMethodsAfterClose3Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose3Test failed"); + throw new Exception("typedQueryMethodsAfterClose3Test failed"); } } @@ -3105,6 +3182,7 @@ public void typedQueryMethodsAfterClose3Test() throws Exception { * @test_Strategy: Call TypedQuery.setFlushMode(FlushModeType) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose4Test() throws Exception { boolean pass = false; @@ -3136,7 +3214,7 @@ public void typedQueryMethodsAfterClose4Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose4Test failed"); + throw new Exception("typedQueryMethodsAfterClose4Test failed"); } } @@ -3149,6 +3227,7 @@ public void typedQueryMethodsAfterClose4Test() throws Exception { * @test_Strategy: Call TypedQuery.setHint(String, Object) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose5Test() throws Exception { boolean pass = false; @@ -3180,7 +3259,7 @@ public void typedQueryMethodsAfterClose5Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose5Test failed"); + throw new Exception("typedQueryMethodsAfterClose5Test failed"); } } @@ -3193,6 +3272,7 @@ public void typedQueryMethodsAfterClose5Test() throws Exception { * @test_Strategy: Call TypedQuery.setLockMode(LockModeType) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose6Test() throws Exception { boolean pass = false; @@ -3224,7 +3304,7 @@ public void typedQueryMethodsAfterClose6Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose6Test failed"); + throw new Exception("typedQueryMethodsAfterClose6Test failed"); } } @@ -3237,6 +3317,7 @@ public void typedQueryMethodsAfterClose6Test() throws Exception { * @test_Strategy: Call TypedQuery.setMaxResults(int) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose7Test() throws Exception { boolean pass = false; @@ -3268,7 +3349,7 @@ public void typedQueryMethodsAfterClose7Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose7Test failed"); + throw new Exception("typedQueryMethodsAfterClose7Test failed"); } } @@ -3281,6 +3362,7 @@ public void typedQueryMethodsAfterClose7Test() throws Exception { * @test_Strategy: Call TypedQuery.setParameter(int, Calendar, TemporalType) * after calling EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose8Test() throws Exception { boolean pass = false; @@ -3309,7 +3391,7 @@ public void typedQueryMethodsAfterClose8Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose8Test failed"); + throw new Exception("typedQueryMethodsAfterClose8Test failed"); } } @@ -3322,6 +3404,7 @@ public void typedQueryMethodsAfterClose8Test() throws Exception { * @test_Strategy: Call TypedQuery.setParameter(int, Date, TemporalType) after * calling EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose9Test() throws Exception { boolean pass = false; @@ -3350,7 +3433,7 @@ public void typedQueryMethodsAfterClose9Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose9Test failed"); + throw new Exception("typedQueryMethodsAfterClose9Test failed"); } } @@ -3363,6 +3446,7 @@ public void typedQueryMethodsAfterClose9Test() throws Exception { * @test_Strategy: Call TypedQuery.setParameter(int, Object) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose10Test() throws Exception { boolean pass = false; @@ -3391,7 +3475,7 @@ public void typedQueryMethodsAfterClose10Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose10Test failed"); + throw new Exception("typedQueryMethodsAfterClose10Test failed"); } } @@ -3405,6 +3489,7 @@ public void typedQueryMethodsAfterClose10Test() throws Exception { * TemporalType) after calling EntityManager.close()and expect * IllegalStateException */ + @Test public void typedQueryMethodsAfterClose11Test() throws Exception { boolean pass = false; @@ -3438,7 +3523,7 @@ public void typedQueryMethodsAfterClose11Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose11Test failed"); + throw new Exception("typedQueryMethodsAfterClose11Test failed"); } } @@ -3452,6 +3537,7 @@ public void typedQueryMethodsAfterClose11Test() throws Exception { * TemporalType) after calling EntityManager.close()and expect * IllegalStateException */ + @Test public void typedQueryMethodsAfterClose12Test() throws Exception { boolean pass = false; @@ -3485,7 +3571,7 @@ public void typedQueryMethodsAfterClose12Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose12Test failed"); + throw new Exception("typedQueryMethodsAfterClose12Test failed"); } } @@ -3498,6 +3584,7 @@ public void typedQueryMethodsAfterClose12Test() throws Exception { * @test_Strategy: Call TypedQuery.setParameter(Parameter, T) after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose13Test() throws Exception { boolean pass = false; @@ -3531,7 +3618,7 @@ public void typedQueryMethodsAfterClose13Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose13Test failed"); + throw new Exception("typedQueryMethodsAfterClose13Test failed"); } } @@ -3545,6 +3632,7 @@ public void typedQueryMethodsAfterClose13Test() throws Exception { * TemporalType) after calling EntityManager.close()and expect * IllegalStateException */ + @Test public void typedQueryMethodsAfterClose14Test() throws Exception { boolean pass = false; @@ -3579,7 +3667,7 @@ public void typedQueryMethodsAfterClose14Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose14Test failed"); + throw new Exception("typedQueryMethodsAfterClose14Test failed"); } } @@ -3592,6 +3680,7 @@ public void typedQueryMethodsAfterClose14Test() throws Exception { * @test_Strategy: Call TypedQuery.setParameter(String, Date, TemporalType) * after calling EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose15Test() throws Exception { boolean pass = false; @@ -3626,7 +3715,7 @@ public void typedQueryMethodsAfterClose15Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose15Test failed"); + throw new Exception("typedQueryMethodsAfterClose15Test failed"); } } @@ -3639,6 +3728,7 @@ public void typedQueryMethodsAfterClose15Test() throws Exception { * @test_Strategy: Call TypedQuery.method_name() after calling * EntityManager.close()and expect IllegalStateException */ + @Test public void typedQueryMethodsAfterClose16Test() throws Exception { boolean pass = false; @@ -3673,7 +3763,7 @@ public void typedQueryMethodsAfterClose16Test() throws Exception { } if (!pass) { - throw new Fault("typedQueryMethodsAfterClose16Test failed"); + throw new Exception("typedQueryMethodsAfterClose16Test failed"); } } @@ -3686,6 +3776,7 @@ public void typedQueryMethodsAfterClose16Test() throws Exception { * @test_Strategy: Call EntityManager.getCriteriaBuilder() that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback18Test() throws Exception { boolean pass = false; @@ -3715,7 +3806,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback18Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback18Test failed"); } } @@ -3728,6 +3819,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback18Test() * @test_Strategy: Call EntityManager.getDelegate() that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback19Test() throws Exception { boolean pass = false; @@ -3758,7 +3850,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback19Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback19Test failed"); } } @@ -3771,6 +3863,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback19Test() * @test_Strategy: Call EntityManager.getEntityManagerFactory() that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback20Test() throws Exception { boolean pass = false; @@ -3801,7 +3894,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback20Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback20Test failed"); } } @@ -3814,6 +3907,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback20Test() * @test_Strategy: Call EntityManager.getMetamodel() that causes * RuntimeException and verify Transaction is set for rollback */ + @Test public void entityManagerMethodsRuntimeExceptionsCauseRollback22Test() throws Exception { boolean pass = false; @@ -3843,7 +3937,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback22Test() } if (!pass) { - throw new Fault( + throw new Exception( "entityManagerMethodsRuntimeExceptionsCauseRollback22Test failed"); } } @@ -3856,6 +3950,7 @@ public void entityManagerMethodsRuntimeExceptionsCauseRollback22Test() * @test_Strategy: * */ + @Test public void storedProcedureQueryMethodsAfterClose1Test() throws Exception { boolean pass = false; @@ -3871,7 +3966,7 @@ public void storedProcedureQueryMethodsAfterClose1Test() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("storedProcedureQueryMethodsAfterClose1Test failed"); + throw new Exception("storedProcedureQueryMethodsAfterClose1Test failed"); } } @@ -3884,6 +3979,7 @@ public void storedProcedureQueryMethodsAfterClose1Test() throws Exception { * @test_Strategy: * */ + @Test public void storedProcedureQueryMethodsAfterClose2Test() throws Exception { boolean pass = false; @@ -3898,7 +3994,7 @@ public void storedProcedureQueryMethodsAfterClose2Test() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("storedProcedureQueryMethodsAfterClose2Test failed"); + throw new Exception("storedProcedureQueryMethodsAfterClose2Test failed"); } } @@ -3911,6 +4007,7 @@ public void storedProcedureQueryMethodsAfterClose2Test() throws Exception { * @test_Strategy: * */ + @Test public void storedProcedureQueryMethodsAfterClose3Test() throws Exception { boolean pass = false; @@ -3927,7 +4024,7 @@ public void storedProcedureQueryMethodsAfterClose3Test() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("storedProcedureQueryMethodsAfterClose3Test failed"); + throw new Exception("storedProcedureQueryMethodsAfterClose3Test failed"); } } @@ -3940,6 +4037,7 @@ public void storedProcedureQueryMethodsAfterClose3Test() throws Exception { * @test_Strategy: * */ + @Test public void storedProcedureQueryMethodsAfterClose4Test() throws Exception { boolean pass = false; @@ -3956,7 +4054,7 @@ public void storedProcedureQueryMethodsAfterClose4Test() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("storedProcedureQueryMethodsAfterClose4Test failed"); + throw new Exception("storedProcedureQueryMethodsAfterClose4Test failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManagerFactory/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManagerFactory/Client.java index 6b3df5d088..df95011cce 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManagerFactory/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManagerFactory/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,7 +18,10 @@ import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -36,53 +39,50 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setupNoData(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupNoData() throws Exception { TestUtil.logTrace("setupNoData"); - this.props = p; try { - super.setup(args, p); + super.setup(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createOrderTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } - public void setupMember(String[] args, Properties p) throws Exception { + @BeforeEach + public void setupMember() throws Exception { TestUtil.logTrace("setup"); - this.props = p; try { - super.setup(args, p); + super.setup(); removeTestData(); createMemberTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } + @AfterEach public void cleanupNoData() throws Exception { super.cleanup(); } + @AfterEach public void cleanup() throws Exception { removeTestData(); TestUtil.logTrace("done cleanup, calling super.cleanup"); @@ -99,6 +99,7 @@ public void cleanup() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoData") + @Test public void getMetamodelIllegalStateExceptionTest() throws Exception { boolean pass = false; try { @@ -116,7 +117,7 @@ public void getMetamodelIllegalStateExceptionTest() throws Exception { TestUtil.logErr("Unexpected exception occurred", e); } if (!pass) { - throw new Fault("getMetamodelIllegalStateExceptionTest failed"); + throw new Exception("getMetamodelIllegalStateExceptionTest failed"); } } @@ -130,6 +131,7 @@ public void getMetamodelIllegalStateExceptionTest() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoSuper") + @Test public void createEntityManagerFactoryNoBeanValidatorTest() throws Exception { boolean pass = false; myProps.put("jakarta.persistence.validation.mode", "callback"); @@ -148,7 +150,7 @@ public void createEntityManagerFactoryNoBeanValidatorTest() throws Exception { TestUtil.logErr("Received unexpected Exception", ex); } if (!pass) { - throw new Fault("createEntityManagerFactoryNoBeanValidatorTest failed"); + throw new Exception("createEntityManagerFactoryNoBeanValidatorTest failed"); } } @@ -161,6 +163,7 @@ public void createEntityManagerFactoryNoBeanValidatorTest() throws Exception { */ @SetupMethod(name = "setupNoData") @CleanupMethod(name = "cleanupNoSuper") + @Test public void createEntityManagerFactoryStringMapTest() throws Exception { boolean pass = false; @@ -177,7 +180,7 @@ public void createEntityManagerFactoryStringMapTest() throws Exception { TestUtil.logErr("Received unexpected exception", e); } if (!pass) { - throw new Fault("createEntityManagerFactoryStringTest failed"); + throw new Exception("createEntityManagerFactoryStringTest failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/pluggability/contracts/resource_local/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/pluggability/contracts/resource_local/Client.java index 373f900900..aaf63e1a17 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/pluggability/contracts/resource_local/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/pluggability/contracts/resource_local/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,9 @@ import java.util.Map; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import com.sun.ts.tests.jpa.common.pluggability.altprovider.implementation.EntityManagerFactoryImpl; @@ -59,25 +61,20 @@ public class Client extends PMClientBase { public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: log.file.location; * */ - public void setup(String[] args, Properties props) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); - super.setup(args, props); - this.props = props; + super.setup(); initEntityManager("ALTPROVIDERPU", false); } public void getLogProcessor() { - logProcessor = new LogFileProcessor(this.props); + logProcessor = new LogFileProcessor(); logProcessor.fetchLog(); // currentSeqNum = logProcessor.getCurrentSequenceNumber(); @@ -90,6 +87,7 @@ public void getLogProcessor() { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceProviderClassName() throws Exception { boolean pass1 = false; @@ -111,7 +109,7 @@ public void getPersistenceProviderClassName() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getPersistenceProviderClassName failed"); + throw new Exception("getPersistenceProviderClassName failed"); } } @@ -122,6 +120,7 @@ public void getPersistenceProviderClassName() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceUnitNameTest() throws Exception { boolean pass1 = false; @@ -152,7 +151,7 @@ public void getPersistenceUnitNameTest() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getPersistenceUnitNameTest failed"); + throw new Exception("getPersistenceUnitNameTest failed"); } } @@ -163,6 +162,7 @@ public void getPersistenceUnitNameTest() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getTransactionType() throws Exception { boolean pass1 = false; @@ -189,7 +189,7 @@ public void getTransactionType() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getTransactionType failed"); + throw new Exception("getTransactionType failed"); } } @@ -200,6 +200,7 @@ public void getTransactionType() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getManagedClassNames() throws Exception { boolean pass1 = false; List expected = new ArrayList(); @@ -232,7 +233,7 @@ public void getManagedClassNames() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected1); if (!pass1 || !pass2) { - throw new Fault("getManagedClassNames failed"); + throw new Exception("getManagedClassNames failed"); } } @@ -243,6 +244,7 @@ public void getManagedClassNames() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getJarFileUrls() throws Exception { boolean pass1 = false; @@ -273,7 +275,7 @@ public void getJarFileUrls() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getJarFileUrls failed"); + throw new Exception("getJarFileUrls failed"); } } @@ -283,6 +285,7 @@ public void getJarFileUrls() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceUnitRootUrl() throws Exception { boolean pass1 = false; @@ -305,7 +308,7 @@ public void getPersistenceUnitRootUrl() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getPersistenceUnitRootUrl failed"); + throw new Exception("getPersistenceUnitRootUrl failed"); } } @@ -315,6 +318,7 @@ public void getPersistenceUnitRootUrl() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getPersistenceXMLSchemaVersion() throws Exception { boolean pass1 = false; @@ -337,7 +341,7 @@ public void getPersistenceXMLSchemaVersion() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getPersistenceXMLSchemaVersion failed"); + throw new Exception("getPersistenceXMLSchemaVersion failed"); } } @@ -347,6 +351,7 @@ public void getPersistenceXMLSchemaVersion() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getProperties() throws Exception { boolean pass1 = true; @@ -400,7 +405,7 @@ public void getProperties() throws Exception { // verify log does NOT contain the string boolean pass2 = logProcessor.verifyLogContains(expected); if (!pass1 || !pass2) { - throw new Fault("getProperties failed"); + throw new Exception("getProperties failed"); } } @@ -410,6 +415,7 @@ public void getProperties() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getSharedCacheMode() throws Exception { boolean pass1 = false; @@ -432,7 +438,7 @@ public void getSharedCacheMode() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getSharedCacheMode failed"); + throw new Exception("getSharedCacheMode failed"); } } @@ -442,6 +448,7 @@ public void getSharedCacheMode() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getValidationMode() throws Exception { boolean pass1 = false; @@ -464,7 +471,7 @@ public void getValidationMode() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected2); if (!pass1 || !pass2) { - throw new Fault("getValidationMode failed"); + throw new Exception("getValidationMode failed"); } } @@ -474,6 +481,7 @@ public void getValidationMode() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getClassLoader() throws Exception { boolean pass1 = false; getClassObjects(); @@ -494,7 +502,7 @@ public void getClassLoader() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected); if (!pass1 || !pass2) { - throw new Fault("getClassLoader failed"); + throw new Exception("getClassLoader failed"); } } @@ -504,6 +512,7 @@ public void getClassLoader() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getMappingFileNames() throws Exception { boolean pass1 = false; List expected = new ArrayList(); @@ -540,7 +549,7 @@ public void getMappingFileNames() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected1); if (!pass1 || !pass2) { - throw new Fault("getMappingFileNames failed"); + throw new Exception("getMappingFileNames failed"); } } @@ -550,6 +559,7 @@ public void getMappingFileNames() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void excludeUnlistedClasses() throws Exception { boolean pass1 = false; @@ -570,7 +580,7 @@ public void excludeUnlistedClasses() throws Exception { boolean pass2 = logProcessor.verifyLogContains(expected); if (!pass1 || !pass2) { - throw new Fault("excludeUnlistedClasses failed"); + throw new Exception("excludeUnlistedClasses failed"); } } @@ -580,6 +590,7 @@ public void excludeUnlistedClasses() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void getProviderUtil() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called getProviderUtil()" }; @@ -591,7 +602,7 @@ public void getProviderUtil() throws Exception { boolean pass = logProcessor.verifyLogContains(expected); if (!pass) { - throw new Fault("getProviderUtil failed"); + throw new Exception("getProviderUtil failed"); } } @@ -601,6 +612,7 @@ public void getProviderUtil() throws Exception { * @test_Strategy: Specify a third Party Persistence Provider through * persistence.xml file */ + @Test public void isLoaded() throws Exception { String expected[] = { LOGMESSAGE_PREFIX + "Called isLoaded()" }; @@ -612,7 +624,7 @@ public void isLoaded() throws Exception { boolean pass = logProcessor.verifyLogContains(expected); if (!pass) { - throw new Fault("isLoaded failed"); + throw new Exception("isLoaded failed"); } } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/resource_local/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/resource_local/Client.java index 2a8df0ff0b..8dca3d5be5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/resource_local/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/resource_local/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,10 @@ import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.harness.CleanupMethod; import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; @@ -42,27 +45,22 @@ public class Client extends PMClientBase { private EntityTransaction entityTransaction; - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { try { - super.setup(args, p); + super.setup(); removeTestData(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } - public void setupOnly(String[] args, Properties p) throws Exception { + public void setupOnly() throws Exception { try { - super.setup(args, p); + super.setup(); } catch (Exception e) { - throw new Fault("Setup Failed!", e); + throw new Exception("Setup Failed!", e); } } /* @@ -75,7 +73,7 @@ public void setupOnly(String[] args, Properties p) throws Exception { * * begin() starts a resource_transaction */ - +@Test public void test1() throws Exception { TestUtil.logTrace("Begin test1"); @@ -101,7 +99,7 @@ public void test1() throws Exception { } if (!pass) - throw new Fault("test1 failed"); + throw new Exception("test1 failed"); } /* @@ -113,7 +111,7 @@ public void test1() throws Exception { * * begin() throws an IllegalStateException if isActive() is true */ - +@Test public void test2() throws Exception { TestUtil.logTrace("Begin test2"); @@ -143,7 +141,7 @@ public void test2() throws Exception { } if (!pass) - throw new Fault("test2 failed"); + throw new Exception("test2 failed"); } /* @@ -155,7 +153,7 @@ public void test2() throws Exception { * * commit() commits the current transaction */ - +@Test public void test3() throws Exception { TestUtil.logTrace("Begin test3"); @@ -202,7 +200,7 @@ public void test3() throws Exception { } if (!pass) - throw new Fault("test3 failed"); + throw new Exception("test3 failed"); } /* @@ -214,7 +212,7 @@ public void test3() throws Exception { * * commit() throws an IllegalStateException if isActive() is false */ - +@Test public void test4() throws Exception { TestUtil.logTrace("Begin test4"); @@ -244,7 +242,7 @@ public void test4() throws Exception { } if (!pass) - throw new Fault("test4 failed"); + throw new Exception("test4 failed"); } /* @@ -257,7 +255,7 @@ public void test4() throws Exception { * * commit() throws a RollbackException if commit fails */ - +@Test public void test5() throws Exception { TestUtil.logTrace("Begin test5"); @@ -288,7 +286,7 @@ public void test5() throws Exception { } if (!pass) - throw new Fault("test5 failed"); + throw new Exception("test5 failed"); } /* @@ -300,7 +298,7 @@ public void test5() throws Exception { * * rollback() rolls back the current transaction */ - +@Test public void test6() throws Exception { TestUtil.logTrace("Begin test6"); @@ -342,7 +340,7 @@ public void test6() throws Exception { } if (!pass) - throw new Fault("test6 failed"); + throw new Exception("test6 failed"); } /* @@ -355,7 +353,7 @@ public void test6() throws Exception { * setRollbackOnly() marks the current transaction so the only outcome is for * the transaction to be rolled back */ - +@Test public void test7() throws Exception { TestUtil.logTrace("Begin test7"); @@ -391,7 +389,7 @@ public void test7() throws Exception { } if (!pass) - throw new Fault("test7 failed"); + throw new Exception("test7 failed"); } /* @@ -403,7 +401,7 @@ public void test7() throws Exception { * * setRollbackOnly throws IllegalStateException if isActive() is false */ - +@Test public void test8() throws Exception { TestUtil.logTrace("Begin test8"); @@ -434,7 +432,7 @@ public void test8() throws Exception { } if (!pass) - throw new Fault("test8 failed"); + throw new Exception("test8 failed"); } /* @@ -448,7 +446,7 @@ public void test8() throws Exception { * rollback test getRollbackOnly when isActive() is true and TX has been * marked for rollback, so getRollbackOnly will return true */ - +@Test public void test9() throws Exception { TestUtil.logTrace("Begin test9"); @@ -483,7 +481,7 @@ public void test9() throws Exception { } if (!pass) - throw new Fault("test9 failed"); + throw new Exception("test9 failed"); } /* @@ -495,7 +493,7 @@ public void test9() throws Exception { * * getRollbackOnly throws IllegalStateException if isActive() is false */ - +@Test public void test10() throws Exception { TestUtil.logTrace("Begin test10"); @@ -525,7 +523,7 @@ public void test10() throws Exception { } if (!pass) - throw new Fault("test10 failed"); + throw new Exception("test10 failed"); } /* @@ -538,7 +536,7 @@ public void test10() throws Exception { * getRollbackOnly will return false * */ - +@Test public void test11() throws Exception { TestUtil.logTrace("Begin test11"); @@ -572,7 +570,7 @@ public void test11() throws Exception { } if (!pass) - throw new Fault("test11 failed"); + throw new Exception("test11 failed"); } /* @@ -586,7 +584,7 @@ public void test11() throws Exception { * isActive() indicates whether a transaction is in progress Try when TX is * active */ - +@Test public void test12() throws Exception { TestUtil.logTrace("Begin test12"); @@ -615,7 +613,7 @@ public void test12() throws Exception { } if (!pass) - throw new Fault("test12 failed"); + throw new Exception("test12 failed"); } /* @@ -628,7 +626,7 @@ public void test12() throws Exception { * isActive() indicates whether a transaction is in progress Try when TX is * not active */ - +@Test public void test13() throws Exception { TestUtil.logTrace("Begin test13"); @@ -653,7 +651,7 @@ public void test13() throws Exception { } if (!pass) - throw new Fault("test13 failed"); + throw new Exception("test13 failed"); } /* @@ -668,7 +666,7 @@ public void test13() throws Exception { * runtime throws an exception defined to cause a transaction rollback, it * must mark the transaction for rollback. */ - +@Test public void test14() throws Exception { TestUtil.logTrace("Begin test14"); @@ -709,7 +707,7 @@ public void test14() throws Exception { } if (!pass) - throw new Fault("test14 failed"); + throw new Exception("test14 failed"); } /* @@ -724,7 +722,7 @@ public void test14() throws Exception { * * */ - +@Test public void test15() throws Exception { TestUtil.logTrace("Begin test15"); @@ -765,7 +763,7 @@ public void test15() throws Exception { } if (!pass) - throw new Fault("test15 failed"); + throw new Exception("test15 failed"); } /* @@ -776,6 +774,7 @@ public void test15() throws Exception { * * @test_Strategy: */ +@Test public void createEntityManagerSynchronizationTypeMapIllegalStateExceptionTest() throws Exception { boolean pass1 = false; @@ -811,7 +810,7 @@ public void createEntityManagerSynchronizationTypeMapIllegalStateExceptionTest() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "createEntityManagerSynchronizationTypeMapIllegalStateExceptionTest failed"); } } @@ -825,8 +824,8 @@ public void createEntityManagerSynchronizationTypeMapIllegalStateExceptionTest() */ @SetupMethod(name = "setupOnly") @CleanupMethod(name = "cleanupOnly") - - public void createEntityManagerSynchronizationTypeIllegalStateExceptionTest() +@Test +public void createEntityManagerSynchronizationTypeIllegalStateExceptionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -860,7 +859,7 @@ public void createEntityManagerSynchronizationTypeIllegalStateExceptionTest() } if (!pass1 || !pass2) { - throw new Fault( + throw new Exception( "createEntityManagerSynchronizationTypeIllegalStateExceptionTest failed"); } } @@ -870,6 +869,7 @@ public void cleanupOnly() throws Exception { super.cleanup(); } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/discriminatorColumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/discriminatorColumn/Client.java index 07db147185..e9bfd86b4f 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/discriminatorColumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/discriminatorColumn/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +34,18 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + + String sTestCase ="testcase"; public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -59,12 +60,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -75,6 +76,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @DiscriminatorColumn annotation */ + @Test public void discriminatorColumnTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -191,10 +193,11 @@ public void discriminatorColumnTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("discriminatorColumnTest failed"); + throw new Exception("discriminatorColumnTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/enumerated/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/enumerated/Client.java index a3164bbaed..920ac8e2a3 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/enumerated/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/enumerated/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +34,19 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -59,12 +61,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -75,6 +77,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @Enumerated annotation */ + @Test public void enumeratedTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -190,10 +193,11 @@ public void enumeratedTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("enumeratedTest failed"); + throw new Exception("enumeratedTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/id/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/id/Client.java index a46aab3471..da2a3a2ec4 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/id/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/id/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +34,19 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -59,12 +61,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -75,6 +77,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @Id annotation */ + @Test public void idTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -189,10 +192,11 @@ public void idTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("idTest failed"); + throw new Exception("idTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/index/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/index/Client.java index 2a86c6cb58..f8fddc4912 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/index/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/index/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +36,19 @@ public class Client extends PMClientBase { private static final long serialVersionUID = 22L; String schemaGenerationDir = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -61,12 +63,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -77,6 +79,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @Index annotation */ + @Test public void indexTest() throws Exception { boolean pass1a = false; boolean pass1b = false; @@ -272,10 +275,11 @@ public void indexTest() throws Exception { // !pass2c || // !pass2d || !pass3 || !pass4) { - throw new Fault("indexTest failed"); + throw new Exception("indexTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/joinTable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/joinTable/Client.java index cd4dbb5107..b5a9a89f28 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/joinTable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/joinTable/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -34,20 +37,19 @@ public class Client extends PMClientBase { private static final long serialVersionUID = 22L; String schemaGenerationDir = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -62,12 +64,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -78,6 +80,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @JoinTable annotation */ + @Test public void joinTableTest() throws Exception { boolean pass1a = false; boolean pass1b = false; @@ -327,10 +330,11 @@ public void joinTableTest() throws Exception { if (!pass1a || !pass1b || !pass1c || !pass1d || !pass1e || !pass2a || !pass2b || !pass2c || !pass2d || !pass2e || !pass3 || !pass4 || !pass5) { - throw new Fault("joinTableTest failed"); + throw new Exception("joinTableTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/orderColumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/orderColumn/Client.java index d7878cf00b..86e97d5ed7 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/orderColumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/orderColumn/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -36,20 +39,19 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; Employee expectedEmployee = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -64,12 +66,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -80,6 +82,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @OrderColumn annotation */ + @Test public void orderColumnTest() throws Exception { boolean pass1a = false; boolean pass1b = false; @@ -265,10 +268,11 @@ public void orderColumnTest() throws Exception { TestUtil.logTrace("pass5:" + pass5); if (!pass1a || !pass1b || !pass1c || !pass2a || !pass2b || !pass2c || !pass3 || !pass4 || !pass5) { - throw new Fault("orderColumnTest failed"); + throw new Exception("orderColumnTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/secondaryTable/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/secondaryTable/Client.java index 2c1ee3e8e7..704df3db88 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/secondaryTable/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/secondaryTable/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +36,19 @@ public class Client extends PMClientBase { private static final long serialVersionUID = 22L; String schemaGenerationDir = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -61,12 +63,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -77,6 +79,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @SecondaryTable annotation */ + @Test public void secondaryTableTest() throws Exception { boolean pass1a = false; boolean pass1b = false; @@ -221,10 +224,11 @@ public void secondaryTableTest() throws Exception { TestUtil.logTrace("pass4:" + pass4); if (!pass1a || !pass1b || !pass1c || !pass2a || !pass2b || !pass2c || !pass3 || !pass4) { - throw new Fault("secondaryTableTest failed"); + throw new Exception("secondaryTableTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/sequenceGenerator/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/sequenceGenerator/Client.java index 6722aa2013..8aa5021798 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/sequenceGenerator/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/sequenceGenerator/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -35,24 +38,23 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; boolean supportSequence; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } /* * @class.setup_props: db.supports.sequence; */ - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); - supportSequence = Boolean.valueOf(p.getProperty("db.supports.sequence")); + super.setup(); + supportSequence = Boolean.valueOf(System.getProperty("db.supports.sequence")); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -67,12 +69,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -83,6 +85,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @SequenceGenerator annotation */ + @Test public void sequenceGeneratorTest() throws Exception { if (!supportSequence) { TestUtil.logMsg( @@ -215,10 +218,11 @@ public void sequenceGeneratorTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1a || !pass1b || !pass2a || !pass2b || !pass3 || !pass4) { - throw new Fault("sequenceGeneratorTest failed"); + throw new Exception("sequenceGeneratorTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/table/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/table/Client.java index 4cb07e86f3..a6ef1aaa40 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/table/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/table/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -19,7 +19,10 @@ import java.io.File; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -29,20 +32,18 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + + String sTestCase ="testcase"; - public Client() { - } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); + public Client() { } - public void setup(String[] args, Properties p) throws Exception { +@BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -57,12 +58,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -73,6 +74,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @Table annotation */ + @Test public void tableTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -181,10 +183,11 @@ public void tableTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("tableTest failed"); + throw new Exception("tableTest failed"); } } +@AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/tableGenerator/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/tableGenerator/Client.java index 6966e79b40..bf0c4be0e9 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/tableGenerator/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/tableGenerator/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +36,19 @@ public class Client extends PMClientBase { private static final long serialVersionUID = 22L; String schemaGenerationDir = null; + + String sTestCase ="testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -61,12 +63,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(false); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -77,6 +79,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @TableGenerator annotation */ + @Test public void tableGeneratorTest() throws Exception { boolean pass1a = false; boolean pass1b = false; @@ -213,10 +216,11 @@ public void tableGeneratorTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1a || !pass1b || !pass1c || !pass2a || !pass3 || !pass4) { - throw new Fault("tableGeneratorTest failed"); + throw new Exception("tableGeneratorTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(true); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/temporal/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/temporal/Client.java index 04c78616f5..7f2a06d702 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/temporal/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/temporal/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -22,7 +22,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -32,20 +35,18 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + + String sTestCase ="testcase"; - public Client() { - } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); + public Client() { } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -60,12 +61,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -76,6 +77,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @Version annotation */ + @Test public void temporalTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -194,10 +196,11 @@ public void temporalTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("temporalTest failed"); + throw new Exception("temporalTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/uniqueConstraint/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/uniqueConstraint/Client.java index a844d0d7cc..b11fd20b0c 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/uniqueConstraint/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/uniqueConstraint/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -33,20 +36,18 @@ public class Client extends PMClientBase { private static final long serialVersionUID = 22L; String schemaGenerationDir = null; + + String sTestCase ="testcase"; - public Client() { - } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); + public Client() { } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -61,12 +62,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -77,6 +78,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @UniqueConstraint annotation */ + @Test public void uniqueConstraintTest() throws Exception { boolean pass1a = false; boolean pass1b = false; @@ -215,10 +217,11 @@ public void uniqueConstraintTest() throws Exception { TestUtil.logTrace("pass4:" + pass4); if (!pass1a || !pass1b || /* !pass2a || */ !pass2b || !pass3 || !pass4) { - throw new Fault("uniqueConstraintTest failed"); + throw new Exception("uniqueConstraintTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/version/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/version/Client.java index fdb3a2a612..88a2e37cd5 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/version/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/annotations/version/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -21,7 +21,10 @@ import java.util.List; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -31,20 +34,18 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + String sTestCase = "testcase"; + public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -59,12 +60,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -75,6 +76,7 @@ public void setup(String[] args, Properties p) throws Exception { * * @test_Strategy: Test the @Version annotation */ + @Test public void versionTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -192,10 +194,11 @@ public void versionTest() throws Exception { TestUtil.logTrace("pass3:" + pass3); TestUtil.logTrace("pass4:" + pass4); if (!pass1 || !pass2 || !pass3 || !pass4) { - throw new Fault("versionTest failed"); + throw new Exception("versionTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/scripts/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/scripts/Client.java index cc163565c1..f48e6d5ab1 100644 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/scripts/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/se/schemaGeneration/scripts/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -30,7 +30,10 @@ import java.io.Reader; import java.util.Properties; -import com.sun.javatest.Status; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; @@ -40,20 +43,16 @@ public class Client extends PMClientBase { String schemaGenerationDir = null; + String sTestCase = "testcase"; public Client() { } - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - public void setup(String[] args, Properties p) throws Exception { + @BeforeEach + public void setup() throws Exception { TestUtil.logTrace("setup"); try { - super.setup(args, p); + super.setup(); schemaGenerationDir = System.getProperty("user.dir"); if (!schemaGenerationDir.endsWith(File.separator)) { @@ -68,12 +67,12 @@ public void setup(String[] args, Properties p) throws Exception { TestUtil.logMsg("Create new directory "); if (!f.mkdir()) { String msg = "Could not mkdir:" + f.getAbsolutePath(); - throw new Fault(msg); + throw new Exception(msg); } removeTestData(); } catch (Exception e) { TestUtil.logErr("Exception: ", e); - throw new Fault("Setup failed:", e); + throw new Exception("Setup failed:", e); } } @@ -87,6 +86,7 @@ public void setup(String[] args, Properties p) throws Exception { * @test_Strategy: create scripts via createEntityManagerFactory using a URL * location */ + @Test public void scriptsURLTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -128,7 +128,7 @@ public void scriptsURLTest() throws Exception { pass1 = findDataInFile(f1, "create table schemaGenSimple"); pass2 = findDataInFile(f2, "drop table schemaGenSimple"); if (!pass1 || !pass2) { - throw new Fault("scriptsURLTest failed"); + throw new Exception("scriptsURLTest failed"); } } @@ -141,6 +141,7 @@ public void scriptsURLTest() throws Exception { * @test_Strategy: create scripts via createEntityManagerFactory using a * PrintWriter */ + @Test public void scriptsPrintWriterTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -201,7 +202,7 @@ public void scriptsPrintWriterTest() throws Exception { pass1 = findDataInFile(f1, "create table schemaGenSimple"); pass2 = findDataInFile(f2, "drop table schemaGenSimple"); if (!pass1 || !pass2) { - throw new Fault("scriptsPrintWriterTest failed"); + throw new Exception("scriptsPrintWriterTest failed"); } } @@ -216,6 +217,7 @@ public void scriptsPrintWriterTest() throws Exception { * @test_Strategy: create scripts via Persistence.generateSchema using a URL * location */ + @Test public void scriptsURL2Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -254,7 +256,7 @@ public void scriptsURL2Test() throws Exception { pass1 = findDataInFile(f1, "create table schemaGenSimple"); pass2 = findDataInFile(f2, "drop table schemaGenSimple"); if (!pass1 || !pass2) { - throw new Fault("scriptsURL2Test failed"); + throw new Exception("scriptsURL2Test failed"); } } @@ -269,6 +271,7 @@ public void scriptsURL2Test() throws Exception { * @test_Strategy: create scripts via Persistence.generateSchema using a * PrintWriter */ + @Test public void scriptsPrintWriter2Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -326,7 +329,7 @@ public void scriptsPrintWriter2Test() throws Exception { pass1 = findDataInFile(f1, "create table schemaGenSimple"); pass2 = findDataInFile(f2, "drop table schemaGenSimple"); if (!pass1 || !pass2) { - throw new Fault("scriptsPrintWriter2Test failed"); + throw new Exception("scriptsPrintWriter2Test failed"); } } @@ -339,6 +342,7 @@ public void scriptsPrintWriter2Test() throws Exception { * @test_Strategy: create scripts and generate the schema via * createEntityManagerFactory using a URL location */ + @Test public void databaseAndScriptsURLTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -404,7 +408,7 @@ public void databaseAndScriptsURLTest() throws Exception { TestUtil.logErr("Received unexpected exception", t); } if (!pass1 || !pass2 || !pass3) { - throw new Fault("databaseAndScriptsURLTest failed"); + throw new Exception("databaseAndScriptsURLTest failed"); } } @@ -416,6 +420,7 @@ public void databaseAndScriptsURLTest() throws Exception { * @test_Strategy: create scripts and generate the schema via * createEntityManagerFactory using a PrintWriter */ + @Test public void databaseAndScriptsPrintWriterTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -498,7 +503,7 @@ public void databaseAndScriptsPrintWriterTest() throws Exception { TestUtil.logErr("Received unexpected exception", t); } if (!pass1 || !pass2 || !pass3) { - throw new Fault("databaseAndScriptsPrintWriterTest failed"); + throw new Exception("databaseAndScriptsPrintWriterTest failed"); } } @@ -513,6 +518,7 @@ public void databaseAndScriptsPrintWriterTest() throws Exception { * @test_Strategy: create scripts and generate the schema via * Persistence.generateSchema using a URL location */ + @Test public void databaseAndScriptsURL2Test() throws Exception { boolean pass = false; @@ -567,7 +573,7 @@ public void databaseAndScriptsURL2Test() throws Exception { TestUtil.logErr("Received unexpected exception", t); } if (!pass) { - throw new Fault("databaseAndScriptsURL2Test failed"); + throw new Exception("databaseAndScriptsURL2Test failed"); } } @@ -582,6 +588,7 @@ public void databaseAndScriptsURL2Test() throws Exception { * @test_Strategy: create scripts and generate the schema via * Persistence.generateSchema using a PrintWriter */ + @Test public void databaseAndScriptsPrintWriter2Test() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -662,7 +669,7 @@ public void databaseAndScriptsPrintWriter2Test() throws Exception { pass2 = findDataInFile(f1, "create table schemaGenSimple"); pass3 = findDataInFile(f2, "drop table schemaGenSimple"); if (!pass1 || !pass2 || !pass3) { - throw new Fault("databaseAndScriptsPrintWriter2Test failed"); + throw new Exception("databaseAndScriptsPrintWriter2Test failed"); } } @@ -677,6 +684,7 @@ public void databaseAndScriptsPrintWriter2Test() throws Exception { * @test_Strategy: create scripts and generate the schema via * Persistence.generateSchema using a PrintWriter */ + @Test public void databaseCreateTest() throws Exception { boolean pass = false; @@ -716,7 +724,7 @@ public void databaseCreateTest() throws Exception { } if (!pass) { - throw new Fault("databaseCreateTest failed"); + throw new Exception("databaseCreateTest failed"); } } @@ -732,6 +740,7 @@ public void databaseCreateTest() throws Exception { * @test_Strategy: create a create script then use a URL location to execute * it */ + @Test public void executeCreateScriptURLTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -801,7 +810,7 @@ public void executeCreateScriptURLTest() throws Exception { TestUtil.logErr("Received unexpected exception", t); } if (!pass1 || !pass2) { - throw new Fault("executeCreateScriptURLTest failed"); + throw new Exception("executeCreateScriptURLTest failed"); } } @@ -816,6 +825,7 @@ public void executeCreateScriptURLTest() throws Exception { * @test_Strategy: create a create script then use a Reader to load and * execute it */ + @Test public void executeCreateScriptReaderTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -898,7 +908,7 @@ public void executeCreateScriptReaderTest() throws Exception { TestUtil.logErr("Received unexpected exception", t); } if (!pass1 || !pass2) { - throw new Fault("executeCreateScriptReaderTest failed"); + throw new Exception("executeCreateScriptReaderTest failed"); } } @@ -914,6 +924,7 @@ public void executeCreateScriptReaderTest() throws Exception { * * @test_Strategy: create drop script using a URL location and execute it */ + @Test public void executeDropScriptURLTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1005,7 +1016,7 @@ public void executeDropScriptURLTest() throws Exception { } if (!pass1 || !pass2 || !pass3) { - throw new Fault("executeDropScriptURLTest failed"); + throw new Exception("executeDropScriptURLTest failed"); } } @@ -1020,6 +1031,7 @@ public void executeDropScriptURLTest() throws Exception { * @test_Strategy: create drop script then use a Reader to load and execute * it. */ + @Test public void executeDropScriptReaderTest() throws Exception { boolean pass1 = false; boolean pass2 = false; @@ -1124,10 +1136,11 @@ public void executeDropScriptReaderTest() throws Exception { pass3 = true; } if (!pass1 || !pass2 || !pass3) { - throw new Fault("executeDropScriptReaderTest failed"); + throw new Exception("executeDropScriptReaderTest failed"); } } + @AfterEach public void cleanup() throws Exception { TestUtil.logTrace("cleanup"); removeTestData(); From f64a715a55affac0aef700ed42f75ab3a822e0e2 Mon Sep 17 00:00:00 2001 From: Gurunandan Rao Date: Sun, 10 Sep 2023 22:39:09 +0530 Subject: [PATCH 02/20] new client files. Signed-off-by: Gurunandan Rao --- .../core/StoredProcedureQuery/ClientIT1.java | 2283 +++++ .../core/StoredProcedureQuery/ClientIT2.java | 562 ++ .../annotations/access/field/ClientIT1.java | 1037 ++ .../annotations/access/field/ClientIT2.java | 106 + .../annotations/access/field/ClientIT3.java | 115 + .../annotations/access/field/ClientIT4.java | 382 + .../access/property/ClientIT2.java | 118 + .../jpa/core/annotations/basic/ClientIT1.java | 592 ++ .../jpa/core/annotations/basic/ClientIT2.java | 842 ++ .../elementcollection/ClientIT1.java | 211 + .../elementcollection/ClientIT2.java | 215 + .../core/annotations/mapkey/ClientIT1.java | 202 + .../core/annotations/mapkey/ClientIT2.java | 457 + .../core/annotations/orderby/ClientIT1.java | 483 + .../core/annotations/orderby/ClientIT2.java | 284 + .../core/annotations/orderby/ClientIT3.java | 220 + .../annotations/ordercolumn/ClientIT1.java | 287 + .../{Client.java => ClientIT2.java} | 143 +- .../annotations/tableGenerator/ClientIT1.java | 100 + .../annotations/tableGenerator/ClientIT2.java | 101 + .../annotations/tableGenerator/ClientIT3.java | 101 + .../annotations/tableGenerator/ClientIT4.java | 98 + .../core/annotations/version/ClientIT1.java | 277 + .../core/annotations/version/ClientIT2.java | 276 + .../core/annotations/version/ClientIT3.java | 272 + .../core/annotations/version/ClientIT4.java | 185 + .../CriteriaBuilder/ClientIT1.java | 401 + .../CriteriaBuilder/ClientIT2.java | 3528 +++++++ .../CriteriaBuilder/ClientIT3.java | 1037 ++ .../CriteriaBuilder/ClientIT4.java | 1248 +++ .../CriteriaBuilder/ClientIT5.java | 2967 ++++++ .../CriteriaBuilder/ClientIT6.java | 1526 +++ .../CriteriaBuilder/ClientIT7.java | 184 + .../CriteriaBuilder/ClientIT8.java | 271 + .../criteriaapi/CriteriaQuery/ClientIT1.java | 549 + .../criteriaapi/CriteriaQuery/ClientIT2.java | 199 + .../criteriaapi/CriteriaQuery/ClientIT3.java | 1447 +++ .../criteriaapi/CriteriaQuery/ClientIT4.java | 300 + .../criteriaapi/CriteriaQuery/ClientIT5.java | 1126 +++ .../criteriaapi/CriteriaQuery/ClientIT6.java | 128 + .../criteriaapi/CriteriaQuery/ClientIT7.java | 129 + .../jpa/core/criteriaapi/From/ClientIT1.java | 425 + .../jpa/core/criteriaapi/From/ClientIT2.java | 335 + .../jpa/core/criteriaapi/From/ClientIT3.java | 715 ++ .../jpa/core/criteriaapi/From/ClientIT4.java | 417 + .../jpa/core/criteriaapi/Join/ClientIT1.java | 400 + .../jpa/core/criteriaapi/Join/ClientIT2.java | 1463 +++ .../jpa/core/criteriaapi/Join/ClientIT3.java | 375 + .../jpa/core/criteriaapi/Root/ClientIT1.java | 426 + .../jpa/core/criteriaapi/Root/ClientIT2.java | 249 + .../jpa/core/criteriaapi/Root/ClientIT3.java | 629 ++ .../jpa/core/criteriaapi/Root/ClientIT4.java | 248 + .../ClientIT1.java} | 5275 ++++++---- .../criteriaapi/metamodelquery/ClientIT2.java | 8909 +++++++++++++++++ .../criteriaapi/metamodelquery/ClientIT3.java | 8909 +++++++++++++++++ .../criteriaapi/metamodelquery/ClientIT4.java | 8909 +++++++++++++++++ .../jpa/core/criteriaapi/misc/ClientIT1.java | 722 ++ .../jpa/core/criteriaapi/misc/ClientIT2.java | 1037 ++ .../jpa/core/criteriaapi/misc/ClientIT3.java | 549 + .../parameter/{Client.java => ClientIT1.java} | 336 +- .../core/criteriaapi/parameter/ClientIT2.java | 407 + .../core/criteriaapi/strquery/ClientIT1.java | 207 + .../core/criteriaapi/strquery/ClientIT2.java | 3257 ++++++ .../core/criteriaapi/strquery/ClientIT3.java | 1137 +++ .../core/criteriaapi/strquery/ClientIT4.java | 262 + .../core/criteriaapi/strquery/ClientIT5.java | 1258 +++ .../jpa/core/entityManager/ClientIT1.java | 1328 +++ .../jpa/core/entityManager/ClientIT2.java | 564 ++ .../jpa/core/entityManager/ClientIT3.java | 486 + .../{Client.java => ClientIT1.java} | 273 +- .../jpa/core/entityManager2/ClientIT2.java | 307 + .../core/entityManagerFactory/ClientIT1.java | 958 ++ .../core/entityManagerFactory/ClientIT2.java | 181 + .../core/entityManagerFactory/ClientIT3.java | 456 + .../apitests/{Client.java => ClientIT1.java} | 415 +- .../jpa/core/query/apitests/ClientIT2.java | 106 + .../jpa/core/query/apitests/ClientIT3.java | 342 + .../jpa/core/query/flushmode/ClientIT1.java | 176 + .../jpa/core/query/flushmode/ClientIT2.java | 332 + .../jpa/core/query/flushmode/ClientIT3.java | 90 + .../jpa/core/query/language/ClientIT1.java | 3497 +++++++ .../jpa/core/query/language/ClientIT2.java | 1703 ++++ .../jpa/core/query/language/ClientIT3.java | 1149 +++ .../jpa/core/query/language/ClientIT4.java | 860 ++ .../jpa/core/query/language/ClientIT5.java | 90 + .../jpa/core/query/language/ClientIT6.java | 92 + .../parameter/{Client.java => ClientIT1.java} | 256 +- .../jpa/core/query/parameter/ClientIT2.java | 266 + .../jpa/core/types/generator/ClientIT1.java | 443 + .../jpa/core/types/generator/ClientIT2.java | 162 + .../jpa/core/types/generator/ClientIT3.java | 164 + .../jpa/core/types/generator/ClientIT4.java | 159 + .../jpa/core/types/property/ClientIT1.java | 967 ++ .../jpa/core/types/property/ClientIT2.java | 147 + .../{Client.java => ClientIT.java} | 132 +- .../{Client.java => ClientIT1.java} | 65 +- .../jpa/se/resource_local/ClientIT2.java | 108 + 97 files changed, 84769 insertions(+), 3350 deletions(-) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT3.java create mode 100755 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT1.java rename jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/{Client.java => ClientIT2.java} (75%) mode change 100755 => 100644 create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT5.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT6.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT7.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT8.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT5.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT6.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaQuery/ClientIT7.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/From/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Join/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/Root/ClientIT4.java rename jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/{strquery/Client.java => metamodelquery/ClientIT1.java} (67%) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/metamodelquery/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/misc/ClientIT3.java rename jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/parameter/{Client.java => ClientIT1.java} (59%) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/parameter/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/strquery/ClientIT5.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager/ClientIT3.java rename jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager2/{Client.java => ClientIT1.java} (85%) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManager2/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/entityManagerFactory/ClientIT3.java rename jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/{Client.java => ClientIT1.java} (93%) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/apitests/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/flushmode/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/ClientIT5.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/language/ClientIT6.java rename jpa/src/main/java/com/sun/ts/tests/jpa/core/query/parameter/{Client.java => ClientIT1.java} (74%) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/query/parameter/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/ClientIT2.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/ClientIT3.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/types/generator/ClientIT4.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/types/property/ClientIT1.java create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/core/types/property/ClientIT2.java rename jpa/src/main/java/com/sun/ts/tests/jpa/se/entityManagerFactory/{Client.java => ClientIT.java} (54%) rename jpa/src/main/java/com/sun/ts/tests/jpa/se/resource_local/{Client.java => ClientIT1.java} (91%) create mode 100644 jpa/src/main/java/com/sun/ts/tests/jpa/se/resource_local/ClientIT2.java diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT1.java new file mode 100644 index 0000000000..baf0d0acd6 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT1.java @@ -0,0 +1,2283 @@ +/* + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.StoredProcedureQuery; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.NoResultException; +import jakarta.persistence.NonUniqueResultException; +import jakarta.persistence.Parameter; +import jakarta.persistence.ParameterMode; +import jakarta.persistence.Query; +import jakarta.persistence.StoredProcedureQuery; +import jakarta.persistence.TemporalType; +import jakarta.persistence.TransactionRequiredException; + +public class ClientIT1 extends Client { + + public ClientIT1() { + } + + + /* + * setup() is called before each test + * + * @class.setup_props: jdbc.db; + */ + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeTestData(); + createEmployeeTestData(); + dataBaseName = System.getProperty("jdbc.db"); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: executeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1557; PERSISTENCE:SPEC:1515; + * PERSISTENCE:SPEC:1566; PERSISTENCE:SPEC:1568; PERSISTENCE:SPEC:1565; + * PERSISTENCE:SPEC:1572; PERSISTENCE:SPEC:1576; PERSISTENCE:SPEC:1577; + * PERSISTENCE:SPEC:1578; PERSISTENCE:SPEC:1580; + * + * @test_Strategy: + * + */ + @Test + public void executeTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + + try { + getEntityTransaction().begin(); + try { + TestUtil.logMsg("Testing using name,class"); + clearCache(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(1, void.class, + ParameterMode.REF_CURSOR); + } + TestUtil.logTrace("executing:" + spq.toString()); + if (spq.execute()) { + + List listOfList = getResultSetsFromStoredProcedure(spq); + if (listOfList.size() == 1) { + List expected = new ArrayList(); + for (Employee e : empRef) { + expected.add(e.getId()); + } + pass1 = verifyEmployeeIds(expected, listOfList); + } else { + TestUtil.logErr( + "Did not get the correct number of result sets returned, expected: 1, actual:" + + listOfList.size()); + } + } else { + TestUtil.logErr("Expected execute() to return true, actual: false"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + try { + TestUtil.logMsg("Testing using name,result mapping"); + clearCache(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdFNameLNameFromRS", + "id-firstname-lastname"); + spq.registerStoredProcedureParameter(1, Integer.class, + ParameterMode.IN); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(2, void.class, + ParameterMode.REF_CURSOR); + } + spq.setParameter(1, 1); + if (spq.execute()) { + + List listOfList = getResultSetsFromStoredProcedure(spq); + if (listOfList.size() == 1) { + List expected = new ArrayList(); + expected.add(new Employee(emp0.getId(), emp0.getFirstName(), + emp0.getLastName())); + pass2 = verifyListOfListEmployees(expected, listOfList); + } else { + TestUtil.logErr( + "Did not get the correct number of result sets returned, expected: 1, actual:" + + listOfList.size()); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + try { + TestUtil.logMsg("Testing using named stored procedure"); + clearCache(); + StoredProcedureQuery spq; + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace( + "Calling refcursor specific named stored procedure query"); + spq = getEntityManager().createNamedStoredProcedureQuery( + "get-id-firstname-lastname-refcursor"); + } else { + spq = getEntityManager() + .createNamedStoredProcedureQuery("get-id-firstname-lastname"); + } + spq.setParameter(1, 1); + if (spq.execute()) { + List listOfList = getResultSetsFromStoredProcedure(spq); + if (listOfList.size() == 1) { + List expected = new ArrayList(); + expected.add(new Employee(emp0.getId(), emp0.getFirstName(), + emp0.getLastName())); + pass3 = verifyListOfListEmployees(expected, listOfList); + } else { + TestUtil.logErr( + "Did not get the correct number of result sets returned, expected: 1, actual:" + + listOfList.size()); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("executeTest failed"); + } + + } + + /* + * @testName: getOutputParameterValueIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1547; PERSISTENCE:SPEC:1569; + * PERSISTENCE:SPEC:1570; PERSISTENCE:SPEC:1583; + * + * @test_Strategy: + * + */ + @Test + public void getOutputParameterValueIntTest() throws Exception { + boolean pass2 = false; + boolean pass4 = false; + boolean pass6 = false; + + Object oActual = null; + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Get the value from an OUT only parameter"); + StoredProcedureQuery spq3 = getEntityManager() + .createStoredProcedureQuery("GetEmpOneFirstNameFromOut"); + spq3.registerStoredProcedureParameter(1, String.class, ParameterMode.OUT); + if (!spq3.execute()) { + + oActual = spq3.getOutputParameterValue(1); + if (oActual instanceof String) { + String actual = (String) oActual; + if (actual.equals(emp0.getFirstName())) { + TestUtil.logTrace("Received expected result:" + actual); + pass6 = true; + } else { + TestUtil.logErr("Expected result: " + emp0.getFirstName() + + ", actual:" + actual); + } + } else { + TestUtil.logErr("Did not get instance of String, instead:" + oActual); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + try { + TestUtil.logMsg("Get the value from an IN and OUT parameter"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq1.setParameter(1, 1); + if (!spq1.execute()) { + + oActual = spq1.getOutputParameterValue(2); + if (oActual instanceof String) { + String actual = (String) oActual; + if (actual.equals(emp0.getFirstName())) { + TestUtil.logTrace("Received expected result:" + actual); + pass2 = true; + } else { + TestUtil.logErr("Expected result: " + emp0.getFirstName() + + ", actual:" + actual); + } + } else { + TestUtil.logErr("Did not get instance of String, instead:" + oActual); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + try { + TestUtil.logMsg("Get the value from an INOUT parameter"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq2.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq2.setParameter(1, "1"); + + if (!spq2.execute()) { + + oActual = spq2.getOutputParameterValue(1); + if (oActual instanceof String) { + String actual = (String) oActual; + if (actual.equals(emp0.getLastName())) { + TestUtil.logTrace("Received expected result:" + actual); + pass4 = true; + } else { + TestUtil.logErr("Expected result: " + emp0.getLastName() + + ", actual:" + actual); + } + } else { + TestUtil.logErr("Expected Integer to be returned, actual:" + oActual); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass2 || !pass4 || !pass6) { + throw new Exception("getOutputParameterValueIntTest failed"); + } + + } + + /* + * @testName: getOutputParameterValueIntIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1548; PERSISTENCE:SPEC:1302.4; + * + * @test_Strategy: + * + */ + @Test + public void getOutputParameterValueIntIllegalArgumentExceptionTest() + throws Exception { + boolean pass2 = false; + boolean pass4 = false; + + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Get a value that does not exist"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq1.setParameter(1, 1); + + if (!spq1.execute()) { + try { + spq1.getOutputParameterValue(99); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + if (getEntityTransaction().getRollbackOnly() != true) { + pass2 = true; + TestUtil.logTrace("Transaction was not marked for rollback"); + } else { + TestUtil.logErr( + "Transaction was marked for rollback and should not have been"); + } + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + TestUtil.logMsg("Get the value from an IN parameter"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq2.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq2.setParameter(1, "1"); + + if (!spq2.execute()) { + try { + spq2.getOutputParameterValue(99); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass4 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass2 || !pass4) { + throw new Exception( + "getOutputParameterValueIntIllegalArgumentExceptionTest failed"); + } + + } + + /* + * @testName: getFirstResultTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1585; PERSISTENCE:JAVADOC:3482; + * PERSISTENCE:SPEC:1515; + * + * @test_Strategy: + * + */ + @Test + public void getFirstResultTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(1, void.class, + ParameterMode.REF_CURSOR); + } + int num = spq.getFirstResult(); + if (num == 0) { + TestUtil + .logTrace("Received expected first result when none is set:" + num); + pass1 = true; + } else { + TestUtil + .logErr("Expected first result when none is set: 0, actual:" + num); + } + + List actual = spq.getResultList(); + num = spq.getFirstResult(); + if (num == 0) { + TestUtil.logTrace( + "Received expected first result:" + num + " after getResultList"); + pass2 = true; + } else { + TestUtil.logErr( + "Expected first result: 0, actual:" + num + " after getResultList"); + } + if (actual.size() > 0) { + pass3 = verifyListEmployees(empRef, actual); + } else { + TestUtil.logErr("getResultList() returned 0 results"); + } + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("getFirstResultTest failed"); + } + + } + + /* + * @testName: getMaxResultsTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1590; + * + * @test_Strategy: + * + */ + @Test + public void getMaxResultsTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(1, void.class, + ParameterMode.REF_CURSOR); + } + int num = spq.getMaxResults(); + if (num == Integer.MAX_VALUE) { + TestUtil.logTrace("Received expected max result:" + num); + pass1 = true; + } else { + TestUtil.logErr( + "Expected max result: " + Integer.MAX_VALUE + ", actual:" + num); + } + List actual = spq.getResultList(); + num = spq.getMaxResults(); + if (num == Integer.MAX_VALUE) { + TestUtil.logTrace( + "Received expected max result:" + num + " after getResultList"); + pass2 = true; + } else { + TestUtil.logErr("Expected max result:" + Integer.MAX_VALUE + ", actual:" + + num + " after getResultList"); + } + if (actual.size() > 0) { + pass3 = verifyListEmployees(empRef, actual); + } else { + TestUtil.logErr("getResultList() returned 0 results"); + } + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("getMaxResultsTest failed"); + } + + } + + /* + * @testName: getSingleResultTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:3482; PERSISTENCE:SPEC:1515; + * + * @test_Strategy: Get single result from returned resultset. + * + */ + @Test + public void getSingleResultTest() throws Exception { + boolean pass = false; + + try { + getEntityTransaction().begin(); + clearCache(); + + StoredProcedureQuery spq = getEntityManager().createStoredProcedureQuery( + "GetEmpIdFNameLNameFromRS", "id-firstname-lastname"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(2, void.class, + ParameterMode.REF_CURSOR); + } + spq.setParameter(1, 1); + Employee expected = new Employee(emp0.getId(), emp0.getFirstName(), + emp0.getLastName()); + Object o = spq.getSingleResult(); + if (o instanceof Employee) { + Employee actual = (Employee) o; + if (actual.equals(expected)) { + TestUtil.logTrace("Received expected result:" + actual); + pass = true; + } else { + TestUtil.logErr("Expected result:" + expected + ", actual:" + actual); + } + } else { + TestUtil.logErr("Did not get Integer result:" + o); + } + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass) { + throw new Exception("getSingleResultTest failed"); + } + + } + + /* + * @testName: getSingleResultNoResultExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:3483 + * + * @test_Strategy: Get single result from returned resultset that is empty + * + */ + @Test + public void getSingleResultNoResultExceptionTest() throws Exception { + boolean pass = false; + + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdFNameLNameFromRS"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(2, void.class, + ParameterMode.REF_CURSOR); + } + spq.setParameter(1, 99); + try { + spq.getSingleResult(); + TestUtil.logErr("Did not throw NoResultException"); + } catch (NoResultException nre) { + TestUtil.logTrace("Received expected NoResultException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass) { + throw new Exception("getSingleResultNoResultExceptionTest failed"); + } + + } + + /* + * @testName: getSingleResultNonUniqueResultExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:3484 + * + * @test_Strategy: Get single result from returned resultset that contains + * multiple values + * + */ + @Test + public void getSingleResultNonUniqueResultExceptionTest() throws Exception { + boolean pass = false; + + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(1, void.class, + ParameterMode.REF_CURSOR); + } + try { + spq.getSingleResult(); + TestUtil.logErr("Did not throw NonUniqueResultException"); + } catch (NonUniqueResultException nure) { + TestUtil.logTrace("Received expected NonUniqueResultException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass) { + throw new Exception("getSingleResultNonUniqueResultExceptionTest failed"); + } + + } + + /* + * @testName: setgetFlushModeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1586; PERSISTENCE:JAVADOC:1559; + * + * @test_Strategy: Set and Get the various flushModes of a Query + */ + @Test + public void setgetFlushModeTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + try { + TestUtil.logMsg("Testing StoredProcedureQuery"); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(1, void.class, + ParameterMode.REF_CURSOR); + } + FlushModeType fmt = spq.getFlushMode(); + if (fmt != null) { + if (fmt.equals(getEntityManager().getFlushMode())) { + TestUtil.logTrace("Setting mode to returned default mode"); + spq.setFlushMode(fmt); + TestUtil.logTrace("Setting mode to FlushModeType.COMMIT"); + spq.setFlushMode(FlushModeType.COMMIT); + fmt = spq.getFlushMode(); + if (fmt.equals(FlushModeType.COMMIT)) { + TestUtil.logTrace("Setting mode to FlushModeType.AUTO"); + spq.setFlushMode(FlushModeType.AUTO); + fmt = spq.getFlushMode(); + if (fmt.equals(FlushModeType.AUTO)) { + TestUtil.logTrace("Query object returned from setFlushMode"); + Query q = spq.setFlushMode(FlushModeType.COMMIT); + fmt = q.getFlushMode(); + if (fmt.equals(FlushModeType.COMMIT)) { + TestUtil.logTrace( + "Received expected Query FlushModeType:" + fmt.name()); + pass1 = true; + } else { + TestUtil.logErr("Expected a value of:" + + FlushModeType.COMMIT.name() + ", actual:" + fmt.name()); + } + } else { + TestUtil.logErr("Expected a value of:" + FlushModeType.AUTO.name() + + ", actual:" + fmt.name()); + } + } else { + TestUtil.logErr("Expected a default value of:" + + FlushModeType.COMMIT.name() + ", actual:" + fmt.name()); + } + } else { + TestUtil.logErr("Expected EntityManager value of:" + + getEntityManager().getFlushMode() + ", actual:" + fmt.name()); + } + } else { + TestUtil.logErr("getFlushMode return null"); + } + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing Query object returned from setFlushMode"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpASCFromRS", Employee.class); + + TestUtil.logTrace("Setting mode to FlushModeType.AUTO"); + Query q = spq2.setFlushMode(FlushModeType.AUTO); + FlushModeType fmt = q.getFlushMode(); + if (fmt.equals(FlushModeType.AUTO)) { + TestUtil.logTrace("Received expected value of:" + fmt.name()); + pass2 = true; + } else { + TestUtil.logErr("Expected a value of:" + FlushModeType.AUTO.name() + + ", actual:" + fmt.name()); + } + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass1 || !pass2) + throw new Exception("setgetFlushModeTest failed"); + } + + /* + * @testName: setLockModeIllegalStateExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1637; + * + * @test_Strategy: + */ + @Test + public void setLockModeIllegalStateExceptionTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("UpdateEmpSalaryColumn"); + try { + spq.setLockMode(LockModeType.PESSIMISTIC_READ); + TestUtil.logErr("Did not throw IllegalStateException"); + } catch (IllegalStateException ise) { + TestUtil.logTrace("Received expected IllegalStateException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass) + throw new Exception("setLockModeIllegalStateExceptionTest failed"); + } + /* + * @testName: getLockModeIllegalStateExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1589; + * + * @test_Strategy: + */ + @Test + public void getLockModeIllegalStateExceptionTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("UpdateEmpSalaryColumn"); + try { + spq.getLockMode(); + TestUtil.logErr("Did not throw IllegalStateException"); + } catch (IllegalStateException ise) { + TestUtil.logTrace("Received expected IllegalStateException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass) + throw new Exception("getLockModeIllegalStateExceptionTest failed"); + } + + /* + * @testName: setGetParameterIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1597; PERSISTENCE:JAVADOC:1574; + * + * @test_Strategy: + */ + @Test + public void setGetParameterIntTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Testing StoredProcedureQuery"); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + Parameter p = spq.getParameter(1); + int pos = p.getPosition(); + if (pos == 1) { + TestUtil.logTrace("Received expected parameter:" + pos); + pass1 = true; + } else { + TestUtil.logErr("Expected position: 1, actual:" + pos); + } + + TestUtil.logMsg("Testing Query object returned from getParameter"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + Query q = spq2.setParameter(1, 1); + p = q.getParameter(1); + pos = p.getPosition(); + if (pos == 1) { + TestUtil.logTrace("Received expected parameter:" + pos); + pass2 = true; + } else { + TestUtil.logErr("Expected position: 1, actual:" + pos); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass1 || !pass2) + throw new Exception("setGetParameterIntTest failed"); + } + + // disabling this test since Store Procedures with named parameters + // isn't supported by all DB's at this time + /* + * testName: setGetParameterStringTest assertion_ids: + * PERSISTENCE:JAVADOC:1549; PERSISTENCE:JAVADOC:1558; + * PERSISTENCE:JAVADOC:1568; PERSISTENCE:JAVADOC:1591; test_Strategy: + */ + + /* + * public void setGetParameterStringTest() throws Exception { boolean pass1 = + * false; boolean pass2 = false; boolean pass3 = false; try { + * getEntityTransaction().begin(); + * + * TestUtil.logMsg("Testing StoredProcedureQuery"); StoredProcedureQuery spq = + * getEntityManager().createStoredProcedureQuery("GetEmpFirstNameFromOut"); + * spq.registerStoredProcedureParameter("IN_PARAM", Integer.class, + * ParameterMode.IN); spq.registerStoredProcedureParameter("OUT_PARAM", + * String.class, ParameterMode.OUT); spq.setParameter("IN_PARAM", 1); + * + * Parameter p = spq.getParameter("OUT_PARAM"); Integer pos = p.getPosition(); + * if (pos == null){ TestUtil.logTrace("Received expected null"); pass1 = + * true; } else { TestUtil.logErr("Expected position: null, actual:" + pos); } + * + * spq.execute(); Object oActual = spq.getOutputParameterValue("OUT_PARAM"); + * if (oActual instanceof String) { String actual = (String) oActual; if + * (actual.equals(emp0.getFirstName())) { + * TestUtil.logTrace("Received expected result:" + actual); pass2 = true; } + * else { TestUtil.logErr("Expected result: " + emp0.getFirstName() + + * ", actual:" + actual); } } else { + * TestUtil.logErr("Did not get instance of String, instead:" + + * oActual.getClass()); } getEntityTransaction().commit(); + * + * } catch (Exception e) { TestUtil.logErr("Caught exception: ", e); } + * + * if (!pass1 || !pass2 ) throw new Exception("setGetParameterStringTest failed"); + * } + */ + + /* + * @testName: getParameterStringExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1609; PERSISTENCE:JAVADOC:1569; + * + * @test_Strategy: + */ + @Test + public void getParameterStringExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + TestUtil.logMsg("Testing StoredProcedureQuery "); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter("ID", Integer.class, + ParameterMode.IN); + spq.registerStoredProcedureParameter("FIRSTNAME", String.class, + ParameterMode.OUT); + spq.setParameter("ID", 1); + try { + spq.getParameter("DOESNOTEXIST"); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (IllegalStateException ise) { + TestUtil.logTrace("Received expected IllegalStateException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg("Testing Query object returned from getParameter"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq2.registerStoredProcedureParameter("ID", Integer.class, + ParameterMode.IN); + spq2.registerStoredProcedureParameter("FIRSTNAME", String.class, + ParameterMode.OUT); + Query q = spq2.setParameter("ID", 1); + try { + q.getParameter("DOESNOTEXIST"); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (IllegalStateException ise) { + TestUtil.logTrace("Received expected IllegalStateException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1 || !pass2) + throw new Exception("getParameterStringExceptionTest failed"); + } + + /* + * @testName: getParameterIntIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1598; + * + * @test_Strategy: + */ + @Test + public void getParameterIntIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + TestUtil.logMsg("Testing StoredProcedureQuery "); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + try { + spq.getParameter(99); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg("Testing Query object returned from getParameter"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + Query q = spq2.setParameter(1, 1); + try { + q.getParameter(99); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1 || !pass2) + throw new Exception("getParameterIntIllegalArgumentExceptionTest failed"); + } + + /* + * @testName: setParameterParameterObjectTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1562; + * + * @test_Strategy: + */ + @Test + public void setParameterParameterObjectTest() throws Exception { + boolean pass2 = false; + boolean pass4 = false; + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Testing StoredProcedureQuery "); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 99); + Parameter p = spq.getParameter(1); + spq.setParameter(p, 1); + + if (!spq.execute()) { + Object oActual = spq.getOutputParameterValue(2); + if (oActual instanceof String) { + String actual = (String) oActual; + if (actual.equals(emp0.getFirstName())) { + TestUtil.logTrace("Received expected result:" + actual); + pass2 = true; + } else { + TestUtil.logErr("Expected result: " + emp0.getFirstName() + + ", actual:" + actual); + } + } else { + TestUtil.logErr( + "Did not get instance of String, instead:" + oActual.getClass()); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Testing Query object returned from setParameter"); + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + Query q = spq2; + q.setParameter(1, 99); + Parameter p = q.getParameter(1); + q.setParameter(p, 1); + StoredProcedureQuery spq3 = (StoredProcedureQuery) q; + if (!spq3.execute()) { + Object oActual = spq3.getOutputParameterValue(2); + if (oActual instanceof String) { + String actual = (String) oActual; + if (actual.equals(emp0.getFirstName())) { + TestUtil.logTrace("Received expected result:" + actual); + pass4 = true; + } else { + TestUtil.logErr("Expected result: " + emp0.getFirstName() + + ", actual:" + actual); + } + } else { + TestUtil.logErr("Did not get instance of String, instead:" + oActual); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + + if (!pass2 || !pass4) + throw new Exception("setParameterParameterObjectTest failed"); + + } + + /* + * @testName: setParameterParameterObjectIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1563; + * + * @test_Strategy: call setParameter(Parameter, Object) using parameter from + * different query. + */ + @Test + public void setParameterParameterObjectIllegalArgumentExceptionTest() + throws Exception { + boolean pass1 = false; + try { + getEntityTransaction().begin(); + + TestUtil.logTrace("Get parameter from other stored procedure"); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq.setParameter(1, "INOUT"); + // Parameter to be used in next StoredProcedure + Parameter p = spq.getParameter(1); + + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + + try { + spq2.setParameter(p, 1); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1) + throw new Exception( + "setParameterParameterObjectIllegalArgumentExceptionTest failed"); + } + + /* + * @testName: setParameterIntObjectIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1575; + * + * @test_Strategy: + */ + @Test + public void setParameterIntObjectIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + boolean pass4 = false; + try { + getEntityTransaction().begin(); + TestUtil.logMsg( + "Testing StoredProcedureQuery with incorrect position specified"); + + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + try { + spq1.setParameter(99, 1); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil + .logMsg("Testing StoredProcedureQuery with incorrect type specified"); + + StoredProcedureQuery spq2 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq2.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq2.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + try { + spq2.setParameter(1, new java.util.Date()); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg("Testing Query object with incorrect position specified"); + StoredProcedureQuery spq3 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq3.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq3.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + Query q1 = spq3.setParameter(1, 1); + try { + spq3.setParameter(99, 1); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass3 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg("Testing Query object with incorrect type specified"); + StoredProcedureQuery spq4 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq4.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq4.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + Query q2 = spq4.setParameter(1, 1); + try { + q2.setParameter(1, new java.util.Date()); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass4 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1 || !pass2 || !pass3 || !pass4) + throw new Exception( + "setParameterIntObjectIllegalArgumentExceptionTest failed"); + } + + /* + * @testName: getParametersTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1597; PERSISTENCE:JAVADOC:1603; + * + * @test_Strategy: + */ + @Test + public void getParametersTest() throws Exception { + boolean pass1 = false; + boolean pass3 = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + Set> p1 = spq.getParameters(); + if (p1.size() == 0) { + TestUtil + .logTrace("Received expected number of parameters when non exist:" + + p1.size()); + pass1 = true; + } else { + TestUtil.logErr( + "Expected number of parameters when non exist: 0, actual:" + p1); + } + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + + if (!spq.execute()) { + Set> p2 = spq.getParameters(); + if (p2.size() == 2) { + TestUtil + .logTrace("Received expected number of parameters:" + p2.size()); + pass3 = true; + } else { + TestUtil + .logErr("Expected number of parameters: 2, actual:" + p2.size()); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass1 || !pass3) + throw new Exception("getParametersTest failed"); + + } + + /* + * @testName: setParameterIntDateTemporalTypeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1578; + * + * @test_Strategy: + */ + @Test + public void setParameterIntDateTemporalTypeTest() throws Exception { + boolean pass2 = false; + boolean pass4 = false; + try { + getEntityTransaction().begin(); + try { + TestUtil.logMsg("Testing StoredProcedureQuery"); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, Integer.class, + ParameterMode.OUT); + spq.setParameter(1, utilDate, TemporalType.DATE); + + if (!spq.execute()) { + + Object o = spq.getOutputParameterValue(2); + if (o instanceof Integer) { + Integer actual = (Integer) o; + if (actual == 1) { + TestUtil.logTrace("Received expected id:" + actual); + pass2 = true; + } else { + TestUtil.logErr("Expected id: 1, actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing Query object"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, Integer.class, + ParameterMode.OUT); + Query q = spq1; + q.setParameter(1, utilDate, TemporalType.DATE); + StoredProcedureQuery spq2 = (StoredProcedureQuery) q; + + if (!spq2.execute()) { + + Object o = spq2.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == 1) { + TestUtil.logTrace("Received expected id:" + actual); + pass4 = true; + } else { + TestUtil.logErr("Expected id: 1, actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass2 || !pass4) + throw new Exception("setParameterIntDateTemporalTypeTest failed"); + + } + + /* + * @testName: setParameterIntDateTemporalTypeIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1579; + * + * @test_Strategy: + */ + @Test + public void setParameterIntDateTemporalTypeIllegalArgumentExceptionTest() + throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + TestUtil.logMsg( + "Testing StoredProcedureQuery with incorrect position specified"); + + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + try { + spq1.setParameter(99, utilDate, TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg("Testing Query object with incorrect position specified"); + StoredProcedureQuery spq3 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq3.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + Query q1 = spq3.setParameter(1, getUtilDate()); + try { + q1.setParameter(99, utilDate, TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1 || !pass2) + throw new Exception( + "setParameterIntDateTemporalTypeIllegalArgumentExceptionTest failed"); + } + + /* + * @testName: setParameterParameterDateTemporalTypeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1566; + * + * @test_Strategy: + */ + @Test + public void setParameterParameterDateTemporalTypeTest() throws Exception { + boolean pass2 = false; + boolean pass3 = false; + boolean pass5 = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, Integer.class, ParameterMode.OUT); + spq.setParameter(1, getUtilDate(), TemporalType.DATE); + + Parameter p = spq.getParameter(1); + spq.setParameter(p, utilDate, TemporalType.DATE); + + if (!spq.execute()) { + Object o = spq.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == 1) { + TestUtil.logTrace("Received expected id:" + actual); + pass2 = true; + } else { + TestUtil.logErr("Expected id: 1, actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Testing Query object"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, Integer.class, + ParameterMode.OUT); + spq1.setParameter(1, getCalDate().getTime(), TemporalType.DATE); + + Query q = spq1; + + // override the previously set parameter + Parameter p = q.getParameter(1); + q.setParameter(p, utilDate, TemporalType.DATE); + + Parameter p2 = q.getParameter(1); + if (p.getPosition().equals(p2.getPosition()) + && p.getParameterType().equals(p2.getParameterType())) { + TestUtil.logTrace("Received expected parameter"); + pass3 = true; + } else { + TestUtil.logErr("Expected parameter:" + p + ", actual:" + p2); + } + StoredProcedureQuery spq2 = (StoredProcedureQuery) q; + if (!spq2.execute()) { + + Object o = spq2.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == emp0.getId()) { + TestUtil.logTrace("Received expected id:" + actual); + pass5 = true; + } else { + TestUtil.logErr("Expected id: 1, actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + + if (!pass2 || !pass3 || !pass5) + throw new Exception("setParameterParameterDateTemporalTypeTest failed"); + } + + /* + * @testName: + * setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1567; + * + * @test_Strategy: + */ + @Test + public void setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest() + throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + TestUtil.logTrace("Get parameter from other stored procedure"); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq.setParameter(1, "INOUT"); + // Parameter to be used in next StoredProcedure + Parameter p = spq.getParameter(1); + TestUtil.logMsg( + "Testing StoredProcedureQuery with parameter specified from another query"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Date.class, ParameterMode.IN); + spq1.setParameter(1, getUtilDate(), TemporalType.DATE); + try { + spq1.setParameter(p, getUtilDate(), TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg( + "Testing Query object with parameter specified from another query"); + StoredProcedureQuery spq3 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq3.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + Query q1 = spq3.setParameter(1, getCalDate()); + try { + q1.setParameter(p, getCalDate(), TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1 || !pass2) + throw new Exception( + "setParameterParameterDateTemporalTypeIllegalArgumentExceptionTest failed"); + } + + /* + * @testName: executeUpdateOfAnUpdateTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1580; PERSISTENCE:JAVADOC:1551; + * PERSISTENCE:SPEC:1516; PERSISTENCE:SPEC:1580; + * + * @test_Strategy: + */ + @Test + public void executeUpdateOfAnUpdateTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("UpdateEmpSalaryColumn"); + + spq.executeUpdate(); + int updateCount = spq.getUpdateCount(); + if (updateCount == -1) { + TestUtil.logTrace("Received expected update count:" + updateCount); + pass = true; + } else { + TestUtil.logErr("Expected update count: -1, actual:" + updateCount); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("executeUpdateOfAnUpdateTest failed"); + } + + /* + * @testName: executeUpdateOfADeleteTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1580; PERSISTENCE:JAVADOC:1551; + * PERSISTENCE:SPEC:1516; + * + * @test_Strategy: + */ + @Test + public void executeUpdateOfADeleteTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("DeleteAllEmp"); + spq.executeUpdate(); + int updateCount = spq.getUpdateCount(); + if (updateCount == -1) { + TestUtil.logTrace("Received expected update count:" + updateCount); + pass = true; + } else { + TestUtil.logErr("Expected update count: -1, actual:" + updateCount); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("executeUpdateOfADeleteTest failed"); + } + + /* + * @testName: executeUpdateTransactionRequiredExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1582; + * + * @test_Strategy: + */ + @Test + public void executeUpdateTransactionRequiredExceptionTest() throws Exception { + boolean pass = false; + try { + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("DeleteAllEmp"); + try { + TestUtil + .logMsg("IsActive returns:" + getEntityTransaction().isActive()); + spq.executeUpdate(); + TestUtil.logErr("Did not throw TransactionRequiredException"); + } catch (TransactionRequiredException tre) { + TestUtil.logTrace("Received expected TransactionRequiredException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("executeUpdateTransactionRequiredExceptionTest failed"); + } + + /* + * @testName: getParameterValueParameterTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1605; PERSISTENCE:JAVADOC:1630; + * + * @test_Strategy: + */ + @Test + public void getParameterValueParameterTest() throws Exception { + boolean pass1 = false; + boolean pass3 = false; + try { + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + Parameter p = spq.getParameter(1); + boolean b = spq.isBound(p); + if (b == true) { + TestUtil.logTrace("Received expected from isBound():" + b); + pass1 = true; + } else { + TestUtil.logErr("Expected result from isBound():true, actual:" + b); + } + if (!spq.execute()) { + p = spq.getParameter(1); + Object o = spq.getParameterValue(p); + if (o instanceof Integer) { + TestUtil.logTrace("Received expected parameter type: Integer"); + Integer i = (Integer) o; + if (i.equals(emp0.getId())) { + TestUtil.logTrace("Received expected parameter value:" + i); + pass3 = true; + } else { + TestUtil.logErr("Expected getParameterValue() result: " + + emp0.getId() + ", actual:" + i); + } + + } else { + TestUtil.logErr( + "Did not get instance of Integer from getParameterValue():" + o); + } + + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass1 || !pass3) + throw new Exception("getParameterValueParameterTest failed"); + + } + + /* + * @testName: getParameterValueParameterIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1606; + * + * @test_Strategy: execute getParameterValue using parameter from different + * query + */ + @Test + public void getParameterValueParameterIllegalArgumentExceptionTest() + throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq.setParameter(1, "1"); + Parameter p = spq.getParameter(1); + + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq1.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq1.setParameter(1, 1); + try { + spq1.getParameterValue(p); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception( + "getParameterValueParameterIllegalArgumentExceptionTest failed"); + + } + + /* + * @testName: getParameterValueParameterIllegalStateExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1607; PERSISTENCE:JAVADOC:1630; + * + * @test_Strategy: + */ + @Test + public void getParameterValueParameterIllegalStateExceptionTest() + throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + Parameter p = spq.getParameter(1); + boolean b = spq.isBound(p); + if (b == true) { + TestUtil.logTrace("Received expected from isBound():" + b); + pass1 = true; + } else { + TestUtil.logErr("Expected result from isBound():true, actual:" + b); + } + Parameter p2 = spq.getParameter(2); + + try { + spq.getParameterValue(p2); + TestUtil.logErr("Did not throw IllegalStateException"); + } catch (IllegalStateException iae) { + TestUtil.logTrace("Received expected IllegalStateException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass1 || !pass2) + throw new Exception( + "getParameterValueParameterIllegalStateExceptionTest failed"); + + } + + /* + * @testName: getParameterValueIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1611; PERSISTENCE:SPEC:1572; + * + * @test_Strategy: + */ + @Test + public void getParameterValueIntTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + boolean pass4 = false; + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Testing createStoredProcedureQuery"); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq.setParameter(1, "1"); + Object o = spq.getParameterValue(1); + if (o instanceof String) { + TestUtil.logTrace("Received expected parameter type: String"); + String s = (String) o; + if (s.equals("1")) { + TestUtil.logTrace("Received expected parameter value:" + s); + pass1 = true; + } else { + TestUtil + .logErr("Expected getParameterValue() result: 1, actual:" + s); + } + + } else { + TestUtil.logErr( + "Did not get instance of String from getParameterValue():" + o); + } + + if (!spq.execute()) { + o = spq.getParameterValue(1); + if (o instanceof String) { + TestUtil.logTrace("Received expected parameter type: String"); + String s = (String) o; + if (s.equals("1")) { + TestUtil.logTrace("Received expected parameter value:" + s); + pass2 = true; + } else { + TestUtil + .logErr("Expected getParameterValue() result: 1, actual:" + s); + } + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Testing createNamedStoredProcedureQuery"); + StoredProcedureQuery spq = getEntityManager() + .createNamedStoredProcedureQuery("getemplastnamefrominout"); + spq.setParameter(1, "1"); + Object o = spq.getParameterValue(1); + if (o instanceof String) { + TestUtil.logTrace("Received expected parameter type: String"); + String s = (String) o; + if (s.equals("1")) { + TestUtil.logTrace("Received expected parameter value:" + s); + pass3 = true; + } else { + TestUtil + .logErr("Expected getParameterValue() result: 1, actual:" + s); + } + + } else { + TestUtil.logErr( + "Did not get instance of String from getParameterValue():" + o); + } + + if (!spq.execute()) { + o = spq.getParameterValue(1); + if (o instanceof String) { + TestUtil.logTrace("Received expected parameter type: String"); + String s = (String) o; + if (s.equals("1")) { + TestUtil.logTrace("Received expected parameter value:" + s); + pass4 = true; + } else { + TestUtil + .logErr("Expected getParameterValue() result: 1, actual:" + s); + } + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + + if (!pass1 || !pass2 || !pass3 || !pass4) + throw new Exception("getParameterValueIntTest failed"); + + } + + /* + * @testName: getParameterValueIntIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1613; + * + * @test_Strategy: + */ + @Test + public void getParameterValueIntIllegalArgumentExceptionTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + try { + spq.getParameterValue(99); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception( + "getParameterValueIntIllegalArgumentExceptionTest failed"); + + } + + /* + * @testName: getParameterValueIntIllegalStateExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1612; + * + * @test_Strategy: + */ + @Test + public void getParameterValueIntIllegalStateExceptionTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + try { + spq.getParameterValue(2); + TestUtil.logErr("Did not throw IllegalStateException"); + } catch (IllegalStateException iae) { + TestUtil.logTrace("Received expected IllegalStateException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("getParameterValueIntIllegalStateExceptionTest failed"); + + } + + /* + * @testName: setHintStringObjectTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1560; + * + * @test_Strategy: Vendor-specific hints that are not recognized by a provider + * must be silently ignored. + */ + @Test + public void setHintStringObjectTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpFirstNameFromOut"); + spq.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT); + spq.setParameter(1, 1); + spq.getParameterValue(1); + spq.setHint("property.that.is.not.recognized", + "property.that.is.not.recognized"); + spq.execute(); + getEntityTransaction().commit(); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("setHintStringObjectTest failed"); + + } + + /* + * @testName: xmlOverridesNamedStoredProcedureQueryTest + * + * @assertion_ids: PERSISTENCE:SPEC:2239; PERSISTENCE:SPEC:2241; + * PERSISTENCE:SPEC:2242; + * + * @test_Strategy: verify xml overrides NamedStoredProcedureQuery annotation + */ + @Test + public void xmlOverridesNamedStoredProcedureQueryTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + try { + + StoredProcedureQuery spq = getEntityManager() + .createNamedStoredProcedureQuery("tobeoverridden1"); + spq.setParameter(1, 1); + Object o = spq.getParameterValue(1); + if (o instanceof Integer) { + TestUtil.logTrace("Received expected parameter type: Integer"); + Integer i = (Integer) o; + if (i.equals(1)) { + TestUtil.logTrace("Received expected parameter value:" + i); + pass1 = true; + } else { + TestUtil + .logErr("Expected getParameterValue() result: 1, actual:" + i); + } + + } else { + TestUtil.logErr( + "Did not get instance of Integer from getParameterValue():" + o); + } + + if (!spq.execute()) { + o = spq.getOutputParameterValue(2); + if (o instanceof String) { + TestUtil.logTrace("Received expected parameter type: String"); + String s = (String) o; + if (s.equals(emp0.getFirstName())) { + TestUtil.logTrace("Received expected parameter value:" + s); + pass2 = true; + } else { + TestUtil.logErr("Expected getParameterValue() result: " + + emp0.getFirstName() + ", actual:" + s); + } + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass1 || !pass2) + throw new Exception("xmlOverridesNamedStoredProcedureQueryTest failed"); + + } + + /* + * @testName: xmlOverridesSqlResultSetMappingAnnotationTest + * + * @assertion_ids: PERSISTENCE:SPEC:2243; PERSISTENCE:SPEC:2245; + * PERSISTENCE:SPEC:2246; + * + * @test_Strategy: verify xml overrides SqlResultSetMapping annotation + * + */ + @Test + public void xmlOverridesSqlResultSetMappingAnnotationTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + try { + TestUtil.logMsg("Testing using name,result mapping"); + clearCache(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdFNameLNameFromRS", + "tobeoverridden2"); + spq.registerStoredProcedureParameter(1, Integer.class, + ParameterMode.IN); + if (dataBaseName.equalsIgnoreCase(ORACLE) + || dataBaseName.equalsIgnoreCase(POSTGRESQL)) { + TestUtil.logTrace("register refcursor parameter"); + spq.registerStoredProcedureParameter(2, void.class, + ParameterMode.REF_CURSOR); + } + spq.setParameter(1, 1); + if (spq.execute()) { + + List listOfList = getResultSetsFromStoredProcedure(spq); + if (listOfList.size() == 1) { + List expected = new ArrayList(); + expected.add(new Employee(emp0.getId(), emp0.getFirstName(), + emp0.getLastName())); + pass = verifyListOfListEmployees(expected, listOfList); + } else { + TestUtil.logErr( + "Did not get the correct number of result sets returned, expected: 1, actual:" + + listOfList.size()); + } + } else { + TestUtil.logErr("Expected execute() to return true, actual: false"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception:", ex); + } + + if (!pass) { + throw new Exception("xmlOverridesSqlResultSetMappingAnnotationTest failed"); + } + + } + + private void createEmployeeTestData() { + + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Creating Employees"); + + final Date d2 = getUtilDate("2001-06-27"); + final Date d3 = getUtilDate("2002-07-07"); + final Date d4 = getUtilDate("2003-03-03"); + final Date d5 = getUtilDate(); + + emp0 = new Employee(1, "Alan", "Frechette", utilDate, (float) 35000.0); + empRef.add(emp0); + empRef.add(new Employee(2, "Arthur", "Frechette", d2, (float) 35000.0)); + empRef.add(new Employee(3, "Shelly", "McGowan", d3, (float) 50000.0)); + empRef.add(new Employee(4, "Robert", "Bissett", d4, (float) 55000.0)); + empRef.add(new Employee(5, "Stephen", "DMilla", d5, (float) 25000.0)); + for (Employee e : empRef) { + if (e != null) { + getEntityManager().persist(e); + TestUtil.logTrace("persisted employee:" + e); + } + } + + getEntityManager().flush(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception fe) { + TestUtil.logErr("Unexpected exception rolling back TX:", fe); + } + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT2.java new file mode 100644 index 0000000000..e762a86832 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/StoredProcedureQuery/ClientIT2.java @@ -0,0 +1,562 @@ +/* + * Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.StoredProcedureQuery; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +import jakarta.persistence.Parameter; +import jakarta.persistence.ParameterMode; +import jakarta.persistence.Query; +import jakarta.persistence.StoredProcedureQuery; +import jakarta.persistence.TemporalType; + +public class ClientIT2 extends Client { + + public ClientIT2() { + } + + + /* + * setupEmployee2Data() is called before each test + * + * @class.setup_props: jdbc.db; + */ + @BeforeEach + public void setupEmployee2Data() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeTestData(); + createEmployee2TestData(); + dataBaseName = System.getProperty("jdbc.db"); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + @AfterEach + public void cleanup() throws Exception { + TestUtil.logTrace("Cleanup data"); + removeTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + public List getResultSetsFromStoredProcedure(StoredProcedureQuery spq) { + TestUtil.logTrace("in getResultSetsFromStoredProcedure"); + boolean results = true; + List listOfList = new ArrayList(); + int rsnum = 1; + int rowsAffected = 0; + + do { + if (results) { + TestUtil.logTrace("Processing set:" + rsnum); + List empList = new ArrayList(); + List list = spq.getResultList(); + if (list != null) { + TestUtil.logTrace( + "Getting result set: " + (rsnum) + ", size:" + list.size()); + for (Object o : list) { + if (o instanceof Employee) { + Employee e = (Employee) o; + TestUtil.logTrace("Saving:" + e); + empList.add(e); + } else { + TestUtil.logErr("Did not get instance of Employee, instead got:" + + o.getClass().getSimpleName()); + } + } + if (empList.size() > 0) { + listOfList.add(empList); + } + } else { + TestUtil.logErr("Result set[" + rsnum + "] returned was null"); + } + rsnum++; + } else { + rowsAffected = spq.getUpdateCount(); + if (rowsAffected >= 0) + TestUtil.logTrace("rowsAffected:" + rowsAffected); + } + results = spq.hasMoreResults(); + TestUtil.logTrace("Results:" + results); + + } while (results || rowsAffected != -1); + return listOfList; + } + + public boolean verifyEmployeeIds(List expected, + List listOfList) { + boolean result = false; + int count = 0; + for (List lEmp : listOfList) { + + if (lEmp.size() > 0) { + List actual = new ArrayList(); + for (Employee e : lEmp) { + actual.add(e.getId()); + } + + if (expected.containsAll(actual) && actual.containsAll(expected) + && expected.size() == actual.size()) { + TestUtil.logTrace("Received expected result:"); + for (Integer a : actual) { + TestUtil.logTrace("id:" + a); + } + count++; + } else { + TestUtil.logErr("Did not receive expected result:"); + for (Integer e : expected) { + TestUtil.logErr(" Expected id:" + e); + } + for (Integer a : actual) { + TestUtil.logErr("Actual id:" + a); + } + } + + } else { + TestUtil.logErr("Result set that was returned had 0 length"); + } + + } + if (count == listOfList.size()) { + result = true; + } + return result; + } + + public boolean verifyListOfListEmployees(List expected, + List listOfList) { + boolean result = false; + int count = 0; + for (List lEmp : listOfList) { + + if (lEmp.size() > 0) { + List actual = new ArrayList(); + for (Employee e : lEmp) { + actual.add(e); + } + if (verifyListEmployees(expected, actual)) { + count++; + } + } else { + TestUtil.logErr("Result set that was returned had 0 length"); + } + } + if (count == listOfList.size()) { + result = true; + } + return result; + } + + public boolean verifyListEmployees(List expected, + List actual) { + boolean result = false; + if (expected.containsAll(actual) && actual.containsAll(expected) + && expected.size() == actual.size()) { + for (Employee e : expected) { + TestUtil.logTrace("Received expected result:" + e); + } + result = true; + } else { + TestUtil.logErr("Did not receive expected result:"); + for (Employee e : expected) { + TestUtil.logErr("expected employee:" + e); + } + for (Employee e : actual) { + TestUtil.logErr("actual employee :" + e); + } + } + return result; + } + + + /* + * @testName: setParameterIntCalendarTemporalTypeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1576; + * + * @test_Strategy: + */ + @Test + public void setParameterIntCalendarTemporalTypeTest() throws Exception { + boolean pass2 = false; + boolean pass4 = false; + try { + getEntityTransaction().begin(); + try { + TestUtil.logMsg("Testing StoredProcedureQuery object"); + + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + spq.registerStoredProcedureParameter(2, Integer.class, + ParameterMode.OUT); + spq.setParameter(1, calDate, TemporalType.DATE); + + if (!spq.execute()) { + Object o = spq.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == emp2.getId()) { + TestUtil.logTrace("Received expected id:" + actual); + pass2 = true; + } else { + TestUtil.logErr( + "Expected id: " + emp2.getId() + ", actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing Query object"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, Integer.class, + ParameterMode.OUT); + Query q = spq1; + q.setParameter(1, getCalDate(), TemporalType.DATE); + StoredProcedureQuery spq2 = (StoredProcedureQuery) q; + if (!spq2.execute()) { + Object o = spq2.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == 5) { + TestUtil.logTrace("Received expected id:" + actual); + pass4 = true; + } else { + TestUtil.logErr("Expected id: 5, actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass2 || !pass4) + throw new Exception("setParameterIntCalendarTemporalTypeTest failed"); + + } + + /* + * @testName: setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1577; + * + * @test_Strategy: + */ + @Test + public void setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest() + throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + TestUtil.logMsg( + "Testing StoredProcedureQuery with incorrect position specified"); + + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + try { + spq1.setParameter(99, getCalDate(), TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg("Testing Query object with incorrect position specified"); + StoredProcedureQuery spq3 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq3.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + Query q1 = spq3.setParameter(1, getCalDate(), TemporalType.DATE); + try { + q1.setParameter(99, getCalDate()); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + if (!pass1 || !pass2) + throw new Exception( + "setParameterIntCalendarTemporalTypeIllegalArgumentExceptionTest failed"); + + } + + + /* + * @testName: setParameterParameterCalendarTemporalTypeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1564; PERSISTENCE:SPEC:1576; + * + * @test_Strategy: + */ + @Test + public void setParameterParameterCalendarTemporalTypeTest() throws Exception { + boolean pass2 = false; + boolean pass3 = false; + boolean pass5 = false; + try { + TestUtil.logMsg("Testing StoredProcedure"); + getEntityTransaction().begin(); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq.registerStoredProcedureParameter(1, Calendar.class, ParameterMode.IN); + spq.registerStoredProcedureParameter(2, Integer.class, ParameterMode.OUT); + + spq.setParameter(1, getCalDate(), TemporalType.DATE); + Parameter p = spq.getParameter(1); + spq.setParameter(p, calDate, TemporalType.DATE); + + if (!spq.execute()) { + Object o = spq.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == emp2.getId()) { + TestUtil.logTrace("Received expected id:" + actual); + pass2 = true; + } else { + TestUtil + .logErr("Expected id: " + emp2.getId() + ", actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + try { + getEntityTransaction().begin(); + TestUtil.logMsg("Testing Query object"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + spq1.registerStoredProcedureParameter(2, Integer.class, + ParameterMode.OUT); + spq1.setParameter(1, getCalDate(), TemporalType.DATE); + Query q = spq1; + + Parameter p = q.getParameter(1); + q.setParameter(p, calDate, TemporalType.DATE); + Parameter p2 = q.getParameter(1); + if (p.getPosition().equals(p2.getPosition()) + && p.getParameterType().equals(p2.getParameterType())) { + TestUtil.logTrace("Received expected parameter"); + pass3 = true; + } else { + TestUtil.logErr("Expected parameter:" + p + ", actual:" + p2); + } + + StoredProcedureQuery spq2 = (StoredProcedureQuery) q; + + if (!spq2.execute()) { + Object o = spq2.getOutputParameterValue(2); + if (o instanceof Integer) { + int actual = (Integer) o; + if (actual == emp2.getId()) { + TestUtil.logTrace("Received expected id:" + actual); + pass5 = true; + } else { + TestUtil + .logErr("Expected id: " + emp2.getId() + ", actual:" + actual); + } + + } else { + TestUtil.logErr("Did not get instance of Integer back:" + o); + } + } else { + TestUtil.logErr("Expected execute() to return false, actual: true"); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } + + if (!pass2 || !pass3 || !pass5) + throw new Exception("setParameterParameterCalendarTemporalTypeTest failed"); + } + + /* + * @testName: + * setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1565; + * + * @test_Strategy: + */ + @Test + public void setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest() + throws Exception { + boolean pass1 = false; + boolean pass2 = false; + try { + getEntityTransaction().begin(); + TestUtil.logTrace("Get parameter from other stored procedure"); + StoredProcedureQuery spq = getEntityManager() + .createStoredProcedureQuery("GetEmpLastNameFromInOut"); + spq.registerStoredProcedureParameter(1, String.class, + ParameterMode.INOUT); + spq.setParameter(1, "INOUT"); + // Parameter to be used in next StoredProcedure + Parameter p = spq.getParameter(1); + + TestUtil.logMsg( + "Testing StoredProcedureQuery with parameter specified from another query"); + StoredProcedureQuery spq1 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq1.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + spq1.setParameter(1, getCalDate(), TemporalType.DATE); + try { + spq1.setParameter(p, getCalDate(), TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + TestUtil.logMsg( + "Testing Query object with parameter specified from another query"); + StoredProcedureQuery spq3 = getEntityManager() + .createStoredProcedureQuery("GetEmpIdUsingHireDateFromOut"); + spq3.registerStoredProcedureParameter(1, Calendar.class, + ParameterMode.IN); + Query q1 = spq3.setParameter(1, getCalDate()); + try { + q1.setParameter(p, getCalDate(), TemporalType.DATE); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Caught unexpected exception", e); + } + + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception e) { + TestUtil.logErr("Caught exception", e); + } + + if (!pass1 || !pass2) + throw new Exception( + "setParameterParameterCalendarTemporalTypeIllegalArgumentExceptionTest failed"); + } + + + private void createEmployee2TestData() { + + try { + getEntityTransaction().begin(); + + TestUtil.logMsg("Creating Employee2"); + + final Calendar d2 = getCalDate(2001, 06, 27); + final Calendar d3 = getCalDate(2002, 07, 07); + final Calendar d4 = getCalDate(2003, 03, 03); + final Calendar d5 = getCalDate(); + + emp2 = new Employee2(1, "Alan", "Frechette", calDate, (float) 35000.0); + empRef2.add(emp2); + empRef2.add(new Employee2(2, "Arthur", "Frechette", d2, (float) 35000.0)); + empRef2.add(new Employee2(3, "Shelly", "McGowan", d3, (float) 50000.0)); + empRef2.add(new Employee2(4, "Robert", "Bissett", d4, (float) 55000.0)); + empRef2.add(new Employee2(5, "Stephen", "DMilla", d5, (float) 25000.0)); + for (Employee2 e : empRef2) { + if (e != null) { + getEntityManager().persist(e); + TestUtil.logTrace("persisted Employee2:" + e); + } + } + + getEntityManager().flush(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception fe) { + TestUtil.logErr("Unexpected exception rolling back TX:", fe); + } + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT1.java new file mode 100644 index 0000000000..8894e6a3b1 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT1.java @@ -0,0 +1,1037 @@ +package com.sun.ts.tests.jpa.core.annotations.access.field; + +import java.util.Arrays; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.core.types.common.Grade; + +import jakarta.persistence.Query; + +public class ClientIT1 extends Client{ + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + + super.setup(); + removeTestData(); + createTestData(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + throw new Exception("Setup failed:", e); + } + } + + + + /* + * @testName: fieldTypeTest1 + * + * @assertion_ids: PERSISTENCE:SPEC:511; PERSISTENCE:SPEC:524; + * PERSISTENCE:SPEC:534; PERSISTENCE:SPEC:512; PERSISTENCE:SPEC:525; + * PERSISTENCE:JAVADOC:14; PERSISTENCE:JAVADOC:203; PERSISTENCE:JAVADOC:300; + * PERSISTENCE:SPEC:1239; PERSISTENCE:SPEC:1320; PERSISTENCE:SPEC:1327.4; + * PERSISTENCE:SPEC:1155; PERSISTENCE:SPEC:1976; PERSISTENCE:SPEC:1977; + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: boolean + */ + + @Test + public void fieldTypeTest1() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (!d1.isProperty())) { + d1.setBooleanData(true); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.isProperty()) { + TestUtil.logTrace("Received expected result:" + d1.isProperty()); + pass = true; + } else { + TestUtil.logErr("Expected: true, actual:" + d1.isProperty()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest1 failed"); + } + + /* + * @testName: fieldTypeTest2 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:513; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: byte + */ + @Test + public void fieldTypeTest2() throws Exception { + + boolean pass = false; + byte newByte = (byte) 111; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (d1.getByteData() == (byte) 100)) { + d1.setByteData(newByte); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getByteData() == newByte) { + pass = true; + } else { + TestUtil.logErr("Expected: 100, actual:" + d1.getByteData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest2 failed"); + } + + /* + * @testName: fieldTypeTest3 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: char + */ + @Test + public void fieldTypeTest3() throws Exception { + + boolean pass = false; + final char newChar = 'b'; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + + if ((null != d1) && (d1.getCharacterData() == ('a'))) { + d1.setCharacterData(newChar); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getCharacterData() == newChar) { + pass = true; + } else { + TestUtil.logErr("Expected: a, actual:" + d1.getCharacterData()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest3 failed"); + } + + /* + * @testName: fieldTypeTest4 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: short + */ + @Test + public void fieldTypeTest4() throws Exception { + + boolean pass = false; + final short newShort = (short) 101; + + try { + + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (d1.getShortData() == (short) 100)) { + d1.setShortData(newShort); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getShortData() == newShort) { + pass = true; + } else { + TestUtil.logErr("Expected: 100, actual:" + d1.getShortData()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + pass = false; + } + } + + if (!pass) + throw new Exception("fieldTypeTest4 failed"); + } + + /* + * @testName: fieldTypeTest5 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: int + */ + @Test + public void fieldTypeTest5() throws Exception { + + boolean pass = false; + final int newInt = 500; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (d1.getIntData() == 300)) { + d1.setIntData(newInt); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getIntData() == newInt) { + pass = true; + } else { + TestUtil.logErr("Expected: 300, actual:" + d1.getIntData()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest5 failed"); + } + + /* + * @testName: fieldTypeTest6 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: long + */ + @Test + public void fieldTypeTest6() throws Exception { + + boolean pass = false; + final long newLong = 600L; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (d1.getLongData() == 600L)) { + d1.setLongData(newLong); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getLongData() == newLong) { + pass = true; + } else { + TestUtil.logErr("Expected: 600, actual:" + d1.getLongData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest6 failed"); + } + + /* + * @testName: fieldTypeTest7 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: double + */ + @Test + public void fieldTypeTest7() throws Exception { + + boolean pass = false; + final double newDbl = 80D; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (d1.getDoubleData() == (50D))) { + d1.setDoubleData(newDbl); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if (d1.getDoubleData() == newDbl) { + pass = true; + } else { + TestUtil.logErr("Expected: 50, actual:" + d1.getDoubleData()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest7 failed"); + } + + /* + * @testName: fieldTypeTest8 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:525; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: Java primitive types: float + */ + @Test + public void fieldTypeTest8() throws Exception { + + boolean pass = false; + final float expFloat = 1.0F; + final float floatRange = 2.0F; + final float newFloat = 6.0F; + final float newfloatRange = 7.0F; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if (null != d1) { + + TestUtil.logTrace("float value is: " + d1.getFloatData()); + + if ((d1.getFloatData() >= expFloat) + && (d1.getFloatData() < floatRange)) { + d1.setFloatData(newFloat); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + if ((d1.getFloatData() >= newFloat) + && (d1.getFloatData() < newfloatRange)) { + pass = true; + } else { + TestUtil.logErr("Expected: >= " + newFloat + " and < " + + newfloatRange + ", actual:" + d1.getFloatData()); + } + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest8 failed"); + } + + /* + * @testName: fieldTypeTest9 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:529; + * PERSISTENCE:SPEC:556; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent field of an entity may be of the following + * type: enums + * + * With the Enumerated annotation and EnumType.STRING. + */ + @Test + public void fieldTypeTest9() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + TestUtil.logTrace("find DataTypes entity in fieldTypeTest9"); + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + TestUtil.logTrace("DataTypes is not null, setting enumData"); + d1.setEnumData(Grade.B); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + TestUtil.logTrace("Update performed, check results"); + if ((null != d1) && (d1.getEnumData().equals(Grade.B))) { + TestUtil.logTrace("Expected results received"); + pass = true; + } else { + TestUtil.logErr("Expected: " + Grade.B.toString() + ", actual:" + + d1.getEnumData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest9 failed"); + } + + /* + * @testName: fieldTypeTest10 + * + * @assertion_ids: PERSISTENCE:SPEC:536; PERSISTENCE:SPEC:540; + * PERSISTENCE:SPEC:550; PERSISTENCE:SPEC:1090.0; PERSISTENCE:JAVADOC:216; + * PERSISTENCE:JAVADOC:217; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The primary key should be one of the following types: + * java.util.Date + * + * The application must not change the value of the primary key. The behavior + * is undefined if this occurs. + * + * Temporal.TemporalType.DATE + */ + @Test + public void fieldTypeTest10() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + TestUtil.logTrace("FIND D2 IN fieldTypeTest10"); + d2 = getEntityManager().find(DataTypes2.class, dateId); + if (null != d2) { + + TestUtil.logTrace("fieldTypeTest10: Check results"); + if (d2.getId().equals(dateId)) { + TestUtil.logTrace("Got expected PK of:" + d2.getId() + "received"); + pass = true; + } else { + TestUtil.logErr("Expected: " + dateId + ", actual: " + d2.getId()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest10 failed"); + } + + /* + * @testName: fieldTypeTest11 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528; + * PERSISTENCE:SPEC:1089; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent property of an entity may be of the + * following type: byte[] + * + */ + @Test + public void fieldTypeTest11() throws Exception { + + boolean pass = false; + final byte[] b = { 31, 32, 33, 63, 64, 65 }; + final byte bv = 5; + byte[] a = null; + + try { + getEntityTransaction().begin(); + TestUtil.logTrace("FIND D1 IN fieldTypeTest11"); + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + TestUtil.logTrace("DataType Entity is not null, setting byteData "); + d1.setByteArrayData(b); + a = d1.getByteArrayData(); + a[0] = (byte) (a[0] + bv); + d1.setByteArrayData(b); + + getEntityManager().merge(d2); + getEntityManager().flush(); + + TestUtil.logTrace("fieldTypeTest11: Check results"); + if ((null != d2) && (Arrays.equals(d1.getByteArrayData(), a))) { + TestUtil.logTrace("fieldTypeTest11: Expected results received"); + pass = true; + } else { + TestUtil.logErr("Unexpected result in array comparison."); + for (Byte aByte : a) { + TestUtil.logErr("Array a in propertyTest9 equals: " + aByte); + } + for (Byte bByte : b) { + TestUtil.logErr("Array b in propertyTest9 equals: " + bByte); + } + pass = false; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest11 failed"); + } + + /* + * @testName: fieldTypeTest12 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:528; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent property of an entity may be of the + * following type: char[] + * + */ + @Test + public void fieldTypeTest12() throws Exception { + + boolean pass = false; + final char[] charData = new char[] { 'c', 't', 's' }; + + try { + getEntityTransaction().begin(); + TestUtil.logTrace("FIND D1 IN fieldTypeTest12"); + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + TestUtil.logTrace("DataType Entity is not null, setting charData "); + d1.setCharArrayData(charData); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + TestUtil.logTrace("fieldTypeTest12: Check results"); + if ((null != d1) && (Arrays.equals(d1.getCharArrayData(), charData))) { + TestUtil.logTrace("fieldTypeTest12: Expected Results Received"); + pass = true; + } else { + TestUtil.logErr("Expected " + Arrays.toString(charData) + ", actual: " + + Arrays.toString(d1.getCharArrayData())); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest12 failed"); + } + + /* + * @testName: fieldTypeTest13 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent property of an entity may be of the + * following type: java.sql.Time + */ + @Test + public void fieldTypeTest13() throws Exception { + + boolean pass = false; + final java.sql.Time timeValue = getTimeData(18, 30, 15); + + try { + getEntityTransaction().begin(); + TestUtil.logTrace("FIND D2 IN fieldTypeTest13"); + d2 = getEntityManager().find(DataTypes2.class, dateId); + + if (null != d2) { + TestUtil.logTrace("DataType Entity is not null, setting TimeData "); + d2.setTimeData(timeValue); + + getEntityManager().merge(d2); + getEntityManager().flush(); + + TestUtil.logTrace("fieldTypeTest13: Check results"); + if ((null != d2) && (d2.getTimeData().equals(timeValue))) { + TestUtil.logTrace("fieldTypeTest13: Expected Time Received"); + pass = true; + } else { + TestUtil.logErr( + "Expected " + timeValue + " , actual: " + d2.getTimeData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest13 failed"); + } + + /* + * @testName: fieldTypeTest14 + * + * @assertion_ids: PERSISTENCE:SPEC:524; PERSISTENCE:SPEC:527; + * PERSISTENCE:SPEC:1319 + * + * @test_Strategy: The persistent property of an entity may be of the + * following type: java.sql.Timestamp + */ + @Test + public void fieldTypeTest14() throws Exception { + + boolean pass = false; + final java.sql.Timestamp tsValue = getTimestampData(2006, 02, 11); + + try { + getEntityTransaction().begin(); + TestUtil.logTrace("FIND D2 IN fieldTypeTest14"); + d2 = getEntityManager().find(DataTypes2.class, dateId); + + if (null != d2) { + TestUtil + .logTrace("DataType Entity is not null, setting TimestampData "); + d2.setTsData(tsValue); + + getEntityManager().merge(d2); + getEntityManager().flush(); + + TestUtil.logTrace("fieldTypeTest14: Check results"); + if ((null != d2) && (d2.getTsData().equals(tsValue))) { + TestUtil.logTrace("fieldTypeTest14: Expected Timestamp Received"); + pass = true; + } else { + TestUtil + .logErr("Expected " + tsValue + " , actual: " + d2.getTsData()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest14 failed"); + } + + /* + * @testName: fieldTypeTest15 + * + * @assertion_ids: PERSISTENCE:SPEC:428; PERSISTENCE:SPEC:529; + * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: enum_expression ::= enum_primary | (subquery) enum_primary + * ::= statefield_path_expression | input parameter | enum_literal + * + * statefield_path_expression + */ + @Test + public void fieldTypeTest15() throws Exception { + + boolean pass = false; + Object result; + Query q; + + try { + + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + d1.setEnumData(Grade.A); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + q = getEntityManager().createQuery( + "SELECT dt FROM DataTypes dt WHERE dt.enumData = com.sun.ts.tests.jpa.core.types.common.Grade.A"); + + result = (DataTypes) q.getSingleResult(); + + if (d1.equals(result)) { + pass = true; + TestUtil.logTrace("Received expected result:" + d1.toString()); + } else { + TestUtil.logErr( + "Expected:" + d1.toString() + ", actual:" + result.toString()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest15 failed"); + } + + /* + * @testName: fieldTypeTest16 + * + * @assertion_ids: PERSISTENCE:SPEC:428; PERSISTENCE:SPEC:529; + * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: enum_expression ::= enum_primary | (subquery) enum_primary + * ::= state_field_path_expression | input parameter | enum_literal + * + * named parameter + */ + @Test + public void fieldTypeTest16() throws Exception { + + boolean pass = false; + Object result; + Query q; + + try { + + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + d1.setEnumData(Grade.A); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + q = getEntityManager() + .createQuery( + "SELECT dt FROM DataTypes dt WHERE dt.enumData = :grade") + .setParameter("grade", Grade.A); + + result = (DataTypes) q.getSingleResult(); + + if (d1.equals(result)) { + pass = true; + TestUtil.logTrace("Received expected result:" + d1.toString()); + } else { + TestUtil.logErr( + "Expected:" + d1.toString() + ", actual:" + result.toString()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest16 failed"); + } + + /* + * @testName: fieldTypeTest17 + * + * @assertion_ids: PERSISTENCE:SPEC:428; PERSISTENCE:SPEC:529; + * PERSISTENCE:SPEC:1090.1; PERSISTENCE:SPEC:1090.2; PERSISTENCE:SPEC:1319 + * + * @test_Strategy: enum_expression ::= enum_primary | (subquery) enum_primary + * ::= state_field_path_expression | input parameter | enum_literal + * + * positional parameters + */ + @Test + public void fieldTypeTest17() throws Exception { + + boolean pass = false; + Object result; + Query q; + final Grade failingGrade = com.sun.ts.tests.jpa.core.types.common.Grade.F; + final Grade incompleteGrade = com.sun.ts.tests.jpa.core.types.common.Grade.INCOMPLETE; + + try { + + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + + if (null != d1) { + d1.setEnumData(Grade.C); + + getEntityManager().merge(d1); + getEntityManager().flush(); + + q = getEntityManager().createQuery( + "SELECT dt FROM DataTypes dt WHERE (dt.enumData <> ?1) OR (dt.enumData <> ?2) ") + .setParameter(1, failingGrade).setParameter(2, incompleteGrade); + + result = (DataTypes) q.getSingleResult(); + + if (d1.equals(result)) { + pass = true; + TestUtil.logTrace("Received expected result:" + d1.toString()); + } else { + TestUtil.logErr( + "Expected:" + d1.toString() + ", actual:" + result.toString()); + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("fieldTypeTest17 failed"); + } + + + + + + // Methods used for Tests + + public void createTestData() { + TestUtil.logTrace("createTestData"); + + try { + getEntityTransaction().begin(); + char[] cArray = { 'a' }; + byte[] bArray = { (byte) 100 }; + d1 = new DataTypes(1, false, (byte) 100, 'a', (short) 100, 300, 600L, 50D, + 1.0F, cArray, bArray); + + TestUtil.logTrace("dateId is: " + dateId); + d2 = new DataTypes2(dateId); + + getEntityManager().persist(d1); + getEntityManager().persist(d2); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT2.java new file mode 100644 index 0000000000..772062b020 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT2.java @@ -0,0 +1,106 @@ +package com.sun.ts.tests.jpa.core.annotations.access.field; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT2 extends Client { + + @BeforeEach + public void setup2() throws Exception { + TestUtil.logTrace("setup2"); + try { + + super.setup(); + removeTestData(); + createTestData2(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + throw new Exception("Setup failed:", e); + } + } + + public void createTestData2() { + TestUtil.logTrace("createTestData2"); + + try { + getEntityTransaction().begin(); + d1 = new DataTypes(1, 300); + + getEntityManager().persist(d1); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + + + + /* + * @testName: mixedAccessTest + * + * @assertion_ids: PERSISTENCE:SPEC:1327.3; + * + * @test_Strategy: + */ + @Test + public void mixedAccessTest() throws Exception { + + boolean pass = false; + final int newInt = 500; + + try { + getEntityTransaction().begin(); + d1 = getEntityManager().find(DataTypes.class, 1); + if ((null != d1) && (d1.getIntData2() == 300)) { + TestUtil.logMsg("Int value after find=" + d1.getIntData2()); + d1.setIntData2(newInt); + TestUtil.logMsg("Int value after set=" + d1.getIntData2()); + getEntityManager().merge(d1); + getEntityManager().flush(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if (d1.getIntData2() == newInt) { + pass = true; + TestUtil.logTrace("Received expected value:" + d1.getIntData2()); + } else { + TestUtil + .logErr("Expected:" + newInt + ", actual:" + d1.getIntData2()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("mixedAccessTest failed"); + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT3.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT3.java new file mode 100644 index 0000000000..28fe593c54 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT3.java @@ -0,0 +1,115 @@ +package com.sun.ts.tests.jpa.core.annotations.access.field; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT3 extends Client{ + + @BeforeEach + public void setup3() throws Exception { + TestUtil.logTrace("setup3"); + try { + + super.setup(); + removeTestData(); + createTestData3(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + throw new Exception("Setup failed:", e); + } + } + + public void createTestData3() { + TestUtil.logTrace("createTestData3"); + + try { + getEntityTransaction().begin(); + d1 = new DataTypes(1, (byte) 5); + + getEntityManager().persist(d1); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + + + + /* + * @testName: transientTest + * + * @assertion_ids: PERSISTENCE:SPEC:1327.2 + * + * @test_Strategy: when transient is specified, verify data isn't persisted + */ + @Test + public void transientTest() throws Exception { + + boolean pass = false; + byte newByte = (byte) 111; + + try { + getEntityTransaction().begin(); + clearCache(); + d1 = getEntityManager().find(DataTypes.class, 1); + if (null != d1) { + if ((d1.getTransient() == (byte) 0)) { + TestUtil.logTrace( + "First find returned expected result:" + d1.getTransient()); + d1.setTransient(newByte); + + getEntityManager().merge(d1); + getEntityManager().flush(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if (d1.getTransient() == (byte) 0) { + pass = true; + TestUtil.logTrace( + "Second find returned expected value:" + d1.getTransient()); + } else { + TestUtil + .logErr("Second find expected:0, actual:" + d1.getTransient()); + } + } else { + TestUtil.logErr( + "Expected first find to return:0, actual:" + d1.getTransient()); + } + getEntityTransaction().commit(); + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("transientTest failed"); + } + + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT4.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT4.java new file mode 100644 index 0000000000..bdc11cf624 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/field/ClientIT4.java @@ -0,0 +1,382 @@ +package com.sun.ts.tests.jpa.core.annotations.access.field; + +import java.util.GregorianCalendar; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +import jakarta.persistence.TypedQuery; + +public class ClientIT4 extends Client{ + + @BeforeEach + public void setup4() throws Exception { + TestUtil.logTrace("setup3"); + try { + + super.setup(); + removeTestData(); + createTestData4(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: testExtractDateYear + * + * @assertion_ids: PERSISTENCE:SPEC:2519.1 + * + * @test_Strategy: SELECT EXTRACT(YEAR FROM d.id) FROM DataTypes2 d WHERE d.id = :id + */ + + @Test + public void testExtractDateYear() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(YEAR FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long y = q1.getSingleResult().longValue(); + System.out.println("DATETIME -- YEAR: " + y); + if (y != TD4_YEAR) { + throw new Exception("EXTRACT(YEAR FROM date) returned wrong value: expeted " + TD4_YEAR + " but got " + y); + } + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateQuarter + * + * @assertion_ids: PERSISTENCE:SPEC:2519.2 + * + * @test_Strategy: SELECT EXTRACT(QUARTER FROM d.id) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateQuarter() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(QUARTER FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long q = q1.getSingleResult().longValue(); + if (q != TD4_QUARTER) { + throw new Exception("EXTRACT(QUARTER FROM date) returned wrong value: expeted " + TD4_QUARTER + " but got " + q); + } + System.out.println("DATETIME -- QUARTER: " + q); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateMonth + * + * @assertion_ids: PERSISTENCE:SPEC:2519.3 + * + * @test_Strategy: SELECT EXTRACT(MONTH FROM d.id) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateMonth() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MONTH FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long m = q1.getSingleResult().longValue(); + if (m != TD4_MONTH) { + throw new Exception("EXTRACT(MONTH FROM date) returned wrong value: expeted " + TD4_MONTH + " but got " + m); + } + System.out.println("DATETIME -- MONTH: " + m); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateDay + * + * @assertion_ids: PERSISTENCE:SPEC:2519.5 + * + * @test_Strategy: SELECT EXTRACT(DAY FROM d.id) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateDay() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(DAY FROM d.id) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long d = q1.getSingleResult().longValue(); + if (d != TD4_DAY) { + throw new Exception("EXTRACT(DAY FROM date) returned wrong value: expeted " + TD4_DAY + " but got " + d); + } + System.out.println("DATETIME -- DAY: " + d); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractTimeHour + * + * @assertion_ids: PERSISTENCE:SPEC:2519.6 + * + * @test_Strategy: SELECT EXTRACT(HOUR FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractTimeHour() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(HOUR FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long h = q1.getSingleResult().longValue(); + if (h != TD4_HOUR) { + throw new Exception("EXTRACT(HOUR FROM time) returned wrong value: expeted " + TD4_HOUR + " but got " + h); + } + System.out.println("DATETIME -- HOUR: " + h); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractTimeMinute + * + * @assertion_ids: PERSISTENCE:SPEC:2519.7 + * + * @test_Strategy: SELECT EXTRACT(MINUTE FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractTimeMinute() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MINUTE FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long m = q1.getSingleResult().longValue(); + if (m != TD4_MINUTE) { + throw new Exception("EXTRACT(MINUTE FROM time) returned wrong value: expeted " + TD4_MINUTE + " but got " + m); + } + System.out.println("DATETIME -- MINUTE: " + m); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractTimeSecond + * + * @assertion_ids: PERSISTENCE:SPEC:2519.8 + * + * @test_Strategy: SELECT EXTRACT(SECOND FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractTimeSecond() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(SECOND FROM d.timeData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long s = q1.getSingleResult().longValue(); + if (s != TD4_SECOND) { + throw new Exception("EXTRACT(SECOND FROM time) returned wrong value: expeted " + TD4_SECOND + " but got " + s); + } + System.out.println("DATETIME -- SECOND: " + s); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeYear + * + * @assertion_ids: PERSISTENCE:SPEC:2519.1 + * + * @test_Strategy: SELECT EXTRACT(YEAR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeYear() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(YEAR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long y = q1.getSingleResult().longValue(); + System.out.println("DATETIME -- YEAR: " + y); + if (y != TD4_YEAR) { + throw new Exception("EXTRACT(YEAR FROM timestamp) returned wrong value: expeted " + TD4_YEAR + " but got " + y); + } + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeQuarter + * + * @assertion_ids: PERSISTENCE:SPEC:2519.2 + * + * @test_Strategy: SELECT EXTRACT(QUARTER FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeQuarter() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(QUARTER FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long q = q1.getSingleResult().longValue(); + if (q != TD4_QUARTER) { + throw new Exception("EXTRACT(QUARTER FROM timestamp) returned wrong value: expeted " + TD4_QUARTER + " but got " + q); + } + System.out.println("DATETIME -- QUARTER: " + q); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeMonth + * + * @assertion_ids: PERSISTENCE:SPEC:2519.3 + * + * @test_Strategy: SELECT EXTRACT(MONTH FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeMonth() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MONTH FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long m = q1.getSingleResult().longValue(); + if (m != TD4_MONTH) { + throw new Exception("EXTRACT(MONTH FROM timestamp) returned wrong value: expeted " + TD4_MONTH + " but got " + m); + } + System.out.println("DATETIME -- MONTH: " + m); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeDay + * + * @assertion_ids: PERSISTENCE:SPEC:2519.5 + * + * @test_Strategy: SELECT EXTRACT(DAY FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeDay() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(DAY FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long d = q1.getSingleResult().longValue(); + if (d != TD4_DAY) { + throw new Exception("EXTRACT(DAY FROM timestamp) returned wrong value: expeted " + TD4_DAY + " but got " + d); + } + System.out.println("DATETIME -- DAY: " + d); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeHour + * + * @assertion_ids: PERSISTENCE:SPEC:2519.6 + * + * @test_Strategy: SELECT EXTRACT(HOUR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeHour() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(HOUR FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long h = q1.getSingleResult().longValue(); + if (h != TD4_HOUR) { + throw new Exception("EXTRACT(HOUR FROM timestamp) returned wrong value: expeted " + TD4_HOUR + " but got " + h); + } + System.out.println("DATETIME -- HOUR: " + h); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeMinute + * + * @assertion_ids: PERSISTENCE:SPEC:2519.7 + * + * @test_Strategy: SELECT EXTRACT(MINUTE FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeMinute() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(MINUTE FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long m = q1.getSingleResult().longValue(); + if (m != TD4_MINUTE) { + throw new Exception("EXTRACT(MINUTE FROM timestamp) returned wrong value: expeted " + TD4_MINUTE + " but got " + m); + } + System.out.println("DATETIME -- MINUTE: " + m); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + /* + * @testName: testExtractDateTimeSecond + * + * @assertion_ids: PERSISTENCE:SPEC:2519.8 + * + * @test_Strategy: SELECT EXTRACT(SECOND FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id + */ + @Test + public void testExtractDateTimeSecond() throws Exception { + try { + TypedQuery q1 = getEntityManager().createQuery("SELECT EXTRACT(SECOND FROM d.tsData) FROM DataTypes2 d WHERE d.id = :id", Number.class); + q1.setParameter("id", t4Date()); + long s = q1.getSingleResult().longValue(); + if (s != TD4_SECOND) { + throw new Exception("EXTRACT(SECOND FROM timestamp) returned wrong value: expeted " + TD4_SECOND + " but got " + s); + } + System.out.println("DATETIME -- SECOND: " + s); + } catch (Exception ex) { + throw new Exception(ex); + } + } + + private final int TD4_YEAR = 1989; + private final int TD4_QUARTER= 4; + private final int TD4_MONTH = 11; + private final int TD4_DAY = 17; + private final int TD4_HOUR = 11; + private final int TD4_MINUTE = 23; + private final int TD4_SECOND = 36; + + private java.sql.Date t4Date() { + final GregorianCalendar cal = new GregorianCalendar(TD4_YEAR, TD4_MONTH-1, TD4_DAY, TD4_HOUR, TD4_MINUTE, TD4_SECOND); + final java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis()); + return java.sql.Date.valueOf(ts.toLocalDateTime().toLocalDate()); + } + + public void createTestData4() { + TestUtil.logTrace("createTestData4"); + final GregorianCalendar cal = new GregorianCalendar(TD4_YEAR, TD4_MONTH-1, TD4_DAY, TD4_HOUR, TD4_MINUTE, TD4_SECOND); + final java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis()); + final java.sql.Date dt = java.sql.Date.valueOf(ts.toLocalDateTime().toLocalDate()); + final java.sql.Time tm = java.sql.Time.valueOf(ts.toLocalDateTime().toLocalTime()); + + try { + getEntityTransaction().begin(); + DataTypes2 dataTypes2 = new DataTypes2(dt, tm, ts); + getEntityManager().persist(dataTypes2); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + + + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT2.java new file mode 100644 index 0000000000..1062422af2 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/access/property/ClientIT2.java @@ -0,0 +1,118 @@ +package com.sun.ts.tests.jpa.core.annotations.access.property; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT2 extends Client { + + @BeforeEach + public void setup2() throws Exception { + TestUtil.logTrace("setup2"); + try { + + super.setup(); + removeTestData(); + createTestData2(); + TestUtil.logTrace("Done creating test data"); + + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: transientTest + * + * @assertion_ids: PERSISTENCE:SPEC:1327.9 + * + * @test_Strategy: when transient is specified, verify data isn't persisted + */ + @Test + public void transientTest() throws Exception { + + boolean pass = false; + final String newString = "NEW_VALUE"; + try { + getEntityTransaction().begin(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + TestUtil.logMsg("d1.toString():" + d1.toString()); + + if (null != d1) { + if (d1.getShouldNotPersist() == null) { + TestUtil.logTrace("Int value after find=" + d1.getShouldNotPersist()); + d1.setShouldNotPersist(newString); + TestUtil.logTrace("Int value after set=" + d1.getShouldNotPersist()); + getEntityManager().merge(d1); + getEntityManager().flush(); + clearCache(); + d1 = null; + d1 = getEntityManager().find(DataTypes.class, 1); + + if (d1.getShouldNotPersist() == null) { + pass = true; + TestUtil.logTrace("Received expected null value"); + } else { + TestUtil.logErr("Expected:null, actual:" + d1.getShouldNotPersist()); + } + getEntityTransaction().commit(); + + } else { + TestUtil.logErr("getShouldNotPersist() returned null"); + } + } else { + TestUtil.logErr("find returned null"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + if (!pass) + throw new Exception("transientTest failed"); + } + + public void createTestData2() { + TestUtil.logTrace("createTestData2"); + + try { + getEntityTransaction().begin(); + + d1 = new DataTypes(1, "INITIAL_VALUE"); + + getEntityManager().persist(d1); + + getEntityManager().flush(); + + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + + + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT1.java new file mode 100644 index 0000000000..5874fe0596 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT1.java @@ -0,0 +1,592 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.basic; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT1 extends Client { + + public ClientIT1() { + } + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeTestData(); + } catch (Exception e) { + throw new Exception("Setup failed:", e); + + } + } + + /* + * @testName: persistBasicTest1 + * + * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:614; + * PERSISTENCE:SPEC:671; PERSISTENCE:SPEC:675; PERSISTENCE:SPEC:1069; + * PERSISTENCE:SPEC:1072; PERSISTENCE:SPEC:1073; PERSISTENCE:SPEC:1074; + * PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; PERSISTENCE:SPEC:1077; + * PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; PERSISTENCE:SPEC:1081; + * PERSISTENCE:SPEC:1082; PERSISTENCE:JAVADOC:308; PERSISTENCE:SPEC:1990; + * + * + * @test_Strategy: A new entity bean instance has no persistent identity and + * is not yet associated to a persistent context. + * + * The contains method (used to determine whether an entity instance is in the + * managed state in the current persistence context) returns false: + * + * If the instance is new and the persist method has not been on the entity. + * + * Instantiate an entity and verify the contains method returns false. + */ + @Test + public void persistBasicTest1() throws Exception { + + TestUtil.logTrace("Begin persistBasicTest1"); + + boolean pass = false; + A aRef; + try { + + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + aRef = new A("1", "a1", 1, integer, basicShort, basicBigShort, basicFloat, + basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, + 'a', charArray, bigCharacterArray, byteArray, bigByteArray, + bigInteger, bigDecimal, date, time, timeStamp, calendar); + + getEntityTransaction().begin(); + if (!getInstanceStatus(aRef)) { + pass = true; + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass) { + throw new Exception("persistBasicTest1 failed"); + } + + } + + /* + * @testName: persistBasicTest2 + * + * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:615; + * PERSISTENCE:SPEC:619; PERSISTENCE:SPEC:667; PERSISTENCE:SPEC:669; + * PERSISTENCE:SPEC:1069; PERSISTENCE:SPEC:1073; PERSISTENCE:SPEC:1074; + * PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; PERSISTENCE:SPEC:1077; + * PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; PERSISTENCE:SPEC:1081; + * PERSISTENCE:SPEC:1082; PERSISTENCE:SPEC:1072; + * + * @test_Strategy: The new entity bean instance becomes both managed and + * persistent by invoking the persist method on it. The semantics of the + * persist operation as applied to entity X is as follows: + * + * If X is a new entity, it becomes managed. + * + * Invoke persist on the new entity. Find the entity instance and ensure it is + * managed by calling contains() verifying it returns true. + */ + @Test + public void persistBasicTest2() throws Exception { + + TestUtil.logTrace("Begin persistBasicTest2"); + + boolean pass = false; + A aRef; + + try { + TestUtil.logTrace("new A"); + + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + aRef = new A("2", "a2", 2, integer, basicShort, basicBigShort, basicFloat, + basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, + 'a', charArray, bigCharacterArray, byteArray, bigByteArray, + bigInteger, bigDecimal, date, time, timeStamp, calendar); + + createA(aRef); + + A newA = findA("2"); + + if (newA != null) { + TestUtil.logTrace("A IS NOT NULL"); + } + + getEntityTransaction().begin(); + pass = getInstanceStatus(findA("2")); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass) { + throw new Exception("persistBasicTest2 failed"); + } + + } + + /* + * @testName: persistBasicTest3 + * + * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:618; + * PERSISTENCE:SPEC:620; PERSISTENCE:SPEC:1069; PERSISTENCE:SPEC:1073; + * PERSISTENCE:SPEC:1074; PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; + * PERSISTENCE:SPEC:1077; PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; + * PERSISTENCE:SPEC:1081; PERSISTENCE:SPEC:1082; PERSISTENCE:SPEC:1072; + * + * @test_Strategy: The new entity bean instance becomes both managed and + * persistent by invoking the persist method on it. The semantics of the + * persist operation as applied to entity X is as follows: + * + * The entity X will be entered into the database at or before transaction + * commit or as a result of the flush operation. + * + * Create a new entity instance, invoke flush(), then attempt to access the + * entity by find and invoking a query on it. + * + */ + @Test + public void persistBasicTest3() throws Exception { + + TestUtil.logTrace("Begin persistBasicTest3"); + + String aName = null; + boolean pass = false; + Object result; + A a1; + + try { + getEntityTransaction().begin(); + + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + a1 = new A("3", "a3", 3, integer, basicShort, basicBigShort, basicFloat, + basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, + 'a', charArray, bigCharacterArray, byteArray, bigByteArray, + bigInteger, bigDecimal, date, time, timeStamp, calendar); + + TestUtil.logTrace("Persist Instance"); + getEntityManager().persist(a1); + getEntityManager().flush(); + + TestUtil.logTrace("find By Name"); + result = (A) findByName("a3"); + + TestUtil.logTrace("Check to see that the entities are identical"); + if (result == a1) { + pass = true; + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception fe) { + TestUtil.logErr("Unexpected exception rolling back transaction", fe); + } + } + + if (!pass) { + throw new Exception("persistBasicTest3 failed"); + } + + } + + /* + * @testName: persistBasicTest4 + * + * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:618; + * PERSISTENCE:SPEC:621; PERSISTENCE:SPEC:1069; PERSISTENCE:SPEC:1073; + * PERSISTENCE:SPEC:1074; PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; + * PERSISTENCE:SPEC:1077; PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; + * PERSISTENCE:SPEC:1081; PERSISTENCE:SPEC:1082; PERSISTENCE:SPEC:1072; + * + * @test_Strategy: The new entity bean instance becomes both managed and + * persistent by invoking the persist method on it. The semantics of the + * persist operation as applied to entity X is as follows: + * + * If X is preexisting managed entity, it is ignored by the persist operation. + * + * Invoke persist on an already managed instance. Ensure no exception is + * thrown and that the entity is still persisted and managed. + * + */ + @Test + public void persistBasicTest4() throws Exception { + + TestUtil.logTrace("Begin persistBasicTest4"); + + boolean pass = false; + A aRef; + try { + + TestUtil.logTrace("Persist Instance"); + + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + aRef = new A("4", "a4", 4, integer, basicShort, basicBigShort, basicFloat, + basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, + 'a', charArray, bigCharacterArray, byteArray, bigByteArray, + bigInteger, bigDecimal, date, time, timeStamp, calendar); + + createA(aRef); + + getEntityTransaction().begin(); + TestUtil.logTrace("get Instance Status "); + if (getInstanceStatus(findA("4"))) { + try { + TestUtil.logTrace("entity is managed, try to persist again "); + A newA = findA("4"); + getEntityManager().persist(newA); + TestUtil.logTrace( + "Persist ignored on an already persisted entity as expected"); + pass = true; + } catch (Exception ee) { + TestUtil.logErr("Unexpected exception trying to persist an" + + " already persisted entity", ee); + pass = false; + } + + } else { + TestUtil.logTrace("Instance is not managed. Test Fails."); + pass = false; + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected exception rolling back transaction", re); + } + } + + if (!pass) { + throw new Exception("persistBasicTest4 failed"); + } + } + + /* + * @testName: persistBasicTest5 + * + * @assertion_ids: PERSISTENCE:SPEC:613; PERSISTENCE:SPEC:618; + * PERSISTENCE:SPEC:641; PERSISTENCE:SPEC:642; PERSISTENCE:SPEC:1069; + * PERSISTENCE:SPEC:1072; PERSISTENCE:SPEC:1073; PERSISTENCE:SPEC:1074; + * PERSISTENCE:SPEC:1075; PERSISTENCE:SPEC:1076; PERSISTENCE:SPEC:1077; + * PERSISTENCE:SPEC:1078; PERSISTENCE:SPEC:1080; PERSISTENCE:SPEC:1081; + * PERSISTENCE:SPEC:1082; PERSISTENCE:JAVADOC:8 + * + * @test_Strategy: The flush method can be used for force synchronization. The + * semantics of the flush operation applied to an entity X is as follows: + * + * If X is a managed entity, it is synchronized to the database. + * + * Execute flush on a managed entity and ensure the database reflects the + * change. + * + */ + @Test + public void persistBasicTest5() throws Exception { + + TestUtil.logTrace("Begin persistBasicTest5"); + A a2; + A aRef; + + boolean pass = true; + try { + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + aRef = new A("5", null, 5, integer, basicShort, basicBigShort, basicFloat, + basicBigFloat, basicLong, basicBigLong, basicDouble, basicBigDouble, + 'a', charArray, bigCharacterArray, byteArray, bigByteArray, + bigInteger, bigDecimal, date, time, timeStamp, calendar); + + TestUtil.logTrace("Persist Instance"); + createA(aRef); + + getEntityTransaction().begin(); + TestUtil.logTrace("get Instance Status "); + if (getInstanceStatus(findA("5"))) { + try { + TestUtil.logTrace("entity is managed, try to change name and flush "); + a2 = findA("5"); + if (a2.getName() == null) { + TestUtil.logTrace("Received Name as null"); + } else { + TestUtil.logErr("Expected null name, actual:" + a2.getName()); + pass = false; + } + a2.setName("a2"); + getEntityManager().flush(); + if (a2.getName().equals("a2")) { + TestUtil.logTrace("sync to database successful"); + } + } catch (Exception ee) { + TestUtil.logErr( + "Unexpected exception trying to flush a" + "persisted entity", + ee); + pass = false; + } + + } else { + TestUtil.logTrace("Instance is not already persisted. Test Fails."); + pass = false; + } + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected exception rolling back transaction", re); + } + + } + + if (!pass) { + throw new Exception("persistBasicTest5 failed"); + } + } + + + /* + * Business Methods for Test Cases + */ + private void createA(final A a) { + TestUtil.logTrace("Entered createA method"); + getEntityTransaction().begin(); + getEntityManager().persist(a); + // WORKAROUND + getEntityManager().flush(); + getEntityTransaction().commit(); + } + + private A findA(final String id) { + TestUtil.logTrace("Entered findA method"); + return getEntityManager().find(A.class, id); + } + + private Object findByName(final String name) { + TestUtil.logTrace("Entered findByName method"); + return getEntityManager() + .createQuery("select a from A a where a.name = :name") + .setParameter("name", name).getSingleResult(); + } + + private boolean getInstanceStatus(final Object o) { + TestUtil.logTrace("Entered getInstanceStatus method"); + return getEntityManager().contains(o); + } + + @AfterEach + public void cleanup() throws Exception { + TestUtil.logTrace("cleanup"); + removeTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + public void createTestData() { + try { + getEntityTransaction().begin(); + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + A aRef = new A("9", null, 9, integer, basicShort, basicBigShort, + basicFloat, basicBigFloat, basicLong, basicBigLong, basicDouble, + basicBigDouble, 'a', charArray, bigCharacterArray, byteArray, + bigByteArray, bigInteger, bigDecimal, date, time, timeStamp, + calendar); + + getEntityManager().persist(aRef); + getEntityManager().flush(); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT2.java new file mode 100644 index 0000000000..663750aa16 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/basic/ClientIT2.java @@ -0,0 +1,842 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.basic; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT2 extends Client { + + public ClientIT2() { + } + + + @BeforeEach + public void setupData() throws Exception { + TestUtil.logTrace("setupData"); + try { + super.setup(); + removeTestData(); + createTestData(); + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: DoubleOperandResultTypeTests + * + * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.1; + * PERSISTENCE:SPEC:1685; + * + * @test_Strategy: Test various operands result in various types + * + */ + @Test + public void DoubleOperandResultTypeTests() throws Exception { + boolean pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8; + pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = pass7 = pass8 = false; + Object p; + + try { + TestUtil.logMsg("Testing + Double operand:"); + getEntityTransaction().begin(); + double whereValue = 1234.5; + p = getEntityManager().createQuery( + "Select (a.basicBigDouble + 1) From A a where (a.basicBigDouble = ?1)") + .setParameter(1, whereValue).getSingleResult(); + if (p instanceof Double) { + TestUtil.logTrace("Received expected Double type"); + pass1 = true; + } else { + TestUtil + .logErr("Result was not of type Double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - Double operand:"); + getEntityTransaction().begin(); + double whereValue = 1234.0; + p = getEntityManager().createQuery( + "Select (a.basicBigDouble - 1) From A a where (a.basicBigDouble > ?1)") + .setParameter(1, whereValue).getSingleResult(); + if (p instanceof Double) { + TestUtil.logTrace("Received expected Double type"); + pass2 = true; + } else { + TestUtil + .logErr("Result was not of type Double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * Double operand:"); + getEntityTransaction().begin(); + double whereValue = 1235.0; + p = getEntityManager().createQuery( + "Select (a.basicBigDouble * 1) From A a where (a.basicBigDouble < ?1)") + .setParameter(1, whereValue).getSingleResult(); + + if (p instanceof Double) { + TestUtil.logTrace("Received expected Double type"); + pass3 = true; + } else { + TestUtil + .logErr("Result was not of type Double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing / Double operand:"); + getEntityTransaction().begin(); + double whereValue = 1235.0; + p = getEntityManager().createQuery( + "Select (a.basicBigDouble / 1) From A a where (a.basicBigDouble <> ?1)") + .setParameter(1, whereValue).getSingleResult(); + if (p instanceof Double) { + TestUtil.logTrace("Received expected Double type"); + pass4 = true; + } else { + TestUtil + .logErr("Result was not of type Double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing + double operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicDouble + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Double) { + TestUtil.logTrace("Received expected double type"); + pass5 = true; + } else { + TestUtil + .logErr("Result was not of type double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - double operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicDouble - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Double) { + TestUtil.logTrace("Received expected double type"); + pass6 = true; + } else { + TestUtil + .logErr("Result was not of type double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * double operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicDouble * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Double) { + TestUtil.logTrace("Received expected double type"); + pass7 = true; + } else { + TestUtil + .logErr("Result was not of type double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing / double operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicDouble / 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Double) { + TestUtil.logTrace("Received expected double type"); + pass8 = true; + } else { + TestUtil + .logErr("Result was not of type double:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 + || !pass8) + throw new Exception("DoubleOperandResultTypeTests failed"); + } + + /* + * @testName: FloatOperandResultTypeTests + * + * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.2; + * + * @test_Strategy: Test various operands result in various types + * + */ + @Test + public void FloatOperandResultTypeTests() throws Exception { + boolean pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8; + pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = pass7 = pass8 = false; + Object p; + try { + TestUtil.logMsg("Testing + Float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigFloat + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Float) { + TestUtil.logTrace("Received expected Float type"); + pass1 = true; + } else { + TestUtil + .logErr("Result was not of type Float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - Float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigFloat - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Float) { + TestUtil.logTrace("Received expected Float type"); + pass2 = true; + } else { + TestUtil + .logErr("Result was not of type Float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * Float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigFloat * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Float) { + TestUtil.logTrace("Received expected Float type"); + pass3 = true; + } else { + TestUtil + .logErr("Result was not of type Float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing / Float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigFloat / 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Float) { + TestUtil.logTrace("Received expected Float type"); + pass4 = true; + } else { + TestUtil + .logErr("Result was not of type Float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing + float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicFloat + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Float) { + TestUtil.logTrace("Received expected float type"); + pass5 = true; + } else { + TestUtil + .logErr("Result was not of type float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicFloat - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Float) { + TestUtil.logTrace("Received expected float type"); + pass6 = true; + } else { + TestUtil + .logErr("Result was not of type float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicFloat * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Float) { + TestUtil.logTrace("Received expected float type"); + pass7 = true; + } else { + TestUtil + .logErr("Result was not of type float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing / float operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigFloat / 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Float) { + TestUtil.logTrace("Received expected Float type"); + pass8 = true; + } else { + TestUtil + .logErr("Result was not of type Float:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6 || !pass7 + || !pass8) + throw new Exception("FloatOperandResultTypeTests failed"); + } + + /* + * @testName: BigDecimalOperandResultTypeTests + * + * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.3; + * + * @test_Strategy: Test various operands result in various types + * + */ + @Test + public void BigDecimalOperandResultTypeTests() throws Exception { + boolean pass1, pass2, pass3, pass4; + pass1 = pass2 = pass3 = pass4 = false; + Object p; + try { + TestUtil.logMsg("Testing + BigDecimal operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigDecimal + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof BigDecimal) { + TestUtil.logTrace("Received expected BigDecimal type"); + pass1 = true; + } else { + TestUtil.logErr( + "Result was not of type BigDecimal:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - BigDecimal operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigDecimal - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof BigDecimal) { + TestUtil.logTrace("Received expected BigDecimal type"); + pass2 = true; + } else { + TestUtil.logErr( + "Result was not of type BigDecimal:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * BigDecimal operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigDecimal * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof BigDecimal) { + TestUtil.logTrace("Received expected BigDecimal type"); + pass3 = true; + } else { + TestUtil.logErr( + "Result was not of type BigDecimal:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing / BigDecimal operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigDecimal / 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof BigDecimal) { + TestUtil.logTrace("Received expected BigDecimal type"); + pass4 = true; + } else { + TestUtil.logErr( + "Result was not of type BigDecimal:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + if (!pass1 || !pass2 || !pass3 || !pass4) + throw new Exception("BigDecimalOperandResultTypeTests failed"); + } + + /* + * @testName: BigIntegerOperandResultTypeTests + * + * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.4; + * + * @test_Strategy: Test various operands result in various types + * + */ + @Test + public void BigIntegerOperandResultTypeTests() throws Exception { + boolean pass1, pass2, pass3; + pass1 = pass2 = pass3 = false; + Object p; + try { + TestUtil.logMsg("Testing + BigInteger operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigInteger + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof BigInteger) { + TestUtil.logTrace("Received expected BigInteger type"); + pass1 = true; + } else { + TestUtil.logErr( + "Result was not of type BigInteger:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - BigInteger operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigInteger - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof BigInteger) { + TestUtil.logTrace("Received expected BigInteger type"); + pass2 = true; + } else { + TestUtil.logErr( + "Result was not of type BigInteger:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * BigInteger operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigInteger * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof BigInteger) { + TestUtil.logTrace("Received expected BigInteger type"); + pass3 = true; + } else { + TestUtil.logErr( + "Result was not of type BigInteger:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass1 || !pass2 || !pass3) + throw new Exception("BigIntegerOperandResultTypeTests failed"); + } + + /* + * @testName: LongOperandResultTypeTests + * + * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.5; + * + * @test_Strategy: Test various operands result in various types + * + */ + @Test + public void LongOperandResultTypeTests() throws Exception { + boolean pass1, pass2, pass3, pass4, pass5, pass6; + pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = false; + Object p; + try { + TestUtil.logMsg("Testing + Long operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigLong + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Long) { + TestUtil.logTrace("Received expected Long type"); + pass1 = true; + } else { + TestUtil + .logErr("Result was not of type Long:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - Long operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigLong - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Long) { + TestUtil.logTrace("Received expected Long type"); + pass2 = true; + } else { + TestUtil + .logErr("Result was not of type Long:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * Long operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigLong * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Long) { + TestUtil.logTrace("Received expected Long type"); + pass3 = true; + } else { + TestUtil + .logErr("Result was not of type Long:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + try { + TestUtil.logMsg("Testing + long operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicLong + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Long) { + TestUtil.logTrace("Received expected long type"); + pass4 = true; + } else { + TestUtil + .logErr("Result was not of type long:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - long operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicLong - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Long) { + TestUtil.logTrace("Received expected long type"); + pass5 = true; + } else { + TestUtil + .logErr("Result was not of type long:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * long operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicLong * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Long) { + TestUtil.logTrace("Received expected long type"); + pass6 = true; + } else { + TestUtil + .logErr("Result was not of type long:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) + throw new Exception("LongOperandResultTypeTests failed"); + } + + /* + * @testName: ShortOperandResultTypeTests + * + * @assertion_ids: PERSISTENCE:SPEC:1677; PERSISTENCE:SPEC:1677.6; + * + * @test_Strategy: Test various operands of integral type and verify the + * result of the operation is of type Integer + * + */ + @Test + public void ShortOperandResultTypeTests() throws Exception { + boolean pass1, pass2, pass3, pass4, pass5, pass6; + pass1 = pass2 = pass3 = pass4 = pass5 = pass6 = false; + Object p; + try { + TestUtil.logMsg("Testing + Short operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigShort + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Integer) { + TestUtil.logTrace("Received expected Integer type"); + pass1 = true; + } else { + TestUtil + .logErr("Result was not of type Integer:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - Short operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigShort - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Integer) { + TestUtil.logTrace("Received expected Integer type"); + pass2 = true; + } else { + TestUtil + .logErr("Result was not of type Integer:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * Short operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery( + "Select (a.basicBigShort * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Integer) { + TestUtil.logTrace("Received expected Integer type"); + pass3 = true; + } else { + TestUtil + .logErr("Result was not of type Integer:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing + short operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicShort + 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Integer) { + TestUtil.logTrace("Received expected Integer type"); + pass4 = true; + } else { + TestUtil + .logErr("Result was not of type Integer:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing - short operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicShort - 1) From A a where (a.id = '9')") + .getSingleResult(); + if (p instanceof Integer) { + TestUtil.logTrace("Received expected Integer type"); + pass5 = true; + } else { + TestUtil + .logErr("Result was not of type Integer:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + try { + TestUtil.logMsg("Testing * short operand:"); + getEntityTransaction().begin(); + p = getEntityManager() + .createQuery("Select (a.basicShort * 1) From A a where (a.id = '9')") + .getSingleResult(); + + if (p instanceof Integer) { + TestUtil.logTrace("Received expected Integer type"); + pass6 = true; + } else { + TestUtil + .logErr("Result was not of type Integer:" + p.getClass().getName()); + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Caught exception: ", e); + } + + if (!pass1 || !pass2 || !pass3 || !pass4 || !pass5 || !pass6) + throw new Exception("ShortOperandResultTypeTests failed"); + } + + + @AfterEach + public void createTestData() { + try { + getEntityTransaction().begin(); + final Integer integer = 1234; + final short basicShort = 12; + final Short basicBigShort = basicShort; + final float basicFloat = 12.3f; + final Float basicBigFloat = basicFloat; + final long basicLong = 1234l; + final Long basicBigLong = basicLong; + final double basicDouble = 1234.5; + final Double basicBigDouble = basicDouble; + final char[] charArray = { 'a', 'b', 'c' }; + final Character[] bigCharacterArray = { 'a', 'b', 'c' }; + final byte[] byteArray = "abc".getBytes(); + final Byte[] bigByteArray = { (byte) 111, (byte) 101, (byte) 100 }; + final BigInteger bigInteger = new BigInteger("12345"); + final BigDecimal bigDecimal = new BigDecimal(bigInteger); + final Date date = new Date(); + final long timeInSeconds = date.getTime(); + final Time time = new Time(timeInSeconds); + final Timestamp timeStamp = new Timestamp(timeInSeconds); + final Calendar calendar = Calendar.getInstance(); + + A aRef = new A("9", null, 9, integer, basicShort, basicBigShort, + basicFloat, basicBigFloat, basicLong, basicBigLong, basicDouble, + basicBigDouble, 'a', charArray, bigCharacterArray, byteArray, + bigByteArray, bigInteger, bigDecimal, date, time, timeStamp, + calendar); + + getEntityManager().persist(aRef); + getEntityManager().flush(); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT1.java new file mode 100644 index 0000000000..925d7e32bf --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT1.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.elementcollection; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +public class ClientIT1 extends PMClientBase { + + public ClientIT1() { + } + + + @BeforeEach + public void setupA() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeATestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + + } + } + + /* + * @testName: elementCollectionEmbeddableType + * + * @assertion_ids: PERSISTENCE:JAVADOC:318; PERSISTENCE:JAVADOC:319; + * PERSISTENCE:SPEC:2007; + * + * @test_Strategy: ElementCollection of an embeddable class + * + */ + @Test + public void elementCollectionEmbeddableType() throws Exception { + boolean pass = false; + A aRef = null; + try { + + final Address addr1 = new Address("1 Network Drive", "Burlington", "MA", + "01801"); + final Address addr2 = new Address("Some Address", "Boston", "MA", + "01803"); + + Set
s1 = new HashSet
(); + s1.add(addr1); + s1.add(addr2); + + aRef = new A("1", "bean1", 1); + aRef.setAddress(s1); + TestUtil.logTrace("Persisting A"); + getEntityTransaction().begin(); + getEntityManager().persist(aRef); + getEntityTransaction().commit(); + + getEntityTransaction().begin(); + A newA = findA("1"); + final Set
newAddressSet = newA.getAddress(); + + dumpAddresses(newAddressSet); + + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = true; + for (Address addr : newAddressSet) { + if (addr != null) { + if (addr.getStreet().equals("1 Network Drive") + && addr.getCity().equals("Burlington") + && addr.getState().equals("MA") + && addr.getZip().equals("01801")) { + pass1 = true; + TestUtil.logTrace("pass1 = " + pass1); + } + if (addr.getStreet().equals("Some Address") + && addr.getCity().equals("Boston") && addr.getState().equals("MA") + && addr.getZip().equals("01803")) { + pass2 = true; + TestUtil.logTrace("pass2 = " + pass2); + } + } else { + TestUtil.logTrace("address=null"); + pass3 = false; + } + } + + if (pass1 && pass2 && pass3) { + pass = true; + } + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception fe) { + TestUtil.logErr("Unexpected exception rolling back TX:", fe); + } + + } + + if (!pass) { + throw new Exception("elementCollectionEmbeddableType failed"); + } + } + + private A findA(final String id) { + return getEntityManager().find(A.class, id); + } + + private void dumpAddresses(final Set
addr) { + TestUtil.logTrace("address Data"); + TestUtil.logTrace("---------------"); + if (addr != null) { + TestUtil.logTrace("size=" + addr.size()); + int elem = 1; + for (Address v : addr) { + TestUtil.logTrace("- Element #" + elem++); + TestUtil.logTrace(" street=" + v.getStreet() + ", city=" + v.getCity() + + ", state=" + v.getState() + ", zip=" + v.getZip()); + } + } else { + TestUtil.logTrace(" address=NULL"); + } + } + + + private void removeCustTestData() { + TestUtil.logTrace("removeCustTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("DELETE FROM CUST_TABLE") + .executeUpdate(); + getEntityManager().createNativeQuery("DELETE FROM PHONES") + .executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } + + + @AfterEach + public void cleanupA() throws Exception { + TestUtil.logTrace("cleanup"); + removeATestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeATestData() { + TestUtil.logTrace("removeATestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("Delete from A_ADDRESS") + .executeUpdate(); + getEntityManager().createNativeQuery("Delete from AEC").executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } + + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT2.java new file mode 100644 index 0000000000..44a8c323ab --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/elementcollection/ClientIT2.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2009, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.elementcollection; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +public class ClientIT2 extends PMClientBase { + + public ClientIT2() { + } + + + + @BeforeEach + public void setupCust() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeCustTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + + } + } + + + /* + * @testName: elementCollectionBasicType + * + * @assertion_ids: PERSISTENCE:SPEC:2007; + * + * @test_Strategy: ElementCollection of a basic type + */ + @Test + public void elementCollectionBasicType() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + Customer expected = new Customer("1"); + List expectedphones = new ArrayList(); + expectedphones.add("781-442-2010"); + expectedphones.add("781-442-2011"); + expectedphones.add("781-442-2012"); + + expected.setPhones(expectedphones); + TestUtil.logTrace("Persisting Customer:" + expected.toString()); + getEntityManager().persist(expected); + getEntityManager().flush(); + getEntityTransaction().commit(); + clearCache(); + getEntityTransaction().begin(); + TestUtil.logTrace( + "find the previously persisted Customer and Country and verify them"); + Customer cust = getEntityManager().find(Customer.class, expected.getId()); + if (cust != null) { + TestUtil.logTrace("Found Customer: " + cust.toString()); + if (cust.getPhones().containsAll(expectedphones) + && expectedphones.containsAll(cust.getPhones()) + && cust.getPhones().size() == expectedphones.size()) { + TestUtil.logTrace("Received expected Phones:"); + for (String s : cust.getPhones()) { + TestUtil.logTrace("phone:" + s); + } + pass = true; + } else { + TestUtil.logErr("Did not get expected results."); + for (String s : expectedphones) { + TestUtil.logErr("expected:" + s); + } + TestUtil.logErr("actual:"); + for (String s : cust.getPhones()) { + TestUtil.logErr("actual:" + s); + } + } + } else { + TestUtil.logErr("Find returned null Customer"); + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred: ", e); + pass = false; + } + if (!pass) { + throw new Exception("elementCollectionBasicType failed"); + } + } + + /* + * @testName: elementCollectionBasicTypeXMLTest + * + * @assertion_ids: PERSISTENCE:SPEC:2008; + * + * @test_Strategy: ElementCollection of a basic type using mapping file to + * define annotation + */ + @Test + public void elementCollectionBasicTypeXMLTest() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + CustomerXML expected = new CustomerXML("1"); + List expectedphones = new ArrayList(); + expectedphones.add("781-442-2010"); + expectedphones.add("781-442-2011"); + expectedphones.add("781-442-2012"); + + expected.setPhones(expectedphones); + TestUtil.logTrace("Persisting Customer:" + expected.toString()); + getEntityManager().persist(expected); + getEntityManager().flush(); + getEntityTransaction().commit(); + clearCache(); + getEntityTransaction().begin(); + TestUtil.logTrace( + "find the previously persisted Customer and Country and verify them"); + CustomerXML cust = getEntityManager().find(CustomerXML.class, + expected.getId()); + if (cust != null) { + TestUtil.logTrace("Found CustomerXML: " + cust.toString()); + if (cust.getPhones().containsAll(expectedphones) + && expectedphones.containsAll(cust.getPhones()) + && cust.getPhones().size() == expectedphones.size()) { + TestUtil.logTrace("Received expected Phones:"); + for (String s : cust.getPhones()) { + TestUtil.logTrace("phone:" + s); + } + pass = true; + } else { + TestUtil.logErr("Did not get expected results."); + for (String s : expectedphones) { + TestUtil.logErr("expected:" + s); + } + TestUtil.logErr("actual:"); + for (String s : cust.getPhones()) { + TestUtil.logErr("actual:" + s); + } + } + } else { + TestUtil.logErr("Find returned null Customer"); + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred: ", e); + pass = false; + } + if (!pass) { + throw new Exception("elementCollectionBasicTypeXMLTest failed"); + } + } + /* + * + * Business Methods to set up data for Test Cases + * + */ + + + @AfterEach + public void cleanupCust() throws Exception { + TestUtil.logTrace("cleanup"); + removeCustTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeCustTestData() { + TestUtil.logTrace("removeCustTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("DELETE FROM CUST_TABLE") + .executeUpdate(); + getEntityManager().createNativeQuery("DELETE FROM PHONES") + .executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT1.java new file mode 100644 index 0000000000..d87dc801a9 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT1.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package com.sun.ts.tests.jpa.core.annotations.mapkey; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT1 extends Client { + + public ClientIT1() { + } + + private Employee empRef[] = new Employee[10]; + + @BeforeEach + public void setupCreateTestData() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeTestData(); + createTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: annotationMapKeyTest1 + * + * @assertion_ids: PERSISTENCE:JAVADOC:114; PERSISTENCE:SPEC:1100; + * PERSISTENCE:SPEC:1101; PERSISTENCE:SPEC:518; PERSISTENCE:SPEC:1980; + * + * @test_Strategy: The MapKey annotation is used to specify the map key for + * associations of type java.util.Map. + * + * The name element designates the name of the persistence property or field + * of the associated entity that is used as the map key. + * + * Execute a query returning Employees objects. + * + */ + @Test + public void annotationMapKeyTest1() throws Exception { + + boolean pass = true; + + try { + List expected = new ArrayList(); + List actual = new ArrayList(); + + expected.add(empRef[0].getId()); + expected.add(empRef[2].getId()); + expected.add(empRef[4].getId()); + + getEntityTransaction().begin(); + + TestUtil.logTrace("find Employees belonging to Department: Marketing"); + List l = getEntityManager() + .createQuery( + "Select e from Employee e where e.department.name = 'Marketing'") + .getResultList(); + + for (Object o : l) { + Employee e = (Employee) o; + actual.add(e.getId()); + } + + Collections.sort(actual); + if (expected.equals(actual)) { + TestUtil.logTrace("Received expected employees"); + } else { + TestUtil.logErr("Expected id values were:"); + for (Integer i : expected) { + TestUtil.logErr("id: " + i); + } + TestUtil.logErr("actual id values were:"); + Collections.sort(actual); + for (Integer i : actual) { + TestUtil.logErr("id: " + i); + } + } + + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Unexpected exception occurred", ex); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass) + throw new Exception("annotationMapKeyTest1 failed"); + } + + /* + * @testName: annotationMapKeyTest2 + * + * @assertion_ids: PERSISTENCE:JAVADOC:114; PERSISTENCE:SPEC:1100; + * PERSISTENCE:SPEC:1101 + * + * @test_Strategy: The MapKey annotation is used to specify the map key for + * associations of type java.util.Map. + * + * The name element designates the name of the persistence property or field + * of the associated entity that is used as the map key. + * + * Execute a query returning Employee IDs. + */ + @Test + public void annotationMapKeyTest2() throws Exception { + + boolean pass = true; + + try { + List expected = new ArrayList(); + List actual = new ArrayList(); + + expected.add(empRef[1].getId()); + expected.add(empRef[3].getId()); + + getEntityTransaction().begin(); + + TestUtil.logTrace("find Employees belonging to Department: Marketing"); + List l = getEntityManager().createQuery( + "Select e.id from Employee e where e.department.name = 'Administration' ORDER BY e.id DESC") + .getResultList(); + + for (Object o : l) { + Integer i = (Integer) o; + actual.add(i); + } + + Collections.sort(actual); + if (expected.equals(actual)) { + TestUtil.logTrace("Received expected employees"); + } else { + TestUtil.logErr("Expected id values were:"); + for (Integer i : expected) { + TestUtil.logErr("id: " + i); + } + TestUtil.logErr("actual id values were:"); + Collections.sort(actual); + for (Integer i : actual) { + TestUtil.logErr("id: " + i); + } + } + + getEntityTransaction().commit(); + + } catch (Exception ex) { + TestUtil.logErr("Unexpected exception occurred", ex); + pass = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass) + throw new Exception("annotationMapKeyTest2 failed"); + } +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT2.java new file mode 100644 index 0000000000..859f2c4ba4 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/mapkey/ClientIT2.java @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package com.sun.ts.tests.jpa.core.annotations.mapkey; + + +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT2 extends Client { + + public ClientIT2() { + } + + private Employee empRef[] = new Employee[10]; + + private Employee2 empRef2; + + private Employee3 empRef3; + + private Employee4 empRef4; + + private static Department deptRef[] = new Department[5]; + + + public void setupCreateTestData() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeTestData(); + createTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: joinColumnInsertable + * + * @assertion_ids: PERSISTENCE:JAVADOC:90 + * + * @test_Strategy: The JoinColumn annotation with an attribute of insertable + * used to specify the mapping for the fk column to a second entity Execute a + * query returning Employees objects. + */ + @Test + public void joinColumnInsertable() throws Exception { + boolean pass = true; + + try { + getEntityTransaction().begin(); + clearCache(); + TestUtil.logTrace("find employee2"); + Employee2 emp2 = getEntityManager().find(Employee2.class, 6); + TestUtil + .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); + Department dept = emp2.getDepartment(); + + if (dept == null) { + TestUtil.logTrace("Received expected null department for employee2"); + } else { + pass = false; + TestUtil.logErr("Expected null department, actual:" + dept.getName()); + } + clearCache(); + + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee3"); + Employee3 emp3 = getEntityManager().find(Employee3.class, 7); + TestUtil + .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); + dept = emp3.getDepartment(); + + if (dept != null && dept.getName().equals(deptRef[0].getName())) { + TestUtil.logTrace( + "Received expected department for employee3:" + dept.getName()); + } else { + pass = false; + if (dept != null) { + TestUtil.logErr("Expected department:" + deptRef[0].getName() + + ", actual:" + dept.getName()); + } else { + TestUtil.logErr( + "Expected department:" + deptRef[0].getName() + ", actual:null"); + } + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee4"); + Employee4 emp4 = getEntityManager().find(Employee4.class, 8); + TestUtil + .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); + dept = emp4.getDepartment(); + + if (dept == null) { + TestUtil.logTrace("Received expected null department for employee4"); + } else { + pass = false; + TestUtil.logErr("Expected department: null, actual:" + dept.getName()); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + pass = false; + TestUtil.logErr("Received unexpected exception", e); + } + + if (!pass) { + throw new Exception("joinColumnInsertable Failed"); + } + } + + /* + * @testName: joinColumnUpdatable + * + * @assertion_ids: PERSISTENCE:JAVADOC:96 + * + * @test_Strategy: The JoinColumn annotation with an attribute of updatable + * used to specify the mapping for the fk column to a second entity Execute a + * query returning Employees objects. + */ + @Test + public void joinColumnUpdatable() throws Exception { + boolean pass = true; + + try { + getEntityTransaction().begin(); + clearCache(); + TestUtil.logTrace("find employee2"); + Employee2 emp2 = getEntityManager().find(Employee2.class, 6); + TestUtil + .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); + TestUtil.logTrace("set department to:" + deptRef[1].getId() + ", " + + deptRef[1].getName()); + emp2.setDepartment(deptRef[1]); + getEntityManager().merge(emp2); + getEntityManager().flush(); + clearCache(); + TestUtil.logTrace("find employee2 again"); + emp2 = getEntityManager().find(Employee2.class, 6); + TestUtil + .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); + Department dept = emp2.getDepartment(); + if (dept == null) { + TestUtil.logTrace("Received expected null department"); + } else { + pass = false; + TestUtil.logErr("Expected null department, actual:" + dept.getName()); + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee3"); + Employee3 emp3 = getEntityManager().find(Employee3.class, 7); + TestUtil + .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); + TestUtil.logTrace("Department:" + emp3.getDepartment().getId() + ", " + + emp3.getDepartment().getName()); + TestUtil.logTrace("set department to:" + deptRef[1].getId() + ", " + + deptRef[1].getName()); + emp3.setDepartment(deptRef[1]); + getEntityManager().merge(emp3); + getEntityManager().flush(); + clearCache(); + TestUtil.logTrace("find employee3 again"); + emp3 = getEntityManager().find(Employee3.class, 7); + TestUtil + .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); + dept = emp3.getDepartment(); + if (dept != null && dept.getName().equals(deptRef[0].getName())) { + TestUtil.logTrace("Received expected department:" + dept.getName()); + } else { + pass = false; + if (dept != null) { + TestUtil.logErr("Expected department:" + deptRef[0].getName() + + ", actual:" + dept.getName()); + } else { + TestUtil.logErr( + "Expected department:" + deptRef[0].getName() + ", actual:null"); + } + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee4"); + Employee4 emp4 = getEntityManager().find(Employee4.class, 8); + TestUtil + .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); + if (emp4.getFirstName() != null) { + TestUtil.logErr( + "Expected first name to be null, actual:" + emp4.getFirstName()); + pass = false; + } + if (emp4.getDepartment() != null) { + TestUtil.logErr("Expected Department to be null, actual:" + + emp4.getDepartment().toString()); + pass = false; + } + TestUtil.logTrace("set department to:" + deptRef[1].getId() + ", " + + deptRef[1].getName()); + emp4.setDepartment(deptRef[1]); + getEntityManager().merge(emp4); + getEntityManager().flush(); + clearCache(); + TestUtil.logTrace("find employee4 again"); + emp4 = getEntityManager().find(Employee4.class, 8); + TestUtil + .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); + dept = emp4.getDepartment(); + if (dept != null && dept.getName().equals(deptRef[1].getName())) { + TestUtil.logTrace("Received expected department:" + dept.getName()); + } else { + pass = false; + if (dept != null) { + TestUtil.logErr("Expected " + deptRef[1].getName() + + " department, actual:" + dept.getName()); + } else { + TestUtil.logErr( + "Expected " + deptRef[1].getName() + " department, actual:null"); + } + } + + getEntityTransaction().commit(); + + } catch (Exception e) { + pass = false; + TestUtil.logErr("Received unexpected exception", e); + } + + if (!pass) { + throw new Exception("joinColumnUpdatable Failed"); + } + } + + /* + * @testName: columnInsertable + * + * @assertion_ids: PERSISTENCE:JAVADOC:12 + * + * @test_Strategy: The JoinColumn annotation with an attribute of insertable + * used to specify the mapping for the fk column to a second entity Execute a + * query returning Employees objects. + */ + @Test + public void columnInsertable() throws Exception { + boolean pass = true; + + try { + + getEntityTransaction().begin(); + clearCache(); + TestUtil.logTrace("find employee2"); + Employee2 emp2 = getEntityManager().find(Employee2.class, 6); + String firstName = emp2.getFirstName(); + TestUtil.logTrace("Name:" + firstName + " " + emp2.getLastName()); + + if (firstName == null) { + TestUtil.logTrace("Received expected null firstName"); + } else { + pass = false; + TestUtil.logErr("Expected firstName: null, actual:" + firstName); + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee3"); + Employee3 emp3 = getEntityManager().find(Employee3.class, 7); + firstName = emp3.getFirstName(); + TestUtil.logTrace("Name:" + firstName + " " + emp3.getLastName()); + + if (firstName != null && firstName.equals("Paul")) { + TestUtil.logTrace("Received expected firstName:" + firstName); + } else { + pass = false; + TestUtil.logErr("Expected firstName: Paul, actual: null"); + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee4"); + Employee4 emp4 = getEntityManager().find(Employee4.class, 8); + firstName = emp4.getFirstName(); + TestUtil.logTrace("Name:" + firstName + " " + emp4.getLastName()); + if (firstName == null) { + TestUtil.logTrace("Received expected null firstName"); + } else { + pass = false; + TestUtil.logErr("Expected firstName: null, actual:" + firstName); + } + getEntityTransaction().commit(); + + } catch (Exception e) { + pass = false; + TestUtil.logErr("Received unexpected exception", e); + } + + if (!pass) { + throw new Exception("columnInsertable Failed"); + } + } + + /* + * @testName: columnUpdatable + * + * @assertion_ids: PERSISTENCE:JAVADOC:20 + * + * @test_Strategy: The JoinColumn annotation with an attribute of updatable + * used to specify the mapping for the fk column to a second entity Execute a + * query returning Employees objects. + */ + @Test + public void columnUpdatable() throws Exception { + boolean pass = true; + + try { + getEntityTransaction().begin(); + clearCache(); + TestUtil.logTrace("find employee2"); + Employee2 emp2 = getEntityManager().find(Employee2.class, 6); + TestUtil + .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); + TestUtil.logTrace("set firstName and save"); + emp2.setFirstName("foo"); + getEntityManager().merge(emp2); + getEntityManager().flush(); + clearCache(); + TestUtil.logTrace("find employee2 again"); + emp2 = getEntityManager().find(Employee2.class, 6); + TestUtil + .logTrace("Name:" + emp2.getFirstName() + " " + emp2.getLastName()); + String firstName = emp2.getFirstName(); + if (firstName == null) { + TestUtil.logTrace("Received expected null firstName"); + } else { + pass = false; + TestUtil.logErr("Expected firstName: null, actual:" + firstName); + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee3"); + Employee3 emp3 = getEntityManager().find(Employee3.class, 7); + TestUtil + .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); + TestUtil.logTrace("set firstName and save"); + emp3.setFirstName("foo"); + getEntityManager().merge(emp3); + getEntityManager().flush(); + clearCache(); + TestUtil.logTrace("find employee3 again"); + emp3 = getEntityManager().find(Employee3.class, 7); + TestUtil + .logTrace("Name:" + emp3.getFirstName() + " " + emp3.getLastName()); + firstName = emp3.getFirstName(); + if (firstName != null && firstName.equals("Paul")) { + TestUtil.logTrace("Received expected firstName:" + firstName); + } else { + pass = false; + TestUtil.logErr("Expected firstName: Paul, actual: null"); + } + + clearCache(); + TestUtil.logTrace("--------------"); + TestUtil.logTrace("find employee4"); + Employee4 emp4 = getEntityManager().find(Employee4.class, 8); + TestUtil + .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); + TestUtil.logTrace("set firstName and save"); + emp4.setFirstName("foo"); + getEntityManager().merge(emp4); + getEntityManager().flush(); + clearCache(); + TestUtil.logTrace("find employee4 again"); + emp4 = getEntityManager().find(Employee4.class, 8); + TestUtil + .logTrace("Name:" + emp4.getFirstName() + " " + emp4.getLastName()); + firstName = emp4.getFirstName(); + if (firstName != null && firstName.equals("foo")) { + TestUtil.logTrace("Received expected firstName:" + firstName); + } else { + pass = false; + TestUtil.logErr("Expected firstName: foo, actual: null"); + } + + getEntityTransaction().commit(); + + } catch (Exception e) { + pass = false; + TestUtil.logErr("Received unexpected exception", e); + } + + if (!pass) { + throw new Exception("columnUpdatable Failed"); + } + + } + + public void createTestData2() throws Exception { + try { + + TestUtil.logTrace("createTestData2"); + createTestDataCommon(); + getEntityTransaction().begin(); + + // insertable = false, updatable = false + TestUtil.logTrace("Create and persist employee2 "); + empRef2 = new Employee2(6, "John", "Smith"); + empRef2.setDepartment(deptRef[0]); + getEntityManager().persist(empRef2); + + // insertable = true, updatable = false + TestUtil.logTrace("Create and persist employee3 "); + empRef3 = new Employee3(7, "Paul", "Jones"); + empRef3.setDepartment(deptRef[0]); + getEntityManager().persist(empRef3); + + // insertable = false, updatable = true + TestUtil.logTrace("Create and persist employee4 "); + empRef4 = new Employee4(8, "Thomas", "Brady"); + empRef4.setDepartment(deptRef[0]); + getEntityManager().persist(empRef4); + getEntityManager().flush(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception creating test data:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + } + + } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT1.java new file mode 100644 index 0000000000..9b7f00dc56 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT1.java @@ -0,0 +1,483 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.orderby; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +public class ClientIT1 extends PMClientBase { + + List
addrRef; + + Address addr1 = null; + + Address addr2 = null; + + Address addr3 = null; + + List addrRef2; + + Address2 addr11 = null; + + Address2 addr12 = null; + + Address2 addr13 = null; + + public ClientIT1() { + } + +@BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeTestData(); + createTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: orderByTest1 + * + * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; + * PERSISTENCE:SPEC:1106; PERSISTENCE:JAVADOC:145; + * + * @test_Strategy: The OrderBy annotation specifies the ordering of the + * elements of a collection valued association at the point when the + * association is retrieved. + * + * The property name must correspond to that of a persistenct property of the + * associated class. + * + * The property used in the ordering must correspond to columns for which + * comparison operations are supported. + * + * If DESC is specified, the elements will be ordered in descending order. + * + * Retrieve the Collection using getter property accessor. + */ +@Test + public void orderByTest1() throws Exception { + + TestUtil.logTrace("Begin orderByTest1"); + boolean pass1 = true; + boolean pass2 = false; + List resultsList = new ArrayList(); + final String[] expectedResult = new String[] { "Zoe", "Song", "Jie", "Ay" }; + + try { + getEntityTransaction().begin(); + + Employee empChange = getEntityManager().find(Employee.class, 65); + + empChange.setFirstName("Ay"); + getEntityManager().merge(empChange); + getEntityManager().flush(); + + final Insurance newIns = getEntityManager().find(Insurance.class, 60); + getEntityManager().refresh(newIns); + + final List insResult = newIns.getEmployees(); + + if (insResult.size() != 4) { + TestUtil.logTrace( + "orderByTest1: Did not get expected results. Expected: 4, " + + "got: " + insResult.size()); + pass1 = false; + } else if (pass1) { + Iterator i1 = insResult.iterator(); + TestUtil.logTrace("Check Employee Collection for expected first names"); + while (i1.hasNext()) { + Employee e1 = (Employee) i1.next(); + resultsList.add((String) e1.getFirstName()); + TestUtil.logTrace("orderByTest1: got Employee FirstName:" + + (String) e1.getFirstName()); + } + + TestUtil.logTrace( + "Compare first names received with expected first names "); + String[] result = (String[]) (resultsList + .toArray(new String[resultsList.size()])); + pass2 = Arrays.equals(expectedResult, result); + + } + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + pass2 = false; + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass1 || !pass2) + throw new Exception("orderByTest1 failed"); + } + + /* + * @testName: orderByTest2 + * + * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; + * PERSISTENCE:SPEC:1106; PERSISTENCE:SPEC:1109; PERSISTENCE:SPEC:1110; + * PERSISTENCE:JAVADOC:145; PERSISTENCE:SPEC:653 + * + * @test_Strategy: The OrderBy annotation specifies the ordering of the + * elements of a collection valued association at the point when the + * association is retrieved. + * + * The property name must correspond to that of a persistenct property of the + * associated class. + * + * The property used in the ordering must correspond to columns for which + * comparison operations are supported. + * + * If ASC is specified, the elements will be ordered in ascending order. + * + * Retrieve the Collection using getter property accessor. + */ +@Test + public void orderByTest2() throws Exception { + + TestUtil.logTrace("Begin orderByTest2"); + boolean pass1 = true; + boolean pass2 = false; + List resultsList = new ArrayList(); + final String[] expectedResult = new String[] { "Jie", "Song", "Yay", + "Zoe" }; + + try { + getEntityTransaction().begin(); + + Employee emp2Change = getEntityManager().find(Employee.class, 65); + + emp2Change.setFirstName("Yay"); + getEntityManager().merge(emp2Change); + getEntityManager().flush(); + + final Department newDept = getEntityManager().find(Department.class, 50); + getEntityManager().refresh(newDept); + + final List deptResult = newDept.getEmployees(); + + if (deptResult.size() != 4) { + TestUtil.logTrace( + "orderByTest2: Did not get expected results. Expected: 4, " + + "got: " + deptResult.size()); + pass1 = false; + } else if (pass1) { + Iterator i2 = deptResult.iterator(); + TestUtil.logTrace("Check Employee Collection for expected first names"); + while (i2.hasNext()) { + Employee e2 = (Employee) i2.next(); + resultsList.add((String) e2.getFirstName()); + TestUtil.logTrace("orderByTest2: got Employee FirstName:" + + (String) e2.getFirstName()); + } + + TestUtil.logTrace( + "Compare first names received with expected first names "); + String[] result = (String[]) (resultsList + .toArray(new String[resultsList.size()])); + pass2 = Arrays.equals(expectedResult, result); + + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass1 || !pass2) + throw new Exception("orderByTest2 failed"); + } + + /* + * @testName: orderByTest3 + * + * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; + * PERSISTENCE:SPEC:1106; PERSISTENCE:JAVADOC:145 + * + * @test_Strategy: The OrderBy annotation specifies the ordering of the + * elements of a collection valued association at the point when the + * association is retrieved. + * + * If DESC is specified, the elements will be ordered in descending order. + * + * Add to the Collection then retrieve the updated Collection and ensure the + * list is ordered. + * + */ +@Test + public void orderByTest3() throws Exception { + TestUtil.logTrace("Begin orderByTest3"); + boolean pass1 = true; + boolean pass2 = false; + List insResult; + List resultsList = new ArrayList(); + final String[] expectedResult = new String[] { "Zoe", "Song", "Penelope", + "May", "Jie" }; + + try { + getEntityTransaction().begin(); + + Employee emp3Change = getEntityManager().find(Employee.class, 85); + Insurance ins = getEntityManager().find(Insurance.class, 60); + + emp3Change.setInsurance(ins); + getEntityManager().merge(emp3Change); + ins.getEmployees().add(emp3Change); + getEntityManager().merge(ins); + getEntityManager().flush(); + + getEntityManager().refresh(ins); + + insResult = ins.getEmployees(); + + if (insResult.size() != 5) { + TestUtil.logErr("orderByTest3: Expected List Size of 5 " + "got: " + + insResult.size()); + pass1 = false; + } else if (pass1) { + Iterator i3 = insResult.iterator(); + TestUtil.logTrace("Check Employee Collection for expected first names"); + while (i3.hasNext()) { + Employee e3 = (Employee) i3.next(); + resultsList.add((String) e3.getFirstName()); + TestUtil.logTrace("orderByTest3: got Employee FirstName:" + + (String) e3.getFirstName()); + } + + TestUtil.logTrace( + "orderByTest3: Expected size received, check ordering . . ."); + String[] result = (String[]) (resultsList + .toArray(new String[resultsList.size()])); + pass2 = Arrays.equals(expectedResult, result); + + } + + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass1 || !pass2) + throw new Exception("orderByTest3 failed"); + } + + /* + * @testName: orderByTest4 + * + * @assertion_ids: PERSISTENCE:SPEC:1103; PERSISTENCE:SPEC:1104; + * PERSISTENCE:SPEC:1106; PERSISTENCE:JAVADOC:145 + * + * @test_Strategy: The OrderBy annotation specifies the ordering of the + * elements of a collection valued association at the point when the + * association is retrieved. + * + * If ASC is specified, the elements will be ordered in ascending order. + * + * Retrieve the Collection, add to the Collection and retrieve it again making + * sure the list is ordered . + * + */ +@Test + public void orderByTest4() throws Exception { + TestUtil.logTrace("Begin orderByTest4"); + boolean pass1 = true; + boolean pass2 = false; + List resultsList = new ArrayList(); + final String[] expectedResult = new String[] { "Jie", "May", "Penelope", + "Song", "Zoe" }; + + try { + getEntityTransaction().begin(); + + Employee emp4Change = getEntityManager().find(Employee.class, 85); + Department dept = getEntityManager().find(Department.class, 50); + + emp4Change.setDepartment(dept); + getEntityManager().merge(emp4Change); + dept.getEmployees().add(emp4Change); + getEntityManager().merge(dept); + getEntityManager().flush(); + + getEntityManager().refresh(dept); + final List deptResult = dept.getEmployees(); + + if (deptResult.size() != 5) { + TestUtil.logErr("orderByTest4: Expected Collection Size of 5 " + "got: " + + deptResult.size()); + pass1 = false; + } else if (pass1) { + Iterator i4 = deptResult.iterator(); + TestUtil.logTrace("Check Employee Collection for expected first names"); + while (i4.hasNext()) { + Employee e4 = (Employee) i4.next(); + resultsList.add((String) e4.getFirstName()); + TestUtil.logTrace("orderByTest4: got Employee FirstName:" + + (String) e4.getFirstName()); + } + + TestUtil.logTrace( + "orderByTest4: Expected size received, check ordering . . ."); + String[] result = (String[]) (resultsList + .toArray(new String[resultsList.size()])); + pass2 = Arrays.equals(expectedResult, result); + } + + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + if (!pass1 || !pass2) + throw new Exception("orderByTest4 failed"); + } + + + private void createTestData() throws Exception { + try { + TestUtil.logTrace("createTestData"); + getEntityTransaction().begin(); + final float salary = 10000.00F; + + Department d1 = new Department(50, "SJSAS Appserver"); + getEntityManager().persist(d1); + + Insurance s1 = new Insurance(60, "United"); + getEntityManager().persist(s1); + + final Employee e1 = new Employee(70, "Jie", "Leng", salary, d1, s1); + final Employee e2 = new Employee(80, "Zoe", "Leng", salary, d1, s1); + final Employee e3 = new Employee(90, "Song", "Leng", salary, d1, s1); + final Employee e4 = new Employee(65, "May", "Leng", salary, d1, s1); + final Employee e5 = new Employee(85, "Penelope", "Leng", salary); + getEntityManager().persist(e1); + getEntityManager().persist(e2); + getEntityManager().persist(e3); + getEntityManager().persist(e4); + getEntityManager().persist(e5); + + List link = new ArrayList(); + link.add(e1); + link.add(e2); + link.add(e3); + link.add(e4); + + d1.setEmployees(link); + getEntityManager().merge(d1); + + s1.setEmployees(link); + getEntityManager().merge(s1); + + TestUtil.logTrace("persisted Entity Data"); + getEntityManager().flush(); + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception creating test data:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + } + + + @AfterEach + public void cleanup() throws Exception { + TestUtil.logTrace("cleanup"); + removeTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeTestData() { + TestUtil.logTrace("removeTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("Delete from EMPLOYEE") + .executeUpdate(); + getEntityManager().createNativeQuery("Delete from DEPARTMENT") + .executeUpdate(); + getEntityManager().createNativeQuery("Delete from INSURANCE") + .executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT2.java new file mode 100644 index 0000000000..c685b0c616 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT2.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.orderby; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +public class ClientIT2 extends PMClientBase { + + List
addrRef; + + Address addr1 = null; + + Address addr2 = null; + + Address addr3 = null; + + List addrRef2; + + Address2 addr11 = null; + + Address2 addr12 = null; + + Address2 addr13 = null; + + public ClientIT2() { + } + + +@BeforeEach + public void setupAddress() throws Exception { + TestUtil.logTrace("setupAddress"); + try { + super.setup(); + removeAddressData(); + createAddressData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: propertyDotNotationTest + * + * @assertion_ids: PERSISTENCE:SPEC:2089; PERSISTENCE:SPEC:2092; + * PERSISTENCE:SPEC:2091; + * + * @test_Strategy: identifier is the name of the respective property + * + */ + @Test + public void propertyDotNotationTest() throws Exception { + boolean pass = false; + + try { + addrRef = new ArrayList
(); + List
expected = new ArrayList
(); + expected.add(addr2); + expected.add(addr3); + expected.add(addr1); + + clearCache(); + A a = getEntityManager().find(A.class, "1"); + + List
actual = a.getAddressList(); + + if (actual.size() == expected.size()) { + int count = 0; + for (int i = 0; i < expected.size(); i++) { + TestUtil.logTrace("Testing - expected[" + expected.get(i) + + "], actual[" + actual.get(i) + "]"); + + if (expected.get(i).equals(actual.get(i))) { + count++; + } + } + if (count == expected.size()) { + pass = true; + } else { + TestUtil + .logErr("count=" + count + ", expected size:" + expected.size()); + for (Address aa : expected) { + TestUtil.logErr("expected:" + aa); + } + TestUtil.logErr("------------"); + for (Address aa : actual) { + TestUtil.logErr("actual:" + aa); + } + } + } else { + TestUtil.logErr("Expected list size:" + expected.size() + + ", actual size:" + actual.size()); + for (Address aa : expected) { + TestUtil.logErr("expected:" + aa); + } + TestUtil.logErr("------------"); + for (Address aa : actual) { + TestUtil.logErr("actual:" + aa); + } + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + if (!pass) { + throw new Exception("propertyDotNotationTest failed"); + } + } + + /* + * @testName: fieldDotNotationTest + * + * @assertion_ids: PERSISTENCE:SPEC:2089; PERSISTENCE:SPEC:2092; + * PERSISTENCE:SPEC:2091; + * + * @test_Strategy: identifier is the name of the respective field + * + */ + @Test + public void fieldDotNotationTest() throws Exception { + boolean pass = false; + + try { + addrRef = new ArrayList
(); + List expected = new ArrayList(); + expected.add(addr12); + expected.add(addr13); + expected.add(addr11); + + TestUtil.logTrace("Clearing the cache"); + clearCache(); + A2 a = getEntityManager().find(A2.class, "2"); + + List actual = a.getAddressList(); + + if (actual.size() == expected.size()) { + int count = 0; + for (int i = 0; i < expected.size(); i++) { + TestUtil.logTrace("Testing - expected[" + expected.get(i) + + "], actual[" + actual.get(i) + "]"); + + if (expected.get(i).equals(actual.get(i))) { + count++; + } + } + + if (count == expected.size()) { + pass = true; + } else { + TestUtil.logTrace( + "count=" + count + ", expected size:" + expected.size()); + for (Address2 aa : expected) { + TestUtil.logErr("expected:" + aa); + } + TestUtil.logErr("------------"); + for (Address2 aa : actual) { + TestUtil.logErr("actual:" + aa); + } + } + } else { + TestUtil.logErr("Expected list size:" + expected.size() + + ", actual size:" + actual.size()); + for (Address2 aa : expected) { + TestUtil.logErr("expected:" + aa); + } + TestUtil.logErr("------------"); + for (Address2 aa : actual) { + TestUtil.logErr("actual:" + aa); + } + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + if (!pass) { + throw new Exception("propertyDotNotationTest failed"); + } + } + + + private void createAddressData() throws Exception { + try { + TestUtil.logTrace("createAddressData"); + getEntityTransaction().begin(); + + addr1 = new Address("1 Network Drive", "Burlington", "MA", + new ZipCode("01801")); + addr2 = new Address("634 Goldstar Road", "Peabody", "MA", + new ZipCode("88444")); + addr3 = new Address("3212 Boston Road", "Chelmsford", "MA", + new ZipCode("01824")); + addrRef = new ArrayList
(); + addrRef.add(addr1); + addrRef.add(addr2); + addrRef.add(addr3); + A a1 = new A("1", "b1", addrRef); + + addr11 = new Address2("1 Network Drive", "Burlington", "MA", + new ZipCode2("01801")); + addr12 = new Address2("634 Goldstar Road", "Peabody", "MA", + new ZipCode2("88444")); + addr13 = new Address2("3212 Boston Road", "Chelmsford", "MA", + new ZipCode2("01824")); + addrRef2 = new ArrayList(); + addrRef2.add(addr11); + addrRef2.add(addr12); + addrRef2.add(addr13); + A2 a2 = new A2("2", "b2", addrRef2); + + getEntityManager().persist(a1); + getEntityManager().persist(a2); + + getEntityManager().flush(); + getEntityManager().refresh(a1); + getEntityManager().refresh(a2); + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception creating test data:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + } + + @AfterEach + public void cleanupAddress() throws Exception { + TestUtil.logTrace("cleanup"); + removeAddressData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeAddressData() { + TestUtil.logTrace("removeAddressData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("Delete from COLTAB_ADDRESS") + .executeUpdate(); + getEntityManager().createNativeQuery("Delete from COLTAB") + .executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT3.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT3.java new file mode 100644 index 0000000000..0071845526 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/orderby/ClientIT3.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.orderby; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +public class ClientIT3 extends PMClientBase { + + List
addrRef; + + Address addr1 = null; + + Address addr2 = null; + + Address addr3 = null; + + List addrRef2; + + Address2 addr11 = null; + + Address2 addr12 = null; + + Address2 addr13 = null; + + public ClientIT3() { + } + + +@BeforeEach + public void setupCust() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + removeCustTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + + } + } + + /* + * @testName: propertyElementCollectionBasicType + * + * @assertion_ids: PERSISTENCE:SPEC:2090 + * + * @test_Strategy: ElementCollection of a basic type + */ + @Test + public void propertyElementCollectionBasicType() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + Customer expected = new Customer("1"); + List expectedphones = new ArrayList(); + expectedphones.add("781-442-2010"); + expectedphones.add("781-442-2011"); + expectedphones.add("781-442-2012"); + + expected.setPhones(expectedphones); + TestUtil.logTrace("Persisting Customer:" + expected.toString()); + getEntityManager().persist(expected); + getEntityManager().flush(); + getEntityTransaction().commit(); + clearCache(); + getEntityTransaction().begin(); + TestUtil.logTrace( + "find the previously persisted Customer and Country and verify them"); + Customer cust = getEntityManager().find(Customer.class, expected.getId()); + if (cust != null) { + TestUtil.logTrace("Found Customer: " + cust.toString()); + if (cust.getPhones().containsAll(expectedphones) + && expectedphones.containsAll(cust.getPhones()) + && cust.getPhones().size() == expectedphones.size()) { + TestUtil.logTrace("Received expected Phones:"); + for (String s : cust.getPhones()) { + TestUtil.logTrace("phone:" + s); + } + pass = true; + } else { + TestUtil.logErr("Did not get expected results."); + for (String s : expectedphones) { + TestUtil.logErr("expected:" + s); + } + TestUtil.logErr("actual:"); + for (String s : cust.getPhones()) { + TestUtil.logErr("actual:" + s); + } + } + } else { + TestUtil.logErr("Find returned null Customer"); + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred: ", e); + pass = false; + } + if (!pass) { + throw new Exception("propertyElementCollectionBasicType failed"); + } + } + + /* + * @testName: fieldElementCollectionBasicType + * + * @assertion_ids: PERSISTENCE:SPEC:2090 + * + * @test_Strategy: ElementCollection of a basic type + */ + @Test + public void fieldElementCollectionBasicType() throws Exception { + boolean pass = false; + try { + getEntityTransaction().begin(); + Customer2 expected = new Customer2("2"); + List expectedphones = new ArrayList(); + expectedphones.add("781-442-2010"); + expectedphones.add("781-442-2011"); + expectedphones.add("781-442-2012"); + + expected.setPhones(expectedphones); + TestUtil.logTrace("Persisting Customer2:" + expected.toString()); + getEntityManager().persist(expected); + getEntityManager().flush(); + getEntityTransaction().commit(); + clearCache(); + getEntityTransaction().begin(); + Customer2 cust = getEntityManager().find(Customer2.class, + expected.getId()); + if (cust != null) { + TestUtil.logTrace("Found Customer2: " + cust.toString()); + if (cust.getPhones().containsAll(expectedphones) + && expectedphones.containsAll(cust.getPhones()) + && cust.getPhones().size() == expectedphones.size()) { + TestUtil.logTrace("Received expected Phones:"); + for (String s : cust.getPhones()) { + TestUtil.logTrace("phone:" + s); + } + pass = true; + } else { + TestUtil.logErr("Did not get expected results."); + for (String s : expectedphones) { + TestUtil.logErr("expected:" + s); + } + TestUtil.logErr("actual:"); + for (String s : cust.getPhones()) { + TestUtil.logErr("actual:" + s); + } + } + } else { + TestUtil.logErr("Find returned null Customer"); + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred: ", e); + pass = false; + } + if (!pass) { + throw new Exception("fieldElementCollectionBasicType failed"); + } + } + +@AfterEach + public void cleanupCust() throws Exception { + TestUtil.logTrace("cleanup"); + removeCustTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeCustTestData() { + TestUtil.logTrace("removeCustTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("DELETE FROM CUST_TABLE") + .executeUpdate(); + getEntityManager().createNativeQuery("DELETE FROM PHONES") + .executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } + + } diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT1.java new file mode 100755 index 0000000000..111e074b56 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT1.java @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.ordercolumn; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; + +public class ClientIT1 extends PMClientBase { + + private List expectedResults; + + public ClientIT1() { + } + + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + + super.setup(); + removeTestData(); + createStudentTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: orderColumn + * + * @assertion_ids: PERSISTENCE:SPEC:500; PERSISTENCE:SPEC:501; + * PERSISTENCE:SPEC:503; PERSISTENCE:SPEC:504; PERSISTENCE:SPEC:505; + * PERSISTENCE:SPEC:506; PERSISTENCE:SPEC:507; PERSISTENCE:SPEC:508; + * PERSISTENCE:SPEC:932; PERSISTENCE:SPEC:936; PERSISTENCE:SPEC:939; + * PERSISTENCE:SPEC:943; PERSISTENCE:SPEC:946; PERSISTENCE:SPEC:930; + * PERSISTENCE:SPEC:1018; PERSISTENCE:SPEC:1019; PERSISTENCE:SPEC:1020; + * PERSISTENCE:SPEC:1021; PERSISTENCE:SPEC:1023; PERSISTENCE:SPEC:1025; + * PERSISTENCE:SPEC:848; PERSISTENCE:SPEC:856; PERSISTENCE:SPEC:908; + * PERSISTENCE:SPEC:909; PERSISTENCE:SPEC:915; PERSISTENCE:SPEC:925; + * PERSISTENCE:SPEC:918; PERSISTENCE:SPEC:928; PERSISTENCE:SPEC:929; + * PERSISTENCE:JAVADOC:149; PERSISTENCE:JAVADOC:152; PERSISTENCE:JAVADOC:163; + * PERSISTENCE:SPEC:846; PERSISTENCE:SPEC:1204; PERSISTENCE:JAVADOC:378; + * PERSISTENCE:JAVADOC:379; PERSISTENCE:JAVADOC:377; PERSISTENCE:JAVADOC:380; + * + * @test_Strategy: With basic entity requirements, persist/remove an entity. + */ + @Test + public void orderColumn() throws Exception { + boolean pass = false; + final String expectedStudentName = "Joseph"; + final int expectedListSize = 4; + final int courseNumber = 101; + List students; + int numStudents = 0; + + try { + getEntityTransaction().begin(); + + final Course course = getEntityManager().find(Course.class, courseNumber); + + if (course != null) { + // force students to be read + numStudents = course.getStudents().size(); + } else { + TestUtil.logErr("course from find() is NULL!"); + } + + if (numStudents == expectedListSize) { + students = course.getStudents(); + if (students.get(0).equals(expectedResults.get(0)) + && students.get(1).equals(expectedResults.get(1)) + && students.get(2).equals(expectedResults.get(2)) + && students.get(3).equals(expectedResults.get(3))) { + TestUtil.logTrace("****Current order of students returned via " + + "getStudents()\nNow checking via JPQL"); + + Query q = getEntityManager().createQuery("SELECT s.studentName " + + "FROM Course c JOIN c.students s where c.courseName ='Physics' and INDEX(s) = 1"); + final String result = (String) q.getSingleResult(); + if (result.equals(expectedStudentName)) { + TestUtil.logTrace( + "+++Received expected Name via Query:" + expectedStudentName); + pass = true; + } else { + TestUtil.logErr("Did NOT get expected name via Query: " + + expectedStudentName + ", received: " + result); + } + + } else { + TestUtil.logErr("Failed to return the correct order of " + + "students via getStudents()"); + } + + } else { + TestUtil.logErr("course.getStudents() returned wrong number!"); + } + + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + } + + if (!pass) { + throw new Exception("orderColumn test failed"); + } + + } + + public void createStudentTestData() { + try { + TestUtil.logTrace("createTestData"); + getEntityTransaction().begin(); + + // Create 8 students; + Student student1 = new Student(1, "Neo"); + Student student2 = new Student(2, "Vivek"); + Student student3 = new Student(3, "Arun"); + Student student4 = new Student(4, "Ganesh"); + Student student5 = new Student(5, "Ram"); + Student student6 = new Student(6, "Rahim"); + Student student7 = new Student(7, "Joseph"); + Student student8 = new Student(8, "Krishna"); + + // Create 12 Courses; + Course appliedMath = new Course(101, "AppliedMathematics"); + Course physics = new Course(102, "Physics"); + Course operationResearch = new Course(103, "OperationResearch"); + Course statistics = new Course(201, "Statistics"); + Course operatingSystem = new Course(202, "OperatingSystem"); + + // Set enrolled students for each course + List studentList1 = new ArrayList(); + studentList1.add(student1); + studentList1.add(student7); + studentList1.add(student2); + studentList1.add(student8); + + expectedResults = new ArrayList(); + expectedResults.addAll(studentList1); + + // Set enrolled students for each course + List studentList2 = new ArrayList(); + studentList2.add(student3); + studentList2.add(student4); + + // Set enrolled students for each course + List studentList3 = new ArrayList(); + studentList3.add(student5); + studentList3.add(student6); + + // Set enrolled students for each course + List studentList4 = new ArrayList(); + studentList4.add(student7); + studentList4.add(student8); + + appliedMath.setStudents(studentList1); + physics.setStudents(studentList1); + operationResearch.setStudents(studentList1); + + statistics.setStudents(studentList2); + operatingSystem.setStudents(studentList2); + + // Set Courses for first semester + List firstSemCourses = new ArrayList(); + firstSemCourses.add(appliedMath); + firstSemCourses.add(physics); + firstSemCourses.add(operationResearch); + + // Set Courses for Second semester + List secondSemCourses = new ArrayList(); + secondSemCourses.add(statistics); + secondSemCourses.add(operatingSystem); + + // Set Courses for each student + student1.setCourses(firstSemCourses); + student2.setCourses(firstSemCourses); + student3.setCourses(secondSemCourses); + student4.setCourses(secondSemCourses); + student5.setCourses(secondSemCourses); + student6.setCourses(secondSemCourses); + student7.setCourses(firstSemCourses); + student8.setCourses(firstSemCourses); + + EntityManager entityManager = getEntityManager(); + + // persist 8 students + + entityManager.persist(student1); + entityManager.persist(student2); + entityManager.persist(student3); + entityManager.persist(student4); + entityManager.persist(student5); + entityManager.persist(student6); + entityManager.persist(student7); + entityManager.persist(student8); + TestUtil.logTrace("persisted 8 students"); + + // persist courses + entityManager.persist(appliedMath); + entityManager.persist(physics); + entityManager.persist(operationResearch); + entityManager.persist(statistics); + entityManager.persist(operatingSystem); + TestUtil.logTrace("persisted 5 Courses"); + + TestUtil.logTrace("persisted Entity Data"); + getEntityManager().flush(); + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception creating test data:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in rollback:", re); + } + } + + } + + @AfterEach + public void cleanup() throws Exception { + TestUtil.logTrace("cleanup"); + removeTestData(); + TestUtil.logTrace("cleanup complete, calling super.cleanup"); + super.cleanup(); + } + + private void removeTestData() { + TestUtil.logTrace("removeTestData"); + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + try { + getEntityTransaction().begin(); + getEntityManager().createNativeQuery("Delete from COURSE_STUDENT") + .executeUpdate(); + getEntityManager().createNativeQuery("Delete from STUDENT") + .executeUpdate(); + getEntityManager().createNativeQuery("Delete from COURSE") + .executeUpdate(); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Exception encountered while removing entities:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception in removeTestData:", re); + } + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT2.java old mode 100755 new mode 100644 similarity index 75% rename from jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java rename to jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT2.java index fe80a1aa39..3abef8dc76 --- a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/Client.java +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/ordercolumn/ClientIT2.java @@ -23,41 +23,24 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.sun.ts.lib.harness.CleanupMethod; -import com.sun.ts.lib.harness.SetupMethod; import com.sun.ts.lib.util.TestUtil; import com.sun.ts.tests.jpa.common.PMClientBase; import jakarta.persistence.EntityManager; -import jakarta.persistence.Query; import jakarta.persistence.TypedQuery; -public class Client extends PMClientBase { +public class ClientIT2 extends PMClientBase { private List expectedResults; - + private List expectedEmployees; private List expectedEmployees2; - public Client() { + public ClientIT2() { } - @BeforeEach - public void setup() throws Exception { - TestUtil.logTrace("setup"); - try { - - super.setup(); - removeTestData(); - createStudentTestData(); - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - throw new Exception("Setup failed:", e); - } - } - @BeforeEach public void setupEmployee() throws Exception { TestUtil.logTrace("setup"); @@ -72,88 +55,6 @@ public void setupEmployee() throws Exception { } } - /* - * @testName: orderColumn - * - * @assertion_ids: PERSISTENCE:SPEC:500; PERSISTENCE:SPEC:501; - * PERSISTENCE:SPEC:503; PERSISTENCE:SPEC:504; PERSISTENCE:SPEC:505; - * PERSISTENCE:SPEC:506; PERSISTENCE:SPEC:507; PERSISTENCE:SPEC:508; - * PERSISTENCE:SPEC:932; PERSISTENCE:SPEC:936; PERSISTENCE:SPEC:939; - * PERSISTENCE:SPEC:943; PERSISTENCE:SPEC:946; PERSISTENCE:SPEC:930; - * PERSISTENCE:SPEC:1018; PERSISTENCE:SPEC:1019; PERSISTENCE:SPEC:1020; - * PERSISTENCE:SPEC:1021; PERSISTENCE:SPEC:1023; PERSISTENCE:SPEC:1025; - * PERSISTENCE:SPEC:848; PERSISTENCE:SPEC:856; PERSISTENCE:SPEC:908; - * PERSISTENCE:SPEC:909; PERSISTENCE:SPEC:915; PERSISTENCE:SPEC:925; - * PERSISTENCE:SPEC:918; PERSISTENCE:SPEC:928; PERSISTENCE:SPEC:929; - * PERSISTENCE:JAVADOC:149; PERSISTENCE:JAVADOC:152; PERSISTENCE:JAVADOC:163; - * PERSISTENCE:SPEC:846; PERSISTENCE:SPEC:1204; PERSISTENCE:JAVADOC:378; - * PERSISTENCE:JAVADOC:379; PERSISTENCE:JAVADOC:377; PERSISTENCE:JAVADOC:380; - * - * @test_Strategy: With basic entity requirements, persist/remove an entity. - */ - @Test - public void orderColumn() throws Exception { - boolean pass = false; - final String expectedStudentName = "Joseph"; - final int expectedListSize = 4; - final int courseNumber = 101; - List students; - int numStudents = 0; - - try { - getEntityTransaction().begin(); - - final Course course = getEntityManager().find(Course.class, courseNumber); - - if (course != null) { - // force students to be read - numStudents = course.getStudents().size(); - } else { - TestUtil.logErr("course from find() is NULL!"); - } - - if (numStudents == expectedListSize) { - students = course.getStudents(); - if (students.get(0).equals(expectedResults.get(0)) - && students.get(1).equals(expectedResults.get(1)) - && students.get(2).equals(expectedResults.get(2)) - && students.get(3).equals(expectedResults.get(3))) { - TestUtil.logTrace("****Current order of students returned via " - + "getStudents()\nNow checking via JPQL"); - - Query q = getEntityManager().createQuery("SELECT s.studentName " - + "FROM Course c JOIN c.students s where c.courseName ='Physics' and INDEX(s) = 1"); - final String result = (String) q.getSingleResult(); - if (result.equals(expectedStudentName)) { - TestUtil.logTrace( - "+++Received expected Name via Query:" + expectedStudentName); - pass = true; - } else { - TestUtil.logErr("Did NOT get expected name via Query: " - + expectedStudentName + ", received: " + result); - } - - } else { - TestUtil.logErr("Failed to return the correct order of " - + "students via getStudents()"); - } - - } else { - TestUtil.logErr("course.getStudents() returned wrong number!"); - } - - getEntityTransaction().commit(); - - } catch (Exception e) { - TestUtil.logErr("Exception: ", e); - } - - if (!pass) { - throw new Exception("orderColumn test failed"); - } - - } - /* * @testName: propertyAccessWithNameTest * @@ -162,8 +63,6 @@ public void orderColumn() throws Exception { * * @test_Strategy: name is specified while using property access. */ - @SetupMethod(name = "setupEmployee") - @CleanupMethod(name = "cleanupEmployee") @Test public void propertyAccessWithNameTest() throws Exception { boolean pass = false; @@ -263,8 +162,6 @@ public void propertyAccessWithNameTest() throws Exception { * * @test_Strategy: name is specified while using property access. */ - @SetupMethod(name = "setupEmployee") - @CleanupMethod(name = "cleanupEmployee") @Test public void fieldAccessWithNameTest() throws Exception { boolean pass = false; @@ -527,13 +424,6 @@ private void createEmployeeTestData() throws Exception { } @AfterEach - public void cleanup() throws Exception { - TestUtil.logTrace("cleanup"); - removeTestData(); - TestUtil.logTrace("cleanup complete, calling super.cleanup"); - super.cleanup(); - } - public void cleanupEmployee() throws Exception { TestUtil.logTrace("cleanupEmployee"); // removeEmployeeTestData(); @@ -541,33 +431,6 @@ public void cleanupEmployee() throws Exception { super.cleanup(); } - private void removeTestData() { - TestUtil.logTrace("removeTestData"); - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - try { - getEntityTransaction().begin(); - getEntityManager().createNativeQuery("Delete from COURSE_STUDENT") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from STUDENT") - .executeUpdate(); - getEntityManager().createNativeQuery("Delete from COURSE") - .executeUpdate(); - getEntityTransaction().commit(); - } catch (Exception e) { - TestUtil.logErr("Exception encountered while removing entities:", e); - } finally { - try { - if (getEntityTransaction().isActive()) { - getEntityTransaction().rollback(); - } - } catch (Exception re) { - TestUtil.logErr("Unexpected Exception in removeTestData:", re); - } - } - } - private void removeEmployeeTestData() { TestUtil.logTrace("removeEmployeeTestData"); if (getEntityTransaction().isActive()) { diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT1.java new file mode 100644 index 0000000000..ad63877840 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT1.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.tableGenerator; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT1 extends Client { + + private DataTypes d0; + + public ClientIT1() { + } + + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + + super.setup(); + removeTestData(); + createTestData(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: generatorOnEntityTest + * + * @assertion_ids: PERSISTENCE:SPEC:2111; PERSISTENCE:SPEC:2111.1; + * PERSISTENCE:SPEC:2113; + * + * @test_Strategy: use a generator specified on an entity + */ +@Test + public void generatorOnEntityTest() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + int id = d0.getId(); + TestUtil.logTrace("find id: " + id); + DataTypes d = getEntityManager().find(DataTypes.class, id); + if (d != null) { + if (d.getStringData().equals(d0.getStringData())) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("EntityManager.find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("generatorOnEntityTest failed"); + } + + // Methods used for Tests + + public void createTestData() { + try { + getEntityTransaction().begin(); + + d0 = new DataTypes(); + d0.setStringData("testData"); + TestUtil.logTrace("DataType:" + d0.toString()); + getEntityManager().persist(d0); + + getEntityManager().flush(); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT2.java new file mode 100644 index 0000000000..590f489f88 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT2.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.tableGenerator; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT2 extends Client { + + private DataTypes2 d2; + + public ClientIT2() { + } + + + @BeforeEach + public void setup2() throws Exception { + TestUtil.logTrace("setup2"); + try { + + super.setup(); + removeTestData(); + createTestData2(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: generatorOnPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2111; PERSISTENCE:SPEC:2111.3; + * PERSISTENCE:SPEC:2113; + * + * @test_Strategy: use a generator specified on a property + */ + @Test + public void generatorOnPropertyTest() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + int id = d2.getId(); + TestUtil.logTrace("find id: " + id); + DataTypes2 d = getEntityManager().find(DataTypes2.class, id); + if (d != null) { + if (d.getStringData().equals(d2.getStringData())) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("EntityManager.find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("generatorOnPropertyTest failed"); + } + + + // Methods used for Tests + + public void createTestData2() { + try { + getEntityTransaction().begin(); + d2 = new DataTypes2(); + d2.setStringData("testData2"); + TestUtil.logTrace("DataType2:" + d2.toString()); + getEntityManager().persist(d2); + + getEntityManager().flush(); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT3.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT3.java new file mode 100644 index 0000000000..d3270eae63 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT3.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.tableGenerator; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT3 extends Client { + + private DataTypes3 d3; + + public ClientIT3() { + } + + @BeforeEach + public void setup3() throws Exception { + TestUtil.logTrace("setup3"); + try { + + super.setup(); + removeTestData(); + createTestData3(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: generatorOnFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2111; PERSISTENCE:SPEC:2111.2; + * PERSISTENCE:SPEC:2113; + * + * @test_Strategy: use a generator specified on a field + */ + @Test + public void generatorOnFieldTest() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + int id = d3.getId(); + TestUtil.logTrace("find id: " + id); + DataTypes3 d = getEntityManager().find(DataTypes3.class, id); + if (d != null) { + if (d.getStringData().equals(d3.getStringData())) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("EntityManager.find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("generatorOnFieldTest failed"); + } + + + // Methods used for Tests + + public void createTestData3() { + try { + getEntityTransaction().begin(); + + d3 = new DataTypes3(); + d3.setStringData("testData3"); + TestUtil.logTrace("DataType3:" + d3.toString()); + getEntityManager().persist(d3); + + getEntityManager().flush(); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT4.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT4.java new file mode 100644 index 0000000000..f1894fba9d --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/tableGenerator/ClientIT4.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.tableGenerator; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT4 extends Client { + + private DataTypes4 d4; + + public ClientIT4() { + } + + @BeforeEach + public void setup4() throws Exception { + TestUtil.logTrace("setup4"); + try { + + super.setup(); + removeTestData(); + createTestData4(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: generatorGlobalTest + * + * @assertion_ids: PERSISTENCE:SPEC:2112; PERSISTENCE:SPEC:2113; + * + * @test_Strategy: Use the generator defined by another entity + */ + @Test + public void generatorGlobalTest() throws Exception { + + boolean pass = false; + + try { + getEntityTransaction().begin(); + int id = d4.getId(); + TestUtil.logTrace("find id: " + id); + DataTypes4 d = getEntityManager().find(DataTypes4.class, id); + if (d != null) { + if (d.getStringData().equals(d4.getStringData())) { + pass = true; + } + + getEntityTransaction().commit(); + } else { + TestUtil.logErr("EntityManager.find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) + throw new Exception("generatorGlobalTest failed"); + } + + // Methods used for Tests + + public void createTestData4() { + try { + getEntityTransaction().begin(); + + d4 = new DataTypes4(); + d4.setStringData("testData4"); + TestUtil.logTrace("DataType4:" + d4.toString()); + getEntityManager().persist(d4); + + getEntityManager().flush(); + getEntityTransaction().commit(); + + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT1.java new file mode 100644 index 0000000000..6ee5ea7e13 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT1.java @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.version; + + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.PMClientBase; + +public class ClientIT1 extends Client { + + public ClientIT1() { + } + + + @BeforeEach + public void setupIntData() throws Exception { + TestUtil.logTrace("setupIntData"); + try { + super.setup(); + + removeTestData(); + createIntTestData(); + + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: intFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2115; PERSISTENCE:SPEC:2116; + * PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.1 + * + * @test_Strategy: + */ + @Test + public void intFieldTest() throws Exception { + + boolean pass = false; + try { + Int_Field a = getEntityManager().find(Int_Field.class, "1"); + if (a != null) { + // if (a.getVersion() == 1) { + TestUtil.logTrace("version:" + a.getVersion()); + int version = a.getVersion(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Int_Field a1 = getEntityManager().find(Int_Field.class, "1"); + if (a1 != null) { + if (a1.getVersion() > version) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("intFieldTest failed"); + } + + } + + /* + * @testName: intPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2115; PERSISTENCE:SPEC:2116; + * PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.1 + * + * @test_Strategy: + */ + @Test + public void intPropertyTest() throws Exception { + boolean pass = false; + try { + Int_Property a = getEntityManager().find(Int_Property.class, "2"); + if (a != null) { + TestUtil.logTrace("version:" + a.getValue()); + // if (a.getVersion() == 1) { + int version = a.getValue(); + + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Int_Property a1 = getEntityManager().find(Int_Property.class, "2"); + if (a1 != null) { + if (a1.getValue() > version) { + TestUtil.logTrace("version:" + a1.getValue()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getValue()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("intPropertyTest failed"); + } + + } + + /* + * @testName: integerFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.2 + * + * @test_Strategy: + */ + @Test + public void integerFieldTest() throws Exception { + + boolean pass = false; + try { + Integer_Field a = getEntityManager().find(Integer_Field.class, "3"); + if (a != null) { + TestUtil.logTrace("version:" + a.getVersion()); + // if (a.getVersion() == 1) { + Integer version = a.getVersion(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Integer_Field a1 = getEntityManager().find(Integer_Field.class, "3"); + if (a1 != null) { + if (a1.getVersion() > version) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("integerFieldTest failed"); + } + + } + + /* + * @testName: integerPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.2 + * + * @test_Strategy: + */ + @Test + public void integerPropertyTest() throws Exception { + boolean pass = false; + try { + Integer_Property a = getEntityManager().find(Integer_Property.class, "4"); + if (a != null) { + TestUtil.logTrace("version:" + a.getBasicInteger()); + // if (a.getVersion() == 1) { + Integer version = a.getBasicInteger(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Integer_Property a1 = getEntityManager().find(Integer_Property.class, + "4"); + if (a1 != null) { + if (a1.getBasicInteger() > version) { + TestUtil.logTrace("version:" + a1.getBasicInteger()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getBasicInteger()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("integerPropertyTest failed"); + } + + } + + public void createIntTestData() { + TestUtil.logTrace("createIntTestData"); + + try { + getEntityTransaction().begin(); + getEntityManager().persist(new Int_Field("1")); + getEntityManager().persist(new Int_Property("2")); + getEntityManager().persist(new Integer_Field("3", new Integer(0))); + getEntityManager().persist(new Integer_Property("4", new Integer(0))); + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createIntTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT2.java new file mode 100644 index 0000000000..214aa42e49 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT2.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.version; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT2 extends Client { + + public ClientIT2() { + } + + @BeforeEach + public void setupShortData() throws Exception { + TestUtil.logTrace("setupShortData"); + try { + super.setup(); + + removeTestData(); + createShortTestData(); + + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: shortFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.3 + * + * @test_Strategy: + */ + @Test + public void shortFieldTest() throws Exception { + + boolean pass = false; + try { + Short_Field a = getEntityManager().find(Short_Field.class, "1"); + if (a != null) { + TestUtil.logTrace("version:" + a.getVersion()); + // if (a.getVersion() == 1) { + short version = a.getVersion(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Short_Field a1 = getEntityManager().find(Short_Field.class, "1"); + if (a1 != null) { + if (a1.getVersion() > version) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortFieldTest failed"); + } + + } + + /* + * @testName: shortPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.3 + * + * @test_Strategy: + */ + @Test + public void shortPropertyTest() throws Exception { + boolean pass = false; + try { + Short_Property a = getEntityManager().find(Short_Property.class, "2"); + if (a != null) { + TestUtil.logTrace("version:" + a.getBasicShort()); + // if (a.getVersion() == 1) { + short version = a.getBasicShort(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Short_Property a1 = getEntityManager().find(Short_Property.class, "2"); + if (a1 != null) { + if (a1.getBasicShort() > version) { + TestUtil.logTrace("version:" + a1.getBasicShort()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getBasicShort()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortPropertyTest failed"); + } + + } + + /* + * @testName: shortClassFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.4 + * + * @test_Strategy: + */ + @Test + public void shortClassFieldTest() throws Exception { + + boolean pass = false; + try { + ShortClass_Field a = getEntityManager().find(ShortClass_Field.class, "3"); + if (a != null) { + TestUtil.logTrace("version:" + a.getVersion()); + // if (a.getVersion() == 1) { + Short version = a.getVersion(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + ShortClass_Field a1 = getEntityManager().find(ShortClass_Field.class, + "3"); + if (a1 != null) { + if (a1.getVersion() > version) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortClassFieldTest failed"); + } + + } + + /* + * @testName: shortClassPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.4 + * + * @test_Strategy: + */ + @Test + public void shortClassPropertyTest() throws Exception { + boolean pass = false; + try { + ShortClass_Property a = getEntityManager().find(ShortClass_Property.class, + "4"); + if (a != null) { + TestUtil.logTrace("version:" + a.getBasicShort()); + // if (a.getVersion() == 1) { + Short version = a.getBasicShort(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + ShortClass_Property a1 = getEntityManager() + .find(ShortClass_Property.class, "4"); + if (a1 != null) { + if (a1.getBasicShort() > version) { + TestUtil.logTrace("version:" + a1.getBasicShort()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getBasicShort()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortClassPropertyTest failed"); + } + + } + + + public void createShortTestData() { + TestUtil.logTrace("createShortTestData"); + + try { + getEntityTransaction().begin(); + getEntityManager().persist(new Short_Field("1")); + getEntityManager().persist(new Short_Property("2")); + getEntityManager() + .persist(new ShortClass_Field("3", new Short((short) 0))); + getEntityManager() + .persist(new ShortClass_Property("4", new Short((short) 0))); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createShortTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT3.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT3.java new file mode 100644 index 0000000000..b2154febb0 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT3.java @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.version; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT3 extends Client { + + public ClientIT3() { + } + + + @BeforeEach + public void setupLongData() throws Exception { + TestUtil.logTrace("setupLongData"); + try { + super.setup(); + + removeTestData(); + createLongTestData(); + + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: longFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.5 + * + * @test_Strategy: + */ + @Test + public void longFieldTest() throws Exception { + + boolean pass = false; + try { + Long_Field a = getEntityManager().find(Long_Field.class, "1"); + if (a != null) { + TestUtil.logTrace("version:" + a.getVersion()); + // if (a.getVersion() == 1) { + long version = a.getVersion(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Long_Field a1 = getEntityManager().find(Long_Field.class, "1"); + if (a1 != null) { + if (a1.getVersion() > version) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortFieldTest failed"); + } + + } + + /* + * @testName: longPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.5 + * + * @test_Strategy: + */ + @Test + public void longPropertyTest() throws Exception { + boolean pass = false; + try { + Long_Property a = getEntityManager().find(Long_Property.class, "2"); + if (a != null) { + TestUtil.logTrace("version:" + a.getBasicLong()); + // if (a.getVersion() == 1) { + long version = a.getBasicLong(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Long_Property a1 = getEntityManager().find(Long_Property.class, "2"); + if (a1 != null) { + if (a1.getBasicLong() > version) { + TestUtil.logTrace("version:" + a1.getBasicLong()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getBasicLong()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortPropertyTest failed"); + } + + } + + /* + * @testName: longClassFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.6 + * + * @test_Strategy: + */ + @Test + public void longClassFieldTest() throws Exception { + + boolean pass = false; + try { + LongClass_Field a = getEntityManager().find(LongClass_Field.class, "3"); + if (a != null) { + TestUtil.logTrace("version:" + a.getVersion()); + // if (a.getVersion() == 1) { + Long version = a.getVersion(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + LongClass_Field a1 = getEntityManager().find(LongClass_Field.class, + "3"); + if (a1 != null) { + if (a1.getVersion() > version) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortClassFieldTest failed"); + } + + } + + /* + * @testName: longClassPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.6 + * + * @test_Strategy: + */ + @Test + public void longClassPropertyTest() throws Exception { + boolean pass = false; + try { + LongClass_Property a = getEntityManager().find(LongClass_Property.class, + "4"); + if (a != null) { + TestUtil.logTrace("version:" + a.getBasicLong()); + // if (a.getVersion() == 1) { + Long version = a.getBasicLong(); + a.setName("two"); + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + LongClass_Property a1 = getEntityManager() + .find(LongClass_Property.class, "4"); + if (a1 != null) { + if (a1.getBasicLong() > version) { + TestUtil.logTrace("version:" + a1.getBasicLong()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getBasicLong()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("shortClassPropertyTest failed"); + } + + } + + public void createLongTestData() { + TestUtil.logTrace("createLongTestData"); + + try { + getEntityTransaction().begin(); + getEntityManager().persist(new Long_Field("1")); + getEntityManager().persist(new Long_Property("2")); + getEntityManager().persist(new LongClass_Field("3", new Long(0))); + getEntityManager().persist(new LongClass_Property("4", new Long(0))); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createLongTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT4.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT4.java new file mode 100644 index 0000000000..8fb4a76706 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/annotations/version/ClientIT4.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.annotations.version; + +import java.sql.Timestamp; +import java.util.Date; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.util.TestUtil; + +public class ClientIT4 extends Client { + + public ClientIT4() { + } + + @BeforeEach + public void setupTimestampData() throws Exception { + TestUtil.logTrace("setupTimestampData"); + try { + super.setup(); + + removeTestData(); + createTimestampTestData(); + + } catch (Exception e) { + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: timestampFieldTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.7 + * + * @test_Strategy: + */ + @Test + public void timestampFieldTest() throws Exception { + + boolean pass = false; + try { + Timestamp_Field a = getEntityManager().find(Timestamp_Field.class, "1"); + if (a != null) { + TestUtil.logTrace("version:" + a.getVersion()); + // if (a.getVersion() == 1) { + Timestamp version = a.getVersion(); + a.setName("two"); + // Sleep for 1 second + try { + Thread.sleep(1 * 1000L); + } catch (Exception ex) { + ex.printStackTrace(); + } + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Timestamp_Field a1 = getEntityManager().find(Timestamp_Field.class, + "1"); + if (a1 != null) { + if (a1.getVersion().after(version)) { + TestUtil.logTrace("version:" + a1.getVersion()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getVersion()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("timestampFieldTest failed"); + } + + } + + /* + * @testName: timestampPropertyTest + * + * @assertion_ids: PERSISTENCE:SPEC:2117; PERSISTENCE:SPEC:2117.7 + * + * @test_Strategy: + */ + @Test + public void timestampPropertyTest() throws Exception { + boolean pass = false; + try { + Timestamp_Property a = getEntityManager().find(Timestamp_Property.class, + "2"); + if (a != null) { + TestUtil.logTrace("version:" + a.getBasicTimestamp()); + // if (a.getVersion() == 1) { + Timestamp version = a.getBasicTimestamp(); + a.setName("two"); + // Sleep for 1 second + try { + Thread.sleep(1 * 1000L); + } catch (Exception ex) { + ex.printStackTrace(); + } + getEntityTransaction().begin(); + getEntityManager().merge(a); + getEntityManager().flush(); + getEntityTransaction().commit(); + Timestamp_Property a1 = getEntityManager() + .find(Timestamp_Property.class, "2"); + if (a1 != null) { + if (a1.getBasicTimestamp().after(version)) { + TestUtil.logTrace("version:" + a1.getBasicTimestamp()); + pass = true; + } else { + TestUtil + .logErr("Did not get a greater version after a modification:" + + a1.getBasicTimestamp()); + } + } else { + TestUtil.logErr("Second find returned null result"); + } + /* + * } else { TestUtil.logErr("Did not get a version of 1 after find"); } + */ + } else { + TestUtil.logErr("Find returned null result"); + } + } catch (Exception e) { + TestUtil.logErr("Unexpected exception occurred", e); + } + + if (!pass) { + throw new Exception("timestampPropertyTest failed"); + } + + } + + public void createTimestampTestData() { + TestUtil.logTrace("createTimestampTestData"); + + try { + getEntityTransaction().begin(); + Timestamp currentTime = new Timestamp(new Date().getTime()); + getEntityManager().persist(new Timestamp_Field("1", currentTime)); + getEntityManager().persist(new Timestamp_Property("2", currentTime)); + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Unexpected Exception in createTimestampTestData:", e); + } finally { + try { + if (getEntityTransaction().isActive()) { + getEntityTransaction().rollback(); + } + } catch (Exception re) { + TestUtil.logErr("Unexpected Exception during Rollback:", re); + } + } + + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT1.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT1.java new file mode 100644 index 0000000000..6f180527c3 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT1.java @@ -0,0 +1,401 @@ +/* + * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.criteriaapi.CriteriaBuilder; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.harness.SetupMethod; +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.schema30.Address; +import com.sun.ts.tests.jpa.common.schema30.Alias; +import com.sun.ts.tests.jpa.common.schema30.Customer; +import com.sun.ts.tests.jpa.common.schema30.Customer_; +import com.sun.ts.tests.jpa.common.schema30.HardwareProduct; +import com.sun.ts.tests.jpa.common.schema30.LineItem; +import com.sun.ts.tests.jpa.common.schema30.Order; +import com.sun.ts.tests.jpa.common.schema30.Order_; +import com.sun.ts.tests.jpa.common.schema30.Product; +import com.sun.ts.tests.jpa.common.schema30.ShelfLife; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct_; +import com.sun.ts.tests.jpa.common.schema30.Spouse; +import com.sun.ts.tests.jpa.common.schema30.Trim; +import com.sun.ts.tests.jpa.common.schema30.Util; + +import jakarta.persistence.Query; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.Trimspec; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ParameterExpression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; + +public class ClientIT1 extends Util { + +@BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + getEntityManager(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + /* + * @testName: createQuery + * + * @assertion_ids: PERSISTENCE:JAVADOC:756; PERSISTENCE:SPEC:1701; + * PERSISTENCE:SPEC:1703; PERSISTENCE:SPEC:1704; + * + * @test_Strategy: + * + */ + @Test + public void createQuery() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("createQuery Test failed"); + } + } + + /* + * @testName: createQuery2 + * + * @assertion_ids: PERSISTENCE:JAVADOC:757; PERSISTENCE:SPEC:1703; + * PERSISTENCE:SPEC:1704; + * + * @test_Strategy: + * + */ + @Test + public void createQuery2() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Order.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("createQuery2 Test failed"); + } + } + + /* + * @testName: createTuple + * + * @assertion_ids: PERSISTENCE:JAVADOC:758; PERSISTENCE:SPEC:1703; + * PERSISTENCE:SPEC:1704; + * + * @test_Strategy: + * + */ + @Test + public void createTuple() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query Tuple"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query Tuple"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("createTuple Test failed"); + } + } + + /* + * @testName: tupleSelectionArrayIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:873 + * + * @test_Strategy: + */ + @Test + public void tupleSelectionArrayIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + try { + CriteriaBuilder qbuilder = getEntityManagerFactory().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = qbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root cust = cquery.from(Customer.class); + + Selection[] s = { cust.get("id"), cust.get("name") }; + + TestUtil.logMsg("Testing tuple"); + try { + qbuilder.tuple(qbuilder.tuple(s)); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + TestUtil.logMsg("Testing array"); + try { + qbuilder.tuple(qbuilder.array(s)); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + if (!pass1 || !pass2) { + throw new Exception("tupleSelectionArrayIllegalArgumentExceptionTest failed"); + } + } + + + /* + * @testName: literalIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:807 + * + * @test_Strategy: + */ + @Test + public void literalIllegalArgumentExceptionTest() throws Exception { + boolean pass = false; + + try { + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + cbuilder.literal(null); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception:", e); + } + + if (!pass) { + throw new Exception("literalIllegalArgumentExceptionTest failed"); + } + } + + + + + /* + * @testName: trimspecTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:915; PERSISTENCE:JAVADOC:916 + * + * @test_Strategy: + * + * + */ + @Test + public void trimspecTest() throws Exception { + boolean pass1 = false; + boolean pass2 = true; + Collection expected = new ArrayList(); + expected.add(CriteriaBuilder.Trimspec.BOTH); + expected.add(CriteriaBuilder.Trimspec.LEADING); + expected.add(CriteriaBuilder.Trimspec.TRAILING); + + try { + CriteriaBuilder.Trimspec[] ts = CriteriaBuilder.Trimspec.values(); + if (ts.length == 3) { + for (CriteriaBuilder.Trimspec tspec : ts) { + pass1 = true; + if (expected.contains(tspec)) { + TestUtil.logMsg("Testing valueOf:" + tspec); + CriteriaBuilder.Trimspec.valueOf(tspec.toString()); + } else { + pass2 = false; + TestUtil.logErr("values() returned incorrect value:" + tspec); + } + } + } else { + TestUtil.logErr("Expected number of values:3, actual:" + ts.length); + } + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + if (!pass1 || !pass2) { + throw new Exception("trimspecTest failed"); + + } + } + + /* + * @testName: createCriteriaDeleteTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1676; PERSISTENCE:SPEC:1701; + * + * @test_Strategy: + */ + @Test + public void createCriteriaDeleteTest() throws Exception { + boolean pass = false; + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + try { + CriteriaDelete cd = cbuilder.createCriteriaDelete(Product.class); + if (cd != null) { + TestUtil.logTrace("Obtained Non-null CriteriaDelete"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null CriteriaDelete"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception", ex); + } + + if (!pass) { + throw new Exception("createCriteriaDeleteTest test failed"); + } + } + + /* + * @testName: createCriteriaUpdateTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1677; PERSISTENCE:SPEC:1701; + * + * @test_Strategy: + */ + @Test + public void createCriteriaUpdateTest() throws Exception { + boolean pass = false; + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + try { + CriteriaUpdate cd = cbuilder.createCriteriaUpdate(Product.class); + if (cd != null) { + TestUtil.logTrace("Obtained Non-null CriteriaUpdate"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null CriteriaUpdate"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception", ex); + } + + if (!pass) { + throw new Exception("createCriteriaUpdateTest test failed"); + } + } + + /* + * @testName: coalesceTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:747 + * + * @test_Strategy: + */ + @Test + public void coalesceTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + getEntityTransaction().begin(); + CriteriaBuilder.Coalesce col = cbuilder.coalesce(); + if (col != null) { + TestUtil.logTrace("Obtained Non-null Coalesce"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null Coalesce"); + + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("coalesceTest failed"); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT2.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT2.java new file mode 100644 index 0000000000..5244208a0f --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT2.java @@ -0,0 +1,3528 @@ +/* + * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.criteriaapi.CriteriaBuilder; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.harness.SetupMethod; +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.schema30.Address; +import com.sun.ts.tests.jpa.common.schema30.Alias; +import com.sun.ts.tests.jpa.common.schema30.Customer; +import com.sun.ts.tests.jpa.common.schema30.Customer_; +import com.sun.ts.tests.jpa.common.schema30.HardwareProduct; +import com.sun.ts.tests.jpa.common.schema30.LineItem; +import com.sun.ts.tests.jpa.common.schema30.Order; +import com.sun.ts.tests.jpa.common.schema30.Order_; +import com.sun.ts.tests.jpa.common.schema30.Product; +import com.sun.ts.tests.jpa.common.schema30.ShelfLife; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct_; +import com.sun.ts.tests.jpa.common.schema30.Spouse; +import com.sun.ts.tests.jpa.common.schema30.Trim; +import com.sun.ts.tests.jpa.common.schema30.UtilCustomerData; + +import jakarta.persistence.Query; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.Trimspec; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ParameterExpression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; + +public class ClientIT2 extends UtilCustomerData { + + @BeforeEach + public void setup() throws Exception { + TestUtil.logTrace("setup"); + try { + super.setup(); + getEntityManager(); + } catch (Exception e) { + TestUtil.logErr("Exception: ", e); + throw new Exception("Setup failed:", e); + } + } + + + /* + * @testName: construct + * + * @assertion_ids: PERSISTENCE:JAVADOC:752; PERSISTENCE:JAVADOC:1470; + * PERSISTENCE:JAVADOC:1026; PERSISTENCE:SPEC:1705; PERSISTENCE:SPEC:1752; + * PERSISTENCE:SPEC:1754; PERSISTENCE:SPEC:1669; + * + * @test_Strategy: convert the following jpql to CriteriaQuery + * + * SELECT NEW com.sun.ts.tests.jpa.core.query.language.schema30.Customer + * (c.id, c.name) FROM Customer c where c.home.city = 'Roslindale' + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void construct() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + + expected[0] = customerRef[16].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery + .select(cbuilder.construct( + com.sun.ts.tests.jpa.common.schema30.Customer.class, + customer.get(Customer_.getSingularAttribute("id", String.class)), + customer + .get(Customer_.getSingularAttribute("name", String.class)))) + .where( + cbuilder.equal( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("city", String.class)), + "Roslindale")); + TypedQuery tq = getEntityManager().createQuery(cquery); + List actual = tq.getResultList(); + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("construct Test failed"); + } + } + + /* + * @testName: tupleIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:433 + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void tupleIntTest() throws Exception { + boolean pass1 = true; + boolean pass2 = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + expected.add(Integer.valueOf(c.getId())); + } + Collections.sort(expected); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)), + customer.get(Customer_.getSingularAttribute("name", String.class))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + + for (Tuple t : result) { + Integer id = Integer.valueOf((String) t.get(0)); + String name = (String) t.get(1); + if (name != null) { + if (customerRef[id - 1].getName().equals(name)) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:|" + customerRef[id - 1].getName() + + "|, actual:|" + name + "|"); + pass1 = false; + } + } else { + if (customerRef[id - 1].getName() == null) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:" + customerRef[id - 1].getName() + + ", actual:null"); + pass1 = false; + } + } + + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass2 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("tupleIntTest test failed"); + } + } + + /* + * @testName: tupleToArrayTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:435; PERSISTENCE:SPEC:1727; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c where (id = 3 or id = 4) + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void tupleToArrayTest() throws Exception { + boolean pass = false; + + List expected = new ArrayList(); + expected.add(customerRef[2].getId()); + expected.add(customerRef[2].getName()); + expected.add(customerRef[3].getId()); + expected.add(customerRef[3].getName()); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)), + customer.get(Customer_.getSingularAttribute("name", String.class))); + + cquery + .where( + cbuilder.or( + cbuilder.equal( + customer.get( + Customer_.getSingularAttribute("id", String.class)), + "3"), + cbuilder.equal( + customer.get( + Customer_.getSingularAttribute("id", String.class)), + "4")) + + ); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Tuple t : result) { + for (Object o : t.toArray()) { + TestUtil.logTrace("Object:" + o); + actual.add((String) o); + } + } + if (TestUtil.traceflag) { + TestUtil.logTrace("actual" + actual); + } + + if (expected.containsAll(actual) && actual.containsAll(expected) + && expected.size() == actual.size()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expected + ", actual: " + actual); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("tupleToArrayTest test failed"); + } + } + + /* + * @testName: tupleIntClassTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:432; PERSISTENCE:SPEC:1706 + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void tupleIntClassTest() throws Exception { + boolean pass1 = true; + boolean pass2 = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + expected.add(Integer.valueOf(c.getId())); + } + Collections.sort(expected); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)), + customer.get(Customer_.getSingularAttribute("name", String.class))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + List actual = new ArrayList(); + + for (Tuple t : result) { + Integer id = Integer.valueOf((String) t.get(0)); + String name = (String) t.get(1); + if (name != null) { + if (customerRef[id - 1].getName().equals(name)) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:|" + customerRef[id - 1].getName() + + "|, actual:|" + name + "|"); + pass1 = false; + } + } else { + if (customerRef[id - 1].getName() == null) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:" + customerRef[id - 1].getName() + + ", actual:null"); + pass1 = false; + } + } + + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass2 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("tupleIntClassTest test failed"); + } + } + + /* + * @testName: tupleGetIntClassIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:602; PERSISTENCE:SPEC:1303; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c Call Tuple.get() using a tuple element that does not + * exist + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void tupleGetIntClassIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + TestUtil.logTrace("Use Tuple Query"); + cquery.multiselect(customer.get("id"), customer.get("name"), + customer.get("home")); + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + Tuple t = result.get(0); + TestUtil.logMsg("Testing valid index"); + TestUtil.logTrace("value:" + t.get(1, String.class)); + + TestUtil.logMsg("Testing invalid index"); + try { + t.get(99, String.class); + + TestUtil.logErr( + "Did not get expected IllegalArgumentException for invalid index:" + + t.get(99, String.class)); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Got expected IllegalArgumentException"); + if (getEntityTransaction().getRollbackOnly() != true) { + pass1 = true; + } else { + TestUtil.logErr( + "Transaction was marked for rollback and should not have been"); + } + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + TestUtil.logMsg("Testing invalid type"); + + try { + t.get(2, Date.class); + + TestUtil.logErr( + "Did not get expected IllegalArgumentException for invalid type:" + + t.get(2, Date.class)); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Got expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("tupleGetIntClassIllegalArgumentExceptionTest failed"); + } + } + + /* + * @testName: tupleElementGetJavaTypeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:437 + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void tupleElementGetJavaTypeTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + Path idPath = customer + .get(Customer_.getSingularAttribute("id", String.class)); + Class type = idPath.getJavaType(); + if (type.getSimpleName().equals("String")) { + TestUtil.logTrace("type=" + type.getSimpleName()); + pass = true; + } else { + TestUtil.logErr("Expected element type of String, actual value:" + + type.getSimpleName()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + if (!pass) { + throw new Exception("tupleElementGetJavaTypeTest failed"); + } + } + + /* + * @testName: tupleSelectionArrayTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:872; PERSISTENCE:SPEC:1752; + * PERSISTENCE:SPEC:1754; + * + * @test_Strategy: Call tuple(Selection[]) and verify result Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void tupleSelectionArrayTest() throws Exception { + boolean pass = false; + + try { + CriteriaBuilder qbuilder = getEntityManagerFactory().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = qbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root cust = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = cust.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.where(qbuilder.equal( + cust.get(Customer_.getSingularAttribute("id", String.class)), "4")); + + Selection[] s = { cust.get("id"), cust.get("name") }; + cquery.select(qbuilder.tuple(s)); + + Query q = getEntityManager().createQuery(cquery); + + List result = q.getResultList(); + if (result.size() == 1) { + Tuple t = (Tuple) result.get(0); + String id = (String) t.get(0); + + if (id.equals(customerRef[3].getId())) { + TestUtil.logTrace("Received expected id:" + id); + pass = true; + } else { + TestUtil.logErr( + "Expected id:" + customerRef[3].getId() + ", actual:" + id); + } + String name = (String) t.get(1); + + if (name.equals(customerRef[3].getName())) { + TestUtil.logTrace("Received expected name:" + name); + } else { + TestUtil.logErr("Expected name:" + customerRef[3].getName() + + ", actual:" + name); + } + } else { + TestUtil + .logErr("Received incorrect result size - Expected: 1, Actual:" + + result.size()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + } catch (Exception e) { + + TestUtil.logErr("Received unexpected exception", e); + } + if (!pass) { + throw new Exception("tupleSelectionArrayTest failed"); + } + } + + /* + * @testName: array + * + * @assertion_ids: PERSISTENCE:JAVADOC:739; PERSISTENCE:SPEC:1752; + * PERSISTENCE:SPEC:1754; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery and return the + * result as an object array + * + * Select c.id, c.name from Customer c + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void array() throws Exception { + boolean pass1 = false; + boolean pass2 = true; + boolean pass3 = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + expected.add(Integer.valueOf(c.getId())); + } + Collections.sort(expected); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.select(cbuilder.array( + customer.get(Customer_.getSingularAttribute("id", String.class)), + customer.get(Customer_.getSingularAttribute("name", String.class)))); + + Query q = getEntityManager().createQuery(cquery); + + List result = q.getResultList(); + + List actual = new ArrayList(); + + pass1 = true; + for (Object[] row : result) { + Integer id = Integer.valueOf((String) row[0]); + String name = (String) row[1]; + if (name != null) { + if (customerRef[id - 1].getName().equals(name)) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:|" + customerRef[id - 1].getName() + + "|, actual:|" + name + "|"); + pass2 = false; + } + } else { + if (customerRef[id - 1].getName() == null) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:" + customerRef[id - 1].getName() + + ", actual:null"); + pass2 = false; + } + } + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass3 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("array test failed"); + } + } + + /* + * @testName: arrayIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:740 + * + * @test_Strategy: Create a CriteriaBuilder array and pass that to the + * CriteriaBuilder.array() method + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void arrayIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + CriteriaBuilder qbuilder = getEntityManagerFactory().getCriteriaBuilder(); + + CriteriaQuery cquery = qbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + Selection[] s = { customer.get("id"), customer.get("name") }; + + TestUtil.logMsg("Testing tuple"); + try { + qbuilder.array(qbuilder.tuple(s)); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + TestUtil.logMsg("Testing array"); + try { + qbuilder.array(qbuilder.array(s)); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + if (!pass1 || !pass2) { + throw new Exception("arrayIllegalArgumentExceptionTest failed"); + } + } + + /* + * @testName: constructIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:753 + * + * @test_Strategy: Create a CriteriaBuilder array and pass that to the + * CriteriaBuilder.construct(...) method + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void constructIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + CriteriaBuilder qbuilder = getEntityManagerFactory().getCriteriaBuilder(); + + CriteriaQuery cquery = qbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + Selection[] s = { customer.get("id"), customer.get("name") }; + + TestUtil.logMsg("Testing tuple"); + try { + qbuilder.construct(Customer.class, qbuilder.tuple(s)); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass1 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + TestUtil.logMsg("Testing array"); + try { + qbuilder.construct(Customer.class, qbuilder.array(s)); + TestUtil.logErr("Did not throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Received expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception", e); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + if (!pass1 || !pass2) { + throw new Exception("constructIllegalArgumentExceptionTest failed"); + } + } + + + /* + * @testName: countDistinct + * + * @assertion_ids: PERSISTENCE:JAVADOC:755 + * + * @test_Strategy: Select DISTINCT Count(c.home.city) from Customer c + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void countDistinct() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Long.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + TestUtil.logTrace("count number of orders by customer"); + + cquery.select(cbuilder.countDistinct( + customer.get(Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("city", String.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Long countResult = tq.getSingleResult(); + Long expectedCount = 16L; + + if (countResult.equals(expectedCount)) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("count test returned:" + countResult + "expected: " + + expectedCount); + + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("countDistinct test failed"); + } + } + + + /* + * @testName: andPredicates + * + * @assertion_ids: PERSISTENCE:JAVADOC:737; PERSISTENCE:SPEC:1729; + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.street = '125 Moxy + * Lane' AND c.home.city = 'Swansea' AND c.home.state = 'MA and c.home.zip = + * '11345' + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void andPredicates() throws Exception { + boolean pass = false; + + Customer expectedCustomer = customerRef[2]; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.and( + cbuilder.equal(customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get( + Address_.getSingularAttribute("street", + String.class)), + "125 Moxy Lane"), + cbuilder.equal( + customer + .get(Customer_.getSingularAttribute("home", + Address.class)) + .get(Address_.getSingularAttribute("city", + String.class)), + "Swansea"), + cbuilder.equal(customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get( + Address_.getSingularAttribute("state", String.class)), + "MA"), + cbuilder.equal(customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + "11345"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Customer result = tq.getSingleResult(); + + if (result.equals(expectedCustomer)) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expectedCustomer + ", actual:" + result); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("andPredicates test failed"); + + } + } + + /* + * @testName: orPredicates + * + * @assertion_ids: PERSISTENCE:JAVADOC:834; PERSISTENCE:SPEC:1729; + * + * @test_Strategy: SELECT Distinct c from Customer c WHERE c.home.street = '47 + * Skyline Drive' OR c.home.city = 'Chelmsford' OR c.home.state = 'VT' OR + * c.home.zip = '02155' + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void orPredicates() throws Exception { + boolean pass = false; + + String[] expected = new String[4]; + expected[0] = customerRef[0].getId(); + expected[1] = customerRef[9].getId(); + expected[2] = customerRef[10].getId(); + expected[3] = customerRef[12].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.or( + cbuilder.equal(customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get( + Address_.getSingularAttribute("street", + String.class)), + "47 Skyline Drive"), + cbuilder.equal( + customer.get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("city", + String.class)), + "Chelmsford"), + cbuilder.equal(customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get( + Address_.getSingularAttribute("state", String.class)), + "VT"), + cbuilder.equal(customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + "02155"))); + cquery.distinct(true); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("orPredicates test failed"); + + } + } + + + /* + * @testName: isNull + * + * @assertion_ids: PERSISTENCE:JAVADOC:789; PERSISTENCE:JAVADOC:957; + * PERSISTENCE:SPEC:1683; PERSISTENCE:SPEC:1728.2; + * + * @test_Strategy: Select c FROM Customer c where c.name is null + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void isNull() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = customerRef[11].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Customer.class); + cquery.select(customer); + + cquery.where(cbuilder.isNull( + customer.get(Customer_.getSingularAttribute("name", String.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("isNull test failed"); + + } + } + + /* + * @testName: isNotNull + * + * @assertion_ids: PERSISTENCE:JAVADOC:788; PERSISTENCE:JAVADOC:956; + * PERSISTENCE:SPEC:1728.3; + * + * @test_Strategy: Select c FROM Customer c where c.work.zip IS NOT NULL + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void isNotNull() throws Exception { + boolean pass = false; + + String[] expected = new String[17]; + int j = 0; + for (int i = 0; i < 18; i++) { + if (i != 12) { + + expected[j++] = customerRef[i].getId(); + } + } + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(Customer.class); + + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = mm.entity(Customer.class); + EntityType
Address_ = mm.entity(Address.class); + cquery.where(cb.isNotNull( + customer.get(Customer_.getSingularAttribute("work", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)))); + + cquery.select(customer); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("isNotNull test failed"); + + } + + } + + /* + * @testName: parameter + * + * @assertion_ids: PERSISTENCE:JAVADOC:836; PERSISTENCE:SPEC:1750; + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.street = :street OR + * c.home.city = :city OR c.home.state = :state OR c.home.zip = :zip + * + * where :street = '47 Skyline Drive' :city ='Chelmsford' :state ='VT' :zip = + * '02155' + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void parameter() throws Exception { + boolean pass = false; + + String[] expected = new String[4]; + expected[0] = customerRef[0].getId(); + expected[1] = customerRef[9].getId(); + expected[2] = customerRef[10].getId(); + expected[3] = customerRef[12].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + ParameterExpression param1 = cbuilder.parameter(String.class, + "streetParam"); + ParameterExpression param2 = cbuilder.parameter(String.class, + "cityParam"); + ParameterExpression param3 = cbuilder.parameter(String.class, + "stateParam"); + ParameterExpression param4 = cbuilder.parameter(String.class, + "zipParam"); + + cquery.select(customer); + cquery.where(cbuilder.or(cbuilder.equal( + customer.get(Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("street", String.class)), + param1), + cbuilder + .equal( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("city", String.class)), + param2), + cbuilder.equal( + customer + .get(Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("state", String.class)), + param3), + cbuilder + .equal( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + param4))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + tq.setParameter("streetParam", "47 Skyline Drive"); + tq.setParameter("cityParam", "Chelmsford"); + tq.setParameter("stateParam", "VT"); + tq.setParameter("zipParam", "02155"); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("parameter test failed"); + + } + } + + /* + * @testName: parameterCaseSensitiveTest + * + * @assertion_ids: PERSISTENCE:SPEC:1306; PERSISTENCE:SPEC:1307 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.state = :state OR + * c.home.state = :STATE + * + * where :state ='RI' :STATE ='VT' + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void parameterCaseSensitiveTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = customerRef[9].getId(); + expected[1] = customerRef[13].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + ParameterExpression param1 = cbuilder.parameter(String.class, + "stateParam"); + ParameterExpression param2 = cbuilder.parameter(String.class, + "STATEPARAM"); + + cquery.select(customer); + cquery + .where(cbuilder.or( + cbuilder.equal( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get( + Address_.getSingularAttribute("state", String.class)), + param1), + cbuilder.equal( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get( + Address_.getSingularAttribute("state", String.class)), + param2))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + tq.setParameter("stateParam", "RI"); + tq.setParameter("STATEPARAM", "VT"); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("parameterCaseSensitiveTest test failed"); + + } + } + + /* + * @testName: criteriaBuilderValuesTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:898 + * + * @test_Strategy: SELECT c.id from Customer c WHERE c.home.state IN (?1, ?2) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void criteriaBuilderValuesTest() throws Exception { + boolean pass = false; + + String[] expected = new String[12]; + + expected[0] = customerRef[0].getId(); + expected[1] = customerRef[1].getId(); + expected[2] = customerRef[2].getId(); + expected[3] = customerRef[3].getId(); + expected[4] = customerRef[6].getId(); + expected[5] = customerRef[7].getId(); + expected[6] = customerRef[8].getId(); + expected[7] = customerRef[9].getId(); + expected[8] = customerRef[10].getId(); + expected[9] = customerRef[12].getId(); + expected[10] = customerRef[14].getId(); + expected[11] = customerRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + CriteriaBuilder.In inExp = cbuilder.in( + customer.get(Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("state", String.class))); + inExp.value(cbuilder.parameter(String.class, "state1")); + inExp.value(cbuilder.parameter(String.class, "state2")); + cquery.where(inExp); + + List result = getEntityManager().createQuery(cquery) + .setParameter("state1", "MA").setParameter("state2", "VT") + .getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + TestUtil.logTrace( + "Customer id:" + c.getId() + ", state:" + c.getHome().getState()); + actual.add(Integer.parseInt(c.getId())); + } + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("criteriaBuilderValuesTest failed"); + + } + } + + /* + * @testName: criteriaBuilderIn1Test + * + * @assertion_ids: PERSISTENCE:JAVADOC:780; PERSISTENCE:JAVADOC:898; + * PERSISTENCE:JAVADOC:899; PERSISTENCE:SPEC:1728.4; + * + * @test_Strategy: SELECT c.id from Customer c WHERE c.home.state IN (?1, ?2) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void criteriaBuilderIn1Test() throws Exception { + boolean pass = false; + + String[] expected = new String[12]; + expected[0] = customerRef[0].getId(); + expected[1] = customerRef[1].getId(); + expected[2] = customerRef[2].getId(); + expected[3] = customerRef[3].getId(); + expected[4] = customerRef[6].getId(); + expected[5] = customerRef[7].getId(); + expected[6] = customerRef[8].getId(); + expected[7] = customerRef[9].getId(); + expected[8] = customerRef[10].getId(); + expected[9] = customerRef[12].getId(); + expected[10] = customerRef[14].getId(); + expected[11] = customerRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + CriteriaBuilder.In inExp = cbuilder.in( + customer.get(Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("state", String.class))); + inExp.value(cbuilder.parameter(String.class, "state1")); + inExp.value(cbuilder.parameter(String.class, "state2")); + + cquery.where(inExp); + + List result = getEntityManager().createQuery(cquery) + .setParameter("state1", "MA").setParameter("state2", "VT") + .getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + TestUtil.logTrace( + "Customer id:" + c.getId() + ", state:" + c.getHome().getState()); + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("criteriaBuilderIn1Test failed"); + + } + } + + /* + * @testName: criteriaBuilderIn2Test + * + * @assertion_ids: PERSISTENCE:JAVADOC:900; PERSISTENCE:JAVADOC:901; + * PERSISTENCE:JAVADOC:902; PERSISTENCE:SPEC:1698; PERSISTENCE:SPEC:1786; + * PERSISTENCE:SPEC:1786.3; + * + * @test_Strategy: Testing not, getOperator and isNegated SELECT s.id from + * Spouse s WHERE s.id NOT IN (2,3) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void criteriaBuilderIn2Test() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + + String[] expected = new String[4]; + expected[0] = spouse[0].getId(); + expected[1] = spouse[3].getId(); + expected[2] = spouse[4].getId(); + expected[3] = spouse[5].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + Root spouse = cquery.from(Spouse.class); + + CriteriaBuilder.In in = cbuilder.in(spouse.get("id")); + for (String id : new String[] { "2", "3" }) { + in.value(id); + } + Predicate pred = in.not(); + cquery.where(pred); + + if (!pred.getOperator().equals(Predicate.BooleanOperator.AND)) { + TestUtil.logErr("Expected: " + Predicate.BooleanOperator.AND + + ", actual:" + pred.getOperator().name()); + } else { + pass1 = true; + } + if (in.not().isNegated() != true) { + TestUtil.logErr("Expected in.not().isNegated() to return: true, actual:" + + in.isNegated()); + } else { + pass2 = true; + } + + List result = getEntityManager().createQuery(cquery) + .getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass3 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("criteriaBuilderIn2Test failed"); + + } + } + + /* + * @testName: criteriaBuilderInValueTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:897 + * + * @test_Strategy: SELECT c.id from Customer c WHERE c.home.state IN (MA, VT) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void criteriaBuilderInValueTest() throws Exception { + boolean pass = false; + + String[] expected = new String[12]; + expected[0] = customerRef[0].getId(); + expected[1] = customerRef[1].getId(); + expected[2] = customerRef[2].getId(); + expected[3] = customerRef[3].getId(); + expected[4] = customerRef[6].getId(); + expected[5] = customerRef[7].getId(); + expected[6] = customerRef[8].getId(); + expected[7] = customerRef[9].getId(); + expected[8] = customerRef[10].getId(); + expected[9] = customerRef[12].getId(); + expected[10] = customerRef[14].getId(); + expected[11] = customerRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + CriteriaBuilder.In inExp = cbuilder.in( + customer.get(Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("state", String.class))); + inExp.value("MA"); + inExp.value("VT"); + cquery.where(inExp); + + List result = getEntityManager().createQuery(cquery) + .getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + TestUtil.logTrace( + "Customer id:" + c.getId() + ", state:" + c.getHome().getState()); + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("criteriaBuilderInValueTest failed"); + + } + } + + /* + * @testName: expressionInObjectArrayTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:952 + * + * @test_Strategy: SELECT s.id from Spouse s WHERE s.id IN (2,3) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void expressionInObjectArrayTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = spouse[1].getId(); + expected[1] = spouse[2].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + Root spouse = cquery.from(Spouse.class); + + Expression exp = spouse.get("id"); + + ParameterExpression param = cbuilder.parameter(String.class); + + cquery.where(exp.in(new Object[] { "2", "3" })); + TypedQuery query = getEntityManager().createQuery(cquery); + + List result = query.getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("expressionInObjectArrayTest failed"); + + } + } + + /* + * @testName: expressionInExpressionArrayTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:953 + * + * @test_Strategy: SELECT s.id from Spouse s WHERE s.id IN (2,3) + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void expressionInExpressionArrayTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = spouse[1].getId(); + expected[1] = spouse[2].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + Root spouse = cquery.from(Spouse.class); + + Expression exp = spouse.get("id"); + + ParameterExpression param = cbuilder.parameter(String.class); + + cquery.where(exp.in( + new Expression[] { cbuilder.literal("2"), cbuilder.literal("3") })); + TypedQuery query = getEntityManager().createQuery(cquery); + + List result = query.getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("expressionInExpressionArrayTest failed"); + + } + } + + /* + * @testName: expressionInExpressionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:955 + * + * @test_Strategy: SELECT s.id from Spouse s WHERE s.id IN (2) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void expressionInExpressionTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = spouse[1].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + Root spouse = cquery.from(Spouse.class); + Expression exp = spouse.get("id"); + + ParameterExpression param = cbuilder.parameter(String.class); + Expression e = cbuilder.literal("2"); + cquery.where(exp.in(e)); + TypedQuery query = getEntityManager().createQuery(cquery); + + List result = query.getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("expressionInExpressionTest failed"); + + } + } + + /* + * @testName: expressionInCollectionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:954 + * + * @test_Strategy: SELECT s.id from Spouse s WHERE s.id IN (2,3) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void expressionInCollectionTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = spouse[1].getId(); + expected[1] = spouse[2].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + Root spouse = cquery.from(Spouse.class); + + Expression exp = spouse.get("id"); + ParameterExpression param = cbuilder.parameter(String.class); + Collection col = new ArrayList(); + col.add("2"); + col.add("3"); + + cquery.where(exp.in(col)); + TypedQuery query = getEntityManager().createQuery(cquery); + + List result = query.getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("expressionInCollectionTest failed"); + + } + } + + /* + * @testName: parameterExpressionIsNullTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1091 + * + * @test_Strategy: SELECT s.id from Spouse s where (2 IS NULL) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void parameterExpressionIsNullTest() throws Exception { + boolean pass = false; + + String[] expected = new String[0]; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + cquery.from(Spouse.class); + + ParameterExpression param = cbuilder.parameter(String.class); + + cquery.where(param.isNull()); + TypedQuery query = getEntityManager().createQuery(cquery); + + List result = query.setParameter(param, "2").getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("parameterExpressionIsNullTest failed"); + + } + } + + /* + * @testName: parameterExpressionIsNotNullTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1090 + * + * @test_Strategy: SELECT s.id from Spouse s where (2 IS NOT NULL) + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void parameterExpressionIsNotNullTest() throws Exception { + boolean pass = false; + + String[] expected = new String[6]; + expected[0] = spouse[0].getId(); + expected[1] = spouse[1].getId(); + expected[2] = spouse[2].getId(); + expected[3] = spouse[3].getId(); + expected[4] = spouse[4].getId(); + expected[5] = spouse[5].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Spouse.class); + if (cquery != null) { + cquery.from(Spouse.class); + + ParameterExpression param = cbuilder.parameter(String.class); + + cquery.where(param.isNotNull()); + TypedQuery query = getEntityManager().createQuery(cquery); + + List result = query.setParameter(param, "2").getResultList(); + + List actual = new ArrayList(); + for (Spouse s : result) { + TestUtil.logTrace("Customer id:" + s.getId() + ", state:" + + s.getSocialSecurityNumber()); + actual.add(Integer.parseInt(s.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("parameterExpressionIsNotNullTest failed"); + + } + } + + /* + * @testName: likeExpStringTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:801 + * + * @test_Strategy: SELECT Distinct c from Customer c WHERE c.home.zip LIKE + * "%77" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void likeExpStringTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = customerRef[1].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.like( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + "%77")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("likeExpStringTest failed"); + + } + } + + /* + * @testName: likeExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:800 + * + * @test_Strategy: SELECT Distinct c from Customer c WHERE c.home.zip LIKE + * "%77" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void likeExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = customerRef[1].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.like( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + cbuilder.literal("%77"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("likeExpExpTest failed"); + + } + } + + /* + * @testName: notLikeExpStringTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:825 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.zip NOT LIKE "%77" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void notLikeExpStringTest() throws Exception { + boolean pass = false; + + String[] expected = new String[17]; + int j = 0; + for (int i = 0; i < 18; i++) { + if (i != 1) { + expected[j++] = customerRef[i].getId(); + } + } + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.notLike( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + "%77")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("notLikeExpStringTest failed"); + + } + } + + /* + * @testName: notLikeExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:824 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.zip NOT LIKE "%77" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void notLikeExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[17]; + int j = 0; + for (int i = 0; i < 18; i++) { + if (i != 1) { + expected[j++] = customerRef[i].getId(); + } + } + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.notLike( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + cbuilder.literal("%77"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("notLikeExpExpTest failed"); + + } + } + + /* + * @testName: notLikeExpExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:826 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.zip NOT LIKE "%_7" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void notLikeExpExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[16]; + int j = 0; + for (int i = 0; i < 18; i++) { + if ((i != 1) && (i != 5)) { + expected[j++] = customerRef[i].getId(); + } + } + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.notLike( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + cbuilder.literal("%_7"), cbuilder.literal('\\'))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("notLikeExpExpExpTest failed"); + + } + } + + /* + * @testName: notLikeExpExpCharTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:827 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.zip NOT LIKE "%_7" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void notLikeExpExpCharTest() throws Exception { + boolean pass = false; + + String[] expected = new String[16]; + int j = 0; + for (int i = 0; i < 18; i++) { + if ((i != 1) && (i != 5)) { + expected[j++] = customerRef[i].getId(); + } + } + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.notLike( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + cbuilder.literal("%_7"), '\\')); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("notLikeExpExpCharTest failed"); + + } + } + + /* + * @testName: notLikeExpStringExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:828 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.zip NOT LIKE "%_7" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void notLikeExpStringExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[16]; + int j = 0; + for (int i = 0; i < 18; i++) { + if ((i != 1) && (i != 5)) { + expected[j++] = customerRef[i].getId(); + } + } + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.notLike( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + "%_7", cbuilder.literal('\\'))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("notLikeExpStringExpTest failed"); + + } + } + + /* + * @testName: notLikeExpStringCharTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:829 + * + * @test_Strategy: SELECT c from Customer c WHERE c.home.zip NOT LIKE "%_7" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void notLikeExpStringCharTest() throws Exception { + boolean pass = false; + + String[] expected = new String[16]; + int j = 0; + for (int i = 0; i < 18; i++) { + if ((i != 1) && (i != 5)) { + expected[j++] = customerRef[i].getId(); + } + } + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + + cquery.select(customer); + + cquery + .where( + cbuilder.notLike( + customer + .get( + Customer_.getSingularAttribute("home", Address.class)) + .get(Address_.getSingularAttribute("zip", String.class)), + "%_7", '\\')); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("notLikeExpStringCharTest failed"); + + } + } + + /* + * @testName: concatExpStringTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:749; PERSISTENCE:JAVADOC:806 + * + * @test_Strategy: SELECT c from Customer c WHERE c.work.street="1 Network" + * CONCAT " Drive" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void concatExpStringTest() throws Exception { + boolean pass = false; + + String[] expected = new String[18]; + for (int i = 0; i < 18; i++) { + expected[i] = customerRef[i].getId(); + } + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + cquery.select(customer); + + cquery.where(cbuilder.equal( + customer.get(Customer_.getSingularAttribute("work", Address.class)) + .get(Address_.getSingularAttribute("street", String.class)), + cbuilder.concat(cbuilder.literal("1 Network"), " Drive"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("concatExpStringTest failed"); + + } + } + + /* + * @testName: concatStringExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:750 + * + * @test_Strategy: SELECT c from Customer c WHERE c.work.street="1 Network" + * CONCAT " Drive" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void concatStringExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[18]; + for (int i = 0; i < 18; i++) { + expected[i] = customerRef[i].getId(); + } + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + cquery.select(customer); + + cquery.where(cbuilder.equal( + customer.get(Customer_.getSingularAttribute("work", Address.class)) + .get(Address_.getSingularAttribute("street", String.class)), + cbuilder.concat("1 Network", cbuilder.literal(" Drive")))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("concatStringExpTest failed"); + + } + } + + /* + * @testName: concatExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:748 + * + * @test_Strategy: SELECT c from Customer c WHERE c.work.street="1 Network" + * CONCAT " Drive" + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void concatExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[18]; + for (int i = 0; i < 18; i++) { + expected[i] = customerRef[i].getId(); + } + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + EntityType
Address_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Address.class); + cquery.select(customer); + + cquery + .where( + cbuilder + .equal( + customer + .get(Customer_.getSingularAttribute("work", + Address.class)) + .get(Address_.getSingularAttribute("street", + String.class)), + cbuilder.concat(cbuilder.literal("1 Network"), + cbuilder.literal(" Drive")))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("concatExpExpTest failed"); + + } + } + + /* + * @testName: trimBothExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:867 + * + * @test_Strategy: Select trim(both from c.name) from Customer c where c.name= + * ' David R. Vincent' + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void trimBothExpTest() throws Exception { + boolean pass = false; + final String expectedResult = "David R. Vincent"; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(String.class); + if (cquery != null) { + Root cust = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = cust.getModel(); + + cquery.where(cb.equal( + cust.get(Customer_.getSingularAttribute("name", String.class)), + cb.literal(" David R. Vincent"))); + cquery.select(cb.trim(Trimspec.BOTH, + cust.get(Customer_.getSingularAttribute("name", String.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + String result = tq.getSingleResult(); + + if (result.equals(expectedResult)) { + TestUtil.logTrace("Received expected result:|" + result + "|"); + pass = true; + } else { + TestUtil.logErr("Mismatch in received results - expected = |" + + expectedResult + "|, received = |" + result + "|"); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("trimBothExpTest failed"); + + } + } + + + /* + * @testName: lower + * + * @assertion_ids: PERSISTENCE:JAVADOC:812 + * + * @test_Strategy: Select lower(c.name) From Customer c a WHERE c.name = 'Lisa + * M. Presley' + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void lower() throws Exception { + final String expectedResult = "lisa m. presley"; + boolean pass = false; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(String.class); + if (cquery != null) { + Root cust = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = cust.getModel(); + + cquery.where(cb.equal( + cust.get(Customer_.getSingularAttribute("name", String.class)), + cb.literal("Lisa M. Presley"))); + cquery.select(cb.lower( + cust.get(Customer_.getSingularAttribute("name", String.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + String result = tq.getSingleResult(); + + if (result.equals(expectedResult)) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("Mismatch in received results - expected = " + + expectedResult + " received = " + result); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("lower test failed"); + + } + + } + + + /* + * @testName: nullifExpressionExpressionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:830 + * + * @test_Strategy: SELECT c.ID, NULLIF(LCASE(c.home.city), LCASE(c.work.city)) + * FROM CUSTOMER c WHERE (((c.home.city IS NOT NULL) AND (c.work.city IS NOT + * NULL)) ORDER BY c.ID ASC + * + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void nullifExpressionExpressionTest() throws Exception { + boolean pass = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + // TestUtil.logTrace("Expected Data:"+c.toString()); + String id = c.getId(); + if (Integer.parseInt(id) <= 18 && Integer.parseInt(id) != 9) { + if (c.getHome().getCity().equals(c.getWork().getCity())) { + expected.add(c.getId() + ",null"); + } else { + expected.add(c.getId() + "," + c.getHome().getCity().toLowerCase()); + } + } + } + + Collections.sort(expected); + + List actual = new ArrayList(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Tuple.class); + if (cquery != null) + + { + Root customer = cquery.from(Customer.class); + + Expression expHomeCity = cbuilder + .lower(customer.get("home"). get("city")); + Expression expWorkCity = cbuilder + .lower(customer.get("work"). get("city")); + + cquery.multiselect(customer.get("id"), + cbuilder.nullif(expHomeCity, expWorkCity)); + + cquery.where(cbuilder.and( + cbuilder.isNotNull(customer.get("home"). get("city")), + cbuilder.isNotNull(customer.get("work"). get("city")))); + cquery.orderBy(cbuilder.asc(customer.get("id"))); + + List result = getEntityManager().createQuery(cquery) + .getResultList(); + + for (Tuple t : result) { + TestUtil.logTrace("actual:" + t.toString()); + + String id = (String) t.get(0); + String city = (String) t.get(1); + if (city != null) { + actual.add(id + "," + city); + } else { + actual.add(id + ",null"); + } + } + + for (String s : actual) { + TestUtil.logTrace("actual:" + s); + } + Collections.sort(actual); + if (expected.containsAll(actual) && actual.containsAll(expected) + && expected.size() == actual.size()) { + TestUtil.logTrace("Received expected results"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results"); + for (String s : expected) { + TestUtil.logErr("expected:" + s); + } + for (String s : actual) { + TestUtil.logErr("actual:" + s); + } + } + } else + + { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("nullifExpressionExpressionTest failed"); + } + + } + + /* + * @testName: nullifExpressionObjectTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:831 + * + * @test_Strategy: SELECT c.ID, NULLIF(LCASE(c.home.city), "burlington") FROM + * CUSTOMER c WHERE ((c.home.city IS NOT NULL) ORDER BY c.ID ASC + * + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void nullifExpressionObjectTest() throws Exception { + boolean pass = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + // TestUtil.logTrace("Expected Data:"+c.toString()); + String id = c.getId(); + if (Integer.parseInt(id) <= 18 && Integer.parseInt(id) != 9) { + if (c.getHome().getCity().equals(c.getWork().getCity())) { + expected.add(c.getId() + ",null"); + } else { + expected.add(c.getId() + "," + c.getHome().getCity().toLowerCase()); + } + } + } + + Collections.sort(expected); + + List actual = new ArrayList(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Tuple.class); + if (cquery != null) + + { + Root customer = cquery.from(Customer.class); + + Expression expHomeCity = cbuilder + .lower(customer.get("home"). get("city")); + + cquery.multiselect(customer.get("id"), + cbuilder.nullif(expHomeCity, "burlington")); + + cquery + .where(cbuilder.isNotNull(customer.get("home"). get("city"))); + + cquery.orderBy(cbuilder.asc(customer.get("id"))); + + List result = getEntityManager().createQuery(cquery) + .getResultList(); + + for (Tuple t : result) { + TestUtil.logTrace("actual:" + t.toString()); + + String id = (String) t.get(0); + String city = (String) t.get(1); + if (city != null) { + actual.add(id + "," + city); + } else { + actual.add(id + ",null"); + } + } + + for (String s : actual) { + TestUtil.logTrace("actual:" + s); + } + Collections.sort(actual); + if (expected.containsAll(actual) && actual.containsAll(expected) + && expected.size() == actual.size()) { + TestUtil.logTrace("Received expected results"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results"); + for (String s : expected) { + TestUtil.logErr("expected:" + s); + } + for (String s : actual) { + TestUtil.logErr("actual:" + s); + } + } + } else + + { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("nullifExpressionObjectTest failed"); + } + + } + + /* + * @testName: locateExpressionExpressionExpressionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:810 + * + * @test_Strategy: SELECT a FROM ALIAS a WHERE (LOCATE(ev, a.alias, 1) > 0) + * + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void locateExpressionExpressionExpressionTest() throws Exception { + boolean pass = false; + + String[] expected = new String[3]; + expected[0] = aliasRef[12].getId(); + expected[1] = aliasRef[13].getId(); + expected[2] = aliasRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) + + { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + + Expression exp1 = alias + .get(Alias_.getSingularAttribute("alias", String.class)); + Expression exp2 = cbuilder.literal("ev"); + Expression exp3 = cbuilder.toInteger(cbuilder.literal(1)); + + cquery.where(cbuilder.gt(cbuilder.locate(exp1, exp2, exp3), 0)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("locateExpressionExpressionExpressionTest failed"); + + } + } + + /* + * @testName: locateExpressionStringIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:811 + * + * @test_Strategy: SELECT a FROM ALIAS a WHERE (LOCATE(ev, a.alias, 1) > 0) + * + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void locateExpressionStringIntTest() throws Exception { + boolean pass = false; + + String[] expected = new String[3]; + expected[0] = aliasRef[12].getId(); + expected[1] = aliasRef[13].getId(); + expected[2] = aliasRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) + + { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + + Expression exp1 = alias + .get(Alias_.getSingularAttribute("alias", String.class)); + + cquery.where(cbuilder.gt(cbuilder.locate(exp1, "ev", 1), 0)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("locateExpressionExpressionExpressionTest failed"); + + } + } + + /* + * @testName: coalesceTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:747 + * + * @test_Strategy: + */ + @Test + public void coalesceTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + getEntityTransaction().begin(); + CriteriaBuilder.Coalesce col = cbuilder.coalesce(); + if (col != null) { + TestUtil.logTrace("Obtained Non-null Coalesce"); + pass = true; + } else { + TestUtil.logErr("Failed to get Non-null Coalesce"); + + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("coalesceTest failed"); + } + } + + /* + * @testName: selectMultiSelectTest + * + * @assertion_ids: PERSISTENCE:SPEC:1707; PERSISTENCE:SPEC:1708; + * PERSISTENCE:SPEC:1709; + * + * @test_Strategy: Execute a query and verify a single result can be returned + * when using cbuilder.createQuery() Execute a query and verify a multiple + * results can be returned when using cbuilder.createQuery() + * + * Select c.id, c.name from Customer c + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void selectMultiSelectTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + expected.add(Integer.valueOf(c.getId())); + } + Collections.sort(expected); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + TestUtil.logMsg("Testing select"); + + try { + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + + cquery.select( + customer.get(Customer_.getSingularAttribute("id", String.class))); + + Query q = getEntityManager().createQuery(cquery); + + List result = q.getResultList(); + + List actual = new ArrayList(); + + for (Object row : result) { + Integer id = Integer.valueOf((String) row); + TestUtil.logTrace("id=" + id); + actual.add(id); + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass1 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception", ex); + } + TestUtil.logMsg("Testing multiselect"); + try { + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)), + customer.get(Customer_.getSingularAttribute("name", String.class))); + + Query q = getEntityManager().createQuery(cquery); + + List result = q.getResultList(); + + List actual = new ArrayList(); + + for (Object[] row : result) { + Integer id = Integer.valueOf((String) row[0]); + String name = (String) row[1]; + TestUtil.logTrace("id=" + id); + TestUtil.logTrace("name=" + name); + // some of the names have nulls so deal with them + if (name != null && customerRef[id - 1].getName() != null) { + if (customerRef[id - 1].getName().equals(name)) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:|" + customerRef[id - 1].getName() + + "|, actual:|" + name + "|"); + } + } else if (name == null && customerRef[id - 1].getName() == null) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:" + customerRef[id - 1].getName() + + ", actual:null"); + } + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass2 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception", ex); + } + + if (!pass1 || !pass2) { + throw new Exception("selectMultiSelectTest test failed"); + } + } + + /* + * @testName: multiRootTest + * + * @assertion_ids: PERSISTENCE:SPEC:1711 + * + * @test_Strategy: Test that using mulitple roots results in a cartesian + * product + * + * Select s1, s2 from Spouse s1, Spouse s2 + * + */ + @SetupMethod(name = "setupCustomerData") + @Test + public void multiRootTest() throws Exception { + boolean pass = true; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + List list = new ArrayList(); + for (int i = 1; i <= spouse.length; i++) { + for (int j = 1; j <= spouse.length; j++) { + list.add(Integer.toString(i) + "," + Integer.toString(j)); + } + } + + try { + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(); + if (cquery != null) { + Root spouse1 = cquery.from(Spouse.class); + Root spouse2 = cquery.from(Spouse.class); + + // Get Metamodel from Root + EntityType Spouse1_ = spouse1.getModel(); + EntityType Spouse2_ = spouse2.getModel(); + + cquery.multiselect( + spouse1.get(Spouse1_.getSingularAttribute("id", String.class)), + spouse2.get(Spouse2_.getSingularAttribute("id", String.class))); + + Query q = getEntityManager().createQuery(cquery); + + List result = q.getResultList(); + + for (Object[] row : result) { + Integer sId1 = Integer.valueOf((String) row[0]); + Integer sId2 = Integer.valueOf((String) row[1]); + TestUtil.logTrace("sId1=" + sId1 + ", sId2=" + sId2); + list.remove(sId1 + "," + sId2); + } + TestUtil.logTrace("Size:" + list.size()); + if (list.isEmpty()) { + TestUtil.logTrace("All PK's were found"); + pass = true; + } else { + TestUtil.logErr("Not all PK's were returned"); + for (String s : list) { + TestUtil.logErr("Not all PK's were returned:" + s); + } + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception", ex); + } + + if (!pass) { + throw new Exception("multiRootTest test failed"); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT3.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT3.java new file mode 100644 index 0000000000..4ded0cc762 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT3.java @@ -0,0 +1,1037 @@ +/* + * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.criteriaapi.CriteriaBuilder; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.harness.SetupMethod; +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.schema30.Address; +import com.sun.ts.tests.jpa.common.schema30.Alias; +import com.sun.ts.tests.jpa.common.schema30.Customer; +import com.sun.ts.tests.jpa.common.schema30.Customer_; +import com.sun.ts.tests.jpa.common.schema30.HardwareProduct; +import com.sun.ts.tests.jpa.common.schema30.LineItem; +import com.sun.ts.tests.jpa.common.schema30.Order; +import com.sun.ts.tests.jpa.common.schema30.Order_; +import com.sun.ts.tests.jpa.common.schema30.Product; +import com.sun.ts.tests.jpa.common.schema30.ShelfLife; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct_; +import com.sun.ts.tests.jpa.common.schema30.Spouse; +import com.sun.ts.tests.jpa.common.schema30.Trim; +import com.sun.ts.tests.jpa.common.schema30.UtilAliasData; + +import jakarta.persistence.Query; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.Trimspec; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ParameterExpression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; + +public class ClientIT3 extends UtilAliasData { + + /* + * @testName: tupleGetIntIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:603; PERSISTENCE:JAVADOC:1164; + * PERSISTENCE:SPEC:1303; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c Call Tuple.get() using a tuple element that does not + * exist + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleGetIntIllegalArgumentExceptionTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect(new Selection[] { + customer.get(Customer_.getSingularAttribute("id", String.class)) + .alias("ID"), + customer.get(Customer_.getSingularAttribute("name", String.class)) + .alias("NAME") }); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + for (Tuple t : result) { + TestUtil.logMsg("Testing invalid index"); + try { + t.get(99); + TestUtil.logErr( + "Did not get expected IllegalArgumentException for invalid index:" + + t.get(99)); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Got expected IllegalArgumentException"); + if (getEntityTransaction().getRollbackOnly() != true) { + pass = true; + } else { + TestUtil.logErr( + "Transaction was marked for rollback and should not have been"); + } + } catch (Exception ex) { + TestUtil.logErr("Received unexpected exception", ex); + } + break; + } + + } else { + + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("tupleGetIntIllegalArgumentExceptionTest failed"); + } + } + + + /* + * @testName: tupleGetElementsGetTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:429; PERSISTENCE:JAVADOC:434; + * PERSISTENCE:JAVADOC:1168; PERSISTENCE:JAVADOC:1169; PERSISTENCE:SPEC:1321; + * PERSISTENCE:SPEC:1763; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c where c.name is not nulls + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleGetElementsGetTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + boolean pass4 = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)) + .alias("ID"), + customer.get(Customer_.getSingularAttribute("name", String.class)) + .alias("NAME")); + + cquery.where(cbuilder.isNotNull( + customer.get(Customer_.getSingularAttribute("name", String.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + for (Tuple t : result) { + String expId = (String) t.get("ID"); + String expName = (String) t.get("NAME"); + TestUtil.logTrace("Received:" + expId + ", " + expName); + + List> lte = t.getElements(); + for (TupleElement te : lte) { + String alias = te.getAlias(); + String type = te.getJavaType().getName(); + if (alias.equals("ID")) { + String actId = (String) t.get(te); + if (actId.equals(expId)) { + TestUtil.logTrace("Received expected id:" + actId); + pass1 = true; + + } else { + TestUtil + .logErr("Expected id:" + expId + ", actual:|" + actId + "|"); + } + if (type.equals("java.lang.String")) { + pass2 = true; + + TestUtil.logTrace("Received expected Java Type for ID:" + type); + } else { + TestUtil + .logErr("Expected java type of ID: java.lang.String, actual:|" + + type + "|"); + } + + } else if (alias.equals("NAME")) { + String actName = (String) t.get(te); + if (actName.equals(expName)) { + TestUtil.logTrace("Received expected name:" + actName); + pass3 = true; + + } else { + TestUtil.logErr( + "Expected name:|" + expName + "|, actual:|" + actName + "|"); + } + + if (type.equals("java.lang.String")) { + TestUtil.logTrace("Received expected Java Type for NAME:" + type); + pass4 = true; + + } else { + TestUtil.logErr( + "Expected java type of NAME: java.lang.String, actual:|" + + type + "|"); + } + + } else { + TestUtil.logErr("Received unexpected TupleElement:" + alias); + } + } + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2 || !pass3 || !pass4) { + throw new Exception("tupleGetElementsGetTest failed"); + } + } + + + /* + * @testName: tupleGetStringTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:431 + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleGetStringTest() throws Exception { + boolean pass1 = true; + boolean pass2 = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + expected.add(Integer.valueOf(c.getId())); + } + Collections.sort(expected); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)) + .alias("ID"), + customer.get(Customer_.getSingularAttribute("name", String.class)) + .alias("NAME")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + + for (Tuple t : result) { + Integer id = Integer.valueOf((String) t.get(0)); + String name = (String) t.get(1); + if (name != null) { + if (customerRef[id - 1].getName().equals(name)) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:|" + customerRef[id - 1].getName() + + "|, actual:|" + name + "|"); + pass1 = false; + } + } else { + if (customerRef[id - 1].getName() == null) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:" + customerRef[id - 1].getName() + + ", actual:null"); + pass1 = false; + } + } + + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass2 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("tupleGetStringTest failed"); + } + } + + /* + * @testName: tupleGetStringIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:601; PERSISTENCE:SPEC:1303; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c Call Tuple.get() using a tuple element that does not + * exist + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleGetStringIllegalArgumentExceptionTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)) + .alias("ID"), + customer.get(Customer_.getSingularAttribute("name", String.class)) + .alias("NAME")); + + cquery.where(cbuilder.equal( + customer.get(Customer_.getSingularAttribute("id", String.class)), + "1")); + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + Tuple t = result.get(0); + TestUtil.logMsg("Testing valid alias"); + TestUtil.logTrace("value:" + t.get("NAME")); + + TestUtil.logMsg("Testing invalid alias"); + try { + t.get("doesnotexist"); + TestUtil.logErr( + "Did not get expected IllegalArgumentException for TupleElement:t.get(\"doesnotexist\")"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Got expected IllegalArgumentException"); + if (getEntityTransaction().getRollbackOnly() != true) { + pass = true; + } else { + TestUtil.logErr( + "Transaction was marked for rollback and should not have been"); + } + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception:" + e); + + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("tupleGetStringIllegalArgumentExceptionTest failed"); + } + } + + /* + * @testName: tupleGetStringClassIllegalArgumentExceptionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:600; PERSISTENCE:SPEC:1303; + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c Call Tuple.get() using a tuple type that does not + * match + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleGetStringClassIllegalArgumentExceptionTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)) + .alias("ID"), + customer.get(Customer_.getSingularAttribute("name", String.class)) + .alias("NAME")); + + cquery.where(cbuilder.equal( + customer.get(Customer_.getSingularAttribute("id", String.class)), + "1")); + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + Tuple t = result.get(0); + TestUtil.logMsg("Testing valid index"); + TestUtil.logTrace("value:" + t.get("NAME")); + TestUtil.logMsg("Testing a name that does not exist"); + + try { + t.get("doesnotexist", String.class); + TestUtil.logErr( + "Did not throw IllegalArgumentException for TupleElement: t.get(\"doesnotexist\", String.class)"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Got expected IllegalArgumentException"); + if (getEntityTransaction().getRollbackOnly() != true) { + pass1 = true; + } else { + TestUtil.logErr( + "Transaction was marked for rollback and should not have been"); + } + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception:" + e); + } + TestUtil.logMsg("Testing invalid type"); + + try { + t.get("ID", Date.class); + TestUtil.logErr( + "Did not throw IllegalArgumentException for TupleElement:t.get(\"ID\", Date.class)"); + } catch (IllegalArgumentException iae) { + TestUtil.logTrace("Got expected IllegalArgumentException"); + pass2 = true; + } catch (Exception e) { + TestUtil.logErr("Received unexpected exception:" + e); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("tupleGetStringClassIllegalArgumentExceptionTest failed"); + } + } + + /* + * @testName: tupleGetStringClassTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:430 + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleGetStringClassTest() throws Exception { + boolean pass1 = false; + boolean pass2 = true; + boolean pass3 = false; + + List expected = new ArrayList(); + for (Customer c : customerRef) { + expected.add(Integer.valueOf(c.getId())); + } + Collections.sort(expected); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + cquery.multiselect( + customer.get(Customer_.getSingularAttribute("id", String.class)) + .alias("ID"), + customer.get(Customer_.getSingularAttribute("name", String.class)) + .alias("NAME")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + + pass1 = true; + for (Tuple t : result) { + Integer id = Integer.valueOf((String) t.get(0)); + String name = (String) t.get(1); + if (name != null) { + if (customerRef[id - 1].getName().equals(name)) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:|" + customerRef[id - 1].getName() + + "|, actual:|" + name + "|"); + pass2 = false; + } + } else { + if (customerRef[id - 1].getName() == null) { + actual.add(id); + } else { + TestUtil.logErr("Expected name:" + customerRef[id - 1].getName() + + ", actual:null"); + pass2 = false; + } + } + + } + Collections.sort(actual); + + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.size() + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass3 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("tupleGetStringClassTest failed"); + } + } + + /* + * @testName: tupleElementGetAliasTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:436; PERSISTENCE:JAVADOC:1102; + * PERSISTENCE:JAVADOC:1103 + * + * @test_Strategy: convert the following JPQL to CriteriaQuery Select c.id, + * c.name from Customer c + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void tupleElementGetAliasTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + boolean pass3 = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + CriteriaQuery cquery = cbuilder.createTupleQuery(); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + TestUtil.logTrace("Use Tuple Query"); + + Path idPath = customer + .get(Customer_.getSingularAttribute("id", String.class)); + String id = idPath.alias("IDID").getAlias(); + if (id.equals("IDID")) { + TestUtil.logTrace("id=" + id); + pass1 = true; + } else { + TestUtil.logErr("Expected id value:IDID, actual value:" + id); + } + Bindable b = idPath.getModel(); + Bindable.BindableType bbt = b.getBindableType(); + if (bbt.equals(Bindable.BindableType.SINGULAR_ATTRIBUTE)) { + TestUtil.logTrace("Received expected model:" + bbt.name()); + pass2 = true; + + } else { + TestUtil.logErr( + "Expected model:" + Bindable.BindableType.SINGULAR_ATTRIBUTE.name() + + ", actual:" + bbt.name()); + } + + Path p = idPath.getParentPath(); + Class parent = p.getJavaType(); + if (parent.getName().equals(Customer.class.getName())) { + TestUtil.logTrace("Received expected parent:" + parent.getName()); + pass3 = true; + + } else { + TestUtil.logErr("Expected parent class:" + Customer.class.getName() + + ", actual:" + parent.getName()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + if (!pass1 || !pass2 || !pass3) { + throw new Exception("tupleElementGetAliasTest failed"); + } + } + + + + /* + * @testName: isEmpty + * + * @assertion_ids: PERSISTENCE:JAVADOC:781 + * + * @test_Strategy: Select c fRoM Customer c where c.aliases IS EMPTY + */ + @SetupMethod(name = "setupAliasData") + @Test + public void isEmpty() throws Exception { + boolean pass = false; + + String[] expected = new String[7]; + expected[0] = customerRef[5].getId(); + expected[1] = customerRef[14].getId(); + expected[2] = customerRef[15].getId(); + expected[3] = customerRef[16].getId(); + expected[4] = customerRef[17].getId(); + expected[5] = customerRef[18].getId(); + expected[6] = customerRef[19].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + + Root customer = cquery.from(Customer.class); + cquery.where(cbuilder.isEmpty(customer.> get("aliases"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("isEmpty test failed"); + } + } + + /* + * @testName: isNotEmpty + * + * @assertion_ids: PERSISTENCE:JAVADOC:785 + * + * @test_Strategy: Select Distinct c fRoM Customer c where c.aliases IS NOT + * EMPTY + */ + @SetupMethod(name = "setupAliasData") + @Test + public void isNotEmpty() throws Exception { + boolean pass = false; + + int j = 0; + String[] expected = new String[13]; + for (int i = 0; i < 14; i++) { + if (i != 5) { + expected[j++] = customerRef[i].getId(); + } + } + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + + Root customer = cquery.from(Customer.class); + cquery.where(cbuilder.isNotEmpty(customer.> get("aliases"))); + cquery.select(customer).distinct(true); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Customer c : result) { + actual.add(Integer.parseInt(c.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("isNotEmpty test failed"); + } + } + + /* + * @testName: sizeCollectionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:846; PERSISTENCE:SPEC:1742; + * + * @test_Strategy: Select size(c.aliases) from Customer c where c.id ="3" + */ + @SetupMethod(name = "setupAliasData") + @Test + public void sizeCollectionTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + cquery.select(cbuilder.size(customer.> get("aliases"))); + cquery.where(cbuilder.equal(customer.get("id"), "3")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Integer result = tq.getSingleResult(); + Integer expectedSize = 2; + + if (result.intValue() == expectedSize.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedSize.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sizeCollectionTest failed"); + } + } + + /* + * @testName: sizeExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:845 + * + * @test_Strategy: Select size(c.aliases) fRoM Customer c where c.id ="3" + */ + @SetupMethod(name = "setupAliasData") + @Test + public void sizeExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root customer = cquery.from(Customer.class); + + Expression> aliases = customer + .> get("aliases"); + + // Get Metamodel from Root + cquery.select(cbuilder.size(aliases)); + cquery.where(cbuilder.equal(customer.get("id"), "3")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Integer result = tq.getSingleResult(); + Integer expectedSize = 2; + + if (result.intValue() == expectedSize.intValue()) { + TestUtil.logTrace( + "Successfully returned expected results:" + result.intValue()); + pass = true; + } else { + TestUtil.logErr("Expected: " + expectedSize.intValue() + ", actual:" + + result.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sizeExpTest failed"); + } + } + + /* + * @testName: isMember + * + * @assertion_ids: PERSISTENCE:JAVADOC:784 + * + * @test_Strategy: Select c FROM Customer c WHERE "aef" MEMBER OF c.aliases + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void isMember() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cqa = cbuilder.createQuery(Alias.class); + Root aliasRoot = cqa.from(Alias.class); + cqa = cqa.where(cbuilder.equal(aliasRoot.get("alias"), "aef")); + Alias alias = getEntityManager().createQuery(cqa).getSingleResult(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Customer.class); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + cquery.where(cbuilder.isMember(alias, + customer.> get("aliases"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + if (result.size() == 1) { + if (result.get(0).equals(customerRef[0])) { + TestUtil.logTrace( + "Successfully returned expected results" + result.toString()); + pass = true; + } else { + TestUtil.logErr("expected customer:" + customerRef[0].toString()); + TestUtil.logErr("actual customer:" + result.toString()); + } + } else { + TestUtil + .logErr("Expected number customers: 1, actual:" + result.size()); + for (Customer c : result) { + TestUtil.logErr("Received customer:" + c.toString()); + } + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("isMember test failed"); + + } + } + + /* + * @testName: isNotMember + * + * @assertion_ids: PERSISTENCE:JAVADOC:786 + * + * @test_Strategy: Select Distinct a FROM Alias a WHERE a.customerNoop NOT + * MEMBER OF a.customersNoop + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void isNotMember() throws Exception { + boolean pass = false; + + String[] expected = new String[30]; + for (int i = 0; i < 30; i++) { + expected[i] = aliasRef[i].getId(); + } + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + cquery.where(cbuilder.isNotMember(alias. get("customerNoop"), + alias.> get("customersNoop"))); + + cquery.distinct(true); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("isNotMember test failed"); + + } + + } + + /* + * @testName: expressionAliasTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:958; + * + * @test_Strategy: + * + */ + @SetupMethod(name = "setupAliasData") + @Test + public void expressionAliasTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + CriteriaQuery cquery = cbuilder.createQuery(); + if (cquery != null) { + Root customer = cquery.from(Customer.class); + + // Get Metamodel from Root + EntityType Customer_ = customer.getModel(); + + Expression idPath = customer + .get(Customer_.getSingularAttribute("id", String.class)); + String id = idPath.alias("IDID").getAlias(); + if (id.equals("IDID")) { + TestUtil.logTrace("id=" + id); + pass = true; + } else { + TestUtil.logErr("Expected id value:IDID, actual value:" + id); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + if (!pass) { + throw new Exception("expressionAliasTest failed"); + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT4.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT4.java new file mode 100644 index 0000000000..50464b0cd9 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT4.java @@ -0,0 +1,1248 @@ +/* + * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.criteriaapi.CriteriaBuilder; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.harness.SetupMethod; +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.schema30.Address; +import com.sun.ts.tests.jpa.common.schema30.Alias; +import com.sun.ts.tests.jpa.common.schema30.Customer; +import com.sun.ts.tests.jpa.common.schema30.Customer_; +import com.sun.ts.tests.jpa.common.schema30.HardwareProduct; +import com.sun.ts.tests.jpa.common.schema30.LineItem; +import com.sun.ts.tests.jpa.common.schema30.Order; +import com.sun.ts.tests.jpa.common.schema30.Order_; +import com.sun.ts.tests.jpa.common.schema30.Product; +import com.sun.ts.tests.jpa.common.schema30.ShelfLife; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct_; +import com.sun.ts.tests.jpa.common.schema30.Spouse; +import com.sun.ts.tests.jpa.common.schema30.Trim; +import com.sun.ts.tests.jpa.common.schema30.UtilAliasOnlyData; + +import jakarta.persistence.Query; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.Trimspec; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ParameterExpression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; + +public class ClientIT4 extends UtilAliasOnlyData { + + + + /* + * @testName: greaterThanExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:774 + * + * @test_Strategy: Select a From Alias a WHERE LENGTH(a.alias) > 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void greaterThanExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[7]; + expected[0] = aliasRef[7].getId(); + expected[1] = aliasRef[9].getId(); + expected[2] = aliasRef[12].getId(); + expected[3] = aliasRef[13].getId(); + expected[4] = aliasRef[17].getId(); + expected[5] = aliasRef[27].getId(); + expected[6] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.greaterThan( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + 4)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("greaterThanExpNumTest failed"); + + } + } + + /* + * @testName: greaterThanExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:773 + * + * @test_Strategy: Select a From Alias a WHERE LENGTH(a.alias) > 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void greaterThanExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[7]; + ; + expected[0] = aliasRef[7].getId(); + expected[1] = aliasRef[9].getId(); + expected[2] = aliasRef[12].getId(); + expected[3] = aliasRef[13].getId(); + expected[4] = aliasRef[17].getId(); + expected[5] = aliasRef[27].getId(); + expected[6] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.greaterThan( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + cbuilder.literal(4))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("greaterThanExpExpTest failed"); + + } + } + + /* + * @testName: greaterThanOrEqualToExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:795; PERSISTENCE:JAVADOC:776 + * + * @test_Strategy: Select a From Alias a WHERE LENGTH(a.alias) >= 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void greaterThanOrEqualToExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[13]; + ; + + expected[0] = aliasRef[2].getId(); + expected[1] = aliasRef[3].getId(); + expected[2] = aliasRef[7].getId(); + expected[3] = aliasRef[9].getId(); + expected[4] = aliasRef[12].getId(); + expected[5] = aliasRef[13].getId(); + expected[6] = aliasRef[17].getId(); + expected[7] = aliasRef[19].getId(); + expected[8] = aliasRef[22].getId(); + expected[9] = aliasRef[23].getId(); + expected[10] = aliasRef[24].getId(); + expected[11] = aliasRef[27].getId(); + expected[12] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.greaterThanOrEqualTo( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + 4)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("greaterThanOrEqualToExpNumTest failed"); + + } + } + + /* + * @testName: greaterThanOrEqualToExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:775 + * + * @test_Strategy: Select a From Alias a WHERE LENGTH(a.alias) >= 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void greaterThanOrEqualToExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[13]; + + expected[0] = aliasRef[2].getId(); + expected[1] = aliasRef[3].getId(); + expected[2] = aliasRef[7].getId(); + expected[3] = aliasRef[9].getId(); + expected[4] = aliasRef[12].getId(); + expected[5] = aliasRef[13].getId(); + expected[6] = aliasRef[17].getId(); + expected[7] = aliasRef[19].getId(); + expected[8] = aliasRef[22].getId(); + expected[9] = aliasRef[23].getId(); + expected[10] = aliasRef[24].getId(); + expected[11] = aliasRef[27].getId(); + expected[12] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.greaterThanOrEqualTo( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + cbuilder.literal(4))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("greaterThanOrEqualToExpExpTest failed"); + + } + } + + + /* + * @testName: gtExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:779 + * + * @test_Strategy: Select a From Alias a WHERE LENGTH(a.alias) > 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void gtExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[7]; + expected[0] = aliasRef[7].getId(); + expected[1] = aliasRef[9].getId(); + expected[2] = aliasRef[12].getId(); + expected[3] = aliasRef[13].getId(); + expected[4] = aliasRef[17].getId(); + expected[5] = aliasRef[27].getId(); + expected[6] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.gt( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + 4)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("gtExpNumTest failed"); + + } + } + + /* + * @testName: gtExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:778 + * + * @test_Strategy: Select a From Alias a WHERE LENGTH(a.alias) > 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void gtExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[7]; + ; + expected[0] = aliasRef[7].getId(); + expected[1] = aliasRef[9].getId(); + expected[2] = aliasRef[12].getId(); + expected[3] = aliasRef[13].getId(); + expected[4] = aliasRef[17].getId(); + expected[5] = aliasRef[27].getId(); + expected[6] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.gt( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + cbuilder.literal(4))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("gtExpExpTest failed"); + + } + } + + /* + * @testName: geExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:772 + * + * @test_Strategy: Select Distinct a From Alias a WHERE LENGTH(a.alias) >= 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void geExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[13]; + ; + expected[0] = aliasRef[2].getId(); + expected[1] = aliasRef[3].getId(); + expected[2] = aliasRef[7].getId(); + expected[3] = aliasRef[9].getId(); + expected[4] = aliasRef[12].getId(); + expected[5] = aliasRef[13].getId(); + expected[6] = aliasRef[17].getId(); + expected[7] = aliasRef[19].getId(); + expected[8] = aliasRef[22].getId(); + expected[9] = aliasRef[23].getId(); + expected[10] = aliasRef[24].getId(); + expected[11] = aliasRef[27].getId(); + expected[12] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.ge( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + 4)); + cquery.distinct(true); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("geExpNumTest failed"); + + } + } + + /* + * @testName: geExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:771 + * + * @test_Strategy: Select Distinct a From Alias a WHERE LENGTH(a.alias) >= 4 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void geExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[13]; + ; + expected[0] = aliasRef[2].getId(); + expected[1] = aliasRef[3].getId(); + expected[2] = aliasRef[7].getId(); + expected[3] = aliasRef[9].getId(); + expected[4] = aliasRef[12].getId(); + expected[5] = aliasRef[13].getId(); + expected[6] = aliasRef[17].getId(); + expected[7] = aliasRef[19].getId(); + expected[8] = aliasRef[22].getId(); + expected[9] = aliasRef[23].getId(); + expected[10] = aliasRef[24].getId(); + expected[11] = aliasRef[27].getId(); + expected[12] = aliasRef[28].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.ge( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + cbuilder.literal(4))); + cquery.distinct(true); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("geExpExpTest failed"); + + } + } + + + /* + * @testName: substringExpIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:850 + * + * @test_Strategy: Select a From Alias a WHERE a.alias = SUBSTRING("iris", 1) + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void substringExpIntTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = aliasRef[19].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + + cquery.select(alias); + cquery.where(cbuilder.equal( + alias.get(Alias_.getSingularAttribute("alias", String.class)), + cbuilder.substring(cbuilder.parameter(String.class, "string1"), 1))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + tq.setParameter("string1", "iris"); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("substringExpIntTest failed"); + + } + } + + /* + * @testName: substringExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:849 + * + * @test_Strategy: Select a From Alias a WHERE a.alias = SUBSTRING("iris", 1) + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void substringExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = aliasRef[19].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + + cquery.select(alias); + cquery.where(cbuilder.equal( + alias.get(Alias_.getSingularAttribute("alias", String.class)), + cbuilder.substring(cbuilder.parameter(String.class, "string1"), + cbuilder.literal(1)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + tq.setParameter("string1", "iris"); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("substringExpExpTest failed"); + + } + } + + /* + * @testName: substringExpIntIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:852 + * + * @test_Strategy: Select a From Alias a WHERE a.alias = SUBSTRING("iris", 1, + * 4) + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void substringExpIntIntTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = aliasRef[19].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + + cquery.select(alias); + cquery.where(cbuilder.equal( + alias.get(Alias_.getSingularAttribute("alias", String.class)), + cbuilder.substring(cbuilder.parameter(String.class, "string1"), 1, + 4))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + tq.setParameter("string1", "iris"); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("substringExpIntIntTest failed"); + + } + } + + /* + * @testName: substringExpExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:851 + * + * @test_Strategy: Select a From Alias a WHERE a.alias = SUBSTRING("iris", 1, + * 4) + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void substringExpExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = aliasRef[19].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + + cquery.select(alias); + cquery.where(cbuilder.equal( + alias.get(Alias_.getSingularAttribute("alias", String.class)), + cbuilder.substring(cbuilder.parameter(String.class, "string1"), + cbuilder.literal(1), cbuilder.literal(4)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + tq.setParameter("string1", "iris"); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("substringExpExpExpTest failed"); + + } + } + + + /* + * @testName: upper + * + * @assertion_ids: PERSISTENCE:JAVADOC:874 + * + * @test_Strategy: Select upper(a.alias) From Alias a WHERE a.alias = 'iris' + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void upper() throws Exception { + final String expectedResult = "IRIS"; + boolean pass = false; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(String.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + + cquery.where(cb.equal( + alias.get(Alias_.getSingularAttribute("alias", String.class)), + cb.literal("iris"))); + cquery.select(cb.upper( + alias.get(Alias_.getSingularAttribute("alias", String.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + String result = tq.getSingleResult(); + + if (result != null) { + if (result.equals(expectedResult)) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("Mismatch in received results - expected = " + + expectedResult + " received = " + result); + } + } else { + TestUtil.logErr("Missing expected result"); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("upper test failed"); + + } + } + + /* + * @testName: length + * + * @assertion_ids: PERSISTENCE:JAVADOC:795 + * + * @test_Strategy: Select a From Alias a WHERE length (a.alias) = 9 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void length() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = aliasRef[27].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + + cquery.where(cbuilder.equal( + cbuilder.length( + alias.get(Alias_.getSingularAttribute("alias", String.class))), + 9)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("length test failed"); + + } + } + + /* + * @testName: locateExpStringTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:809 + * + * @test_Strategy: Select a from Alias a where LOCATE('ev', a.alias) = 3 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void locateExpStringTest() throws Exception { + boolean pass = false; + + String[] expected = new String[3]; + expected[0] = aliasRef[12].getId(); + expected[1] = aliasRef[13].getId(); + expected[2] = aliasRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.equal(cbuilder.locate( + alias.get(Alias_.getSingularAttribute("alias", String.class)), "ev"), + 3)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("locateExpStringTest failed"); + + } + } + + /* + * @testName: locateExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:808 + * + * @test_Strategy: Select a from Alias a where LOCATE('ev', a.alias) = 3 + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void locateExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[3]; + expected[0] = aliasRef[12].getId(); + expected[1] = aliasRef[13].getId(); + expected[2] = aliasRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + cquery.where(cbuilder.equal(cbuilder.locate( + alias.get(Alias_.getSingularAttribute("alias", String.class)), + cbuilder.literal("ev")), 3)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("locateExpExpTest failed"); + + } + } + + + /* + * @testName: locateExpressionExpressionExpressionTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:810 + * + * @test_Strategy: SELECT a FROM ALIAS a WHERE (LOCATE(ev, a.alias, 1) > 0) + * + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void locateExpressionExpressionExpressionTest() throws Exception { + boolean pass = false; + + String[] expected = new String[3]; + expected[0] = aliasRef[12].getId(); + expected[1] = aliasRef[13].getId(); + expected[2] = aliasRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) + + { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + + Expression exp1 = alias + .get(Alias_.getSingularAttribute("alias", String.class)); + Expression exp2 = cbuilder.literal("ev"); + Expression exp3 = cbuilder.toInteger(cbuilder.literal(1)); + + cquery.where(cbuilder.gt(cbuilder.locate(exp1, exp2, exp3), 0)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("locateExpressionExpressionExpressionTest failed"); + + } + } + + /* + * @testName: locateExpressionStringIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:811 + * + * @test_Strategy: SELECT a FROM ALIAS a WHERE (LOCATE(ev, a.alias, 1) > 0) + * + * + */ + @SetupMethod(name = "setupAliasOnlyData") + @Test + public void locateExpressionStringIntTest() throws Exception { + boolean pass = false; + + String[] expected = new String[3]; + expected[0] = aliasRef[12].getId(); + expected[1] = aliasRef[13].getId(); + expected[2] = aliasRef[17].getId(); + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Alias.class); + if (cquery != null) + + { + Root alias = cquery.from(Alias.class); + + // Get Metamodel from Root + EntityType Alias_ = alias.getModel(); + cquery.select(alias); + + Expression exp1 = alias + .get(Alias_.getSingularAttribute("alias", String.class)); + + cquery.where(cbuilder.gt(cbuilder.locate(exp1, "ev", 1), 0)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Alias a : result) { + actual.add(Integer.parseInt(a.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("locateExpressionExpressionExpressionTest failed"); + + } + } + +} diff --git a/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT5.java b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT5.java new file mode 100644 index 0000000000..482397b1e8 --- /dev/null +++ b/jpa/src/main/java/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/ClientIT5.java @@ -0,0 +1,2967 @@ +/* + * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.ts.tests.jpa.core.criteriaapi.CriteriaBuilder; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sun.ts.lib.harness.SetupMethod; +import com.sun.ts.lib.util.TestUtil; +import com.sun.ts.tests.jpa.common.schema30.Address; +import com.sun.ts.tests.jpa.common.schema30.Alias; +import com.sun.ts.tests.jpa.common.schema30.Customer; +import com.sun.ts.tests.jpa.common.schema30.Customer_; +import com.sun.ts.tests.jpa.common.schema30.HardwareProduct; +import com.sun.ts.tests.jpa.common.schema30.LineItem; +import com.sun.ts.tests.jpa.common.schema30.Order; +import com.sun.ts.tests.jpa.common.schema30.Order_; +import com.sun.ts.tests.jpa.common.schema30.Product; +import com.sun.ts.tests.jpa.common.schema30.ShelfLife; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct; +import com.sun.ts.tests.jpa.common.schema30.SoftwareProduct_; +import com.sun.ts.tests.jpa.common.schema30.Spouse; +import com.sun.ts.tests.jpa.common.schema30.Trim; +import com.sun.ts.tests.jpa.common.schema30.UtilProductData; + +import jakarta.persistence.Query; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.Trimspec; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ParameterExpression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; + +public class ClientIT5 extends UtilProductData { + + + /* + * @testName: primaryKeyJoinColumnTest + * + * @assertion_ids: PERSISTENCE:SPEC:1120; + * PERSISTENCE:SPEC:1121;PERSISTENCE:SPEC:1121.1; PERSISTENCE:SPEC:2109; + * + * @test_Strategy: Select p from Product p where p.whouse = "WH5" + */ + @SetupMethod(name = "setupProductData") + @Test + public void primaryKeyJoinColumnTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + Root product = cquery.from(Product.class); + cquery.select(product); + cquery.where(cbuilder.equal(product.get("wareHouse"), "WH5")); + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + if (result.size() == 1 && result.get(0).getWareHouse().equals("WH5")) { + TestUtil.logTrace( + "Expected results received:" + result.get(0).getWareHouse()); + pass = true; + } else { + TestUtil.logErr("test returned: " + result.get(0).getWareHouse() + + ", expected: WH5"); + for (Product p : result) { + TestUtil.logErr("**id=" + p.getId() + ", model=" + p.getWareHouse()); + } + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("primaryKeyJoinColumnTest failed"); + } + } + + /* + * @testName: asc + * + * @assertion_ids: PERSISTENCE:JAVADOC:741; PERSISTENCE:SPEC:1690; + * PERSISTENCE:SPEC:1774; + * + * @test_Strategy: Select hardwareProduct from HardwareProduct ORDER BY + * hardware.Product.modeNumber + */ + @SetupMethod(name = "setupProductData") + @Test + public void asc() throws Exception { + final int expectedModelNumber = 40; + final int expectedResultSize = 10; + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder + .createQuery(HardwareProduct.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root hardProd = cquery.from(HardwareProduct.class); + EntityType HardwareProduct_ = hardProd.getModel(); + cquery.select(hardProd); + cquery.orderBy(cbuilder.asc( + hardProd.get(HardwareProduct_.getSingularAttribute("modelNumber")))); + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + if (result.size() == expectedResultSize + && result.get(0).getModelNumber() == expectedModelNumber) { + TestUtil.logTrace("Expected results received."); + pass = true; + } else { + TestUtil.logErr("test returned: " + result.get(0).getModelNumber() + + ", expected: " + expectedModelNumber); + for (HardwareProduct o : result) { + TestUtil + .logErr("**id=" + o.getId() + ", model=" + o.getModelNumber()); + } + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("asc Test failed"); + } + } + + /* + * @testName: desc + * + * @assertion_ids: PERSISTENCE:JAVADOC:762; PERSISTENCE:SPEC:1774; + * + * @test_Strategy: + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void desc() throws Exception { + final int expectedModelNumber = 104; + final int expectedResultSize = 10; + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder + .createQuery(HardwareProduct.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root hardProd = cquery.from(HardwareProduct.class); + EntityType HardwareProduct_ = hardProd.getModel(); + cquery.select(hardProd); + cquery.orderBy(cbuilder.desc( + hardProd.get(HardwareProduct_.getSingularAttribute("modelNumber")))); + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + if (result.size() == expectedResultSize + && result.get(7).getModelNumber() == expectedModelNumber) { + TestUtil.logTrace("Expected results received."); + pass = true; + } else { + TestUtil.logErr("test returned: " + result.get(7).getModelNumber() + + "expected: " + expectedModelNumber); + for (HardwareProduct o : result) { + TestUtil + .logErr("**id=" + o.getId() + ", model=" + o.getModelNumber()); + } + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("desc Test failed"); + } + } + + + /* + * @testName: sumExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:853; PERSISTENCE:SPEC:1740; + * PERSISTENCE:SPEC:1746; PERSISTENCE:SPEC:1746.1; + * + * @test_Strategy: Convert the following JPQL to CriteriaQuery SELECT + * Sum(p.price) FROM Product p + */ + @SetupMethod(name = "setupProductData") + @Test + public void sumExpTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Number.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root product = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = product.getModel(); + Expression e = product + .get(Product_.getSingularAttribute("price", Double.class)); + cquery.select(cbuilder.sum(e)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + double d1 = 33387.14D; + double d2 = 33387.15D; + + Number d3 = tq.getSingleResult(); + if (d3 instanceof Double) { + TestUtil.logTrace("Received expected type of Double"); + pass1 = true; + } else { + TestUtil.logErr("Expected type Double, actual:" + d3); + } + double d4 = d3.doubleValue(); + if (((d4 >= d1) && (d4 < d2))) { + TestUtil.logTrace("sum returned expected results: " + d1); + pass2 = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("sumExpTest failed"); + } + } + + /* + * @testName: sumExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:855 + * + * @test_Strategy: Convert the following JPQL to CriteriaQuery SELECT + * sum(p.price,100) FROM Product p WHERE p.id = 1 + */ + @SetupMethod(name = "setupProductData") + @Test + public void sumExpNumTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root product = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = product.getModel(); + Expression e = product + .get(Product_.getSingularAttribute("quantity", Integer.class)); + cquery.select(cbuilder.sum(e, 100)); + cquery.where(cbuilder + .equal(product.get(Product_.getSingularAttribute("id")), "1")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer actual = tq.getSingleResult(); + Integer expected = productRef[0].getQuantity() + 100; + if (actual.equals(expected)) { + TestUtil.logTrace("sum returned expected results: " + actual); + pass = true; + } else { + TestUtil + .logErr("Expected value:" + expected + ", actual value:" + actual); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sumExpNumTest failed"); + } + } + + /* + * @testName: sumNumExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:856 + * + * @test_Strategy: Convert the following JPQL to CriteriaQuery SELECT + * sum(100,p.price) FROM Product p WHERE p.id = 1 + */ + @SetupMethod(name = "setupProductData") + @Test + public void sumNumExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root product = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = product.getModel(); + Expression e = product + .get(Product_.getSingularAttribute("quantity", Integer.class)); + cquery.select(cbuilder.sum(100, e)); + cquery.where(cbuilder + .equal(product.get(Product_.getSingularAttribute("id")), "1")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer actual = tq.getSingleResult(); + Integer expected = productRef[0].getQuantity() + 100; + if (actual.equals(expected)) { + TestUtil.logTrace("sum test returned expected results: " + actual); + pass = true; + } else { + TestUtil + .logErr("Expected value:" + expected + ", actual value:" + actual); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sumNumExpTest failed"); + } + } + + /* + * @testName: sumExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:854 + * + * @test_Strategy: Convert the following JPQL to CriteriaQuery SELECT + * sum(p.quantity,p.quantity) FROM Product p WHERE p.id = 1 + */ + @SetupMethod(name = "setupProductData") + @Test + public void sumExpExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root product = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = product.getModel(); + Expression e = product + .get(Product_.getSingularAttribute("quantity", Integer.class)); + cquery.select(cbuilder.sum(e, e)); + cquery.where(cbuilder + .equal(product.get(Product_.getSingularAttribute("id")), "1")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer actual = tq.getSingleResult(); + Integer expected = productRef[0].getQuantity() + + productRef[0].getQuantity(); + if (actual.equals(expected)) { + TestUtil.logTrace("sum test returned expected results: " + actual); + pass = true; + } else { + TestUtil + .logErr("Expected value:" + expected + ", actual value:" + actual); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sumExpExpTest failed"); + } + } + + + /* + * @testName: exists + * + * @assertion_ids: PERSISTENCE:JAVADOC:769; PERSISTENCE:JAVADOC:1190; + * PERSISTENCE:SPEC:1767; + * + * @test_Strategy: convert the following JPQL into CriteriaQuery + * + * SELECT product FROM PRODUCT product WHERE EXISTS (Select hardProd From + * PRODUCT hardprod where hardprod.id = '19'). + * + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void exists() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = "19"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root product = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = product.getModel(); + + // create Subquery instance, with root Customer + Subquery sq = cquery.subquery(Product.class); + Root hardProd = sq.from(Product.class); + if (hardProd.getModel().getName().equals(Product.class.getSimpleName())) { + TestUtil.logTrace("Received expected subquery root"); + } else { + TestUtil + .logErr("Expected subquery root:" + Product.class.getSimpleName() + + ", actual:" + hardProd.getModel().getName()); + } + + // the subquery references the root of the containing query + sq.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("id", String.class)), "19")) + .select(hardProd); + + // an exists condition is applied to the subquery result + cquery.where(cbuilder.exists(sq)); + + cquery.select(product); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("exists test failed"); + } + } + + /* + * @testName: subqueryFromEntityTypeTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:1191; PERSISTENCE:SPEC:1765; + * + * @test_Strategy: + * + * SELECT product FROM PRODUCT product WHERE EXISTS (Select hardProd From + * PRODUCT hardprod where hardprod.id = '19'). + * + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void subqueryFromEntityTypeTest() throws Exception { + boolean pass = false; + + String[] expected = new String[1]; + expected[0] = "19"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root product = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = product.getModel(); + + // create Subquery instance, with root Customer + Subquery sq = cquery.subquery(Product.class); + Root hardProd = sq.from(Product_); + if (hardProd.getModel().getName().equals(Product_.getName())) { + TestUtil.logTrace("Received expected subquery root"); + } else { + TestUtil.logErr("Expected subquery root:" + Product_.getName() + + ", actual:" + hardProd.getModel().getName()); + } + + // the subquery references the root of the containing query + sq.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("id", String.class)), "19")) + .select(hardProd); + + // an exists condition is applied to the subquery result + cquery.where(cbuilder.exists(sq)); + + cquery.select(product); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("subqueryFromEntityTypeTest failed"); + } + } + + /* + * @testName: all + * + * @assertion_ids: PERSISTENCE:JAVADOC:735; PERSISTENCE:SPEC:1766; + * PERSISTENCE:SPEC:1766.1; + * + * @test_Strategy: convert the following JPQL into CriteriaQuery + * + * Select hardProd.modelNumber From HardwareProduct hardProd where + * hardProd.modelNumber > ALL ( Select subHardProd.modelNumber From + * HardwareProduct subHardProd where subHardProd.modelNumber < 10050 ) + * + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void all() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + List expected = new ArrayList(); + expected.add(10050); + expected.add(2578); + expected.add(3000); + expected.add(10000); + expected.add(2368); + Collections.sort(expected); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + TestUtil.logTrace("Obtained Non-null Criteria Query"); + Root hardProd = cquery.from(HardwareProduct.class); + + // Get Metamodel from Root + EntityType HardwareProduct_ = hardProd.getModel(); + + // create Subquery instance + Subquery sq = cquery.subquery(Integer.class); + Root subHardProd = sq.from(HardwareProduct.class); + + sq.select(subHardProd.get( + HardwareProduct_.getSingularAttribute("modelNumber", Integer.class))); + sq.where(cbuilder.lt(subHardProd.get( + HardwareProduct_.getSingularAttribute("modelNumber", Integer.class)), + 1050)); + + cquery.select(hardProd.get( + HardwareProduct_.getSingularAttribute("modelNumber", Integer.class))); + cquery + .where( + cbuilder.gt( + hardProd.get(HardwareProduct_ + .getSingularAttribute("modelNumber", Integer.class)), + cbuilder.all(sq))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List actual = tq.getResultList(); + Collections.sort(actual); + if (expected.containsAll(actual) && actual.containsAll(expected) + && expected.size() == actual.size()) { + TestUtil.logTrace("Received expected results"); + pass = true; + } else { + TestUtil.logErr("Did not get expected results"); + for (Integer i : expected) { + TestUtil.logErr("expected:" + i); + } + for (Integer i : actual) { + TestUtil.logErr("actual:" + i); + } + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("all test failed"); + } + } + + + /* + * @testName: sumAsDoubleTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:857 + * + * @test_Strategy: + * + * Select sumAsDouble(p.quantity*0.5) From Product p WHERE p.quantity > 50 and + * p.quantity < 100 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void sumAsDoubleTest() throws Exception { + boolean pass = false; + double expected = 217.5d; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cb.createQuery(Double.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where( + cb.gt( + prod.get( + Product_.getSingularAttribute("quantity", Integer.class)), + 50), + cb.lt( + prod.get( + Product_.getSingularAttribute("quantity", Integer.class)), + 100)); + + cquery.select(cb.sumAsDouble(cb.toFloat(cb.prod( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + 0.5f)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Double actual = tq.getSingleResult(); + + TestUtil.logTrace("actual" + actual); + + if (expected == actual) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expected + ", actual: " + actual); + + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sumAsDoubleTest failed"); + + } + } + + /* + * @testName: sumAsLongTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:858 + * + * @test_Strategy: + * + * Select sumAsLong(p.quantity) From Product p WHERE p.quantity > 50 and + * p.quantity < 100 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void sumAsLongTest() throws Exception { + boolean pass = false; + long expected = 435; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cb.createQuery(Long.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where( + cb.gt( + prod.get( + Product_.getSingularAttribute("quantity", Integer.class)), + 50), + cb.lt( + prod.get( + Product_.getSingularAttribute("quantity", Integer.class)), + 100)); + cquery.select(cb.sumAsLong( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Long actual = tq.getSingleResult(); + + TestUtil.logTrace("actual" + actual); + + if (expected == actual) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expected + ", actual: " + actual); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sumAsLongTest failed"); + + } + } + + + /* + * @testName: lessThanExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:797 + * + * @test_Strategy: + * + * Select p From Product p WHERE p.quantity < 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void lessThanExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[20]; + ; + expected[0] = "4"; + expected[1] = "6"; + expected[2] = "7"; + expected[3] = "8"; + expected[4] = "9"; + expected[5] = "12"; + expected[6] = "15"; + expected[7] = "16"; + expected[8] = "17"; + expected[9] = "19"; + expected[10] = "21"; + expected[11] = "22"; + expected[12] = "24"; + expected[13] = "27"; + expected[14] = "28"; + expected[15] = "30"; + expected[16] = "31"; + expected[17] = "35"; + expected[18] = "36"; + expected[19] = "37"; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cb.createQuery(Product.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cb.lessThan( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + 50)); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("lessThanExpNumTest failed"); + + } + } + + /* + * @testName: lessThanExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:796 + * + * @test_Strategy: + * + * Select p From Product p WHERE p.quantity < 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void lessThanExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[20]; + ; + expected[0] = "4"; + expected[1] = "6"; + expected[2] = "7"; + expected[3] = "8"; + expected[4] = "9"; + expected[5] = "12"; + expected[6] = "15"; + expected[7] = "16"; + expected[8] = "17"; + expected[9] = "19"; + expected[10] = "21"; + expected[11] = "22"; + expected[12] = "24"; + expected[13] = "27"; + expected[14] = "28"; + expected[15] = "30"; + expected[16] = "31"; + expected[17] = "35"; + expected[18] = "36"; + expected[19] = "37"; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cb.createQuery(Product.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cb.lessThan( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + cb.literal(50))); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("lessThanExpExpTest failed"); + + } + } + + /* + * @testName: lessThanOrEqualToExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:799 + * + * @test_Strategy: Select p From Product p WHERE p.quantity <= 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void lessThanOrEqualToExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[22]; + ; + expected[0] = "4"; + expected[1] = "5"; + expected[2] = "6"; + expected[3] = "7"; + expected[4] = "8"; + expected[5] = "9"; + expected[6] = "12"; + expected[7] = "15"; + expected[8] = "16"; + expected[9] = "17"; + expected[10] = "19"; + expected[11] = "20"; + expected[12] = "21"; + expected[13] = "22"; + expected[14] = "24"; + expected[15] = "27"; + expected[16] = "28"; + expected[17] = "30"; + expected[18] = "31"; + expected[19] = "35"; + expected[20] = "36"; + expected[21] = "37"; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(Product.class); + + if (cquery != null) { + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cb.lessThanOrEqualTo( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + 50)); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("lessThanOrEqualToExpNumTest failed"); + + } + } + + /* + * @testName: lessThanOrEqualToExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:798 + * + * @test_Strategy: Select p From Product p WHERE p.quantity <= 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void lessThanOrEqualToExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[22]; + ; + expected[0] = "4"; + expected[1] = "5"; + expected[2] = "6"; + expected[3] = "7"; + expected[4] = "8"; + expected[5] = "9"; + expected[6] = "12"; + expected[7] = "15"; + expected[8] = "16"; + expected[9] = "17"; + expected[10] = "19"; + expected[11] = "20"; + expected[12] = "21"; + expected[13] = "22"; + expected[14] = "24"; + expected[15] = "27"; + expected[16] = "28"; + expected[17] = "30"; + expected[18] = "31"; + expected[19] = "35"; + expected[20] = "36"; + expected[21] = "37"; + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(Product.class); + + if (cquery != null) { + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cb.lessThanOrEqualTo( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + cb.literal(50))); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("lessThanOrEqualToExpExpTest failed"); + + } + } + + /* + * @testName: between + * + * @assertion_ids: PERSISTENCE:JAVADOC:743; PERSISTENCE:JAVADOC:835 + * + * @test_Strategy: SELECT p From Product p where p.shelfLife.soldDate BETWEEN + * :date1 AND :date6 + */ + @SetupMethod(name = "setupProductData") + @Test + public void between() throws Exception { + boolean pass = false; + + String[] expected = new String[4]; + expected[0] = "31"; + expected[1] = "32"; + expected[2] = "33"; + expected[3] = "37"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + Date date1 = getSQLDate("2000-02-14"); + Date date6 = getSQLDate("2005-02-18"); + + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = product.getModel(); + EmbeddableType ShelfLife_ = mm.embeddable(ShelfLife.class); + + cquery.select(product); + + cquery + .where(cbuilder.between( + product + .get(Product_.getSingularAttribute("shelfLife", + ShelfLife.class)) + .get(ShelfLife_.getSingularAttribute("soldDate", Date.class)), + cbuilder.parameter(Date.class, "date1"), + cbuilder.parameter(Date.class, "date6"))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + tq.setParameter("date1", date1); + tq.setParameter("date6", date6); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("between test failed"); + } + } + + + /* + * @testName: ltExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:814 + * + * @test_Strategy: Select p From Product p WHERE p.quantity < 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void ltExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[20]; + expected[0] = "4"; + expected[1] = "6"; + expected[2] = "7"; + expected[3] = "8"; + expected[4] = "9"; + expected[5] = "12"; + expected[6] = "15"; + expected[7] = "16"; + expected[8] = "17"; + expected[9] = "19"; + expected[10] = "21"; + expected[11] = "22"; + expected[12] = "24"; + expected[13] = "27"; + expected[14] = "28"; + expected[15] = "30"; + expected[16] = "31"; + expected[17] = "35"; + expected[18] = "36"; + expected[19] = "37"; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cb.createQuery(Product.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cb.lt( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + 50)); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("ltExpNumTest failed"); + + } + } + + /* + * @testName: ltExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:813 + * + * @test_Strategy: Select p From Product p WHERE p.quantity < 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void ltExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[20]; + expected[0] = "4"; + expected[1] = "6"; + expected[2] = "7"; + expected[3] = "8"; + expected[4] = "9"; + expected[5] = "12"; + expected[6] = "15"; + expected[7] = "16"; + expected[8] = "17"; + expected[9] = "19"; + expected[10] = "21"; + expected[11] = "22"; + expected[12] = "24"; + expected[13] = "27"; + expected[14] = "28"; + expected[15] = "30"; + expected[16] = "31"; + expected[17] = "35"; + expected[18] = "36"; + expected[19] = "37"; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cb.createQuery(Product.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cb.lt( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + cb.literal(50))); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("ltExpExpTest failed"); + + } + } + + /* + * @testName: leExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:793 + * + * @test_Strategy: Select p From Product p WHERE p.quantity <= 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void leExpNumTest() throws Exception { + boolean pass = false; + + String[] expected = new String[22]; + expected[0] = "4"; + expected[1] = "5"; + expected[2] = "6"; + expected[3] = "7"; + expected[4] = "8"; + expected[5] = "9"; + expected[6] = "12"; + expected[7] = "15"; + expected[8] = "16"; + expected[9] = "17"; + expected[10] = "19"; + expected[11] = "20"; + expected[12] = "21"; + expected[13] = "22"; + expected[14] = "24"; + expected[15] = "27"; + expected[16] = "28"; + expected[17] = "30"; + expected[18] = "31"; + expected[19] = "35"; + expected[20] = "36"; + expected[21] = "37"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cbuilder.le( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + 50)); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("leExpNumTest failed"); + + } + } + + /* + * @testName: leExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:792 + * + * @test_Strategy: Select p From Product p WHERE p.quantity <= 50 + * + */ + @SetupMethod(name = "setupProductData") + @Test + public void leExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[22]; + expected[0] = "4"; + expected[1] = "5"; + expected[2] = "6"; + expected[3] = "7"; + expected[4] = "8"; + expected[5] = "9"; + expected[6] = "12"; + expected[7] = "15"; + expected[8] = "16"; + expected[9] = "17"; + expected[10] = "19"; + expected[11] = "20"; + expected[12] = "21"; + expected[13] = "22"; + expected[14] = "24"; + expected[15] = "27"; + expected[16] = "28"; + expected[17] = "30"; + expected[18] = "31"; + expected[19] = "35"; + expected[20] = "36"; + expected[21] = "37"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + + Root prod = cquery.from(Product.class); + + // Get Metamodel from Root + EntityType Product_ = prod.getModel(); + cquery.where(cbuilder.le( + prod.get(Product_.getSingularAttribute("quantity", Integer.class)), + cbuilder.literal(50))); + cquery.select(prod); + + TypedQuery tq = getEntityManager().createQuery(cquery); + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("leExpExpTest failed"); + + } + } + + /* + * @testName: neg + * + * @assertion_ids: PERSISTENCE:JAVADOC:820 + * + * @test_Strategy: SELECT NEG(p.quantity) From Product p where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void neg() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.neg(product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expectedResult = Integer.valueOf(-5); + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("neg test failed"); + } + + } + + + /* + * @testName: prodExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:838; PERSISTENCE:SPEC:1746; + * PERSISTENCE:SPEC:1746.2; + * + * @test_Strategy: SELECT p.quantity *10F From Product p where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void prodExpNumTest() throws Exception { + boolean pass1 = false; + boolean pass2 = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Number.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.prod( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 10F)); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Number result = tq.getSingleResult(); + Float expectedResult = 5F * 10F; + + if (result instanceof Float) { + TestUtil.logTrace("Received expected type of Float"); + pass1 = true; + } else { + TestUtil.logErr("Expected type Double, actual:" + result); + } + Float f = result.floatValue(); + if (f == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results:" + f); + pass2 = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass1 || !pass2) { + throw new Exception("prodExpNumTest failed"); + } + } + + /* + * @testName: prodNumExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:839 + * + * @test_Strategy: SELECT 10 * p.quantity From Product p where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void prodNumExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.prod(10, product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expectedResult = 10 * 5; + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results:" + result); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("prodNumExpTest failed"); + } + } + + /* + * @testName: prodExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:837 + * + * @test_Strategy: SELECT p.quantity * p.quantity From Product p where + * p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void prodExpExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.prod( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expectedResult = 5 * 5; + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results:" + result); + pass = true; + } else { + TestUtil.logErr("expected: " + expectedResult.intValue() + + ", actual result:" + result.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("prodExpExpTest failed"); + } + } + + /* + * @testName: diffExpNumberTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:764 + * + * @test_Strategy: SELECT DIFF(p.quantity, 2) From Product p where + * p.quantity=5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void diffExpNumberTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.diff( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 2)); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expected = Integer.valueOf(3); + + if (result.intValue() == expected.intValue()) { + TestUtil.logTrace( + "Successfully returned expected results" + result.intValue()); + pass = true; + } else { + TestUtil.logErr("Expected: " + expected.intValue() + ", actual:" + + result.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("diffExpNumberTest failed"); + } + } + + /* + * @testName: diffNumberExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:765 + * + * @test_Strategy: SELECT DIFF(8, p.quantity) From Product p where + * p.quantity=5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void diffNumberExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.diff(8, product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expected = Integer.valueOf(3); + + if (result.intValue() == expected.intValue()) { + TestUtil.logTrace( + "Successfully returned expected results" + result.intValue()); + pass = true; + } else { + TestUtil.logErr("Expected: " + expected.intValue() + ", actual:" + + result.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("diffNumberExpTest failed"); + } + } + + /* + * @testName: diffExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:763 + * + * @test_Strategy: SELECT DIFF(p.quantity, p.quantity) From Product p where + * p.quantity=5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void diffExpExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.diff( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expected = Integer.valueOf(0); + + if (result.intValue() == expected.intValue()) { + TestUtil.logTrace( + "Successfully returned expected results" + result.intValue()); + pass = true; + } else { + TestUtil.logErr("Expected: " + expected.intValue() + ", actual:" + + result.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("diffExpExpTest failed"); + } + } + + /* + * @testName: quotExpNumTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:841 + * + * @test_Strategy: SELECT QUOT(p.quantity, 2) From Product p where p.quantity + * = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void quotExpNumTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(Number.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm.entity(Product.class); + + cquery.select(cb.quot( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 2)); + cquery.where(cb.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Number actual = tq.getSingleResult(); + + Integer expected = Integer.valueOf(2); + + if (actual.intValue() == expected.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expected.intValue() + ", actual:" + + actual.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("quotExpNumTest failed"); + } + } + + /* + * @testName: quotNumExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:842 + * + * @test_Strategy: SELECT QUOT(10, p.quantity) From Product p where p.quantity + * = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void quotNumExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(Number.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm.entity(Product.class); + + cquery.select(cb.quot(10, product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + cquery.where(cb.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Number actual = tq.getSingleResult(); + + Integer expected = Integer.valueOf(2); + + if (actual.intValue() == expected.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expected.intValue() + ", actual:" + + actual.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("quotNumExpTest failed"); + } + } + + /* + * @testName: quotExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:840 + * + * @test_Strategy: SELECT QUOT(2, p.quantity) From Product p where p.quantity + * = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void quotExpExpTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cb.createQuery(Number.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm.entity(Product.class); + + cquery.select(cb.quot( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + cquery.where(cb.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Number actual = tq.getSingleResult(); + + Integer expected = Integer.valueOf(1); + + if (actual.intValue() == expected.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("expected: " + expected.intValue() + ", actual:" + + actual.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("quotExpExpTest failed"); + } + } + + /* + * @testName: modExpIntTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:818 + * + * @test_Strategy: Select Object(p) From Product p where MOD(550, 100) = + * p.quantity + */ + @SetupMethod(name = "setupProductData") + @Test + public void modExpIntTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = "5"; + expected[1] = "20"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.where( + cbuilder.equal(cbuilder.mod(cbuilder.literal(550), 100), product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("modExpIntTest failed"); + } + } + + /* + * @testName: modExpExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:817 + * + * @test_Strategy: Select Object(p) From Product p where MOD(550, 100) = + * p.quantity + */ + @SetupMethod(name = "setupProductData") + @Test + public void modExpExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = "5"; + expected[1] = "20"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.where(cbuilder.equal( + cbuilder.mod(cbuilder.literal(550), cbuilder.literal(100)), product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("modExpExpTest failed"); + } + } + + /* + * @testName: modIntExpTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:819 + * + * @test_Strategy: Select Object(p) From Product p where MOD(550, 100) = + * p.quantity + */ + @SetupMethod(name = "setupProductData") + @Test + public void modIntExpTest() throws Exception { + boolean pass = false; + + String[] expected = new String[2]; + expected[0] = "5"; + expected[1] = "20"; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Product.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.where( + cbuilder.equal(cbuilder.mod(550, cbuilder.literal(100)), product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + List result = tq.getResultList(); + + List actual = new ArrayList(); + for (Product p : result) { + actual.add(Integer.parseInt(p.getId())); + } + if (!checkEntityPK(actual, expected)) { + TestUtil.logErr("Did not get expected results. Expected " + + expected.length + " references, got: " + actual.size()); + } else { + TestUtil.logTrace("Expected results received"); + pass = true; + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("modIntExpTest failed"); + } + } + + /* + * @testName: sqrt + * + * @assertion_ids: PERSISTENCE:JAVADOC:848 + * + * @test_Strategy: SELECT SQRT(p.quantity) From Product p where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void sqrt() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Double.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.sqrt(product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Double result = tq.getSingleResult(); + Double expectedResult = 2.1D; + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + // TestUtil.logErr("test returned:" + result.doubleValue() + "expected: + // " + expectedResult.doubleValue()); + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("sqrt test failed"); + } + } + + /* + * @testName: toLong + * + * @assertion_ids: PERSISTENCE:JAVADOC:864 + * + * @test_Strategy: SELECT toLong(p.quantity * 5L) From Product p where + * p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void toLong() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Long.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toLong(cbuilder.prod( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5L))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Long result = tq.getSingleResult(); + Long expectedResult = Long.valueOf(25); + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toLong test failed"); + } + } + + /* + * @testName: toInteger + * + * @assertion_ids: PERSISTENCE:JAVADOC:863 + * + * @test_Strategy: SELECT toInteger(p.quantity) From Product p where + * p.partNumber = 373767373 + */ + @SetupMethod(name = "setupProductData") + @Test + public void toInteger() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toInteger(product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("partNumber", Long.class)), + 373767373)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expectedResult = Integer.valueOf(5); + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toInteger test failed"); + } + } + + /* + * @testName: toFloat + * + * @assertion_ids: PERSISTENCE:JAVADOC:862 + * + * @test_Strategy: SELECT p.quantity *1/2 From Product p where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void toFloat() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Float.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toFloat(cbuilder.prod( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 0.5f))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Float result = tq.getSingleResult(); + Float expectedResult = 2.5F; + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toFloat test failed"); + } + + } + + /* + * @testName: toDouble + * + * @assertion_ids: PERSISTENCE:JAVADOC:861 + * + * @test_Strategy: SELECT toDouble(SQRT(p.quantity)) From Product p where + * p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void toDouble() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Double.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toDouble(cbuilder.sqrt(product + .get(Product_.getSingularAttribute("quantity", Integer.class))))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + Double result = tq.getSingleResult(); + Double expectedResult = 2.1D; + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toDouble test failed"); + } + } + + /* + * @testName: toBigDecimal + * + * @assertion_ids: PERSISTENCE:JAVADOC:859 + * + * @test_Strategy: SELECT ToBigDecimal(p.quantity * BIGDECIMAL) From Product p + * where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void toBigDecimal() throws Exception { + final BigDecimal expectedResult = new BigDecimal("50.5"); + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(BigDecimal.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toBigDecimal(cbuilder.prod( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + new BigDecimal("10.1")))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + BigDecimal result = tq.getSingleResult(); + + if (result.compareTo(expectedResult) == 0) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil + .logErr("test returned:" + result + "expected: " + expectedResult); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toBigDecimal test failed"); + } + } + + /* + * @testName: toBigInteger + * + * @assertion_ids: PERSISTENCE:JAVADOC:860 + * + * @test_Strategy: SELECT toBigInteger(p.quantity * BigInteger("10000000000")) + * From Product p where p.quantity = 5 + */ + @SetupMethod(name = "setupProductData") + @Test + public void toBigInteger() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(BigInteger.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toBigInteger(cbuilder.prod( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + new BigInteger("10000000000")))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("quantity", Integer.class)), + 5)); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + BigInteger result = tq.getSingleResult(); + BigInteger expectedResult = new BigInteger("50000000000"); + + if (result.compareTo(expectedResult) == 0) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil + .logErr("test returned:" + result + "expected: " + expectedResult); + } + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toBigInteger test failed"); + } + } + + /* + * @testName: toStringTest + * + * @assertion_ids: PERSISTENCE:JAVADOC:865 + * + * @test_Strategy: SELECT ToString(p.id) From Product p where p.id ='1' + */ + @SetupMethod(name = "setupProductData") + @Test + public void toStringTest() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(String.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(cbuilder.toString(cbuilder.literal('a'))); + + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("id", String.class)), "1")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + String result = tq.getSingleResult(); + String expectedResult = "a"; + + if (result.equals(expectedResult)) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil + .logErr("test returned:" + result + "expected: " + expectedResult); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("toStringTest test failed"); + } + } + + /* + * @testName: literal + * + * @assertion_ids: PERSISTENCE:JAVADOC:806 + * + * @test_Strategy: SELECT p.quantity From Product p where 5 = p.quantity + */ + @SetupMethod(name = "setupProductData") + @Test + public void literal() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + Metamodel mm = getEntityManager().getMetamodel(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Integer.class); + if (cquery != null) { + + Root product = cquery.from(Product.class); + EntityType Product_ = mm + .entity(com.sun.ts.tests.jpa.common.schema30.Product.class); + + cquery.select(product + .get(Product_.getSingularAttribute("quantity", Integer.class))); + + cquery.where(cbuilder.equal(cbuilder.literal(5), product + .get(Product_.getSingularAttribute("quantity", Integer.class)))); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Integer result = tq.getSingleResult(); + Integer expectedResult = 5; + + if (result.intValue() == expectedResult.intValue()) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("test returned:" + result.intValue() + "expected: " + + expectedResult.intValue()); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("literal test failed"); + } + } + + + /* + * @testName: currentDate + * + * @assertion_ids: PERSISTENCE:JAVADOC:759 + * + * @test_Strategy: SELECT current_date() From Product p where p.id = "1" + */ + @SetupMethod(name = "setupProductData") + @Test + public void currentDate() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery cquery = cbuilder.createQuery(Date.class); + if (cquery != null) { + Root product = cquery.from(Product.class); + EntityType Product_ = product.getModel(); + cquery.select(cbuilder.currentDate()); + cquery.where(cbuilder.equal( + product.get(Product_.getSingularAttribute("id", String.class)), "1")); + + TypedQuery tq = getEntityManager().createQuery(cquery); + + Date result = tq.getSingleResult(); + Date d = Date.valueOf(result.toString()); + if (d.equals(result)) { + TestUtil.logTrace("Successfully returned expected results"); + pass = true; + } else { + TestUtil.logErr("Did not get the expected Date object"); + } + + } else { + TestUtil.logErr("Failed to get Non-null Criteria Query"); + } + + getEntityTransaction().commit(); + + if (!pass) { + throw new Exception("currentDate test failed"); + } + } + + /* + * @testName: currentTime + * + * @assertion_ids: PERSISTENCE:JAVADOC:760 + * + * @test_Strategy: SELECT current_time() From Product p where p.id = "1" + */ + @SetupMethod(name = "setupProductData") + @Test + public void currentTime() throws Exception { + boolean pass = false; + + CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); + + getEntityTransaction().begin(); + CriteriaQuery