RFR: 8378595: Refactor miscellaneous tests under test/jdk/java/net/httpclient from TestNG to JUnit

SendaoYan syan at openjdk.org
Wed Feb 25 11:00:41 UTC 2026


On Tue, 24 Feb 2026 18:09:19 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> A small changeset to convert TestNG tests under `test/jdk/java/net/httpclient/security`, `test/jdk/java/net/httpclient/offline`, and `test/jdk/java/net/httpclient/PathSubscriber` to JUnit.

test/jdk/java/net/httpclient/PathSubscriber/BodyHandlerOfFileDownloadTest.java line 116:

> 114:                 {  http3URI,   defaultFsPath,  MSG,  true   },
> 115:                 {  http3URI,   defaultFsPath,  MSG,  false  },
> 116: 

Could we remove this empty line

test/jdk/java/net/httpclient/security/filePerms/FileProcessorPermissionTest.java line 38:

> 36: 
> 37: import org.junit.jupiter.api.Test;
> 38: import static org.junit.jupiter.api.Assertions.*;

This import "import static org.junit.jupiter.api.Assertions.*;" seems useless.

test/jdk/java/net/httpclient/security/filePerms/SecurityBeforeFile.java line 44:

> 42: import org.junit.jupiter.params.ParameterizedTest;
> 43: import org.junit.jupiter.params.provider.MethodSource;
> 44: import static org.junit.jupiter.api.Assertions.*;

In this file, seems that we can import "org.junit.jupiter.api.Assertions.fail" explicitly rather than import all the assertion method.

test/jdk/java/net/httpclient/security/filePerms/SecurityBeforeFile.java line 79:

> 77:         try {
> 78:             BodyHandlers.ofFileDownload(p, openOptions);
> 79:             fail("UNEXPECTED, file " + p.toString() + " exists?");

Seems that use assertThrows better than try-fail-catch


        assertThrows(FileNotFoundException.class, () -> {
            BodyPublishers.ofFile(p);
        });

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29900#discussion_r2851205494
PR Review Comment: https://git.openjdk.org/jdk/pull/29900#discussion_r2851274993
PR Review Comment: https://git.openjdk.org/jdk/pull/29900#discussion_r2851300459
PR Review Comment: https://git.openjdk.org/jdk/pull/29900#discussion_r2851308262


More information about the net-dev mailing list