Skip to content

Commit

Permalink
fail test showing gav is not working in BndPomRepo
Browse files Browse the repository at this point in the history
this PomRepositoryTest. testGetViaBSNAndGAV() will fail, which we try to fix in the next commit.

Signed-off-by: Christoph Rueger <[email protected]>
  • Loading branch information
chrisrueger committed Jan 11, 2024
1 parent 7c3e51f commit 39eca3c
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package aQute.bnd.repository.maven.helpers;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.File;

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);

assertEquals("commons-cli-1.2.jar", f12maven.getName());
assertEquals(f12maven, f12osgi);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import aQute.bnd.osgi.Jar;
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.repository.XMLResourceParser;
import aQute.bnd.repository.maven.helpers.MavenRepoTestHelper;
import aQute.bnd.repository.maven.provider.MavenBndRepoTest;
import aQute.bnd.service.RepositoryListenerPlugin;
import aQute.bnd.service.RepositoryPlugin;
import aQute.bnd.test.jupiter.InjectTemporaryDirectory;
Expand Down Expand Up @@ -267,6 +269,31 @@ public void testBndPomRepoFile() throws Exception {
}
}


/**
* Commons CLI 1.2 is in there as GAV & as BSN Note: This test should be
* kept in sync with {@link MavenBndRepoTest#testGetViaBSNAndGAV()}
*/
@Test
public void testGetViaBSNAndGAV() throws Exception {
try (BndPomRepository repo = new BndPomRepository()) {
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
repo.setRegistry(w);

Map<String, String> config = new HashMap<>();
config.put("pom", "testdata/pomrepo/simpleGetViaBSNAndGAV.xml");
config.put("transitive", "false");
config.put("snapshotUrl", "https://repo.maven.apache.org/maven2/");
config.put("releaseUrl", "https://repo.maven.apache.org/maven2/");
config.put("name", "test2");
repo.setProperties(config);

MavenRepoTestHelper.assertMavenReposGetViaBSNAndGAV(repo);
}

}

@Test
public void testBndPomRepoFileExistingParent() throws Exception {
try (BndPomRepository bpr = new BndPomRepository()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.resource.ResourceUtils;
import aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability;
import aQute.bnd.repository.maven.helpers.MavenRepoTestHelper;
import aQute.bnd.repository.maven.pom.provider.PomRepositoryTest;
import aQute.bnd.service.RepositoryPlugin.PutOptions;
import aQute.bnd.service.RepositoryPlugin.PutResult;
import aQute.bnd.service.maven.PomOptions;
Expand Down Expand Up @@ -619,24 +621,18 @@ public void testGetFileRepo() throws Exception {
assertTrue(file.isFile());
}

/*
* Commons CLI 1.2 is in there as GAV & as BSN
/**
* Commons CLI 1.2 is in there as GAV & as BSN Note: This test should be
* kept in sync with {@link PomRepositoryTest#testGetViaBSNAndGAV()}
*/
@Test
public void testGetViaBSNAndGAV() throws Exception {
config(null);

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);

assertEquals("commons-cli-1.2.jar", f12maven.getName());
assertEquals(f12maven, f12osgi);
MavenRepoTestHelper.assertMavenReposGetViaBSNAndGAV(repo);
}


@Test
public void testList() throws Exception {
config(null);
Expand Down
20 changes: 20 additions & 0 deletions biz.aQute.repository/testdata/pomrepo/simpleGetViaBSNAndGAV.xml
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>

0 comments on commit 39eca3c

Please sign in to comment.