1 package org.apache.maven.plugin.resources;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Properties;
24
25 public class AdvancePropertyUtilsTest
26 extends AbstractPropertyUtilsTest
27 {
28 final static protected String propFileName = "/target/test-classes/unit/propertiesutils-test/advance.properties";
29
30 final static protected String validationFileName =
31 "/target/test-classes/unit/propertiesutils-test/advance_validation.properties";
32
33 protected File getPropertyFile()
34 {
35
36 File propFile = new File( getBasedir(), propFileName );
37
38 if ( !propFile.exists() )
39 {
40 propFile = null;
41 }
42
43 return propFile;
44 }
45
46 protected File getValidationFile()
47 {
48
49 File validationFile = new File( getBasedir(), validationFileName );
50
51 if ( !validationFile.exists() )
52 {
53 validationFile = null;
54 }
55
56 return validationFile;
57 }
58
59
60
61
62
63
64
65 public void testAdvanceLoadProperty_FF()
66 throws Exception
67 {
68 Properties prop;
69 boolean throwsException = false;
70
71 try
72 {
73 prop = PropertyUtils.loadPropertyFile( propertyFile, false, false );
74 }
75 catch ( Exception ex )
76 {
77 prop = null;
78 throwsException = true;
79 }
80
81 assertFalse( throwsException );
82 assertNotNull( prop );
83 assertTrue( validateProperties( prop ) );
84
85 }
86
87
88
89
90
91
92
93 public void testAdvanceLoadProperty_TF()
94 throws Exception
95 {
96 Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, false );
97
98 assertNotNull( prop );
99 assertTrue( validateProperties( prop ) );
100 }
101
102
103
104
105
106
107
108 public void testAdvanceLoadProperty_TT()
109 throws Exception
110 {
111 Properties prop = PropertyUtils.loadPropertyFile( propertyFile, true, true );
112
113
114
115 validationProp.putAll( System.getProperties() );
116 assertNotNull( prop );
117 assertTrue( validateProperties( prop ) );
118 }
119 }