You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.8 KiB
86 lines
2.8 KiB
package de.superx; |
|
|
|
import java.io.IOException; |
|
import java.util.HashMap; |
|
import java.util.Map; |
|
|
|
import javax.sql.DataSource; |
|
|
|
import org.junit.Ignore; |
|
import org.pentaho.di.core.KettleEnvironment; |
|
import org.springframework.context.annotation.Bean; |
|
import org.springframework.context.annotation.ComponentScan; |
|
import org.springframework.context.annotation.Configuration; |
|
import org.springframework.context.annotation.Import; |
|
import org.springframework.context.annotation.Primary; |
|
import org.springframework.context.annotation.PropertySource; |
|
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; |
|
|
|
import de.superx.dbt.DbtUtils; |
|
import de.superx.servlet.SxPools; |
|
import de.superx.spring.batch.His1DataSources; |
|
|
|
@Ignore |
|
@Configuration |
|
@EnableJdbcRepositories(basePackages = {"de.superx.jdbc.repository","de.superx.bianalysis.repository"} ) |
|
@PropertySource("classpath:spring-batch.properties") |
|
@PropertySource("classpath:test.properties") |
|
@ComponentScan( |
|
basePackages = "de.superx.spring.service,de.superx.dbt,de.superx.rest,de.superx.bianalysis.service,de.superx.bianalysis.rest,de.superx.access,de.superx.spring.config") |
|
@Import(TestAppConfig.class) |
|
// TODO TestApplicationConfigH2 wird nicht mehr gebraucht. Stattdessen besser einen eigenen |
|
// TestDbManager für die H2 tests erstellen! |
|
public class TestApplicationConfigPg extends TestApplicationConfigH2 { |
|
|
|
private TestDbManager db; |
|
|
|
@Override |
|
@Bean |
|
@Primary |
|
DataSource dataSource() throws Exception { |
|
DataSource ds = dataSources().get(TestDbManager.EDUETL_DB); |
|
if (!batchSchemaExists(ds)) { |
|
createBatchSchema(ds); |
|
} |
|
return ds; |
|
} |
|
|
|
@Override |
|
@Bean |
|
public His1DataSources dataSources() { |
|
Map<String,DataSource> dataSources = new HashMap<>(); |
|
dataSources.put("eduetl", db.getDataSource(TestDbManager.EDUETL_DB)); |
|
dataSources.put("hisinone", db.getDataSource(TestDbManager.HISINONE_DB)); |
|
return new His1DataSources(dataSources); |
|
} |
|
|
|
@Bean |
|
public Map<String, String> dbtProfile() { |
|
return db.dbtProfile(); |
|
} |
|
|
|
@Override |
|
protected void setupTestDb() throws IOException { |
|
// Für Tests auf vmpostgres17.his.de |
|
db = new TestDbManagerPg(); |
|
|
|
// Für Tests auf den lokalen DBs |
|
//(Verbindungsinformationen werden aus der his1_databases.properties genommen) |
|
//db = new TestDbManagerPgLocal(); |
|
|
|
db.setupTestDbs(); |
|
} |
|
|
|
@Override |
|
public void destroy() throws Exception { |
|
System.out.println("Context Stop Event received."); |
|
SxPools.closeAll(); |
|
System.setProperty("SX_LOG_TO_TMP", "false"); |
|
if (KettleEnvironment.isInitialized()) { |
|
KettleEnvironment.shutdown(); |
|
} |
|
// Auskommentieren, wenn die DBs für Debugging nach den Tests |
|
// noch benötigt werden! |
|
db.removeTestDbs(); |
|
} |
|
}
|
|
|