mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
FIX: possible resource leaking in testcases (all created transactions are closed by followed try statement) (#1273)
This commit is contained in:
committed by
Rob Bygrave
parent
8e9843ab8a
commit
e3425a8850
@@ -3,6 +3,7 @@ package org.tests.delete;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Transaction;
|
||||
import org.tests.model.basic.Product;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Assert;
|
||||
@@ -26,21 +27,21 @@ public class TestDeleteByIdWithPersistenceContext extends BaseTestCase {
|
||||
Product prod2 = createProduct(101, "bananas");
|
||||
server.insert(prod2);
|
||||
|
||||
server.beginTransaction();
|
||||
// effectively load these into the persistence context
|
||||
server.find(Product.class, prod1.getId());
|
||||
server.find(Product.class, prod2.getId());
|
||||
try (Transaction txn = server.beginTransaction()) {
|
||||
// effectively load these into the persistence context
|
||||
server.find(Product.class, prod1.getId());
|
||||
server.find(Product.class, prod2.getId());
|
||||
|
||||
server.deleteAll(Product.class, Arrays.asList(prod1.getId(), prod2.getId()));
|
||||
server.deleteAll(Product.class, Arrays.asList(prod1.getId(), prod2.getId()));
|
||||
|
||||
// are these found in the persistence context?
|
||||
Product shadow1 = server.find(Product.class, prod1.getId());
|
||||
Product shadow2 = server.find(Product.class, prod2.getId());
|
||||
// are these found in the persistence context?
|
||||
Product shadow1 = server.find(Product.class, prod1.getId());
|
||||
Product shadow2 = server.find(Product.class, prod2.getId());
|
||||
|
||||
Assert.assertNull(shadow1);
|
||||
Assert.assertNull(shadow2);
|
||||
Assert.assertNull(shadow1);
|
||||
Assert.assertNull(shadow2);
|
||||
|
||||
server.endTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user