mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
Refactor move tests from ebean-core to ebean-test
This commit is contained in:
1 parent
0b00a14fd3
commit
eab56d323b
1650 files changed
+185
-147
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package org.tests.transaction;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.EBasicVer;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestSavepoint extends BaseTestCase {
|
||||
|
||||
@ForPlatform({Platform.POSTGRES, Platform.H2})
|
||||
@Test
|
||||
public void test() throws SQLException {
|
||||
|
||||
EBasicVer basicVer = new EBasicVer("save1");
|
||||
basicVer.setOther("other1");
|
||||
DB.save(basicVer);
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
|
||||
Connection connection = transaction.connection();
|
||||
Savepoint savepoint = connection.setSavepoint();
|
||||
|
||||
basicVer.setOther("changeOther");
|
||||
DB.save(basicVer);
|
||||
|
||||
connection.rollback(savepoint);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
EBasicVer found = DB.find(EBasicVer.class, basicVer.getId());
|
||||
assertThat(found.getOther()).isEqualTo("other1");
|
||||
|
||||
}
|
||||
|
||||
@ForPlatform({Platform.POSTGRES, Platform.H2})
|
||||
@Test
|
||||
public void rollbackOnly_expect_similarResult() {
|
||||
|
||||
EBasicVer basicVer = new EBasicVer("save2");
|
||||
basicVer.setOther("other2");
|
||||
DB.save(basicVer);
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setRollbackOnly();
|
||||
|
||||
basicVer.setOther("changeOther");
|
||||
DB.save(basicVer);
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
EBasicVer found = DB.find(EBasicVer.class, basicVer.getId());
|
||||
assertThat(found.getOther()).isEqualTo("other2");
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user