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
28 protected File getPropertyFile() {
29 File propFile = new File(getBasedir(), "/target/test-classes/unit/propertiesutils-test/basic.properties");
30
31 if (!propFile.exists()) {
32 propFile = null;
33 }
34
35 return propFile;
36 }
37
38 protected File getValidationFile() {
39 File validationFile =
40 new File(getBasedir(), "/target/test-classes/unit/propertiesutils-test/basic_validation.properties");
41
42 if (!validationFile.exists()) {
43 validationFile = null;
44 }
45
46 return validationFile;
47 }
48
49
50
51
52
53
54 public void testBasicLoadPropertyFF() throws Exception {
55 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, false, false);
56
57 assertNotNull(prop);
58 assertTrue(validateProperties(prop));
59 }
60
61
62
63
64
65
66 public void testBasicLoadPropertyTF() throws Exception {
67 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, true, false);
68
69 assertNotNull(prop);
70 assertTrue(validateProperties(prop));
71 }
72
73
74
75
76
77
78 public void testBasicLoadPropertyTT() throws Exception {
79 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, true, true);
80
81 validationProp.putAll(System.getProperties());
82 assertNotNull(prop);
83 assertTrue(validateProperties(prop));
84 }
85
86
87
88
89
90
91 public void testNonExistentProperty() throws Exception {
92 Properties prop = PropertyUtils.loadPropertyFile(propertyFile, true, true);
93
94 validationProp.putAll(System.getProperties());
95 assertNotNull(prop);
96 assertNull(prop.getProperty("does_not_exist"));
97 }
98 }