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

Skip to content

Commit dde59e7

Browse files
committed
updated dependencies, refactored code
1 parent b401126 commit dde59e7

24 files changed

+110
-119
lines changed

pom.xml

+13-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>
@@ -233,7 +233,7 @@
233233
</plugin>
234234
<plugin>
235235
<artifactId>maven-assembly-plugin</artifactId>
236-
<version>3.2.0</version>
236+
<version>3.3.0</version>
237237
<executions>
238238
<execution>
239239
<phase>package</phase>
@@ -256,7 +256,7 @@
256256
<plugin>
257257
<groupId>org.robotframework</groupId>
258258
<artifactId>robotframework-maven-plugin</artifactId>
259-
<version>1.5.1</version>
259+
<version>1.7.1</version>
260260
<executions>
261261
<execution>
262262
<id>acceptance tests</id>
@@ -316,7 +316,7 @@
316316
<plugin>
317317
<groupId>org.apache.maven.plugins</groupId>
318318
<artifactId>maven-shade-plugin</artifactId>
319-
<version>3.2.1</version>
319+
<version>3.2.4</version>
320320
<executions>
321321
<execution>
322322
<phase>package</phase>
@@ -366,7 +366,7 @@
366366
<dependency>
367367
<groupId>org.apache.maven</groupId>
368368
<artifactId>maven-model</artifactId>
369-
<version>3.6.2</version>
369+
<version>3.6.3</version>
370370
</dependency>
371371
<dependency>
372372
<groupId>org.jmockit</groupId>
@@ -377,7 +377,7 @@
377377
<dependency>
378378
<groupId>junit</groupId>
379379
<artifactId>junit</artifactId>
380-
<version>4.12</version>
380+
<version>4.13</version>
381381
</dependency>
382382
<dependency>
383383
<groupId>org.testfx</groupId>
@@ -397,7 +397,7 @@
397397
<dependency>
398398
<groupId>org.robotframework</groupId>
399399
<artifactId>robotframework</artifactId>
400-
<version>3.1.2</version>
400+
<version>3.2.1</version>
401401
</dependency>
402402
<dependency>
403403
<groupId>org.hamcrest</groupId>
@@ -407,7 +407,7 @@
407407
<dependency>
408408
<groupId>com.google.guava</groupId>
409409
<artifactId>guava</artifactId>
410-
<version>28.1-jre</version>
410+
<version>29.0-jre</version>
411411
</dependency>
412412
<dependency>
413413
<groupId>org.robotframework</groupId>
@@ -417,12 +417,12 @@
417417
<dependency>
418418
<groupId>org.apache.commons</groupId>
419419
<artifactId>commons-lang3</artifactId>
420-
<version>3.9</version>
420+
<version>3.11</version>
421421
</dependency>
422422
<dependency>
423423
<groupId>commons-io</groupId>
424424
<artifactId>commons-io</artifactId>
425-
<version>2.6</version>
425+
<version>2.7</version>
426426
</dependency>
427427
</dependencies>
428428
</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/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/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) {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public FxRobotInterface clickOnCoordinates(int x, int y, String motion) {
150150
checkClickLocation(x, y);
151151

152152
try {
153-
return robot.clickOn((double) x, (double) y, getMotion(motion), MouseButton.PRIMARY);
153+
return robot.clickOn(x, y, getMotion(motion), MouseButton.PRIMARY);
154154
} catch (Exception e) {
155155
if (e instanceof JavaFXLibraryNonFatalException) {
156156
throw e;
@@ -167,7 +167,7 @@ public FxRobotInterface doubleClickOnCoordinates(int x, int y, String motion) {
167167
checkClickLocation(x, y);
168168
try {
169169
RobotLog.info("Double clicking on coordinates x=\"" + x + "\"" + ", y=\"" + y + "\"" + " and motion=\"" + motion + "\"");
170-
return robot.doubleClickOn((double) x, (double) y, getMotion(motion), MouseButton.PRIMARY);
170+
return robot.doubleClickOn(x, y, getMotion(motion), MouseButton.PRIMARY);
171171
} catch (Exception e) {
172172
if (e instanceof JavaFXLibraryNonFatalException) {
173173
throw e;
@@ -184,7 +184,7 @@ public FxRobotInterface rightClickOnCoordinates(int x, int y, String motion) {
184184
checkClickLocation(x, y);
185185
try {
186186
RobotLog.info("Right clicking on coordinates x=\"" + x + "\"" + ", y=\"" + y + "\"" + " and motion=\"" + motion + "\"");
187-
return robot.rightClickOn((double) x, (double) y, getMotion(motion));
187+
return robot.rightClickOn(x, y, getMotion(motion));
188188
} catch (Exception e) {
189189
if (e instanceof JavaFXLibraryNonFatalException) {
190190
throw e;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public FxRobotInterface dropBy(int x, int y) {
113113

114114
try {
115115
RobotLog.info("Dropping by x=\"" + x + "\" and y=\"" + y + "\"");
116-
return robot.dropBy((double) x, (double) y);
116+
return robot.dropBy(x, y);
117117
} catch (Exception e) {
118118
if (e instanceof JavaFXLibraryNonFatalException) {
119119
throw e;
@@ -134,7 +134,7 @@ public FxRobotInterface dropBy(int x, int y) {
134134
public FxRobotInterface dragFromCoordinates(int x, int y, String... buttons) {
135135
try {
136136
RobotLog.info("Dragging from x=\"" + x + "\" and y=\"" + y + "\" with buttons \"" + Arrays.toString(buttons) + "\"");
137-
return robot.drag((double) x, (double) y, HelperFunctions.getMouseButtons(buttons));
137+
return robot.drag(x, y, HelperFunctions.getMouseButtons(buttons));
138138
} catch (Exception e) {
139139
if (e instanceof JavaFXLibraryNonFatalException) {
140140
throw e;
@@ -153,7 +153,7 @@ public FxRobotInterface dragFromCoordinates(int x, int y, String... buttons) {
153153
public FxRobotInterface dropToCoordinates(int x, int y) {
154154
try {
155155
RobotLog.info("Dropping to x=\"" + x + "\" and y=\"" + y + "\"");
156-
return robot.dropTo((double) x, (double) y);
156+
return robot.dropTo(x, y);
157157
} catch (Exception e) {
158158
if ( e instanceof JavaFXLibraryNonFatalException ) {
159159
throw e;

0 commit comments

Comments
 (0)