Plug-in tests using JDT - no default VM found on Mac OS X [message #1384672] |
Fri, 30 May 2014 04:33  |
Eclipse User |
|
|
|
Hi,
I'm running some plug-in tests which require a Java project to be built.
One of my colleagues noted that tests were failing on Mac OS X, while
they were working fine on Windows and Linux. The tests use Kepler as a
target platform.
Digging a bit deeper, he found out that there was no default JVM
library. The problems view reported a problem
Unbound classpath container: 'Default System Library' in project
'test-project-1'
I terms of JDT code, JavaRuntime.getDefaultVMInstall() returns null.
We tried to work around it by manually creating a new default VM:
final IVMInstallType vmInstallType =
JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
String id = null;
do {
id = String.valueOf(System.currentTimeMillis());
} while (vmInstallType.findVMInstall(id) != null);
VMStandin newVm = new VMStandin(vmInstallType, id);
newVm.setName("Default-VM");
File installLocation = new File(jrePath);
newVm.setInstallLocation(installLocation);
IVMInstall realVm = newVm.convertToRealVM();
JavaRuntime.setDefaultVMInstall(realVm, new NullProgressMonitor());
but I'm not really happy about it. There are two reasons:
1. It seems like we are working around a platform limitation, and
hopefully there's a simpler way to achieve our goal
2. Reconfiguring the default VM seems to need some amount of time, and
the call does not block until that's done.
So I have two questions:
1. Is there a way to ensure that test Eclipse runtime has a default VM
set up on Mac OS X?
2. If 1 is not possible, is there a way I can know when the default VM
is reconfigured, except using Thread.sleep and hoping for the best?
The code for the tests is available, see for instance [1].
Thanks,
Robert
[1]:
https://github.com/apache/sling/blob/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/BundleDeploymentTest.java#L112
|
|
|
Re: Plug-in tests using JDT - no default VM found on Mac OS X [message #1692768 is a reply to message #1384672] |
Fri, 17 April 2015 14:52  |
Eclipse User |
|
|
|
I realize this is nearly a year old, but raising it from the dead as I recently hit the issue trying to run UI Eclipse tests with Tycho in Maven 3. Your solution works perfectly to set the default JVM for OS X based systems.
The only thing I wanted to add, is instead of relying on Thread.sleep(), what if you wrap the operation in an IWorkspaceRunnable and run it with ResourcesPlugin.getWorkbench().run(runnable, monitor)? This is what I am doing and it seems to work great.
Thanks for the solution!
|
|
|
Powered by
FUDForum. Page generated in 0.26150 seconds