use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class ErrorOnInsertTest method test.
@Override
protected void test() {
if (getSession().isClientSession() || getSession().isDistributedSession()) {
throw new TestWarningException("Unable to trigger error in ClientSession or Remote UnitOfWork");
}
mary = new Employee();
mary.setFirstName("Mary");
mary.setLastName("Magdalene");
mary.setId(new BigDecimal(100002929));
mary.setPeriod(new EmploymentPeriod(new Date(3), new Date(3455)));
UnitOfWorkImpl uow = (UnitOfWorkImpl) getSession().acquireUnitOfWork();
DatabaseAccessor accessor = (DatabaseAccessor) uow.getParent().getAccessor();
uow.getParent().setAccessor(new DummyAccessor(accessor));
Employee maryClone = (Employee) uow.registerObject(mary);
UnitOfWorkChangeSet uowcs = (UnitOfWorkChangeSet) uow.getCurrentChanges();
try {
uow.commitAndResumeWithPreBuiltChangeSet(uowcs);
} catch (Exception ex) {
}
uow.revertAndResume();
uow.getParent().setAccessor(accessor);
try {
uow.commitAndResumeWithPreBuiltChangeSet(uowcs);
} catch (QueryException ex) {
if (ex.getErrorCode() == 6004) {
throw new TestErrorException("New Object was not inserted because cachekey was not removed");
} else {
throw ex;
}
}
uow.commit();
}
use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class NestedUnitOfWorkReadOnlyClassTest method setup.
@Override
public void setup() {
if (!isSequenceNumberEnabled()) {
throw new TestWarningException("This test uses sequence numbers.");
}
getAbstractSession().beginTransaction();
postalCode = "AB7J98";
UnitOfWork uow = getSession().acquireUnitOfWork();
Address address = (Address) uow.registerObject(new Address());
uow.assignSequenceNumber(address);
address.setPostalCode(postalCode);
address.setCity("Toronto");
address.setCountry("CANADA");
uow.commit();
getAbstractSession().commitTransaction();
originalAddress = address;
}
use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class ShouldPrepareTest method setup.
@Override
public void setup() {
if (getSession().getPlatform().isDB2()) {
throw new TestWarningException("This test is not supposed to work with DB2. " + org.eclipse.persistence.internal.helper.Helper.cr() + "\t\tBecause as expected, sql string contains (t0.F_NAME = NULL) when the query is executed the second time with argument null, and '=NULL' is illegal syntax on DB2." + org.eclipse.persistence.internal.helper.Helper.cr() + "\t\tHence, executing the query would result in runtime exception.");
}
query = (ReadObjectQuery) getSession().getDescriptor(org.eclipse.persistence.testing.models.employee.domain.Employee.class).getQueryManager().getQuery("shouldPrepareQuery");
queryCopy = (ReadObjectQuery) query.clone();
ExpressionBuilder ex = new ExpressionBuilder();
queryCopy.setSelectionCriteria(ex.get("firstName").equal(ex.getParameter("firstName1")));
queryCopy.addArgument("firstName1");
vec = new Vector();
vec.add("Bob");
getSession().executeQuery(queryCopy, vec);
}
use of org.eclipse.persistence.testing.framework.TestWarningException in project eclipselink by eclipse-ee4j.
the class UnwrapConnectionCustomSQLTestModel method setup.
@Override
public void setup() {
if (!getSession().getPlatform().isOracle()) {
throw new TestWarningException("WARNING: This model is not supposed to be run on databases other than Oracle.");
}
DatabaseSession session = (DatabaseSession) getSession();
session.logout();
// save the connector to restore later
originalConnector = session.getLogin().getConnector();
DataSource dataSource = new TestOracleDataSource(session.getLogin().getDriverClassName(), session.getLogin().getConnectionString(), (Properties) session.getLogin().getProperties().clone());
session.getLogin().setConnector(new JNDIConnector(dataSource));
originalServerPlatform = session.getServerPlatform();
session.setServerPlatform(new TestServerPlatform(session));
originalShouldUseExternalConnectionPooling = session.getLogin().shouldUseExternalConnectionPooling();
session.getLogin().useExternalConnectionPooling();
session.login();
super.setup();
}
Aggregations