Search in sources :

Example 1 with SqlChangeLogParser

use of liquibase.parser.core.sql.SqlChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method unregister_instance.

@Test
public void unregister_instance() {
    ChangeLogParserFactory factory = ChangeLogParserFactory.getInstance();
    factory.getParsers().clear();
    assertEquals(5, factory.getParsers().size());
    XMLChangeLogSAXParser changeLogParser = new XMLChangeLogSAXParser();
    factory.register(new SqlChangeLogParser());
    factory.register(changeLogParser);
    assertEquals(7, factory.getParsers().size());
    factory.unregister(changeLogParser);
    assertEquals(6, factory.getParsers().size());
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Example 2 with SqlChangeLogParser

use of liquibase.parser.core.sql.SqlChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_byFile.

@Test
public void getParser_byFile() throws Exception {
    ChangeLogParserFactory.getInstance().unregisterAllParsers();
    assumeThat(ChangeLogParserFactory.getInstance().getParsers(), empty());
    XMLChangeLogSAXParser xmlChangeLogParser = new XMLChangeLogSAXParser();
    ChangeLogParserFactory.getInstance().register(xmlChangeLogParser);
    ChangeLogParserFactory.getInstance().register(new SqlChangeLogParser());
    ChangeLogParser parser = ChangeLogParserFactory.getInstance().getParser("path/to/a/file.xml", new JUnitResourceAccessor());
    assertNotNull(parser);
    assertSame(xmlChangeLogParser, parser);
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) MockChangeLogParser(liquibase.parser.MockChangeLogParser) SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) ChangeLogParser(liquibase.parser.ChangeLogParser) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Example 3 with SqlChangeLogParser

use of liquibase.parser.core.sql.SqlChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_noneMatching.

@Test(expected = UnknownChangelogFormatException.class)
public void getParser_noneMatching() throws Exception {
    ChangeLogParserFactory.getInstance().unregisterAllParsers();
    XMLChangeLogSAXParser xmlChangeLogParser = new XMLChangeLogSAXParser();
    ChangeLogParserFactory.getInstance().register(xmlChangeLogParser);
    ChangeLogParserFactory.getInstance().register(new SqlChangeLogParser());
    ChangeLogParserFactory.getInstance().getParser("badextension", new JUnitResourceAccessor());
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Example 4 with SqlChangeLogParser

use of liquibase.parser.core.sql.SqlChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method unregister_instance.

@Test
public void unregister_instance() {
    ChangeLogParserFactory factory = ChangeLogParserFactory.getInstance();
    factory.unregisterAllParsers();
    assumeThat(ChangeLogParserFactory.getInstance().getParsers(), empty());
    ChangeLogParser mockChangeLogParser = new MockChangeLogParser(".test");
    factory.register(new XMLChangeLogSAXParser());
    factory.register(mockChangeLogParser);
    factory.register(new SqlChangeLogParser());
    assertEquals(3, factory.getParsers().size());
    factory.unregister(mockChangeLogParser);
    assertEquals(2, factory.getParsers().size());
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) MockChangeLogParser(liquibase.parser.MockChangeLogParser) ChangeLogParserFactory(liquibase.parser.ChangeLogParserFactory) MockChangeLogParser(liquibase.parser.MockChangeLogParser) SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) ChangeLogParser(liquibase.parser.ChangeLogParser) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Example 5 with SqlChangeLogParser

use of liquibase.parser.core.sql.SqlChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_byExtension.

@Test
public void getParser_byExtension() throws Exception {
    ChangeLogParserFactory.getInstance().unregisterAllParsers();
    assumeThat(ChangeLogParserFactory.getInstance().getParsers(), empty());
    XMLChangeLogSAXParser xmlChangeLogParser = new XMLChangeLogSAXParser();
    ChangeLogParserFactory.getInstance().register(xmlChangeLogParser);
    ChangeLogParserFactory.getInstance().register(new SqlChangeLogParser());
    ChangeLogParser parser = ChangeLogParserFactory.getInstance().getParser("xml", new JUnitResourceAccessor());
    assertNotNull(parser);
    assertSame(xmlChangeLogParser, parser);
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) MockChangeLogParser(liquibase.parser.MockChangeLogParser) SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) ChangeLogParser(liquibase.parser.ChangeLogParser) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Aggregations

SqlChangeLogParser (liquibase.parser.core.sql.SqlChangeLogParser)5 XMLChangeLogSAXParser (liquibase.parser.core.xml.XMLChangeLogSAXParser)5 Test (org.junit.Test)5 ChangeLogParser (liquibase.parser.ChangeLogParser)3 MockChangeLogParser (liquibase.parser.MockChangeLogParser)3 JUnitResourceAccessor (liquibase.test.JUnitResourceAccessor)3 ChangeLogParserFactory (liquibase.parser.ChangeLogParserFactory)1