本文整理汇总了Java中liquibase.changelog.DatabaseChangeLog.getChangeSets方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseChangeLog.getChangeSets方法的具体用法?Java DatabaseChangeLog.getChangeSets怎么用?Java DatabaseChangeLog.getChangeSets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类liquibase.changelog.DatabaseChangeLog
的用法示例。
在下文中一共展示了DatabaseChangeLog.getChangeSets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
liquiBase.checkLiquibaseTables(false, changeLog, new Contexts(), new LabelExpression());
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
Change change = changeSets.get(0).getChanges().get(0);
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
String expected = "DROP SYNONYM new_synonym";
assertEquals(expected, sql[0].toSql());
}
示例2: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser( changeLogFile, resourceAccessor ).parse( changeLogFile, changeLogParameters, resourceAccessor );
liquiBase.checkLiquibaseTables( true, changeLog, new Contexts() );
changeLog.validate( database );
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview1 AS select 1 as One from dual", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview2 AS select * from mytable", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview2 AS select * from mytable where rownum = 1", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview4 AS select 1 as One from dual", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview3 AS select * from mytable", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "CREATE OR REPLACE VIEW %s.myview3 AS select * from mytable where one like '%%'", database.getLiquibaseSchemaName() ) );
expectedQuery.add( String.format( "Drop materialized view myview2" ) );
int i = 0;
for ( ChangeSet changeSet : changeSets ) {
for ( Change change : changeSet.getChanges() ) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql( change.generateStatements( database )[0], database );
if ( change instanceof CreateFlexibleViewChange ) {
for ( Sql s : sql ) {
System.out.println( "--------------------------------------------------------------------------------------------------------" );
System.out.println( "ACTUAL: " + s.toSql() );
System.out.println( "EXPECT: " + expectedQuery.get( i ) );
assertEquals( expectedQuery.get( i ), s.toSql() );
i++;
}
}
}
}
}
示例3: handleIncludedChangeLog
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
protected boolean handleIncludedChangeLog(String fileName,
boolean isRelativePath, String relativeBaseFileName)
throws LiquibaseException {
if (!(fileName.endsWith(".xml") || fileName.endsWith(".sql"))) {
log.debug(relativeBaseFileName + "/" + fileName
+ " is not a recognized file type");
return false;
}
if (fileName.equalsIgnoreCase(".svn") || fileName.equalsIgnoreCase("cvs")) {
return false;
}
if (isRelativePath) {
// workaround for FilenameUtils.normalize() returning null for relative paths like ../conf/liquibase.xml
String tempFile = FilenameUtils.concat(FilenameUtils.getFullPath(relativeBaseFileName), fileName);
if(tempFile != null && new File(tempFile).exists() == true) {
fileName = tempFile;
} else {
fileName = FilenameUtils.getFullPath(relativeBaseFileName) + fileName;
}
}
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(fileName, resourceAccessor).parse(fileName, changeLogParameters,
resourceAccessor);
PreconditionContainer preconditions = changeLog.getPreconditions();
if (preconditions != null) {
if (null == databaseChangeLog.getPreconditions()) {
databaseChangeLog.setPreconditions(new PreconditionContainer());
}
databaseChangeLog.getPreconditions().addNestedPrecondition(
preconditions);
}
for (ChangeSet changeSet : changeLog.getChangeSets()) {
handleChangeSet(changeSet);
}
return true;
}
示例4: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("CREATE TABLE LBUSER.person (id NUMBER(10), name VARCHAR2(50))");
expectedQuery.add("INSERT INTO LBUSER.person (id, name) VALUES ('1', 'James')");
expectedQuery.add("ALTER TABLE LBUSER.person RENAME TO Tperson");
expectedQuery.add("CREATE OR REPLACE VIEW LBUSER.person AS SELECT * FROM Tperson");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals(expectedQuery.get(i), sql[0].toSql());
}
i++;
}
}
示例5: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("ALTER TRIGGER zuiolTrigger RENAME TO RenamedZuiolTrigger");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 4) {
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
}
i++;
}
}
示例6: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("ALTER TABLE LBUSER.test DISABLE CONSTRAINT tom_check");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 2) {
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
}
i++;
}
}
示例7: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery
.add("CREATE TRIGGER zuiolTrigger before INSERT ON TriggerTest FOR EACH ROW DECLARE v_username varchar2(10); BEGIN SELECT pierwsza INTO v_username FROM TriggerTest; :new.created_by := v_username; END;");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 2) {
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
}
i++;
}
}
示例8: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile, changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("CREATE TABLE LBUSER.AddDeferredPrimaryKeyTest (id NUMBER(10), name VARCHAR2(50))");
expectedQuery.add("ALTER TABLE LBUSER.AddDeferredPrimaryKeyTest ADD CONSTRAINT PK_AddDeferredPrimaryKeyTest PRIMARY KEY (id) DEFERRABLE INITIALLY DEFERRED");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals(expectedQuery.get(i), sql[0].toSql());
}
i++;
}
}
示例9: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery
.add("declare commit_interval integer; sleep_seconds integer; c integer; begin commit_interval := 5; sleep_seconds := 1; c := 1; while c > 0 loop UPDATE LongUpdateTest SET name='checked' where name='test' and rownum <= 5; c := SQL%ROWCOUNT; COMMIT; dbms_lock.sleep(1); end loop; end;");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 2) {
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
}
i++;
}
}
示例10: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("Drop materialized view zuiolView");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 5) {
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
}
i++;
}
}
示例11: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("CREATE MATERIALIZED VIEW zuiolView AS select * from Table1");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 4) {
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
}
i++;
}
}
示例12: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("SET TRANSACTION NAME 'zuiolTransaction'");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
// if(i == 2)
assertEquals(expectedQuery.get(i), sql[0].toSql());
}
i++;
}
}
示例13: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("CREATE TABLE LBUSER.truncatetest (id NUMBER(10), name VARCHAR2(50))");
expectedQuery.add("insert into truncatetest (id, name) values (1, 'dgolda')");
expectedQuery.add("TRUNCATE TABLE LBUSER.truncatetest PURGE MATERIALIZED VIEW LOG REUSE STORAGE");
// expectedQuery.add("TRUNCATE TABLE artur.truncatetest PURGE MATERIALIZED VIEW LOG REUSE STORAGE");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
// Change change = changeSet.getChanges().get(0);
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals(expectedQuery.get(i), sql[0].toSql());
}
i++;
}
}
示例14: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance()
.getParser(changeLogFile, resourceAccessor)
.parse(changeLogFile, new ChangeLogParameters(), resourceAccessor);
liquiBase.checkLiquibaseTables( false, changeLog, new Contexts(), new LabelExpression());
changeLog.validate(database);
List<String> expectedSql = new ArrayList<String>();
expectedSql.add("BEGIN DBMS_MVIEW.REFRESH('TABLE1_MVIEW','?',ATOMIC_REFRESH=>TRUE); END;");
expectedSql.add("BEGIN DBMS_MVIEW.REFRESH('TABLE1_MVIEW','C',ATOMIC_REFRESH=>FALSE); END;");
expectedSql.add("BEGIN DBMS_MVIEW.REFRESH('LIQUIBASE.TABLE1_MVIEW','?',ATOMIC_REFRESH=>FALSE); END;");
List<ChangeSet> changeSets = changeLog.getChangeSets();
assertEquals( "Test is out of sync with the changelog.test.xml file. # of changesets",
6, changeSets.size());
ChangeSet changeSet = changeSets.get(changeSets.size()-1);
assertEquals( "Test is out of sync with the changelog.test.xml file. # of changes in changeset", 3, changeSet.getChanges().size() );
List<String> actualSql = new ArrayList<String>();
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals( "Wrong number of SQL statements generated", 1, sql.length );
actualSql.add(sql[0].toSql());
}
assertEquals( "Generated SQL statements incorrect", expectedSql, actualSql );
}
示例15: parseAndGenerate
import liquibase.changelog.DatabaseChangeLog; //导入方法依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
expectedQuery.add("ALTER TABLE LBUSER.test drop CONSTRAINT tom_check");
int i = 0;
for (ChangeSet changeSet : changeSets) {
for (Change change : changeSet.getChanges()) {
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
if (i == 1) {
assertEquals(expectedQuery.get(i - 1), sql[0].toSql());
}
}
i++;
}
}