Search in sources :

Example 16 with DownloadReport

use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.

the class AggregatedOSGiResolverTest method genericTestResolveDownload.

private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException {
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    DownloadReport report = resolver.download(new Artifact[] { artifact }, new DownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] { artifact }, new DownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DownloadOptions(org.apache.ivy.core.resolve.DownloadOptions) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Artifact(org.apache.ivy.core.module.descriptor.Artifact)

Example 17 with DownloadReport

use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.

the class FileSystemResolverTest method testChecksum.

@Test
public void testChecksum() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[artifact]-[revision].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[artifact]-[revision].[ext]");
    resolver.setChecksums("sha1, md5");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions());
    assertEquals(4, dr.getArtifactsReports(DownloadStatus.SUCCESSFUL).length);
    resolver.setChecksums("md5");
    mrid = ModuleRevisionId.newInstance("test", "badivycs", "1.0");
    rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNull(rmr);
    resolver.setChecksums("none");
    rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    dr = resolver.download(new Artifact[] { new DefaultArtifact(mrid, rmr.getPublicationDate(), mrid.getName(), "jar", "jar") }, getDownloadOptions());
    assertEquals(1, dr.getArtifactsReports(DownloadStatus.SUCCESSFUL).length);
    resolver.setChecksums("md5");
    mrid = ModuleRevisionId.newInstance("test", "badartcs", "1.0");
    rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    dr = resolver.download(new Artifact[] { new DefaultArtifact(mrid, rmr.getPublicationDate(), mrid.getName(), "jar", "jar") }, getDownloadOptions());
    assertEquals(1, dr.getArtifactsReports(DownloadStatus.FAILED).length);
    resolver.setChecksums("");
    rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    dr = resolver.download(new Artifact[] { new DefaultArtifact(mrid, rmr.getPublicationDate(), mrid.getName(), "jar", "jar") }, getDownloadOptions());
    assertEquals(1, dr.getArtifactsReports(DownloadStatus.SUCCESSFUL).length);
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 18 with DownloadReport

use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.

the class FileSystemResolverTest method testFixedRevision.

@Test
public void testFixedRevision() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());
    resolver.addIvyPattern(IVY_PATTERN);
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
    // test to ask to download
    DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar");
    DownloadReport report = resolver.download(new Artifact[] { artifact }, getDownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] { artifact }, getDownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) GregorianCalendar(java.util.GregorianCalendar) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Date(java.util.Date) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 19 with DownloadReport

use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.

the class FileSystemResolverTest method testDownloadWithUseOriginIsTrue.

@Test
public void testDownloadWithUseOriginIsTrue() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    ((DefaultRepositoryCacheManager) resolver.getRepositoryCacheManager()).setUseOrigin(true);
    assertEquals("test", resolver.getName());
    resolver.addIvyPattern(IVY_PATTERN);
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
    // test to ask to download
    DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar");
    DownloadReport report = resolver.download(new Artifact[] { artifact }, getDownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) GregorianCalendar(java.util.GregorianCalendar) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultRepositoryCacheManager(org.apache.ivy.core.cache.DefaultRepositoryCacheManager) Date(java.util.Date) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 20 with DownloadReport

use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.

the class IvyRepResolverTest method testIvyRepWithLocalURL.

@Test
public void testIvyRepWithLocalURL() throws Exception {
    IvyRepResolver resolver = new IvyRepResolver();
    String rootpath = new File("test/repositories/1").getAbsolutePath();
    resolver.setName("testLocal");
    resolver.setIvyroot("file:" + rootpath);
    resolver.setIvypattern("[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.setArtroot("file:" + rootpath);
    resolver.setArtpattern("[organisation]/[module]/jars/[artifact]-[revision].[ext]");
    resolver.setSettings(settings);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "mod1.1", "jar", "jar");
    DownloadReport report = resolver.download(new Artifact[] { artifact }, downloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] { artifact }, downloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) File(java.io.File) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Aggregations

DownloadReport (org.apache.ivy.core.report.DownloadReport)25 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)24 Artifact (org.apache.ivy.core.module.descriptor.Artifact)20 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)18 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)18 Test (org.junit.Test)16 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)15 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)12 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)10 Date (java.util.Date)6 File (java.io.File)5 GregorianCalendar (java.util.GregorianCalendar)5 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)2 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)2 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)2 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 ArtifactOrigin (org.apache.ivy.core.cache.ArtifactOrigin)1 CacheDownloadOptions (org.apache.ivy.core.cache.CacheDownloadOptions)1 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)1