use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithComments.
@Test
public void testUpdateWithComments() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-with-comments.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, new BufferedOutputStream(buffer, 1024), getUpdateOptions("release", "mynewrev"));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
DependencyDescriptor[] dependencies = updatedMd.getDependencies();
assertNotNull(dependencies);
assertEquals(3, dependencies.length);
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testLatestWithDefault.
@Test
public void testLatestWithDefault() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
chain.setLatestStrategy(new LatestRevisionStrategy());
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", true, ModuleRevisionId.newInstance("org", "mod", "1"), new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest -> but default
MockResolver.buildMockResolver(settings, "3", true, ModuleRevisionId.newInstance("org", "mod", "2"), new GregorianCalendar(2005, 1, 25).getTime()), MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> should the one kept
MockResolver.buildMockResolver(settings, "6", true, ModuleRevisionId.newInstance("org", "mod", "3"), new GregorianCalendar(2005, 1, 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null) };
for (MockResolver resolver : resolvers) {
chain.add(resolver);
}
assertResolversSizeAndNames(chain, resolvers.length);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "latest.integration"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("5", rmr.getResolver().getName());
List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
for (MockResolver resolver : resolvers) {
assertEquals(ddAsList, resolver.askedDeps);
}
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testWithDefault.
@Test
public void testWithDefault() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
chain.setLatestStrategy(new LatestRevisionStrategy());
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest -> but default
MockResolver.buildMockResolver(settings, "3", false, null), MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> should be the one kept
MockResolver.buildMockResolver(settings, "6", false, null), MockResolver.buildMockResolver(settings, "7", false, null) };
for (MockResolver resolver : resolvers) {
chain.add(resolver);
}
assertResolversSizeAndNames(chain, resolvers.length);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "4"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("5", rmr.getResolver().getName());
List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
for (int i = 0; i < 5; i++) {
assertEquals(ddAsList, resolvers[i].askedDeps);
}
for (int i = 5; i < resolvers.length; i++) {
assertTrue(resolvers[i].askedDeps.isEmpty());
}
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class AbstractModuleDescriptorParserTester method getDependency.
protected DependencyDescriptor getDependency(DependencyDescriptor[] dependencies, String name) {
for (DependencyDescriptor dependency : dependencies) {
assertNotNull(dependency);
assertNotNull(dependency.getDependencyId());
if (name.equals(dependency.getDependencyId().getName())) {
return dependency;
}
}
return null;
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorParser method parseOtherPom.
private ResolvedModuleRevision parseOtherPom(ParserSettings ivySettings, ModuleRevisionId parentModRevID) throws ParseException {
DependencyDescriptor dd = new DefaultDependencyDescriptor(parentModRevID, true);
ResolveData data = IvyContext.getContext().getResolveData();
if (data == null) {
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
ResolveOptions options = new ResolveOptions();
options.setDownload(false);
data = new ResolveData(engine, options);
}
DependencyResolver resolver = ivySettings.getResolver(parentModRevID);
if (resolver == null) {
// TODO: Throw exception here?
return null;
}
dd = toSystem(dd, ivySettings.getContextNamespace());
return resolver.getDependency(dd, data);
}
Aggregations