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.shared.filtering;
20  
21  import java.nio.file.Files;
22  import java.nio.file.Path;
23  import java.nio.file.Paths;
24  import java.util.Collections;
25  
26  import org.apache.maven.api.di.Inject;
27  import org.apache.maven.api.di.testing.MavenDITest;
28  import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
29  import org.apache.maven.di.Injector;
30  import org.junit.jupiter.api.BeforeEach;
31  import org.junit.jupiter.api.Test;
32  
33  import static org.apache.maven.api.di.testing.MavenDIExtension.getBasedir;
34  import static org.junit.jupiter.api.Assertions.fail;
35  
36  /**
37   * @author Mikolaj Izdebski
38   */
39  @MavenDITest
40  public class InvalidMarkTest {
41  
42      @Inject
43      Injector container;
44  
45      Path outputDirectory = Paths.get(getBasedir(), "target/LongLineTest");
46  
47      @BeforeEach
48      protected void setUp() throws Exception {
49          if (Files.exists(outputDirectory)) {
50              IOUtils.deleteDirectory(outputDirectory);
51          }
52          Files.createDirectories(outputDirectory);
53      }
54  
55      @Test
56      public void testEscape() throws Exception {
57          MavenResourcesFiltering mavenResourcesFiltering = container.getInstance(MavenResourcesFiltering.class);
58  
59          Resource resource = new Resource();
60          resource.setDirectory("src/test/units-files/MSHARED-325");
61          resource.setFiltering(true);
62  
63          MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(
64                  Collections.singletonList(resource),
65                  outputDirectory,
66                  new ProjectStub().setBasedir(Paths.get(".")),
67                  "UTF-8",
68                  Collections.<String>emptyList(),
69                  Collections.<String>emptyList(),
70                  new StubSession());
71  
72          try {
73              mavenResourcesFiltering.filterResources(mavenResourcesExecution);
74          } catch (MavenFilteringException e) {
75              fail();
76          }
77      }
78  }