|
| 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.it; |
| 20 | + |
| 21 | +import java.io.File; |
| 22 | +import java.nio.file.Files; |
| 23 | +import java.util.Properties; |
| 24 | + |
| 25 | +import org.junit.jupiter.api.Test; |
| 26 | + |
| 27 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 28 | + |
| 29 | +/** |
| 30 | + * This is a test set for MNG-4559: |
| 31 | + * - Verifies that multiple JVM arguments in .mvn/jvm.config are properly handled |
| 32 | + * - Ensures arguments are correctly split and passed to the JVM |
| 33 | + */ |
| 34 | +public class MavenITmng4559MultipleJvmArgsTest extends AbstractMavenIntegrationTestCase { |
| 35 | + public MavenITmng4559MultipleJvmArgsTest() { |
| 36 | + super("[4.0.0-rc-4,)"); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void testMultipleJvmArgs() throws Exception { |
| 41 | + File testDir = extractResources("/mng-4559-multiple-jvm-args"); |
| 42 | + File mvnDir = new File(testDir, ".mvn"); |
| 43 | + File jvmConfig = new File(mvnDir, "jvm.config"); |
| 44 | + |
| 45 | + mvnDir.mkdirs(); |
| 46 | + Files.writeString( |
| 47 | + jvmConfig.toPath(), |
| 48 | + "# This is a comment\n" + "-Xmx2048m -Xms1024m -Dtest.prop1=value1 # end of line comment\n" |
| 49 | + + "# Another comment\n" |
| 50 | + + "-Dtest.prop2=\"value 2\""); |
| 51 | + |
| 52 | + Verifier verifier = newVerifier(testDir.getAbsolutePath()); |
| 53 | + verifier.setForkJvm(true); |
| 54 | + verifier.addCliArgument("validate"); |
| 55 | + verifier.execute(); |
| 56 | + verifier.verifyErrorFreeLog(); |
| 57 | + |
| 58 | + Properties props = verifier.loadProperties("target/jvm.properties"); |
| 59 | + assertEquals("value1", props.getProperty("project.properties.pom.test.prop1")); |
| 60 | + assertEquals("value 2", props.getProperty("project.properties.pom.test.prop2")); |
| 61 | + } |
| 62 | +} |
0 commit comments