mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Test usingDatabase with a non default db
Move the test to separate class with better name.
This commit is contained in:
@@ -19,21 +19,6 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestQueryUsingConnection extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void usingDatabase() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
final Database database = DB.getDefault();
|
||||
|
||||
int count =
|
||||
DB.find(Country.class)
|
||||
.usingDatabase(database)
|
||||
.findCount();
|
||||
|
||||
assertThat(count).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usingConnection() throws SQLException {
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.tests.basic;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.ESimple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestQueryUsingDatabase {
|
||||
|
||||
private static final String SOME_OTHER_DB_NAME = "someotherdb";
|
||||
public static final ESimple RECORD1 = new ESimple();
|
||||
public static final ESimple RECORD2 = new ESimple();
|
||||
|
||||
@Before
|
||||
public void setupNonDefaultDatabase() {
|
||||
DB.byName(SOME_OTHER_DB_NAME).insert(RECORD1);
|
||||
DB.byName(SOME_OTHER_DB_NAME).insert(RECORD2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usingNonDefaultDatabase() {
|
||||
final Database nonDefaultDb = DB.byName(SOME_OTHER_DB_NAME);
|
||||
|
||||
List<ESimple> orderList = DB.find(ESimple.class)
|
||||
.usingDatabase(nonDefaultDb)
|
||||
.findList();
|
||||
|
||||
assertThat(orderList).size().isEqualTo(2);
|
||||
assertThat(orderList).containsExactlyInAnyOrder(RECORD1, RECORD2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user