Search in sources :

Example 46 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class HibernateJPAConcurrencyComparisonModel method setupProvider.

/**
 * Setup the JPA provider.
 */
@Override
public void setupProvider() {
    // Configure provider to be Hibernate.
    String providerClass = "org.hibernate.ejb.HibernatePersistence";
    PersistenceProvider provider = null;
    try {
        provider = (PersistenceProvider) Class.forName(providerClass).getConstructor().newInstance();
    } catch (Exception error) {
        throw new TestProblemException("Failed to create persistence provider.", error);
    }
    Map properties = new HashMap();
    // For DataSource testing.
    // properties.put("jakarta.persistence.nonJtaDataSource", "datasource");
    // For JSE testing.
    properties.put("hibernate.connection.driver_class", getSession().getLogin().getDriverClassName());
    properties.put("hibernate.connection.url", getSession().getLogin().getConnectionString());
    properties.put("hibernate.connection.username", getSession().getLogin().getUserName());
    properties.put("hibernate.connection.password", getSession().getLogin().getPassword());
    properties.put("hibernate.connection.pool_size", "32");
    /*/ For emulated connection testing.
        try {
            Class.forName(getSession().getLogin().getDriverClassName());
        } catch (Exception ignore) {}
        properties.put("hibernate.connection.driver_class", "org.eclipse.persistence.testing.tests.performance.emulateddb.EmulatedDriver");
        properties.put("hibernate.connection.url", "emulate:" + getSession().getLogin().getConnectionString());
        properties.put("hibernate.connection.username", getSession().getLogin().getUserName());
        properties.put("hibernate.connection.password", getSession().getLogin().getPassword());
        properties.put("hibernate.connection.pool_size", "32");*/
    properties.put("hibernate.jdbc.batch_size", "100");
    properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect");
    properties.put("hibernate.cache.provider_class", "org.hibernate.cache.EhCacheProvider");
    // properties.put("hibernate.cache.use_structured_entries", "true");
    if (getSession().getSessionLog().getLevel() <= SessionLog.FINE) {
        properties.put("hibernate.show_sql", "true");
    }
    getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
}
Also used : HashMap(java.util.HashMap) PersistenceProvider(jakarta.persistence.spi.PersistenceProvider) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) Map(java.util.Map) HashMap(java.util.HashMap) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException)

Example 47 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class HibernateJPAPerformanceRegressionModel method setupProvider.

/**
 * Setup the JPA provider.
 */
@Override
public void setupProvider() {
    // Configure provider to be Hibernate.
    String providerClass = "org.hibernate.ejb.HibernatePersistence";
    PersistenceProvider provider = null;
    try {
        provider = (PersistenceProvider) Class.forName(providerClass).getConstructor().newInstance();
    } catch (Exception error) {
        throw new TestProblemException("Failed to create persistence provider.", error);
    }
    Map properties = new HashMap();
    // For DataSource testing.
    // properties.put("jakarta.persistence.nonJtaDataSource", "datasource");
    // For JSE testing.
    properties.put("hibernate.connection.driver_class", getSession().getLogin().getDriverClassName());
    properties.put("hibernate.connection.url", getSession().getLogin().getConnectionString());
    properties.put("hibernate.connection.username", getSession().getLogin().getUserName());
    properties.put("hibernate.connection.password", getSession().getLogin().getPassword());
    properties.put("hibernate.connection.pool_size", "10");
    /*/ For emulated connection testing.
        try {
            Class.forName(getSession().getLogin().getDriverClassName());
        } catch (Exception ignore) {}
        properties.put("hibernate.connection.driver_class", "org.eclipse.persistence.testing.tests.performance.emulateddb.EmulatedDriver");
        properties.put("hibernate.connection.url", "emulate:" + getSession().getLogin().getConnectionString());
        properties.put("hibernate.connection.username", getSession().getLogin().getUserName());
        properties.put("hibernate.connection.password", getSession().getLogin().getPassword());
        properties.put("hibernate.connection.pool_size", "10");*/
    properties.put("hibernate.jdbc.batch_size", "100");
    properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect");
    properties.put("hibernate.cache.provider_class", "org.hibernate.cache.EhCacheProvider");
    if (getSession().getSessionLog().getLevel() <= SessionLog.FINE) {
        properties.put("hibernate.show_sql", "true");
    }
    getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
}
Also used : HashMap(java.util.HashMap) PersistenceProvider(jakarta.persistence.spi.PersistenceProvider) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) Map(java.util.Map) HashMap(java.util.HashMap) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException)

Example 48 with TestProblemException

use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.

the class XDBTestModel method addForcedRequiredSystems.

@Override
public void addForcedRequiredSystems() {
    addForcedRequiredSystem(new XMLTypeEmployeeSystem());
    oldPlatform = getSession().getPlatform();
    if (!(oldPlatform instanceof OraclePlatform)) {
        throw new TestProblemException("This model is intended for Oracle databases through OCI");
    }
    this.getSession().getLogin().setPlatform(new Oracle12Platform());
    getDatabaseSession().logout();
    getDatabaseSession().login();
    try {
        super.addForcedRequiredSystems();
    } catch (Exception ex) {
        String message = ex.getMessage();
        if ((message != null) && (message.indexOf("invalid datatype") > 0)) {
            throw new TestProblemException("This model will only work on Oracle 9i and up");
        } else {
            throw new TestProblemException("Error occurred", ex);
        }
    }
}
Also used : TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) Oracle12Platform(org.eclipse.persistence.platform.database.oracle.Oracle12Platform) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) OraclePlatform(org.eclipse.persistence.platform.database.OraclePlatform)

Aggregations

TestProblemException (org.eclipse.persistence.testing.framework.TestProblemException)48 TestSetup (junit.extensions.TestSetup)18 TestSuite (junit.framework.TestSuite)18 PersistenceProvider (jakarta.persistence.spi.PersistenceProvider)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 SQLException (java.sql.SQLException)4 Vector (java.util.Vector)3 NamingException (javax.naming.NamingException)3 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)3 DatabaseAccessor (org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor)3 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)3 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)3 TestWarningException (org.eclipse.persistence.testing.framework.TestWarningException)3 RMISecurityManager (java.rmi.RMISecurityManager)2 RemoteException (java.rmi.RemoteException)2 Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 DatabaseException (org.eclipse.persistence.exceptions.DatabaseException)2 Expression (org.eclipse.persistence.expressions.Expression)2