forked from eclipse-m2e/m2e-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Test-Case for transitive resolution of dependency
Reproducer for eclipse-m2e#1501
- Loading branch information
1 parent
3410597
commit 3382aa7
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
org.eclipse.m2e.jdt.tests/projects/transitiveDependencyResolution/project.a/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<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>foo.bar</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<artifactId>project.a</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.7.0</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
org.eclipse.m2e.jdt.tests/projects/transitiveDependencyResolution/project.b/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<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>foo.bar</groupId> | ||
<artifactId>project.b</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<!-- Depends on junit-jupiter-api 5.7 and must be listed first--> | ||
<groupId>foo.bar</groupId> | ||
<artifactId>project.a</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.8.0</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
11 changes: 11 additions & 0 deletions
11
...sts/projects/transitiveDependencyResolution/project.b/src/main/java/project/b/AClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package project.b; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
|
||
public class AClass { | ||
|
||
public void aMethod() { | ||
// Added in junit-juptier-api 5.8 | ||
Assertions.assertInstanceOf(String.class, ""); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...lipse.m2e.jdt.tests/src/org/eclipse/m2e/jdt/tests/TransitiveDependencyResolutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023-2023 Hannes Wellmann and others | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Hannes Wellmann - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.m2e.jdt.tests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IncrementalProjectBuilder; | ||
import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase; | ||
import org.junit.Test; | ||
|
||
public class TransitiveDependencyResolutionTest extends AbstractMavenProjectTestCase { | ||
|
||
@Test | ||
public void resolutionOfOlderDependencyVersionsAsTransitiveDependency() throws Exception { | ||
IProject projectA = importProject("projects/transitiveDependencyResolution/project.a/pom.xml"); | ||
IProject projectB = importProject("projects/transitiveDependencyResolution/project.b/pom.xml"); | ||
// Project-A depends on junit-jupiter-api:5.7 | ||
// Project-B depends on junit-jupiter-api:5.8 and Project-A | ||
// B also contains a class that references a method added to the Assertions | ||
// class in junit-jupiter-api 5.8. | ||
// The Assertions class itself already existed in 5.7 | ||
|
||
projectA.build(IncrementalProjectBuilder.FULL_BUILD, monitor); | ||
projectB.build(IncrementalProjectBuilder.FULL_BUILD, monitor); | ||
waitForJobsToComplete(); | ||
assertEquals("Project-A has errors", List.of(), findErrorMarkers(projectA)); | ||
assertEquals("Project-B has errors", List.of(), findErrorMarkers(projectB)); | ||
} | ||
|
||
} |