diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 06282fd66b..bb3cf81e88 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -111,6 +111,7 @@ public class IntegrationTestSuite suite.addTestSuite( MavenITmng6386BaseUriPropertyTest.class ); suite.addTestSuite( MavenITmng6330RelativePath.class ); suite.addTestSuite( MavenITmng5965ParallelBuildMultipliesWorkTest.class ); + suite.addTestSuite( MavenITmng6255FixConcatLines.class ); suite.addTestSuite( MavenITmng6240PluginExtensionAetherProvider.class ); suite.addTestSuite( MavenITmng6223FindBasedir.class ); suite.addTestSuite( MavenITmng6189SiteReportPluginsWarningTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6255FixConcatLines.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6255FixConcatLines.java new file mode 100644 index 0000000000..35644759a2 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6255FixConcatLines.java @@ -0,0 +1,104 @@ +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 java.util.Properties; + +import org.apache.maven.it.util.ResourceExtractor; + +import com.google.common.base.Charsets; +import com.google.common.base.Joiner; +import com.google.common.io.Files; + +/** + * This is a test set for MNG-6255: + * Check that the .mvn/jvm.config file contents are concatenated properly, no matter + * what line endings are used. + */ +public class MavenITmng6255FixConcatLines + extends AbstractMavenIntegrationTestCase +{ + public MavenITmng6255FixConcatLines() + { + super( "[3.5.3,)" ); + } + + protected MavenITmng6255FixConcatLines( String constraint ) + { + super( constraint ); + } + + /** + * Check that CR line endings work. + *

+ * Currently disabled. + */ + public void disabledJvmConfigFileCR() + throws Exception + { + runWithLineEndings( "\r" ); + } + + /** + * Check that LF line endings work. + */ + public void testJvmConfigFileLF() + throws Exception + { + runWithLineEndings( "\n" ); + } + + /** + * Check that CRLF line endings work. + */ + public void testJvmConfigFileCRLF() + throws Exception + { + runWithLineEndings( "\r\n" ); + } + + protected void runWithLineEndings( String lineEndings ) + throws Exception + { + File baseDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6255" ); + File mvnDir = new File( baseDir, ".mvn" ); + + File jvmConfig = new File( mvnDir, "jvm.config" ); + createJvmConfigFile( jvmConfig, lineEndings, "-Djvm.config=ok", "-Xms256m", "-Xmx512m" ); + + Verifier verifier = newVerifier( baseDir.getAbsolutePath() ); + verifier.getCliOptions().add( "-Dexpression.outputFile=" + new File( baseDir, "expression.properties" ).getAbsolutePath() ); + verifier.setForkJvm( true ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + Properties props = verifier.loadProperties( "expression.properties" ); + assertEquals( "ok", props.getProperty( "project.properties.jvm-config" ) ); + } + + protected void createJvmConfigFile( File jvmConfig, String lineEndings, String...lines ) + throws Exception + { + String content = Joiner.on(lineEndings).join(lines); + Files.write( content, jvmConfig, Charsets.UTF_8 ); + } +} diff --git a/its/core-it-suite/src/test/resources/mng-6255/.mvn/jvm.config b/its/core-it-suite/src/test/resources/mng-6255/.mvn/jvm.config new file mode 100644 index 0000000000..e69de29bb2 diff --git a/its/core-it-suite/src/test/resources/mng-6255/pom.xml b/its/core-it-suite/src/test/resources/mng-6255/pom.xml new file mode 100644 index 0000000000..90fe9e1216 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-6255/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng6255 + test + 1 + pom + + Maven Integration Test :: MNG-6255 + + Verify that .mvn/jvm.config file is parsed correctly with different line endings + + + + ${jvm.config} + ${user.dir} + ${maven.multiModuleProjectDirectory} + + + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + + project/properties/jvm-config + project/properties/user-dir + project/properties/maven-multiModuleProjectDirectory + project/basedir + + + + + test + validate + + eval + + + + + + +