use of org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.ClasspathOptions in project eclipse.jdt.ls by eclipse.
the class ProjectCommandTest method testGetClasspathsForMaven.
@Test
public void testGetClasspathsForMaven() throws Exception {
importProjects("maven/classpathtest");
IProject project = WorkspaceHelper.getProject("classpathtest");
String uriString = project.getFile("src/main/java/main/App.java").getLocationURI().toString();
ClasspathOptions options = new ClasspathOptions();
options.scope = "runtime";
ClasspathResult result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(1, result.classpaths.length);
assertEquals(0, result.modulepaths.length);
assertTrue(result.classpaths[0].indexOf("junit") == -1);
options.scope = "test";
result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(4, result.classpaths.length);
assertEquals(0, result.modulepaths.length);
boolean containsJunit = Arrays.stream(result.classpaths).anyMatch(element -> {
return element.indexOf("junit") > -1;
});
assertTrue(containsJunit);
}
use of org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.ClasspathOptions in project eclipse.jdt.ls by eclipse.
the class ProjectCommandTest method testGetClasspathsForMavenModular.
@Test
public void testGetClasspathsForMavenModular() throws Exception {
importProjects("maven/modular-project");
IProject project = WorkspaceHelper.getProject("modular-project");
String uriString = project.getFile("src/main/java/modular/Main.java").getLocationURI().toString();
ClasspathOptions options = new ClasspathOptions();
options.scope = "test";
ClasspathResult result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(0, result.classpaths.length);
assertEquals(1, result.modulepaths.length);
}
use of org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.ClasspathOptions in project eclipse.jdt.ls by eclipse.
the class ProjectCommandTest method testGetClasspathsForMavenWhenUpdating.
@Test
public void testGetClasspathsForMavenWhenUpdating() throws Exception {
importProjects("maven/classpathtest");
IProject project = WorkspaceHelper.getProject("classpathtest");
String uriString = project.getFile("src/main/java/main/App.java").getLocationURI().toString();
ClasspathOptions options = new ClasspathOptions();
options.scope = "test";
projectsManager.updateProject(project, true);
for (int i = 0; i < 10; i++) {
ClasspathResult result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(4, result.classpaths.length);
assertEquals(0, result.modulepaths.length);
boolean containsJunit = Arrays.stream(result.classpaths).anyMatch(element -> {
return element.indexOf("junit") > -1;
});
assertTrue(containsJunit);
}
}
use of org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.ClasspathOptions in project eclipse.jdt.ls by eclipse.
the class ProjectCommandTest method testGetClasspathsForGradle.
@Test
public void testGetClasspathsForGradle() throws Exception {
importProjects("gradle/simple-gradle");
IProject project = WorkspaceHelper.getProject("simple-gradle");
String uriString = project.getFile("src/main/java/Library.java").getLocationURI().toString();
ClasspathOptions options = new ClasspathOptions();
// Gradle project will always return classpath containing test dependencies.
// So we only test `scope = "test"` scenario.
options.scope = "test";
ClasspathResult result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(5, result.classpaths.length);
assertEquals(0, result.modulepaths.length);
boolean containsJunit = Arrays.stream(result.classpaths).anyMatch(element -> {
return element.indexOf("junit") > -1;
});
assertTrue(containsJunit);
}
use of org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.ClasspathOptions in project eclipse.jdt.ls by eclipse.
the class ProjectCommandTest method testGetClasspathsForEclipse.
@Test
public void testGetClasspathsForEclipse() throws Exception {
importProjects("eclipse/hello");
IProject project = WorkspaceHelper.getProject("hello");
String uriString = project.getFile("src/java/Bar.java").getLocationURI().toString();
ClasspathOptions options = new ClasspathOptions();
options.scope = "runtime";
ClasspathResult result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(1, result.classpaths.length);
assertEquals(0, result.modulepaths.length);
options.scope = "test";
result = ProjectCommand.getClasspaths(uriString, options);
assertEquals(2, result.classpaths.length);
assertEquals(0, result.modulepaths.length);
}
Aggregations