use of org.apache.ivy.core.module.id.ModuleId in project ant-ivy by apache.
the class XmlModuleDescriptorWriterTest method testTransitiveAttributeForNonTransitiveConfs.
/**
* Test that the transitive attribute is written for non-transitive configurations.
*
* <code><conf ... transitive="false" ... /></code>
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a>
*/
@Test
public void testTransitiveAttributeForNonTransitiveConfs() throws Exception {
// Given a ModuleDescriptor with a non-transitive configuration
DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId("myorg", "myname"), "1.0"), "integration", new Date());
Configuration conf = new Configuration("conf", PUBLIC, "desc", null, false, null);
md.addConfiguration(conf);
// When the ModuleDescriptor is written
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
// Then the transitive attribute must be set to false
String output = FileUtil.readEntirely(dest);
String writtenConf = output.substring(output.indexOf("<configurations>") + 16, output.indexOf("</configurations>")).trim();
assertTrue("Transitive attribute not set to false: " + writtenConf, writtenConf.contains("transitive=\"false\""));
}
use of org.apache.ivy.core.module.id.ModuleId in project ant-ivy by apache.
the class XmlSettingsParserTest method testConflictManager.
@Test
public void testConflictManager() throws Exception {
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-conflict-manager.xml"));
assertEquals("latest-time", settings.getConflictManager(new ModuleId("apache", "ivyde")).getName());
assertEquals("all", settings.getConflictManager(new ModuleId("apache", "ant")).getName());
}
use of org.apache.ivy.core.module.id.ModuleId in project ant-ivy by apache.
the class XmlSettingsParserTest method testCacheTTLMatcherAttribute.
/**
* Test case for IVY-1495.
* <code><ttl></code> containing the <code>matcher</code> attribute,
* in an ivy settings file, must work as expected.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1495">IVY-1495</a>
*/
@Test
public void testCacheTTLMatcherAttribute() throws Exception {
final IvySettings settings = new IvySettings();
settings.setBaseDir(new File("test/base/dir"));
final XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-cache-ttl-matcher.xml"));
// verify ttl
final DefaultRepositoryCacheManager cacheManager = (DefaultRepositoryCacheManager) settings.getRepositoryCacheManager("foo");
assertNotNull("Missing cache manager 'foo'", cacheManager);
assertEquals("Unexpected default ttl on cache manager", 30000, cacheManager.getDefaultTTL());
final ModuleRevisionId module1 = new ModuleRevisionId(new ModuleId("foo", "bar"), "*");
final long module1SpecificTTL = cacheManager.getTTL(module1);
assertEquals("Unexpected ttl for module " + module1 + " on cache manager", 60000, module1SpecificTTL);
final ModuleRevisionId module2 = new ModuleRevisionId(new ModuleId("food", "*"), "1.2.4");
final long module2SpecificTTL = cacheManager.getTTL(module2);
assertEquals("Unexpected ttl for module " + module2 + " on cache manager", 60000, module2SpecificTTL);
}
use of org.apache.ivy.core.module.id.ModuleId 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.id.ModuleId in project lucene-solr by apache.
the class IvyNodeElementAdapter method findConflictsBeneathNode.
/**
* Derives configuration conflicts that exist between node and all of its descendant dependencies.
*/
private static void findConflictsBeneathNode(IvyNodeElement node) {
// Derive conflicts
Map<ModuleId, Collection<IvyNodeElement>> moduleRevisionMap = new HashMap<>();
IvyNodeElement[] deepDependencies = node.getDeepDependencies();
for (int i = 0; i < deepDependencies.length; i++) {
if (deepDependencies[i].isEvicted())
continue;
ModuleId moduleId = deepDependencies[i].getModuleRevisionId().getModuleId();
if (moduleRevisionMap.containsKey(moduleId)) {
Collection<IvyNodeElement> conflicts = moduleRevisionMap.get(moduleId);
conflicts.add(deepDependencies[i]);
for (Iterator<IvyNodeElement> iter = conflicts.iterator(); iter.hasNext(); ) {
IvyNodeElement conflict = iter.next();
conflict.setConflicts(conflicts);
}
} else {
List<IvyNodeElement> immutableMatchingSet = Arrays.asList(deepDependencies[i]);
moduleRevisionMap.put(moduleId, new HashSet<>(immutableMatchingSet));
}
}
}
Aggregations