Wed, 18 Sep 2013 22:47:06 -0700
8024096: some javadoc tests may contain false positive results
Reviewed-by: jjg
1.1 --- a/test/com/sun/javadoc/lib/JavadocTester.java Wed Sep 18 17:13:26 2013 -0700 1.2 +++ b/test/com/sun/javadoc/lib/JavadocTester.java Wed Sep 18 22:47:06 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -57,6 +57,7 @@ 1.11 protected static final String SRC_DIR = System.getProperty("test.src", "."); 1.12 protected static final String JAVA_VERSION = System.getProperty("java.version"); 1.13 protected static final String[][] NO_TEST = new String[][] {}; 1.14 + protected static final String[] NO_FILE_TEST = new String[] {}; 1.15 1.16 /** 1.17 * Use this as the file name in the test array when you want to search 1.18 @@ -166,6 +167,26 @@ 1.19 } 1.20 1.21 /** 1.22 + * Execute the tests. 1.23 + * 1.24 + * @param tester the tester to execute 1.25 + * @param args the arguments to pass to Javadoc 1.26 + * @param testArray the array of tests 1.27 + * @param negatedTestArray the array of negated tests 1.28 + * @param fileTestArray the array of file tests 1.29 + * @param negatedFileTestArray the array of negated file tests 1.30 + * @return the return code for the execution of Javadoc 1.31 + */ 1.32 + public static int run(JavadocTester tester, String[] args, 1.33 + String[][] testArray, String[][] negatedTestArray, String[] fileTestArray, 1.34 + String[] negatedFileTestArray) { 1.35 + int returnCode = tester.runJavadoc(args); 1.36 + tester.runTestsOnHTML(testArray, negatedTestArray); 1.37 + tester.runTestsOnFile(fileTestArray, negatedFileTestArray); 1.38 + return returnCode; 1.39 + } 1.40 + 1.41 + /** 1.42 * Execute Javadoc using the default doclet. 1.43 * 1.44 * @param args the arguments to pass to Javadoc 1.45 @@ -244,6 +265,19 @@ 1.46 } 1.47 1.48 /** 1.49 + * Run array of tests on the generated files. 1.50 + * This method accepts a fileTestArray for testing if a file is generated 1.51 + * and a negatedFileTestArray for testing if a file is not found. 1.52 + * 1.53 + * @param testArray the array of file tests 1.54 + * @param negatedTestArray the array of negated file tests 1.55 + */ 1.56 + public void runTestsOnFile(String[] fileTestArray, String[] negatedFileTestArray) { 1.57 + runTestsOnFile(fileTestArray, false); 1.58 + runTestsOnFile(negatedFileTestArray, true); 1.59 + } 1.60 + 1.61 + /** 1.62 * Run the array of tests on the resulting HTML. 1.63 * 1.64 * @param testArray the array of tests 1.65 @@ -265,9 +299,11 @@ 1.66 fileString = readFileToString(testArray[i][0]); 1.67 } catch (Error e) { 1.68 if (isNegated) { 1.69 - numTestsPassed += 1; 1.70 - System.out.println("Passed\n not found:\n" 1.71 - + stringToFind + " in non-existent " + testArray[i][0] + "\n"); 1.72 + System.out.println( "FAILED" + "\n" 1.73 + + "for bug " + getBugId() 1.74 + + " (" + getBugName() + ") " 1.75 + + "due to " 1.76 + + e + "\n"); 1.77 continue; 1.78 } 1.79 throw e; 1.80 @@ -291,6 +327,39 @@ 1.81 } 1.82 1.83 /** 1.84 + * Run the array of file tests on the generated files. 1.85 + * 1.86 + * @param testArray the array of file tests 1.87 + * @param isNegated true if test is negated; false otherwise 1.88 + */ 1.89 + private void runTestsOnFile(String[] testArray, boolean isNegated) { 1.90 + String fileName; 1.91 + String failedString; 1.92 + String passedString; 1.93 + for (int i = 0; i < testArray.length; i++) { 1.94 + numTestsRun++; 1.95 + fileName = testArray[i]; 1.96 + failedString = "FAILED" + "\n" 1.97 + + "for bug " + getBugId() + " (" + getBugName() + ") " 1.98 + + "file (" + fileName + ") found" + "\n"; 1.99 + passedString = "Passed" + "\n" + 1.100 + "file (" + fileName + ") not found" + "\n"; 1.101 + System.out.print("Running subtest #" + numTestsRun + "... "); 1.102 + try { 1.103 + File file = new File(fileName); 1.104 + if ((file.exists() && !isNegated) || (!file.exists() && isNegated)) { 1.105 + numTestsPassed += 1; 1.106 + System.out.println(passedString); 1.107 + } else { 1.108 + System.out.println(failedString); 1.109 + } 1.110 + } catch (Error e) { 1.111 + System.err.println(e); 1.112 + } 1.113 + } 1.114 + } 1.115 + 1.116 + /** 1.117 * Iterate through the list of given file pairs and diff each file. 1.118 * 1.119 * @param filePairs the pairs of files to diff.
2.1 --- a/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java Wed Sep 18 17:13:26 2013 -0700 2.2 +++ b/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java Wed Sep 18 22:47:06 2013 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -25,7 +25,7 @@ 2.11 2.12 /* 2.13 * @test 2.14 - * @bug 4258405 4973606 2.15 + * @bug 4258405 4973606 8024096 2.16 * @summary This test verifies that the doc-file directory does not 2.17 * get overwritten when the sourcepath is equal to the destination 2.18 * directory. 2.19 @@ -47,25 +47,17 @@ 2.20 }; 2.21 private static final String[][] NEGATED_TEST1 = NO_TEST; 2.22 2.23 - private static final String[][] TEST2 = { 2.24 - {BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used1" + 2.25 + private static final String[] FILE_TEST2 = { 2.26 + BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used1" + 2.27 FS + "testfile.txt", 2.28 - "passed" 2.29 - }, 2.30 - {BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used2" + 2.31 + BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used2" + 2.32 + FS + "testfile.txt" 2.33 + }; 2.34 + private static final String[] FILE_NEGATED_TEST2 = { 2.35 + BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded1" + 2.36 FS + "testfile.txt", 2.37 - "passed" 2.38 - }, 2.39 - }; 2.40 - private static final String[][] NEGATED_TEST2 = { 2.41 - {BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded1" + 2.42 - FS + "testfile.txt", 2.43 - "passed" 2.44 - }, 2.45 - {BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded2" + 2.46 - FS + "testfile.txt", 2.47 - "passed" 2.48 - }, 2.49 + BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded2" + 2.50 + FS + "testfile.txt" 2.51 }; 2.52 2.53 private static final String[][] TEST0 = { 2.54 @@ -106,7 +98,7 @@ 2.55 run(tester, ARGS0, TEST0, NEGATED_TEST0); 2.56 copyDir(SRC_DIR + FS + "pkg", BUG_ID + "-1"); 2.57 run(tester, ARGS1, TEST1, NEGATED_TEST1); 2.58 - run(tester, ARGS2, TEST2, NEGATED_TEST2); 2.59 + run(tester, ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2); 2.60 tester.printSummary(); 2.61 } 2.62
3.1 --- a/test/com/sun/javadoc/testEncoding/EncodeTest.java Wed Sep 18 17:13:26 2013 -0700 3.2 +++ b/test/com/sun/javadoc/testEncoding/EncodeTest.java Wed Sep 18 22:47:06 2013 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -23,7 +23,9 @@ 3.11 3.12 3.13 /** 3.14 - * ±ρΙΏν Ή©’! 3.15 + * Testing en\u00e7\u00f4ded string. 3.16 + * In the encoded comment string, Unicode U+00E7 is "Latin small letter C with cedilla" 3.17 + * and Unicode U+00F4 is "Latin small letter O with circumflex" 3.18 */ 3.19 public class EncodeTest { 3.20 }
4.1 --- a/test/com/sun/javadoc/testEncoding/TestEncoding.java Wed Sep 18 17:13:26 2013 -0700 4.2 +++ b/test/com/sun/javadoc/testEncoding/TestEncoding.java Wed Sep 18 22:47:06 2013 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -23,7 +23,7 @@ 4.11 4.12 /* 4.13 * @test 4.14 - * @bug 4661481 4.15 + * @bug 4661481 8024096 4.16 * @summary This test determines if the value of the -encoding option is 4.17 * properly passed from Javadoc to the source file parser. 4.18 * @author jamieh 4.19 @@ -40,12 +40,12 @@ 4.20 4.21 //If ??? is found in the output, the source file was not read with the correct encoding setting. 4.22 private static final String[][] NEGATED_TEST = { 4.23 - {BUG_ID + FS + "EncodeTest.html", "???"} 4.24 + {BUG_ID + FS + "EncodeTest.html", "??"} 4.25 }; 4.26 private static final String[] ARGS = 4.27 new String[] { 4.28 "-d", BUG_ID, "-sourcepath", SRC_DIR, 4.29 - "-encoding", "SJIS", SRC_DIR + FS + "EncodeTest.java" 4.30 + "-encoding", "iso-8859-1", SRC_DIR + FS + "EncodeTest.java" 4.31 }; 4.32 4.33 /**
5.1 --- a/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java Wed Sep 18 17:13:26 2013 -0700 5.2 +++ b/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java Wed Sep 18 22:47:06 2013 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -23,7 +23,7 @@ 5.11 5.12 /* 5.13 * @test 5.14 - * @bug 8002304 5.15 + * @bug 8002304 8024096 5.16 * @summary Test for various method types in the method summary table 5.17 * @author Bhavesh Patel 5.18 * @library ../lib/ 5.19 @@ -107,7 +107,7 @@ 5.20 "</caption>" 5.21 }, 5.22 5.23 - {BUG_ID + FS + "pkg" + FS + "D.html", 5.24 + {BUG_ID + FS + "pkg1" + FS + "D.html", 5.25 "<caption><span>Methods</span><span class=\"tabEnd\"> </span>" + 5.26 "</caption>" 5.27 },
6.1 --- a/test/com/sun/javadoc/testProfiles/TestProfiles.java Wed Sep 18 17:13:26 2013 -0700 6.2 +++ b/test/com/sun/javadoc/testProfiles/TestProfiles.java Wed Sep 18 22:47:06 2013 -0700 6.3 @@ -23,7 +23,7 @@ 6.4 6.5 /* 6.6 * @test 6.7 - * @bug 8006124 8009684 8016921 8023700 6.8 + * @bug 8006124 8009684 8016921 8023700 8024096 6.9 * @summary Test javadoc support for profiles. 6.10 * @author Bhavesh Patel, Evgeniya Stepanova 6.11 * @library ../lib/ 6.12 @@ -187,26 +187,6 @@ 6.13 } 6.14 }; 6.15 private static final String[][] PACKAGES_NEGATED_TEST = { 6.16 - {PACKAGE_BUG_ID + FS + "profile-overview-frame.html", 6.17 - "<span><a href=\"overview-frame.html\" " 6.18 - + "target=\"packageListFrame\">All Packages</a></span>" 6.19 - }, 6.20 - {PACKAGE_BUG_ID + FS + "compact2-frame.html", 6.21 - "<span><a href=\"overview-frame.html\" target=\"packageListFrame\">" 6.22 - + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" " 6.23 - + "target=\"packageListFrame\">All Profiles</a></span>" 6.24 - }, 6.25 - {PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html", 6.26 - "<a href=\"../compact2-summary.html\" target=\"classFrame\">" 6.27 - + "compact2</a> - <a href=\"../pkg2/compact2-package-summary.html\" " 6.28 - + "target=\"classFrame\">pkg2</a>" 6.29 - }, 6.30 - {PACKAGE_BUG_ID + FS + "compact2-summary.html", 6.31 - "<h1 title=\"Profile\" class=\"title\">Profile compact2</h1>" 6.32 - }, 6.33 - {PACKAGE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html", 6.34 - "<div class=\"subTitle\">compact3</div>" 6.35 - }, 6.36 {PACKAGE_BUG_ID + FS + "overview-frame.html", 6.37 "<span><a href=\"profile-overview-frame.html\" " 6.38 + "target=\"packageListFrame\">All Profiles</a></span>" 6.39 @@ -222,6 +202,13 @@ 6.40 "</ul>" 6.41 } 6.42 }; 6.43 + private static final String[] PACKAGES_NEGATED_FILE_TEST = { 6.44 + PACKAGE_BUG_ID + FS + "profile-overview-frame.html", 6.45 + PACKAGE_BUG_ID + FS + "compact2-frame.html", 6.46 + PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html", 6.47 + PACKAGE_BUG_ID + FS + "compact2-summary.html", 6.48 + PACKAGE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html" 6.49 + }; 6.50 6.51 /** 6.52 * The entry point of the test. 6.53 @@ -231,7 +218,7 @@ 6.54 public static void main(String[] args) { 6.55 TestProfiles tester = new TestProfiles(); 6.56 run(tester, ARGS1, PROFILES_TEST, PROFILES_NEGATED_TEST); 6.57 - run(tester, ARGS2, PACKAGES_TEST, PACKAGES_NEGATED_TEST); 6.58 + run(tester, ARGS2, PACKAGES_TEST, PACKAGES_NEGATED_TEST, NO_FILE_TEST, PACKAGES_NEGATED_FILE_TEST); 6.59 tester.printSummary(); 6.60 } 6.61