use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class MavenBndRepoTest method testPutRemoteSnapshotFileRepo.
public void testPutRemoteSnapshotFileRepo() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("snapshotUrl", remote.toURI().toString());
config(map);
File jar = IO.getFile("testresources/snapshot.jar");
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "remote;snapshot=1");
PutOptions put = new PutOptions();
put.context = context;
PutResult r = repo.put(new FileInputStream(jar), put);
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.pom");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-sources.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
File f = IO.getFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
String s = IO.collect(f);
assertTrue(s.contains("3.2.0-19700101.000000"));
}
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "remote;snapshot=10000");
PutOptions put = new PutOptions();
put.context = context;
PutResult r = repo.put(new FileInputStream(jar), put);
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.pom");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-sources.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000000-1-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2.pom.sha1");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2.pom.md5");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000010-2-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
File f = IO.getFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
String s = IO.collect(f);
assertTrue(s.contains("<value>3.2.0-19700101.000000-1</value>"));
assertTrue(s.contains("<value>3.2.0-19700101.000010-2</value>"));
}
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "remote;snapshot=20000");
PutOptions put = new PutOptions();
put.context = context;
PutResult r = repo.put(new FileInputStream(jar), put);
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000020-3.pom");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000020-3.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000020-3-sources.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-19700101.000020-3-javadoc.jar");
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
File f = IO.getFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/maven-metadata.xml");
String s = IO.collect(f);
assertTrue(s.contains("<value>3.2.0-19700101.000020-3</value>"));
}
}
use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class AgainstNexusTest method testRelease.
public void testRelease() throws Exception {
if (skip)
return;
config(null);
File r = IO.getFile("testresources/release.jar");
File s = IO.getFile("testresources/snapshot.jar");
PutOptions p = new PutOptions();
p.context = new Processor();
p.context.setProperty("-maven-release", "remote");
PutResult put = repo.put(new FileInputStream(s), p);
}
use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class MavenBndRepoTest method testPutLocalTwiceNoSnapshot.
public void testPutLocalTwiceNoSnapshot() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("releaseUrl", remote.toURI().toString());
config(map);
File jar = IO.getFile("testresources/release.jar");
PutResult put = repo.put(new FileInputStream(jar), null);
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0.pom");
put = repo.put(new FileInputStream(jar), null);
Requirement wc = ResourceUtils.createWildcardRequirement();
Collection<Capability> caps = repo.findProviders(Collections.singleton(wc)).get(wc);
Set<Resource> resources = ResourceUtils.getResources(caps);
assertEquals(2, resources.size());
IdentityCapability bc = ResourceUtils.getIdentityCapability(resources.iterator().next());
assertEquals("biz.aQute.bnd.maven", bc.osgi_identity());
}
use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class MavenBndRepoTest method testPutDefaultLocalSnapshotFileRepo.
public void testPutDefaultLocalSnapshotFileRepo() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("snapshotUrl", remote.toURI().toString());
config(map);
File jar = IO.getFile("testresources/snapshot.jar");
PutResult put = repo.put(new FileInputStream(jar), null);
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.jar");
assertIsFile(local, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0-SNAPSHOT/biz.aQute.bnd.maven-3.2.0-SNAPSHOT.pom");
String s = IO.collect(index);
// snapshots not added to index
assertFalse(s.contains("biz.aQute.bnd.maven"));
}
use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class FileRepoTest method testDownloadListenerCallback.
public void testDownloadListenerCallback() throws Exception {
try {
FileRepo repo = new FileRepo("tmp", tmp, true);
File srcBundle = IO.getFile("testresources/test.jar");
PutResult r = repo.put(IO.stream(IO.getFile("testresources/test.jar")), null);
assertNotNull(r);
assertNotNull(r.artifact);
// file repo, so should match
File f = new File(r.artifact);
SHA1 sha1 = SHA1.digest(srcBundle);
sha1.equals(SHA1.digest(f));
DownloadListener mock = Mockito.mock(DownloadListener.class);
f = repo.get("test", new Version("0"), null, mock);
Mockito.verify(mock).success(f);
Mockito.verifyNoMoreInteractions(mock);
Mockito.reset(mock);
f = repo.get("XXXXXXXXXXXXXXXXX", new Version("0"), null, mock);
assertNull(f);
Mockito.verifyZeroInteractions(mock);
} finally {
IO.delete(tmp);
}
}
Aggregations