Search in sources :

Example 11 with PutResult

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>"));
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) File(java.io.File) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) PutOptions(aQute.bnd.service.RepositoryPlugin.PutOptions) FileInputStream(java.io.FileInputStream)

Example 12 with PutResult

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);
}
Also used : Processor(aQute.bnd.osgi.Processor) File(java.io.File) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) PutOptions(aQute.bnd.service.RepositoryPlugin.PutOptions) FileInputStream(java.io.FileInputStream)

Example 13 with PutResult

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());
}
Also used : Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) HashMap(java.util.HashMap) Resource(org.osgi.resource.Resource) File(java.io.File) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) FileInputStream(java.io.FileInputStream) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)

Example 14 with PutResult

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"));
}
Also used : HashMap(java.util.HashMap) File(java.io.File) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) FileInputStream(java.io.FileInputStream)

Example 15 with PutResult

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);
    }
}
Also used : SHA1(aQute.libg.cryptography.SHA1) DownloadListener(aQute.bnd.service.RepositoryPlugin.DownloadListener) Version(aQute.bnd.version.Version) FileRepo(aQute.lib.deployer.FileRepo) IO.getFile(aQute.lib.io.IO.getFile) File(java.io.File) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult)

Aggregations

PutResult (aQute.bnd.service.RepositoryPlugin.PutResult)18 File (java.io.File)17 FileInputStream (java.io.FileInputStream)13 BufferedInputStream (java.io.BufferedInputStream)8 PutOptions (aQute.bnd.service.RepositoryPlugin.PutOptions)7 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)6 HashMap (java.util.HashMap)6 Version (aQute.bnd.version.Version)4 Processor (aQute.bnd.osgi.Processor)3 IO.getFile (aQute.lib.io.IO.getFile)3 IOException (java.io.IOException)3 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)2 InputStream (java.io.InputStream)2 DownloadBlocker (aQute.bnd.build.DownloadBlocker)1 Project (aQute.bnd.build.Project)1 Workspace (aQute.bnd.build.Workspace)1 Jar (aQute.bnd.osgi.Jar)1 JarResource (aQute.bnd.osgi.JarResource)1 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)1 DownloadListener (aQute.bnd.service.RepositoryPlugin.DownloadListener)1