-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8382264: Refactor java.logging TestNG tests to use JUnit #30769
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
Open
dfuch
wants to merge
4
commits into
openjdk:master
Choose a base branch
from
dfuch:junit-logging-8382264
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+50
−53
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -25,23 +25,26 @@ | |
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | ||
| import static jdk.test.lib.process.ProcessTools.*; | ||
|
|
||
| import jdk.test.lib.compiler.CompilerUtils; | ||
| import static org.testng.Assert.*; | ||
| import static jdk.test.lib.process.ProcessTools.executeTestJava; | ||
|
|
||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| /* | ||
| * @test | ||
| * @bug 8129126 8136802 8137316 8137317 8136804 8139350 | ||
| * @library /test/lib | ||
| * @modules jdk.compiler | ||
| * java.logging | ||
| * @build GetResourceBundleTest jdk.test.lib.process.ProcessTools | ||
| * jdk.test.lib.compiler.CompilerUtils | ||
| * @run testng GetResourceBundleTest | ||
| * @run junit GetResourceBundleTest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this intentionally not use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Fixed. |
||
| * @summary Tests Logger.getLogger + logger.getResourceBundle in an named/unnamed module, | ||
| * resources are in named and unnamed modules respectively. | ||
| * Positive tests to ensure that a Logger can retrieve ResourceBundle in its current module. | ||
|
|
@@ -63,8 +66,8 @@ public class GetResourceBundleTest { | |
| /** | ||
| * Compiles all modules used by the test, copy resource files. | ||
| */ | ||
| @BeforeClass | ||
| public void setup() throws Exception { | ||
| @BeforeAll | ||
| public static void setup() throws Exception { | ||
| // compile all modules | ||
| for (String mn : modules) { | ||
| Path msrc = MOD_SRC_DIR.resolve(mn); | ||
|
|
@@ -93,6 +96,6 @@ public void run() throws Exception { | |
| .outputTo(System.out) | ||
| .errorTo(System.err) | ||
| .getExitValue(); | ||
| assertTrue(exitValue == 0); | ||
| assertEquals(0, exitValue); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
LogRecordThreadIdTest previously used TestNG @BeforeTest, which runs before each @test method, so each test started with freshly constructed LogRecord instances. With JUnit @BeforeAll + static fields, the same instances are reused. The assertions still look safe because each test overwrites the state it cares about, but could you confirm this was intentional? If you want to preserve the old “fresh records per test” behavior, @beforeeach (possibly with non-static fields) would be closer to TestNG.
Uh oh!
There was an error while loading. Please reload this page.
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.
As far as I understand
@BeforeTestmeans that the method will be run before any test in the test group. If there is no test group, the test group is the class. Which means that BeforeAll/BeforeTest/BeforeClass are all equivalent here. That said there's no real reason to use a setup method here. I simply removed it.