27
27
import java .io .IOException ;
28
28
import java .util .Locale ;
29
29
30
+ import org .apache .commons .io .FileUtils ;
30
31
import org .apache .commons .lang3 .StringUtils ;
31
- import org .codehaus .plexus .util .FileUtils ;
32
32
import org .w3c .dom .Document ;
33
33
34
34
/**
@@ -54,11 +54,11 @@ protected void setUp() throws Exception {
54
54
public void testDefaultConfiguration () throws Exception {
55
55
File generatedReport =
56
56
generateReport ("cpd" , "default-configuration/cpd-default-configuration-plugin-config.xml" );
57
- assertTrue (FileUtils . fileExists (generatedReport .getAbsolutePath ()));
57
+ assertTrue (new File (generatedReport .getAbsolutePath ()). exists ( ));
58
58
59
59
// check if the CPD files were generated
60
60
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
61
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
61
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
62
62
63
63
// check the contents of cpd.html
64
64
String str = readFile (generatedReport );
@@ -82,9 +82,9 @@ public void testTxtFormat() throws Exception {
82
82
83
83
// check if the CPD files were generated
84
84
File generatedFile = new File (getBasedir (), "target/test/unit/custom-configuration/target/cpd.xml" );
85
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
85
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
86
86
generatedFile = new File (getBasedir (), "target/test/unit/custom-configuration/target/cpd.txt" );
87
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
87
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
88
88
89
89
// check the contents of cpd.txt
90
90
String str = readFile (generatedFile );
@@ -101,11 +101,11 @@ public void testTxtFormat() throws Exception {
101
101
*/
102
102
public void testCustomConfiguration () throws Exception {
103
103
File generatedReport = generateReport ("cpd" , "custom-configuration/cpd-custom-configuration-plugin-config.xml" );
104
- assertTrue (FileUtils . fileExists (generatedReport .getAbsolutePath ()));
104
+ assertTrue (new File (generatedReport .getAbsolutePath ()). exists ( ));
105
105
106
106
// check if the CPD files were generated
107
107
File generatedFile = new File (getBasedir (), "target/test/unit/custom-configuration/target/cpd.csv" );
108
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
108
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
109
109
110
110
String str = readFile (generatedReport );
111
111
// Contents that should NOT be in the report
@@ -162,7 +162,7 @@ public void testWriteNonHtml() throws Exception {
162
162
163
163
// check if the CPD files were generated
164
164
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
165
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
165
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
166
166
167
167
DocumentBuilder builder = DocumentBuilderFactory .newInstance ().newDocumentBuilder ();
168
168
Document pmdCpdDocument = builder .parse (generatedFile );
@@ -183,7 +183,7 @@ public void testIncludeXmlInSite() throws Exception {
183
183
generateReport ("cpd" , "default-configuration/cpd-report-include-xml-in-site-plugin-config.xml" );
184
184
185
185
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
186
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
186
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
187
187
188
188
DocumentBuilder builder = DocumentBuilderFactory .newInstance ().newDocumentBuilder ();
189
189
Document pmdCpdDocument = builder .parse (generatedFile );
@@ -193,7 +193,7 @@ public void testIncludeXmlInSite() throws Exception {
193
193
assertTrue (str .contains ("</pmd-cpd>" ));
194
194
195
195
File siteReport = new File (getBasedir (), "target/test/unit/default-configuration/target/site/cpd.xml" );
196
- assertTrue (FileUtils . fileExists (siteReport .getAbsolutePath ()));
196
+ assertTrue (new File (siteReport .getAbsolutePath ()). exists ( ));
197
197
String siteReportContent = readFile (siteReport );
198
198
assertTrue (siteReportContent .contains ("</pmd-cpd>" ));
199
199
assertEquals (str , siteReportContent );
@@ -202,13 +202,13 @@ public void testIncludeXmlInSite() throws Exception {
202
202
public void testSkipEmptyReportConfiguration () throws Exception {
203
203
// verify the generated files do not exist because PMD was skipped
204
204
File generatedReport = generateReport ("cpd" , "empty-report/cpd-skip-empty-report-plugin-config.xml" );
205
- assertFalse (FileUtils . fileExists (generatedReport .getAbsolutePath ()));
205
+ assertFalse (new File (generatedReport .getAbsolutePath ()). exists ( ));
206
206
}
207
207
208
208
public void testEmptyReportConfiguration () throws Exception {
209
209
// verify the generated files do exist, even if there are no violations
210
210
File generatedReport = generateReport ("cpd" , "empty-report/cpd-empty-report-plugin-config.xml" );
211
- assertTrue (FileUtils . fileExists (generatedReport .getAbsolutePath ()));
211
+ assertTrue (new File (generatedReport .getAbsolutePath ()). exists ( ));
212
212
213
213
String str = readFile (generatedReport );
214
214
assertFalse (lowerCaseContains (str , "Hello.java" ));
@@ -224,7 +224,7 @@ public void testCpdEncodingConfiguration() throws Exception {
224
224
225
225
// check if the CPD files were generated
226
226
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
227
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
227
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
228
228
String str = readFile (generatedFile );
229
229
assertTrue (lowerCaseContains (str , "AppSample.java" ));
230
230
} finally {
@@ -237,7 +237,7 @@ public void testCpdJavascriptConfiguration() throws Exception {
237
237
238
238
// verify the generated file to exist and violations are reported
239
239
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
240
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
240
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
241
241
String str = readFile (generatedFile );
242
242
assertTrue (lowerCaseContains (str , "Sample.js" ));
243
243
assertTrue (lowerCaseContains (str , "SampleDup.js" ));
@@ -248,7 +248,7 @@ public void testCpdJspConfiguration() throws Exception {
248
248
249
249
// verify the generated file to exist and violations are reported
250
250
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
251
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
251
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
252
252
String str = readFile (generatedFile );
253
253
assertTrue (lowerCaseContains (str , "sample.jsp" ));
254
254
assertTrue (lowerCaseContains (str , "sampleDup.jsp" ));
@@ -259,7 +259,7 @@ public void testExclusionsConfiguration() throws Exception {
259
259
260
260
// verify the generated file to exist and no duplications are reported
261
261
File generatedFile = new File (getBasedir (), "target/test/unit/default-configuration/target/cpd.xml" );
262
- assertTrue (FileUtils . fileExists (generatedFile .getAbsolutePath ()));
262
+ assertTrue (new File (generatedFile .getAbsolutePath ()). exists ( ));
263
263
String str = readFile (generatedFile );
264
264
assertEquals (0 , StringUtils .countMatches (str , "<duplication" ));
265
265
}
0 commit comments