Test code improvements · apache/maven-jxr@f04a98f (original) (raw)
`@@ -19,10 +19,9 @@
`
19
19
` * under the License.
`
20
20
` */
`
21
21
``
22
``
`-
import java.io.BufferedReader;
`
23
22
`import java.io.File;
`
24
``
`-
import java.io.FileReader;
`
25
23
`import java.io.IOException;
`
``
24
`+
import java.nio.file.Files;
`
26
25
``
27
26
`import org.apache.maven.plugin.testing.AbstractMojoTestCase;
`
28
27
``
`@@ -59,41 +58,18 @@ public void testSourceDir()
`
59
58
`assertTrue( new File( xrefTestDir, "stylesheet.css" ).exists() );
`
60
59
``
61
60
`// check if there's a link to the javadoc files
`
62
``
`-
String str = readFile( new File( xrefTestDir, "testsourcedir/test/AppSampleTest.html" ) );
`
63
``
`-
assertTrue( str.toLowerCase().indexOf( "/apidocs/testsourcedir/test/AppSample.html"".toLowerCase() ) == -1 );
`
64
``
-
65
``
`-
str = readFile( new File( xrefTestDir, "testsourcedir/test/AppTest.html" ) );
`
66
``
`-
assertTrue( str.toLowerCase().indexOf( "/apidocs/testsourcedir/test/App.html"".toLowerCase() ) == -1 );
`
67
``
-
68
``
`-
}
`
69
``
-
70
``
`-
protected void tearDown()
`
71
``
`-
throws Exception
`
72
``
`-
{
`
``
61
`+
String str = readFile( xrefTestDir, "testsourcedir/test/AppSampleTest.html" );
`
``
62
`+
assertFalse( str.toLowerCase().contains( "/apidocs/testsourcedir/test/AppSample.html"".toLowerCase() ) );
`
73
63
``
``
64
`+
str = readFile( xrefTestDir, "testsourcedir/test/AppTest.html" );
`
``
65
`+
assertFalse( str.toLowerCase().contains( "/apidocs/testsourcedir/test/App.html"".toLowerCase() ) );
`
74
66
` }
`
75
67
``
76
68
`/**
`
77
69
` * Read the contents of the specified file object into a string
`
78
``
`-
`
79
``
`-
- @param file the file to be read
`
80
``
`-
- @return a String object that contains the contents of the file
`
81
``
`-
- @throws java.io.IOException
`
82
70
` */
`
83
``
`-
private String readFile( File file )
`
84
``
`-
throws IOException
`
``
71
`+
private String readFile( File xrefTestDir, String fileName ) throws IOException
`
85
72
` {
`
86
``
`-
String str = "", strTmp = "";
`
87
``
-
88
``
`-
try ( BufferedReader in = new BufferedReader( new FileReader( file ) ) )
`
89
``
`-
{
`
90
``
`-
while ( ( strTmp = in.readLine() ) != null )
`
91
``
`-
{
`
92
``
`-
str = str + ' ' + strTmp;
`
93
``
`-
}
`
94
``
`-
}
`
95
``
-
96
``
`-
return str;
`
``
73
`+
return new String( Files.readAllBytes( xrefTestDir.toPath().resolve( fileName ) ) );
`
97
74
` }
`
98
``
-
99
75
`}
`