Fix unit tests

This commit is contained in:
Guillaume Nodet 2024-05-29 14:34:01 +02:00
parent eb4a75bb07
commit 07c67c8de9
2 changed files with 48 additions and 33 deletions

View File

@ -1,5 +1,5 @@
<project>
<modelVersion>4.0.0</modelVersion>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tests.project</groupId>
<artifactId>duplicate-plugin-defs-merged</artifactId>
<version>1</version>
@ -8,6 +8,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<dependencies>
<dependency>
<groupId>group</groupId>
@ -24,25 +25,36 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>second</artifactId>
<version>1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>second</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
<profiles>
<profile>
<id>foo</id>
<activation><activeByDefault>true</activeByDefault></activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>second</artifactId>
<version>1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>second</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -412,7 +412,8 @@ public class DefaultModelValidatorTest extends TestCase {
}
public void testHardCodedSystemPath() throws Exception {
SimpleProblemCollector result = validateRaw("hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
SimpleProblemCollector result =
validateRaw("hard-coded-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 1);
@ -420,8 +421,7 @@ public class DefaultModelValidatorTest extends TestCase {
result.getWarnings().get(0),
"'dependencies.dependency.systemPath' for test:a:jar should use a variable instead of a hard-coded path");
SimpleProblemCollector result_31 =
validateRaw("hard-coded-system-path.xml");
SimpleProblemCollector result_31 = validateRaw("hard-coded-system-path.xml");
assertViolations(result_31, 0, 0, 3);
@ -445,7 +445,8 @@ public class DefaultModelValidatorTest extends TestCase {
}
public void testDuplicatePlugin30() throws Exception {
SimpleProblemCollector result = validateRaw("duplicate-plugin.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
SimpleProblemCollector result =
validateRaw("duplicate-plugin.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 4);
@ -478,7 +479,8 @@ public class DefaultModelValidatorTest extends TestCase {
}
public void testReservedRepositoryId30() throws Exception {
SimpleProblemCollector result = validate("reserved-repository-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
SimpleProblemCollector result =
validate("reserved-repository-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 4);
@ -497,8 +499,7 @@ public class DefaultModelValidatorTest extends TestCase {
assertContains(result.getErrors().get(0), "'repositories.repository.id'" + " must not be 'local'");
assertContains(result.getErrors().get(1), "'pluginRepositories.pluginRepository.id' must not be 'local'");
assertContains(result.getErrors().get(2), "'distributionManagement.repository.id' must not be 'local'");
assertContains(
result.getErrors().get(3), "'distributionManagement.snapshotRepository.id' must not be 'local'");
assertContains(result.getErrors().get(3), "'distributionManagement.snapshotRepository.id' must not be 'local'");
}
public void testMissingPluginDependencyGroupId() throws Exception {
@ -550,7 +551,8 @@ public class DefaultModelValidatorTest extends TestCase {
}
public void testBadSnapshotVersion30() throws Exception {
SimpleProblemCollector result = validate("bad-snapshot-version.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
SimpleProblemCollector result =
validate("bad-snapshot-version.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 1);
@ -566,7 +568,8 @@ public class DefaultModelValidatorTest extends TestCase {
}
public void testBadRepositoryId30() throws Exception {
SimpleProblemCollector result = validate("bad-repository-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
SimpleProblemCollector result =
validate("bad-repository-id.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 4);
@ -654,7 +657,8 @@ public class DefaultModelValidatorTest extends TestCase {
}
public void testSystemPathRefersToProjectBasedir() throws Exception {
SimpleProblemCollector result = validateRaw("basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
SimpleProblemCollector result =
validateRaw("basedir-system-path.xml", ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
assertViolations(result, 0, 0, 2);
@ -665,8 +669,7 @@ public class DefaultModelValidatorTest extends TestCase {
result.getWarnings().get(1),
"'dependencies.dependency.systemPath' for test:b:jar should not point at files within the project directory");
SimpleProblemCollector result_31 =
validateRaw("basedir-system-path.xml");
SimpleProblemCollector result_31 = validateRaw("basedir-system-path.xml");
assertViolations(result_31, 0, 0, 4);