use of org.eclipse.persistence.testing.framework.TestWarningException 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.TestWarningException in project eclipselink by eclipse-ee4j.
the class ProxyAuthenticationConnectionCustomizerTestCase method setup.
@Override
public void setup() {
if (!getSession().getPlatform().isOracle()) {
throw new TestWarningException("Supports Oracle platform only");
}
Properties loginProperties = ProxyAuthenticationUsersAndProperties.connectionProperties;
// In case of ServerSession with internal connection pools each pool will use just one connection.
getExecutor().setSession(exchanger.createNewSession((DatabaseSession) getSession(), shouldUseDatabaseSession, shouldUseExternalConnectionPooling, loginProperties, mainSessionProxyProperties, 1, 1, 1, 1));
getSession().getEventManager().addListener(listener);
if (!shouldUseDatabaseSession) {
if (shoulUseExclusiveIsolatedSession) {
((ServerSession) getSession()).getDefaultConnectionPolicy().setExclusiveMode(ConnectionPolicy.ExclusiveMode.Always);
}
}
}
use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class CommitAfterExecuteModifyQueryDuringTransTest method setup.
/**
* Test makes modifications that is not wrapped in a transaction..
*/
@Override
public void setup() {
if (getSession() instanceof RemoteSession) {
throw new TestWarningException("test will not run on RemoteSession - it uses events");
}
// employee to be modified - needed for reset.
cachedEmployee = (Employee) getSession().readObject(Employee.class);
ClassDescriptor descriptor = getSession().getDescriptor(this.cachedEmployee);
if (descriptor.isProtectedIsolation() && descriptor.shouldIsolateProtectedObjectsInUnitOfWork() && getSession() instanceof IsolatedClientSession) {
// this will have read a version of the protected Entity into the Isolated Cache even though the test wants to isolated to UOW
// replace with actual shared cache version
this.cachedEmployee = (Employee) ((AbstractSession) getSession()).getParentIdentityMapSession(descriptor, false, true).getIdentityMapAccessor().getFromIdentityMap(this.cachedEmployee);
}
originalEmployee = (Employee) getSession().copy(cachedEmployee);
employeesNewFirstName = "formerlyKnownAs";
initialVersionField = getSession().getIdentityMapAccessor().getWriteLockValue(cachedEmployee);
// query to be executed more than once
dataModifyQuery = new DataModifyQuery("UPDATE EMPLOYEE SET F_NAME = #F_NAME, VERSION = #VERSION WHERE L_NAME = #L_NAME");
dataModifyQuery.addArgument("F_NAME");
dataModifyQuery.addArgument("VERSION");
dataModifyQuery.addArgument("L_NAME");
}
use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class ConcurrentReadOnUpdateWithEarlyTransTest method setup.
@Override
public void setup() {
// remote is for a single client, so this test is not relevant.
if (getSession().isDistributedSession()) {
throw new TestWarningException("Test unavailable on Remote UnitOfWork.");
}
readAddress = new ConcurrentAddress();
readAddress.setId(new BigDecimal(8));
readAddress.setCity("Toronto");
readAddress.setPostalCode("L5J2B5");
readAddress.setProvince("ONT");
readAddress.setStreet("1450 Acme Cr., suite 4");
readAddress.setCountry("Canada");
UnitOfWork uow = getSession().acquireUnitOfWork();
uow.registerObject(readAddress);
uow.commit();
ConcurrentAddress.RUNNING_TEST = ConcurrentAddress.READ_ON_UPDATE_EARLY_TRANS;
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
}
use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class PessimisticLockTest method test.
@Override
public void test() throws Exception {
checkSelectForUpateSupported();
// HANA supports SELECT FOR UPDATE but not with queries that select from multiple tables
if (getSession().getPlatform().isHANA()) {
throw new TestWarningException("This database does not support FOR UPDATE on multiple tables");
}
// Object locking is done using ObjectBuildingQuery.LOCK_NOWAIT
checkNoWaitSupported();
uow = getSession().acquireUnitOfWork();
this.employeeObject = (Employee) uow.registerObject(employeeObject);
city = employeeObject.getAddress().getCity();
employeeObject.getAddress().setCity("Chelmsford");
startTime = employeeObject.getStartTime();
employeeObject.setStartTime(null);
endDate = employeeObject.getPeriod().getEndDate();
employeeObject.getPeriod().setEndDate(null);
managerName = employeeObject.getManager().getFirstName();
employeeObject.getManager().setFirstName("Karl");
collectionSize = employeeObject.getPhoneNumbers().size();
employeeObject.getPhoneNumbers().removeAllElements();
responsibilityListSize = employeeObject.getResponsibilitiesList().size();
employeeObject.getResponsibilitiesList().removeAllElements();
uow.refreshAndLockObject(employeeObject, (short) this.lockMode);
// Test the lock.
DatabaseSession session2 = null;
UnitOfWork uow2 = null;
try {
if (getSession() instanceof org.eclipse.persistence.sessions.remote.RemoteSession) {
session2 = org.eclipse.persistence.testing.tests.remote.RemoteModel.getServerSession().getProject().createDatabaseSession();
} else {
session2 = getSession().getProject().createDatabaseSession();
}
session2.setSessionLog(getSession().getSessionLog());
session2.login();
uow2 = session2.acquireUnitOfWork();
boolean isLocked = false;
Object result = null;
try {
result = uow2.refreshAndLockObject(employeeObject, org.eclipse.persistence.queries.ObjectBuildingQuery.LOCK_NOWAIT);
} catch (EclipseLinkException exeception) {
session2.logMessage(exeception.toString());
isLocked = true;
}
if (result == null) {
isLocked = true;
}
if (!isLocked) {
throw new TestWarningException("Select for update does not acquire a lock");
}
} finally {
if (uow2 != null) {
uow2.release();
}
if (session2 != null) {
session2.logout();
}
}
}
Aggregations