RFR: 8281535: Create a regression test for JDK-4670051

Alexey Ivanov aivanov at openjdk.java.net
Fri Feb 11 12:59:18 UTC 2022


On Wed, 9 Feb 2022 14:58:10 GMT, Manukumar V S <mvs at openjdk.org> wrote:

> Create a regression test for [JDK-4670051](https://bugs.openjdk.java.net/browse/JDK-4670051) which checks whether JSpinner with a SpinnerDateModel exactly spins the field where cursor is there.
> I have updated the testing details in the comment section of JDK-8281535.

test/jdk/javax/swing/JSpinner/4670051/JSpinnerFieldUnderCursorTest.java line 49:

> 47:  * @bug 4670051
> 48:  * @summary Checks whether JSpinner with a SpinnerDateModel
> 49:  * exactly spins the field where cursor is there.

Suggestion:

 * @summary Checks whether JSpinner with a SpinnerDateModel
 *          spins the field where cursor is located.

test/jdk/javax/swing/JSpinner/4670051/JSpinnerFieldUnderCursorTest.java line 124:

> 122:                 updateSpinnerValue();
> 123:                 // Increment Day
> 124:                 initValue = spinnerValue;

May I suggest modifying `updateSpinnerValue` so that it returns the updated value? I think this code will be clearer:

                initValue = getSpinnerValue();
                // Increment Day

test/jdk/javax/swing/JSpinner/4670051/JSpinnerFieldUnderCursorTest.java line 184:

> 182:     private static void updateSpinnerValue() throws Exception {
> 183:         SwingUtilities.invokeAndWait(() -> spinnerValue = (Date) spinner.getValue());
> 184:     }

Suggestion:

    private static Date getSpinnerValue() throws Exception {
        SwingUtilities.invokeAndWait(() -> spinnerValue = (Date) spinner.getValue());
        return spinnerValue;
    }

test/jdk/javax/swing/JSpinner/4670051/JSpinnerFieldUnderCursorTest.java line 214:

> 212:                 (d1.get(Calendar.DAY_OF_YEAR) == d2.get(Calendar.DAY_OF_YEAR)) &&
> 213:                 (d1.get(Calendar.DAY_OF_MONTH) == d2.get(Calendar.DAY_OF_MONTH));
> 214:     }

`DATE` and `DAY_OF_MONTH` return the same value.

Does it make sense to compare `MONTH` and `YEAR`? You never compare that the months or years are equal, the former, however, should be covered by `DAY_OF_YEAR`.

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

PR: https://git.openjdk.java.net/jdk/pull/7404



More information about the client-libs-dev mailing list