summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-01-07 22:16:45 -0800
committerGeorge Fraser <george@fivetran.com>2019-01-07 22:16:45 -0800
commitf6fc3a421ac4b51a43352da53f056e8c17b94647 (patch)
tree21b7c460033b750aa6d521aeeadb479001ee8612 /src/test/java
parent7e9c41c98f7938166bd34d557f18fb3cf5d1bdd0 (diff)
downloadjava-language-server-f6fc3a421ac4b51a43352da53f056e8c17b94647.zip
Remove StringFileObject, FileManagerWrapper
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/javacs/BenchmarkPruner.java10
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java2
-rw-r--r--src/test/java/org/javacs/PrunerTest.java13
3 files changed, 12 insertions, 13 deletions
diff --git a/src/test/java/org/javacs/BenchmarkPruner.java b/src/test/java/org/javacs/BenchmarkPruner.java
index 4e9f10a..1daf169 100644
--- a/src/test/java/org/javacs/BenchmarkPruner.java
+++ b/src/test/java/org/javacs/BenchmarkPruner.java
@@ -15,12 +15,12 @@ import org.openjdk.jmh.annotations.*;
@Fork(1)
public class BenchmarkPruner {
private static Path sourceRoot = Paths.get("src/main/java").normalize();
- private static List<StringFileObject> files = files(false);
- private static List<StringFileObject> pruned = files(true);
+ private static List<SourceFileObject> files = files(false);
+ private static List<SourceFileObject> pruned = files(true);
- private static List<StringFileObject> files(boolean prune) {
+ private static List<SourceFileObject> files(boolean prune) {
try {
- var files = new ArrayList<StringFileObject>();
+ var files = new ArrayList<SourceFileObject>();
var dir = Paths.get("src/main/java/org/javacs").normalize();
var it = Files.list(dir).iterator();
while (it.hasNext()) {
@@ -30,7 +30,7 @@ public class BenchmarkPruner {
if (prune) {
contents = Pruner.prune(file.toUri(), contents, "isWord");
}
- files.add(new StringFileObject(contents, file.toUri()));
+ files.add(new SourceFileObject(file, contents));
}
return files;
} catch (IOException e) {
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java
index b9419ad..a0618da 100644
--- a/src/test/java/org/javacs/JavaCompilerServiceTest.java
+++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java
@@ -64,7 +64,7 @@ public class JavaCompilerServiceTest {
return join.toString();
}
- private URI resourceUri(String resourceFile) {
+ static URI resourceUri(String resourceFile) {
var root = JavaCompilerServiceTest.simpleProjectSrc();
var file = root.resolve(resourceFile);
return file.toUri();
diff --git a/src/test/java/org/javacs/PrunerTest.java b/src/test/java/org/javacs/PrunerTest.java
index 50e511f..9d649c2 100644
--- a/src/test/java/org/javacs/PrunerTest.java
+++ b/src/test/java/org/javacs/PrunerTest.java
@@ -1,45 +1,44 @@
package org.javacs;
import static org.hamcrest.Matchers.*;
-import static org.javacs.JavaCompilerServiceTest.contents;
+import static org.javacs.JavaCompilerServiceTest.*;
import static org.junit.Assert.*;
-import java.net.URI;
import org.junit.Test;
public class PrunerTest {
@Test
public void pruneMethods() {
- var actual = Pruner.prune(URI.create("/PruneMethods.java"), contents("PruneMethods.java"), 6, 19);
+ var actual = Pruner.prune(resourceUri("PruneMethods.java"), contents("PruneMethods.java"), 6, 19);
var expected = contents("PruneMethods_erased.java");
assertThat(actual, equalToIgnoringWhiteSpace(expected));
}
@Test
public void pruneToEndOfBlock() {
- var actual = Pruner.prune(URI.create("/PruneToEndOfBlock.java"), contents("PruneToEndOfBlock.java"), 4, 18);
+ var actual = Pruner.prune(resourceUri("PruneToEndOfBlock.java"), contents("PruneToEndOfBlock.java"), 4, 18);
var expected = contents("PruneToEndOfBlock_erased.java");
assertThat(actual, equalToIgnoringWhiteSpace(expected));
}
@Test
public void pruneMiddle() {
- var actual = Pruner.prune(URI.create("/PruneMiddle.java"), contents("PruneMiddle.java"), 4, 12);
+ var actual = Pruner.prune(resourceUri("PruneMiddle.java"), contents("PruneMiddle.java"), 4, 12);
var expected = contents("PruneMiddle_erased.java");
assertThat(actual, equalToIgnoringWhiteSpace(expected));
}
@Test
public void pruneDot() {
- var actual = Pruner.prune(URI.create("/PruneDot.java"), contents("PruneDot.java"), 3, 11);
+ var actual = Pruner.prune(resourceUri("PruneDot.java"), contents("PruneDot.java"), 3, 11);
var expected = contents("PruneDot_erased.java");
assertThat(actual, equalToIgnoringWhiteSpace(expected));
}
@Test
public void pruneWords() {
- var actual = Pruner.prune(URI.create("/PruneWords.java"), contents("PruneWords.java"), "word");
+ var actual = Pruner.prune(resourceUri("PruneWords.java"), contents("PruneWords.java"), "word");
var expected = contents("PruneWords_erased.java");
assertThat(actual, equalToIgnoringWhiteSpace(expected));
}