RFR: 8315952: Open source several Swing JToolbar JTooltip JTree tests

Alexey Ivanov aivanov at openjdk.org
Mon Sep 18 14:07:45 UTC 2023


On Thu, 14 Sep 2023 21:34:56 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

> These are the tests being converted:
> 
> javax/swing/JToolBar/4368050/bug4368050.java
> javax/swing/JToolBar/4465534/bug4465534.java
> javax/swing/JToolBar/4700351/bug4700351.java
> javax/swing/JToolTip/4107843/bug4107843.java
> javax/swing/JTree/4161685/bug4161685.java

test/jdk/javax/swing/JToolBar/bug4368050.java line 47:

> 45:         oos.writeObject(toolBar);
> 46:         byte[] buf = baos.toByteArray();
> 47:         baos.close();

Use try-with-resources to close the streams automatically?

test/jdk/javax/swing/JToolBar/bug4465534.java line 39:

> 37:     public static void main(String[] args) throws InterruptedException,
> 38:             InvocationTargetException {
> 39:         SwingUtilities.invokeAndWait(() -> {

Safe to run on the main thread.

test/jdk/javax/swing/JToolBar/bug4700351.java line 41:

> 39:     static JFrame fr;
> 40:     static JToolBar tb;
> 41:     static BasicToolBarUI ui;

Both `tb` and `ui` can be converted to local variables.

test/jdk/javax/swing/JToolBar/bug4700351.java line 46:

> 44:             InvocationTargetException {
> 45:         SwingUtilities.invokeAndWait(() -> {
> 46:             fr = new JFrame("bug4700351");

Dispose of the frame when the test completes?

test/jdk/javax/swing/JToolTip/bug4107843.java line 45:

> 43:             tp.setToolTipTextAt(0, "first button");
> 44:             if (!tp.getToolTipTextAt(0).equals("first button")) {
> 45:                 throw new RuntimeException("ToolTipText doesn't set " +

Suggestion:

                throw new RuntimeException("ToolTipText isn't set " +

test/jdk/javax/swing/JToolTip/bug4107843.java line 50:

> 48:             tp.setToolTipTextAt(1, "second button");
> 49:             if (!tp.getToolTipTextAt(1).equals("second button")) {
> 50:                 throw new RuntimeException("ToolTipText doesn't set " +

Suggestion:

                throw new RuntimeException("ToolTipText isn't set " +

test/jdk/javax/swing/JTree/bug4161685.java line 45:

> 43:             tr.setAnchorSelectionPath(tp);
> 44:             if (tr.getAnchorSelectionPath() != tp) {
> 45:                 throw new RuntimeException("AnchorSelectionPath doesn't " +

Suggestion:

                throw new RuntimeException("AnchorSelectionPath isn't " +

test/jdk/javax/swing/JTree/bug4161685.java line 50:

> 48:             tr.setLeadSelectionPath(tp);
> 49:             if (tr.getLeadSelectionPath() != tp) {
> 50:                 throw new RuntimeException("LeadSelectionPath doesn't " +

Suggestion:

                throw new RuntimeException("LeadSelectionPath isn't " +

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328773986
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328776673
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328779989
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328779142
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328781616
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328781833
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328783007
PR Review Comment: https://git.openjdk.org/jdk/pull/15755#discussion_r1328783312


More information about the client-libs-dev mailing list