From 5e8c834b63c2169c367cd4650694ab5083e74ea0 Mon Sep 17 00:00:00 2001 From: Christoph Etzel Date: Fri, 14 Jul 2017 10:43:58 +0200 Subject: [PATCH] MNG-6265 Add integration test --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...g6256SpecialCharsAlternatePOMLocation.java | 92 +++++++++++++++++++ .../folder-with- -space/pom.xml | 8 ++ .../folder-with-)-closing-bracket/pom.xml | 8 ++ 4 files changed, 109 insertions(+) create mode 100644 core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6256SpecialCharsAlternatePOMLocation.java create mode 100644 core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with- -space/pom.xml create mode 100644 core-it-suite/src/test/resources/mng-6256-special-chars-alternate-pom-location/folder-with-)-closing-bracket/pom.xml 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 026b4b01d..458e35cbd 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 000000000..9a9020411 --- /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 MNG-6256: check that directories + * passed via -f/--file containing special characters do not break the script. E.g + * -f "folderWithClosing)Bracket/pom.xml". + */ +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 folder-with- -space + */ + public void testFolderWithSpace() + throws Exception + { + runWithMvnFileLongOption( "folder-with- -space" ); + runWithMvnFileShortOption( "folder-with- -space" ); + } + + /** + * check script is working when path to POM is set to folder-with-)-closing-bracket + */ + 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() + "\"" ); // "" + 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 000000000..1faf517c2 --- /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 @@ + + 4.0.0 + scratch + scratch + 0.0.1-SNAPSHOT + + + 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 000000000..1faf517c2 --- /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 @@ + + 4.0.0 + scratch + scratch + 0.0.1-SNAPSHOT + + +