Search in sources :

Example 16 with TestWarningException

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);
    }
}
Also used : DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) Project(org.eclipse.persistence.sessions.Project) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) TestProblemException(org.eclipse.persistence.testing.framework.TestProblemException) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException)

Example 17 with TestWarningException

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);
        }
    }
}
Also used : DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) Properties(java.util.Properties) PersistenceUnitProperties(org.eclipse.persistence.config.PersistenceUnitProperties) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException)

Example 18 with TestWarningException

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");
}
Also used : IsolatedClientSession(org.eclipse.persistence.internal.sessions.IsolatedClientSession) ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) RemoteSession(org.eclipse.persistence.sessions.remote.RemoteSession) DataModifyQuery(org.eclipse.persistence.queries.DataModifyQuery) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession)

Example 19 with TestWarningException

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();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) BigDecimal(java.math.BigDecimal) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException)

Example 20 with TestWarningException

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();
        }
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException) TestWarningException(org.eclipse.persistence.testing.framework.TestWarningException)

Aggregations

TestWarningException (org.eclipse.persistence.testing.framework.TestWarningException)29 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)9 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)7 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)5 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)4 BigDecimal (java.math.BigDecimal)3 Vector (java.util.Vector)3 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)3 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)3 DataSource (javax.sql.DataSource)2 DatabasePlatform (org.eclipse.persistence.internal.databaseaccess.DatabasePlatform)2 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)2 ReportQuery (org.eclipse.persistence.queries.ReportQuery)2 ScrollableCursor (org.eclipse.persistence.queries.ScrollableCursor)2 DatabaseLogin (org.eclipse.persistence.sessions.DatabaseLogin)2 JNDIConnector (org.eclipse.persistence.sessions.JNDIConnector)2 TestProblemException (org.eclipse.persistence.testing.framework.TestProblemException)2 Address (org.eclipse.persistence.testing.models.employee.domain.Address)2 Order (org.eclipse.persistence.testing.models.transparentindirection.Order)2 Connection (java.sql.Connection)1