summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2011-08-23 15:40:53 +0000
committerArtur Signell <artur.signell@itmill.com>2011-08-23 15:40:53 +0000
commitd3b615cd22526538d561fa92b8060414862211bd (patch)
treed8b9c94f3ebee3e3350dc93e22e7d5a974d88a82
parent26d41ac211c4debae5f8323822bd5ec446dbacc0 (diff)
downloadvaadin-framework-d3b615cd22526538d561fa92b8060414862211bd.tar.gz
vaadin-framework-d3b615cd22526538d561fa92b8060414862211bd.zip
Test that ensures the license is included in all java files
svn changeset:20594/svn branch:6.7
-rw-r--r--tests/src/com/vaadin/tests/server/LicenseInJavaFiles.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/server/LicenseInJavaFiles.java b/tests/src/com/vaadin/tests/server/LicenseInJavaFiles.java
new file mode 100644
index 0000000000..5307da3abe
--- /dev/null
+++ b/tests/src/com/vaadin/tests/server/LicenseInJavaFiles.java
@@ -0,0 +1,49 @@
+package com.vaadin.tests.server;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashSet;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.commons.io.IOUtils;
+
+public class LicenseInJavaFiles extends TestCase {
+
+ public void testJavaFilesContainsLicense() throws IOException {
+ File srcDir = new File("src");
+ System.out.println(new File(".").getAbsolutePath());
+ HashSet<String> missing = new HashSet<String>();
+ checkForLicense(srcDir, missing);
+ if (!missing.isEmpty()) {
+ throw new RuntimeException(
+ "The following files are missing license information:\n"
+ + missing.toString());
+ }
+ }
+
+ private void checkForLicense(File srcDir, HashSet<String> missing)
+ throws IOException {
+ Assert.assertTrue("Source directory " + srcDir + " does not exist",
+ srcDir.exists());
+
+ for (File f : srcDir.listFiles()) {
+ if (f.isDirectory()) {
+ checkForLicense(f, missing);
+ } else if (f.getName().endsWith(".java")) {
+ checkForLicenseInFile(f, missing);
+ }
+ }
+ }
+
+ private void checkForLicenseInFile(File f, HashSet<String> missing)
+ throws IOException {
+ String contents = IOUtils.toString(new FileInputStream(f));
+ if (!contents.contains("@" + "ITMillApache2LicenseForJavaFiles" + "@")) {
+ missing.add(f.getPath());
+ }
+
+ }
+}