mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-25 15:18:59 +00:00
FIX: introduced TransactionalTestCase, so that changes to DB are not persisted (#1298)
* FIX: introduced TransactionalTestCase, so that changes to DB are not persisted * removed license header
This commit is contained in:
1 parent
9e2ddc9f8c
commit
11e180aa3f
22 files changed
+142
-89
No files matched your search
@@ -21,11 +21,11 @@ public class TestPersistContextClear extends BaseTestCase {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
ResetBasicData.createOrderCustAndOrder("testPc");
|
||||
Order order0 = null;
|
||||
|
||||
Transaction t = Ebean.beginTransaction();
|
||||
try {
|
||||
ResetBasicData.createOrderCustAndOrder("testPc");
|
||||
SpiTransaction spiTxn = (SpiTransaction) t;
|
||||
PersistenceContext pc = spiTxn.getPersistenceContext();
|
||||
|
||||
|
||||
@@ -34,15 +34,18 @@ public class TestTransactionTryResources extends BaseTestCase {
|
||||
|
||||
Document document = Document.find.asDraft(doc.getId());
|
||||
assertThat(document).isNotNull();
|
||||
|
||||
// cleanup
|
||||
Ebean.delete(document);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IgnorePlatform(Platform.ORACLE) // does not support uncommited reads
|
||||
public void tryWithResources_catch() {
|
||||
|
||||
Document doc = null;
|
||||
try (Transaction transaction = Ebean.beginTransaction()) {
|
||||
|
||||
Document doc = new Document();
|
||||
doc = new Document();
|
||||
doc.setTitle("tryWithResources_catch");
|
||||
doc.setBody("tryWithResources_catch_1");
|
||||
doc.save();
|
||||
@@ -69,6 +72,10 @@ public class TestTransactionTryResources extends BaseTestCase {
|
||||
.findList();
|
||||
|
||||
assertThat(docs).hasSize(1);
|
||||
assertThat(doc).isNotNull();
|
||||
// Cleanup
|
||||
Ebean.delete(Document.class, doc.getId());
|
||||
Ebean.delete(Document.class, doc3.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user