Search in sources :

Example 1 with MockChangeLogParser

use of liquibase.parser.MockChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_shouldNotGiveAbilityToChangeParsers.

@Test
public void getParser_shouldNotGiveAbilityToChangeParsers() {
    ChangeLogParserFactory factory = ChangeLogParserFactory.getInstance();
    MockChangeLogParser mockChangeLogParser = new MockChangeLogParser();
    factory.getParsers().add(mockChangeLogParser);
    assertThat(factory.getParsers(), not(hasItem(mockChangeLogParser)));
}
Also used : MockChangeLogParser(liquibase.parser.MockChangeLogParser) ChangeLogParserFactory(liquibase.parser.ChangeLogParserFactory) Test(org.junit.Test)

Example 2 with MockChangeLogParser

use of liquibase.parser.MockChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method register.

@Test
public void register() {
    ChangeLogParserFactory.getInstance().unregisterAllParsers();
    assumeThat(ChangeLogParserFactory.getInstance().getParsers(), empty());
    ChangeLogParserFactory.getInstance().register(new MockChangeLogParser(".test"));
    assertEquals(1, ChangeLogParserFactory.getInstance().getParsers().size());
}
Also used : MockChangeLogParser(liquibase.parser.MockChangeLogParser) Test(org.junit.Test)

Example 3 with MockChangeLogParser

use of liquibase.parser.MockChangeLogParser 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 4 with MockChangeLogParser

use of liquibase.parser.MockChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method unregisterAllParsers_ShouldRemoveAllParsers.

@Test
public void unregisterAllParsers_ShouldRemoveAllParsers() {
    ChangeLogParserFactory factory = ChangeLogParserFactory.getInstance();
    factory.register(new MockChangeLogParser());
    assumeThat(factory.getParsers(), not(empty()));
    factory.unregisterAllParsers();
    assertThat(factory.getParsers(), empty());
}
Also used : MockChangeLogParser(liquibase.parser.MockChangeLogParser) ChangeLogParserFactory(liquibase.parser.ChangeLogParserFactory) Test(org.junit.Test)

Example 5 with MockChangeLogParser

use of liquibase.parser.MockChangeLogParser in project liquibase by liquibase.

the class ChangeLogParserFactoryTest method getParser_shouldAssumePriority.

@Test
public void getParser_shouldAssumePriority() throws Exception {
    ChangeLogParserFactory factory = ChangeLogParserFactory.getInstance();
    MockChangeLogParser higherPriorityParser = new MockChangeLogParser("banana") {

        @Override
        public int getPriority() {
            return Integer.MAX_VALUE;
        }
    };
    factory.register(new MockChangeLogParser("banana"));
    factory.register(higherPriorityParser);
    assertEquals(higherPriorityParser, factory.getParser("banana", new JUnitResourceAccessor()));
}
Also used : MockChangeLogParser(liquibase.parser.MockChangeLogParser) ChangeLogParserFactory(liquibase.parser.ChangeLogParserFactory) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) Test(org.junit.Test)

Aggregations

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