use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class TestReadAggregateEntityU1MMapMapping method verify.
@Override
public void verify() {
if (holders == null || holders.size() != 1) {
throw new TestErrorException("Incorrect number of MapHolders was read.");
}
AggregateEntityU1MMapHolder holder = (AggregateEntityU1MMapHolder) holders.get(0);
if (!((IndirectMap) holder.getAggregateToEntityMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
throw new TestErrorException("Relationship was not properly joined.");
}
if (holder.getAggregateToEntityMap().size() != 2) {
throw new TestErrorException("Incorrect Number of MapEntityValues was read.");
}
AggregateMapKey mapKey = new AggregateMapKey();
mapKey.setKey(11);
EntityMapValue value = (EntityMapValue) holder.getAggregateToEntityMap().get(mapKey);
if (value.getId() != 1) {
throw new TestErrorException("Incorrect MapEntityValues was read.");
}
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class TestReadAggregateEntityU1MMapMapping method reset.
@Override
public void reset() {
UnitOfWork uow = getSession().acquireUnitOfWork();
Iterator i = holders.iterator();
while (i.hasNext()) {
AggregateEntityU1MMapHolder holder = (AggregateEntityU1MMapHolder) i.next();
Iterator j = holder.getAggregateToEntityMap().keySet().iterator();
while (j.hasNext()) {
uow.deleteObject(holder.getAggregateToEntityMap().get(j.next()));
}
}
uow.deleteAllObjects(holders);
uow.commit();
if (!verifyDelete(holders.get(0))) {
throw new TestErrorException("Delete was unsuccessful.");
}
mapping.setJoinFetch(oldFetchJoinValue);
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class TestReadDirectDirectMapMapping method verify.
@Override
public void verify() {
if (holders == null || holders.size() != 1) {
throw new TestErrorException("Incorrect number of MapHolders was read.");
}
DirectDirectMapHolder holder = (DirectDirectMapHolder) holders.get(0);
if (!((IndirectMap) holder.getDirectToDirectMap()).getValueHolder().isInstantiated() && fetchJoinRelationship > 0) {
throw new TestErrorException("Relationship was not properly joined.");
}
if (holder.getDirectToDirectMap().size() != 2) {
throw new TestErrorException("Incorrect Number of Map values was read.");
}
Integer value = (Integer) holder.getDirectToDirectMap().get(1);
if (value != 1) {
throw new TestErrorException("Incorrect map value was read.");
}
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class TestReadDirectDirectMapMapping method reset.
@Override
public void reset() {
UnitOfWork uow = getSession().acquireUnitOfWork();
uow.deleteAllObjects(holders);
uow.commit();
if (!verifyDelete(holders.get(0))) {
throw new TestErrorException("Delete was unsuccessful.");
}
mapping.setJoinFetch(oldFetchJoinValue);
}
use of org.eclipse.persistence.testing.framework.TestErrorException in project eclipselink by eclipse-ee4j.
the class DeepMergeCloneIndirectionTest method test.
/**
* This test creates an object and registers it with a unit of work. It then serializes that
* object and deserializes it. Adds an object onto the origional then performs serialization
* sequence again. Then deepMergeClone is attempted and the results are compared to verify that
* the merge worked.
*/
@Override
public void test() {
try {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream stream = new ObjectOutputStream(byteStream);
// create the phoneNumber object
Order orderClone;
Session session = getSession();
org.eclipse.persistence.sessions.UnitOfWork uow = session.acquireUnitOfWork();
this.orderObject = (Order) session.readObject(Order.class);
// force instantiations of value holders before serialization
((Collection) this.orderObject.getLineContainer()).size();
// serialize object by writing to a stream
stream.writeObject(this.orderObject);
stream.flush();
byte[] arr = byteStream.toByteArray();
ByteArrayInputStream inByteStream = new ByteArrayInputStream(arr);
ObjectInputStream inObjStream = new ObjectInputStream(inByteStream);
Order deserialOrder;
// deserialize the object
try {
deserialOrder = (Order) inObjStream.readObject();
} catch (ClassNotFoundException e) {
throw new TestErrorException("Could not deserialize object " + e.toString());
}
// add a new manager, test 1-m's
OrderLine newLine = new OrderLine();
((Collection) deserialOrder.getLineContainer()).clear();
deserialOrder.addLine(newLine);
newLine.order = deserialOrder;
orderClone = (Order) uow.registerObject(this.orderObject);
orderClone = (Order) uow.deepMergeClone(deserialOrder);
uow.commit();
} catch (IOException e) {
throw new TestErrorException("Error running Test " + e.toString());
} catch (NullPointerException exception) {
throw new TestErrorException("Test Failed. Backup clone indirection was not triggered in mergeIntoObject.");
}
}
Aggregations