forked from bndtools/bnd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bndtools#5964 from chrisrueger/fix-gav-in-repo-mac…
…ro-bndpomrepository BndPomRepository should support both bsn and gav like MavenBndRepository
- Loading branch information
Showing
6 changed files
with
198 additions
and
20 deletions.
There are no files selected for viewing
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
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
62 changes: 62 additions & 0 deletions
62
biz.aQute.repository/test/aQute/bnd/repository/maven/helpers/MavenRepoTestHelper.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,62 @@ | ||
package aQute.bnd.repository.maven.helpers; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.File; | ||
import java.util.SortedSet; | ||
|
||
import aQute.bnd.service.RepositoryPlugin; | ||
import aQute.bnd.version.Version; | ||
|
||
public class MavenRepoTestHelper { | ||
|
||
/** | ||
* This method is called by two maven repo tests to ensure that both repos | ||
* behave the same and can get a resource by bns and gav in case both are | ||
* available. | ||
* | ||
* @param repo | ||
* @throws Exception | ||
*/ | ||
public static void assertMavenReposGetViaBSNAndGAV(RepositoryPlugin repo) throws Exception { | ||
assertEquals(1, repo.list("org.apache.commons.cli") | ||
.size()); | ||
System.out.println(repo.list("org.apache.commons.cli")); | ||
System.out.println(repo.versions("org.apache.commons.cli")); | ||
|
||
File f12maven = repo.get("commons-cli:commons-cli", new Version("1.2.0"), null); | ||
File f12osgi = repo.get("org.apache.commons.cli", new Version("1.2.0"), null); | ||
|
||
assertTrue(f12maven.exists()); | ||
assertTrue(f12osgi.exists()); | ||
|
||
assertEquals("commons-cli-1.2.jar", f12maven.getName()); | ||
assertEquals(f12maven, f12osgi); | ||
|
||
// check if 1.2 instead of 1.2.0 works too | ||
File f12maven2DigitsVer = repo.get("commons-cli:commons-cli", new Version("1.2"), null); | ||
File f12osgi2DigitsVer = repo.get("org.apache.commons.cli", new Version("1.2"), null); | ||
|
||
assertTrue(f12maven2DigitsVer.exists()); | ||
assertTrue(f12osgi2DigitsVer.exists()); | ||
|
||
assertEquals("commons-cli-1.2.jar", f12maven2DigitsVer.getName()); | ||
assertEquals(f12maven2DigitsVer, f12osgi2DigitsVer); | ||
|
||
// version should accept both too | ||
SortedSet<Version> versionsMaven = repo.versions("commons-cli:commons-cli"); | ||
SortedSet<Version> versionsOsgi = repo.versions("org.apache.commons.cli"); | ||
|
||
assertNotNull(versionsMaven); | ||
assertNotNull(versionsOsgi); | ||
assertTrue(versionsMaven.stream() | ||
.anyMatch(v -> "1.2.0".equals(v.toString()))); | ||
assertTrue(versionsOsgi.stream() | ||
.anyMatch(v -> "1.2.0".equals(v.toString()))); | ||
|
||
|
||
} | ||
|
||
} |
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
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
20 changes: 20 additions & 0 deletions
20
biz.aQute.repository/testdata/pomrepo/simpleGetViaBSNAndGAV.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,20 @@ | ||
<?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>test</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |