use of org.qi4j.library.uowfile.internal.ConcurrentUoWFileModificationException in project qi4j-sdk by Qi4j.
the class HasUoWFilesTest method testConcurrentModification.
@Test
public void testConcurrentModification() throws IOException, UnitOfWorkCompletionException {
LOGGER.info("# Test Concurrent Modification ###############################################################");
final String entityId;
// Create new
try (UnitOfWork uow = module.newUnitOfWork()) {
TestedEntity entity = createTestedOneEntityTwoFilesEntity(uow, "Testing Concurrent Modification");
entityId = entity.identity().get();
uow.complete();
}
// Testing concurrent modification
UnitOfWork uow, uow2;
TestedEntity entity;
uow = module.newUnitOfWork();
entity = uow.get(TestedEntity.class, entityId);
Inputs.text(MODIFICATION_CONTENT_URL).transferTo(Outputs.text(entity.managedFile(MyEnum.fileOne)));
uow2 = module.newUnitOfWork();
entity = uow2.get(TestedEntity.class, entityId);
Inputs.text(MODIFICATION_CONTENT_URL).transferTo(Outputs.text(entity.managedFile(MyEnum.fileOne)));
uow.complete();
try {
uow2.complete();
fail("A ConcurrentUoWFileModificationException should have been raised");
} catch (ConcurrentUoWFileModificationException expected) {
uow2.discard();
}
}
use of org.qi4j.library.uowfile.internal.ConcurrentUoWFileModificationException in project qi4j-sdk by Qi4j.
the class HasUoWFileTest method testConcurrentModification.
@Test
public void testConcurrentModification() throws IOException, UnitOfWorkCompletionException {
LOGGER.info("# Test Concurrent Modification ###############################################################");
final String entityId;
// Create new
try (UnitOfWork uow = module.newUnitOfWork()) {
TestedEntity entity = createTestedEntity(uow, "Testing Concurrent Modification");
entityId = entity.identity().get();
uow.complete();
}
// Testing concurrent modification
UnitOfWork uow, uow2;
TestedEntity entity;
uow = module.newUnitOfWork();
entity = uow.get(TestedEntity.class, entityId);
Inputs.text(MODIFICATION_CONTENT_URL).transferTo(Outputs.text(entity.managedFile()));
uow2 = module.newUnitOfWork();
entity = uow2.get(TestedEntity.class, entityId);
Inputs.text(MODIFICATION_CONTENT_URL).transferTo(Outputs.text(entity.managedFile()));
uow.complete();
try {
uow2.complete();
fail("A ConcurrentUoWFileModificationException should have been raised");
} catch (ConcurrentUoWFileModificationException expected) {
uow2.discard();
}
}
Aggregations