remove changes to DatabaseAdaptor with new fields username/password, use our own username/password in maria_db tests

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
olivier lamy 2020-05-26 15:58:38 +10:00 committed by Olivier Lamy
parent c05bd6c26d
commit 1249763aad
3 changed files with 14 additions and 41 deletions

View File

@ -60,8 +60,6 @@ public class DatabaseAdaptor
private String _connectionUrl;
private Driver _driver;
private DataSource _datasource;
private String _username;
private String _password;
private String _jndiName;
@ -259,26 +257,6 @@ public class DatabaseAdaptor
return _connectionUrl;
}
public String getUsername()
{
return _username;
}
public void setUsername(String username)
{
this._username = username;
}
public String getPassword()
{
return _password;
}
public void setPassword(String password)
{
this._password = password;
}
public void initialize()
throws Exception
{
@ -324,8 +302,7 @@ public class DatabaseAdaptor
if (_datasource != null)
return _datasource.getConnection();
else
return _username == null ? DriverManager.getConnection(_connectionUrl)
: DriverManager.getConnection(_connectionUrl, _username, _password);
return DriverManager.getConnection(_connectionUrl);
}
/**

View File

@ -70,9 +70,10 @@ public class JdbcTestHelper
public static final String COOKIE_COL = "cooktime";
public static final String CREATE_COL = "ctime";
static MariaDBContainer MARIAD_DB =
new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6"))
.withDatabaseName("sessions");
static MariaDBContainer MARIAD_DB;
static final String MARIA_DB_USER = "beer";
static final String MARIA_DB_PASSWORD = "pacific_ale";
static
{
@ -81,6 +82,11 @@ public class JdbcTestHelper
try
{
long start = System.currentTimeMillis();
MARIAD_DB =
new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6"))
.withUsername(MARIA_DB_USER)
.withPassword(MARIA_DB_PASSWORD)
.withDatabaseName("sessions");
MARIAD_DB.withLogConsumer(new Slf4jLogConsumer(MARIADB_LOG)).start();
String containerIpAddress = MARIAD_DB.getContainerIpAddress();
int mariadbPort = MARIAD_DB.getMappedPort(3306);
@ -88,6 +94,9 @@ public class JdbcTestHelper
DRIVER_CLASS = MARIAD_DB.getDriverClassName();
LOG.info("Mariadb container started for {}:{} - {}ms", containerIpAddress, mariadbPort,
System.currentTimeMillis() - start);
DEFAULT_CONNECTION_URL = DEFAULT_CONNECTION_URL + "?user=" + MARIA_DB_USER +
"&password=" + MARIA_DB_PASSWORD;
LOG.info("DEFAULT_CONNECTION_URL: {}", DEFAULT_CONNECTION_URL);
}
catch (Exception e)
{
@ -132,11 +141,6 @@ public class JdbcTestHelper
public static DatabaseAdaptor buildDatabaseAdaptor()
{
DatabaseAdaptor da = new DatabaseAdaptor();
if (USE_MARIADB)
{
da.setUsername(MARIAD_DB.getUsername());
da.setPassword(MARIAD_DB.getPassword());
}
da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL);
return da;
}
@ -145,10 +149,7 @@ public class JdbcTestHelper
throws Exception
{
Class.forName(DRIVER_CLASS);
return USE_MARIADB ? DriverManager.getConnection(DEFAULT_CONNECTION_URL,
MARIAD_DB.getUsername(),
MARIAD_DB.getPassword())
: DriverManager.getConnection(DEFAULT_CONNECTION_URL);
return DriverManager.getConnection(DEFAULT_CONNECTION_URL);
}
/**

View File

@ -61,11 +61,6 @@ public class SessionTableSchemaTest
return true; //test special handling for oracle
}
};
if (USE_MARIADB)
{
_da.setUsername(JdbcTestHelper.MARIAD_DB.getUsername());
_da.setPassword(JdbcTestHelper.MARIAD_DB.getPassword());
}
_da.setDriverInfo(JdbcTestHelper.DRIVER_CLASS, JdbcTestHelper.DEFAULT_CONNECTION_URL);
_tableSchema = JdbcTestHelper.newSessionTableSchema();
_tableSchema.setDatabaseAdaptor(_da);