mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
ebean-test - Fix AutoConfigureForTesting to skip configuration for non-default DatabaseConfig (#2644)
#2644 - ebean-test - Fix AutoConfigureForTesting to skip configuration for non-default DatabaseConfig
This commit is contained in:
+7
-12
@@ -1,4 +1,4 @@
|
||||
package io.ebean.xtest.config;
|
||||
package io.ebean.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.ebean.annotation.MutationDetection;
|
||||
@@ -17,11 +17,10 @@ import java.util.Properties;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class DatabaseConfigTest {
|
||||
class DatabaseConfigTest {
|
||||
|
||||
@Test
|
||||
public void testLoadFromEbeanProperties() {
|
||||
|
||||
void testLoadFromEbeanProperties() {
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
config.loadFromProperties();
|
||||
|
||||
@@ -30,8 +29,7 @@ public class DatabaseConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evalPropertiesInput() {
|
||||
|
||||
void evalPropertiesInput() {
|
||||
String home = System.getProperty("user.home");
|
||||
String fileSeparator = System.getProperty("file.separator");
|
||||
|
||||
@@ -46,8 +44,7 @@ public class DatabaseConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadWithProperties() {
|
||||
|
||||
void testLoadWithProperties() {
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
config.setPersistBatch(PersistBatch.NONE);
|
||||
config.setPersistBatchOnCascade(PersistBatch.NONE);
|
||||
@@ -154,8 +151,7 @@ public class DatabaseConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_defaults() {
|
||||
|
||||
void test_defaults() {
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
assertTrue(config.isIdGeneratorAutomatic());
|
||||
assertTrue(config.isDefaultServer());
|
||||
@@ -186,8 +182,7 @@ public class DatabaseConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_putServiceObject() {
|
||||
|
||||
void test_putServiceObject() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
@@ -29,16 +29,17 @@ public class AutoConfigureForTesting implements AutoConfigure {
|
||||
|
||||
@Override
|
||||
public void preConfigure(DatabaseConfig config) {
|
||||
|
||||
if (!config.isDefaultServer()) {
|
||||
log.info("skip automatic testing config on non-default server name:{} register:{}", config.getName(), config.isRegister());
|
||||
return;
|
||||
}
|
||||
Properties properties = config.getProperties();
|
||||
if (isExtraServer(config, properties)) {
|
||||
setupExtraDataSourceIfNecessary(config);
|
||||
return;
|
||||
}
|
||||
|
||||
String testPlatform = properties.getProperty("ebean.test.platform");
|
||||
log.debug("automatic testing config - with ebean.test.platform:{} environment db:{} name:{}", testPlatform, environmentDb, config.getName());
|
||||
|
||||
log.debug("automatic testing config - with ebean.test.platform:{} name:{} environmentDb:{}", testPlatform, config.getName(), environmentDb);
|
||||
if (RunOnceMarker.isRun()) {
|
||||
setupPlatform(environmentDb, config);
|
||||
}
|
||||
@@ -46,8 +47,10 @@ public class AutoConfigureForTesting implements AutoConfigure {
|
||||
|
||||
@Override
|
||||
public void postConfigure(DatabaseConfig config) {
|
||||
if (!config.isDefaultServer()) {
|
||||
return;
|
||||
}
|
||||
setupProviders(config);
|
||||
|
||||
if (org.h2.engine.Constants.VERSION_MAJOR == 1) {
|
||||
// This code may be removed later, when droppinv H2 1.xxx compatibility
|
||||
System.err.println("Running tests in H2 1.xxx compatibility mode");
|
||||
|
||||
@@ -68,6 +68,8 @@ public abstract class BaseTestCase {
|
||||
DB_CLOCK_DELTA = 100;
|
||||
}
|
||||
try {
|
||||
String propsFile = System.getProperty("props.file");
|
||||
System.out.println("BaseTestCase: -Dprops.file=" + propsFile); // help debug CI
|
||||
// First try, if we get the default server. If this fails, all tests will fail.
|
||||
DB.getDefault();
|
||||
} catch (Throwable e) {
|
||||
|
||||
@@ -72,11 +72,12 @@
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
|
||||
<logger name="org.tests" level="INFO"/>
|
||||
<logger name="io.ebean" level="INFO"/>
|
||||
|
||||
<logger name="io.avaje.config" level="TRACE"/>
|
||||
<logger name="io.ebean.docker" level="TRACE"/>
|
||||
<logger name="io.ebean.test" level="TRACE"/>
|
||||
|
||||
<!-- <logger name="io.ebean.DDL" level="DEBUG"/>-->
|
||||
|
||||
<!-- <logger name="io.ebean.SQL" level="TRACE"/>-->
|
||||
|
||||
Reference in New Issue
Block a user