This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch SUREFIRE-1360 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit bbdcf90874cee037dc4b1e8226896fffbabd96e3 Author: Michael Osipov <[email protected]> AuthorDate: Fri Jul 5 22:28:37 2024 +0200 Add IT --- .../its/jiras/Surefire1360PropertiesElementIT.java | 60 ++++++++++++++++++++++ .../pom.xml | 58 +++++++++++++++++++++ .../TestPropertiesElement.java | 18 +++++++ .../TestPropertiesElement2.java | 17 ++++++ .../pom.xml | 59 +++++++++++++++++++++ .../TestPropertiesElement.java | 12 +++++ 6 files changed, 224 insertions(+) diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.java new file mode 100644 index 000000000..4f2181883 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1360PropertiesElementIT.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.surefire.its.jiras; + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.TestFile; +import org.junit.Test; + +/** + * Test for SUREFIRE-1360. Enabling and disabling properties element in plugin configuration. + */ +public class Surefire1360PropertiesElementIT extends SurefireJUnit4IntegrationTestCase { + + @Test + public void testPropertiesElementDisabled() { + final OutputValidator outputValidator = unpack("/surefire-1360-disable-properties-element") + .maven() + .withFailure() + .executeTest(); + final TestFile reportFile = + outputValidator.getSurefireReportsXmlFile("TEST-disablePropertiesElement.TestPropertiesElement.xml"); + + reportFile.assertContainsText("<properties>"); + reportFile.assertContainsText("</properties>"); + + final TestFile reportFile2 = + outputValidator.getSurefireReportsXmlFile("TEST-disablePropertiesElement.TestPropertiesElement2.xml"); + + reportFile2.assertNotContainsText("<properties>"); + reportFile2.assertNotContainsText("</properties>"); + } + + @Test + public void testPropertiesElementEnabled() { + final OutputValidator outputValidator = + unpack("/surefire-1360-enable-properties-element").executeTest(); + final TestFile reportFile = + outputValidator.getSurefireReportsXmlFile("TEST-enablePropertiesElement.TestPropertiesElement.xml"); + + reportFile.assertContainsText("<properties>"); + reportFile.assertContainsText("</properties>"); + } +} diff --git a/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml new file mode 100644 index 000000000..dee3a5ce4 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/pom.xml @@ -0,0 +1,58 @@ +<?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> + + <parent> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>it-parent</artifactId> + <version>1.0</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>surefire-1960-disable-properties-element</artifactId> + <version>1.0</version> + <url>http://maven.apache.org</url> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.0</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <enablePropertiesElement>false</enablePropertiesElement> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/surefire-its/src/test/resources/surefire-1360-disable-properties-element/src/test/java/disablePropertiesElement/TestPropertiesElement.java b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/src/test/java/disablePropertiesElement/TestPropertiesElement.java new file mode 100644 index 000000000..66b7e7cbf --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/src/test/java/disablePropertiesElement/TestPropertiesElement.java @@ -0,0 +1,18 @@ +package disablePropertiesElement; + +import org.junit.Test; + +public class TestPropertiesElement { + + @Test + public void success() { + System.out.println("This is successful."); + } + + @Test + public void failure() throws Exception { + System.out.println("This is faulty."); + throw new Exception("Expected to fail"); + } + +} diff --git a/surefire-its/src/test/resources/surefire-1360-disable-properties-element/src/test/java/disablePropertiesElement/TestPropertiesElement2.java b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/src/test/java/disablePropertiesElement/TestPropertiesElement2.java new file mode 100644 index 000000000..8f8cf7485 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1360-disable-properties-element/src/test/java/disablePropertiesElement/TestPropertiesElement2.java @@ -0,0 +1,17 @@ +package disablePropertiesElement; + +import org.junit.Test; + +public class TestPropertiesElement2 { + + @Test + public void success() { + System.out.println("This is successful."); + } + + @Test + public void success2() { + System.out.println("This is successful, too."); + } + +} diff --git a/surefire-its/src/test/resources/surefire-1360-enable-properties-element/pom.xml b/surefire-its/src/test/resources/surefire-1360-enable-properties-element/pom.xml new file mode 100644 index 000000000..10d85898b --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1360-enable-properties-element/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> + + <parent> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>it-parent</artifactId> + <version>1.0</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>surefire-1360-enable-properties-element</artifactId> + <version>1.0</version> + <url>http://maven.apache.org</url> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.0</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <!-- Default value, but setting it explicitly for test --> + <enablePropertiesElement>true</enablePropertiesElement> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/surefire-its/src/test/resources/surefire-1360-enable-properties-element/src/test/java/enablePropertiesElement/TestPropertiesElement.java b/surefire-its/src/test/resources/surefire-1360-enable-properties-element/src/test/java/enablePropertiesElement/TestPropertiesElement.java new file mode 100644 index 000000000..fc90db58c --- /dev/null +++ b/surefire-its/src/test/resources/surefire-1360-enable-properties-element/src/test/java/enablePropertiesElement/TestPropertiesElement.java @@ -0,0 +1,12 @@ +package enablePropertiesElement; + +import org.junit.Test; + +public class TestPropertiesElement { + + @Test + public void success() { + System.out.println("This is successful."); + } + +}
