Monocle Headless Platform has been compiled by a more recent version of the Java Runtime (class file version 53.0)
I'm writing an application test with Junit5 and TestFX. My intention is that the main test class relaunches the application after each test, all tests should run headless.
Here is my test class:
public class MainTest extends ApplicationTest implements FxRobotInterface {
Logger loggerGuiTesting = LoggerManager.getInstance().getLogger(LoggerType.GUI_TESTING);
public static final boolean HEADLESS = true;
private Stage primaryStage = AppMainClass.getStage();
@BeforeAll
public static void setupSpec() throws Exception {
if (HEADLESS) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
FxToolkit.registerPrimaryStage();
}
@BeforeEach
public void setUp() throws Exception {
FxToolkit.setupApplication(AppMainClass.class);
}
private Scene scene;
@Override
public void start(final Stage stage) {
this.primaryStage = stage;
this.primaryStage.show();
this.scene = this.primaryStage.getScene();
this.loggerGuiTesting.log(Level.INFO, "App starts!");
}
@AfterAll
public void endApplication() {
new ExitGuiTest().run(); // That's my internal test framework
}
@Test
public void atestIfOpeningScreenIsThere() {
verifyThat("#imageViewSplashScreenLogo", NodeMatchers.isNotNull());
verifyThat("#progressBarSplashScreen", NodeMatchers.isNotNull());
verifyThat("#labelSplashScreenVersion", NodeMatchers.isNotNull());
verifyThat("#labelSplashScreenDate", NodeMatchers.isNotNull());
this.loggerGuiTesting.log(Level.INFO, "testIfOpeningScreenIsThere, succeeded!");
}
@Test
public void btestIfRadioButtonOneExist() {
assertThat("#sourcesOneRadioButton", is("#sourcesOneRadioButton"));
this.loggerGuiTesting.log(Level.INFO, "testIfRadioButtonOneExist, succeeded!");
}
@Test
public cnextTest() {
new StartAnotherGuiTest().run();
this.loggerGuiTesting.log(Level.INFO, "anotherTest, succeeded!");
}
}
I run the test and error code appeared with this message:
java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: com/sun/glass/ui/monocle/HeadlessPlatform has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
java.lang.UnsupportedClassVersionError: com/sun/glass/ui/monocle/HeadlessPlatform has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
java.lang.IllegalStateException: Toolkit not initialized
My build.gradle looks something like this:
dependencies {
implementation project(':A')
implementation project(':B')
implementation project(':C')
implementation project(':D')
implementation project(':E')
implementation project(':F') implementation fileTree(dir: 'lib', include: '.jar')
implementation fileTree(dir: '../A/lib', include: '.jar')
implementation fileTree(dir: '../A/lib/gson', include: '.jar')
implementation fileTree(dir: 'lib/', include: '.jar')
implementation fileTree(dir: 'lib/', include: '.jar')
implementation fileTree(dir: '../C/C1/framework/libraries', include:'.jar')
implementation fileTree(dir: '../C/C1/framework', include:'*.jar') api 'org.apache.commons:commons-math3:3.6.1' api 'junit:junit:4.12' api 'junit:junit:4.13-beta-3'if(JavaVersion.current() >= JavaVersion.VERSION_11){
implementation("org.openjfx:javafx-base:11.0.+:win",
"org.openjfx:javafx-graphics:11.0.+:win",
"org.openjfx:javafx-controls:11.0.+:win",
"org.openjfx:javafx-media:11.0.+:win", "org.openjfx:javafx-fxml:11.0.+:win", "org.openjfx:javafx-swing:11.0.+:win",
"org.openjfx:javafx-web:11.0.+:win") }// Use JUnit test framework // This dependency provides the public API for writing tests and extensions testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: >'5.4.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.4.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-migrationsupport', version: >'5.4.2' testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.4.2'
testRuntimeOnly group:'org.junit.vintage', name: 'junit-vintage-engine', version: '5.4.2' testImplementation group: 'org.junit.platform', name: 'junit-platform-engine', version: '1.5.1'
testImplementation group:'org.junit.platform', name: 'junit-platform-launcher', version: '1.5.1'testCompileOnly group: 'junit', name: 'junit', version: '4.13-beta-3' testCompileOnly group: 'junit', name: 'junit', version: '4.12' testImplementation group: 'org.testifyproject.junit4', name: 'junit4-core', version: '1.0.6' //This dependency provides TestFX testImplementation group: 'org.testfx', name: 'testfx-junit5', version: '4.0.16-alpha' testImplementation group: "org.testfx", name: "testfx-core", version: "4.0.16-alpha" testImplementation group: "org.testfx", name: "testfx-junit", version: "4.0.16-alpha" testImplementation group: 'org.testfx', name: 'testfx-legacy', version: '4.0.8-alpha' // This dependency runs tests in JUnit 5, 4, 3 testRuntimeOnly( 'org.junit.jupiter:junit-jupiter-engine:5.4.2', 'org.junit.vintage:junit-vintage-engine:5.4.2', 'org.testfx:openjfx-monocle:jdk-9+181.1' ) }
test { useJUnitPlatform()
useJUnit() jvmArgs "-Dheadless=${project.hasProperty('headless') ? project.headless : false}" testLogging { events "passed", "skipped", "failed" } }
I'm currently using jdk1.8.0_201. I'm not allowed to renew the java version.