use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class DefaultRepositoryCacheManagerTest method testLatestIntegrationIsCachedPerResolver.
@Test
@Ignore
public void testLatestIntegrationIsCachedPerResolver() throws Exception {
// given a module org#module
ModuleId mi = new ModuleId("org", "module");
// and a latest.integration mrid/dd
ModuleRevisionId mridLatest = new ModuleRevisionId(mi, "trunk", "latest.integration");
DependencyDescriptor ddLatest = new DefaultDependencyDescriptor(mridLatest, false);
// and some random options
CacheMetadataOptions options = new CacheMetadataOptions().setCheckTTL(false);
// setup resolver1 to download the static content so we can call cacheModuleDescriptor
MockResolver resolver = new MockResolver();
resolver.setName("resolver1");
resolver.setSettings(ivy.getSettings());
ivy.getSettings().addResolver(resolver);
ResourceDownloader downloader = new ResourceDownloader() {
public void download(Artifact artifact, Resource resource, File dest) throws IOException {
String content = "<ivy-module version=\"2.0\"><info organisation=\"org\" module=\"module\" status=\"integration\" revision=\"1.1\" branch=\"trunk\"/></ivy-module>";
dest.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(dest);
PrintWriter pw = new PrintWriter(out);
pw.write(content);
pw.flush();
out.close();
}
};
ModuleDescriptorWriter writer = new ModuleDescriptorWriter() {
public void write(ResolvedResource originalMdResource, ModuleDescriptor md, File src, File dest) throws IOException {
XmlModuleDescriptorWriter.write(md, dest);
}
};
// latest.integration will resolve to 1.1 in resolver1
ModuleRevisionId mrid11 = new ModuleRevisionId(mi, "trunk", "1.1");
DefaultArtifact artifact11 = new DefaultArtifact(mrid11, new Date(), "module-1.1.ivy", "ivy", "ivy", true);
DependencyDescriptor dd11 = new DefaultDependencyDescriptor(mrid11, false);
BasicResource resource11 = new BasicResource("/module-1-1.ivy", true, 1, 0, true);
ResolvedResource mdRef11 = new ResolvedResource(resource11, "1.1");
// tell the cache about 1.1
ResolvedModuleRevision rmr11 = cacheManager.cacheModuleDescriptor(resolver, mdRef11, dd11, artifact11, downloader, options);
cacheManager.originalToCachedModuleDescriptor(resolver, mdRef11, artifact11, rmr11, writer);
// and use the new overload that passes in resolver name
cacheManager.saveResolvedRevision("resolver1", mridLatest, "1.1");
ResolvedModuleRevision rmrFromCache = cacheManager.findModuleInCache(ddLatest, mridLatest, options, "resolver1");
assertEquals(rmr11, rmrFromCache);
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class P2DescriptorTest method testResolveSource.
@Test
public void testResolveSource() throws Exception {
settings.setDefaultResolver("p2-sources");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy", "2.2.0.final_20100923230623");
ResolvedModuleRevision rmr = p2SourceResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);
DownloadReport report = p2SourceResolver.download(rmr.getDescriptor().getAllArtifacts(), new DownloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
for (int i = 0; i < 2; i++) {
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[i];
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
DownloadReport report2 = p2SourceResolver.download(new Artifact[] { artifact }, new DownloadOptions());
assertNotNull(report2);
assertEquals(1, report2.getArtifactsReports().length);
ar = report2.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class P2DescriptorTest method testResolvePacked.
@Test
public void testResolvePacked() throws Exception {
settings.setDefaultResolver("p2-with-packed");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit", "4.10.0.v4_10_0_v20120426-0900");
ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2WithPackedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
assertNotNull(ar.getUnpackedLocalFile());
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class P2DescriptorTest method testResolveNotZipped.
@Test
public void testResolveNotZipped() throws Exception {
settings.setDefaultResolver("p2-zipped");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.eclipse.e4.core.services", "1.0.0.v20120521-2346");
ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
assertNull(ar.getUnpackedLocalFile());
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project Saturn by vipshop.
the class IvyGetArtifact method getIvyfile.
private File getIvyfile(String org, String name, String rev, String[] confs, Set<Map<String, Object>> artifacts) throws IOException {
File ivyfile;
ivyfile = File.createTempFile("ivy", ".xml");
ivyfile.deleteOnExit();
DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(org, name + "-caller", "working"));
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(org, name, rev), false, false, true);
if (artifacts != null && !artifacts.isEmpty()) {
for (Map<String, Object> artifact : artifacts) {
String artifactName = (String) artifact.get("name");
String artifactType = (String) artifact.get("type");
String artifactExt = (String) artifact.get("ext");
URL artifactUrl = (URL) artifact.get("url");
Map<?, ?> extraAttributes = (Map<?, ?>) artifact.get("extraAttributes");
DefaultDependencyArtifactDescriptor dad = new DefaultDependencyArtifactDescriptor(dd, artifactName, artifactType, artifactExt, artifactUrl, extraAttributes);
dd.addDependencyArtifact("default", dad);
}
}
for (int i = 0; i < confs.length; i++) {
dd.addDependencyConfiguration("default", confs[i]);
}
md.addDependency(dd);
md.addExtraAttributeNamespace("m", "http://ant.apache.org/ivy/maven");
XmlModuleDescriptorWriter.write(md, ivyfile);
return ivyfile;
}
Aggregations