mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix for #159 - Refactor - cleanup clode when closing query only transaction + change default option
This commit is contained in:
@@ -39,4 +39,34 @@ public class TestQueryFindVisit extends BaseTestCase {
|
||||
|
||||
Assert.assertEquals(2, counter.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the behaviour when an exception is thrown inside the findVisit().
|
||||
*/
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void testVisitThrowingException() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
Query<Customer> query = server.find(Customer.class).setAutofetch(false)
|
||||
.fetch("contacts", new FetchConfig().query(2)).where().gt("id", 0).orderBy("id")
|
||||
.setMaxRows(2);
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger(0);
|
||||
|
||||
query.findVisit(new QueryResultVisitor<Customer>() {
|
||||
|
||||
public boolean accept(Customer bean) {
|
||||
counter.incrementAndGet();
|
||||
if (counter.intValue() > 0) {
|
||||
throw new IllegalStateException("cause a failure");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertFalse("Never get here - exception thrown", true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user