You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2019/01/08 23:54:18 UTC

[GitHub] asfgit closed pull request #23: [MNG-6265] Integration test for Maven script can break if "-f" path contains special characters

asfgit closed pull request #23: [MNG-6265] Integration test for Maven script can break if "-f" path contains special characters 
URL: https://github.com/apache/maven-integration-testing/pull/23
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 026b4b01..458e35cb 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -106,6 +106,7 @@ public static Test suite()
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
+        suite.addTestSuite( MavenITmng6256SpecialCharsAlternatePOMLocation.class );
         suite.addTestSuite( MavenITmng6240PluginExtensionAetherProvider.class );
         suite.addTestSuite( MavenITmng6223FindBasedir.class );
         suite.addTestSuite( MavenITmng6189SiteReportPluginsWarningTest.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java
new file mode 100644
index 00000000..9a902041
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java
@@ -0,0 +1,92 @@
+package org.apache.maven.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6256">MNG-6256</a>: check that directories
+ * passed via <code>-f/--file</code> containing special characters do not break the script. E.g
+ * <code>-f "folderWithClosing)Bracket/pom.xml"</code>.
+ */
+public class MavenITmng6256SpecialCharsAlternatePOMLocation
+    extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng6256SpecialCharsAlternatePOMLocation()
+    {
+        super( "[3.5.1,)" );
+    }
+
+    protected MavenITmng6256SpecialCharsAlternatePOMLocation( String constraint )
+    {
+        super( constraint );
+    }
+
+    /**
+     * check script is working when path to POM is set to <code>folder-with- -space</code>
+     */
+    public void testFolderWithSpace()
+        throws Exception
+    {
+        runWithMvnFileLongOption( "folder-with- -space" );
+        runWithMvnFileShortOption( "folder-with- -space" );
+    }
+
+    /**
+     * check script is working when path to POM is set to <code>folder-with-)-closing-bracket</code>
+     */
+    public void testFolderWithClosingBracket()
+        throws Exception
+    {
+        runWithMvnFileLongOption( "folder-with-)-closing-bracket" );
+        runWithMvnFileShortOption( "folder-with-)-closing-bracket" );
+    }
+
+    private void runWithMvnFileLongOption( String subDir )
+        throws Exception
+    {
+        runCoreExtensionWithOption( "--file", subDir );
+    }
+
+    private void runWithMvnFileShortOption( String subDir )
+        throws Exception
+    {
+        runCoreExtensionWithOption( "-f", subDir );
+    }
+
+    private void runCoreExtensionWithOption( String option, String subDir )
+        throws Exception
+    {
+        File resourceDir =
+            ResourceExtractor.simpleExtractResources( getClass(), "/mng-6256-special-chars-alternate-pom-location" );
+
+        File testDir = new File( resourceDir, "../mng-6256-" + subDir );
+        testDir.mkdir();
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.getCliOptions().add( option ); // -f/--file
+        verifier.getCliOptions().add( "\"" + new File( resourceDir, subDir ).getAbsolutePath() + "\"" ); // "<path>"
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with- -space/pom.xml b/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with- -space/pom.xml
new file mode 100644
index 00000000..1faf517c
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with- -space/pom.xml	
@@ -0,0 +1,8 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>scratch</groupId>
+  <artifactId>scratch</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <build>
+  </build>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with-)-closing-bracket/pom.xml b/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with-)-closing-bracket/pom.xml
new file mode 100644
index 00000000..1faf517c
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with-)-closing-bracket/pom.xml
@@ -0,0 +1,8 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>scratch</groupId>
+  <artifactId>scratch</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <build>
+  </build>
+</project>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services