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.internal;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import org.junit.jupiter.api.Test;
25  
26  import static org.junit.jupiter.api.Assertions.assertEquals;
27  
28  class MultilineMessageHelperTest {
29  
30      @Test
31      void testBuilderCommon() {
32          List<String> msgs = new ArrayList<>();
33          msgs.add("*****************************************************************");
34          msgs.add("* Your build is requesting parallel execution, but project      *");
35          msgs.add("* contains the following plugin(s) that have goals not marked   *");
36          msgs.add("* as @threadSafe to support parallel building.                  *");
37          msgs.add("* While this /may/ work fine, please look for plugin updates    *");
38          msgs.add("* and/or request plugins be made thread-safe.                   *");
39          msgs.add("* If reporting an issue, report it against the plugin in        *");
40          msgs.add("* question, not against maven-core                              *");
41          msgs.add("*****************************************************************");
42  
43          assertEquals(
44                  msgs,
45                  MultilineMessageHelper.format(
46                          "Your build is requesting parallel execution, but project contains the following "
47                                  + "plugin(s) that have goals not marked as @threadSafe to support parallel building.",
48                          "While this /may/ work fine, please look for plugin updates and/or "
49                                  + "request plugins be made thread-safe.",
50                          "If reporting an issue, report it against the plugin in question, not against maven-core"));
51      }
52  
53      @Test
54      void testMojoExecutor() {
55          List<String> msgs = new ArrayList<>();
56          msgs.add("*****************************************************************");
57          msgs.add("* An aggregator Mojo is already executing in parallel build,    *");
58          msgs.add("* but aggregator Mojos require exclusive access to reactor to   *");
59          msgs.add("* prevent race conditions. This mojo execution will be blocked  *");
60          msgs.add("* until the aggregator work is done.                            *");
61          msgs.add("*****************************************************************");
62  
63          assertEquals(
64                  msgs,
65                  MultilineMessageHelper.format(
66                          "An aggregator Mojo is already executing in parallel build, but aggregator "
67                                  + "Mojos require exclusive access to reactor to prevent race conditions. This "
68                                  + "mojo execution will be blocked until the aggregator work is done."));
69      }
70  }