langtools/test/tools/javadoc/api/basic/GetTask_OptionsTest.java
changeset 27319 030080f03e4f
parent 14545 2e7bab0639b8
child 30730 d3ce7619db2c
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
     1 /*
     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    52      */
    52      */
    53     @Test
    53     @Test
    54     public void testNoIndex() throws Exception {
    54     public void testNoIndex() throws Exception {
    55         JavaFileObject srcFile = createSimpleJavaFileObject();
    55         JavaFileObject srcFile = createSimpleJavaFileObject();
    56         DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    56         DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    57         StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    57         try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
    58         File outDir = getOutDir();
    58             File outDir = getOutDir();
    59         fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    59             fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    60         Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    60             Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    61         Iterable<String> options = Arrays.asList("-noindex");
    61             Iterable<String> options = Arrays.asList("-noindex");
    62         DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
    62             DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
    63         if (t.call()) {
    63             if (t.call()) {
    64             System.err.println("task succeeded");
    64                 System.err.println("task succeeded");
    65             Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
    65                 Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
    66             expectFiles.remove("index-all.html");
    66                 expectFiles.remove("index-all.html");
    67             checkFiles(outDir, expectFiles);
    67                 checkFiles(outDir, expectFiles);
    68         } else {
    68             } else {
    69             error("task failed");
    69                 error("task failed");
       
    70             }
    70         }
    71         }
    71     }
    72     }
    72 
    73 
    73     /**
    74     /**
    74      * Verify null is handled correctly.
    75      * Verify null is handled correctly.
    75      */
    76      */
    76     @Test
    77     @Test
    77     public void testNull() throws Exception {
    78     public void testNull() throws Exception {
    78         JavaFileObject srcFile = createSimpleJavaFileObject();
    79         JavaFileObject srcFile = createSimpleJavaFileObject();
    79         DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    80         DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    80         StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    81         try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
    81         File outDir = getOutDir();
    82             File outDir = getOutDir();
    82         fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    83             fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    83         Iterable<String> options = Arrays.asList((String) null);
    84             Iterable<String> options = Arrays.asList((String) null);
    84         Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    85             Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    85         try {
    86             try {
    86             DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
    87                 DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
    87             error("getTask succeeded, no exception thrown");
    88                 error("getTask succeeded, no exception thrown");
    88         } catch (NullPointerException e) {
    89             } catch (NullPointerException e) {
    89             System.err.println("exception caught as expected: " + e);
    90                 System.err.println("exception caught as expected: " + e);
       
    91             }
    90         }
    92         }
    91     }
    93     }
    92 
    94 
    93 }
    95 }
    94 
    96