summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2018-09-16 10:30:38 -0700
committerGeorge Fraser <george@fivetran.com>2018-09-16 10:30:38 -0700
commite60ee6dc55943e0252cc3dbb66a5ffcc453d4b78 (patch)
tree04bee4226dcb4e356ece4569899563e9e37514b0 /src/test
parent2f20929eaa41bb0af83340b935e9ccd0361e51a3 (diff)
downloadjava-language-server-e60ee6dc55943e0252cc3dbb66a5ffcc453d4b78.zip
Revive externalDependencies and classPath
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/javacs/InferBazelConfigTest.java4
-rw-r--r--src/test/java/org/javacs/InferConfigTest.java62
2 files changed, 55 insertions, 11 deletions
diff --git a/src/test/java/org/javacs/InferBazelConfigTest.java b/src/test/java/org/javacs/InferBazelConfigTest.java
index d3e04fc..f5dcd80 100644
--- a/src/test/java/org/javacs/InferBazelConfigTest.java
+++ b/src/test/java/org/javacs/InferBazelConfigTest.java
@@ -7,6 +7,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Collections;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -15,7 +16,8 @@ public class InferBazelConfigTest {
private Path bazelWorkspace = Paths.get("src/test/test-project/bazel-workspace"),
bazelTemp = Paths.get("src/test/test-project/bazel-temp");
- private InferConfig bazel = new InferConfig(bazelWorkspace, Paths.get("nowhere"));
+ private InferConfig bazel =
+ new InferConfig(bazelWorkspace, Collections.emptySet(), Paths.get("nowhere"), Paths.get("nowhere"));
private Path bazelBin = bazelWorkspace.resolve("bazel-bin"),
bazelBinTarget = bazelTemp.resolve("xyz/execroot/test/bazel-out/local-fastbuild/bin").toAbsolutePath(),
bazelGenfiles = bazelWorkspace.resolve("bazel-genfiles"),
diff --git a/src/test/java/org/javacs/InferConfigTest.java b/src/test/java/org/javacs/InferConfigTest.java
index 2a951cc..debd6db 100644
--- a/src/test/java/org/javacs/InferConfigTest.java
+++ b/src/test/java/org/javacs/InferConfigTest.java
@@ -5,40 +5,82 @@ import static org.junit.Assert.*;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.Set;
import org.junit.Test;
public class InferConfigTest {
private Path workspaceRoot = Paths.get("src/test/test-project/workspace");
private Path mavenHome = Paths.get("src/test/test-project/home/.m2");
- private Artifact externalArtifact = new Artifact("com.external", "external-library", "1.2");
- private InferConfig infer = new InferConfig(workspaceRoot, mavenHome);
+ private Path gradleHome = Paths.get("src/test/test-project/home/.gradle");
+ private Set<String> externalDependencies = Set.of("com.external:external-library:1.2");
+ private InferConfig both = new InferConfig(workspaceRoot, externalDependencies, mavenHome, gradleHome);
+ private InferConfig gradle = new InferConfig(workspaceRoot, externalDependencies, Paths.get("nowhere"), gradleHome);
+ private InferConfig onlyPomXml =
+ new InferConfig(
+ Paths.get("src/test/test-project/only-pom-xml"),
+ Collections.emptySet(),
+ mavenHome,
+ Paths.get("nowhere"));
@Test
public void mavenClassPath() {
- var found = infer.findMavenJar(externalArtifact, false);
- assertTrue(found.isPresent());
assertThat(
- found.get(),
- equalTo(mavenHome.resolve("repository/com/external/external-library/1.2/external-library-1.2.jar")));
+ both.buildClassPath(),
+ contains(mavenHome.resolve("repository/com/external/external-library/1.2/external-library-1.2.jar")));
+ // v1.1 should be ignored
+ }
+
+ @Test
+ public void gradleClasspath() {
+ assertThat(
+ gradle.buildClassPath(),
+ contains(
+ gradleHome.resolve(
+ "caches/modules-2/files-2.1/com.external/external-library/1.2/xxx/external-library-1.2.jar")));
// v1.1 should be ignored
}
@Test
public void mavenDocPath() {
- var found = infer.findMavenJar(externalArtifact, true);
- assertTrue(found.isPresent());
assertThat(
- found.get(),
- equalTo(
+ both.buildDocPath(),
+ contains(
mavenHome.resolve(
"repository/com/external/external-library/1.2/external-library-1.2-sources.jar")));
// v1.1 should be ignored
}
@Test
+ public void gradleDocPath() {
+ assertThat(
+ gradle.buildDocPath(),
+ contains(
+ gradleHome.resolve(
+ "caches/modules-2/files-2.1/com.external/external-library/1.2/yyy/external-library-1.2-sources.jar")));
+ // v1.1 should be ignored
+ }
+
+ @Test
public void dependencyList() {
assertThat(
InferConfig.dependencyList(Paths.get("pom.xml")),
hasItem(new Artifact("org.hamcrest", "hamcrest-all", "1.3")));
}
+
+ @Test
+ public void onlyPomXmlClassPath() {
+ assertThat(
+ onlyPomXml.buildClassPath(),
+ contains(mavenHome.resolve("repository/com/external/external-library/1.2/external-library-1.2.jar")));
+ }
+
+ @Test
+ public void onlyPomXmlDocPath() {
+ assertThat(
+ onlyPomXml.buildDocPath(),
+ contains(
+ mavenHome.resolve(
+ "repository/com/external/external-library/1.2/external-library-1.2-sources.jar")));
+ }
}