test/tools/javadoc/api/basic/DocumentationToolLocationTest.java

Tue, 06 Jun 2017 10:03:06 -0700

author
asaha
date
Tue, 06 Jun 2017 10:03:06 -0700
changeset 3395
ec280466843d
parent 0
959103a6100f
permissions
-rw-r--r--

Added tag jdk8u141-b12 for changeset b5259d2465fa

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     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
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 8025844
    27  * @summary test DocumentationTool.Location methods
    28  * @build APITest
    29  * @run main DocumentationToolLocationTest
    30  */
    32 import javax.tools.DocumentationTool;
    33 import java.util.Objects;
    35 /**
    36  * Test for DocumentationTool.Location methods.
    37  */
    38 public class DocumentationToolLocationTest extends APITest {
    39     public static void main(String[] args) throws Exception {
    40         new DocumentationToolLocationTest().run();
    41     }
    43     /**
    44      * Test getName() method
    45      */
    46     @Test
    47     public void testGetName() throws Exception {
    48         // getName() returns name(). This is for test coverage of getName.
    49         for (DocumentationTool.Location dl: DocumentationTool.Location.values()) {
    50             String expect = dl.name();
    51             String found = dl.getName();
    52             if (!Objects.equals(expect, found))
    53                 throw new Exception("mismatch for " + dl + "; expected " + expect + ", found " + found);
    54         }
    55     }
    57     /**
    58      * Test generated enum methods values() and valueOf()
    59      */
    60     @Test
    61     public void testEnumMethods() throws Exception {
    62         DocumentationTool.Location[] values = DocumentationTool.Location.values();
    63         if (values.length != 3)
    64             throw new Exception("unexpected number of values returned");
    66         for (DocumentationTool.Location dl: values) {
    67             DocumentationTool.Location expect = dl;
    68             DocumentationTool.Location found = DocumentationTool.Location.valueOf(dl.name());
    69             if (!Objects.equals(expect, found))
    70                 throw new Exception("mismatch for " + dl + "; expected " + expect + ", found " + found);
    71         }
    72     }
    73 }

mercurial