On Mon, 7 Sep 2020 11:24:18 GMT, Chris Hegarty <che...@openjdk.org> wrote:
>> Jaikiran Pai has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Convert to TestNG test case > > test/jdk/java/net/URLConnection/RequestProperties.java line 90: > >> 88: try { >> 89: conn.addRequestProperty(null, "hello"); >> 90: Assert.fail("addRequestProperty on " + >> conn.getClass().getName() > > Now that the test is using TestNG, you can use the convenient > Assert.assertThrows / Assert.expectThrows, e.g. something > like: > static final Class<NullPointerException> NPE = NullPointerException.class; > > assertThrows(NPE, () -> conn.addRequestProperty(null, "hello")); > > similar for IllegalStateException Thank you. I wasn't aware of those APIs in TestNG. Looks like they got introduced in 6.9.5 of TestNG. Not sure what version of TestNG, the `jtreg` tool supports. But when I changed this test to use those APIs and run it, it worked fine and passed. So I guess it's supported. Using `jtreg -version` doesn't show the TestNG version (unlike what the docs claim), but that anyway isn't something relevant here and is a question to discuss on the jtreg mailing list: jtreg -version jtreg, version 5.1 dev 827 Installed in /home/me/jtreg/jtreg/lib/jtreg.jar Running on platform version 1.8.0_265 from /home/me/java/Contents/Home/jre. Built with Java(TM) 2 SDK, Version 1.8.0_172-b11 on June 21, 2020. Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. JT Harness, version 6.0 ea b11 (June 21, 2020) JCov 3.0-2 TestNG (testng.jar): version unknown TestNG (jcommander.jar): version 1.72 Java Assembler Tools, version 7.0 beta b02 (June 21, 2020) I've updated this PR to include your suggested change. ------------- PR: https://git.openjdk.java.net/jdk/pull/26