use of com.axway.ats.action.dbaccess.DatabaseOperations in project ats-framework by Axway.
the class DatabaseBackupRestoreTests method init.
@BeforeMethod
public void init() {
serverBox = new TestBox();
serverBox.setHost(configuration.getDatabaseHost());
serverBox.setDbType(configuration.getDatabaseType());
serverBox.setDbName(configuration.getBackupDatabaseName());
serverBox.setDbUser(configuration.getDatabaseUser());
serverBox.setDbPass(configuration.getDatabasePassword());
serverBox.setDbPort(String.valueOf(configuration.getDbPort()));
// establish DB connection
dbOperations = new DatabaseOperations(serverBox);
dbConn = new DbConnPostgreSQL(configuration.getDatabaseHost(), port, configuration.getBackupDatabaseName(), configuration.getDatabaseUser(), configuration.getDatabasePassword(), null);
// establish tables which to be inspected
dbTables = new ArrayList<>();
dbTables.add(new DbTable(TABLE));
}
use of com.axway.ats.action.dbaccess.DatabaseOperations in project ats-framework by Axway.
the class DatabaseVerificationTests method beforeMethod.
/**
* Prior to each test we make sure we have the table we worked with
* is in same state
*/
@BeforeMethod
public void beforeMethod() {
// initialize all connection parameters
dbServerBox = new TestBox();
dbServerBox.setHost(configuration.getDatabaseHost());
dbServerBox.setDbType(configuration.getDatabaseType());
dbServerBox.setDbName(configuration.getDatabaseName());
dbServerBox.setDbUser(configuration.getDatabaseUser());
dbServerBox.setDbPass(configuration.getDatabasePassword());
dbServerBox.setDbPort(String.valueOf(configuration.getDbPort()));
// initialize this helper class
dbOperations = new DatabaseOperations(dbServerBox);
// cleanup the table we use and fill it with the needed data
dbOperations.delete(TABLE, "1=1");
dbOperations.insertValues(TABLE, new String[] { "id", "firstName", "lastName", "age" }, new String[] { "1", "Chuck", "Norris", "70" });
dbOperations.insertValues(TABLE, new String[] { "id", "firstName", "lastName", "age" }, new String[] { "2", "Jackie", "Chan", "64" });
// Initialize the class we will use in our tests
dbVerification = new DbVerification(dbServerBox, TABLE);
}
use of com.axway.ats.action.dbaccess.DatabaseOperations in project ats-framework by Axway.
the class DatabaseOperationTests method beforeMethod.
/**
* Prior to each test we make sure we have the table we worked with
* is in same state
*/
@BeforeMethod
public void beforeMethod() {
// Here we define all connection parameters
TestBox serverBox = new TestBox();
serverBox.setHost(configuration.getDatabaseHost());
serverBox.setDbType(configuration.getDatabaseType());
serverBox.setDbName(configuration.getDatabaseName());
serverBox.setDbUser(configuration.getDatabaseUser());
serverBox.setDbPass(configuration.getDatabasePassword());
serverBox.setDbPort(String.valueOf(configuration.getDbPort()));
// establish DB connection
dbOperations = new DatabaseOperations(serverBox);
// cleanup the table we use and fill it with the needed data
dbOperations.delete(TABLE, "1=1");
dbOperations.insertValues(TABLE, new String[] { "id", "firstName", "lastName", "age" }, new String[] { "1", "Chuck", "Norris", "70" });
dbOperations.insertValues(TABLE, new String[] { "id", "firstName", "lastName", "age" }, new String[] { "2", "Jackie", "Chan", "64" });
}
use of com.axway.ats.action.dbaccess.DatabaseOperations in project ats-framework by Axway.
the class AtsVersionVerifier method getDatabaseVersion.
private static String getDatabaseVersion(TestBox box, Map<String, Object> properties) {
DatabaseOperations dbOps = new DatabaseOperations(box, properties);
try {
String query = null;
if (box.getDbType().equals(DbConnSQLServer.DATABASE_TYPE)) {
query = "SELECT value from tInternal where [key] = 'version'";
} else if (box.getDbType().equals(DbConnPostgreSQL.DATABASE_TYPE)) {
query = "SELECT value from \"tInternal\" where key = 'version'";
} else {
throw new UnsupportedOperationException("Could not construct statement query for getting database version for connection of class '" + box.getDbType() + "'");
}
DatabaseRow[] rows = dbOps.getDatabaseData(query);
if (rows != null) {
for (DatabaseRow row : rows) {
return row.getCellValue("version");
}
}
throw new RuntimeException(String.format("SQL Select Query '%s' returned 0 (zero) results!", query));
} catch (Exception e) {
throw new RuntimeException(String.format("Could not get ATS Version for ATS Log Database at %s%s", box.toString(), (properties != null && !properties.isEmpty()) ? " with custom properties " + properties.toString() : ""), e);
} finally {
if (dbOps != null) {
dbOps.disconnect();
}
}
}
Aggregations