1 /* |
|
2 * Copyright (c) 2013, 2015, 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 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 8025844 |
|
27 * @summary test DocumentationTool.Location methods |
|
28 * @modules java.compiler |
|
29 * jdk.compiler |
|
30 * @build APITest |
|
31 * @run main DocumentationToolLocationTest |
|
32 */ |
|
33 |
|
34 import javax.tools.DocumentationTool; |
|
35 import java.util.Objects; |
|
36 |
|
37 /** |
|
38 * Test for DocumentationTool.Location methods. |
|
39 */ |
|
40 public class DocumentationToolLocationTest extends APITest { |
|
41 public static void main(String[] args) throws Exception { |
|
42 new DocumentationToolLocationTest().run(); |
|
43 } |
|
44 |
|
45 /** |
|
46 * Test getName() method |
|
47 */ |
|
48 @Test |
|
49 public void testGetName() throws Exception { |
|
50 // getName() returns name(). This is for test coverage of getName. |
|
51 for (DocumentationTool.Location dl: DocumentationTool.Location.values()) { |
|
52 String expect = dl.name(); |
|
53 String found = dl.getName(); |
|
54 if (!Objects.equals(expect, found)) |
|
55 throw new Exception("mismatch for " + dl + "; expected " + expect + ", found " + found); |
|
56 } |
|
57 } |
|
58 |
|
59 /** |
|
60 * Test generated enum methods values() and valueOf() |
|
61 */ |
|
62 @Test |
|
63 public void testEnumMethods() throws Exception { |
|
64 DocumentationTool.Location[] values = DocumentationTool.Location.values(); |
|
65 if (values.length != 3) |
|
66 throw new Exception("unexpected number of values returned"); |
|
67 |
|
68 for (DocumentationTool.Location dl: values) { |
|
69 DocumentationTool.Location expect = dl; |
|
70 DocumentationTool.Location found = DocumentationTool.Location.valueOf(dl.name()); |
|
71 if (!Objects.equals(expect, found)) |
|
72 throw new Exception("mismatch for " + dl + "; expected " + expect + ", found " + found); |
|
73 } |
|
74 } |
|
75 } |
|