I am trying to automate testing for a JavaFX 2 application running on Java 7u6 with the integrated JavaFX 2.2. To that end, I have built and integrated Jemmy3 and JemmyFX into my build environment. A simple smoke test runs on all relevant OSs.
As a next step, I want to run the tests as part of the continuous deployment process.
Since the current CI server runs on OpenSUSE, which is not officially supported by JavaFX,
I have set up an Ubuntu Server installation in a virtual machine and installed gtk2.
To remedy the lack of a fully fledged windowing system, I have tried running the tests on both Xvnc and Xvfb, but to no avail.
On Xvnc, the tests fail with
Prism ES2 Error - nInitialize: glXChooseFBConfig failed
whereas on Xvfb, they give me
Xlib: extension "RANDR" missing on display ":10".
A blog post suggested to install gtk-engines-pixbuf
to alleviate the second problem, but this only changed the number of the display in the error message.
Now, I summon the JavaFX knowledge of StackOverflow and ask
I had a similar problem - running JUnit tests in a headless environment with Maven.
We don't use JemmyFX. We have just very simple tests that use a JUnit Rule similar to this one: https://gist.github.com/andytill/3835914 (this is required for code that uses Platform.runLater(...))
Current version of JavaFX (supplied with JDK 1.7.0-21) seems to be working in Xvfb on Ubuntu 12.04 without a running Xserver:
Xvfb :99
DISPLAY=:99 mvn clean install
Support for (headless) CI server testing of JavaFX is not available until JavaFX 8.
Answer based on information in these JavaFX issue tracking records:
Update Jan 8, 2015
The linked JavaFX issue tracking records were not implemented for Java 8 and have been reassigned to Java 9.
Java 8 source code currently includes a minimal rendering engine named Monocle which provides Headless rendering (and rendering for various other target platforms) for JavaFX components. I have never used Monocle and cannot provide detailed instructions on how to use it for headless rendering. I believe to use Monocle, you currently need to perform a custom build of JavaFX from source (as I think Monocle is usually only shipped in embedded JavaFX versions, which is not the standard JavaFX version which ships with the desktop Java runtime and JDK environments).
Information on Monocle is available on the JavaFX wiki.
Although, headless rendering is provided by Monocle, I do not think that using Monocle to perform headless rendering is officially supported by Oracle (though i don't think headless rendering of JavaFX in any form is officially supported, so I guess if Monocle works well for you, by all means use it).
The headless rendering in Monocle is a software rendering implementation so execution of some graphic primitives may be slower than the standard hardware accelerated operation of JavaFX in a desktop environment.
There may be other methods of allowing JavaFX to run in a headless environment that I am not aware of.
If in doubt, ask the JavaFX developers on the openjfx-dev mailing list.
If you are running under Linux, using Xvfb as suggested by Jan Zarnikov's answer is probably a good solution and is likely preferable to using Monocle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With