View Javadoc
1   package org.apache.maven.tools.plugin.javadoc;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import java.io.IOException;
22  import java.net.URI;
23  import java.util.stream.Stream;
24  
25  import org.apache.maven.tools.plugin.javadoc.FullyQualifiedJavadocReference.MemberType;
26  import org.junit.jupiter.params.ParameterizedTest;
27  import org.junit.jupiter.params.provider.Arguments;
28  import org.junit.jupiter.params.provider.MethodSource;
29  
30  class JavadocSiteIT
31  {
32  
33      static Stream<Arguments> javadocBaseUrls()
34      {
35          return Stream.of( Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/17/docs/api/" ) ),
36                            Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/16/docs/api/" ) ),
37                            Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/15/docs/api/" ) ),
38                            Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/14/docs/api/" ) ),
39                            Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/13/docs/api/" ) ),
40                            Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/12/docs/api/" ) ),
41                            Arguments.of( URI.create( "https://docs.oracle.com/en/java/javase/11/docs/api/" ) ),
42                            Arguments.of( URI.create( "https://docs.oracle.com/javase/10/docs/api/" ) ),
43                            Arguments.of( URI.create( "https://docs.oracle.com/javase/9/docs/api/" ) ),
44                            Arguments.of( URI.create( "https://docs.oracle.com/javase/8/docs/api/" ) ),
45                            Arguments.of( URI.create( "https://docs.oracle.com/javase/7/docs/api/" ) ),
46                            Arguments.of( URI.create( "https://docs.oracle.com/javase/6/docs/api/" ) ),
47                            Arguments.of( URI.create( "https://docs.oracle.com/javase/1.5.0/docs/api/" ) ),
48                            Arguments.of( URI.create( "https://javaalmanac.io/jdk/1.4/api/index.html" ) ),
49                            Arguments.of( URI.create( "https://javaalmanac.io/jdk/1.3/api/index.html" ) )
50                  );
51      }
52  
53      @ParameterizedTest
54      @MethodSource( "javadocBaseUrls" )
55      void testConstructors( URI javadocBaseUrl )
56          throws IOException
57      {
58          JavadocSite site = new JavadocSite( javadocBaseUrl, null );
59          JavadocSiteTest.assertUrlValid( site.createLink( new FullyQualifiedJavadocReference( "java.lang", "String",
60                                                                                               "String(byte[],int)",
61                                                                                               MemberType.CONSTRUCTOR, true ) ) );
62      }
63  
64      @ParameterizedTest
65      @MethodSource( "javadocBaseUrls" )
66      void testMethods( URI javadocBaseUrl )
67          throws IOException
68      {
69          JavadocSite site = new JavadocSite( javadocBaseUrl, null );
70          JavadocSiteTest.assertUrlValid( site.createLink( new FullyQualifiedJavadocReference( "java.lang", "String",
71                                                                                               "copyValueOf(char[],int,int)",
72                                                                                               MemberType.METHOD, true ) ) );
73      }
74  
75      @ParameterizedTest
76      @MethodSource( "javadocBaseUrls" )
77      void testFields( URI javadocBaseUrl )
78          throws IOException
79      {
80          JavadocSite site = new JavadocSite( javadocBaseUrl, null );
81          JavadocSiteTest.assertUrlValid( site.createLink( new FullyQualifiedJavadocReference( "java.lang", "String",
82                                                                                               "CASE_INSENSITIVE_ORDER",
83                                                                                               MemberType.FIELD, true ) ) );
84      }
85  }