We have run into a problem when migrating our Powermock-assisted GUI unit tests
to Java 8.
It took a while to find the root cause, because the tests run fine
individually, but not in sequence.
All it takes to reproduce the problem is three unit tests which prepare some
class (doesn't matter which) using PowerMock and somehow use a JavaFX node in
the unit test.
This is the simplest example imagineable (I also attached it as a mvn project):
@RunWith(PowerMockRunner.class)
@PrepareForTest(Service.class)
public class SimplePowermockTest {
@Test
public void testIt() throws Exception {
new Pane();
}
}
public class AnotherSimplePowermockTest extends SimplePowermockTest {
}
public class YetAnotherSimplePowermockTest extends SimplePowermockTest {
}
In Java 7, this was working fine. In Java 8, a QuantumRenderer error ("no
suitable pipeline found") happens when the third test is run. See stacktrace
below.
One can also run the whole thing on the JavaFX application thread or create a
new JFXPanel() beforehand to initialize the toolkit, it still doesn't work.
May have something to do with concurrency, as if run on the JavaFX application
thread, an additional error says:
java.lang.UnsatisfiedLinkError: Native Library C:\Program Files
(x86)\Java\jdk1.8.0\jre\bin\glass.dll already loaded in another classloader
Is it a Powermock bug or a JavaFX 8.0 bug? Or is there some change of procedure
I missed out on?
I posted it to the JavaFX community in parallel:
https://community.oracle.com/thread/3556788
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running AnotherSimplePowermockTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 1.727 sec
Running SimplePowermockTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 1.792 sec
Running YetAnotherSimplePowermockTest
Graphics Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing
QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:300)
at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:179)
at com.sun.javafx.perf.PerformanceTracker.logEvent(PerformanceTracker.java:110)
at javafx.scene.Node.<clinit>(Node.java:379)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at javassist.runtime.Desc.getClassObject(Desc.java:43)
at javassist.runtime.Desc.getClassType(Desc.java:152)
at javassist.runtime.Desc.getType(Desc.java:122)
at javassist.runtime.Desc.getType(Desc.java:78)
at SimplePowermockTest.testIt(SimplePowermockTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:118)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:104)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no
suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:98)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:128)
at java.lang.Thread.run(Thread.java:744)
Tests run: 2, Failures: 0, Errors: 1, Skipped: 1, Time elapsed: 0.016 sec <<<
FAILURE!
Original issue reported on code.google.com by andhi.pa...@googlemail.com on 8 May 2014 at 10:46
Original issue reported on code.google.com by
andhi.pa...@googlemail.com
on 8 May 2014 at 10:46Attachments: