diff options
author | George Fraser <george@fivetran.com> | 2018-06-23 11:32:53 -0700 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2018-06-23 11:32:53 -0700 |
commit | 67bae42e1055f60f99aa433767211ea4e87e4b21 (patch) | |
tree | 457498df11f5d7c1e92f4035d4a5e1bcd18ed137 /src/test | |
parent | 6b370a7112a6b2cfe711dc201883e8ad1dccee4e (diff) | |
download | java-language-server-67bae42e1055f60f99aa433767211ea4e87e4b21.zip |
Fix lint
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/javacs/JavaCompilerServiceTest.java | 17 | ||||
-rw-r--r-- | src/test/resources/HasError.java | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java index 652c3b6..7f7c580 100644 --- a/src/test/java/org/javacs/JavaCompilerServiceTest.java +++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java @@ -14,6 +14,8 @@ import java.util.*; import java.util.logging.*; import java.util.stream.Collectors; import javax.lang.model.element.*; +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; import org.junit.Test; public class JavaCompilerServiceTest { @@ -38,6 +40,14 @@ public class JavaCompilerServiceTest { } } + private URI resourceUri(String resourceFile) { + try { + return JavaCompilerServiceTest.class.getResource(resourceFile).toURI(); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + @Test public void element() { Element found = compiler.element(URI.create("/HelloWorld.java"), contents("/HelloWorld.java"), 3, 24); @@ -205,4 +215,11 @@ public class JavaCompilerServiceTest { assertThat( found.overloads, containsInAnyOrder(hasToString("print(int)"), hasToString("print(java.lang.String)"))); } + + @Test + public void lint() { + List<Diagnostic<? extends JavaFileObject>> diags = + compiler.lint(Collections.singleton(resourceUri("/HasError.java"))); + assertThat(diags, not(empty())); + } } diff --git a/src/test/resources/HasError.java b/src/test/resources/HasError.java new file mode 100644 index 0000000..ad2fbe2 --- /dev/null +++ b/src/test/resources/HasError.java @@ -0,0 +1,5 @@ +class HasError { + void test() { + String x = 1; + } +}
\ No newline at end of file |