use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class SessionHelper method createDatabaseSession.
/**
* Creates {@link DatabaseSession} from project and connect it to database.
* {@link DatabaseSession#logout()} must be called before session instance is disposed.
*/
public static DatabaseSession createDatabaseSession(final Project project) {
DatabaseSession session = project.createDatabaseSession();
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 OpenJPAPerformanceRegressionModel method setupProvider.
/**
* Setup the JPA provider.
*/
@Override
public void setupProvider() {
// Configure provider to be OpenJPA.
String providerClass = "org.apache.openjpa.persistence.PersistenceProviderImpl";
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();
// properties.put("jakarta.persistence.nonJtaDataSource", "datasource");
properties.put("openjpa.ConnectionDriverName", getSession().getLogin().getDriverClassName());
properties.put("openjpa.ConnectionURL", getSession().getLogin().getConnectionString());
properties.put("openjpa.ConnectionUserName", getSession().getLogin().getUserName());
properties.put("openjpa.ConnectionPassword", getSession().getLogin().getPassword());
if (getSession().shouldLogMessages()) {
properties.put("openjpa.Log", "DefaultLevel=WARN,SQL=TRACE");
}
getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class TopLinkJPAPerformanceRegressionModel method setupProvider.
/**
* Setup the JPA provider.
*/
@Override
public void setupProvider() {
// Configure provider to be TopLink.
String providerClass = "oracle.toplink.PersistenceProvider";
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();
properties.put("toplink.jdbc.driver", getSession().getLogin().getDriverClassName());
properties.put("toplink.jdbc.url", getSession().getLogin().getConnectionString());
properties.put("toplink.jdbc.user", getSession().getLogin().getUserName());
properties.put("toplink.jdbc.password", getSession().getLogin().getPassword());
properties.put("toplink.logging.level", getSession().getSessionLog().getLevelString());
getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class DbChangeNotificationInternalTestModel method setupUser.
protected void setupUser() {
if (!getSession().getPlatform().isOracle()) {
throw new TestWarningException("Supports Oracle platform only");
}
oldSession = getSession();
if (!oldSession.getLogin().getUserName().equalsIgnoreCase(aqUser)) {
// 1 - might need to install aq procesures?
// in sqlplus - @@<orahome>\ora92\rdbms\admin\catproc.sql
// - as SYSDBA
// 2 - create a AQ user <aquser> with password <aqpassword>
// grant connect, resource , aq_administrator_role to <aquser> identified by <aqpassword>
// grant execute on dbms_aq to <aquser>
// grant execute on dbms_aqadm to <aquser>
// grant execute on dbms_lock to <aquser>
DatabaseLogin login = (DatabaseLogin) oldSession.getLogin().clone();
login.setUserName(aqUser);
login.setPassword(aqPassword);
DatabaseSession session = new Project(login).createDatabaseSession();
session.setSessionLog(getSession().getSessionLog());
session.setLogLevel(getSession().getLogLevel());
try {
session.login();
} catch (Exception exception) {
throw new TestProblemException("Database needs to be setup for AQ, needs user " + OracleAqHelper.getAqUser());
}
getExecutor().setSession(session);
}
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class ProxyAuthenticationConnectionCustomizerTestCase method testServerSession.
void testServerSession() {
ServerSession ss = (ServerSession) getSession();
if (shouldEnableStatementCaching) {
ss.getPlatform().setShouldCacheAllStatements(true);
}
verifyUser("ServerSession first read", getReadUser(ss), expectedMainSessionUser);
// The first ClientSession created without proxy properties - should always use the same user as ServerSession.
ClientSession cs1 = ss.acquireClientSession();
if (shoulUseExclusiveIsolatedSession) {
// verify that IsolatedSession is used if required.
if (!(cs1 instanceof ExclusiveIsolatedClientSession)) {
throw new TestProblemException("The ClientSession must be ExclusiveIsolatedClientSession");
}
}
verifyUser("ClientSession1 before transaction read", getReadUser(cs1), expectedMainSessionUser);
cs1.beginTransaction();
verifyUser("ClientSession1in transaction read", getReadUser(cs1), expectedMainSessionUser);
verifyUser("ClientSession1 wrote", getWriteUser(cs1), expectedMainSessionUser);
cs1.rollbackTransaction();
verifyUser("ClientSession1 after transaction read", getReadUser(cs1), expectedMainSessionUser);
cs1.release();
// The second ClientSession created with proxy properties.
ClientSession cs2 = ss.acquireClientSession(clientSessionProxyProperties);
if (shoulUseExclusiveIsolatedSession) {
verifyUser("ExclusiveIsolatedClientSession2 before transaction read", getReadUser(cs2), expectedClientSessionUser);
} else {
verifyUser("ClientSession2 before transaction read", getReadUser(cs2), expectedMainSessionUser);
}
cs2.beginTransaction();
verifyUser("ClientSession2 in transaction read", getReadUser(cs2), expectedClientSessionUser);
verifyUser("ClientSession2 wrote", getWriteUser(cs2), expectedClientSessionUser);
cs2.rollbackTransaction();
if (shoulUseExclusiveIsolatedSession) {
verifyUser("ExclusiveIsolatedClientSession2 after transaction read", getReadUser(cs2), expectedClientSessionUser);
} else {
verifyUser("ClientSession2 after transaction read", getReadUser(cs2), expectedMainSessionUser);
}
cs2.release();
// verify that ServerSession still uses the correct user.
// Because there is one one connection in each connection pool (internal pool case) this would fail in case proxy customizer
// wasn't removed by cs2.
verifyUser("ServerSession second read", getReadUser(ss), expectedMainSessionUser);
// The third ClientSession created without proxy properties again - should always use the same user as ServerSession.
// Because there is one one connection in each connection pool (internal pool case) this would fail in case proxy customizer
// wasn't removed by cs2.
ClientSession cs3 = ss.acquireClientSession();
verifyUser("ClientSession3 before transaction read", getReadUser(cs3), expectedMainSessionUser);
cs3.beginTransaction();
verifyUser("ClientSession3 in transaction read", getReadUser(cs3), expectedMainSessionUser);
verifyUser("ClientSession3 wrote", getWriteUser(cs3), expectedMainSessionUser);
cs3.rollbackTransaction();
verifyUser("ClientSession3 after transaction read", getReadUser(cs3), expectedMainSessionUser);
cs3.release();
}
Aggregations