use of com.sun.ts.lib.harness.EETest.Fault in project tests by datanucleus.
the class Client method postLoadTest.
/*
* @testName: postLoadTest
* @assertion_ids: PERSISTENCE:SPEC:695; PERSISTENCE:SPEC:719;
* PERSISTENCE:SPEC:720
* @test_Strategy:
*/
public void postLoadTest() throws Fault {
boolean status = false;
String reason = null;
String id = postLoadTest;
try {
getEntityTransaction().begin();
product = newProduct(id);
getEntityManager().persist(product);
getEntityManager().flush();
getEntityManager().refresh(product);
Query q = getEntityManager().createQuery("select distinct p from Product p");
java.util.List results = q.getResultList();
// for(int i = 0, n = results.size(); i < n; i++) {
//
// }
TLogger.log(results.toString());
if (product.isPostLoadCalled()) {
reason = "Product: postLoad was called after the query result was returned.";
TLogger.log(reason);
} else {
reason = "Product: postLoad was not called even after the query result was returned.";
throw new Fault(reason);
}
getEntityTransaction().commit();
} catch (Exception e) {
TLogger.log("Exception caught during postLoadTest", e);
throw new Fault(e);
} finally {
try {
if (getEntityTransaction().isActive()) {
getEntityTransaction().rollback();
}
} catch (Exception re) {
TLogger.log("Exception caught while rolling back TX", re);
}
}
}
use of com.sun.ts.lib.harness.EETest.Fault in project tests by datanucleus.
the class Client method prePersistRuntimeExceptionTest.
/*
* @testName: prePersistRuntimeExceptionTest
* @assertion_ids: PERSISTENCE:SPEC:695; PERSISTENCE:SPEC:704
* @test_Strategy:
*/
public void prePersistRuntimeExceptionTest() throws Fault {
String id = prePersistRuntimeExceptionTest;
try {
getEntityTransaction().begin();
product = newProduct(id);
txShouldRollback(product, id);
} catch (Exception e) {
TLogger.log("Exception caught during prePersistRuntimeExceptionTest", e);
throw new Fault(e);
} finally {
try {
if (getEntityTransaction().isActive()) {
getEntityTransaction().rollback();
}
} catch (Exception re) {
TLogger.log("Exception caught while rolling back TX", re);
}
}
}
use of com.sun.ts.lib.harness.EETest.Fault in project tests by datanucleus.
the class Client method preRemoveCascadeTest.
/*
* @testName: preRemoveCascadeTest
* @assertion_ids: PERSISTENCE:SPEC:695; PERSISTENCE:SPEC:708
* @test_Strategy:
*/
public void preRemoveCascadeTest() throws Fault {
boolean status = false;
String reason = null;
String id = preRemoveCascadeTest;
try {
getEntityTransaction().begin();
order = newOrder(id);
product = newProduct(id);
lineItem = newLineItem(id);
lineItem.setOrder(order);
lineItem.setProduct(product);
order.addLineItem(lineItem);
getEntityManager().persist(product);
getEntityManager().persist(order);
getEntityManager().remove(order);
boolean b = order.isPreRemoveCalled();
order = null;
if (b) {
reason = "Order: preRemove was called.";
TLogger.log(reason);
} else {
reason = "Order: preRemove was not called.";
throw new Fault(reason);
}
if (lineItem.isPrePersistCalled()) {
reason = "LineItem: preRemove was called.";
TLogger.log(reason);
} else {
reason = "LineItem: preRemove was not called.";
throw new Fault(reason);
}
getEntityTransaction().commit();
} catch (Exception e) {
TLogger.log("Exception caught during preRemoveCascadeTest", e);
throw new Fault(e);
} finally {
try {
if (getEntityTransaction().isActive()) {
getEntityTransaction().rollback();
}
} catch (Exception re) {
TLogger.log("Exception caught while rolling back TX", re);
}
}
}
use of com.sun.ts.lib.harness.EETest.Fault in project tests by datanucleus.
the class Client method preRemoveMultiCascadeTest.
/*
* @testName: preRemoveMultiCascadeTest
* @assertion_ids: PERSISTENCE:SPEC:694; PERSISTENCE:SPEC:708;
* PERSISTENCE:SPEC:722; PERSISTENCE:SPEC:726;
* PERSISTENCE:SPEC:727
* @test_Strategy:
*/
public void preRemoveMultiCascadeTest() throws Fault {
boolean status = false;
String reason = null;
String id = preRemoveMultiCascadeTest;
try {
getEntityTransaction().begin();
order = newOrder(id);
product = newProduct(id);
lineItem = newLineItem(id);
lineItem.setOrder(order);
lineItem.setProduct(product);
order.addLineItem(lineItem);
getEntityManager().persist(product);
getEntityManager().persist(order);
getEntityManager().remove(order);
boolean b = order.isPreRemoveCalled();
List actual = order.getPreRemoveCalls();
Helper.compareResultList(LISTENER_ABC, actual);
actual = lineItem.getPreRemoveCalls();
Helper.compareResultList(LISTENER_BC, actual);
order = null;
getEntityTransaction().commit();
} catch (Exception e) {
TLogger.log("Exception caught during preRemoveMultiCascadeTest", e);
throw new Fault(e);
} finally {
try {
if (getEntityTransaction().isActive()) {
getEntityTransaction().rollback();
}
} catch (Exception re) {
TLogger.log("Exception caught while rolling back TX", re);
}
}
}
use of com.sun.ts.lib.harness.EETest.Fault in project tests by datanucleus.
the class Client method prePersistMultiCascadeTest.
/*
* @testName: prePersistMultiCascadeTest
* @assertion_ids: PERSISTENCE:SPEC:694; PERSISTENCE:SPEC:697;
* PERSISTENCE:SPEC:708; PERSISTENCE:JAVADOC:34;
* PERSISTENCE:SPEC:723; PERSISTENCE:SPEC:724;
* @test_Strategy:
*/
public void prePersistMultiCascadeTest() throws Fault {
boolean status = false;
String reason = null;
String id = prePersistMultiCascadeTest;
try {
getEntityTransaction().begin();
order = newOrder(id);
product = newProduct(id);
lineItem = newLineItem(id);
lineItem.setOrder(order);
lineItem.setProduct(product);
order.addLineItem(lineItem);
getEntityManager().persist(product);
getEntityManager().persist(order);
List actual = order.getPrePersistCalls();
Helper.compareResultList(LISTENER_ABC, actual);
actual = lineItem.getPrePersistCalls();
Helper.compareResultList(LISTENER_BC, actual);
getEntityTransaction().commit();
} catch (Exception e) {
throw new Fault(e);
} finally {
try {
if (getEntityTransaction().isActive()) {
getEntityTransaction().rollback();
}
} catch (Exception re) {
TLogger.log("Exception caught while rolling back TX", re);
}
}
}
Aggregations