Can griffon tests in JavaFX be run in headless mode?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Can griffon tests in JavaFX be run in headless mode?

Marcelo
This post was updated on .
Hi,

I wanted to know if Griffon provides any way to run visual tests in headless mode. I read a post by Andres on JRoller running_testfx_tests_in_headless but I still cannot make it work.

This is the output I get:

Prism pipeline init order: sw 
Using java-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.sw.SWPipeline
(X) Got class = class com.sun.prism.sw.SWPipeline
Initialized prism pipeline: com.sun.prism.sw.SWPipeline
Failed to load Glass factory class

and this exception:

*** Fallback to Prism SW pipeline
java.lang.ClassNotFoundException: com.sun.glass.ui.monocle.MonoclePlatformFactory
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
	at com.sun.glass.ui.Application.run(Application.java:146)
	at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
	at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
	at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
	at java.lang.Thread.run(Thread.java:745)

According to what I read, this is because I need to build monocle, and I wanted to know if I could do that with gradle so I don't have to worry if the platform where the project is deployed has monocle built (like a CI server).

Obviously there might be also something else going on: this is my first try to use monocle on a project.

Thanks.

Marcelo.
Reply | Threaded
Open this post in threaded view
|

Re: Can griffon tests in JavaFX be run in headless mode?

Marcelo
I guess I moved forward a bit...

According to this TestFX thread there is a problem in TestFx / Monocle. In TestFX Issue #264 a user mentions using Monocle 8u20 with testfx 4.0.4-alpha

It also seems I am running the test JVMs with the correct arguments:

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

But my tests are falling with a RuntimeException, caused by and IllegalStateException with the message: Monocle platform not found

Any ideas on how to solve this?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Can griffon tests in JavaFX be run in headless mode?

aalmiray
Administrator
Hi Marcelo,

You're on the right track. Some months ago I wrote how to get it done.
See http://www.jroller.com/aalmiray/entry/running_testfx_tests_in_headless

Although it looks like you got most of the options. I must confess I haven't tried Monocle 8u40 yet.

You may want to upgrade to testfx-4.0.5-alpha and test again.
Btw Griffon 2.10.0 will upgrade this dependency too.

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Can griffon tests in JavaFX be run in headless mode?

Marcelo
Hi Andres,

I read your post and many others to try to have this working.
I know there is a video on YouTube from a guy that uses it with the Spring framework and TestFX, but I can't get it to work on my end.

I tried updating the dependencies to TestFx 4.0.5-alpha and tried Monocle from TestFX (version 1.80.20) and many different ones from jfxtras... and none worked. It seems Monocle is very dependent on the JDK version (mine is 1.8.0_121).

When you tried Monocle on your end, did you have to build the project and save it to the ext folder in the java installation location?

Thanks,

Marcelo.
Reply | Threaded
Open this post in threaded view
|

Re: Can griffon tests in JavaFX be run in headless mode?

aalmiray
Administrator
I'm using Monocle 1.8.0_20, TestFX 4.0.4-alpha, and Oracle JDK 8u112 with success. Previous versions of Oracle JDK8 work down to u20 I believe. I've set my minimum version to 8u60 as there are breaking changes in JavaFX up to that release.

I've not tried with 8u121 nor TestFX 4.0.5-alpha.
Did not have to setup monocle as an external installation either.

Have you tried a minimalist JavaFX application (a stage and a button for example) with the latest versions of Gradle, Monocle, TestFX, and Java? I don't believe Griffon has anything to do here but just in case. If reproducible then this sample app can be used as a demonstration device for other interested parties.

Cheers,
Andres