map =
+ refs.values().stream().collect(toMap(ComponentReference::getID, value -> value));
if (!refs.equals(map)) {
// atomic update of references map
@@ -316,12 +313,12 @@ private synchronized void verify() throws InvalidScriptException {
for (ComponentReference ref : refs.values()) {
String id = ref.getAttribute(TAG_PARENT);
if (id != null && refs.get(id) == null) {
- String msg = Strings.get("script.parent_missing", new Object[]{id});
+ String msg = Strings.get("script.parent_missing", new Object[] {id});
throw new InvalidScriptException(msg);
}
id = ref.getAttribute(TAG_WINDOW);
if (id != null && refs.get(id) == null) {
- String msg = Strings.get("script.window_missing", new Object[]{id});
+ String msg = Strings.get("script.window_missing", new Object[] {id});
throw new InvalidScriptException(msg);
}
}
@@ -555,7 +552,7 @@ public String getUsage() {
@Override
public String getDefaultDescription() {
String ext = fork ? " &" : "";
- String desc = Strings.get("script.desc", new Object[]{getFilename(), ext});
+ String desc = Strings.get("script.desc", new Object[] {getFilename(), ext});
return desc.contains(UNTITLED_FILE) ? UNTITLED : desc;
}
@@ -689,7 +686,7 @@ private ComponentReference addComponentReference(Element el) throws InvalidScrip
public ComponentReference getComponentReference(Component comp) {
if (!getHierarchy().contains(comp)) {
- String msg = Strings.get("script.not_in_hierarchy", new Object[]{comp.toString()});
+ String msg = Strings.get("script.not_in_hierarchy", new Object[] {comp.toString()});
throw new IllegalArgumentException(msg);
}
synchReferenceIDs();
diff --git a/abbot/src/main/java/abbot/script/Sequence.java b/abbot/src/main/java/abbot/script/Sequence.java
index 28d2a3e..8b5019d 100644
--- a/abbot/src/main/java/abbot/script/Sequence.java
+++ b/abbot/src/main/java/abbot/script/Sequence.java
@@ -69,7 +69,7 @@ protected void parseChildren(Element el) throws InvalidScriptException {
}
public String getDefaultDescription() {
- return Strings.get("sequence.desc", new Object[]{String.valueOf(size())});
+ return Strings.get("sequence.desc", new Object[] {String.valueOf(size())});
}
public String getXMLTag() {
diff --git a/abbot/src/main/java/abbot/script/Step.java b/abbot/src/main/java/abbot/script/Step.java
index ee0b3e6..c54d185 100644
--- a/abbot/src/main/java/abbot/script/Step.java
+++ b/abbot/src/main/java/abbot/script/Step.java
@@ -26,6 +26,7 @@
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
+
/**
* Provides access to one step (line) from a script. A Step is the basic unit of execution.
* Custom Step classes
@@ -133,7 +134,7 @@ protected void usage() {
protected void usage(String details) {
String msg = getUsage();
if (details != null) {
- msg = Strings.get("step.usage", new Object[]{msg, details});
+ msg = Strings.get("step.usage", new Object[] {msg, details});
}
setScriptError(new InvalidScriptException(msg));
}
@@ -157,13 +158,14 @@ protected Element addContent(Element el) {
protected Element addAttributes(Element el) {
// Use a TreeMap to keep the attributes sorted on output
new TreeMap<>(getAttributes())
- .forEach((key, value) -> {
- if (value == null) {
- Log.warn("Attribute '" + key + "' value was null in step " + getXMLTag());
- value = "";
- }
- el.addAttribute(key, value);
- });
+ .forEach(
+ (key, value) -> {
+ if (value == null) {
+ Log.warn("Attribute '" + key + "' value was null in step " + getXMLTag());
+ value = "";
+ }
+ el.addAttribute(key, value);
+ });
return el;
}
@@ -204,11 +206,7 @@ public static Step createStep(Resolver resolver, String str)
protected static Map createAttributeMap(Element el) {
Log.debug("Creating attribute map for " + el);
- return el.attributes().stream()
- .collect(toMap(
- Attribute::getName,
- Attribute::getValue
- ));
+ return el.attributes().stream().collect(toMap(Attribute::getName, Attribute::getValue));
}
public static Step createStep(Resolver resolver, Element el) throws InvalidScriptException {
@@ -217,15 +215,11 @@ public static Step createStep(Resolver resolver, Element el) throws InvalidScrip
Map attributes;
if (tag.equals(TAG_WAIT)) {
- attributes = Stream
- .concat(
- createAttributeMap(el).entrySet().stream(),
- Map.of(TAG_WAIT, "true").entrySet().stream())
- .collect(
- Collectors.toMap(
- Entry::getKey,
- Entry::getValue
- ));
+ attributes =
+ Stream.concat(
+ createAttributeMap(el).entrySet().stream(),
+ Map.of(TAG_WAIT, "true").entrySet().stream())
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
name = "Assert";
} else {
attributes = createAttributeMap(el);
@@ -236,17 +230,17 @@ public static Step createStep(Resolver resolver, Element el) throws InvalidScrip
Class> cls = Class.forName(name);
try {
// Steps with contents require access to the XML element
- Class>[] argTypes = new Class>[]{Resolver.class, Element.class, Map.class};
+ Class>[] argTypes = new Class>[] {Resolver.class, Element.class, Map.class};
Constructor> ctor = cls.getConstructor(argTypes);
return (Step) ctor.newInstance(resolver, el, attributes);
} catch (NoSuchMethodException nsm) {
// All steps must support this ctor
- Class>[] argTypes = new Class>[]{Resolver.class, Map.class};
+ Class>[] argTypes = new Class>[] {Resolver.class, Map.class};
Constructor> ctor = cls.getConstructor(argTypes);
return (Step) ctor.newInstance(resolver, attributes);
}
} catch (ClassNotFoundException cnf) {
- String msg = Strings.get("step.unknown_tag", new Object[]{tag});
+ String msg = Strings.get("step.unknown_tag", new Object[] {tag});
throw new InvalidScriptException(msg);
} catch (InvocationTargetException ite) {
Log.warn(ite);
diff --git a/abbot/src/main/java/abbot/script/StepRunner.java b/abbot/src/main/java/abbot/script/StepRunner.java
index 8203749..16832c2 100644
--- a/abbot/src/main/java/abbot/script/StepRunner.java
+++ b/abbot/src/main/java/abbot/script/StepRunner.java
@@ -9,7 +9,6 @@
import abbot.i18n.Strings;
import abbot.util.AWTFixtureHelper;
import abbot.util.EDTExceptionCatcher;
-import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -207,8 +206,7 @@ public void run(Step step) throws Throwable {
Log.debug("App tried to exit");
terminate();
} finally {
- if (step instanceof Script
- && (stopped() && terminateOnStop)) {
+ if (step instanceof Script && (stopped() && terminateOnStop)) {
terminate();
}
removeSecurityManager();
@@ -236,9 +234,10 @@ protected void clearErrors() {
protected void checkFile(Script script) throws InvalidScriptException {
var file = script.getFile();
if (!file.exists() && !file.getName().startsWith(Script.UNTITLED_FILE)) {
- var msg = String.format(
- "The script '%s' does not exist at the expected location '%s'", script.getFilename(),
- file.getAbsolutePath());
+ var msg =
+ String.format(
+ "The script '%s' does not exist at the expected location '%s'",
+ script.getFilename(), file.getAbsolutePath());
throw new InvalidScriptException(msg);
}
}
diff --git a/abbot/src/main/java/abbot/tester/ComponentTester.java b/abbot/src/main/java/abbot/tester/ComponentTester.java
index d1090b9..8a87b47 100644
--- a/abbot/src/main/java/abbot/tester/ComponentTester.java
+++ b/abbot/src/main/java/abbot/tester/ComponentTester.java
@@ -324,7 +324,7 @@ protected String deriveAccessibleTag(AccessibleContext context) {
* be useful in a custom component if the method is supported.
*/
private static final String[] tagMethods = {
- "getLabel", "getTitle", "getText",
+ "getLabel", "getTitle", "getText",
};
public static String getTag(Component component) {
@@ -347,7 +347,7 @@ public String deriveTag(Component comp) {
for (String tagMethod : tagMethods) {
// Don't use getText on text components
if (((comp instanceof javax.swing.text.JTextComponent)
- || (comp instanceof java.awt.TextComponent))
+ || (comp instanceof java.awt.TextComponent))
&& "getText".equals(tagMethod)) {
continue;
}
@@ -474,8 +474,8 @@ public void actionSelectPopupMenuItem(Component invoker, String path) {
actionSelectPopupMenuItem(invoker, invoker.getWidth() / 2, invoker.getHeight() / 2, path);
}
- public void actionSelectPopupMenuItem(Component invoker, ComponentLocation location,
- String path) {
+ public void actionSelectPopupMenuItem(
+ Component invoker, ComponentLocation location, String path) {
selectPopupMenuItem(invoker, location, path);
waitForIdle();
}
@@ -740,7 +740,7 @@ public boolean test() {
}
public String toString() {
- return Strings.get("tester.Component.show_wait", new Object[]{identifier});
+ return Strings.get("tester.Component.show_wait", new Object[] {identifier});
}
},
componentDelay);
@@ -763,7 +763,7 @@ public boolean test() {
}
public String toString() {
- return Strings.get("tester.Component.show_wait", new Object[]{ref});
+ return Strings.get("tester.Component.show_wait", new Object[] {ref});
}
},
componentDelay);
@@ -792,8 +792,8 @@ private Method[] getMethods(String prefix, Class> returnType, boolean componen
Class>[] params = method.getParameterTypes();
if ((returnType == null || returnType.equals(method.getReturnType()))
&& ((params.length == 0 && !componentArgument)
- || (params.length > 0
- && (Component.class.isAssignableFrom(params[0]) == componentArgument)))) {
+ || (params.length > 0
+ && (Component.class.isAssignableFrom(params[0]) == componentArgument)))) {
methods.add(method);
names.add(name);
}
diff --git a/abbot/src/main/java/abbot/tester/JComboBoxTester.java b/abbot/src/main/java/abbot/tester/JComboBoxTester.java
index d5f73ca..42c7880 100644
--- a/abbot/src/main/java/abbot/tester/JComboBoxTester.java
+++ b/abbot/src/main/java/abbot/tester/JComboBoxTester.java
@@ -90,7 +90,8 @@ public String getValueAsString(JComboBox> combo, JList> list, Object item, i
// If the value is the default Object.toString method (which
// returns @), try to find something better.
if (value.startsWith(item.getClass().getName() + "@")) {
- ListCellRenderer super Object> renderer = (ListCellRenderer super Object>) combo.getRenderer();
+ ListCellRenderer super Object> renderer =
+ (ListCellRenderer super Object>) combo.getRenderer();
Component c = renderer.getListCellRendererComponent(list, item, index, true, true);
if (c instanceof javax.swing.JLabel) {
return ((javax.swing.JLabel) c).getText();
@@ -130,6 +131,6 @@ public void actionSelectItem(Component comp, String item) {
}
contents.append("]");
throw new ActionFailedException(
- Strings.get("tester.JComboBox.item_not_found", new Object[]{item, contents.toString()}));
+ Strings.get("tester.JComboBox.item_not_found", new Object[] {item, contents.toString()}));
}
}
diff --git a/abbot/src/main/java/abbot/tester/JListTester.java b/abbot/src/main/java/abbot/tester/JListTester.java
index f47e2a4..83d68e0 100644
--- a/abbot/src/main/java/abbot/tester/JListTester.java
+++ b/abbot/src/main/java/abbot/tester/JListTester.java
@@ -37,9 +37,10 @@ public class JListTester extends JComponentTester {
*/
static String valueToString(JList> list, int index) {
Object value = list.getModel().getElementAt(index);
- ListCellRenderer super Object> cellRenderer = (ListCellRenderer super Object>) list.getCellRenderer();
- Component renderedListComponent = cellRenderer
- .getListCellRendererComponent(list, value, index, false, false);
+ ListCellRenderer super Object> cellRenderer =
+ (ListCellRenderer super Object>) list.getCellRenderer();
+ Component renderedListComponent =
+ cellRenderer.getListCellRendererComponent(list, value, index, false, false);
return convertToString(renderedListComponent, value);
}
@@ -47,13 +48,14 @@ static String valueToString(JList> list, int index) {
private static String convertToString(Component renderedListComponent, Object value) {
return convertListValueIntoString(renderedListComponent)
.filter(v -> !v.isEmpty() && !ArgumentParser.isDefaultToString(v))
- .orElseGet(() -> {
- String string = ArgumentParser.toString(value);
- if (Objects.equals(string, ArgumentParser.DEFAULT_TOSTRING)) {
- return null;
- }
- return string;
- });
+ .orElseGet(
+ () -> {
+ String string = ArgumentParser.toString(value);
+ if (Objects.equals(string, ArgumentParser.DEFAULT_TOSTRING)) {
+ return null;
+ }
+ return string;
+ });
}
private static Optional convertListValueIntoString(Component renderedListComponent) {
@@ -123,7 +125,7 @@ public void actionSelectRow(JList> list, JListLocation location) {
int index = location.getIndex(list);
if (index < 0 || index >= list.getModel().getSize()) {
- String msg = Strings.get("tester.JList.invalid_index", new Object[]{index});
+ String msg = Strings.get("tester.JList.invalid_index", new Object[] {index});
throw new ActionFailedException(msg);
}
diff --git a/abbot/src/main/java/abbot/tester/JTreeTester.java b/abbot/src/main/java/abbot/tester/JTreeTester.java
index 70dfc5e..8746cac 100644
--- a/abbot/src/main/java/abbot/tester/JTreeTester.java
+++ b/abbot/src/main/java/abbot/tester/JTreeTester.java
@@ -39,8 +39,7 @@ public static boolean isLocationInExpandControl(JTree tree, int x, int y) {
row = tree.getClosestRowForLocation(x, y);
if (row != -1) {
Rectangle rect = tree.getRowBounds(row);
- if (row == tree.getRowCount() - 1
- && y >= rect.y + rect.height) {
+ if (row == tree.getRowCount() - 1 && y >= rect.y + rect.height) {
return false;
}
// An approximation: use a square area to the left of the row
@@ -160,7 +159,7 @@ public void actionSelectRow(Component component, ComponentLocation componentLoca
if (componentLocation instanceof JTreeLocation treeLocation) {
TreePath path = treeLocation.getPath((JTree) component);
if (path == null) {
- String msg = Strings.get("tester.JTree.path_not_found", new Object[]{componentLocation});
+ String msg = Strings.get("tester.JTree.path_not_found", new Object[] {componentLocation});
throw new LocationUnavailableException(msg);
}
makeVisible(component, path);
@@ -251,7 +250,7 @@ public boolean test() {
@Override
public String toString() {
- return Strings.get("tester.Component.show_wait", new Object[]{path.toString()});
+ return Strings.get("tester.Component.show_wait", new Object[] {path.toString()});
}
},
componentDelay);
@@ -298,8 +297,8 @@ public void actionToggleRow(Component component, ComponentLocation componentLoca
// Alternatively, we can reflect into the UI and do a single click
// on the appropriate expand location, but this is safer.
if (tree.getToggleClickCount() != 0) {
- actionClick(tree, componentLocation, InputEvent.BUTTON1_DOWN_MASK,
- tree.getToggleClickCount());
+ actionClick(
+ tree, componentLocation, InputEvent.BUTTON1_DOWN_MASK, tree.getToggleClickCount());
} else {
// BasicTreeUI provides this method; punt if we can't find it
if (!(tree.getUI() instanceof BasicTreeUI)) {
diff --git a/abbot/src/main/java/abbot/tester/Robot.java b/abbot/src/main/java/abbot/tester/Robot.java
index b4f3e69..3cb77ea 100644
--- a/abbot/src/main/java/abbot/tester/Robot.java
+++ b/abbot/src/main/java/abbot/tester/Robot.java
@@ -119,7 +119,7 @@ protected static final boolean useScreenMenuBar() {
// property is read once at startup and ignored thereafter.
return Platform.isOSX()
&& (Boolean.getBoolean("com.apple.macos.useScreenMenuBar")
- || Boolean.getBoolean("apple.laf.useScreenMenuBar"));
+ || Boolean.getBoolean("apple.laf.useScreenMenuBar"));
}
/**
@@ -395,7 +395,7 @@ public void run() {
long start = System.currentTimeMillis();
while (!fw.focused) {
if (System.currentTimeMillis() - start > componentDelay) {
- String msg = Strings.get("tester.Robot.focus_failed", new Object[]{toString(comp)});
+ String msg = Strings.get("tester.Robot.focus_failed", new Object[] {toString(comp)});
throw new ActionFailedException(msg);
}
sleep();
@@ -528,8 +528,7 @@ public void delay(int ms) {
private static final Runnable EMPTY_RUNNABLE =
new Runnable() {
@Override
- public void run() {
- }
+ public void run() {}
};
/**
@@ -542,9 +541,7 @@ protected boolean queueBlocked() {
}
protected boolean postInvocationEvent(EventQueue eq, Toolkit toolkit, long timeout) {
- class RobotIdleLock {
-
- }
+ class RobotIdleLock {}
Object lock = new RobotIdleLock();
synchronized (lock) {
eq.postEvent(new InvocationEvent(toolkit, EMPTY_RUNNABLE, lock, true));
@@ -1101,13 +1098,14 @@ public final void click(Component comp, int x, int y, int mask) {
}
public void click(Component comp, int x, int y, int mask, int count) {
- var message = "Click at ("
- + x
- + ","
- + y
- + ") on "
- + toString(comp)
- + (count > 1 ? (" count=" + count) : "");
+ var message =
+ "Click at ("
+ + x
+ + ","
+ + y
+ + ") on "
+ + toString(comp)
+ + (count > 1 ? (" count=" + count) : "");
Log.debug(message);
int keyModifiers = mask & ~AWTConstants.BUTTON_DOWN_MASK;
@@ -1148,12 +1146,12 @@ public void selectAWTMenuItemByLabel(Frame frame, String path) {
public void selectAWTMenuItem(Frame frame, String path) {
MenuBar mb = frame.getMenuBar();
if (mb == null) {
- String msg = Strings.get("tester.Robot.no_menu_bar", new Object[]{toString(frame)});
+ String msg = Strings.get("tester.Robot.no_menu_bar", new Object[] {toString(frame)});
throw new ActionFailedException(msg);
}
MenuItem[] items = AWT.findAWTMenuItems(frame, path);
if (items.length == 0) {
- String msg = Strings.get("tester.Robot.no_menu_item", new Object[]{path, toString(frame)});
+ String msg = Strings.get("tester.Robot.no_menu_item", new Object[] {path, toString(frame)});
throw new ActionFailedException(msg);
}
if (items.length > 1) {
@@ -1185,18 +1183,17 @@ public void selectAWTPopupMenuItem(Component invoker, String path) {
return;
} else if (items.length == 0) {
String msg =
- Strings.get("tester.Robot.no_popup_menu_item", new Object[]{path, toString(invoker)});
+ Strings.get("tester.Robot.no_popup_menu_item", new Object[] {path, toString(invoker)});
throw new ActionFailedException(msg);
}
- String msg = Strings.get("tester.Robot.multiple_menu_items", new Object[]{path});
+ String msg = Strings.get("tester.Robot.multiple_menu_items", new Object[] {path});
throw new ActionFailedException(msg);
} finally {
AWT.dismissAWTPopup();
}
}
- protected void fireAccessibleAction(
- Component context, AccessibleAction action, String name) {
+ protected void fireAccessibleAction(Component context, AccessibleAction action, String name) {
if (action != null && action.getAccessibleActionCount() > 0) {
invokeLater(
context,
@@ -1207,7 +1204,7 @@ public void run() {
}
});
} else {
- String msg = Strings.get("tester.Robot.no_accessible_action", new String[]{name});
+ String msg = Strings.get("tester.Robot.no_accessible_action", new String[] {name});
throw new ActionFailedException(msg);
}
}
@@ -1596,7 +1593,7 @@ public void run() {
(Boolean)
Toolkit.class
.getMethod("isFrameStateSupported", int.class)
- .invoke(toolkit, new Object[]{new Integer(MAXIMIZED_BOTH)});
+ .invoke(toolkit, new Object[] {new Integer(MAXIMIZED_BOTH)});
if (b.booleanValue() && !serviceMode) {
Frame.class
.getMethod("setExtendedState", int.class)
@@ -1892,8 +1889,7 @@ public static String getDescriptiveName(Component c) {
if ((name = getTitle(c)) == null) {
if ((name = getText(c)) == null) {
if ((name = getLabel(c)) == null) {
- if ((name = getIconName(c)) == null) {
- }
+ if ((name = getIconName(c)) == null) {}
}
}
}
diff --git a/abbot/src/main/java/abbot/util/AWT.java b/abbot/src/main/java/abbot/util/AWT.java
index c620c69..dfe7657 100644
--- a/abbot/src/main/java/abbot/util/AWT.java
+++ b/abbot/src/main/java/abbot/util/AWT.java
@@ -917,7 +917,9 @@ private static String getModifiers(int flags, boolean isMouse) {
// On a mac, ALT+BUTTON1 means BUTTON2; META+BUTTON1 means BUTTON3
int macModifiers =
- getDefaultToolkit().getMenuShortcutKeyMaskEx() | InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK;
+ getDefaultToolkit().getMenuShortcutKeyMaskEx()
+ | InputEvent.ALT_DOWN_MASK
+ | InputEvent.META_DOWN_MASK;
boolean isMacButton = isMouse && Platform.isMacintosh() && (flags & macModifiers) != 0;
String mods = "";
String or = "";
@@ -996,8 +998,12 @@ public static int getKeyCode(String code) {
public static boolean isModifier(int keycode) {
return switch (keycode) {
- case KeyEvent.VK_META, KeyEvent.VK_ALT, KeyEvent.VK_ALT_GRAPH, KeyEvent.VK_CONTROL,
- KeyEvent.VK_SHIFT -> true;
+ case KeyEvent.VK_META,
+ KeyEvent.VK_ALT,
+ KeyEvent.VK_ALT_GRAPH,
+ KeyEvent.VK_CONTROL,
+ KeyEvent.VK_SHIFT ->
+ true;
default -> false;
};
}
diff --git a/abbot/src/main/java/abbot/util/AbbotTimerTask.java b/abbot/src/main/java/abbot/util/AbbotTimerTask.java
index 0b7e1e8..8a78828 100644
--- a/abbot/src/main/java/abbot/util/AbbotTimerTask.java
+++ b/abbot/src/main/java/abbot/util/AbbotTimerTask.java
@@ -44,8 +44,7 @@ public abstract class AbbotTimerTask extends TimerTask {
/**
* Creates a new timer task.
*/
- protected AbbotTimerTask() {
- }
+ protected AbbotTimerTask() {}
/**
* The action to be performed by this timer task.
@@ -65,5 +64,4 @@ public boolean cancel() {
public boolean isCanceled() {
return state == CANCELLED;
}
-
}
diff --git a/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java b/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java
index 421d98d..81b77a1 100644
--- a/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java
+++ b/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java
@@ -89,8 +89,7 @@ public void run() {
// Does nothing but wait for the previous invocation to finish
AWT.invokeAndWait(
new Runnable() {
- public void run() {
- }
+ public void run() {}
});
System.setProperties(holder.properties);
String oldHandler = System.getProperty(PROP_NAME);
diff --git a/com.windowtester.junit5/pom.xml b/com.windowtester.junit5/pom.xml
index b0f20c2..a400dab 100644
--- a/com.windowtester.junit5/pom.xml
+++ b/com.windowtester.junit5/pom.xml
@@ -6,7 +6,7 @@
io.github.r4fterman
com.windowtester
- 6.0.0-SNAPSHOT
+ 6.0.1-SNAPSHOT
com.windowtester.junit5
@@ -32,4 +32,16 @@
junit-jupiter-api