summaryrefslogtreecommitdiffstats
path: root/tests/server-side/com/vaadin
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-04-25 07:14:56 +0000
committerLeif Åstrand <leif@vaadin.com>2012-04-25 07:14:56 +0000
commit4e795bc38ff7ee8a41bd3885eea9ce5de2c281f1 (patch)
tree6422f9acac84151d1e20fd5fc58c27f5faf2e648 /tests/server-side/com/vaadin
parent935850bc41d42e29b75279a718312dbefc70f405 (diff)
downloadvaadin-framework-4e795bc38ff7ee8a41bd3885eea9ce5de2c281f1.tar.gz
vaadin-framework-4e795bc38ff7ee8a41bd3885eea9ce5de2c281f1.zip
Add test for $entry and make it ignore some false positives (#8699)
svn changeset:23626/svn branch:6.8
Diffstat (limited to 'tests/server-side/com/vaadin')
-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();
+ }
+ }
+ }
+
+ }
}