TestFx in headless mode with openjfx-monocle-1.8.0_20.jar

980 views
Skip to first unread message

Tommy Yeh

unread,
Apr 6, 2016, 2:30:50 AM4/6/16
to TestFX
I want to test fx application in headless mode, 

I have download the openjfx-monocle-1.8.0_20.jar and copy it to the ..\jdk1.8.0_74\jre\lib\ext,

What VM arguments I should give is correctly when I want to test ?

Benjamin Gudehus

unread,
Apr 6, 2016, 3:16:35 AM4/6/16
to Tommy Yeh, TestFX
Hi Tommy,

since TestFX runs headless tests using Travis CI you can find the VM arguments in the `.travis` file [1].

The correct VM arguments are 

~~~
-Djava.awt.headless=true -Dtestfx.robot=glass -Dtestfx.headless=true -Dprism.order=sw -Dprism.text=t2k
~~~

Don't use `-Dglass.platform=Monocle -Dmonocle.platform=Headless`, if you want to run headless tests on desktop systems (i.e. Linux, Mac and Windows).

I've uploaded Monocle artifacts for newer Java 8 versions [2]. Monocle's internal package structure was changed in Java 8u40, and TestFX needs to reflect this change (i.e. `ApplicationLauncherImpl` needs changes). If you run headless tests on Java 8u74 you'll get a `IllegalStateException` ("Monocle headless platform not found").


--
You received this message because you are subscribed to the Google Groups "TestFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testfx-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tommy Yeh

unread,
Apr 6, 2016, 3:58:05 AM4/6/16
to TestFX
Hi Benjamin

I really got IllegalStateException after update openjfx-monocle-1.8.0_20.jar to openjfx-monocle-8u76-b04.jar and give the VM arguments you mentioned.

Do you have any suggestion if I want to test in Java 8u74 and Java 8u71 ?

Kay Pac

unread,
Sep 6, 2016, 11:18:17 PM9/6/16
to TestFX
I am looking to do headless testing but I am using the latest Oracle JDK.- 1.8.0_101.

There are only a couple of artifacts at the url http://central.maven.org/maven2/org/testfx/openjfx-monocle/
Do I need to revert to an old JDK in order to perform this kind of testing?

Kay

Kay Pac

unread,
Sep 7, 2016, 6:37:20 PM9/7/16
to TestFX
I tried to use these parameters and I got the following exception in running my tests:


java.lang.IllegalStateException: Toolkit not initialized

    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
    at javafx.application.Platform.runLater(Platform.java:83)
    at org.testfx.util.WaitForAsyncUtils.runOnFxThread(WaitForAsyncUtils.java:356)
    at org.testfx.util.WaitForAsyncUtils.asyncFx(WaitForAsyncUtils.java:115)
    at org.testfx.toolkit.impl.ApplicationServiceImpl.stop(ApplicationServiceImpl.java:70)
    at org.testfx.toolkit.impl.ToolkitServiceImpl.cleanupApplication(ToolkitServiceImpl.java:151)
    at org.testfx.api.FxToolkit.cleanupApplication(FxToolkit.java:187)
    at org.testfx.framework.junit.ApplicationTest.internalAfter(ApplicationTest.java:61)
    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:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
    at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:66)
    at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:57)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:124)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
    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:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)


Is this an expected bug? I would love to solve this because I am unable to run tests on my continuous integration server (jenkins).

Chris Merrill

unread,
Jan 30, 2017, 12:14:03 PM1/30/17
to TestFX, tommy....@gmail.com
Want to thank Benjamin for this post. Worked perfectly for me:

added to my Gradle build file:
      testCompile 'org.jfxtras:openjfx-monocle:1.8.0_20'

Using java 1.8.0_111.

Thanks!
Reply all
Reply to author
Forward
0 new messages