SuperX-Kernmodul
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.
 
 
 
 
 
 

68 lines
2.1 KiB

package de.superx;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.sql.DataSource;
import org.junit.Ignore;
import org.springframework.context.annotation.Bean;
import com.zaxxer.hikari.HikariDataSource;
import de.superx.spring.DatabaseUtils;
@Ignore
public class TestDbManagerPgLocal implements TestDbManager {
Map<String,Map<String,String>> connections = new HashMap<>();
@Override
public void setupTestDbs() {
try {
connections = DatabaseUtils.getValidConnections();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void removeTestDbs() {
// Nothing to do here
}
@Override
public DataSource getDataSource(String logicalDbName) {
Map<String,String> eduetlProps = connections.get(logicalDbName);
HikariDataSource ds = DatabaseUtils.convertConnection(logicalDbName, eduetlProps, 0, 180000);
//ds.setConnectionInitSql("SET standard_conforming_strings TO 'off'; SET datestyle TO 'ISO, DMY';");
return ds;
}
@Override
public Map<String, String> dbtProfile() {
Map<String, String> attributes = new HashMap<>();
Map<String, String> con;
try {
con = DatabaseUtils.getConnection("eduetl");
attributes.put("DBT_HOST", con.get("host"));
attributes.put("DBT_PORT", con.get("dbserverport"));
attributes.put("DBT_USER", con.get("user"));
attributes.put("DBT_ENV_SECRET_PW", con.get("password"));
attributes.put("DBT_DB", con.get("database"));
return attributes;
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException
| BadPaddingException e) {
e.printStackTrace();
}
return attributes;
}
}