Skip to content

Commit

Permalink
[MNG-7228] Add IT that ensure nothing "leaks" into installed model (#273
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cstamas committed Jun 24, 2023
1 parent 411870e commit c289abe
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core-it-suite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ under the License.
<artifactId>junit-jupiter</artifactId>
<!-- NOTE: Use compile scope for transitivity. -->
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 org.apache.commons.io.FileUtils;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;

class MavenITmng7228LeakyModelTest extends AbstractMavenIntegrationTestCase {

protected MavenITmng7228LeakyModelTest() {
// broken: 4.0.0-alpha-3 - 4.0.0-alpha-6
super("[,4.0.0-alpha-3),(4.0.0-alpha-6,]");
}

@Test
void testLeakyModel() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7228-leaky-model");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setForkJvm(true);

verifier.addCliArgument("-e");
verifier.addCliArgument("-s");
verifier.addCliArgument(new File(testDir, "settings.xml").getAbsolutePath());
verifier.addCliArgument("-Pmanual-profile");

verifier.addCliArgument("install");

verifier.execute();

verifier.verifyErrorFreeLog();

String pom = FileUtils.readFileToString(
new File(verifier.getArtifactPath("org.apache.maven.its.mng7228", "test", "1.0.0-SNAPSHOT", "pom")));

assertThat(pom, containsString("projectProperty"));
assertThat(pom, not(containsString("activeProperty")));
assertThat(pom, not(containsString("manualProperty")));

assertThat(pom, containsString("project-repo"));
assertThat(pom, not(containsString("active-repo")));
assertThat(pom, not(containsString("manual-repo")));

assertThat(pom, containsString("project-plugin-repo"));
assertThat(pom, not(containsString("active-plugin-repo")));
assertThat(pom, not(containsString("manual-plugin-repo")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public TestSuiteOrdering() {
* the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well.
*/
suite.addTestSuite(MavenITmng7228LeakyModelTest.class);
suite.addTestSuite(MavenITmng7819FileLockingWithSnapshotsTest.class);
suite.addTestSuite(MavenITmng5600DependencyManagementImportExclusionsTest.class);
suite.addTestSuite(MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.class);
Expand Down
2 changes: 2 additions & 0 deletions core-it-suite/src/test/resources-filtered/bootstrap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ org.apache.maven.plugins:maven-resources-plugin:3.2.0
org.apache.maven.plugins:maven-resources-plugin:3.3.0
org.apache.maven.plugins:maven-site-plugin:${stubPluginVersion}
org.apache.maven.plugins:maven-site-plugin:3.9.1
org.apache.maven.plugins:maven-shade-plugin:3.5.0
org.apache.maven.plugins:maven-source-plugin:${stubPluginVersion}
org.apache.maven.plugins:maven-surefire-plugin:${stubPluginVersion}
org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5
Expand Down Expand Up @@ -167,4 +168,5 @@ org.ow2.asm:asm:4.1
org.ow2.asm:asm:6.2
org.ow2.asm:asm:7.2
org.slf4j:slf4j-api:1.6.1
org.slf4j:slf4j-api:1.7.36
org.sonatype.sisu:sisu-guice:3.1.0:jar:no_aop
76 changes: 76 additions & 0 deletions core-it-suite/src/test/resources/mng-7228-leaky-model/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.mng7228</groupId>
<artifactId>test</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>
<projectProperty>project</projectProperty>
</properties>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>

<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
<id>project-repo</id>
<url>http://localhost:1234</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
<id>project-plugin-repo</id>
<url>http://localhost:1234</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<shadedClassifierName />
</configuration>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
104 changes: 104 additions & 0 deletions core-it-suite/src/test/resources/mng-7228-leaky-model/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?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.
-->

<settings>
<profiles>
<profile>
<id>manual-profile</id>
<repositories>
<repository>
<id>manual-repo</id>
<url>http://localhost:1234</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>manual-plugin-repo</id>
<url>http://localhost:1234</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<manualProperty>settings</manualProperty>
</properties>
</profile>
<profile>
<id>active-profile</id>
<repositories>
<repository>
<id>active-repo</id>
<url>http://localhost:1234</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>active-plugin-repo</id>
<url>http://localhost:1234</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<activeProperty>settings</activeProperty>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>active-profile</activeProfile>
</activeProfiles>
</settings>

0 comments on commit c289abe

Please sign in to comment.