Skip to content

Commit

Permalink
java 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Turmio committed Apr 4, 2023
1 parent 3c113f8 commit 1dfaccf
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 36 deletions.
41 changes: 37 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -260,7 +260,7 @@
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.7.1</version>
<version>2.1.0</version>
<executions>
<execution>
<id>acceptance tests</id>
Expand Down Expand Up @@ -367,6 +367,39 @@
</build>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
<classifier>mac</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
Expand All @@ -391,7 +424,7 @@
<dependency>
<groupId>org.testfx</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>8u76-b04</version>
<version>jdk-12.0.1+2</version>
</dependency>
<dependency>
<groupId>org.robotframework</groupId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/JavaFXLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public JavaFXLibrary(boolean headless) {
if (headless) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("glass.platform", "Monocle");
System.setProperty("monocle.platform", "Headless");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
TestFxAdapter.isHeadless = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,12 @@ private Class getMainClass(String appName) {
}

private void addPathToClassPath(String path) {
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();

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

try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(classLoader, (new File(path)).toURI().toURL());
URL[] urls = new URL[]{new File(path).toURI().toURL()};
URLClassLoader classLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());

} catch (Exception e) {
throw new JavaFXLibraryFatalException("Problem setting the classpath: " + path, e);
Expand Down Expand Up @@ -176,11 +174,11 @@ public void setToClasspath(String path, boolean failIfNotFound) {
@RobotKeyword("Logs current classpath content")
public void logApplicationClasspath() {
try {
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader) cl).getURLs();
RobotLog.info("Printing out classpaths: \n");
for (URL url : urls) {
RobotLog.info(url.getFile());

String classpathStr = System.getProperty("java.class.path");
for (String classpathItem : classpathStr.split(System.getProperty("path.separator"))) {
RobotLog.info(classpathItem);
}
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to log application classpaths", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package javafxlibrary.keywords.AdditionalKeywords;

import com.sun.javafx.scene.control.skin.TableViewSkin;
import com.sun.javafx.scene.control.skin.VirtualFlow;
import javafx.scene.control.skin.TableViewSkin;
import javafx.scene.control.skin.VirtualFlow;
import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.geometry.BoundingBox;
Expand Down Expand Up @@ -279,7 +279,7 @@ public String getNodeText(Object locator) {
@RobotKeyword("Returns image name and path of the node. \n\n"
+ "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see "
+ "`3. Locating JavaFX Nodes`. \n\n"
+ "Returns full image path by subsequently calling impl_getUrl -method. \n\n"
+ "Returns full image path by subsequently calling getUrl -method. \n\n"
+ "Note, impl_getUrl -method is deprecated! Support for this method will be removed from Java in the future.")
@ArgumentNames({"node"})
public String getNodeImageUrl(Object locator) {
Expand All @@ -294,8 +294,7 @@ public String getNodeImageUrl(Object locator) {
try {
Object result = m.invoke(node, (Object) null);
Image image = (Image) result;
RobotLog.trace("Calling deprecated method impl_getUrl() for image: \"" + image + "\"");
return image.impl_getUrl();
return image.getUrl();
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Problem calling method: .getImage(): " + e.getMessage(), e);
}
Expand Down Expand Up @@ -480,13 +479,17 @@ public List<Object> getTableColumnCells(Object locator, int column) {
RobotLog.info("Getting table \"" + locator + "\" cells from column \"" + column + "\".");
TableView table = (TableView) objectToNode(locator);
List<Object> columnCells = new ArrayList<>();
VirtualFlow<?> vf = (VirtualFlow<?>) ((TableViewSkin<?>) table.getSkin()).getChildren().get(1);

for (int i = vf.getFirstVisibleCell().getIndex(); i < vf.getLastVisibleCell().getIndex() + 1; i++) {
RobotLog.info("Index number: " + i);
columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column)));
Optional<VirtualFlow> vf = table.getChildrenUnmodifiable().stream().filter(node -> node instanceof VirtualFlow).map(VirtualFlow.class::cast).findFirst();
if (vf.isPresent()) {
VirtualFlow virtualFlow = vf.get();
for (int i = virtualFlow.getFirstVisibleCell().getIndex(); i < virtualFlow.getLastVisibleCell().getIndex() + 1; i++) {
RobotLog.info("Index number: " + i);
columnCells.add(mapObject(virtualFlow.getCell(i).getChildrenUnmodifiable().get(column)));
}
return mapObjects(columnCells);
} else {
throw new JavaFXLibraryNonFatalException("Could not find VirtualFlow from Tableview!");
}
return mapObjects(columnCells);
} catch (ClassCastException cce) {
throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/javafxlibrary/TestFxAdapterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public FxRobotInterface getRobot() {
public static void setupTests() {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("glass.platform", "Monocle");
System.setProperty("monocle.platform", "Headless");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package javafxlibrary.testapps.controllers;

import com.sun.javafx.scene.control.skin.TextAreaSkin;
import javafx.scene.control.skin.TextAreaSkin;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
Expand Down Expand Up @@ -52,15 +52,9 @@ public void initialize(URL location, ResourceBundle resources) {
@Override
public void handle(KeyEvent event) {
if (event.getCode().equals(KeyCode.TAB)) {
if (event.isShiftDown()) {
textArea.setText(textArea.getText() + " ");
textArea.positionCaret(textArea.getText().length());
event.consume();
} else {
TextAreaSkin skin = (TextAreaSkin) textArea.getSkin();
skin.getBehavior().traverseNext();
event.consume();
}
textArea.setText(textArea.getText() + " ");
textArea.positionCaret(textArea.getText().length());
event.consume();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import javafx.scene.input.MouseButton;
import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
import javafxlibrary.utils.HelperFunctions;

import java.util.Arrays;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -50,7 +53,7 @@ public void getMouseButtons_MultipleValues() {
public void getMouseButtons_InvalidValue() {
thrown.expect(JavaFXLibraryNonFatalException.class);
// thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("\"HUGE_RED_ONE\" is not a valid MouseButton. Accepted values are: [NONE, PRIMARY, MIDDLE, SECONDARY]");
thrown.expectMessage("\"HUGE_RED_ONE\" is not a valid MouseButton. Accepted values are: " + Arrays.asList(MouseButton.values()));
HelperFunctions.getMouseButtons(new String[]{"HUGE_RED_ONE"});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void mapObjects_FromSet() {

@Test
public void mapObjects_FromQueue() {
Queue<Button> queue = new PriorityQueue<>();
Queue<Button> queue = new LinkedList<>();
queue.add(button);
List<Object> keys = HelperFunctions.mapObjects(queue);
Button b = (Button) TestFxAdapter.objectMap.get(keys.get(0));
Expand Down
2 changes: 1 addition & 1 deletion src/test/robotframework/acceptance/MiscTests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Get Table Cell Value Using Index That Is Out Of Bounds
Set Test Application javafxlibrary.testapps.TestTableManagement
${TABLE} Find id=table
${MSG} Run Keyword And Expect Error * Get Table Cell Value ${TABLE} 0 40
Should Be Equal ${MSG} Out of table bounds: Index: 40, Size: 5
Should Be Equal ${MSG} Out of table bounds: Index 40 out of bounds for length 5

Get Object Property
[Tags] smoke
Expand Down

0 comments on commit 1dfaccf

Please sign in to comment.