RFR: JDK-8295087: Manual Test to Automated Test Conversion

Mahendra Chhipa mchhipa at openjdk.org
Fri Oct 14 11:32:06 UTC 2022


On Mon, 10 Oct 2022 21:39:05 GMT, Bill Huang <bhuang at openjdk.org> wrote:

> This task converts 5 manual tests to automated tests.
> 
> sun/security/provider/PolicyParser/ExtDirsDefaultPolicy.java 
> sun/security/provider/PolicyParser/ExtDirsChange.java 
> sun/security/provider/PolicyParser/ExtDirs.java 
> java/security/Policy/Root/Root.javajava/security/Policy/Root/Root.java 
> javax/crypto/CryptoPermissions/InconsistentEntries.java

Changes requested by mchhipa (Committer).

test/jdk/java/security/Policy/Root/Root.java line 48:

> 46:     private static final Path TARGET = Paths.get(ROOT, ".java.policy");
> 47:     public static void main(String[] args) throws Exception {
> 48:         Files.copy(SOURCE, TARGET, StandardCopyOption.REPLACE_EXISTING);

Could you please use the testng framework for initial setup of test.

test/jdk/java/security/Policy/Root/Root.java line 57:

> 55: 
> 56:     private static void test() throws Exception{
> 57:         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(

No need to create ProceesBuilder if use the testng framework

test/jdk/java/security/Policy/Root/Root.java line 64:

> 62:         OutputAnalyzer output = new OutputAnalyzer(proc);
> 63:         output.stdoutShouldNotBeEmpty();
> 64:         output.shouldContain("Test succeeded");

p.implies() returns boolean value, instead of checking for string "Test succeded", use Assert.assertTrue()

test/jdk/javax/crypto/CryptoPermissions/InconsistentEntries.java line 31:

> 29:  * @summary Test limited/default_local.policy containing inconsistent entries
> 30:  * @library /test/lib
> 31:  * @run driver InconsistentEntries

Use the testng framework.

test/jdk/javax/crypto/CryptoPermissions/InconsistentEntries.java line 76:

> 74:         OutputAnalyzer output = new OutputAnalyzer(proc);
> 75:         output.shouldContain("Test completed successfully");
> 76:         System.out.println("Test passed.");

Please use testng framework instead of creating ProcessBuilder

test/jdk/javax/crypto/CryptoPermissions/InconsistentEntries.java line 105:

> 103:             } catch (ExceptionInInitializerError e) {
> 104:                 e.printStackTrace();
> 105:                 System.out.println("Test completed successfully");

This test can be rewritten and use @Test(expectedException = ExceptionInInitializerError.class) instead of creating the ProcessBuilder to capture the output.

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

PR: https://git.openjdk.org/jdk/pull/10637


More information about the core-libs-dev mailing list