Skip to content

Commit

Permalink
Intermittent failure of testSignatureHelpForSelectedCompletionProposal
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Sep 8, 2023
1 parent f4d1a4a commit edbd443
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ls.core.internal.ClassFileUtil;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
Expand Down Expand Up @@ -50,6 +51,9 @@ public void setUp() throws Exception {
importProjects("maven/salut");
project = WorkspaceHelper.getProject("salut");
defaultProject = linkFilesToDefaultProject("singlefile/Single.java").getProject();
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, monitor);
Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, monitor);
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, monitor);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.jdt.ls.core.internal.JVMConfigurator;
import org.eclipse.jdt.ls.core.internal.JobHelpers;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
Expand All @@ -40,6 +42,7 @@

public class JavaFXTest extends AbstractProjectsManagerBasedTest {

private static final String VERSION_1_8 = "1.8";
private static final String JAVA8FX_HOME = "java8fx.home";
private static final String JAVA_SE_8 = "JavaSE-1.8";
private static final String JAVA_SE_17 = "JavaSE-17";
Expand Down Expand Up @@ -71,13 +74,8 @@ public void testJavaFX() throws Exception {
// Delete JavaFX runtime, project should fail to compile
IVMInstall vm = JVMConfigurator.findVM(new File(jdkFXHome), null);
vm.getVMInstallType().disposeVMInstall(vm.getId());
TestVMType.setTestJREAsDefault("1.8");
IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(TestVMType.VMTYPE_ID);
IVMInstall jvm8 = vmInstallType.findVMInstall("1.8");
IExecutionEnvironment environment = JVMConfigurator.getExecutionEnvironment(JAVA_SE_8);
if (environment != null) {
environment.setDefaultVM(jvm8);
}
TestVMType.setTestJREAsDefault(VERSION_1_8);
JDTUtils.setCompatibleVMs(VERSION_1_8);
JobHelpers.waitForJobsToComplete();
List<IMarker> errors = ResourceUtils.getErrorMarkers(project);
assertNotEquals(0, errors.size());
Expand All @@ -92,22 +90,25 @@ public void testJavaFX() throws Exception {
}
}

@Override
@After
public void cleanJdkfxHome() throws Exception {
public void cleanUp() throws Exception {
super.cleanUp();
String jdkFXHome = System.getProperty(JAVA8FX_HOME);
if (jdkFXHome != null && !jdkFXHome.isBlank()) {
IVMInstall vm = JVMConfigurator.findVM(new File(jdkFXHome), null);
if (vm != null) {
vm.getVMInstallType().disposeVMInstall(vm.getId());
}
IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(TestVMType.VMTYPE_ID);
IVMInstall jvm8 = vmInstallType.findVMInstall("1.8");
IExecutionEnvironment environment = JVMConfigurator.getExecutionEnvironment(JAVA_SE_8);
if (environment != null) {
environment.setDefaultVM(jvm8);
}
}
TestVMType.setTestJREAsDefault("17");
JDTUtils.setCompatibleVMs(VERSION_1_8);
// Copied from org.eclipse.jdt.core.tests.model.ClasspathInitializerTests.tearDown()
// Cleanup caches
JavaModelManager manager = JavaModelManager.getJavaModelManager();
manager.containers = new HashMap<>(5);
manager.variables = new HashMap<>(5);
JobHelpers.waitForJobsToComplete();
}

private Preferences createJavaFXRuntimePrefs(String path) {
Expand Down

0 comments on commit edbd443

Please sign in to comment.