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.surefire.its;
20  
21  import java.util.List;
22  
23  import org.apache.maven.it.VerificationException;
24  import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
25  import org.apache.maven.surefire.its.fixture.OutputValidator;
26  import org.junit.Test;
27  
28  import static org.assertj.core.api.Assertions.assertThat;
29  import static org.hamcrest.Matchers.containsString;
30  import static org.hamcrest.Matchers.is;
31  
32  /**
33   * Integration test for <a href="https://issues.apache.org/jira/browse/SUREFIRE-1733">SUREFIRE-1733</a>.
34   */
35  public class MultiModuleProjectWithJPMSIT extends AbstractJava9PlusIT {
36      @Test
37      public void test() throws VerificationException {
38          OutputValidator validator = assumeJava9()
39                  .debugLogging()
40                  .executeVerify()
41                  .verifyErrorFreeLog()
42                  .assertThatLogLine(containsString("Lets see JDKModulePath"), is(2))
43                  .assertThatLogLine(containsString("Lets see JDKModulePath: null"), is(0));
44  
45          List<String> lines = validator.loadLogLines(containsString("Lets see JDKModulePath"));
46          int i = 0;
47          for (String line : lines) {
48              assertThat(line)
49                      .contains("com.foo.api")
50                      .contains("junit-jupiter-api")
51                      .contains("junit-jupiter-engine")
52                      .contains("slf4j-simple")
53                      .contains("slf4j-api")
54                      .contains("jakarta.xml.bind-api")
55                      .contains("jakarta.ws.rs-api")
56                      .contains("jakarta.persistence-api");
57  
58              assertThat(line).contains(i++ == 0 ? "test-classes" : "com.foo.impl");
59          }
60      }
61  
62      @Override
63      protected String getProjectDirectoryName() {
64          return "maven-multimodule-project-with-jpms";
65      }
66  }