1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.resources;
20
21 import java.io.File;
22 import java.util.Properties;
23
24 import org.apache.maven.shared.filtering.PropertyUtils;
25
26 public class BasicPropertyUtilsTest extends AbstractPropertyUtilsTest {
27 protected static final String validationFileName =
28 "/target/test-classes/unit/propertiesutils-test/basic_validation.properties";
29
30 protected static final String propFileName = "/target/test-classes/unit/propertiesutils-test/basic.properties";
31
32 protected File getPropertyFile() {
33 File propFile = new File(getBasedir(), propFileName);
34
35 if (!propFile.exists()) {
36 propFile = null;
37 }
38
39 return propFile;
40 }
41
42 protected File getValidationFile() {
43 File validationFile = new File(getBasedir(), validationFileName);
44
45 if (!validationFile.exists()) {
46 validationFile = null;
47 }
48
49 return validationFile;
50 }
51
52
53
54
55
56
57 public void testBasicLoadProperty_FF() throws Exception {
58 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, false, false);
59
60 assertNotNull(prop);
61 assertTrue(validateProperties(prop));
62 }
63
64
65
66
67
68
69 public void testBasicLoadProperty_TF() throws Exception {
70 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, true, false);
71
72 assertNotNull(prop);
73 assertTrue(validateProperties(prop));
74 }
75
76
77
78
79
80
81 public void testBasicLoadProperty_TT() throws Exception {
82 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, true, true);
83
84 validationProp.putAll(System.getProperties());
85 assertNotNull(prop);
86 assertTrue(validateProperties(prop));
87 }
88
89
90
91
92
93
94 public void testNonExistentProperty() throws Exception {
95 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, true, true);
96
97 validationProp.putAll(System.getProperties());
98 assertNotNull(prop);
99 assertNull(prop.getProperty("does_not_exist"));
100 }
101 }