From 5242b2fd08410fa5d35476927d963827a8360ac4 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Mon, 23 Oct 2023 11:12:27 +0800 Subject: [PATCH] Fix tests Signed-off-by: Sheng Chen --- .../managers/ProjectsManagerTest.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/ProjectsManagerTest.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/ProjectsManagerTest.java index c57ce42992..b9c1a66575 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/ProjectsManagerTest.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/managers/ProjectsManagerTest.java @@ -211,13 +211,14 @@ public void dontFilterGitLikePackages() throws Exception { @Test public void testImportMavenSubModule() throws IOException, OperationCanceledException, CoreException { - Path projectDir = copyFiles("maven/multimodule", true).toPath(); + File projectDir = copyFiles("maven/multimodule", true); + Path projectDirPath = projectDir.toPath(); Collection configurationPaths = new ArrayList<>(); - Path subModuleConfiguration = projectDir.resolve("module1/pom.xml"); + Path subModuleConfiguration = projectDirPath.resolve("module1/pom.xml"); IPath filePath = ResourceUtils.canonicalFilePathFromURI(subModuleConfiguration.toUri().toString()); configurationPaths.add(filePath); preferenceManager.getPreferences().setProjectConfigurations(configurationPaths); - projectsManager.initializeProjects(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.toString())), monitor); + projectsManager.initializeProjects(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.getAbsolutePath())), monitor); IProject[] allProjects = ProjectUtils.getAllProjects(); Set expectedProjects = new HashSet<>(Arrays.asList( "module1", @@ -232,13 +233,14 @@ public void testImportMavenSubModule() throws IOException, OperationCanceledExce @Test public void testImportMixedProjects() throws IOException, OperationCanceledException, CoreException { - Path projectDir = copyFiles("mixed", true).toPath(); + File projectDir = copyFiles("mixed", true); + Path projectDirPath = projectDir.toPath(); Collection configurationPaths = new ArrayList<>(); - configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDir.resolve("hello/.project").toUri().toString())); - configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDir.resolve("simple-gradle/build.gradle").toUri().toString())); - configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDir.resolve("salut/pom.xml").toUri().toString())); + configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDirPath.resolve("hello/.project").toUri().toString())); + configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDirPath.resolve("simple-gradle/build.gradle").toUri().toString())); + configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDirPath.resolve("salut/pom.xml").toUri().toString())); preferenceManager.getPreferences().setProjectConfigurations(configurationPaths); - projectsManager.initializeProjects(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.toString())), monitor); + projectsManager.initializeProjects(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.getAbsolutePath())), monitor); IProject[] allProjects = ProjectUtils.getAllProjects(); Set expectedProjects = new HashSet<>(Arrays.asList( "jdt.ls-java-project", @@ -254,12 +256,13 @@ public void testImportMixedProjects() throws IOException, OperationCanceledExcep @Test public void testImportMixedProjectsPartially() throws IOException, OperationCanceledException, CoreException { - Path projectDir = copyFiles("mixed", true).toPath(); + File projectDir = copyFiles("mixed", true); + Path projectDirPath = projectDir.toPath(); Collection configurationPaths = new ArrayList<>(); - configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDir.resolve("simple-gradle/build.gradle").toUri().toString())); - configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDir.resolve("salut/pom.xml").toUri().toString())); + configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDirPath.resolve("simple-gradle/build.gradle").toUri().toString())); + configurationPaths.add(ResourceUtils.canonicalFilePathFromURI(projectDirPath.resolve("salut/pom.xml").toUri().toString())); preferenceManager.getPreferences().setProjectConfigurations(configurationPaths); - projectsManager.initializeProjects(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.toString())), monitor); + projectsManager.initializeProjects(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.getAbsolutePath())), monitor); IProject[] allProjects = ProjectUtils.getAllProjects(); Set expectedProjects = new HashSet<>(Arrays.asList( "jdt.ls-java-project",