use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testUseCache.
@Test
public void testUseCache() throws Exception {
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
// resolve dependency twice
chainToPutDefaultModuleInCache().getDependency(dd, data);
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", true, null) };
for (MockResolver resolver : resolvers) {
chain.add(resolver);
}
chain.getDependency(dd, data);
// should not have asked any dependency, should have hit the cache
assertEquals(Collections.emptyList(), resolvers[0].askedDeps);
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver.
/**
* Test case for IVY-207.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-207">IVY-207</a>
*/
@Test
public void testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver() throws Exception {
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
// 1 ---- we first do a first resolve which puts a default file in cache
chainToPutDefaultModuleInCache().getDependency(dd, data);
// 2 ---- now we ask to resolve dependencies with a chain in return first mode, in which the
// first resolver is not able to find the module, but the second is
ChainResolver chain = returnFirstChain();
chain.setCheckmodified(true);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertFalse(rmr.getDescriptor().isDefault());
assertEquals("2", rmr.getResolver().getName());
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class MirroredURLResolverTest method testFail.
@Test
public void testFail() throws Exception {
DependencyResolver resolver = settings.getResolver("fail");
assertNotNull(resolver);
assertTrue(resolver instanceof MirroredURLResolver);
MirroredURLResolver mirrored = (MirroredURLResolver) resolver;
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
assertNull(rmr);
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class PackagerResolverTest method testZipResourceInclusion.
@Test
public void testZipResourceInclusion() throws Exception {
Locale oldLocale = Locale.getDefault();
try {
// set the locale to UK as workaround for SUN bug 6240963
Locale.setDefault(Locale.UK);
// Create and configure resolver
PackagerResolver resolver = new PackagerResolver();
resolver.setSettings(settings);
String repoRoot = new File("test/repositories/IVY-1179/repo").toURI().toURL().toExternalForm();
resolver.addIvyPattern(repoRoot + "[organisation]/[module]/[revision]/ivy.xml");
resolver.setPackagerPattern(repoRoot + "[organisation]/[module]/[revision]/packager.xml");
resolver.setBuildRoot(builddir);
resolver.setResourceCache(cachedir);
resolver.setPreserveBuildDirectories(true);
resolver.setVerbose(true);
resolver.setProperty("packager.website.url", new File("test/repositories/IVY-1179/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "A", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "A", "jar", "jar");
resolver.download(new Artifact[] { artifact }, downloadOptions());
// assert that the file A.jar is extracted from the archive
File jar = new File(builddir, "org/A/1.0/artifacts/jars/A.jar");
assertTrue(jar.exists());
// assert that the file README is not extracted from the archive
File readme = new File(builddir, "org/A/1.0/extract/A-1.0/README");
assertFalse(readme.exists());
} finally {
Locale.setDefault(oldLocale);
}
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class PackagerResolverTest method testTarResourceInclusion.
@Test
public void testTarResourceInclusion() throws Exception {
Locale oldLocale = Locale.getDefault();
try {
// set the locale to UK as workaround for SUN bug 6240963
Locale.setDefault(Locale.UK);
// Create and configure resolver
PackagerResolver resolver = new PackagerResolver();
resolver.setSettings(settings);
String repoRoot = new File("test/repositories/IVY-1179/repo").toURI().toURL().toExternalForm();
resolver.addIvyPattern(repoRoot + "[organisation]/[module]/[revision]/ivy.xml");
resolver.setPackagerPattern(repoRoot + "[organisation]/[module]/[revision]/packager.xml");
resolver.setBuildRoot(builddir);
resolver.setResourceCache(cachedir);
resolver.setPreserveBuildDirectories(true);
resolver.setVerbose(true);
resolver.setProperty("packager.website.url", new File("test/repositories/IVY-1179/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "B", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "B", "jar", "jar");
resolver.download(new Artifact[] { artifact }, downloadOptions());
// assert that the file B.jar is extracted from the archive
File jar = new File(builddir, "org/B/1.0/artifacts/jars/B.jar");
assertTrue(jar.exists());
// assert that the file README is not extracted from the archive
File readme = new File(builddir, "org/B/1.0/extract/B-1.0/README");
assertFalse(readme.exists());
} finally {
Locale.setDefault(oldLocale);
}
}
Aggregations