Clover Coverage Report - Liquibase Core 2.0.3-SNAPSHOT
Coverage timestamp: Sat Aug 6 2011 11:33:15 EDT
35   104   9   3.89
0   70   0.26   9
9     1  
1    
 
  ChangeFactoryTest       Line # 12 35 0% 9 0 100% 1.0
 
  (8)
 
1    package liquibase.change.core;
2   
3    import liquibase.change.Change;
4    import liquibase.change.ChangeFactory;
5    import static org.junit.Assert.*;
6    import org.junit.Before;
7    import org.junit.Test;
8   
9    /**
10    * Tests for {@link liquibase.change.ChangeFactory}
11    */
 
12    public class ChangeFactoryTest {
13   
 
14  8 toggle @Before
15    public void setup() {
16  8 ChangeFactory.reset();
17   
18    }
19   
 
20  1 toggle @Test
21    public void getInstance() {
22  1 assertNotNull(ChangeFactory.getInstance());
23   
24  1 assertTrue(ChangeFactory.getInstance() == ChangeFactory.getInstance());
25    }
26   
 
27  1 toggle @Test
28    public void register() {
29  1 ChangeFactory.getInstance().getRegistry().clear();
30   
31  1 assertEquals(0, ChangeFactory.getInstance().getRegistry().size());
32   
33  1 ChangeFactory.getInstance().register(CreateTableChange.class);
34   
35  1 assertEquals(1, ChangeFactory.getInstance().getRegistry().size());
36    }
37   
 
38  1 toggle @Test
39    public void unregister_instance() {
40  1 ChangeFactory factory = ChangeFactory.getInstance();
41   
42  1 factory.getRegistry().clear();
43   
44  1 assertEquals(0, factory.getRegistry().size());
45   
46  1 AddAutoIncrementChange change = new AddAutoIncrementChange();
47   
48  1 factory.register(CreateTableChange.class);
49  1 factory.register(change.getClass());
50  1 factory.register(DropTableChange.class);
51   
52  1 assertEquals(3, factory.getRegistry().size());
53   
54  1 factory.unregister(change.getChangeMetaData().getName());
55  1 assertEquals(2, factory.getRegistry().size());
56    }
57   
 
58  1 toggle @Test
59    public void unregister_doesNotExist() {
60  1 ChangeFactory factory = ChangeFactory.getInstance();
61   
62  1 factory.getRegistry().clear();
63   
64  1 assertEquals(0, factory.getRegistry().size());
65   
66  1 factory.register(CreateTableChange.class);
67  1 factory.register(AddAutoIncrementChange.class);
68  1 factory.register(DropTableChange.class);
69   
70  1 assertEquals(3, factory.getRegistry().size());
71   
72  1 factory.unregister("doesNoExist");
73  1 assertEquals(3, factory.getRegistry().size());
74    }
75   
 
76  1 toggle @Test
77    public void create_exists() {
78  1 Change change = ChangeFactory.getInstance().create("createTable");
79   
80  1 assertNotNull(change);
81  1 assertTrue(change instanceof CreateTableChange);
82   
83    }
84   
 
85  1 toggle @Test
86    public void builtInGeneratorsAreFound() {
87  1 assertTrue(ChangeFactory.getInstance().getRegistry().size() > 10);
88    }
89   
 
90  1 toggle @Test
91    public void create_notExists() {
92  1 Change change = ChangeFactory.getInstance().create("badChangeName");
93   
94  1 assertNull(change);
95   
96    }
97   
 
98  1 toggle @Test
99    public void reset() {
100  1 ChangeFactory instance1 = ChangeFactory.getInstance();
101  1 ChangeFactory.reset();
102  1 assertFalse(instance1 == ChangeFactory.getInstance());
103    }
104    }