public void testNestedECs() {
try {
EOEditingContext ec = ERXEC.newEditingContext();
Company c = (Company) EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME);
c.setName("Name");
ec.saveChanges();
EOEditingContext nested = ERXEC.newEditingContext(ec);
Company nestC = c.localInstanceIn(nested);
Employee e = (Employee) EOUtilities.createAndInsertInstance(nested, Employee.ENTITY_NAME);
e.setFirstName("First");
e.setLastName("Last");
e.setManager(Boolean.FALSE);
e.addObjectToBothSidesOfRelationshipWithKey(nestC, Employee.COMPANY_KEY);
nested.saveChanges();
ec.saveChanges();
System.gc();
c.delete();
ec.saveChanges();
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}