View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.jxr.pacman;
20  
21  import java.io.IOException;
22  import java.nio.file.Paths;
23  import java.util.Iterator;
24  
25  import org.junit.Test;
26  
27  import static org.junit.Assert.assertEquals;
28  
29  public class JavaFileImplTest {
30      @Test
31      public void testJXR_135_lotsOfNested() throws IOException {
32          JavaFileImpl javaFile = new JavaFileImpl(
33                  Paths.get("src/test/resources/jxr135/org/apache/maven/jxr/pacman/ClassWithNested.java"), "UTF-8");
34          final Iterator<ClassType> classTypes = javaFile.getClassTypes().iterator();
35          assertEquals("ClassWithNested", classTypes.next().getName());
36          assertEquals("ClassWithNested.NestedInterface", classTypes.next().getName());
37          assertEquals("ClassWithNested.NestedClassWithEnum", classTypes.next().getName());
38          assertEquals(
39                  "ClassWithNested.NestedClassWithEnum.NestedEnum",
40                  classTypes.next().getName());
41          assertEquals(
42                  "ClassWithNested.NestedClassWithEnum.NestedClass2",
43                  classTypes.next().getName());
44          assertEquals("ClassWithNested.NestedClassWithEnum2", classTypes.next().getName());
45          assertEquals(
46                  "ClassWithNested.NestedClassWithEnum2.NestedEnum",
47                  classTypes.next().getName());
48          assertEquals(
49                  "ClassWithNested.NestedClassWithEnum2.NestedClass2",
50                  classTypes.next().getName());
51          assertEquals("NotNested", classTypes.next().getName());
52      }
53  
54      @Test
55      public void testJXR_170_multiLineString() throws IOException {
56          JavaFileImpl javaFile = new JavaFileImpl(
57                  Paths.get("src/test/resources/jxr170/org/apache/maven/jxr/pacman/ClassWithMultiLineString.java"),
58                  "UTF-8");
59          assertEquals(1, javaFile.getClassTypes().size());
60          assertEquals("ClassWithMultiLineString", javaFile.getClassTypes().get(0).getName());
61          assertEquals("[ImportType[name=java.lang.*]]", javaFile.getImportTypes().toString());
62      }
63  
64      @Test
65      public void testJXR_175_java14Record() throws IOException {
66          JavaFileImpl javaFile = new JavaFileImpl(
67                  Paths.get("src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java"), "UTF-8");
68          assertEquals(1, javaFile.getClassTypes().size());
69          assertEquals("Java14Record", javaFile.getClassTypes().get(0).getName());
70      }
71  }