1 |
|
package org.liquibase.maven.plugins; |
2 |
|
|
3 |
|
import java.util.*; |
4 |
|
import org.codehaus.plexus.configuration.PlexusConfiguration; |
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
@author |
9 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (63) |
Complexity: 6 |
Complexity Density: 0.11 |
|
10 |
|
public class LiquibaseUpdateMojoTest extends AbstractLiquibaseMojoTest { |
11 |
|
|
12 |
|
private static final String CONFIG_FILE = "update/plugin_config.xml"; |
13 |
|
|
14 |
|
private static final Map<String, Object> DEFAULT_PROPERTIES; |
15 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
16 |
1
|
static {... |
17 |
1
|
DEFAULT_PROPERTIES = new HashMap<String, Object>(); |
18 |
1
|
DEFAULT_PROPERTIES.put("changeLogFile", "org/liquibase/changelog.xml"); |
19 |
1
|
DEFAULT_PROPERTIES.put("driver", "com.mysql.jdbc.Driver"); |
20 |
1
|
DEFAULT_PROPERTIES.put("url", "jdbc:mysql://localhost/eformat"); |
21 |
1
|
DEFAULT_PROPERTIES.put("username", "root"); |
22 |
1
|
DEFAULT_PROPERTIES.put("password", null); |
23 |
1
|
DEFAULT_PROPERTIES.put("verbose", true); |
24 |
|
} |
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
26 |
1
|
public void testNoPropertiesFile() throws Exception {... |
27 |
1
|
LiquibaseUpdate mojo = createUpdateMojo(); |
28 |
|
|
29 |
1
|
setVariableValueToObject(mojo, "propertyFile", null); |
30 |
1
|
setVariableValueToObject(mojo, "propertyFileWillOverride", false); |
31 |
|
|
32 |
1
|
loadPropertiesFileIfPresent(mojo); |
33 |
|
|
34 |
1
|
Map values = getVariablesAndValuesFromObject(mojo); |
35 |
1
|
checkValues(DEFAULT_PROPERTIES, values); |
36 |
|
} |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
38 |
1
|
public void testOverideAllWithPropertiesFile() throws Exception {... |
39 |
|
|
40 |
1
|
Properties props = new Properties(); |
41 |
1
|
props.setProperty("driver", "properties_driver_value"); |
42 |
1
|
props.setProperty("url", "properties_url_value"); |
43 |
1
|
props.setProperty("username", "properties_user_value"); |
44 |
1
|
props.setProperty("password", "properties_password_value"); |
45 |
1
|
props.setProperty("changeLogFile", "properties_changeLogFile_value"); |
46 |
1
|
createPropertiesFile("update/test.properties", props); |
47 |
|
|
48 |
1
|
LiquibaseUpdate mojo = createUpdateMojo(); |
49 |
1
|
setVariableValueToObject(mojo, "propertyFile", "update/test.properties"); |
50 |
1
|
setVariableValueToObject(mojo, "propertyFileWillOverride", true); |
51 |
1
|
loadPropertiesFileIfPresent(mojo); |
52 |
|
|
53 |
1
|
Map values = super.getVariablesAndValuesFromObject(mojo); |
54 |
1
|
checkValues(props, values); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
57 |
1
|
public void testOverrideAllButDriverWithPropertiesFile() throws Exception {... |
58 |
|
|
59 |
1
|
Properties props = new Properties(); |
60 |
1
|
props.setProperty("url", "properties_url_value"); |
61 |
1
|
props.setProperty("username", "properties_user_value"); |
62 |
1
|
props.setProperty("password", "properties_password_value"); |
63 |
1
|
props.setProperty("changeLogFile", "properties_changeLogFile_value"); |
64 |
1
|
createPropertiesFile("update/test.properties", props); |
65 |
|
|
66 |
1
|
LiquibaseUpdate mojo = createUpdateMojo(); |
67 |
1
|
setVariableValueToObject(mojo, "propertyFile", "update/test.properties"); |
68 |
1
|
setVariableValueToObject(mojo, "propertyFileWillOverride", true); |
69 |
1
|
loadPropertiesFileIfPresent(mojo); |
70 |
|
|
71 |
1
|
Map values = getVariablesAndValuesFromObject(mojo); |
72 |
1
|
checkValues(props, values); |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
1
|
assertEquals("Driver should be set to the default value", |
77 |
|
DEFAULT_PROPERTIES.get("driver"), |
78 |
|
values.get("driver")); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
81 |
1
|
public void testPropertiesFilePresentWithNoOverrideAndMissingProperty() throws Exception {... |
82 |
|
|
83 |
1
|
Properties props = new Properties(); |
84 |
1
|
props.setProperty("url", "properties_url_value"); |
85 |
1
|
props.setProperty("username", "properties_user_value"); |
86 |
1
|
props.setProperty("password", "properties_password_value"); |
87 |
1
|
props.setProperty("changeLogFile", "properties_changeLogFile_value"); |
88 |
1
|
createPropertiesFile("update/test.properties", props); |
89 |
|
|
90 |
1
|
LiquibaseUpdate mojo = createUpdateMojo(); |
91 |
1
|
setVariableValueToObject(mojo, "propertyFile", "update/test.properties"); |
92 |
1
|
setVariableValueToObject(mojo, "propertyFileWillOverride", false); |
93 |
1
|
loadPropertiesFileIfPresent(mojo); |
94 |
|
|
95 |
1
|
Map values = super.getVariablesAndValuesFromObject(mojo); |
96 |
|
|
97 |
|
|
98 |
1
|
Map expected = new HashMap<String, Object>(DEFAULT_PROPERTIES); |
99 |
1
|
expected.put("password", props.getProperty("password")); |
100 |
1
|
checkValues(expected, values); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
108 |
4
|
private LiquibaseUpdate createUpdateMojo() throws Exception {... |
109 |
4
|
LiquibaseUpdate mojo = new LiquibaseUpdate(); |
110 |
4
|
PlexusConfiguration config = loadConfiguration(CONFIG_FILE); |
111 |
4
|
configureMojo(mojo, config); |
112 |
4
|
return mojo; |
113 |
|
} |
114 |
|
} |