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);
}
}
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;
}
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();
}
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);
}
}
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));
}
Aggregations