當前位置: 首頁>>代碼示例>>Java>>正文


Java TestContext類代碼示例

本文整理匯總了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()
                );
            }
        }
    }
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:19,代碼來源:SetSequenceGeneratorTest.java

示例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()
                );
            }
        }
    }
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:20,代碼來源:SetSequenceGeneratorTest.java

示例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());
}
 
開發者ID:lbitonti,項目名稱:liquibase-hana,代碼行數:18,代碼來源:AbstractIntegrationTest.java


注:本文中的liquibase.test.TestContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。