This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git


The following commit(s) were added to refs/heads/maven-3.9.x by this push:
     new 351a0271d Add test cases for apache/maven#10937 (#407)
351a0271d is described below

commit 351a0271dba0c5e85f18d40d8de33e16c58dd0ea
Author: Bob <1674237+bob...@users.noreply.github.com>
AuthorDate: Fri Jul 25 19:08:27 2025 +1000

    Add test cases for apache/maven#10937 (#407)
    
    * Add test cases for apache/maven#10937
    
    Test that adding pipes to either MAVEN_OPTS or jvm.config does not break 
anything
    
    * Add test cases for apache/maven#10937
    
    Test that adding pipes to either MAVEN_OPTS or jvm.config does not break 
anything
---
 .../MavenITgh10937QuotedPipesInMavenOptsTest.java  | 60 ++++++++++++++++++++++
 .../org/apache/maven/it/TestSuiteOrdering.java     |  2 +
 .../gh-10937-pipes-maven-opts/.mvn/jvm.config      |  1 +
 .../resources/gh-10937-pipes-maven-opts/pom.xml    | 59 +++++++++++++++++++++
 4 files changed, 122 insertions(+)

diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10937QuotedPipesInMavenOptsTest.java
 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10937QuotedPipesInMavenOptsTest.java
new file mode 100644
index 000000000..bea3532fe
--- /dev/null
+++ 
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10937QuotedPipesInMavenOptsTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.verifier.Verifier;
+import org.apache.maven.shared.verifier.util.ResourceExtractor;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * This is a test set for <a 
href="https://github.com/apache/maven/issues/10937";>gh-10937</a>.
+ */
+class MavenITgh10937QuotedPipesInMavenOptsTest extends 
AbstractMavenIntegrationTestCase {
+
+    MavenITgh10937QuotedPipesInMavenOptsTest() {
+        super("[3.0.0,)");
+    }
+
+    /**
+     *  Verify the dependency management of the consumer POM is computed 
correctly
+     */
+    @Test
+    void testIt() throws Exception {
+        File basedir = ResourceExtractor.simpleExtractResources(getClass(), 
"/gh-10937-pipes-maven-opts");
+
+        Verifier verifier = newVerifier(basedir.getAbsolutePath());
+        verifier.setEnvironmentVariable("MAVEN_OPTS", 
"-Dprop.maven-opts=\"foo|bar\"");
+        verifier.addCliArguments("validate");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        Properties props = verifier.loadProperties("target/pom.properties");
+        // Strip quotes because the bash startup script in 3.9.x preserves 
them while cmd does not
+        // In this test we only care that the pipe does not cause issues and 
is retained,
+        // not what happens to the surrounding quotes.
+        assertEquals("foo|bar", 
StringUtils.strip(props.getProperty("project.properties.pom.prop.jvm-opts"), 
"\""));
+        assertEquals("foo|bar", 
StringUtils.strip(props.getProperty("project.properties.pom.prop.maven-opts"), 
"\""));
+    }
+}
diff --git 
a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java 
b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index 0cd88ba47..ecc524039 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -120,6 +120,8 @@ public class TestSuiteOrdering implements ClassOrderer {
          * the tests are to finishing. Newer tests are also more likely to 
fail, so this is
          * a fail fast technique as well.
          */
+
+        suite.addTestSuite(MavenITgh10937QuotedPipesInMavenOptsTest.class);
         suite.addTestSuite(MavenITmng8106OverlappingDirectoryRolesTest.class);
         suite.addTestSuite(MavenITmng7939PluginsValidationExcludesTest.class);
         suite.addTestSuite(MavenITmng7804PluginExecutionOrderTest.class);
diff --git 
a/core-it-suite/src/test/resources/gh-10937-pipes-maven-opts/.mvn/jvm.config 
b/core-it-suite/src/test/resources/gh-10937-pipes-maven-opts/.mvn/jvm.config
new file mode 100644
index 000000000..10fc239d8
--- /dev/null
+++ b/core-it-suite/src/test/resources/gh-10937-pipes-maven-opts/.mvn/jvm.config
@@ -0,0 +1 @@
+-Dprop.jvm-opts="foo|bar"
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/gh-10937-pipes-maven-opts/pom.xml 
b/core-it-suite/src/test/resources/gh-10937-pipes-maven-opts/pom.xml
new file mode 100644
index 000000000..d1ef2ca10
--- /dev/null
+++ b/core-it-suite/src/test/resources/gh-10937-pipes-maven-opts/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<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>org.apache.maven.its.gh10937</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+
+  <name>Maven Integration Test :: GH-10937</name>
+  <description>Verify that JVM args can contain pipes.</description>
+
+  <properties>
+    <pom.prop.maven-opts>${prop.maven-opts}</pom.prop.maven-opts>
+    <pom.prop.jvm-opts>${prop.jvm-opts}</pom.prop.jvm-opts>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-expression</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>eval</goal>
+            </goals>
+            <phase>validate</phase>
+            <configuration>
+              <outputFile>target/pom.properties</outputFile>
+              <expressions>
+                <expression>project/properties</expression>
+              </expressions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Reply via email to