Path: blob/master/test/langtools/jdk/javadoc/tool/api/basic/DocumentationToolLocationTest.java
40983 views
/*1* Copyright (c) 2013, 2015, 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*/2223/*24* @test25* @bug 802584426* @summary test DocumentationTool.Location methods27* @modules java.compiler28* jdk.compiler29* @build APITest30* @run main DocumentationToolLocationTest31*/3233import javax.tools.DocumentationTool;34import java.util.Objects;3536/**37* Test for DocumentationTool.Location methods.38*/39public class DocumentationToolLocationTest extends APITest {40public static void main(String[] args) throws Exception {41new DocumentationToolLocationTest().run();42}4344/**45* Test getName() method46*/47@Test48public void testGetName() throws Exception {49// getName() returns name(). This is for test coverage of getName.50for (DocumentationTool.Location dl: DocumentationTool.Location.values()) {51String expect = dl.name();52String found = dl.getName();53if (!Objects.equals(expect, found))54throw new Exception("mismatch for " + dl + "; expected " + expect + ", found " + found);55}56}5758/**59* Test generated enum methods values() and valueOf()60*/61@Test62public void testEnumMethods() throws Exception {63DocumentationTool.Location[] values = DocumentationTool.Location.values();64if (values.length != 3)65throw new Exception("unexpected number of values returned");6667for (DocumentationTool.Location dl: values) {68DocumentationTool.Location expect = dl;69DocumentationTool.Location found = DocumentationTool.Location.valueOf(dl.name());70if (!Objects.equals(expect, found))71throw new Exception("mismatch for " + dl + "; expected " + expect + ", found " + found);72}73}74}757677