001: package liquibase.parser.filter;
002:
003: import liquibase.ChangeSet;
004: import static org.junit.Assert.*;
005: import org.junit.Test;
006:
007: public class ContextChangeSetFilterTest {
008:
009: @Test
010: public void emptyContexts() {
011: ContextChangeSetFilter filter = new ContextChangeSetFilter();
012:
013: assertTrue(filter.accepts(new ChangeSet(null, null, false,
014: false, null, null, "test1", null)));
015: assertTrue(filter.accepts(new ChangeSet(null, null, false,
016: false, null, null, "test2", null)));
017: assertTrue(filter.accepts(new ChangeSet(null, null, false,
018: false, null, null, "test1, test2", null)));
019: assertTrue(filter.accepts(new ChangeSet(null, null, false,
020: false, null, null, null, null)));
021: }
022:
023: @Test
024: public void nullContexts() {
025: ContextChangeSetFilter filter = new ContextChangeSetFilter(null);
026:
027: assertTrue(filter.accepts(new ChangeSet(null, null, false,
028: false, null, null, "test1", null)));
029: assertTrue(filter.accepts(new ChangeSet(null, null, false,
030: false, null, null, "test2", null)));
031: assertTrue(filter.accepts(new ChangeSet(null, null, false,
032: false, null, null, "test1, test2", null)));
033: assertTrue(filter.accepts(new ChangeSet(null, null, false,
034: false, null, null, null, null)));
035: }
036:
037: @Test
038: public void nullListContexts() {
039: ContextChangeSetFilter filter = new ContextChangeSetFilter(
040: new String[] { null });
041:
042: assertTrue(filter.accepts(new ChangeSet(null, null, false,
043: false, null, null, "test1", null)));
044: assertTrue(filter.accepts(new ChangeSet(null, null, false,
045: false, null, null, "test2", null)));
046: assertTrue(filter.accepts(new ChangeSet(null, null, false,
047: false, null, null, "test1, test2", null)));
048: assertTrue(filter.accepts(new ChangeSet(null, null, false,
049: false, null, null, null, null)));
050: }
051:
052: @Test
053: public void singleContexts() {
054: ContextChangeSetFilter filter = new ContextChangeSetFilter(
055: "test1");
056:
057: assertTrue(filter.accepts(new ChangeSet(null, null, false,
058: false, null, null, "test1", null)));
059: assertTrue(filter.accepts(new ChangeSet(null, null, false,
060: false, null, null, "test1, test2", null)));
061: assertFalse(filter.accepts(new ChangeSet(null, null, false,
062: false, null, null, "test2", null)));
063: assertTrue(filter.accepts(new ChangeSet(null, null, false,
064: false, null, null, null, null)));
065: }
066:
067: @Test
068: public void multiContexts() {
069: ContextChangeSetFilter filter = new ContextChangeSetFilter(
070: "test1", "test2");
071:
072: assertTrue(filter.accepts(new ChangeSet(null, null, false,
073: false, null, null, "test1", null)));
074: assertTrue(filter.accepts(new ChangeSet(null, null, false,
075: false, null, null, "test2", null)));
076: assertTrue(filter.accepts(new ChangeSet(null, null, false,
077: false, null, null, "test1, test2", null)));
078: assertFalse(filter.accepts(new ChangeSet(null, null, false,
079: false, null, null, "test3", null)));
080: assertTrue(filter.accepts(new ChangeSet(null, null, false,
081: false, null, null, "test3, test1", null)));
082: assertTrue(filter.accepts(new ChangeSet(null, null, false,
083: false, null, null, null, null)));
084: }
085:
086: @Test
087: public void multiContextsSingeParameter() {
088: ContextChangeSetFilter filter = new ContextChangeSetFilter(
089: "test1, test2");
090:
091: assertTrue(filter.accepts(new ChangeSet(null, null, false,
092: false, null, null, "test1", null)));
093: assertTrue(filter.accepts(new ChangeSet(null, null, false,
094: false, null, null, "test2", null)));
095: assertTrue(filter.accepts(new ChangeSet(null, null, false,
096: false, null, null, "test1, test2", null)));
097: assertFalse(filter.accepts(new ChangeSet(null, null, false,
098: false, null, null, "test3", null)));
099: assertTrue(filter.accepts(new ChangeSet(null, null, false,
100: false, null, null, "test3, test1", null)));
101: assertTrue(filter.accepts(new ChangeSet(null, null, false,
102: false, null, null, null, null)));
103: }
104: }
|