mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
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:
committed by
Rob Bygrave
parent
f3e4696498
commit
8d334ff2e8
@@ -4,8 +4,11 @@ import io.ebean.AcquireLockException;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.Platform;
|
||||
import io.ebean.Query;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
@@ -17,37 +20,38 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestQueryForUpdate extends BaseTestCase {
|
||||
|
||||
private boolean isSupportLocking() {
|
||||
return isH2() || isOracle() || isPostgres() || isSqlServer() || isMySql();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@ForPlatform({
|
||||
Platform.H2, Platform.ORACLE, Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL
|
||||
})
|
||||
public void testForUpdate() {
|
||||
|
||||
if (isSupportLocking()) {
|
||||
ResetBasicData.reset();
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.forUpdate()
|
||||
.setMaxRows(1)
|
||||
.order().desc("id");
|
||||
|
||||
query.findList();
|
||||
if (isSqlServer()) {
|
||||
assertThat(sqlOf(query)).contains("with (updlock)");
|
||||
} else {
|
||||
assertThat(sqlOf(query)).contains("for update");
|
||||
}
|
||||
if (isSqlServer()) {
|
||||
assertThat(sqlOf(query)).contains("with (updlock)");
|
||||
} else {
|
||||
assertThat(sqlOf(query)).contains("for update");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform({
|
||||
Platform.H2, Platform.ORACLE, Platform.POSTGRES, Platform.SQLSERVER
|
||||
})
|
||||
public void testForUpdate_noWait() {
|
||||
|
||||
if (isSupportLocking()) {
|
||||
ResetBasicData.reset();
|
||||
ResetBasicData.reset();
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
Ebean.beginTransaction();
|
||||
try {
|
||||
@@ -83,9 +87,8 @@ public class TestQueryForUpdate extends BaseTestCase {
|
||||
txn2.end();
|
||||
}
|
||||
|
||||
} finally {
|
||||
Ebean.endTransaction();
|
||||
}
|
||||
} finally {
|
||||
Ebean.endTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user