use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class ResolveTest method testResolveWithRetainingArtifactNameAndExtraAttributes.
@Test
public void testResolveWithRetainingArtifactNameAndExtraAttributes() throws Exception {
((DefaultRepositoryCacheManager) ivy.getSettings().getDefaultRepositoryCacheManager()).setArtifactPattern(ivy.substitute("[module]/[originalname].[ext]"));
ResolveReport report = ivy.resolve(new File("test/repositories/2/mod15.4/ivy-1.1.xml"), getResolveOptions(new String[] { "default" }).setValidate(false));
assertNotNull(report);
Map<String, String> extra = new HashMap<>();
extra.put("extra", "foo");
ArtifactDownloadReport[] dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org15", "mod15.3", "1.1", extra));
assertNotNull(dReports);
assertEquals("number of downloaded artifacts not correct", 1, dReports.length);
Artifact artifact = dReports[0].getArtifact();
assertNotNull(artifact);
String cachePath = getArchivePathInCache(artifact);
assertTrue("artifact name has not been retained: " + cachePath, cachePath.endsWith("library.jar"));
dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org14", "mod14.1", "1.1"));
assertNotNull(dReports);
assertEquals("number of downloaded artifacts not correct", 1, dReports.length);
artifact = dReports[0].getArtifact();
assertNotNull(artifact);
cachePath = getArchivePathInCache(artifact);
assertTrue("artifact name has not been retained: " + cachePath, cachePath.endsWith("mod14.1-1.1.jar"));
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class ResolveTest method testResolveWithRetainingArtifactName.
@Test
public void testResolveWithRetainingArtifactName() throws Exception {
((DefaultRepositoryCacheManager) ivy.getSettings().getDefaultRepositoryCacheManager()).setArtifactPattern(ivy.substitute("[module]/[originalname].[ext]"));
ResolveReport report = ivy.resolve(new File("test/repositories/2/mod15.2/ivy-1.1.xml"), getResolveOptions(new String[] { "default" }));
assertNotNull(report);
ArtifactDownloadReport[] dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org15", "mod15.1", "1.1"));
assertNotNull(dReports);
assertEquals("number of downloaded artifacts not correct", 1, dReports.length);
Artifact artifact = dReports[0].getArtifact();
assertNotNull(artifact);
String cachePath = getArchivePathInCache(artifact);
assertTrue("artifact name has not been retained: " + cachePath, cachePath.endsWith("library.jar"));
dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org14", "mod14.1", "1.1"));
assertNotNull(dReports);
assertEquals("number of downloaded artifacts not correct", 1, dReports.length);
artifact = dReports[0].getArtifact();
assertNotNull(artifact);
cachePath = getArchivePathInCache(artifact);
assertTrue("artifact name has not been retained: " + cachePath, cachePath.endsWith("mod14.1-1.1.jar"));
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class ResolveTest method assertDoesntContainArtifact.
private void assertDoesntContainArtifact(String org, String module, String rev, String artName, String type, String ext, ConfigurationResolveReport conf) {
Artifact art = getArtifact(org, module, rev, artName, type, ext);
assertFalse("artifact " + art + " should NOT be part of " + conf.getConfiguration() + " from " + conf.getModuleDescriptor().getModuleRevisionId(), containsArtifact(art, conf.getDownloadedArtifactsReports()));
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class OBRResolverTest 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());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class OBRXMLWriterTest method testWriteWithSource.
@Test
public void testWriteWithSource() throws Exception {
List<BundleInfo> bundles = new ArrayList<>();
BundleInfo bundle = new BundleInfo(BUNDLE_1, BUNDLE_VERSION);
bundle.addArtifact(new BundleArtifact(false, new URI("file:///test.jar"), null));
bundle.addArtifact(new BundleArtifact(true, new URI("file:///test-sources.jar"), null));
bundles.add(bundle);
bundle = new BundleInfo(BUNDLE_2, BUNDLE_VERSION);
bundle.addArtifact(new BundleArtifact(false, new URI("file:///test2.jar"), null));
bundles.add(bundle);
new File("build/test-files").mkdirs();
File obrFile = new File("build/test-files/obr-sources.xml");
try (FileOutputStream out = new FileOutputStream(obrFile)) {
ContentHandler handler = OBRXMLWriter.newHandler(out, "UTF-8", true);
OBRXMLWriter.writeBundles(bundles, handler);
}
BundleRepoDescriptor repo;
try (FileInputStream in = new FileInputStream(obrFile)) {
repo = OBRXMLParser.parse(new URI("file:///test"), in);
}
assertEquals(2, CollectionUtils.toList(repo.getModules()).size());
ModuleDescriptorWrapper bundle1 = repo.findModule(BUNDLE_1, BUNDLE_VERSION);
assertNotNull(bundle1);
Artifact[] artifacts = bundle1.getModuleDescriptor().getAllArtifacts();
assertEquals(2, artifacts.length);
if (artifacts[0].getType().equals("jar")) {
assertEquals("source", artifacts[1].getType());
} else {
assertEquals("jar", artifacts[1].getType());
assertEquals("source", artifacts[0].getType());
}
ModuleDescriptorWrapper bundle2 = repo.findModule(BUNDLE_2, BUNDLE_VERSION);
assertNotNull(bundle2);
assertEquals(1, bundle2.getModuleDescriptor().getAllArtifacts().length);
}
Aggregations