Skip to content

Commit 1dfaccf

Browse files
committed
java 11 support
1 parent 3c113f8 commit 1dfaccf

File tree

9 files changed

+71
-36
lines changed

9 files changed

+71
-36
lines changed

pom.xml

+37-4
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@
207207
<artifactId>maven-compiler-plugin</artifactId>
208208
<version>3.8.1</version>
209209
<configuration>
210-
<source>1.8</source>
211-
<target>1.8</target>
210+
<source>11</source>
211+
<target>11</target>
212212
</configuration>
213213
</plugin>
214214
<plugin>
@@ -260,7 +260,7 @@
260260
<plugin>
261261
<groupId>org.robotframework</groupId>
262262
<artifactId>robotframework-maven-plugin</artifactId>
263-
<version>1.7.1</version>
263+
<version>2.1.0</version>
264264
<executions>
265265
<execution>
266266
<id>acceptance tests</id>
@@ -367,6 +367,39 @@
367367
</build>
368368

369369
<dependencies>
370+
<dependency>
371+
<groupId>org.openjfx</groupId>
372+
<artifactId>javafx-graphics</artifactId>
373+
<version>11</version>
374+
<classifier>win</classifier>
375+
</dependency>
376+
<dependency>
377+
<groupId>org.openjfx</groupId>
378+
<artifactId>javafx-graphics</artifactId>
379+
<version>11</version>
380+
<classifier>linux</classifier>
381+
</dependency>
382+
<dependency>
383+
<groupId>org.openjfx</groupId>
384+
<artifactId>javafx-graphics</artifactId>
385+
<version>11</version>
386+
<classifier>mac</classifier>
387+
</dependency>
388+
<dependency>
389+
<groupId>org.openjfx</groupId>
390+
<artifactId>javafx-controls</artifactId>
391+
<version>11</version>
392+
</dependency>
393+
<dependency>
394+
<groupId>org.openjfx</groupId>
395+
<artifactId>javafx-swing</artifactId>
396+
<version>11</version>
397+
</dependency>
398+
<dependency>
399+
<groupId>org.openjfx</groupId>
400+
<artifactId>javafx-fxml</artifactId>
401+
<version>11</version>
402+
</dependency>
370403
<dependency>
371404
<groupId>org.apache.maven</groupId>
372405
<artifactId>maven-model</artifactId>
@@ -391,7 +424,7 @@
391424
<dependency>
392425
<groupId>org.testfx</groupId>
393426
<artifactId>openjfx-monocle</artifactId>
394-
<version>8u76-b04</version>
427+
<version>jdk-12.0.1+2</version>
395428
</dependency>
396429
<dependency>
397430
<groupId>org.robotframework</groupId>

src/main/java/JavaFXLibrary.java

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public JavaFXLibrary(boolean headless) {
128128
if (headless) {
129129
System.setProperty("testfx.robot", "glass");
130130
System.setProperty("testfx.headless", "true");
131+
System.setProperty("glass.platform", "Monocle");
132+
System.setProperty("monocle.platform", "Headless");
131133
System.setProperty("prism.order", "sw");
132134
System.setProperty("prism.text", "t2k");
133135
TestFxAdapter.isHeadless = true;

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,12 @@ private Class getMainClass(String appName) {
112112
}
113113

114114
private void addPathToClassPath(String path) {
115-
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
116115

117116
RobotLog.info("Setting following path to classpath: " + path);
118117

119118
try {
120-
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
121-
method.setAccessible(true);
122-
method.invoke(classLoader, (new File(path)).toURI().toURL());
119+
URL[] urls = new URL[]{new File(path).toURI().toURL()};
120+
URLClassLoader classLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
123121

124122
} catch (Exception e) {
125123
throw new JavaFXLibraryFatalException("Problem setting the classpath: " + path, e);
@@ -176,11 +174,11 @@ public void setToClasspath(String path, boolean failIfNotFound) {
176174
@RobotKeyword("Logs current classpath content")
177175
public void logApplicationClasspath() {
178176
try {
179-
ClassLoader cl = ClassLoader.getSystemClassLoader();
180-
URL[] urls = ((URLClassLoader) cl).getURLs();
181177
RobotLog.info("Printing out classpaths: \n");
182-
for (URL url : urls) {
183-
RobotLog.info(url.getFile());
178+
179+
String classpathStr = System.getProperty("java.class.path");
180+
for (String classpathItem : classpathStr.split(System.getProperty("path.separator"))) {
181+
RobotLog.info(classpathItem);
184182
}
185183
} catch (Exception e) {
186184
throw new JavaFXLibraryNonFatalException("Unable to log application classpaths", e);

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
package javafxlibrary.keywords.AdditionalKeywords;
1919

20-
import com.sun.javafx.scene.control.skin.TableViewSkin;
21-
import com.sun.javafx.scene.control.skin.VirtualFlow;
20+
import javafx.scene.control.skin.TableViewSkin;
21+
import javafx.scene.control.skin.VirtualFlow;
2222
import javafx.collections.ObservableList;
2323
import javafx.css.PseudoClass;
2424
import javafx.geometry.BoundingBox;
@@ -279,7 +279,7 @@ public String getNodeText(Object locator) {
279279
@RobotKeyword("Returns image name and path of the node. \n\n"
280280
+ "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
281281
+ "`3. Locating JavaFX Nodes`. \n\n"
282-
+ "Returns full image path by subsequently calling impl_getUrl -method. \n\n"
282+
+ "Returns full image path by subsequently calling getUrl -method. \n\n"
283283
+ "Note, impl_getUrl -method is deprecated! Support for this method will be removed from Java in the future.")
284284
@ArgumentNames({"node"})
285285
public String getNodeImageUrl(Object locator) {
@@ -294,8 +294,7 @@ public String getNodeImageUrl(Object locator) {
294294
try {
295295
Object result = m.invoke(node, (Object) null);
296296
Image image = (Image) result;
297-
RobotLog.trace("Calling deprecated method impl_getUrl() for image: \"" + image + "\"");
298-
return image.impl_getUrl();
297+
return image.getUrl();
299298
} catch (Exception e) {
300299
throw new JavaFXLibraryNonFatalException("Problem calling method: .getImage(): " + e.getMessage(), e);
301300
}
@@ -480,13 +479,17 @@ public List<Object> getTableColumnCells(Object locator, int column) {
480479
RobotLog.info("Getting table \"" + locator + "\" cells from column \"" + column + "\".");
481480
TableView table = (TableView) objectToNode(locator);
482481
List<Object> columnCells = new ArrayList<>();
483-
VirtualFlow<?> vf = (VirtualFlow<?>) ((TableViewSkin<?>) table.getSkin()).getChildren().get(1);
484-
485-
for (int i = vf.getFirstVisibleCell().getIndex(); i < vf.getLastVisibleCell().getIndex() + 1; i++) {
486-
RobotLog.info("Index number: " + i);
487-
columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column)));
482+
Optional<VirtualFlow> vf = table.getChildrenUnmodifiable().stream().filter(node -> node instanceof VirtualFlow).map(VirtualFlow.class::cast).findFirst();
483+
if (vf.isPresent()) {
484+
VirtualFlow virtualFlow = vf.get();
485+
for (int i = virtualFlow.getFirstVisibleCell().getIndex(); i < virtualFlow.getLastVisibleCell().getIndex() + 1; i++) {
486+
RobotLog.info("Index number: " + i);
487+
columnCells.add(mapObject(virtualFlow.getCell(i).getChildrenUnmodifiable().get(column)));
488+
}
489+
return mapObjects(columnCells);
490+
} else {
491+
throw new JavaFXLibraryNonFatalException("Could not find VirtualFlow from Tableview!");
488492
}
489-
return mapObjects(columnCells);
490493
} catch (ClassCastException cce) {
491494
throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
492495
}

src/test/java/javafxlibrary/TestFxAdapterTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public FxRobotInterface getRobot() {
3737
public static void setupTests() {
3838
System.setProperty("testfx.robot", "glass");
3939
System.setProperty("testfx.headless", "true");
40+
System.setProperty("glass.platform", "Monocle");
41+
System.setProperty("monocle.platform", "Headless");
4042
System.setProperty("prism.order", "sw");
4143
System.setProperty("prism.text", "t2k");
4244
try {

src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package javafxlibrary.testapps.controllers;
1919

20-
import com.sun.javafx.scene.control.skin.TextAreaSkin;
20+
import javafx.scene.control.skin.TextAreaSkin;
2121
import javafx.event.EventHandler;
2222
import javafx.fxml.FXML;
2323
import javafx.fxml.Initializable;
@@ -52,15 +52,9 @@ public void initialize(URL location, ResourceBundle resources) {
5252
@Override
5353
public void handle(KeyEvent event) {
5454
if (event.getCode().equals(KeyCode.TAB)) {
55-
if (event.isShiftDown()) {
56-
textArea.setText(textArea.getText() + " ");
57-
textArea.positionCaret(textArea.getText().length());
58-
event.consume();
59-
} else {
60-
TextAreaSkin skin = (TextAreaSkin) textArea.getSkin();
61-
skin.getBehavior().traverseNext();
62-
event.consume();
63-
}
55+
textArea.setText(textArea.getText() + " ");
56+
textArea.positionCaret(textArea.getText().length());
57+
event.consume();
6458
}
6559
}
6660
});

src/test/java/javafxlibrary/utils/HelperFunctionsTests/GetMouseButtonsTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import javafx.scene.input.MouseButton;
44
import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
55
import javafxlibrary.utils.HelperFunctions;
6+
7+
import java.util.Arrays;
8+
69
import org.junit.Assert;
710
import org.junit.Rule;
811
import org.junit.Test;
@@ -50,7 +53,7 @@ public void getMouseButtons_MultipleValues() {
5053
public void getMouseButtons_InvalidValue() {
5154
thrown.expect(JavaFXLibraryNonFatalException.class);
5255
// thrown.expect(IllegalArgumentException.class);
53-
thrown.expectMessage("\"HUGE_RED_ONE\" is not a valid MouseButton. Accepted values are: [NONE, PRIMARY, MIDDLE, SECONDARY]");
56+
thrown.expectMessage("\"HUGE_RED_ONE\" is not a valid MouseButton. Accepted values are: " + Arrays.asList(MouseButton.values()));
5457
HelperFunctions.getMouseButtons(new String[]{"HUGE_RED_ONE"});
5558
}
5659

src/test/java/javafxlibrary/utils/HelperFunctionsTests/MapObjectsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void mapObjects_FromSet() {
4747

4848
@Test
4949
public void mapObjects_FromQueue() {
50-
Queue<Button> queue = new PriorityQueue<>();
50+
Queue<Button> queue = new LinkedList<>();
5151
queue.add(button);
5252
List<Object> keys = HelperFunctions.mapObjects(queue);
5353
Button b = (Button) TestFxAdapter.objectMap.get(keys.get(0));

src/test/robotframework/acceptance/MiscTests.robot

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ Get Table Cell Value Using Index That Is Out Of Bounds
311311
Set Test Application javafxlibrary.testapps.TestTableManagement
312312
${TABLE} Find id=table
313313
${MSG} Run Keyword And Expect Error * Get Table Cell Value ${TABLE} 0 40
314-
Should Be Equal ${MSG} Out of table bounds: Index: 40, Size: 5
314+
Should Be Equal ${MSG} Out of table bounds: Index 40 out of bounds for length 5
315315

316316
Get Object Property
317317
[Tags] smoke

0 commit comments

Comments
 (0)