Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8278977

Browse files
committed
Merge branch 'master' of github.com:eficode/JavaFXLibrary
2 parents 6e08488 + fe86001 commit 8278977

30 files changed

+179
-140
lines changed

pom.xml

+14-13
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<plugin>
8181
<groupId>org.apache.maven.plugins</groupId>
8282
<artifactId>maven-source-plugin</artifactId>
83-
<version>3.1.0</version>
83+
<version>3.2.1</version>
8484
<executions>
8585
<execution>
8686
<id>attach-sources</id>
@@ -93,7 +93,7 @@
9393
<plugin>
9494
<groupId>org.apache.maven.plugins</groupId>
9595
<artifactId>maven-javadoc-plugin</artifactId>
96-
<version>3.1.1</version>
96+
<version>3.2.0</version>
9797
<executions>
9898
<execution>
9999
<id>attach-javadocs</id>
@@ -107,7 +107,7 @@
107107
<plugin>
108108
<groupId>org.codehaus.mojo</groupId>
109109
<artifactId>build-helper-maven-plugin</artifactId>
110-
<version>3.0.0</version>
110+
<version>3.2.0</version>
111111
<executions>
112112
<execution>
113113
<id>attach-artifacts</id>
@@ -195,7 +195,7 @@
195195
<plugin>
196196
<groupId>org.sonatype.plugins</groupId>
197197
<artifactId>nexus-staging-maven-plugin</artifactId>
198-
<version>1.6.7</version>
198+
<version>1.6.8</version>
199199
<extensions>true</extensions>
200200
<configuration>
201201
<serverId>ossrh</serverId>
@@ -232,8 +232,9 @@
232232
</executions>
233233
</plugin>
234234
<plugin>
235+
<groupId>org.apache.maven.plugins</groupId>
235236
<artifactId>maven-assembly-plugin</artifactId>
236-
<version>3.2.0</version>
237+
<version>3.3.0</version>
237238
<executions>
238239
<execution>
239240
<phase>package</phase>
@@ -256,7 +257,7 @@
256257
<plugin>
257258
<groupId>org.robotframework</groupId>
258259
<artifactId>robotframework-maven-plugin</artifactId>
259-
<version>1.5.1</version>
260+
<version>1.7.1</version>
260261
<executions>
261262
<execution>
262263
<id>acceptance tests</id>
@@ -316,7 +317,7 @@
316317
<plugin>
317318
<groupId>org.apache.maven.plugins</groupId>
318319
<artifactId>maven-shade-plugin</artifactId>
319-
<version>3.2.1</version>
320+
<version>3.2.4</version>
320321
<executions>
321322
<execution>
322323
<phase>package</phase>
@@ -366,7 +367,7 @@
366367
<dependency>
367368
<groupId>org.apache.maven</groupId>
368369
<artifactId>maven-model</artifactId>
369-
<version>3.6.2</version>
370+
<version>3.6.3</version>
370371
</dependency>
371372
<dependency>
372373
<groupId>org.jmockit</groupId>
@@ -377,7 +378,7 @@
377378
<dependency>
378379
<groupId>junit</groupId>
379380
<artifactId>junit</artifactId>
380-
<version>4.12</version>
381+
<version>4.13</version>
381382
</dependency>
382383
<dependency>
383384
<groupId>org.testfx</groupId>
@@ -397,7 +398,7 @@
397398
<dependency>
398399
<groupId>org.robotframework</groupId>
399400
<artifactId>robotframework</artifactId>
400-
<version>3.1.2</version>
401+
<version>3.2.1</version>
401402
</dependency>
402403
<dependency>
403404
<groupId>org.hamcrest</groupId>
@@ -407,7 +408,7 @@
407408
<dependency>
408409
<groupId>com.google.guava</groupId>
409410
<artifactId>guava</artifactId>
410-
<version>28.1-jre</version>
411+
<version>29.0-jre</version>
411412
</dependency>
412413
<dependency>
413414
<groupId>org.robotframework</groupId>
@@ -417,12 +418,12 @@
417418
<dependency>
418419
<groupId>org.apache.commons</groupId>
419420
<artifactId>commons-lang3</artifactId>
420-
<version>3.9</version>
421+
<version>3.11</version>
421422
</dependency>
422423
<dependency>
423424
<groupId>commons-io</groupId>
424425
<artifactId>commons-io</artifactId>
425-
<version>2.6</version>
426+
<version>2.7</version>
426427
</dependency>
427428
</dependencies>
428429
</project>

src/main/java/JavaFXLibrary.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ public String getKeywordDocumentation(String keywordName) {
224224
return FileUtils.readFileToString(new File("./src/main/java/libdoc-documentation.txt"), "utf-8");
225225
} catch (IOException e) {
226226
e.printStackTrace();
227-
return "IOException occured while reading the documentation file!";
227+
return "IOException occurred while reading the documentation file!";
228228
}
229229
} else if (keywordName.equals("__init__")) {
230230
try {
231231
return FileUtils.readFileToString(new File("./src/main/java/libdoc-init-documentation.txt"), "utf-8");
232232
} catch (IOException e) {
233233
e.printStackTrace();
234-
return "IOException occured while reading the init documentation file!";
234+
return "IOException occurred while reading the init documentation file!";
235235
}
236236
} else {
237237
try {

src/main/java/JavaFXLibraryRemoteServer.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ public JavaFXLibraryRemoteServer(int port) {
2929
super(port);
3030
}
3131

32-
private static Log log = LogFactory.getLog(RemoteServer.class);
33-
3432
public static void configureLogging() {
3533
Configurator.initialize(new DefaultConfiguration());
3634
Configurator.setRootLevel(Level.FATAL);
3735
org.eclipse.jetty.util.log.Log.setLog(new Jetty2Log4J());
3836
LogFactory.releaseAll();
3937
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
4038
"org.apache.commons.logging.impl.Log4JLogger");
41-
log = LogFactory.getLog(RemoteServer.class);
39+
Log log = LogFactory.getLog(RemoteServer.class);
4240
}
4341
}

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.lang.reflect.Method;
3030
import java.net.URL;
3131
import java.net.URLClassLoader;
32+
import java.nio.file.FileSystems;
3233
import java.util.*;
3334

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

109-
RobotLog.info("Setting following path to Classpath: " + path);
110+
RobotLog.info("Setting following path to classpath: " + path);
110111

111112
try {
112113
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
@@ -133,11 +134,14 @@ public void setToClasspath(String path) {
133134
try {
134135
File directory = new File(path);
135136
File[] fileList = directory.listFiles();
136-
137-
for (File file : fileList) {
138-
if (file.getName().endsWith(".jar"))
137+
boolean jarsFound = false;
138+
for (File file : Objects.requireNonNull(fileList)) {
139+
if (file.getName().endsWith(".jar")) {
140+
jarsFound = true;
139141
_addPathToClassPath(file.getAbsolutePath());
142+
}
140143
}
144+
if(!jarsFound) throw new JavaFXLibraryNonFatalException("No jar files found from classpath: " + FileSystems.getDefault().getPath(path).normalize().toAbsolutePath().toString());
141145
} catch (NullPointerException e) {
142146
throw new JavaFXLibraryFatalException("Directory not found: " + path + "\n" + e.getMessage(), e);
143147
}
@@ -160,7 +164,7 @@ public void logApplicationClasspath() {
160164
}
161165
}
162166

163-
@RobotKeyword("Sets system property ``name`` to ``value``. Equals commmand line usage `-Dname=value`.\n"
167+
@RobotKeyword("Sets system property ``name`` to ``value``. Equals command line usage `-Dname=value`.\n"
164168
+ "\nExample:\n"
165169
+ "| Set System Property | locale | en_US | \n")
166170
@ArgumentNames({ "name", "value" })

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

+18-19
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void bringStageToFront(Stage stage) {
8585
RobotLog.info("Bringing following Stage to front: \"" + stage + "\"");
8686
try {
8787
robot.targetWindow(stage);
88-
Platform.runLater(() -> stage.toFront());
88+
Platform.runLater(stage::toFront);
8989
} catch (Exception e) {
9090
throw new JavaFXLibraryNonFatalException("Unable to bring stage to front.", e);
9191
}
@@ -251,7 +251,7 @@ public String[] listNodeMethods(Node node) {
251251
RobotLog.info("Listing all available methods for node: \"" + node + "\"");
252252
try {
253253
Class klass = node.getClass();
254-
ArrayList<String> list = new ArrayList<String>();
254+
ArrayList<String> list = new ArrayList<>();
255255
System.out.println("*INFO*");
256256
while (klass != null) {
257257
String name = String.format("\n*%s*\n", klass.getName());
@@ -264,21 +264,21 @@ public String[] listNodeMethods(Node node) {
264264
}
265265
klass = klass.getSuperclass();
266266
}
267-
return list.toArray(new String[list.size()]);
267+
return list.toArray(new String[0]);
268268
} catch (Exception e) {
269269
throw new JavaFXLibraryNonFatalException("Listing node methods failed.", e);
270270
}
271271
}
272272

273273
private String getMethodDescription(Method m) {
274-
String entry = m.getReturnType().getName() + " ";
275-
entry += m.getName();
276-
entry += "(";
274+
StringBuilder entry = new StringBuilder(m.getReturnType().getName() + " ");
275+
entry.append(m.getName());
276+
entry.append("(");
277277
Class[] args = m.getParameterTypes();
278278
for (int i = 0; i < args.length; i++) {
279-
entry += args[i].getName();
279+
entry.append(args[i].getName());
280280
if (i != args.length - 1)
281-
entry += ", ";
281+
entry.append(", ");
282282
}
283283
return entry + ")";
284284
}
@@ -405,12 +405,11 @@ public Set<Object> getNodeChildrenByClassName(Object locator, String className)
405405
Node node = objectToNode(locator);
406406
RobotLog.info("Getting node: \"" + node + "\" children by class name: \"" + className + "\"");
407407
try {
408-
Set<Object> keys = new HashSet<Object>();
408+
Set<Object> keys = new HashSet<>();
409409
Set childNodes = node.lookupAll("*");
410-
Iterator iter = childNodes.iterator();
411410

412-
while (iter.hasNext()) {
413-
Node childNode = (Node) iter.next();
411+
for (Object o : childNodes) {
412+
Node childNode = (Node) o;
414413
if (childNode.getClass().getSimpleName().equals(className)) {
415414
RobotLog.trace("Classname: \"" + className + "\" found: \"" + childNode + "\"");
416415
keys.add(mapObject(childNode));
@@ -455,7 +454,7 @@ public String getNodeHeight(Object locator) {
455454
for (Method m : methods) {
456455
if (m.getName().equals("getHeight")) {
457456
try {
458-
Object result = m.invoke(node, null);
457+
Object result = m.invoke(node, (Object) null);
459458
return result.toString();
460459
} catch (Exception e) {
461460
throw new JavaFXLibraryNonFatalException("Problem calling method: .getHeight(): " + e.getMessage(), e);
@@ -486,7 +485,7 @@ public String getNodeImageUrl(Object locator) {
486485
if (m.getName().equals("getImage") && m.getParameterCount() == 0) {
487486
RobotLog.trace("Method getImage() found. Invoking it on node: \"" + node + "\"");
488487
try {
489-
Object result = m.invoke(node, null);
488+
Object result = m.invoke(node, (Object) null);
490489
Image image = (Image) result;
491490
RobotLog.trace("Calling deprecated method impl_getUrl() for image: \"" + image + "\"");
492491
return image.impl_getUrl();
@@ -594,7 +593,7 @@ public String getWindowTitle(Object object) {
594593

595594
try {
596595
Method m = object.getClass().getMethod("getTitle");
597-
return (String) m.invoke(object, null);
596+
return (String) m.invoke(object, (Object[]) null);
598597
} catch (NoSuchMethodException e) {
599598
RobotLog.info("This window type has no getTitle() -method. Returning null");
600599
return "";
@@ -700,7 +699,7 @@ public List<Object> getTableColumnCells(Object locator, int column) {
700699
VirtualFlow<?> vf = (VirtualFlow<?>) ( (TableViewSkin<?>) table.getSkin() ).getChildren().get( 1 );
701700

702701
for(int i = vf.getFirstVisibleCell().getIndex(); i < vf.getLastVisibleCell().getIndex() + 1; i++) {
703-
RobotLog.info("Index number: " + Integer.toString(i));
702+
RobotLog.info("Index number: " + i);
704703
columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column)));
705704
}
706705

@@ -867,7 +866,7 @@ public Object getSelectedRadioButton(Object locator) {
867866

868867
try{
869868
RadioButton rb = (RadioButton)objectToNode(locator);
870-
return (Node)rb.getToggleGroup().getSelectedToggle();
869+
return rb.getToggleGroup().getSelectedToggle();
871870

872871
} catch (ClassCastException cce) {
873872
throw new JavaFXLibraryNonFatalException("Unable to handle given locator as RadioButton!");
@@ -998,7 +997,7 @@ public Double getScrollPaneHorizontalValue(Object locator){
998997
}
999998
}
1000999

1001-
@RobotKeyword("Returns the selected date from given datepicker element\n\n"
1000+
@RobotKeyword("Returns the selected date from given DatePicker element\n\n"
10021001
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the DatePicker element, see "
10031002
+ "`3. Locating JavaFX Nodes`. \n\n"
10041003
+ "\nExample:\n"
@@ -1098,7 +1097,7 @@ public void waitForEventsInFxApplicationThread(int timeout) {
10981097
final Throwable[] threadException = new JavaFXLibraryNonFatalException[1];
10991098
try {
11001099
Semaphore semaphore = new Semaphore(0);
1101-
Platform.runLater(() -> semaphore.release());
1100+
Platform.runLater(semaphore::release);
11021101
Thread t = new Thread(() -> {
11031102
int passed = 0;
11041103
try {

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

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public Object find(String query, boolean failIfNotFound, Parent root) {
7272
@ArgumentNames({"query", "failIfNotFound=False", "root="})
7373
public List<Object> findAll(String query, boolean failIfNotFound, Parent root) {
7474
try {
75+
RobotLog.info("Trying to find all nodes matching the query: \"" + query + "\", failIfNotFound=\"" +
76+
failIfNotFound + "\", root=\"" + root + "\"");
7577
if (root != null) {
7678
return mapObjects(new Finder().findAll(query, root));
7779
} else {

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
@RobotKeywords
3131
public class RunOnFailure extends TestFxAdapter{
3232

33-
// The keyword to run an failure
34-
private String runOnFailureKeyword = "Take Screenshot";
35-
3633
// Only run keyword on failure if false
3734
private static boolean runningOnFailureRoutine = false;
3835

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

5047
public void runOnFailure() {
5148

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

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.testfx.service.support.impl.PixelMatcherRgb;
4141
import org.hamcrest.core.IsNot;
4242

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

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

351351
@RobotKeyword("Fails if images are not similar enough\n\n"
@@ -443,6 +443,7 @@ public static void toggleButtonShouldNotBeSelected(Object locator) {
443443
throw new JavaFXLibraryNonFatalException("Unable to handle given locator as ToggleButton!");
444444
}
445445
}
446+
446447
@RobotKeyword("Waits until given ProgressBar is finished or timeout expires. \n\n"
447448
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the ToggleButton element, see "
448449
+ " `3. Locating JavaFX Nodes`. \n\n"

src/main/java/javafxlibrary/keywords/Keywords/BoundsLocation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Object createPoint(double x, double y) {
8686
@ArgumentNames({"minX", "minY", "width", "height"})
8787
public Object createRectangle(double minX, double minY, double width, double height) {
8888
try {
89-
RobotLog.info("Creating retangle object with minX=\"" + minX + "\", minY=\"" + minY + "\", width=\"" +
89+
RobotLog.info("Creating rectangle object with minX=\"" + minX + "\", minY=\"" + minY + "\", width=\"" +
9090
width + "\" and height=\"" + height + "\"");
9191
return mapObject(new Rectangle2D(minX, minY, width, height));
9292
} catch (Exception e) {

0 commit comments

Comments
 (0)