1
1
package test .javafx .fxml ;
2
2
/*
3
- * Copyright (c) 2011, 2016 , Oracle and/or its affiliates. All rights reserved.
3
+ * Copyright (c) 2011, 2020 , Oracle and/or its affiliates. All rights reserved.
4
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
5
*
6
6
* This code is free software; you can redistribute it and/or modify it
31
31
import java .util .concurrent .atomic .AtomicBoolean ;
32
32
import javafx .fxml .FXMLLoader ;
33
33
import javafx .fxml .LoadListener ;
34
+ import javax .script .ScriptEngineManager ;
35
+ import javax .script .ScriptEngine ;
34
36
35
37
import static org .junit .Assert .*;
38
+ import static org .junit .Assume .assumeTrue ;
36
39
37
40
public class FXMLLoader_ScriptTest {
38
41
@ Test
@@ -130,6 +133,10 @@ public void endElement(Object value) {
130
133
@ Test
131
134
public void testScriptHandler () throws IOException {
132
135
136
+ // This test needs Nashorn script engine.
137
+ // Test will be rewritten under - JDK-8245568
138
+ assumeTrue (isNashornEngineAvailable ());
139
+
133
140
FXMLLoader loader = new FXMLLoader (getClass ().getResource ("script_handler.fxml" ));
134
141
loader .load ();
135
142
@@ -143,6 +150,10 @@ public void testScriptHandler() throws IOException {
143
150
@ Test
144
151
public void testExternalScriptHandler () throws IOException {
145
152
153
+ // This test needs Nashorn script engine.
154
+ // Test will be rewritten under - JDK-8245568
155
+ assumeTrue (isNashornEngineAvailable ());
156
+
146
157
FXMLLoader loader = new FXMLLoader (getClass ().getResource ("script_handler_external.fxml" ));
147
158
loader .load ();
148
159
@@ -152,4 +163,11 @@ public void testExternalScriptHandler() throws IOException {
152
163
w .fire ();
153
164
assertTrue (((AtomicBoolean )loader .getNamespace ().get ("actionDone" )).get ());
154
165
}
166
+
167
+ private boolean isNashornEngineAvailable () {
168
+ ScriptEngineManager factory = new ScriptEngineManager ();
169
+ ScriptEngine engine = factory .getEngineByName ("nashorn" );
170
+
171
+ return (engine != null );
172
+ }
155
173
}
0 commit comments