summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2012-02-07 11:51:48 +0000
committerArtur Signell <artur.signell@itmill.com>2012-02-07 11:51:48 +0000
commitdf20381a91ded3647efac616f61e6820e5618a0e (patch)
tree1d0575ca96d2943289be35ed78fd233b02768f39 /tests
parent8d761b45cc1f677a735aed4d8a80de70464772ce (diff)
downloadvaadin-framework-df20381a91ded3647efac616f61e6820e5618a0e.tar.gz
vaadin-framework-df20381a91ded3647efac616f61e6820e5618a0e.zip
[merge from 6.7] Ensure that all opened FileInputStreams are closed
svn changeset:22944/svn branch:6.8
Diffstat (limited to 'tests')
-rw-r--r--tests/server-side/com/vaadin/tests/server/SourceFileChecker.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java
index 3115ce49c8..453aab5af8 100644
--- a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java
+++ b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java
@@ -134,20 +134,37 @@ public class SourceFileChecker extends TestCase {
}
}
- class DosNewlineDetector implements FileValidator {
-
+ abstract class FileContentsValidator implements FileValidator {
public void validateFile(File f) throws Exception {
- String contents = IOUtils.toString(new FileInputStream(f));
+ FileInputStream fis = new FileInputStream(f);
+ String contents = IOUtils.toString(fis);
+ fis.close();
+ validateContents(f, contents);
+ }
+
+ protected abstract void validateContents(File f, String contents)
+ throws Exception;
+
+ }
+
+ class DosNewlineDetector extends FileContentsValidator {
+
+ @Override
+ protected void validateContents(File f, String contents)
+ throws Exception {
if (contents.contains("\r\n")) {
throw new IllegalArgumentException();
}
}
+
}
- class LicenseChecker implements FileValidator {
- public void validateFile(File f) throws Exception {
- String contents = IOUtils.toString(new FileInputStream(f));
+ class LicenseChecker extends FileContentsValidator {
+
+ @Override
+ protected void validateContents(File f, String contents)
+ throws Exception {
if (!contents.contains("@" + "VaadinApache2LicenseForJavaFiles"
+ "@")) {
throw new IllegalArgumentException();