Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8316559: Refactor some util/Calendar tests to JUnit #15853

Closed

Conversation

justin-curtis-lu
Copy link
Member

@justin-curtis-lu justin-curtis-lu commented Sep 20, 2023

Please review this PR which converts some tests under Calendar to use JUnit. These tests either previously used the internal IntlTest, or used no framework at all.

Any files named BugXXXXXXX.java will be renamed after review.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8316559: Refactor some util/Calendar tests to JUnit (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15853/head:pull/15853
$ git checkout pull/15853

Update a local copy of the PR:
$ git checkout pull/15853
$ git pull https://git.openjdk.org/jdk.git pull/15853/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15853

View PR using the GUI difftool:
$ git pr show -t 15853

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15853.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 20, 2023

👋 Welcome back jlu! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 20, 2023
@openjdk
Copy link

openjdk bot commented Sep 20, 2023

@justin-curtis-lu The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Sep 20, 2023
@mlbridge
Copy link

mlbridge bot commented Sep 20, 2023

Webrevs

*/

import java.util.GregorianCalendar;

@SuppressWarnings("serial")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is removing this OK?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I thought so, there is no warning about a missing serialVersionUID when the SuppressWarnings annotation is removed, and IntelliJ actually flags the annotation as redundant. But since it was added separately and intentionally in JDK-8165296, I would rather leave it alone on second thought.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why IntelliJ claims it redundant, but compiling the test case alone, without that @SuppressWarnings with -Xlint gives me this:

warning: [serial] serializable class MyCalendar has no definition of serialVersionUID


public class bug4028518 {

public static void main(String[] args)
{
// Ensure modifying cloned gregCalendar does not modify the original
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that the comment is saying the other way around

Comment on lines 46 to 48
void setUp() {
Locale.setDefault(Locale.US);
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the test is not going to restore the original defaults with tearDown(), I'd expect othervm explicitly on @run directive. (applies to other locations)

Copy link
Member Author

@justin-curtis-lu justin-curtis-lu Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for correcting that, I had a misconception that JUnit would be ran with an independent JVM (not potentially reused), which is why I removed the saving of the default TZ and Locale. Adjusted so that they are preserved and reset with a tearDown() method.


@Test
public void serializationTest() throws IOException, ClassNotFoundException {
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that, thank you.

// Test the overloaded set() methods. Check year value.
@Test
public void buddhistSetTest() {
Calendar cal = getBuddhistCalendar();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Calendar cal = getBuddhistCalendar();
Calendar cal = getBuddhistCalendar();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you.

@openjdk
Copy link

openjdk bot commented Sep 22, 2023

@justin-curtis-lu This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8316559: Refactor some util/Calendar tests to JUnit

Reviewed-by: naoto, lancea

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 137 new commits pushed to the master branch:

  • ca5eee2: 8316445: Mark com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java as vm.flagless
  • 060db1b: 8315031: YoungPLABSize and OldPLABSize not aligned by ObjectAlignmentInBytes
  • 3481a48: 8316974: ListFormat creation is unsuccessful for some of the supported Locales
  • 29348b3: 8316894: make test TEST="jtreg:test/jdk/..." fails on AIX
  • 3f19df6: 8315936: Parallelize gc/stress/TestStressG1Humongous.java test
  • fc98998: 8316580: HttpClient with StructuredTaskScope does not close when a task fails
  • 065203d: 8313631: SA: stack trace printed using "where" command does not show class name
  • 0c55887: 8309599: WeakHandle and OopHandle release should clear obj pointer
  • 1230aed: 8316885: jcmd: Compiler.CodeHeap_Analytics cmd does not inform about missing aggregate
  • d0c1444: 8316957: Serial: Change GenCollectedHeap to SerialHeap inside gc/serial folder
  • ... and 127 more: https://git.openjdk.org/jdk/compare/833a82872c0b2517c7f4ae5d512cff3a428a071c...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 22, 2023
Copy link
Contributor

@LanceAndersen LanceAndersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is fine.

I would like to suggest comments to introduce all tests and DataProviders. Extra credit for helper methods.

From a future maintainers Point of view, having more info in the tests is beneficial.

@justin-curtis-lu
Copy link
Member Author

Overall, this is fine.

I would like to suggest comments to introduce all tests and DataProviders. Extra credit for helper methods.

From a future maintainers Point of view, having more info in the tests is beneficial.

Thanks for reviewing Lance. Agreed, there's been times where I've wished there was more context in the test file itself, rather than having to navigate to the JBS issue or older diffs for more info.

Updated to have comments for tests, data providers, and helper methods as you suggested (will do the same for future JUnit conversions).

@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 22, 2023
@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 22, 2023
@justin-curtis-lu
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 28, 2023

Going to push as commit 355811a.
Since your change was applied there have been 142 commits pushed to the master branch:

  • ecb5e8a: 8317264: Pattern.Bound has static fields that should be static final.
  • f2c221d: 8317119: Remove unused imports in the java.util.stream package
  • 09dad0e: 8313810: BoxLayout uses
    instead of list for layout options
  • 73a47f0: 4622866: javax.swing.text.Document.remove(int, int) has a misleading picture
  • cfcbfc6: 8316879: RegionMatches1Tests fails if CompactStrings are disabled after JDK-8302163
  • ca5eee2: 8316445: Mark com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java as vm.flagless
  • 060db1b: 8315031: YoungPLABSize and OldPLABSize not aligned by ObjectAlignmentInBytes
  • 3481a48: 8316974: ListFormat creation is unsuccessful for some of the supported Locales
  • 29348b3: 8316894: make test TEST="jtreg:test/jdk/..." fails on AIX
  • 3f19df6: 8315936: Parallelize gc/stress/TestStressG1Humongous.java test
  • ... and 132 more: https://git.openjdk.org/jdk/compare/833a82872c0b2517c7f4ae5d512cff3a428a071c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 28, 2023
@openjdk openjdk bot closed this Sep 28, 2023
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 28, 2023
@openjdk openjdk bot removed the rfr Pull request is ready for review label Sep 28, 2023
@openjdk
Copy link

openjdk bot commented Sep 28, 2023

@justin-curtis-lu Pushed as commit 355811a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants