diff --git a/langtools/test/com/sun/javadoc/lib/JavadocTester.java b/langtools/test/com/sun/javadoc/lib/JavadocTester.java index 5149d9301fc..6773ec144a7 100644 --- a/langtools/test/com/sun/javadoc/lib/JavadocTester.java +++ b/langtools/test/com/sun/javadoc/lib/JavadocTester.java @@ -113,6 +113,46 @@ public abstract class JavadocTester { */ private File outputDir; + /** + * Alternatives for checking the contents of a directory. + */ + enum DirectoryCheck { + /** + * Check that the directory is empty. + */ + EMPTY((file, name) -> true), + /** + * Check that the directory does not contain any HTML files, + * such as may have been generated by a prior run of javadoc + * using this directory. + * For now, the check is only performed on the top level directory. + */ + NO_HTML_FILES((file, name) -> name.endsWith(".html")), + /** + * No check is performed on the directory contents. + */ + NONE(null) { @Override void check(File dir) { } }; + + /** The filter used to detect that files should not be present. */ + FilenameFilter filter; + + DirectoryCheck(FilenameFilter f) { + filter = f; + } + + 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) + throw new Error("directory has unexpected content: " + dir); + } + } + } + + private DirectoryCheck outputDirectoryCheck = DirectoryCheck.EMPTY; + /** * The current subtest number. */ @@ -206,6 +246,8 @@ public abstract class JavadocTester { } } + outputDirectoryCheck.check(outputDir); + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); PrintStream prevOut = System.out; System.setOut(new PrintStream(stdout)); @@ -231,6 +273,15 @@ public abstract class JavadocTester { return returnCode; } + /** + * Set a filter to check the initial contents of the output directory + * before javadoc is run. + * The filter should return true for files that should not appear. + */ + public void setCheckOutputDirectoryCheck(DirectoryCheck c) { + outputDirectoryCheck = c; + } + /** * Create new string writer buffers */ diff --git a/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java b/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java index 3f263f6a1f3..c939e49dc46 100644 --- a/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java +++ b/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java @@ -86,10 +86,12 @@ public class TestDocFileDir extends JavadocTester { */ public static void main(String[] args) { TestDocFileDir tester = new TestDocFileDir(); + tester.setCheckOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); copyDir(SRC_DIR + "/pkg", "."); tester.run(ARGS0, TEST0, NO_TEST); copyDir(SRC_DIR + "/pkg", OUTPUT_DIR + "-1"); tester.run(ARGS1, TEST1, NO_TEST); + tester.setCheckOutputDirectoryCheck(DirectoryCheck.NONE); tester.run(ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2); tester.printSummary(); } diff --git a/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java b/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java index a43bdc17b35..8d7b090df39 100644 --- a/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java +++ b/langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java @@ -58,7 +58,7 @@ public class TestGeneratedBy extends JavadocTester { private static final String[] NO_TIMESTAMP_ARGS = new String[] { "-notimestamp", - "-d", OUTPUT_DIR, + "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg" }; diff --git a/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java b/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java index d86eaba77db..b1cdc9b8334 100644 --- a/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java +++ b/langtools/test/com/sun/javadoc/testGroupOption/TestGroupOption.java @@ -45,7 +45,7 @@ public class TestGroupOption extends JavadocTester { }; private static final String[] ARGS2 = new String[] { - "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, + "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "-group", "Package One", "pkg1", "-group", "Package One", "pkg2", "-group", "Package One", "pkg3", diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java index ec111e9d9e2..7b3e4f685ca 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java @@ -40,127 +40,134 @@ public class TestHtmlDefinitionListTag extends JavadocTester { // Optional Element should print properly nested definition list tags // for default value. private static final String[][] TEST_ALL = { - { "pkg1/C1.html", "
public class " +
- "C1\n" +
- "extends java.lang.Object\n" +
- "implements java.io.Serializable
"},
- { "pkg1/C4.html", "public class C1\n" +
+ "extends java.lang.Object\n" +
+ "implements java.io.Serializable
"},
+ { "pkg1/C4.html",
+ "" +
- "C2
, \n" +
- "" +
- "Serialized FormsetUndecorated(boolean)
title" +
- "
- the titletest
- boolean value" +
- "java.lang.IllegalArgumentException
- if the " +
- "owner
's\n" +
- " GraphicsConfiguration
is not from a screen " +
- "deviceHeadlessException
undecorated" +
- "
- true
if no decorations are\n" +
- " to be enabled;\n" +
- " false
" +
- "if decorations are to be enabled.readObject()" +
- "
java.io.IOException
setUndecorated(boolean)
set
- boolean" +
- "java.io.IOException
C1.setUndecorated(boolean)
" +
+ "C2
, \n" +
+ "" +
+ "Serialized FormsetUndecorated(boolean)
title
- the titletest
- boolean value" +
+ "java.lang.IllegalArgumentException
- if the " +
+ "owner
's\n" +
+ " GraphicsConfiguration
is not from a screen " +
+ "deviceHeadlessException
undecorated" +
+ "
- true
if no decorations are\n" +
+ " to be enabled;\n" +
+ " false
" +
+ "if decorations are to be enabled.readObject()" +
+ "
java.io.IOException
setUndecorated(boolean)
set
- booleansetUndecorated(boolean)
.\n" +
- "C1.setUndecorated(boolean)
" +
+ "java.io.IOException
C1.setUndecorated(boolean)
setUndecorated(boolean)
.\n" +
- "" +
- "IOException
java.io.IOException
setUndecorated(boolean)
.\n" +
+ "C1.setUndecorated(boolean)
setUndecorated(boolean)
.\n" +
+ "" +
+ "IOException
java.io.IOException
C2
, \n" +
- "" +
- "Serialized Formtitle
- the title" +
- "test
- boolean valuejava.lang.IllegalArgumentException" +
- "
- if the owner
's\n" +
- " GraphicsConfiguration" +
- "
is not from a screen device" +
- "HeadlessException
undecorated
- true
" +
- " if no decorations are\n" +
- " to be enabled;\n" +
- " false
if decorations are to be enabled." +
- "readObject()
java.io.IOException
setUndecorated(boolean)
" +
- "java.io.IOException
C1.setUndecorated(boolean)
C2
, \n" +
+ "" +
+ "Serialized Formtitle
- the title" +
+ "test
- boolean valuejava.lang.IllegalArgumentException" +
+ "
- if the owner
's\n" +
+ " GraphicsConfiguration" +
+ "
is not from a screen device" +
+ "HeadlessException
undecorated
- true
" +
+ " if no decorations are\n" +
+ " to be enabled;\n" +
+ " false
if decorations are to be enabled." +
+ "readObject()
java.io.IOException
setUndecorated(boolean)
setUndecorated(boolean)
.\n" +
- "C1.setUndecorated(boolean)
" +
+ "java.io.IOException
C1.setUndecorated(boolean)
setUndecorated(boolean)
.\n" +
- "" +
- "IOException
java.io.IOException
setUndecorated(boolean)
.\n" +
+ "C1.setUndecorated(boolean)
setUndecorated(boolean)
.\n" +
+ "" +
+ "IOException
java.io.IOException
public void readObject()\n" + - " throws java.io.IOException\n" + - ""}, + "
public void readObject()\n" + + " throws java.io.IOException\n" + + ""}, { "pkg1/C2.html", "
public C2()\n" + - ""}, + ""}, { "pkg1/C1.ModalExclusionType.html", "
public " + - "static final C1.ModalExclusionType " + - "APPLICATION_EXCLUDE\n" + - ""}, + "static final C1.ModalExclusionType " + + "APPLICATION_EXCLUDE\n" + + ""}, { "serialized-form.html", "
boolean " + - "undecorated\n" + - "
" +
- "setUndecorated(boolean)
." +
+ "setUndecorated(boolean)
.setUndecorated(boolean)
.\n" +
- ""}};
+ "Deprecated. As of JDK version" +
+ " 1.5, replaced by\n" +
+ " " +
+ "setUndecorated(boolean)
.\n" +
+ ""}};
// Test for valid HTML generation which should not comprise of empty
// definition list tags.
- private static final String[][] NEGATED_TEST = {
- { "pkg1/package-summary.html", "Class C
."
}
};
@@ -119,7 +119,6 @@ public class TestLinkOption extends JavadocTester {
public static void main(String[] args) {
TestLinkOption tester = new TestLinkOption();
tester.run(ARGS1, TEST1, NEGATED_TEST1);
- tester.run(ARGS1, TEST1, NEGATED_TEST1);
tester.run(ARGS2, TEST2, NO_TEST);
tester.runJavadoc(createArguments(true)); // with trailing slash
tester.runJavadoc(createArguments(false)); // without trailing slash
diff --git a/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java b/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java
index 613967b0948..ab0b9a0987d 100644
--- a/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java
+++ b/langtools/test/com/sun/javadoc/testNotifications/TestNotifications.java
@@ -67,7 +67,9 @@ public class TestNotifications extends JavadocTester {
tester.run(ARGS, TEST, NO_TEST);
// No need to notify that the destination must be created because
// it already exists.
+ tester.setCheckOutputDirectoryCheck(DirectoryCheck.NONE);
tester.run(ARGS, NO_TEST, NEGATED_TEST);
+ tester.setCheckOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES);
//Make sure classname is not include in javadoc usage message.
tester.run(ARGS2, NO_TEST, NEGATED_TEST2);
tester.printSummary();
diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
index d9ebb4ef911..20e28da635e 100644
--- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
@@ -115,19 +115,19 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester {
private static final String[] ARGS1 =
new String[] {
- "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1"};
+ "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg1"};
private static final String[] ARGS2 =
new String[] {
- "-d", OUTPUT_DIR, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
+ "-d", OUTPUT_DIR + "-2", "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
private static final String[] ARGS3 =
new String[] {
- "-d", OUTPUT_DIR, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
+ "-d", OUTPUT_DIR + "-3", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
private static final String[] ARGS4 =
new String[] {
- "-d", OUTPUT_DIR, "-nocomment", "-nodeprecated", "-sourcepath",
+ "-d", OUTPUT_DIR + "-4", "-nocomment", "-nodeprecated", "-sourcepath",
SRC_DIR, "pkg1"};
/**
diff --git a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
index d8f768ce583..451cd30bf32 100644
--- a/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
+++ b/langtools/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
@@ -35,11 +35,11 @@ public class TestSinceTag extends JavadocTester {
//Javadoc arguments.
private static final String[] ARGS1 = new String[] {
- "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg1"
+ "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg1"
};
private static final String[] ARGS2 = new String[] {
- "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-nosince", "pkg1"
+ "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, "-nosince", "pkg1"
};
//Input for string search tests.
diff --git a/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java b/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
index 8607b043e72..d07899011ca 100644
--- a/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
+++ b/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
@@ -39,11 +39,11 @@ public class TestTypeParameters extends JavadocTester {
//Javadoc arguments.
private static final String[] ARGS1 = new String[]{
- "-d", OUTPUT_DIR, "-use", "-sourcepath", SRC_DIR,
+ "-d", OUTPUT_DIR + "-1", "-use", "-sourcepath", SRC_DIR,
"pkg"
};
private static final String[] ARGS2 = new String[]{
- "-d", OUTPUT_DIR, "-linksource", "-sourcepath", SRC_DIR,
+ "-d", OUTPUT_DIR + "-2", "-linksource", "-sourcepath", SRC_DIR,
"pkg"
};
diff --git a/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java b/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java
index 37884dd25da..c2c13ab736a 100644
--- a/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java
+++ b/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java
@@ -40,11 +40,11 @@ public class TestWarnings extends JavadocTester {
//Javadoc arguments.
private static final String[] ARGS = new String[] {
- "-Xdoclint:none", "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg"
+ "-Xdoclint:none", "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg"
};
private static final String[] ARGS2 = new String[] {
- "-Xdoclint:none", "-d", OUTPUT_DIR, "-private", "-sourcepath", SRC_DIR,
+ "-Xdoclint:none", "-d", OUTPUT_DIR + "-2", "-private", "-sourcepath", SRC_DIR,
"pkg"
};
@@ -78,7 +78,6 @@ public class TestWarnings extends JavadocTester {
public static void main(String[] args) {
TestWarnings tester = new TestWarnings();
tester.run(ARGS, TEST, NEGATED_TEST);
- tester.run(ARGS, TEST, NEGATED_TEST);
tester.run(ARGS2, TEST2, NO_TEST);
tester.printSummary();
}