Search in sources :

Example 1 with XMLChangeLogSAXParser

use of liquibase.parser.core.xml.XMLChangeLogSAXParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method unregister_instance.

@Test
public void unregister_instance() {
    ChangeLogParserFactory factory = ChangeLogParserFactory.getInstance();
    factory.getParsers().clear();
    assertEquals(0, factory.getParsers().size());
    ChangeLogParser mockChangeLogParser = new MockChangeLogParser();
    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) ChangeLogParserFactory(liquibase.parser.ChangeLogParserFactory) SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) ChangeLogParser(liquibase.parser.ChangeLogParser) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Example 2 with XMLChangeLogSAXParser

use of liquibase.parser.core.xml.XMLChangeLogSAXParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_noneMatching.

@Test
public void getParser_noneMatching() throws Exception {
    ChangeLogParserFactory.getInstance().getParsers().clear();
    ChangeLogParserFactory.getInstance().getParsers().clear();
    XMLChangeLogSAXParser xmlChangeLogParser = new XMLChangeLogSAXParser();
    ChangeLogParserFactory.getInstance().register(xmlChangeLogParser);
    ChangeLogParserFactory.getInstance().register(new SqlChangeLogParser());
    try {
        ChangeLogParserFactory.getInstance().getParser("badextension", new JUnitResourceAccessor());
        fail("Did not throw an exception");
    } catch (Exception e) {
    //what we want
    }
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) ChangeLogParseException(liquibase.exception.ChangeLogParseException) Test(org.junit.Test)

Example 3 with XMLChangeLogSAXParser

use of liquibase.parser.core.xml.XMLChangeLogSAXParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_byFile.

@Test
public void getParser_byFile() throws Exception {
    ChangeLogParserFactory.getInstance().getParsers().clear();
    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);
    assertTrue(xmlChangeLogParser == parser);
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) 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 4 with XMLChangeLogSAXParser

use of liquibase.parser.core.xml.XMLChangeLogSAXParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method unregister_instance.

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

Example 5 with XMLChangeLogSAXParser

use of liquibase.parser.core.xml.XMLChangeLogSAXParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParsers.

@Test
public void getParsers() throws Exception {
    ChangeLogParser parser = ChangeLogParserFactory.getInstance().getParser("asdf.xml", new JUnitResourceAccessor());
    assertNotNull(parser);
    assertTrue(parser instanceof XMLChangeLogSAXParser);
}
Also used : SqlChangeLogParser(liquibase.parser.core.sql.SqlChangeLogParser) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) XMLChangeLogSAXParser(liquibase.parser.core.xml.XMLChangeLogSAXParser) Test(org.junit.Test)

Aggregations

XMLChangeLogSAXParser (liquibase.parser.core.xml.XMLChangeLogSAXParser)8 Test (org.junit.Test)8 SqlChangeLogParser (liquibase.parser.core.sql.SqlChangeLogParser)7 JUnitResourceAccessor (liquibase.test.JUnitResourceAccessor)6 ChangeLogParser (liquibase.parser.ChangeLogParser)3 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)1 ChangeLogParseException (liquibase.exception.ChangeLogParseException)1 ChangeLogParserFactory (liquibase.parser.ChangeLogParserFactory)1