-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8310923: Refactor Currency tests to use JUnit #14682
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
8310923: Refactor Currency tests to use JUnit #14682
Conversation
|
👋 Welcome back jlu! A progress list of the required criteria for merging this PR into |
|
@justin-curtis-lu The following labels will be automatically applied to this pull request:
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. |
Webrevs
|
|
|
||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| public class CurrencyNameProviderTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is not a generic CurrencyNameProvider test, but specific to the default impl of CNP.getDisplayName(), the class name could be more specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have renamed the file to be more descriptive, but if acronyms are not preferred in file names, I can rename it.
| Currency currency1 = Currency.getInstance(currencyCode); | ||
| Currency currency2 = Currency.getInstance(currencyCode); | ||
| assertEquals(currency1, currency2, "Didn't get same instance for same currency code"); | ||
| assertEquals(currency1.getCurrencyCode(), currencyCode, "Currency code changed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message more like "wrong currency code", than "changed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the err msg
| Arguments.of("BHD", 3), Arguments.of("IQD", 3), | ||
| Arguments.of("JOD", 3), Arguments.of("KWD", 3), | ||
| Arguments.of("LYD", 3), Arguments.of("OMR", 3), | ||
| Arguments.of("TND", 3), Arguments.of("TRL", 0), // Turkish Lira |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The turkish lira comment should apply to both TRL and TRY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good point, I have clarified the comment
| if (!currency1.getCurrencyCode().equals(currencyCode)) { | ||
| throw new RuntimeException("Currency code changed"); | ||
|
|
||
| // Calling getInstance() with an illegal name should throw an IAE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
illegal name -> invalid currency code
| /* | ||
| * @test | ||
| * @bug 4512215 4818420 4819436 8310923 | ||
| * @summary Test some minor undefined currencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be more readable something like "currencies without minor units." The class name can also be renamed to something like NoMinorUnitCurrenciesTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted the wording throughout the file according to your suggestions
| // at the same time | ||
| setUpISO4217Codes(); | ||
| setUpAdditionalCodes(); | ||
| finishTestCurrencies(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name finish is kind of confusing. I'd explicitly describe what the method does, i.e, setup other currencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it to your suggestion
| String[][] extraCodes = { | ||
| /* Defined in ISO 4217 list, but don't have code and minor unit info. */ | ||
| {"AQ", "", "", "0"}, // Antarctica | ||
| /* | ||
| * Defined in ISO 4217 list, but don't have code and minor unit info in | ||
| * it. On the other hand, both code and minor unit are defined in | ||
| * .properties file. I don't know why, though. | ||
| */ | ||
| {"GS", "GBP", "826", "2"}, // South Georgia And The South Sandwich Islands | ||
| /* Not defined in ISO 4217 list, but defined in .properties file. */ | ||
| {"AX", "EUR", "978", "2"}, // \u00c5LAND ISLANDS | ||
| {"PS", "ILS", "376", "2"}, // Palestinian Territory, Occupied | ||
| /* Not defined in ISO 4217 list, but added in ISO 3166 country code list */ | ||
| {"JE", "GBP", "826", "2"}, // Jersey | ||
| {"GG", "GBP", "826", "2"}, // Guernsey | ||
| {"IM", "GBP", "826", "2"}, // Isle of Man | ||
| {"BL", "EUR", "978", "2"}, // Saint Barthelemy | ||
| {"MF", "EUR", "978", "2"}, // Saint Martin | ||
| /* Defined neither in ISO 4217 nor ISO 3166 list */ | ||
| {"XK", "EUR", "978", "2"}, // Kosovo | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this array to be placed as static in the class, not within the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, as well as for otherCodes
| final String otherCodes = | ||
| "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-" | ||
| + "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-" | ||
| + "PTE-ROL-RUR-SDD-SIT-SLL-SKK-SRG-STD-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-VED-" | ||
| + "XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-" | ||
| + "YUM-ZMK-ZWD-ZWN-ZWR"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto as extraCodes
| private static final byte[] codes = new byte[ALPHA_NUM * ALPHA_NUM]; | ||
| // Codes derived from ISO4217 golden-data file | ||
| private static final List<Arguments> ISO4217Codes = new ArrayList<Arguments>(); | ||
| // Additional codes not from the ISO4217 golden-data file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these from the golden file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am misinterpreting the question, additionalCodes is built from the extraCodes array, which contains data that is not found in tablea1.txt(golden file)
| // Old and New Turkish Lira | ||
| Arguments.of("TRL", 0), Arguments.of("TRY", 2), | ||
| Arguments.of("TND", 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably TND moving upward before the comment would be clearer, like:
Arguments.of("LYD", 3), Arguments.of("OMR", 3),
Arguments.of("TND", 3),
// Old and New Turkish Lira
Arguments.of("TRL", 0), Arguments.of("TRY", 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted TND upwards
naotoj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the refactoring
|
@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: 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 77 new commits pushed to the
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 |
|
/integrate |
|
Going to push as commit e848d94.
Your commit was automatically rebased without conflicts. |
|
@justin-curtis-lu Pushed as commit e848d94. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this PR which refactors Currency tests to use JUnit.
The most significant change occurs in
ValidateISO4217.java. Other changes to this file excluding the JUnit refactoring includeBug4512215.javanow renamed toMinorUndefinedCodeswas updated to remove redundant testing, and the file changed to focus on testing minor undefined currency codes instead.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14682/head:pull/14682$ git checkout pull/14682Update a local copy of the PR:
$ git checkout pull/14682$ git pull https://git.openjdk.org/jdk.git pull/14682/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14682View PR using the GUI difftool:
$ git pr show -t 14682Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14682.diff
Webrev
Link to Webrev Comment