test/jdk/javadoc/doclet/lib/JavadocTester.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -134,16 +134,12 @@
     public static final String FS = System.getProperty("file.separator");
     public static final String PS = System.getProperty("path.separator");
     public static final String NL = System.getProperty("line.separator");
 
     public enum Output {
-        /** The name for error output from javadoc. */
-        ERROR,
-        /** The name for the notice output from javadoc. */
-        NOTICE,
-        /** The name for the warning output  from javadoc. */
-        WARNING,
+        /** The name of the output stream from javadoc. */
+        OUT,
         /** The name for any output written to System.out. */
         STDOUT,
         /** The name for any output written to System.err. */
         STDERR
     }

@@ -205,15 +201,20 @@
         void check(File dir) {
             if (dir.isDirectory()) {
                 String[] contents = dir.list(filter);
                 if (contents == null)
                     throw new Error("cannot list directory: " + dir);
-                if (contents.length > 0)
+                if (contents.length > 0) {
+                    System.err.println("Found extraneous files in dir:" + dir.getAbsolutePath());
+                    for (String x : contents) {
+                        System.err.println(x);
+                    }
                     throw new Error("directory has unexpected content: " + dir);
             }
         }
     }
+    }
 
     private DirectoryCheck outputDirectoryCheck = DirectoryCheck.EMPTY;
 
     /** The current subtest number. Incremented when checking(...) is called. */
     private int numTestsRun = 0;

@@ -222,16 +223,10 @@
     private int numTestsPassed = 0;
 
     /** The current run of javadoc. Incremented when javadoc is called. */
     private int javadocRunNum = 0;
 
-    /** The name of the standard doclet. */
-    // This ought not to be necessary; there ought to be a javadoc entry point
-    // that does not require this to be know externally.
-    private static final String standardDocletClassName =
-            "com.sun.tools.doclets.standard.Standard";
-
     /** Marker annotation for test methods to be invoked by runTests. */
     @Retention(RetentionPolicy.RUNTIME)
     @interface Test { }
 
     /**

@@ -294,31 +289,24 @@
         out.println("args: " + Arrays.toString(args));
 //        log.setOutDir(outputDir);
 
         outputDirectoryCheck.check(outputDir);
 
-        // These are the primary streams used by javadoc
-        WriterOutput errOut = new WriterOutput();
-        WriterOutput warnOut = new WriterOutput();
-        WriterOutput noticeOut = new WriterOutput();
+        // This is the sole stream used by javadoc
+        WriterOutput outOut = new WriterOutput();
+
         // These are to catch output to System.out and System.err,
         // in case these are used instead of the primary streams
         StreamOutput sysOut = new StreamOutput(System.out, System::setOut);
         StreamOutput sysErr = new StreamOutput(System.err, System::setErr);
 
         try {
-            exitCode = com.sun.tools.javadoc.Main.execute(
-                    "javadoc",
-                    errOut.pw, warnOut.pw, noticeOut.pw,
-                    standardDocletClassName,
-                    args);
+            exitCode = jdk.javadoc.internal.tool.Main.execute(args, outOut.pw);
         } finally {
             outputMap.put(Output.STDOUT, sysOut.close());
             outputMap.put(Output.STDERR, sysErr.close());
-            outputMap.put(Output.ERROR, errOut.close());
-            outputMap.put(Output.WARNING, warnOut.close());
-            outputMap.put(Output.NOTICE, noticeOut.close());
+            outputMap.put(Output.OUT, outOut.close());
         }
 
         outputMap.forEach((name, text) -> {
             if (!text.isEmpty()) {
                 out.println("javadoc " + name + ":");

@@ -449,20 +437,21 @@
      */
     public void checkOrder(String path, String... strings) {
         String fileString = readOutputFile(path);
         int prevIndex = -1;
         for (String s : strings) {
+            s = s.replace("\n", NL); // normalize new lines
             int currentIndex = fileString.indexOf(s);
             checking(s + " at index " + currentIndex);
             if (currentIndex == -1) {
                 failed(s + " not found.");
                 continue;
             }
             if (currentIndex > prevIndex) {
                 passed(s + " is in the correct order");
             } else {
-                failed(s + " is in the wrong order.");
+                failed("file: " + path + ": " + s + " is in the wrong order.");
             }
             prevIndex = currentIndex;
         }
     }