View Javadoc
1   package org.apache.maven.surefire.its;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.surefire.its.fixture.OutputValidator;
23  import org.junit.Test;
24  
25  import java.io.File;
26  
27  import static org.apache.maven.surefire.its.fixture.SurefireLauncher.EXT_JDK_HOME;
28  import static org.apache.maven.surefire.its.fixture.SurefireLauncher.EXT_JDK_HOME_KEY;
29  import static org.hamcrest.Matchers.anyOf;
30  import static org.hamcrest.Matchers.greaterThanOrEqualTo;
31  import static org.hamcrest.Matchers.is;
32  
33  /**
34   * Running Surefire on the top of JDK 9 and should be able to load
35   * classes of multiple different Jigsaw modules without error.
36   *
37   * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
38   * @since 2.20.1
39   */
40  public class Java9FullApiIT
41          extends AbstractJigsawIT
42  {
43  
44      @Test
45      public void shouldLoadMultipleJavaModules_JavaHome() throws Exception
46      {
47          OutputValidator validator = assumeJigsaw()
48                                              .setForkJvm()
49                                              .debugLogging()
50                                              .execute( "verify" )
51                                              .verifyErrorFree( 1 );
52  
53          validator.verifyTextInLog( "loaded class java.sql.SQLException" )
54                  .verifyTextInLog( "loaded class javax.xml.ws.Holder" )
55                  .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" )
56                  .verifyTextInLog( "loaded class javax.transaction.TransactionManager" )
57                  .verifyTextInLog( "loaded class javax.transaction.InvalidTransactionException" )
58                  .assertThatLogLine( anyOf( is( "java.specification.version=9" ),
59                                             is( "java.specification.version=10" ),
60                                             is( "java.specification.version=11" ) ),
61                                      greaterThanOrEqualTo( 1 ) );
62      }
63  
64      @Test
65      public void shouldLoadMultipleJavaModules_JvmParameter() throws Exception
66      {
67          OutputValidator validator = assumeJava9Property()
68                                              .setForkJvm()
69                                              .debugLogging()
70                                              .sysProp( EXT_JDK_HOME_KEY, new File( EXT_JDK_HOME ).getCanonicalPath() )
71                                              .execute( "verify" )
72                                              .verifyErrorFree( 1 );
73  
74          validator.verifyTextInLog( "loaded class java.sql.SQLException" )
75                  .verifyTextInLog( "loaded class javax.xml.ws.Holder" )
76                  .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" )
77                  .verifyTextInLog( "loaded class javax.transaction.TransactionManager" )
78                  .verifyTextInLog( "loaded class javax.transaction.InvalidTransactionException" )
79                  .assertThatLogLine( anyOf( is( "java.specification.version=9" ),
80                                             is( "java.specification.version=10" ),
81                                             is( "java.specification.version=11" ) ),
82                                      greaterThanOrEqualTo( 1 ) );
83      }
84  
85      @Test
86      public void shouldLoadMultipleJavaModules_ToolchainsXML() throws Exception
87      {
88          OutputValidator validator = assumeJava9Property()
89                                              .setForkJvm()
90                                              .activateProfile( "use-toolchains" )
91                                              .addGoal( "--toolchains" )
92                                              .addGoal( System.getProperty( "maven.toolchains.file" ) )
93                                              .execute( "verify" )
94                                              .verifyErrorFree( 1 );
95  
96          validator.verifyTextInLog( "loaded class java.sql.SQLException" )
97                  .verifyTextInLog( "loaded class javax.xml.ws.Holder" )
98                  .verifyTextInLog( "loaded class javax.xml.bind.JAXBException" )
99                  .verifyTextInLog( "loaded class javax.transaction.TransactionManager" )
100                 .verifyTextInLog( "loaded class javax.transaction.InvalidTransactionException" )
101                 .assertThatLogLine( anyOf( is( "java.specification.version=9" ),
102                                            is( "java.specification.version=10" ),
103                                            is( "java.specification.version=11" ) ),
104                                     greaterThanOrEqualTo( 1 ) );
105     }
106 
107     @Override
108     protected String getProjectDirectoryName()
109     {
110         return "java9-full-api";
111     }
112 }