Search in sources :

Example 6 with PutResult

use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.

the class TestMultipleLocalIndexGeneration method testDeployBundle.

public void testDeployBundle() throws Exception {
    PutResult r = repo.put(new BufferedInputStream(new FileInputStream("testdata/bundles/name.njbartlett.osgi.emf.minimal-2.6.1.jar")), new RepositoryPlugin.PutOptions());
    File deployedFile = new File(r.artifact);
    assertEquals(IO.getFile(outputDir, "name.njbartlett.osgi.emf.minimal/name.njbartlett.osgi.emf.minimal-2.6.1.jar").getAbsolutePath(), deployedFile.getAbsolutePath());
    File r5IndexFile = IO.getFile(outputDir, "index.xml.gz");
    assertTrue(r5IndexFile.exists());
    File obrIndexFile = IO.getFile(outputDir, "repository.xml");
    assertTrue(obrIndexFile.exists());
    AbstractIndexedRepo checkRepo;
    File[] files;
    checkRepo = createRepoForIndex(r5IndexFile);
    files = checkRepo.get("name.njbartlett.osgi.emf.minimal", null);
    assertNotNull(files);
    assertEquals(1, files.length);
    assertEquals(deployedFile.getAbsoluteFile(), files[0]);
    checkRepo = createRepoForIndex(obrIndexFile);
    files = checkRepo.get("name.njbartlett.osgi.emf.minimal", null);
    assertNotNull(files);
    assertEquals(1, files.length);
    assertEquals(deployedFile.getAbsoluteFile(), files[0]);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 7 with PutResult

use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.

the class TestLocalIndexGeneration method testDeployBundle.

public void testDeployBundle() throws Exception {
    PutResult r = repo.put(new BufferedInputStream(new FileInputStream("testdata/bundles/name.njbartlett.osgi.emf.minimal-2.6.1.jar")), new RepositoryPlugin.PutOptions());
    File deployedFile = new File(r.artifact);
    assertEquals(IO.getFile(outputDir, "name.njbartlett.osgi.emf.minimal/name.njbartlett.osgi.emf.minimal-2.6.1.jar").getAbsolutePath(), deployedFile.getAbsolutePath());
    File indexFile = IO.getFile(outputDir, "index.xml");
    assertTrue(indexFile.exists());
    File indexFileSha = IO.getFile(outputDir, "index.xml.sha");
    assertTrue(indexFileSha.exists());
    AbstractIndexedRepo repo2 = createRepoForIndex(indexFile);
    File[] files = repo2.get("name.njbartlett.osgi.emf.minimal", null);
    assertNotNull(files);
    assertEquals(1, files.length);
    assertEquals(deployedFile.getAbsoluteFile(), files[0]);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 8 with PutResult

use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.

the class TestLocalIndexGeneration method testUncompressedIndexFile.

public void testUncompressedIndexFile() throws Exception {
    repo = new LocalIndexedRepo();
    config = new HashMap<String, String>();
    config.put("local", outputDir.getAbsolutePath());
    config.put("type", "R5");
    config.put("pretty", "true");
    config.put("compressed", "false");
    repo.setProperties(config);
    repo.setReporter(reporter);
    PutResult r = repo.put(new BufferedInputStream(new FileInputStream("testdata/bundles/name.njbartlett.osgi.emf.minimal-2.6.1.jar")), new RepositoryPlugin.PutOptions());
    File deployedFile = new File(r.artifact);
    File compressedIndexFile = IO.getFile(outputDir, "index.xml.gz");
    assertFalse(compressedIndexFile.exists());
    File prettyIndexFile = IO.getFile(outputDir, "index.xml");
    assertTrue(prettyIndexFile.exists());
    try {
        GZIPInputStream gzip = new GZIPInputStream(new FileInputStream(prettyIndexFile));
        fail("expected opening gzip on index file would fail because it should be uncompressed");
    } catch (ZipException ze) {
    } finally {
        IO.delete(new File(r.artifact));
        IO.delete(prettyIndexFile);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) BufferedInputStream(java.io.BufferedInputStream) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) ZipException(java.util.zip.ZipException) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 9 with PutResult

use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.

the class MavenBndRepoTest method testPutRemoteSnapshot.

public void testPutRemoteSnapshot() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("releaseUrl", null);
    map.put("snapshotUrl", fnx.getBaseURI() + "/repo/");
    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.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>"));
    }
}
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 10 with PutResult

use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.

the class MavenBndRepoTest method testPutReleaseAndThenIndex.

public void testPutReleaseAndThenIndex() throws Exception {
    Workspace ws = Workspace.findWorkspace(IO.getFile("testdata/releasews"));
    Project p1 = ws.getProject("p1");
    Project indexProject = ws.getProject("index");
    Map<String, String> map = new HashMap<>();
    map.put("releaseUrl", remote.toURI().toString());
    config(map);
    repo.begin(indexProject);
    File jar = IO.getFile("testresources/release.jar");
    PutOptions po = new PutOptions();
    po.context = p1;
    PutResult put = repo.put(new FileInputStream(jar), po);
    File demoJar = IO.getFile("testresources/demo.jar");
    PutOptions indexPo = new PutOptions();
    indexPo.context = indexProject;
    put = repo.put(new FileInputStream(demoJar), indexPo);
    repo.end(indexProject);
    assertTrue(indexProject.check());
    assertTrue(IO.getFile(remote, "biz/aQute/bnd/demo/1.0.0/demo-1.0.0-index.xml").isFile());
}
Also used : Project(aQute.bnd.build.Project) HashMap(java.util.HashMap) File(java.io.File) PutResult(aQute.bnd.service.RepositoryPlugin.PutResult) PutOptions(aQute.bnd.service.RepositoryPlugin.PutOptions) FileInputStream(java.io.FileInputStream) Workspace(aQute.bnd.build.Workspace)

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