Clover Coverage Report - Liquibase Core 2.0.3-SNAPSHOT
Coverage timestamp: Sat Aug 6 2011 11:33:15 EDT
21   67   6   3.5
0   46   0.29   6
6     1  
1    
 
  ChangeLogParametersTest       Line # 11 21 0% 6 0 100% 1.0
 
  (6)
 
1    package liquibase.changelog;
2   
3    import org.junit.Before;
4    import org.junit.Test;
5    import static org.junit.Assert.*;
6    import liquibase.database.core.H2Database;
7   
8    import java.util.Arrays;
9   
10   
 
11    public class ChangeLogParametersTest {
12   
 
13  1 toggle @Test
14    public void setParameterValue_doubleSet() {
15  1 ChangeLogParameters changeLogParameters = new ChangeLogParameters();
16   
17  1 changeLogParameters.set("doubleSet", "originalValue");
18  1 changeLogParameters.set("doubleSet", "newValue");
19   
20  1 assertEquals("re-setting a param should not overwrite the value (like how ant works)", "originalValue", changeLogParameters.getValue("doubleSet"));
21    }
22   
 
23  1 toggle @Test
24    public void getParameterValue_systemProperty() {
25  1 ChangeLogParameters changeLogParameters = new ChangeLogParameters();
26   
27  1 assertEquals(System.getProperty("user.name"), changeLogParameters.getValue("user.name"));
28    }
29   
 
30  1 toggle @Test
31    public void setParameterValue_doubleSetButSecondWrongDatabase() {
32  1 ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
33   
34  1 changeLogParameters.set("doubleSet", "originalValue", null, "baddb");
35  1 changeLogParameters.set("doubleSet", "newValue");
36   
37  1 assertEquals("newValue", changeLogParameters.getValue("doubleSet"));
38    }
39   
 
40  1 toggle @Test
41    public void setParameterValue_multiDatabase() {
42  1 ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
43   
44  1 changeLogParameters.set("doubleSet", "originalValue", null, "baddb, h2");
45   
46  1 assertEquals("originalValue", changeLogParameters.getValue("doubleSet"));
47    }
48   
 
49  1 toggle @Test
50    public void setParameterValue_rightDBWrongContext() {
51  1 ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
52  1 changeLogParameters.setContexts(Arrays.asList("junit"));
53   
54  1 changeLogParameters.set("doubleSet", "originalValue", "anotherContext", "baddb, h2");
55   
56  1 assertNull(changeLogParameters.getValue("doubleSet"));
57    }
 
58  1 toggle @Test
59    public void setParameterValue_rightDBRightContext() {
60  1 ChangeLogParameters changeLogParameters = new ChangeLogParameters(new H2Database());
61  1 changeLogParameters.setContexts(Arrays.asList("junit"));
62   
63  1 changeLogParameters.set("doubleSet", "originalValue", "junit", "baddb, h2");
64   
65  1 assertEquals("originalValue", changeLogParameters.getValue("doubleSet"));
66    }
67    }