use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class EMCascadingModifyAndMergeTest method test.
@Override
public void test() {
employee.setFirstName("Ivy");
PhoneNumber phone = employee.getPhoneNumbers().iterator().next();
phone.setAreaCode("519");
phone.setNumber("9876543");
try {
CMP3TestModel.createEntityManager();
beginTransaction();
Employee emp = getEntityManager().find(Employee.class, empIDs[0]);
emp.setFirstName("Tobin");
PhoneNumber phon = emp.getPhoneNumbers().iterator().next();
phon.setAreaCode("416");
phon.setNumber("7654321");
// emp.addPhoneNumber(ModelExamples.phoneExample7());
getEntityManager().merge(employee);
commitTransaction();
} catch (Exception ex) {
rollbackTransaction();
ex.printStackTrace();
throw new TestErrorException("Exception thrown durring persist and flush" + ex);
}
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class EMCascadingPersistAndCommitTest method test.
@Override
public void test() {
Employee employee = new Employee();
employee.setFirstName("First");
employee.setLastName("Bean");
Project project = new Project();
project.setName("Project # 1");
project.setDescription("A simple Project");
PhoneNumber phone = new PhoneNumber("Work", "613", "9876543");
employee.addProject(project);
employee.addPhoneNumber(phone);
try {
beginTransaction();
getEntityManager().persist(employee);
empIDs[0] = employee.getId();
commitTransaction();
} catch (Exception ex) {
rollbackTransaction();
throw new TestErrorException("Exception thrown durring persist and flush" + ex);
}
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class EMCascadingRemoveAndFlushTest method test.
@Override
public void test() {
try {
beginTransaction();
Employee employee = getEntityManager().find(Employee.class, empIDs[0]);
for (Iterator<PhoneNumber> phones = employee.getPhoneNumbers().iterator(); phones.hasNext(); ) {
this.phoneIDs.add(phones.next().buildPK());
}
getEntityManager().remove(employee);
getEntityManager().flush();
// lets initialize the identity map to make sure they were persisted
((JpaEntityManager) getEntityManager()).getServerSession().getIdentityMapAccessor().initializeAllIdentityMaps();
getEntityManager().clear();
persistedItems.put("after flush Employee", getEntityManager().find(Employee.class, empIDs[0]));
for (Iterator<PhoneNumberPK> ids = this.phoneIDs.iterator(); ids.hasNext(); ) {
PhoneNumber phone = getEntityManager().find(PhoneNumber.class, ids.next());
if (phone != null) {
persistedItems.put("after flush PhoneNumber", phone);
}
}
commitTransaction();
} catch (Exception ex) {
rollbackTransaction();
ex.printStackTrace();
throw new TestErrorException("Exception thrown durring persist and flush" + ex);
}
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class EMRemoveAndFlushTest method setup.
@Override
public void setup() {
super.setup();
persistedItems.clear();
Employee employee = ModelExamples.employeeExample1();
Project project = ModelExamples.projectExample1();
try {
beginTransaction();
getEntityManager().persist(employee);
getEntityManager().persist(project);
commitTransaction();
} catch (Exception ex) {
rollbackTransaction();
ex.printStackTrace();
throw new TestErrorException("Exception thrown durring persist and flush" + ex);
}
empIDs[0] = employee.getId();
projIDs[0] = project.getId();
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class UCPUnitOfWorkTests method buildServerSession.
@Override
public Server buildServerSession() {
try {
PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();
// dataSource.setONSConfiguration("nodes=adcdbc01-r.us.oracle.com:6200");
dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
dataSource.setURL(getSession().getLogin().getConnectionString());
dataSource.setUser(getSession().getLogin().getUserName());
dataSource.setPassword(getSession().getLogin().getPassword());
dataSource.setInitialPoolSize(1);
dataSource.setMinPoolSize(1);
dataSource.setMaxPoolSize(10);
dataSource.setFastConnectionFailoverEnabled(true);
Project project = getSession().getProject().clone();
project.setLogin(project.getLogin().clone());
project.getLogin().setConnector(new JNDIConnector(dataSource));
project.getLogin().setUsesExternalConnectionPooling(true);
Server server = project.createServerSession();
server.setSessionLog(getSession().getSessionLog());
server.login();
return server;
} catch (SQLException error) {
throw new TestErrorException("UCP failed to initialize.", error);
}
}
Aggregations