本文整理匯總了Java中liquibase.test.TestContext類的典型用法代碼示例。如果您正苦於以下問題:Java TestContext類的具體用法?Java TestContext怎麽用?Java TestContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TestContext類屬於liquibase.test包,在下文中一共展示了TestContext類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBasicOperation
import liquibase.test.TestContext; //導入依賴的package包/類
@Test
public void testBasicOperation() {
for (final Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof PostgresDatabase) {
final SetSequenceStatement statement = new SetSequenceStatement("SEQUENCE_NAME");
statement.addTable("TABLE_NAME", "COLUMN1_NAME");
if (shouldBeImplementation(database)) {
final SqlGenerator<SetSequenceStatement> generator = this.generatorUnderTest;
final String tempTableName = ((SetSequenceGenerator)generator).getTempTableName();
final Sql[] sql = generator.generateSql(statement, database, null);
assertEquals(
"SELECT pg_catalog.setval('SEQUENCE_NAME',(SELECT max(" + tempTableName + ".id)+1 AS id FROM ((SELECT max(COLUMN1_NAME) AS id FROM TABLE_NAME LIMIT 1)) AS " + tempTableName + " LIMIT 1),true);",
sql[0].toSql()
);
}
}
}
}
示例2: testWithMultipleTables
import liquibase.test.TestContext; //導入依賴的package包/類
@Test
public void testWithMultipleTables() {
for (final Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof PostgresDatabase) {
final SetSequenceStatement statement = new SetSequenceStatement("SEQUENCE_NAME");
statement.addTable("TABLE1_NAME", "COLUMN1_NAME");
statement.addTable("TABLE2_NAME", "COLUMN2_NAME");
if (shouldBeImplementation(database)) {
final SqlGenerator<SetSequenceStatement> generator = this.generatorUnderTest;
final String tempTableName = ((SetSequenceGenerator)generator).getTempTableName();
final Sql[] sql = generator.generateSql(statement, database, null);
assertEquals(
"SELECT pg_catalog.setval('SEQUENCE_NAME',(SELECT max(" + tempTableName + ".id)+1 AS id FROM ((SELECT max(COLUMN1_NAME) AS id FROM TABLE1_NAME LIMIT 1) UNION (SELECT max(COLUMN2_NAME) AS id FROM TABLE2_NAME LIMIT 1)) AS " + tempTableName + " LIMIT 1),true);",
sql[0].toSql()
);
}
}
}
}
示例3: AbstractIntegrationTest
import liquibase.test.TestContext; //導入依賴的package包/類
protected AbstractIntegrationTest(String changelogDir, String url) throws Exception {
LogFactory.setLoggingLevel("info");
this.completeChangeLog = "changelogs/" + changelogDir + "/complete/root.changelog.xml";
this.rollbackChangeLog = "changelogs/" + changelogDir + "/rollback/rollbackable.changelog.xml";
this.includedChangeLog = "changelogs/" + changelogDir + "/complete/included.changelog.xml";
this.encodingChangeLog = "changelogs/common/encoding.changelog.xml";
this.externalfkInitChangeLog= "changelogs/common/externalfk.init.changelog.xml";
this.externalEntityChangeLog= "changelogs/common/externalEntity.changelog.xml";
this.externalEntityChangeLog2= "com/example/nonIncluded/externalEntity.changelog.xml";
this.invalidReferenceChangeLog= "changelogs/common/invalid.reference.changelog.xml";
this.objectQuotingStrategyChangeLog = "changelogs/common/object.quoting.strategy.changelog.xml";
this.url = url;
ServiceLocator.getInstance().setResourceAccessor(TestContext.getInstance().getTestResourceAccessor());
}