Search in sources :

Example 41 with TestProblemException

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

the class RegisterNewObjectInIdentityMapNoSeqTest method setup.

@Override
public void setup() {
    zeroFailed = false;
    negativeFailed = false;
    zeroOverridden = false;
    negativeOverridden = false;
    getAbstractSession().beginTransaction();
    ClassDescriptor descriptor = getSession().getClassDescriptor(Weather.class);
    idValidationOriginal = descriptor.getIdValidation();
    descriptor.setIdValidation(idValidation);
    if (keepSequencing) {
        if (descriptor.getSequence() == null) {
            // ReturningPolicyTestModel substitutes sequences for returning
            throw new TestWarningException("Cannot run test with descriptor.getSequence() == null");
        }
        if (!shouldAlwaysOverrideExistingValue) {
            if (descriptor.getSequence().shouldAcquireValueAfterInsert()) {
                throw new TestProblemException("Cannot run test with keepSequencing==true and alwayOverrideExistingValueOriginal==false with Identity sequence: it should always override");
            }
        }
        shouldAlwaysOverrideExistingValueOriginal = descriptor.getSequence().shouldAlwaysOverrideExistingValue();
        descriptor.getSequence().setShouldAlwaysOverrideExistingValue(shouldAlwaysOverrideExistingValue);
    } else {
        sequenceNumberField = descriptor.getSequenceNumberField();
        descriptor.setSequenceNumberField(null);
        sequenceNumberName = descriptor.getSequenceNumberName();
        descriptor.setSequenceNumberName(null);
    }
}
Also used : ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException)

Example 42 with TestProblemException

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

the class SessionHelper method createServerSession.

/**
 * Creates {@link DatabaseSession} from project and connect it to database.
 * {@link DatabaseSession#logout()} must be called before session instance is disposed.
 */
public static Server createServerSession(final Project project) {
    Server session = project.createServerSession();
    session.setSessionLog(LOG);
    try {
        session.login();
    } catch (Exception ex) {
        throw new TestProblemException("Database needs to be setup for AQ, with the user " + NoSQLProperties.getDBUserName(), ex);
    }
    return session;
}
Also used : Server(org.eclipse.persistence.sessions.server.Server) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) DatabaseException(org.eclipse.persistence.exceptions.DatabaseException)

Example 43 with TestProblemException

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

the class LOBUpdateTest method setup.

@Override
protected void setup() {
    // Create originalObject and insert it into db - it will be deleted in reset()
    try {
        originalObject = ((Image) originalObjectNotInDB).clone();
    } catch (CloneNotSupportedException ex) {
        throw new TestProblemException("clone failed", ex);
    }
    UnitOfWork uow = getSession().acquireUnitOfWork();
    uow.registerObject(originalObject);
    uow.commit();
    super.setup();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException)

Example 44 with TestProblemException

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

the class SessionExchanger method createDataSource.

// create a data source using the supplied connection string
void createDataSource(String connectionString, int minConnections, int maxConnections) {
    try {
        dataSource = PoolDataSourceFactory.getPoolDataSource();
        dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
        Properties props = new Properties();
        if (minConnections >= 0) {
            dataSource.setMinPoolSize(minConnections);
            dataSource.setInitialPoolSize(minConnections);
        }
        if (maxConnections >= 0) {
            dataSource.setMaxPoolSize(maxConnections);
        }
        dataSource.setURL(connectionString);
    } catch (SQLException ex) {
        throw new TestProblemException("Failed to create OracleDataSource with " + connectionString + ".\n", ex);
    }
}
Also used : SQLException(java.sql.SQLException) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) Properties(java.util.Properties)

Example 45 with TestProblemException

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

the class HibernateJPA2PerformanceRegressionModel 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("performance2", 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)

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