summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/server-side/com/vaadin/tests/server/SourceFileChecker.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java
index 453aab5af8..9906990165 100644
--- a/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java
+++ b/tests/server-side/com/vaadin/tests/server/SourceFileChecker.java
@@ -5,6 +5,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import junit.framework.Assert;
import junit.framework.TestCase;
@@ -81,6 +83,17 @@ public class SourceFileChecker extends TestCase {
}
}
+ public void testGwtFilesUsingEntry() {
+ Set<String> ignore = new HashSet<String>(alwaysIgnore);
+ ignore.add(externalJavaFiles);
+ validateFiles(
+ SRC_DIR,
+ new GwtEntryChecker(),
+ ignore,
+ "The following files might export javscript callbacks without $entry:\n{0}",
+ ".java");
+ }
+
public interface FileValidator {
void validateFile(File f) throws Exception;
}
@@ -171,4 +184,33 @@ public class SourceFileChecker extends TestCase {
}
}
}
+
+ class GwtEntryChecker extends FileContentsValidator {
+ // Matches e.g.
+ // @com.vaadin.terminal.gwt.client.HistoryImplIEVaadin::escapeHtml(
+ private final Matcher matcher = Pattern.compile("@[\\w.]+::\\w+\\(")
+ .matcher("");
+
+ @Override
+ protected void validateContents(File f, String contents)
+ throws Exception {
+ matcher.reset(contents);
+ while (matcher.find()) {
+ int start = matcher.start();
+
+ // Search backwards to find index of native block start
+ int nativeBlockStart = contents.lastIndexOf("/*-{", start);
+
+ // Get contents between block start and our match
+ String beforeMatchInBlock = contents.substring(
+ nativeBlockStart, start);
+
+ // Fail if there's no $entry
+ if (!beforeMatchInBlock.contains("$entry")) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ }
}