Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java
47559 views
/*1* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.File;2425/*26* @test27* @bug 4258405 4973606 802409628* @summary This test verifies that the doc-file directory does not29* get overwritten when the sourcepath is equal to the destination30* directory.31* Also test that -docfilessubdirs and -excludedocfilessubdir both work.32* @author jamieh33* @library ../lib/34* @build JavadocTester35* @build TestDocFileDir36* @run main TestDocFileDir37*/3839public class TestDocFileDir extends JavadocTester {4041private static final String BUG_ID = "4258405-4973606";4243private static final String[][] TEST1 = {44{BUG_ID + "-1" + FS + "pkg" + FS + "doc-files" + FS + "testfile.txt",45"This doc file did not get trashed."}46};47private static final String[][] NEGATED_TEST1 = NO_TEST;4849private static final String[] FILE_TEST2 = {50BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used1" +51FS + "testfile.txt",52BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used2" +53FS + "testfile.txt"54};55private static final String[] FILE_NEGATED_TEST2 = {56BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded1" +57FS + "testfile.txt",58BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded2" +59FS + "testfile.txt"60};6162private static final String[][] TEST0 = {63{"pkg" + FS + "doc-files" + FS + "testfile.txt",64"This doc file did not get trashed."}65};66private static final String[][] NEGATED_TEST0 = {};6768//Output dir = Input Dir69private static final String[] ARGS1 =70new String[] {71"-d", BUG_ID + "-1",72"-sourcepath",73"blah" + File.pathSeparator + BUG_ID + "-1" + File.pathSeparator + "blah",74"pkg"};7576//Exercising -docfilessubdirs and -excludedocfilessubdir77private static final String[] ARGS2 =78new String[] {79"-d", BUG_ID + "-2",80"-sourcepath", SRC_DIR,81"-docfilessubdirs",82"-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",83"pkg"};8485//Output dir = "", Input dir = ""86private static final String[] ARGS0 =87new String[] {"pkg" + FS + "C.java"};888990/**91* The entry point of the test.92* @param args the array of command line arguments.93*/94public static void main(String[] args) {95TestDocFileDir tester = new TestDocFileDir();96copyDir(SRC_DIR + FS + "pkg", ".");97run(tester, ARGS0, TEST0, NEGATED_TEST0);98copyDir(SRC_DIR + FS + "pkg", BUG_ID + "-1");99run(tester, ARGS1, TEST1, NEGATED_TEST1);100run(tester, ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2);101tester.printSummary();102}103104/**105* {@inheritDoc}106*/107public String getBugId() {108return BUG_ID;109}110111/**112* {@inheritDoc}113*/114public String getBugName() {115return getClass().getName();116}117}118119120