Skip to content

0.5.5 changes from development #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>org.robotframework</groupId>
<artifactId>javafxlibrary</artifactId>
<packaging>jar</packaging>
<version>0.5.4</version>
<version>0.5.5-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmockit.version>1.44</jmockit.version>
Expand Down Expand Up @@ -80,7 +80,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -93,7 +93,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -107,7 +107,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
Expand Down Expand Up @@ -195,7 +195,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand Down Expand Up @@ -232,8 +232,9 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -256,7 +257,7 @@
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.5.1</version>
<version>1.7.1</version>
<executions>
<execution>
<id>acceptance tests</id>
Expand Down Expand Up @@ -316,7 +317,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -366,7 +367,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.6.2</version>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
Expand All @@ -377,7 +378,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13</version>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
Expand All @@ -397,7 +398,7 @@
<dependency>
<groupId>org.robotframework</groupId>
<artifactId>robotframework</artifactId>
<version>3.1.2</version>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
Expand All @@ -407,7 +408,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>org.robotframework</groupId>
Expand All @@ -417,12 +418,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
<version>3.11</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.7</version>
</dependency>
</dependencies>
</project>
4 changes: 2 additions & 2 deletions src/main/java/JavaFXLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ public String getKeywordDocumentation(String keywordName) {
return FileUtils.readFileToString(new File("./src/main/java/libdoc-documentation.txt"), "utf-8");
} catch (IOException e) {
e.printStackTrace();
return "IOException occured while reading the documentation file!";
return "IOException occurred while reading the documentation file!";
}
} else if (keywordName.equals("__init__")) {
try {
return FileUtils.readFileToString(new File("./src/main/java/libdoc-init-documentation.txt"), "utf-8");
} catch (IOException e) {
e.printStackTrace();
return "IOException occured while reading the init documentation file!";
return "IOException occurred while reading the init documentation file!";
}
} else {
try {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/JavaFXLibraryRemoteServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ public JavaFXLibraryRemoteServer(int port) {
super(port);
}

private static Log log = LogFactory.getLog(RemoteServer.class);

public static void configureLogging() {
Configurator.initialize(new DefaultConfiguration());
Configurator.setRootLevel(Level.FATAL);
org.eclipse.jetty.util.log.Log.setLog(new Jetty2Log4J());
LogFactory.releaseAll();
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.Log4JLogger");
log = LogFactory.getLog(RemoteServer.class);
Log log = LogFactory.getLog(RemoteServer.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystems;
import java.util.*;

import static javafxlibrary.utils.HelperFunctions.createThreadedWrapperApplication;
Expand Down Expand Up @@ -106,7 +107,7 @@ private Class getMainClass(String appName) {
private void _addPathToClassPath(String path) {
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();

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

try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
Expand All @@ -133,11 +134,14 @@ public void setToClasspath(String path) {
try {
File directory = new File(path);
File[] fileList = directory.listFiles();

for (File file : fileList) {
if (file.getName().endsWith(".jar"))
boolean jarsFound = false;
for (File file : Objects.requireNonNull(fileList)) {
if (file.getName().endsWith(".jar")) {
jarsFound = true;
_addPathToClassPath(file.getAbsolutePath());
}
}
if(!jarsFound) throw new JavaFXLibraryNonFatalException("No jar files found from classpath: " + FileSystems.getDefault().getPath(path).normalize().toAbsolutePath().toString());
} catch (NullPointerException e) {
throw new JavaFXLibraryFatalException("Directory not found: " + path + "\n" + e.getMessage(), e);
}
Expand All @@ -160,7 +164,7 @@ public void logApplicationClasspath() {
}
}

@RobotKeyword("Sets system property ``name`` to ``value``. Equals commmand line usage `-Dname=value`.\n"
@RobotKeyword("Sets system property ``name`` to ``value``. Equals command line usage `-Dname=value`.\n"
+ "\nExample:\n"
+ "| Set System Property | locale | en_US | \n")
@ArgumentNames({ "name", "value" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void bringStageToFront(Stage stage) {
RobotLog.info("Bringing following Stage to front: \"" + stage + "\"");
try {
robot.targetWindow(stage);
Platform.runLater(() -> stage.toFront());
Platform.runLater(stage::toFront);
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Unable to bring stage to front.", e);
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public String[] listNodeMethods(Node node) {
RobotLog.info("Listing all available methods for node: \"" + node + "\"");
try {
Class klass = node.getClass();
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = new ArrayList<>();
System.out.println("*INFO*");
while (klass != null) {
String name = String.format("\n*%s*\n", klass.getName());
Expand All @@ -264,21 +264,21 @@ public String[] listNodeMethods(Node node) {
}
klass = klass.getSuperclass();
}
return list.toArray(new String[list.size()]);
return list.toArray(new String[0]);
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Listing node methods failed.", e);
}
}

private String getMethodDescription(Method m) {
String entry = m.getReturnType().getName() + " ";
entry += m.getName();
entry += "(";
StringBuilder entry = new StringBuilder(m.getReturnType().getName() + " ");
entry.append(m.getName());
entry.append("(");
Class[] args = m.getParameterTypes();
for (int i = 0; i < args.length; i++) {
entry += args[i].getName();
entry.append(args[i].getName());
if (i != args.length - 1)
entry += ", ";
entry.append(", ");
}
return entry + ")";
}
Expand Down Expand Up @@ -405,12 +405,11 @@ public Set<Object> getNodeChildrenByClassName(Object locator, String className)
Node node = objectToNode(locator);
RobotLog.info("Getting node: \"" + node + "\" children by class name: \"" + className + "\"");
try {
Set<Object> keys = new HashSet<Object>();
Set<Object> keys = new HashSet<>();
Set childNodes = node.lookupAll("*");
Iterator iter = childNodes.iterator();

while (iter.hasNext()) {
Node childNode = (Node) iter.next();
for (Object o : childNodes) {
Node childNode = (Node) o;
if (childNode.getClass().getSimpleName().equals(className)) {
RobotLog.trace("Classname: \"" + className + "\" found: \"" + childNode + "\"");
keys.add(mapObject(childNode));
Expand Down Expand Up @@ -455,7 +454,7 @@ public String getNodeHeight(Object locator) {
for (Method m : methods) {
if (m.getName().equals("getHeight")) {
try {
Object result = m.invoke(node, null);
Object result = m.invoke(node, (Object) null);
return result.toString();
} catch (Exception e) {
throw new JavaFXLibraryNonFatalException("Problem calling method: .getHeight(): " + e.getMessage(), e);
Expand Down Expand Up @@ -486,7 +485,7 @@ public String getNodeImageUrl(Object locator) {
if (m.getName().equals("getImage") && m.getParameterCount() == 0) {
RobotLog.trace("Method getImage() found. Invoking it on node: \"" + node + "\"");
try {
Object result = m.invoke(node, null);
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();
Expand Down Expand Up @@ -594,7 +593,7 @@ public String getWindowTitle(Object object) {

try {
Method m = object.getClass().getMethod("getTitle");
return (String) m.invoke(object, null);
return (String) m.invoke(object, (Object[]) null);
} catch (NoSuchMethodException e) {
RobotLog.info("This window type has no getTitle() -method. Returning null");
return "";
Expand Down Expand Up @@ -700,7 +699,7 @@ public List<Object> getTableColumnCells(Object locator, int column) {
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: " + Integer.toString(i));
RobotLog.info("Index number: " + i);
columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column)));
}

Expand Down Expand Up @@ -867,7 +866,7 @@ public Object getSelectedRadioButton(Object locator) {

try{
RadioButton rb = (RadioButton)objectToNode(locator);
return (Node)rb.getToggleGroup().getSelectedToggle();
return rb.getToggleGroup().getSelectedToggle();

} catch (ClassCastException cce) {
throw new JavaFXLibraryNonFatalException("Unable to handle given locator as RadioButton!");
Expand Down Expand Up @@ -998,7 +997,7 @@ public Double getScrollPaneHorizontalValue(Object locator){
}
}

@RobotKeyword("Returns the selected date from given datepicker element\n\n"
@RobotKeyword("Returns the selected date from given DatePicker element\n\n"
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the DatePicker element, see "
+ "`3. Locating JavaFX Nodes`. \n\n"
+ "\nExample:\n"
Expand Down Expand Up @@ -1098,7 +1097,7 @@ public void waitForEventsInFxApplicationThread(int timeout) {
final Throwable[] threadException = new JavaFXLibraryNonFatalException[1];
try {
Semaphore semaphore = new Semaphore(0);
Platform.runLater(() -> semaphore.release());
Platform.runLater(semaphore::release);
Thread t = new Thread(() -> {
int passed = 0;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public Object find(String query, boolean failIfNotFound, Parent root) {
@ArgumentNames({"query", "failIfNotFound=False", "root="})
public List<Object> findAll(String query, boolean failIfNotFound, Parent root) {
try {
RobotLog.info("Trying to find all nodes matching the query: \"" + query + "\", failIfNotFound=\"" +
failIfNotFound + "\", root=\"" + root + "\"");
if (root != null) {
return mapObjects(new Finder().findAll(query, root));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
@RobotKeywords
public class RunOnFailure extends TestFxAdapter{

// The keyword to run an failure
private String runOnFailureKeyword = "Take Screenshot";

// Only run keyword on failure if false
private static boolean runningOnFailureRoutine = false;

Expand All @@ -49,6 +46,8 @@ public class RunOnFailure extends TestFxAdapter{

public void runOnFailure() {

// The keyword to run an failure
String runOnFailureKeyword = "Take Screenshot";
RobotLog.debug("Executing cleanup functions by running: " + runOnFailureKeyword);
RobotLog.debug("runningOnFailureRoutine: " + runningOnFailureRoutine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.testfx.service.support.impl.PixelMatcherRgb;
import org.hamcrest.core.IsNot;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.testfx.api.FxAssert.verifyThat;
import static org.testfx.matcher.base.NodeMatchers.*;
import static javafxlibrary.utils.HelperFunctions.*;
Expand Down Expand Up @@ -330,9 +330,9 @@ public void boundsShouldBeEqual(Bounds firstBounds, Bounds secondBounds) {
RobotLog.info("Checking if \"" + firstBounds + "\" equals with \"" + secondBounds + "\".");
if (firstBounds == null || secondBounds == null )
throw new JavaFXLibraryNonFatalException("One of the bounds is null. Check log for additional info.");
assertTrue("Expected bounds to be equal:\n"
assertEquals("Expected bounds to be equal:\n"
+ " First bound: " + firstBounds + "\n"
+ " Second bound: " + secondBounds, firstBounds.equals(secondBounds));
+ " Second bound: " + secondBounds, firstBounds, secondBounds);
}

@RobotKeyword("Checks if given two bounds are not equal. \n\n"
Expand All @@ -343,9 +343,9 @@ public void boundsShouldNotBeEqual(Bounds firstBounds, Bounds secondBounds) {
RobotLog.info("Checking if \"" + firstBounds + "\" are not equal with \"" + secondBounds + "\".");
if (firstBounds == null || secondBounds == null )
throw new JavaFXLibraryNonFatalException("One of the bounds is null. Check log for additional info.");
assertTrue("Expected bounds to be not equal:\n"
assertNotEquals("Expected bounds to be not equal:\n"
+ " First bound: " + firstBounds + "\n"
+ " Second bound: " + secondBounds, !firstBounds.equals(secondBounds));
+ " Second bound: " + secondBounds, firstBounds, secondBounds);
}

@RobotKeyword("Fails if images are not similar enough\n\n"
Expand Down Expand Up @@ -443,6 +443,7 @@ public static void toggleButtonShouldNotBeSelected(Object locator) {
throw new JavaFXLibraryNonFatalException("Unable to handle given locator as ToggleButton!");
}
}

@RobotKeyword("Waits until given ProgressBar is finished or timeout expires. \n\n"
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the ToggleButton element, see "
+ " `3. Locating JavaFX Nodes`. \n\n"
Expand Down
Loading