[Minor] Added tests for archive PostgreSQL scripts
This commit is contained in:
parent
b546f49b66
commit
d695879f82
|
@ -61,10 +61,10 @@ public abstract class PerformanceTest {
|
|||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class);
|
||||
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
logger.info(StringHelper.NEW_LINE + sql);
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
|
|
|
@ -42,7 +42,8 @@ import org.postgresql.Driver;
|
|||
*/
|
||||
public class PostgreSqlPersistenceHandler extends StrolchComponent implements PersistenceHandler {
|
||||
|
||||
public static final String SCRIPT_PREFIX = "strolch"; //$NON-NLS-1$
|
||||
public static final String SCRIPT_PREFIX_STROLCH = "strolch"; //$NON-NLS-1$
|
||||
public static final String SCRIPT_PREFIX_ARCHIVE = "archive"; //$NON-NLS-1$
|
||||
public static final String PROP_DATA_TYPE = "dataType"; //$NON-NLS-1$
|
||||
public static final String DATA_TYPE_XML = "xml"; //$NON-NLS-1$
|
||||
public static final String DATA_TYPE_JSON = "json"; //$NON-NLS-1$
|
||||
|
@ -95,7 +96,7 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements Pe
|
|||
boolean allowDataInitOnSchemaCreate = configuration
|
||||
.getBoolean(PROP_ALLOW_DATA_INIT_ON_SCHEMA_CREATE, Boolean.FALSE);
|
||||
|
||||
DbSchemaVersionCheck schemaVersionCheck = new DbSchemaVersionCheck(SCRIPT_PREFIX, this.getClass(),
|
||||
DbSchemaVersionCheck schemaVersionCheck = new DbSchemaVersionCheck(SCRIPT_PREFIX_STROLCH, this.getClass(),
|
||||
allowSchemaCreation, allowSchemaMigration, allowSchemaDrop);
|
||||
schemaVersionCheck.checkSchemaVersion(this.dsMap);
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package li.strolch.persistence.postgresql.dao.test;
|
||||
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH;
|
||||
import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -65,7 +67,8 @@ public class AuditQueryTest {
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
dropSchema(DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
File rootPath = new File(RUNTIME_PATH);
|
||||
File configSrc = new File(CONFIG_SRC);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package li.strolch.persistence.postgresql.dao.test;
|
||||
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -58,7 +60,8 @@ public class CachedDaoTest extends AbstractModelTest {
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
dropSchema(DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
File rootPath = new File(RUNTIME_PATH);
|
||||
File configSrc = new File(CONFIG_SRC);
|
||||
|
@ -72,17 +75,16 @@ public class CachedDaoTest extends AbstractModelTest {
|
|||
assertEquals(DataType.xml, persistenceHandler.getDataType());
|
||||
}
|
||||
|
||||
public static void dropSchema(String dbUrl, String dbUsername, String dbPassword) throws Exception {
|
||||
public static void dropSchema(String scriptPrefix, String dbUrl, String dbUsername, String dbPassword)
|
||||
throws Exception {
|
||||
|
||||
if (!Driver.isRegistered())
|
||||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
Version dbVersion = DbSchemaVersionCheck.getExpectedDbVersion(scriptPrefix, PostgreSqlPersistenceHandler.class);
|
||||
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
.getSql(scriptPrefix, PostgreSqlPersistenceHandler.class, dbVersion, "drop"); //$NON-NLS-1$
|
||||
logger.info(StringHelper.NEW_LINE + sql);
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
connection.prepareStatement(sql).execute();
|
||||
|
|
|
@ -78,10 +78,10 @@ public class CachedJsonDaoTest extends AbstractModelTest {
|
|||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class);
|
||||
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
logger.info(StringHelper.NEW_LINE + sql);
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
|
|
|
@ -78,10 +78,10 @@ public class CachedJsonVersioningDaoTest extends AbstractModelTest {
|
|||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class);
|
||||
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
logger.info(StringHelper.NEW_LINE + sql);
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
|
|
|
@ -78,10 +78,10 @@ public class CachedVersioningDaoTest extends AbstractModelTest {
|
|||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class);
|
||||
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
logger.info(StringHelper.NEW_LINE + sql);
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
|
|
|
@ -16,8 +16,11 @@
|
|||
package li.strolch.persistence.postgresql.dao.test;
|
||||
|
||||
import static java.util.Comparator.comparing;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH;
|
||||
import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.*;
|
||||
import static li.strolch.runtime.StrolchConstants.DEFAULT_REALM;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
|
@ -29,9 +32,8 @@ import java.util.Arrays;
|
|||
import li.strolch.db.DbException;
|
||||
import li.strolch.db.DbSchemaVersionCheck;
|
||||
import li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler;
|
||||
import li.strolch.runtime.StrolchConstants;
|
||||
import li.strolch.utils.Version;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -39,41 +41,54 @@ import org.slf4j.LoggerFactory;
|
|||
/**
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class DbMigrationTest {
|
||||
public class DbSchemaCreationTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DbMigrationTest.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DbSchemaCreationTest.class);
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
dropSchema(DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreate() throws Exception {
|
||||
create(SCRIPT_PREFIX_STROLCH);
|
||||
create(SCRIPT_PREFIX_ARCHIVE);
|
||||
}
|
||||
|
||||
DbSchemaVersionCheck dbCheck = new DbSchemaVersionCheck(SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, true,
|
||||
private void create(String scriptPrefix) throws Exception {
|
||||
|
||||
logger.info("");
|
||||
logger.info("===============================================");
|
||||
logger.info("Trying to create DB schema for " + scriptPrefix);
|
||||
logger.info("");
|
||||
|
||||
DbSchemaVersionCheck dbCheck = new DbSchemaVersionCheck(scriptPrefix, PostgreSqlPersistenceHandler.class, true,
|
||||
true, true);
|
||||
|
||||
try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) {
|
||||
|
||||
// CREATE 0.1.0
|
||||
dbCheck.createSchema(con, StrolchConstants.DEFAULT_REALM, Version.valueOf("0.1.0"));
|
||||
dbCheck.createSchema(con, DEFAULT_REALM, Version.valueOf("0.1.0"));
|
||||
|
||||
File scriptsD = new File("src/main/resources");
|
||||
File[] scriptFiles = scriptsD.listFiles(f -> f.getName().endsWith("_initial.sql"));
|
||||
File[] scriptFiles = scriptsD
|
||||
.listFiles(f -> f.getName().startsWith(scriptPrefix) && f.getName().endsWith("_initial.sql"));
|
||||
assertNotNull(scriptFiles);
|
||||
Arrays.sort(scriptFiles, comparing(File::getName));
|
||||
for (File scriptFile : scriptFiles) {
|
||||
|
||||
String name = scriptFile.getName();
|
||||
String versionS = name
|
||||
.substring("strolch_db_schema_".length(), name.length() - "_initial.sql".length());
|
||||
.substring((scriptPrefix + "_db_schema_").length(), name.length() - "_initial.sql".length());
|
||||
Version version = Version.valueOf(versionS);
|
||||
logger.info("Creating Version " + version);
|
||||
|
||||
dropSchema(DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(scriptPrefix, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
// CREATE
|
||||
dbCheck.createSchema(con, StrolchConstants.DEFAULT_REALM, version);
|
||||
dbCheck.createSchema(con, DEFAULT_REALM, version);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
@ -82,29 +97,4 @@ public class DbMigrationTest {
|
|||
throw new DbException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMigrate() throws Exception {
|
||||
|
||||
DbSchemaVersionCheck dbCheck = new DbSchemaVersionCheck(SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, true,
|
||||
true, true);
|
||||
|
||||
try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) {
|
||||
|
||||
// CREATE 0.1.0
|
||||
Version currentVersion = Version.valueOf("0.1.0");
|
||||
dbCheck.createSchema(con, StrolchConstants.DEFAULT_REALM, currentVersion);
|
||||
|
||||
Version expectedDbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
|
||||
// MIGRATE
|
||||
dbCheck.migrateSchema(con, StrolchConstants.DEFAULT_REALM, currentVersion, expectedDbVersion);
|
||||
|
||||
} catch (SQLException e) {
|
||||
String msg = "Failed to open DB connection to URL {0} due to: {1}"; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, DB_URL, e.getMessage());
|
||||
throw new DbException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package li.strolch.persistence.postgresql.dao.test;
|
||||
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH;
|
||||
import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.*;
|
||||
import static li.strolch.runtime.StrolchConstants.DEFAULT_REALM;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import li.strolch.db.DbException;
|
||||
import li.strolch.db.DbSchemaVersionCheck;
|
||||
import li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler;
|
||||
import li.strolch.utils.Version;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class DbSchemaMigrationTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DbSchemaMigrationTest.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMigrate() throws Exception {
|
||||
migrate(SCRIPT_PREFIX_STROLCH);
|
||||
migrate(SCRIPT_PREFIX_ARCHIVE);
|
||||
}
|
||||
|
||||
private void migrate(String scriptPrefix) throws Exception {
|
||||
|
||||
logger.info("");
|
||||
logger.info("===============================================");
|
||||
logger.info("Trying to migrate DB schema from 0.1.0 upwards...");
|
||||
logger.info("");
|
||||
|
||||
// first clear DB
|
||||
dropSchema(scriptPrefix, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
DbSchemaVersionCheck dbCheck = new DbSchemaVersionCheck(scriptPrefix, PostgreSqlPersistenceHandler.class, true,
|
||||
true, true);
|
||||
|
||||
try (Connection con = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) {
|
||||
|
||||
// CREATE 0.1.0
|
||||
Version currentVersion = Version.valueOf("0.1.0");
|
||||
dbCheck.createSchema(con, DEFAULT_REALM, currentVersion);
|
||||
|
||||
Version expectedDbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(scriptPrefix, PostgreSqlPersistenceHandler.class);
|
||||
|
||||
// MIGRATE
|
||||
dbCheck.migrateSchema(con, DEFAULT_REALM, currentVersion, expectedDbVersion);
|
||||
|
||||
} catch (SQLException e) {
|
||||
String msg = "Failed to open DB connection to URL {0} due to: {1}"; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, DB_URL, e.getMessage());
|
||||
throw new DbException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ package li.strolch.persistence.postgresql.dao.test;
|
|||
|
||||
import static li.strolch.model.ModelGenerator.createOrder;
|
||||
import static li.strolch.model.ModelGenerator.createResource;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH;
|
||||
import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -60,7 +62,8 @@ public class ObserverUpdateTest {
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
dropSchema(DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
File rootPath = new File(RUNTIME_PATH);
|
||||
File configSrc = new File(CONFIG_SRC);
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package li.strolch.persistence.postgresql.dao.test;
|
||||
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_ARCHIVE;
|
||||
import static li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH;
|
||||
import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.DB_PASSWORD;
|
||||
import static li.strolch.persistence.postgresql.dao.test.CachedDaoTest.dropSchema;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -40,8 +43,11 @@ import org.junit.Test;
|
|||
|
||||
public class RealmTest extends AbstractModelTest {
|
||||
|
||||
private static final String TESTUSER2 = "testuser2"; //$NON-NLS-1$
|
||||
private static final String TESTUSER1 = "testuser1"; //$NON-NLS-1$
|
||||
public static final String DB_URL1 = "jdbc:postgresql://localhost/testdb1";
|
||||
public static final String DB_URL2 = "jdbc:postgresql://localhost/testdb2";
|
||||
|
||||
private static final String TEST_USER2 = "testuser2"; //$NON-NLS-1$
|
||||
private static final String TEST_USER1 = "testuser1"; //$NON-NLS-1$
|
||||
private static final String TEST = "test"; //$NON-NLS-1$
|
||||
private static final String FIRST = "first"; //$NON-NLS-1$
|
||||
private static final String SECOND = "second"; //$NON-NLS-1$
|
||||
|
@ -60,8 +66,10 @@ public class RealmTest extends AbstractModelTest {
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
|
||||
dropSchema("jdbc:postgresql://localhost/testdb1", TESTUSER1, TEST); //$NON-NLS-1$
|
||||
dropSchema("jdbc:postgresql://localhost/testdb2", TESTUSER2, TEST); //$NON-NLS-1$
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL1, TEST_USER1, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL1, TEST_USER1, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_ARCHIVE, DB_URL2, TEST_USER2, DB_PASSWORD);
|
||||
dropSchema(SCRIPT_PREFIX_STROLCH, DB_URL2, TEST_USER2, DB_PASSWORD);
|
||||
|
||||
File rootPath = new File(RUNTIME_PATH);
|
||||
File configSrc = new File(CONFIG_SRC);
|
||||
|
|
|
@ -87,9 +87,9 @@ public abstract class AbstractRealmServiceTest<T extends ServiceArgument, U exte
|
|||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class);
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX_STROLCH, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
connection.prepareStatement(sql).execute();
|
||||
|
|
Loading…
Reference in New Issue