Feature/contitional test runner (#1132)

* FIX: warnings (add generics, overrides, fix imports) - should be no effecive code change

* replaced deprecated methods by default methods

* FIX: more compiler warnings

* FIX more warnings - no code changes

* FIX: deprecated call to JsonParseException

* Remove unused code, check unused variables

* ADD: ContitonaltestRunner to skip tests for certain platforms

* Use annotations to control on which platforms a test shoud run

* FIX: compile errors
This commit is contained in:
Roland Praml
2017-09-15 21:03:03 +12:00
committed by Rob Bygrave
parent f3e4696498
commit 8d334ff2e8
17 changed files with 176 additions and 76 deletions
@@ -3,7 +3,9 @@ package org.tests.transaction;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.EbeanServer;
import io.ebean.Platform;
import io.ebean.Transaction;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Transactional;
import org.tests.model.m2m.MnyB;
import org.junit.Test;
@@ -19,8 +21,8 @@ public class TestCommitAndContinue extends BaseTestCase {
@Test
@Transactional
@IgnorePlatform({Platform.SQLSERVER, Platform.HSQLDB}) // they will dead lock
public void transactional_partialSuccess() {
if (isHSqlDb()) return; // HSQL will lock up here
MnyB a = new MnyB("a100");
MnyB b = new MnyB("b200");
@@ -45,10 +47,8 @@ public class TestCommitAndContinue extends BaseTestCase {
try (Transaction anotherTxn = server.createTransaction()) {
// success prior to commitAndContinue
assertNotNull(server.find(MnyB.class, a.getId(), anotherTxn));
if (!isSqlServer()) {
// insert failed after commitAndContinue - sqlserver dead locks here
assertNull(server.find(MnyB.class, b.getId(), anotherTxn));
}
// insert failed after commitAndContinue - sqlserver dead locks here
assertNull(server.find(MnyB.class, b.getId(), anotherTxn));
}
}
}
@@ -57,6 +57,7 @@ public class TestCommitAndContinue extends BaseTestCase {
* The @Transactional is nicer to me.
*/
@Test
@IgnorePlatform({Platform.SQLSERVER, Platform.HSQLDB}) // they will dead lock
public void tryFinally_partialSuccess() {
MnyB a = new MnyB("a100");
@@ -80,15 +81,13 @@ public class TestCommitAndContinue extends BaseTestCase {
txn.setRollbackOnly();
// use a different transaction to assert
if (!isSqlServer() && !isHSqlDb()) { // sqlServer & HSQL dead locks here...
try (Transaction anotherTxn = server.createTransaction()) {
// success prior to commitAndContinue
assertNotNull(server.find(MnyB.class, a.getId(), anotherTxn));
// insert failed after commitAndContinue
assertNull(server.find(MnyB.class, b.getId(), anotherTxn));
}
//anotherTxn.end();
try (Transaction anotherTxn = server.createTransaction()) {
// success prior to commitAndContinue
assertNotNull(server.find(MnyB.class, a.getId(), anotherTxn));
// insert failed after commitAndContinue
assertNull(server.find(MnyB.class, b.getId(), anotherTxn));
}
//anotherTxn.end();
}
// does not commit due to the txn.setRollbackOnly();
@@ -102,9 +101,8 @@ public class TestCommitAndContinue extends BaseTestCase {
@Test
@Transactional
@IgnorePlatform({Platform.SQLSERVER, Platform.HSQLDB}) // they will dead lock
public void transactional_partialSuccess_secondTransactionInsert() {
if (isHSqlDb()) return; // HSQL will lock up here
MnyB a = new MnyB("a100");
MnyB b = new MnyB("b200");
@@ -143,10 +141,9 @@ public class TestCommitAndContinue extends BaseTestCase {
// success prior to commitAndContinue
assertNotNull(server.find(MnyB.class, a.getId(), txnForAssert));
if (!isSqlServer()) {
// insert failed after commitAndContinue
assertNull(server.find(MnyB.class, b.getId(), txnForAssert));
}
// insert failed after commitAndContinue
assertNull(server.find(MnyB.class, b.getId(), txnForAssert));
// successful insert using txn2
assertNotNull(server.find(MnyB.class, c.getId(), txnForAssert));
}