1 6 package fr.jayasoft.ivy; 7 8 import java.io.File ; 9 import java.util.Arrays ; 10 import java.util.Date ; 11 import java.util.HashSet ; 12 import java.util.Iterator ; 13 import java.util.Set ; 14 15 import javax.xml.parsers.SAXParser ; 16 import javax.xml.parsers.SAXParserFactory ; 17 18 import junit.framework.TestCase; 19 20 import org.apache.tools.ant.Project; 21 import org.apache.tools.ant.taskdefs.Delete; 22 import org.xml.sax.SAXException ; 23 import org.xml.sax.helpers.DefaultHandler ; 24 25 import fr.jayasoft.ivy.circular.CircularDependencyException; 26 import fr.jayasoft.ivy.circular.ErrorCircularDependencyStrategy; 27 import fr.jayasoft.ivy.circular.IgnoreCircularDependencyStrategy; 28 import fr.jayasoft.ivy.circular.WarnCircularDependencyStrategy; 29 import fr.jayasoft.ivy.report.ArtifactDownloadReport; 30 import fr.jayasoft.ivy.report.ConfigurationResolveReport; 31 import fr.jayasoft.ivy.report.DownloadStatus; 32 import fr.jayasoft.ivy.report.ResolveReport; 33 import fr.jayasoft.ivy.report.XmlReportOutputter; 34 import fr.jayasoft.ivy.resolver.BasicResolver; 35 import fr.jayasoft.ivy.resolver.DualResolver; 36 import fr.jayasoft.ivy.resolver.FileSystemResolver; 37 import fr.jayasoft.ivy.util.FileUtil; 38 39 43 public class ResolveTest extends TestCase { 44 private final Ivy _ivy; 45 private File _cache; 46 47 public ResolveTest() throws Exception { 48 _ivy = new Ivy(); 49 _ivy.configure(new File ("test/repositories/ivyconf.xml")); 50 } 51 52 protected void setUp() throws Exception { 53 createCache(); 54 } 55 56 private void createCache() { 57 _cache = new File ("build/cache"); 58 _cache.mkdirs(); 59 } 60 61 protected void tearDown() throws Exception { 62 cleanCache(); 63 } 64 65 private void cleanCache() { 66 Delete del = new Delete(); 67 del.setProject(new Project()); 68 del.setDir(_cache); 69 del.execute(); 70 } 71 72 public void testResolveWithRetainingArtifactName() throws Exception { 73 _ivy.setCacheArtifactPattern(_ivy.substitute("[module]/[originalname].[ext]")); 74 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod15.2/ivy-1.1.xml").toURL(), 75 null, new String [] {"default"}, _cache, null, true); 76 assertNotNull(report); 77 78 ArtifactDownloadReport[] dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org15", "mod15.1", "1.1")); 79 assertNotNull(dReports); 80 assertEquals("number of downloaded artifacts not correct", 1, dReports.length); 81 82 Artifact artifact = dReports[0].getArtifact(); 83 assertNotNull(artifact); 84 85 String cachePath = _ivy.getArchivePathInCache(artifact); 86 assertTrue("artifact name has not been retained: " + cachePath, cachePath.endsWith("library.jar")); 87 88 dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org14", "mod14.1", "1.1")); 89 assertNotNull(dReports); 90 assertEquals("number of downloaded artifacts not correct", 1, dReports.length); 91 92 artifact = dReports[0].getArtifact(); 93 assertNotNull(artifact); 94 95 cachePath = _ivy.getArchivePathInCache(artifact); 96 assertTrue("artifact name has not been retained: " + cachePath, cachePath.endsWith("mod14.1-1.1.jar")); 97 } 98 99 public void testArtifactOrigin() throws Exception { 100 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 101 null, new String [] {"default"}, _cache, null, true); 102 assertNotNull(report); 103 104 ArtifactDownloadReport[] dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")); 105 assertNotNull(dReports); 106 assertEquals("number of downloaded artifacts not correct", 1, dReports.length); 107 108 Artifact artifact = dReports[0].getArtifact(); 109 assertNotNull(artifact); 110 111 String expectedLocation = new File ("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").getAbsolutePath(); 112 113 ArtifactOrigin reportOrigin = dReports[0].getArtifactOrigin(); 115 assertNotNull(reportOrigin); 116 assertEquals("isLocal for artifact not correct", true, reportOrigin.isLocal()); 117 assertEquals("location for artifact not correct", expectedLocation, reportOrigin.getLocation()); 118 119 ArtifactOrigin ivyOrigin = _ivy.getSavedArtifactOrigin(_cache, artifact); 121 assertNotNull(ivyOrigin); 122 assertEquals("isLocal for artifact not correct", true, ivyOrigin.isLocal()); 123 assertEquals("location for artifact not correct", expectedLocation, ivyOrigin.getLocation()); 124 125 report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 127 null, new String [] {"default"}, _cache, null, true); 128 assertNotNull(report); 129 130 dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")); 131 assertNotNull(dReports); 132 assertEquals("number of downloaded artifacts not correct", 1, dReports.length); 133 assertEquals("download status not correct", DownloadStatus.NO, dReports[0].getDownloadStatus()); 134 reportOrigin = dReports[0].getArtifactOrigin(); 135 assertNotNull(reportOrigin); 136 assertEquals("isLocal for artifact not correct", true, reportOrigin.isLocal()); 137 assertEquals("location for artifact not correct", expectedLocation, reportOrigin.getLocation()); 138 } 139 140 public void testUseOrigin() throws Exception { 141 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 142 null, new String [] {"default"}, _cache, null, true, false, true, true, null); 143 assertNotNull(report); 144 145 ArtifactDownloadReport[] dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")); 146 assertNotNull(dReports); 147 assertEquals("number of downloaded artifacts not correct.", 1, dReports.length); 148 assertEquals("download status not correct: should not download the artifact in useOrigin mode.", DownloadStatus.NO, dReports[0].getDownloadStatus()); 149 150 Artifact artifact = dReports[0].getArtifact(); 151 assertNotNull(artifact); 152 153 String expectedLocation = new File ("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").getAbsolutePath(); 154 155 ArtifactOrigin origin = _ivy.getSavedArtifactOrigin(_cache, artifact); 156 File artInCache = new File (_cache, _ivy.getArchivePathInCache(artifact, origin)); 157 assertFalse("should not download artifact in useOrigin mode.", artInCache.exists()); 158 assertEquals("location for artifact not correct.", expectedLocation, _ivy.getArchiveFileInCache(_cache, artifact).getAbsolutePath()); 159 } 160 161 public void testResolveSimple() throws Exception { 162 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 164 null, new String [] {"*"}, _cache, null, true); 165 assertNotNull(report); 166 ModuleDescriptor md = report.getModuleDescriptor(); 167 assertNotNull(md); 168 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); 169 assertEquals(mrid, md.getModuleRevisionId()); 170 171 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 172 173 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 175 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 176 } 177 178 public void testResolveBadStatus() throws Exception { 179 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.4/ivys/ivy-1.1.xml").toURL(), 181 null, new String [] {"*"}, _cache, null, true); 182 assertNotNull(report); 183 assertTrue(report.hasError()); 184 } 185 186 public void testResolveNoRevisionInPattern() throws Exception { 187 Ivy ivy = new Ivy(); 189 ivy.configure(new File ("test/repositories/norev/ivyconf.xml").toURL()); 190 ResolveReport report = ivy.resolve(new File ("test/repositories/norev/ivy.xml").toURL(), 191 null, new String [] {"*"}, _cache, null, true); 192 assertNotNull(report); 193 assertFalse(report.hasError()); 194 } 195 196 public void testResolveNoRevisionInDep() throws Exception { 197 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.4/ivys/ivy-1.2.xml").toURL(), 199 null, new String [] {"*"}, _cache, null, true); 200 assertNotNull(report); 201 assertTrue(report.hasError()); 202 } 203 204 public void testResolveNoRevisionNowhere() throws Exception { 205 Ivy ivy = new Ivy(); 208 ivy.configure(new File ("test/repositories/IVY-258/ivyconf.xml").toURL()); 209 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-258/ivy.xml").toURL(), 210 null, new String [] {"*"}, _cache, null, true); 211 assertFalse(report.hasError()); 212 213 ((BasicResolver)ivy.getResolver("myresolver")).setCheckconsistency(false); 214 report = ivy.resolve(new File ("test/repositories/IVY-258/ivy.xml").toURL(), 215 null, new String [] {"*"}, _cache, null, true); 216 assertFalse(report.hasError()); 217 } 218 219 public void testResolveRequiresIvyFile() throws Exception { 220 Ivy ivy = new Ivy(); 222 ivy.configure(new File ("test/repositories/ivyconf.xml")); 223 ((FileSystemResolver)ivy.getResolver("1")).setAllownomd(false); 224 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 225 null, new String [] {"*"}, _cache, null, true); 226 assertNotNull(report); 227 assertTrue(report.hasError()); 228 } 229 230 public void testResolveOtherConfiguration() throws Exception { 231 ResolveReport report = _ivy.resolve(ResolveTest.class.getResource("ivy-other.xml"), null, new String [] {"test"}, _cache, null, true); 232 233 assertNotNull(report); 234 assertFalse(report.hasError()); 235 236 assertEquals("Number of artifacts not correct", 1, report.getConfigurationReport("test").getArtifactsNumber()); 237 } 238 239 public void testResolveWithSlashes() throws Exception { 240 ResolveReport report = _ivy.resolve(ResolveTest.class.getResource("ivy-198.xml"), 243 null, new String [] {"*"}, _cache, null, true); 244 assertNotNull(report); 245 ModuleDescriptor md = report.getModuleDescriptor(); 246 assertNotNull(md); 247 ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg/mydep", "system/module", "1.0"); 248 assertEquals(mrid, md.getModuleRevisionId()); 249 250 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 251 252 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 254 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 255 256 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("yourorg/yourdep", "yoursys/yourmod", "1.0")).exists()); 257 assertTrue(_ivy.getArchiveFileInCache(_cache, "yourorg/yourdep", "yoursys/yourmod", "1.0", "yourmod", "jar", "jar").exists()); 258 } 259 260 public void testFromCache() throws Exception { 261 263 _ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 265 null, new String [] {"*"}, _cache, null, true); 266 267 Ivy ivy = new Ivy(); 269 ivy.configure(new File ("test/repositories/bugIVY-56/ivyconf.xml")); 270 271 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 272 null, new String [] {"*"}, _cache, null, true); 273 assertFalse(report.hasError()); 274 275 ModuleDescriptor md = report.getModuleDescriptor(); 276 277 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); 278 assertEquals(mrid, md.getModuleRevisionId()); 279 280 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 281 282 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 284 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 285 } 286 287 public void testFromCache2() throws Exception { 288 290 Ivy ivy = new Ivy(); 292 DualResolver resolver = new DualResolver(); 293 resolver.setName("dual"); 294 FileSystemResolver r = new FileSystemResolver(); 295 r.setName("1"); 296 r.addArtifactPattern("build/testCache2/[artifact]-[revision].[ext]"); 297 resolver.add(r); 298 r = new FileSystemResolver(); 299 r.setName("2"); 300 r.addArtifactPattern("build/testCache2/[artifact]-[revision].[ext]"); 301 resolver.add(r); 302 ivy.addResolver(resolver); 303 ivy.setDefaultResolver("dual"); 304 305 File art = new File ("build/testCache2/mod1.2-2.0.jar"); 307 FileUtil.copy(new File ("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), art, null); 308 309 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 311 null, new String [] {"*"}, _cache, null, true); 312 assertFalse(report.hasError()); 313 314 Delete del = new Delete(); 316 del.setProject(new Project()); 317 del.setDir(new File ("build/testCache2")); 318 del.execute(); 319 320 report = ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 322 null, new String [] {"*"}, _cache, null, true); 323 assertFalse(report.hasError()); 324 325 ModuleDescriptor md = report.getModuleDescriptor(); 326 327 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); 328 assertEquals(mrid, md.getModuleRevisionId()); 329 330 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 331 332 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 334 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 335 } 336 337 public void testFromCacheOnly() throws Exception { 338 Ivy ivy = new Ivy(); 339 ivy.configure(new File ("test/repositories/bugIVY-56/ivyconf.xml")); 340 341 346 File ivyfile = ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")); 348 File art = ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar"); 349 FileUtil.copy(ResolveTest.class.getResource("ivy-mod1.2.xml"), ivyfile, null); 350 FileUtil.copy(new File ("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), art, null); 351 352 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 353 null, new String [] {"*"}, _cache, null, true); 354 assertFalse(report.hasError()); 355 } 356 357 public void testChangeCacheLayout() throws Exception { 358 Ivy ivy = new Ivy(); 359 ivy.configure(new File ("test/repositories/ivyconf.xml")); 360 ivy.setCacheIvyPattern("[module]/ivy.xml"); 361 ivy.setCacheArtifactPattern("[artifact].[ext]"); 362 363 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 365 null, new String [] {"*"}, _cache, null, true); 366 assertNotNull(report); 367 ModuleDescriptor md = report.getModuleDescriptor(); 368 assertNotNull(md); 369 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); 370 assertEquals(mrid, md.getModuleRevisionId()); 371 372 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 373 374 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 376 assertTrue(new File (_cache, "mod1.2/ivy.xml").exists()); 377 assertTrue(ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 378 assertTrue(new File (_cache, "mod1.2.jar").exists()); 379 } 380 381 public void testResolveExtends() throws Exception { 382 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.1/ivys/ivy-0.3.xml").toURL(), 384 null, new String [] {"extension"}, _cache, null, true); 385 assertNotNull(report); 386 ModuleDescriptor md = report.getModuleDescriptor(); 387 assertNotNull(md); 388 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "0.3"); 389 assertEquals(mrid, md.getModuleRevisionId()); 390 391 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 392 393 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 395 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 396 } 397 398 public void testResolveExtended() throws Exception { 399 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.1/ivys/ivy-0.3.xml").toURL(), 401 null, new String [] {"default"}, _cache, null, true); 402 assertNotNull(report); 403 ModuleDescriptor md = report.getModuleDescriptor(); 404 assertNotNull(md); 405 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "0.3"); 406 assertEquals(mrid, md.getModuleRevisionId()); 407 408 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 409 410 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 412 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 413 } 414 415 public void testResolveExtendedAndExtends() throws Exception { 416 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.1/ivys/ivy-0.3.xml").toURL(), 418 null, new String [] {"default", "extension"}, _cache, null, true); 419 assertNotNull(report); 420 ModuleDescriptor md = report.getModuleDescriptor(); 421 assertNotNull(md); 422 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "0.3"); 423 assertEquals(mrid, md.getModuleRevisionId()); 424 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 425 assertNotNull(crr); 426 assertEquals(1, crr.getArtifactsNumber()); 427 crr = report.getConfigurationReport("extension"); 428 assertNotNull(crr); 429 assertEquals(1, crr.getArtifactsNumber()); 430 431 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 432 433 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 434 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 435 } 436 437 public void testResolveMultipleExtends() throws Exception { 438 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.2/ivys/ivy-0.3.xml").toURL(), 445 null, new String [] {"default", "extension"}, _cache, null, true); 446 assertNotNull(report); 447 assertFalse(report.hasError()); 448 ModuleDescriptor md = report.getModuleDescriptor(); 449 assertNotNull(md); 450 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.3"); 451 assertEquals(mrid, md.getModuleRevisionId()); 452 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 453 assertNotNull(crr); 454 assertEquals(2, crr.getArtifactsNumber()); 455 crr = report.getConfigurationReport("extension"); 456 assertNotNull(crr); 457 assertEquals(2, crr.getArtifactsNumber()); 458 459 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 460 461 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org6", "mod6.1", "0.4")).exists()); 462 assertTrue(_ivy.getArchiveFileInCache(_cache, "org6", "mod6.1", "0.4", "mod6.1", "jar", "jar").exists()); 463 464 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 465 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 466 } 467 468 public void testResolveMultipleExtendsAndConfs() throws Exception { 469 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod6.3/ivy-1.1.xml").toURL(), 478 null, new String [] {"*"}, _cache, null, true); 479 assertNotNull(report); 480 assertFalse(report.hasError()); 481 ModuleDescriptor md = report.getModuleDescriptor(); 482 assertNotNull(md); 483 ConfigurationResolveReport crr = report.getConfigurationReport("libraries"); 484 assertEquals(0, crr.getArtifactsNumber()); 485 486 crr = report.getConfigurationReport("run"); 487 assertEquals(2, crr.getArtifactsNumber()); 488 assertContainsArtifact("org6", "mod6.2", "2.0", "mod6.2", "jar", "jar", crr); 489 assertContainsArtifact("org6", "mod6.1", "2.0", "mod6.1", "jar", "jar", crr); 490 491 crr = report.getConfigurationReport("compile"); 492 assertEquals(2, crr.getArtifactsNumber()); 493 assertContainsArtifact("org6", "mod6.2", "2.0", "mod6.2", "jar", "jar", crr); 494 assertContainsArtifact("org6", "mod6.1", "2.0", "mod6.1", "jar", "jar", crr); 495 496 crr = report.getConfigurationReport("test"); 497 assertEquals(2, crr.getArtifactsNumber()); 498 assertContainsArtifact("org6", "mod6.1", "2.0", "mod6.1", "jar", "jar", crr); 499 assertContainsArtifact("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar", crr); 500 } 501 502 public void testResolveMultipleConfsWithLatest() throws Exception { 503 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.2/ivys/ivy-0.6.xml").toURL(), 511 null, new String [] {"compile", "run"}, _cache, null, true); 512 assertNotNull(report); 513 assertFalse(report.hasError()); 514 515 ConfigurationResolveReport crr = report.getConfigurationReport("compile"); 516 assertNotNull(crr); 517 assertEquals(2, crr.getArtifactsNumber()); 518 crr = report.getConfigurationReport("run"); 519 assertNotNull(crr); 520 assertEquals(1, crr.getArtifactsNumber()); 521 522 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists()); 523 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 524 } 525 526 public void testResolveMultipleConfsWithConflicts() throws Exception { 527 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.2/ivys/ivy-0.5.xml").toURL(), 538 null, new String [] {"compile", "run"}, _cache, null, true); 539 assertNotNull(report); 540 assertFalse(report.hasError()); 541 ModuleDescriptor md = report.getModuleDescriptor(); 542 assertNotNull(md); 543 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.5"); 544 assertEquals(mrid, md.getModuleRevisionId()); 545 ConfigurationResolveReport crr = report.getConfigurationReport("compile"); 546 assertNotNull(crr); 547 assertEquals(3, crr.getArtifactsNumber()); 548 crr = report.getConfigurationReport("run"); 549 assertNotNull(crr); 550 assertEquals(3, crr.getArtifactsNumber()); 551 552 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 553 554 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org6", "mod6.1", "0.5")).exists()); 555 assertTrue(_ivy.getArchiveFileInCache(_cache, "org6", "mod6.1", "0.5", "mod6.1", "jar", "jar").exists()); 556 557 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 558 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 559 560 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 561 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 562 563 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 564 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 565 } 566 567 public void testResolveMultipleExtends2() throws Exception { 568 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org6/mod6.2/ivys/ivy-0.4.xml").toURL(), 571 null, new String [] {"default", "extension"}, _cache, null, true); 572 assertNotNull(report); 573 assertFalse(report.hasError()); 574 ModuleDescriptor md = report.getModuleDescriptor(); 575 assertNotNull(md); 576 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.4"); 577 assertEquals(mrid, md.getModuleRevisionId()); 578 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 579 assertNotNull(crr); 580 assertEquals(2, crr.getArtifactsNumber()); 581 IvyNode node = crr.getDependency(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")); 582 assertNotNull(node); 583 assertFalse(node.isEvicted("default")); 584 crr = report.getConfigurationReport("extension"); 585 assertNotNull(crr); 586 assertEquals(2, crr.getArtifactsNumber()); 587 node = crr.getDependency(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")); 588 assertNotNull(node); 589 assertTrue(node.isEvicted("extension")); 590 node = crr.getDependency(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")); 591 assertNotNull(node); 592 assertFalse(node.isEvicted("extension")); 593 594 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 595 596 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org6", "mod6.1", "0.4")).exists()); 597 assertTrue(_ivy.getArchiveFileInCache(_cache, "org6", "mod6.1", "0.4", "mod6.1", "jar", "jar").exists()); 598 599 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 600 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 601 602 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 603 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 604 } 605 606 public void testResolveSeveralDefaultWithArtifacts() throws Exception { 607 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.6/ivys/ivy-1.0.3.xml").toURL(), 612 null, new String [] {"*"}, _cache, null, true); 613 assertFalse(report.hasError()); 614 615 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar").exists()); 617 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar").exists()); 618 } 619 620 public void testResolveSeveralDefaultWithArtifactsAndConfs() throws Exception { 621 Ivy ivy = new Ivy(); 623 ivy.configure(new File ("test/repositories/IVY-283/ivyconf.xml")); 624 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-283/ivy.xml").toURL(), 625 null, new String [] {"*"}, _cache, null, true); 626 assertFalse(report.hasError()); 627 628 ConfigurationResolveReport crr = report.getConfigurationReport("build"); 630 assertNotNull(crr); 631 assertEquals(3, crr.getDownloadReports(ModuleRevisionId.newInstance("medicel", "C", "1.0")).length); 632 633 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "C", "1.0", "lib_c_a", "jar", "jar").exists()); 634 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "C", "1.0", "lib_c_b", "jar", "jar").exists()); 635 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "C", "1.0", "lib_c_d", "jar", "jar").exists()); 636 } 637 638 public void testResolveSeveralDefaultWithArtifactsAndConfs2() throws Exception { 639 Ivy ivy = new Ivy(); 641 ivy.configure(new File ("test/repositories/IVY-283/ivyconf.xml")); 642 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-283/ivy-d.xml").toURL(), 643 null, new String [] {"*"}, _cache, null, true); 644 assertFalse(report.hasError()); 645 646 ConfigurationResolveReport crr = report.getConfigurationReport("build"); 648 assertNotNull(crr); 649 assertEquals(9, crr.getDownloadReports(ModuleRevisionId.newInstance("medicel", "module_a", "local")).length); 650 651 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_a", "jar", "jar").exists()); 652 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_b", "jar", "jar").exists()); 653 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_c", "jar", "jar").exists()); 654 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_d", "jar", "jar").exists()); 655 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_e", "jar", "jar").exists()); 656 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_f", "jar", "jar").exists()); 657 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_g", "jar", "jar").exists()); 658 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_h", "jar", "jar").exists()); 659 assertTrue(_ivy.getArchiveFileInCache(_cache, "medicel", "module_a", "local", "lib_a_i", "jar", "jar").exists()); 660 } 661 662 663 664 public void testResolveDefaultWithArtifactsConf1() throws Exception { 665 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.2/ivys/ivy-0.5.xml").toURL(), 667 null, new String [] {"myconf1"}, _cache, null, true); 668 assertNotNull(report); 669 ModuleDescriptor md = report.getModuleDescriptor(); 670 assertNotNull(md); 671 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.2", "0.5"); 672 assertEquals(mrid, md.getModuleRevisionId()); 673 674 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 675 676 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.3", "3.0")).exists()); 678 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar").exists()); 679 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar").exists()); 680 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); 681 } 682 683 public void testResolveDefaultWithArtifactsConf2() throws Exception { 684 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.2/ivys/ivy-0.5.xml").toURL(), 686 null, new String [] {"myconf2"}, _cache, null, true); 687 assertNotNull(report); 688 ModuleDescriptor md = report.getModuleDescriptor(); 689 assertNotNull(md); 690 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.2", "0.5"); 691 assertEquals(mrid, md.getModuleRevisionId()); 692 693 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 694 695 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.3", "3.0")).exists()); 696 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3-A", "jar", "jar").exists()); 697 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3-B", "jar", "jar").exists()); 698 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org1", "mod1.3", "3.0", "mod1.3", "jar", "jar").exists()); 699 } 700 701 public void testResolveWithDependencyArtifactsConf1() throws Exception { 702 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.4.xml").toURL(), 704 null, new String [] {"myconf1"}, _cache, null, true); 705 assertNotNull(report); 706 ModuleDescriptor md = report.getModuleDescriptor(); 707 assertNotNull(md); 708 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.4"); 709 assertEquals(mrid, md.getModuleRevisionId()); 710 711 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 712 713 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 714 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 715 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 716 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 717 } 718 719 public void testResolveWithDependencyArtifactsConf2() throws Exception { 720 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.4.xml").toURL(), 722 null, new String [] {"myconf2"}, _cache, null, true); 723 assertNotNull(report); 724 ModuleDescriptor md = report.getModuleDescriptor(); 725 assertNotNull(md); 726 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.4"); 727 assertEquals(mrid, md.getModuleRevisionId()); 728 729 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 730 731 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 732 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 733 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 734 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 735 } 736 737 public void testResolveWithDependencyArtifactsWithoutConf() throws Exception { 738 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.5.xml").toURL(), 740 null, new String [] {"*"}, _cache, null, true); 741 assertNotNull(report); 742 ModuleDescriptor md = report.getModuleDescriptor(); 743 assertNotNull(md); 744 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.5"); 745 assertEquals(mrid, md.getModuleRevisionId()); 746 747 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 748 749 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 750 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 751 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 752 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 753 } 754 755 public void testResolveWithExcludesArtifacts() throws Exception { 756 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.xml").toURL(), 758 null, new String [] {"*"}, _cache, null, true); 759 assertNotNull(report); 760 ModuleDescriptor md = report.getModuleDescriptor(); 761 assertNotNull(md); 762 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6"); 763 assertEquals(mrid, md.getModuleRevisionId()); 764 765 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 766 767 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 768 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 769 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 770 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 771 } 772 773 public void testResolveWithExcludesArtifacts2() throws Exception { 774 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.2.xml").toURL(), 776 null, new String [] {"*"}, _cache, null, true); 777 assertNotNull(report); 778 ModuleDescriptor md = report.getModuleDescriptor(); 779 assertNotNull(md); 780 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6.2"); 781 assertEquals(mrid, md.getModuleRevisionId()); 782 783 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 784 785 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 786 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 787 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 788 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 789 } 790 791 public void testResolveWithExcludesArtifacts3() throws Exception { 792 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.3.xml").toURL(), 794 null, new String [] {"*"}, _cache, null, true); 795 assertNotNull(report); 796 ModuleDescriptor md = report.getModuleDescriptor(); 797 assertNotNull(md); 798 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6.3"); 799 assertEquals(mrid, md.getModuleRevisionId()); 800 801 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 802 803 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 804 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 805 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 806 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 807 } 808 809 public void testResolveWithExcludesArtifacts4() throws Exception { 810 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.4.xml").toURL(), 812 null, new String [] {"*"}, _cache, null, true); 813 assertNotNull(report); 814 ModuleDescriptor md = report.getModuleDescriptor(); 815 assertNotNull(md); 816 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6.4"); 817 assertEquals(mrid, md.getModuleRevisionId()); 818 819 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 820 821 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 822 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 823 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 824 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 825 } 826 827 public void testResolveWithExcludesArtifacts5() throws Exception { 828 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.3/ivys/ivy-0.6.5.xml").toURL(), 830 null, new String [] {"*"}, _cache, null, true); 831 assertNotNull(report); 832 ModuleDescriptor md = report.getModuleDescriptor(); 833 assertNotNull(md); 834 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.3", "0.6.5"); 835 assertEquals(mrid, md.getModuleRevisionId()); 836 837 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 838 839 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 840 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 841 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 842 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "mod2.1", "jar", "jar").exists()); 843 } 844 845 public void testResolveTransitiveDependencies() throws Exception { 846 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.xml").toURL(), 848 null, new String [] {"*"}, _cache, null, true); 849 assertNotNull(report); 850 ModuleDescriptor md = report.getModuleDescriptor(); 851 assertNotNull(md); 852 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.3"); 853 assertEquals(mrid, md.getModuleRevisionId()); 854 855 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 856 857 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 859 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 860 861 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 862 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 863 } 864 865 public void testResolveTransitiveDisabled() throws Exception { 866 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.xml").toURL(), 868 null, new String [] {"*"}, _cache, null, true, false, false, null); 869 assertNotNull(report); 870 ModuleDescriptor md = report.getModuleDescriptor(); 871 assertNotNull(md); 872 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.3"); 873 assertEquals(mrid, md.getModuleRevisionId()); 874 875 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 876 877 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 879 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 880 881 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 882 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 883 } 884 885 public void testDependenciesOrder() throws Exception { 886 ResolveReport report = _ivy.resolve(ResolveTest.class.getResource("ivy-225.xml"), 887 null, new String [] {"default"}, _cache, null, true); 888 889 Set revisions = report.getConfigurationReport("default").getModuleRevisionIds(); 890 assertTrue("number of revisions is not correct", revisions.size() >= 3); 891 892 Iterator it = revisions.iterator(); 894 ModuleRevisionId revId1 = (ModuleRevisionId) it.next(); 895 assertEquals("mod1.2", revId1.getName()); 896 assertEquals("1.1", revId1.getRevision()); 897 898 ModuleRevisionId revId2 = (ModuleRevisionId) it.next(); 899 assertEquals("mod3.2", revId2.getName()); 900 assertEquals("1.4", revId2.getRevision()); 901 902 ModuleRevisionId revId3 = (ModuleRevisionId) it.next(); 903 assertEquals("mod5.1", revId3.getName()); 904 assertEquals("4.2", revId3.getRevision()); 905 } 906 907 public void testDisableTransitivityPerConfiguration() throws Exception { 908 911 _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.1.xml").toURL(), 913 null, new String [] {"compile"}, _cache, null, true); 914 915 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 917 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 918 919 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 920 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 921 922 _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.1.xml").toURL(), 924 null, new String [] {"runtime"}, _cache, null, true); 925 926 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 928 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 929 930 ResolveReport r = _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.1.xml").toURL(), 932 null, new String [] {"runtime", "compile"}, _cache, null, true); 933 assertFalse(r.hasError()); 934 assertEquals(1, r.getConfigurationReport("compile").getArtifactsNumber()); 935 assertEquals(2, r.getConfigurationReport("runtime").getArtifactsNumber()); 936 } 937 938 public void testDisableTransitivityPerConfiguration2() throws Exception { 939 943 _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.2.xml").toURL(), 945 null, new String [] {"compile"}, _cache, null, true); 946 947 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 949 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 950 951 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 952 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 953 954 _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.2.xml").toURL(), 956 null, new String [] {"runtime"}, _cache, null, true); 957 958 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 960 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 961 962 ResolveReport r = _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.2.xml").toURL(), 964 null, new String [] {"runtime", "compile"}, _cache, null, true); 965 assertFalse(r.hasError()); 966 assertEquals(1, r.getConfigurationReport("compile").getArtifactsNumber()); 967 assertEquals(2, r.getConfigurationReport("runtime").getArtifactsNumber()); 968 } 969 970 public void testDisableTransitivityPerConfiguration3() throws Exception { 971 975 _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.3.xml").toURL(), 977 null, new String [] {"compile"}, _cache, null, true); 978 979 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 981 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 982 983 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 984 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 985 986 _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.3.xml").toURL(), 988 null, new String [] {"runtime"}, _cache, null, true); 989 990 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 992 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 993 994 ResolveReport r = _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.3.xml").toURL(), 996 null, new String [] {"compile", "runtime"}, _cache, null, true); 997 assertFalse(r.hasError()); 998 assertEquals(1, r.getConfigurationReport("compile").getArtifactsNumber()); 999 assertEquals(2, r.getConfigurationReport("runtime").getArtifactsNumber()); 1000 } 1001 1002 public void testDisableTransitivityPerConfiguration4() throws Exception { 1003 1009 ResolveReport r = _ivy.resolve(new File ("test/repositories/1/org2/mod2.2/ivys/ivy-0.6.xml").toURL(), 1010 null, new String [] {"*"}, _cache, null, true); 1011 assertFalse(r.hasError()); 1012 1013 assertEquals(new HashSet (Arrays.asList(new ModuleRevisionId[] { 1015 ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2"), 1016 ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 1017 ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), 1018 })), r.getConfigurationReport("A").getModuleRevisionIds()); 1019 1020 assertEquals(new HashSet (Arrays.asList(new ModuleRevisionId[] { 1022 ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2"), 1023 ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 1024 })), r.getConfigurationReport("B").getModuleRevisionIds()); 1025 1026 assertEquals(new HashSet (Arrays.asList(new ModuleRevisionId[] { 1028 ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2"), 1029 })), r.getConfigurationReport("compile").getModuleRevisionIds()); 1030 } 1031 1032 public void testDisableTransitivityPerConfiguration5() throws Exception { 1033 1041 ResolveReport r = _ivy.resolve(new File ("test/repositories/1/org2/mod2.2/ivys/ivy-0.7.xml").toURL(), 1042 null, new String [] {"A","B","compile"}, _cache, null, true); 1043 assertFalse(r.hasError()); 1044 1045 assertEquals(new HashSet (Arrays.asList(new ModuleRevisionId[] { 1047 ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2"), 1048 ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 1049 ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), 1050 })), r.getConfigurationReport("A").getModuleRevisionIds()); 1051 1052 assertEquals(new HashSet (Arrays.asList(new ModuleRevisionId[] { 1054 ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2"), 1055 ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 1056 })), r.getConfigurationReport("B").getModuleRevisionIds()); 1057 1058 assertEquals(new HashSet (Arrays.asList(new ModuleRevisionId[] { 1060 ModuleRevisionId.newInstance("org2", "mod2.1", "0.3.2"), 1061 ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 1062 })), r.getConfigurationReport("compile").getModuleRevisionIds()); 1063 } 1064 1065 public void testResolveDiamond() throws Exception { 1066 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.0.xml").toURL(), 1070 null, new String [] {"*"}, _cache, null, true); 1071 assertNotNull(report); 1072 ModuleDescriptor md = report.getModuleDescriptor(); 1073 assertNotNull(md); 1074 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.0"); 1075 assertEquals(mrid, md.getModuleRevisionId()); 1076 1077 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1078 1079 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 1081 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 1082 1083 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1084 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1085 1086 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.0")).exists()); 1087 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.0", "mod3.1", "jar", "jar").exists()); 1088 } 1089 1090 public void testResolveConflict() throws Exception { 1091 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.1.xml").toURL(), 1095 null, new String [] {"*"}, _cache, null, true); 1096 assertNotNull(report); 1097 ModuleDescriptor md = report.getModuleDescriptor(); 1098 assertNotNull(md); 1099 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.1"); 1100 assertEquals(mrid, md.getModuleRevisionId()); 1101 1102 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1103 1104 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1106 assertNotNull(crr); 1107 assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).length); 1108 assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).length); 1109 1110 File r = new File (_cache, XmlReportOutputter.getReportFileName(mrid.getModuleId(), "default")); 1111 assertTrue(r.exists()); 1112 final boolean[] found = new boolean[] {false}; 1113 SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); 1114 saxParser.parse(r, new DefaultHandler () { 1115 public void startElement(String uri,String localName,String qName,org.xml.sax.Attributes attributes) throws SAXException { 1116 if ("revision".equals(qName) && "2.0".equals(attributes.getValue("name"))) { 1117 found[0] = true; 1118 } 1119 } 1120 }); 1121 assertTrue(found[0]); 1123 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 1124 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 1125 1126 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.1")).exists()); 1127 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.1", "mod3.1", "jar", "jar").exists()); 1128 1129 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1130 1131 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1132 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1133 } 1134 1135 public void testResolveConflict2() throws Exception { 1136 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.14.xml").toURL(), 1141 null, new String [] {"*"}, _cache, null, true); 1142 1143 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1145 assertNotNull(crr); 1146 assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).length); 1147 assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).length); 1148 1149 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.14"); 1150 File r = new File (_cache, XmlReportOutputter.getReportFileName(mrid.getModuleId(), "default")); 1151 assertTrue(r.exists()); 1152 final boolean[] found = new boolean[] {false}; 1153 SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); 1154 saxParser.parse(r, new DefaultHandler () { 1155 public void startElement(String uri,String localName,String qName,org.xml.sax.Attributes attributes) throws SAXException { 1156 if ("revision".equals(qName) && "2.0".equals(attributes.getValue("name"))) { 1157 found[0] = true; 1158 } 1159 } 1160 }); 1161 assertTrue(found[0]); 1163 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 1164 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 1165 1166 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.1")).exists()); 1167 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.1", "mod3.1", "jar", "jar").exists()); 1168 1169 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1170 1171 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1172 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1173 } 1174 1175 public void testResolveConflict3() throws Exception { 1176 Ivy ivy = new Ivy(); 1181 ivy.configure(new File ("test/repositories/IVY-264/ivyconf.xml")); 1182 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-264/ivy.xml").toURL(), 1183 null, new String [] {"*"}, _cache, null, true); 1184 assertFalse(report.hasError()); 1185 1186 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1188 assertNotNull(crr); 1189 assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("myorg", "commons-lang", "1.0.1")).length); 1190 assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("myorg", "commons-lang", "2.0")).length); 1191 1192 assertFalse(_ivy.getArchiveFileInCache(_cache, "myorg", "commons-lang", "1.0.1", "commons-lang", "jar", "jar").exists()); 1193 1194 assertTrue(_ivy.getArchiveFileInCache(_cache, "myorg", "commons-lang", "2.0", "commons-lang", "jar", "jar").exists()); 1195 } 1196 1197 public void testTransitiveEviction() throws Exception { 1198 1202 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod7.3/ivy-1.0.xml").toURL(), 1203 null, new String [] {"*"}, _cache, null, true); 1204 assertNotNull(report); 1205 ModuleDescriptor md = report.getModuleDescriptor(); 1206 assertNotNull(md); 1207 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org7", "mod7.3", "1.0"); 1208 assertEquals(mrid, md.getModuleRevisionId()); 1209 1210 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1211 1212 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org7", "mod7.2", "1.0")).exists()); 1214 assertTrue(_ivy.getArchiveFileInCache(_cache, "org7", "mod7.2", "1.0", "mod7.2", "jar", "jar").exists()); 1215 1216 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org7", "mod7.1", "2.0")).exists()); 1217 assertTrue(_ivy.getArchiveFileInCache(_cache, "org7", "mod7.1", "2.0", "mod7.1", "jar", "jar").exists()); 1218 1219 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org7", "mod7.1", "1.0", "mod7.1", "jar", "jar").exists()); 1220 1221 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1222 } 1223 1224 public void testTransitiveEviction2() throws Exception { 1225 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.13.xml").toURL(), 1231 null, new String [] {"*"}, _cache, null, true); 1232 assertNotNull(report); 1233 1234 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1236 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1237 1238 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1239 } 1240 1241 public void testResolveConflictInConf() throws Exception { 1242 1244 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.1/ivys/ivy-0.4.xml").toURL(), 1247 null, new String [] {"*"}, _cache, null, true); 1248 assertNotNull(report); 1249 ModuleDescriptor md = report.getModuleDescriptor(); 1250 assertNotNull(md); 1251 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.1", "0.4"); 1252 assertEquals(mrid, md.getModuleRevisionId()); 1253 1254 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1255 1256 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 1258 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 1259 1260 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1261 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1262 1263 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1264 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1265 } 1266 1267 public void testEvictWithConf() throws Exception { 1268 1270 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod6.1/ivy-1.0.xml").toURL(), 1276 null, new String [] {"*"}, _cache, null, true); 1277 assertNotNull(report); 1278 ModuleDescriptor md = report.getModuleDescriptor(); 1279 assertNotNull(md); 1280 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "1.0"); 1281 assertEquals(mrid, md.getModuleRevisionId()); 1282 1283 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1284 1285 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).exists()); 1287 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51A", "jar", "jar").exists()); 1288 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51B", "jar", "jar").exists()); 1289 1290 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.2", "1.0")).exists()); 1291 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.2", "1.0", "mod5.2", "jar", "jar").exists()); 1292 1293 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1294 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1295 1296 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.0")).exists()); 1298 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 1299 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 1300 } 1301 1302 public void testEvictWithConf2() throws Exception { 1303 1307 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod6.1/ivy-1.1.xml").toURL(), 1313 null, new String [] {"*"}, _cache, null, true); 1314 assertNotNull(report); 1315 ModuleDescriptor md = report.getModuleDescriptor(); 1316 assertNotNull(md); 1317 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "1.1"); 1318 assertEquals(mrid, md.getModuleRevisionId()); 1319 1320 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1321 1322 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).exists()); 1324 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51A", "jar", "jar").exists()); 1325 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51B", "jar", "jar").exists()); 1326 1327 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.2", "1.0")).exists()); 1328 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.2", "1.0", "mod5.2", "jar", "jar").exists()); 1329 1330 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1331 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1332 1333 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 1335 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 1336 } 1337 1338 public void testEvictWithConfInMultiConf() throws Exception { 1339 1342 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod6.1/ivy-1.2.xml").toURL(), 1348 null, new String [] {"*"}, _cache, null, true); 1349 assertNotNull(report); 1350 ModuleDescriptor md = report.getModuleDescriptor(); 1351 assertNotNull(md); 1352 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "1.2"); 1353 assertEquals(mrid, md.getModuleRevisionId()); 1354 1355 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1356 1357 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).exists()); 1359 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51A", "jar", "jar").exists()); 1360 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51B", "jar", "jar").exists()); 1361 1362 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.2", "1.0")).exists()); 1363 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.2", "1.0", "mod5.2", "jar", "jar").exists()); 1364 1365 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1366 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1367 1368 ConfigurationResolveReport crr = report.getConfigurationReport("A"); 1370 assertNotNull(crr); 1371 assertEquals(2, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length); 1372 1373 crr = report.getConfigurationReport("B"); 1374 assertNotNull(crr); 1375 assertEquals(2, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length); 1376 1377 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 1379 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 1380 } 1381 1382 public void testEvictWithConfInMultiConf2() throws Exception { 1383 1387 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod6.1/ivy-1.3.xml").toURL(), 1396 null, new String [] {"*"}, _cache, null, true); 1397 assertNotNull(report); 1398 ModuleDescriptor md = report.getModuleDescriptor(); 1399 assertNotNull(md); 1400 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "1.3"); 1401 assertEquals(mrid, md.getModuleRevisionId()); 1402 1403 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1404 1405 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).exists()); 1407 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51A", "jar", "jar").exists()); 1408 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.2", "art51B", "jar", "jar").exists()); 1409 1410 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.0")).exists()); 1411 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 1412 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 1413 1414 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.2", "1.0")).exists()); 1415 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.2", "1.0", "mod5.2", "jar", "jar").exists()); 1416 1417 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1418 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1419 1420 ConfigurationResolveReport crr = report.getConfigurationReport("A"); 1422 assertNotNull(crr); 1423 assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length); 1424 1425 crr = report.getConfigurationReport("B"); 1426 assertNotNull(crr); 1427 assertEquals(2, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length); 1428 } 1429 1430 public void testResolveForce() throws Exception { 1431 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.2.xml").toURL(), 1435 null, new String [] {"*"}, _cache, null, true); 1436 assertNotNull(report); 1437 ModuleDescriptor md = report.getModuleDescriptor(); 1438 assertNotNull(md); 1439 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.2"); 1440 assertEquals(mrid, md.getModuleRevisionId()); 1441 1442 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1443 1444 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.1")).exists()); 1446 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.1", "mod3.1", "jar", "jar").exists()); 1447 1448 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1449 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1450 1451 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1452 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1453 } 1454 1455 public void testResolveForceAfterConflictSolved() throws Exception { 1456 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.9.xml").toURL(), 1462 null, new String [] {"*"}, _cache, null, true); 1463 assertNotNull(report); 1464 ModuleDescriptor md = report.getModuleDescriptor(); 1465 assertNotNull(md); 1466 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.9"); 1467 assertEquals(mrid, md.getModuleRevisionId()); 1468 1469 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1470 1471 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1473 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1474 1475 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1476 } 1477 1478 public void testResolveForceAfterDependencyExist() throws Exception { 1479 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.10.xml").toURL(), 1484 null, new String [] {"*"}, _cache, null, true); 1485 assertNotNull(report); 1486 1487 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1489 1490 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1491 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1492 } 1493 1494 public void testResolveForceInDepOnly() throws Exception { 1495 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.11.xml").toURL(), 1503 null, new String [] {"*"}, _cache, null, true); 1504 assertNotNull(report); 1505 1506 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1508 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1509 1510 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1511 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "1.0", "mod1.2", "jar", "jar").exists()); 1512 } 1513 1514 public void testResolveForceInDepOnly2() throws Exception { 1515 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.12.xml").toURL(), 1524 null, new String [] {"*"}, _cache, null, true); 1525 assertNotNull(report); 1526 1527 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1529 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1530 1531 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1532 } 1533 1534 public void testResolveForceWithDynamicRevisions() throws Exception { 1535 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.5.xml").toURL(), 1539 null, new String [] {"*"}, _cache, null, true); 1540 assertNotNull(report); 1541 ModuleDescriptor md = report.getModuleDescriptor(); 1542 assertNotNull(md); 1543 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.5"); 1544 assertEquals(mrid, md.getModuleRevisionId()); 1545 1546 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1547 1548 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.2")).exists()); 1550 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.2", "mod3.1", "jar", "jar").exists()); 1551 1552 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "1.1")).exists()); 1553 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "1.1", "mod1.2", "jar", "jar").exists()); 1554 1555 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists()); 1556 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 1557 } 1558 1559 public void testResolveForceWithDynamicRevisionsAndSeveralConfs() throws Exception { 1560 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.6.xml").toURL(), 1564 null, new String [] {"*"}, _cache, null, true); 1565 assertNotNull(report); 1566 ModuleDescriptor md = report.getModuleDescriptor(); 1567 assertNotNull(md); 1568 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.6"); 1569 assertEquals(mrid, md.getModuleRevisionId()); 1570 1571 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1572 1573 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.2")).exists()); 1575 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.2", "mod3.1", "jar", "jar").exists()); 1576 1577 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "1.1")).exists()); 1578 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "1.1", "mod1.2", "jar", "jar").exists()); 1579 1580 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists()); 1581 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 1582 } 1583 1584 public void testResolveForceWithDynamicRevisionsAndSeveralConfs2() throws Exception { 1585 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod4.1/ivy-4.7.xml").toURL(), 1591 null, new String [] {"*"}, _cache, null, true); 1592 assertNotNull(report); 1593 ModuleDescriptor md = report.getModuleDescriptor(); 1594 assertNotNull(md); 1595 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.7"); 1596 assertEquals(mrid, md.getModuleRevisionId()); 1597 1598 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1599 1600 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.3")).exists()); 1602 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.3", "mod3.1", "jar", "jar").exists()); 1603 1604 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "1.1")).exists()); 1605 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "1.1", "mod1.2", "jar", "jar").exists()); 1606 1607 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists()); 1608 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 1609 } 1610 1611 public void testResolveForceWithDynamicRevisionsAndCyclicDependencies() throws Exception { 1612 ResolveReport report = _ivy.resolve(ResolveTest.class.getResource("ivy-182.xml"), 1622 null, new String [] {"*"}, _cache, null, true); 1623 assertNotNull(report); 1624 ModuleDescriptor md = report.getModuleDescriptor(); 1625 assertNotNull(md); 1626 ModuleId mid = new ModuleId("test", "IVY-182"); 1627 assertEquals(mid, md.getModuleRevisionId().getModuleId()); 1628 1629 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org3", "mod3.1", "1.4")).exists()); 1631 assertTrue(_ivy.getArchiveFileInCache(_cache, "org3", "mod3.1", "1.4", "mod3.1", "jar", "jar").exists()); 1632 1633 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "1.1")).exists()); 1634 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "1.1", "mod1.2", "jar", "jar").exists()); 1635 1636 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists()); 1637 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 1638 } 1639 1640 public void testResolveContradictoryConflictResolution() throws Exception { 1641 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod10.1/ivy-1.0.xml").toURL(), 1648 null, new String [] {"*"}, _cache, null, true); 1649 assertNotNull(report); 1650 ModuleDescriptor md = report.getModuleDescriptor(); 1651 assertNotNull(md); 1652 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org10", "mod10.1", "1.0"); 1653 assertEquals(mrid, md.getModuleRevisionId()); 1654 1655 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1656 1657 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1659 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1660 1661 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1662 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1663 } 1664 1665 public void testResolveContradictoryConflictResolution2() throws Exception { 1666 _ivy.resolve(new File ("test/repositories/2/mod10.1/ivy-1.1.xml").toURL(), 1674 null, new String [] {"*"}, _cache, null, true); 1675 1676 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 1678 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 1679 1680 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists()); 1681 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists()); 1682 } 1683 1684 public void testResolveContradictoryConflictResolution3() throws Exception { 1685 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod10.1/ivy-1.3.xml").toURL(), 1693 null, new String [] {"*"}, _cache, null, true); 1694 1695 IvyNode[] evicted = report.getConfigurationReport("default").getEvictedNodes(); 1696 assertEquals(1, evicted.length); 1697 assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1"), evicted[0].getResolvedId()); 1698 } 1699 1700 public void testExtends() throws Exception { 1701 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod5.2/ivy-1.0.xml").toURL(), 1706 null, new String [] {"*"}, _cache, null, true); 1707 assertNotNull(report); 1708 ModuleDescriptor md = report.getModuleDescriptor(); 1709 assertNotNull(md); 1710 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org5", "mod5.2", "1.0"); 1711 assertEquals(mrid, md.getModuleRevisionId()); 1712 1713 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1714 1715 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org5", "mod5.1", "4.0")).exists()); 1717 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 1718 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 1719 } 1720 1721 public void testMultiConfs() throws Exception { 1722 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod5.2/ivy-2.0.xml").toURL(), 1726 null, new String [] {"B", "A"}, _cache, null, true); 1727 assertNotNull(report); 1728 ModuleDescriptor md = report.getModuleDescriptor(); 1729 assertNotNull(md); 1730 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org5", "mod5.2", "2.0"); 1731 assertEquals(mrid, md.getModuleRevisionId()); 1732 1733 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1734 1735 ModuleRevisionId depId = ModuleRevisionId.newInstance("org5", "mod5.1", "4.1"); 1737 1738 ConfigurationResolveReport crr = report.getConfigurationReport("A"); 1739 assertNotNull(crr); 1740 assertEquals(1, crr.getDownloadReports(depId).length); 1741 1742 File r = new File (_cache, XmlReportOutputter.getReportFileName(mrid.getModuleId(), "A")); 1743 assertTrue(r.exists()); 1744 final boolean[] found = new boolean[] {false}; 1745 SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); 1746 saxParser.parse(r, new DefaultHandler () { 1747 public void startElement(String uri,String localName,String qName,org.xml.sax.Attributes attributes) throws SAXException { 1748 if ("artifact".equals(qName) && "art51B".equals(attributes.getValue("name"))) { 1749 found[0] = true; 1750 } 1751 } 1752 }); 1753 assertFalse(found[0]); 1754 1755 assertTrue(_ivy.getIvyFileInCache(_cache, depId).exists()); 1756 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.1", "art51A", "jar", "jar").exists()); 1757 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.1", "art51B", "jar", "jar").exists()); 1758 } 1759 1760 public void testThisConfiguration() throws Exception { 1761 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod14.4/ivy-1.1.xml").toURL(), 1762 null, new String [] {"compile"}, _cache, null, true); 1763 assertNotNull(report); 1764 ModuleDescriptor md = report.getModuleDescriptor(); 1765 assertNotNull(md); 1766 1767 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org14", "mod14.4", "1.1"); 1768 assertEquals(mrid, md.getModuleRevisionId()); 1769 ConfigurationResolveReport crr = report.getConfigurationReport("compile"); 1770 assertNotNull(crr); 1771 assertEquals(4, crr.getArtifactsNumber()); 1772 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.3", "1.1")).exists()); 1773 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.2", "1.1")).exists()); 1774 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.1", "1.1")).exists()); 1775 assertTrue(!_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org8", "mod8.3", "1.0")).exists()); 1776 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org8", "mod8.1", "1.0")).exists()); 1777 1778 cleanCache(); 1779 createCache(); 1780 report = _ivy.resolve(new File ("test/repositories/2/mod14.4/ivy-1.1.xml").toURL(), 1781 null, new String [] {"standalone"}, _cache, null, true); 1782 crr = report.getConfigurationReport("standalone"); 1783 assertNotNull(crr); 1784 assertEquals(7, crr.getArtifactsNumber()); 1785 1786 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.3", "1.1")).exists()); 1787 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.1", "1.1")).exists()); 1788 assertTrue(!_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.2", "1.1")).exists()); 1789 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org14", "mod14.3", "1.1")).exists()); 1790 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org8", "mod8.3", "1.0")).exists()); 1791 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org8", "mod8.1", "1.0")).exists()); 1792 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org8", "mod8.4", "1.1")).exists()); 1793 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org8", "mod8.2", "1.1")).exists()); 1794 } 1795 1796 public void testLatest() throws Exception { 1797 Ivy ivy = new Ivy(); 1799 ivy.configure(new File ("test/repositories/ivyconf.xml")); 1800 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml").toURL(), 1801 null, new String [] {"default"}, _cache, null, true); 1802 assertNotNull(report); 1803 ModuleDescriptor md = report.getModuleDescriptor(); 1804 assertNotNull(md); 1805 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.1"); 1806 assertEquals(mrid, md.getModuleRevisionId()); 1807 1808 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 1809 1810 ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "2.2"); 1812 1813 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1814 assertNotNull(crr); 1815 assertEquals(1, crr.getDownloadReports(depId).length); 1816 1817 File r = new File (_cache, XmlReportOutputter.getReportFileName(mrid.getModuleId(), "default")); 1818 assertTrue(r.exists()); 1819 final boolean[] found = new boolean[] {false}; 1820 SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); 1821 saxParser.parse(r, new DefaultHandler () { 1822 public void startElement(String uri,String localName,String qName,org.xml.sax.Attributes attributes) throws SAXException { 1823 if ("artifact".equals(qName) && "mod1.2".equals(attributes.getValue("name"))) { 1824 found[0] = true; 1825 } 1826 } 1827 }); 1828 assertTrue(found[0]); 1829 1830 assertTrue(ivy.getIvyFileInCache(_cache, depId).exists()); 1831 assertTrue(ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 1832 } 1833 1834 public void testLatestMultiple() throws Exception { 1835 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.5/ivys/ivy-1.0.2.xml").toURL(), 1839 null, new String [] {"default"}, _cache, null, true); 1840 assertFalse(report.hasError()); 1841 1842 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.4", "2.0")).exists()); 1844 1845 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).exists()); 1846 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists()); 1847 } 1848 1849 1850 public void testVersionRange1() throws Exception { 1851 Ivy ivy = new Ivy(); 1853 ivy.configure(new File ("test/repositories/ivyconf.xml")); 1854 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml").toURL(), 1855 null, new String [] {"default"}, _cache, null, true); 1856 assertFalse(report.hasError()); 1857 1858 ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "1.1"); 1860 1861 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1862 assertNotNull(crr); 1863 assertEquals(1, crr.getDownloadReports(depId).length); 1864 1865 assertTrue(ivy.getIvyFileInCache(_cache, depId).exists()); 1866 } 1867 1868 public void testVersionRange2() throws Exception { 1869 Ivy ivy = new Ivy(); 1871 ivy.configure(new File ("test/repositories/ivyconf.xml")); 1872 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.3.xml").toURL(), 1873 null, new String [] {"default"}, _cache, null, true); 1874 assertTrue(report.hasError()); 1875 } 1876 1877 public void testLatestMilestone() throws Exception { 1878 Ivy ivy = new Ivy(); 1880 ivy.configure(new File ("test/repositories/ivyconf.xml")); 1881 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org9/mod9.2/ivys/ivy-1.1.xml").toURL(), 1882 null, new String [] {"default"}, _cache, null, true); 1883 assertFalse(report.hasError()); 1884 1885 ModuleRevisionId depId = ModuleRevisionId.newInstance("org6", "mod6.4", "3"); 1887 1888 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1889 assertNotNull(crr); 1890 assertEquals(1, crr.getDownloadReports(depId).length); 1891 1892 assertTrue(ivy.getIvyFileInCache(_cache, depId).exists()); 1893 } 1894 1895 public void testLatestMilestone2() throws Exception { 1896 Ivy ivy = new Ivy(); 1899 ivy.configure(new File ("test/repositories/ivyconf.xml")); 1900 ResolveReport report = ivy.resolve(new File ("test/repositories/1/org9/mod9.2/ivys/ivy-1.2.xml").toURL(), 1901 null, new String [] {"default"}, _cache, null, true); 1902 assertTrue(report.hasError()); 1904 1905 ConfigurationResolveReport crr = report.getConfigurationReport("default"); 1907 assertNotNull(crr); 1908 assertEquals(0, crr.getArtifactsNumber()); 1909 } 1910 1911 public void testIVY56() throws Exception { 1912 Ivy ivy = new Ivy(); 1913 ivy.configure(new File ("test/repositories/bugIVY-56/ivyconf.xml")); 1914 1915 ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-56.xml"), 1916 null, new String [] {"default"}, _cache, null, true); 1917 assertNotNull(report); 1918 } 1919 1920 public void testIVY214() throws Exception { 1921 ResolveReport report = _ivy.resolve(ResolveTest.class.getResource("ivy-214.xml"), null, new String [] {"compile"}, _cache, null, true); 1922 1923 assertNotNull(report); 1924 assertFalse(report.hasError()); 1925 1926 assertEquals("Number of artifacts not correct", 1, report.getConfigurationReport("compile").getArtifactsNumber()); 1927 } 1928 1929 public void testIVY218() throws Exception { 1930 ResolveReport report = _ivy.resolve(ResolveTest.class.getResource("ivy-218.xml"), null, new String [] {"test"}, _cache, null, true); 1931 1932 assertNotNull(report); 1933 assertFalse(report.hasError()); 1934 1935 assertEquals("Number of artifacts not correct", 3, report.getConfigurationReport("test").getArtifactsNumber()); 1936 } 1937 1938 public void testCircular() throws Exception { 1939 1941 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod6.3/ivy-1.0.xml").toURL(), 1942 null, new String [] {"default"}, _cache, null, true); 1943 assertFalse(report.hasError()); 1944 1945 _ivy.setCircularDependencyStrategy(IgnoreCircularDependencyStrategy.getInstance()); 1946 report = _ivy.resolve(new File ("test/repositories/2/mod6.3/ivy-1.0.xml").toURL(), 1947 null, new String [] {"default"}, _cache, null, true); 1948 assertFalse(report.hasError()); 1949 1950 _ivy.setCircularDependencyStrategy(WarnCircularDependencyStrategy.getInstance()); 1951 report = _ivy.resolve(new File ("test/repositories/2/mod6.3/ivy-1.0.xml").toURL(), 1952 null, new String [] {"default"}, _cache, null, true); 1953 assertFalse(report.hasError()); 1954 1955 _ivy.setCircularDependencyStrategy(ErrorCircularDependencyStrategy.getInstance()); 1956 try { 1957 _ivy.resolve(new File ("test/repositories/2/mod6.3/ivy-1.0.xml").toURL(), 1958 null, new String [] {"default"}, _cache, null, true); 1959 fail("no exception with circular dependency strategy set to error"); 1960 } catch (CircularDependencyException ex) { 1961 assertEquals("[ org6 | mod6.3 | 1.0 ]->[ org6 | mod6.2 | 1.0 ]->[ org6 | mod6.3 | latest.integration ]", ex.getMessage()); 1962 } 1963 } 1964 1965 public void testCircular2() throws Exception { 1966 1968 ResolveReport report = _ivy.resolve(new File ("test/repositories/circular/ivy.xml").toURL(), 1969 null, new String [] {"*"}, _cache, null, true); 1970 assertFalse(report.hasError()); 1971 1972 _ivy.setCircularDependencyStrategy(ErrorCircularDependencyStrategy.getInstance()); 1973 try { 1974 _ivy.resolve(new File ("test/repositories/circular/ivy.xml").toURL(), 1975 null, new String [] {"*"}, _cache, null, true); 1976 fail("no exception with circular dependency strategy set to error"); 1977 } catch (CircularDependencyException ex) { 1978 assertEquals("[ org8 | mod8.5 | NONE ]->[ org8 | mod8.6 | 2.+ ]->[ org8 | mod8.5 | 2.+ ]", ex.getMessage()); 1980 } 1981 } 1982 1983 public void testRegularCircular() throws Exception { 1984 _ivy.setCircularDependencyStrategy(ErrorCircularDependencyStrategy.getInstance()); 1987 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod11.1/ivy-1.0.xml").toURL(), 1988 null, new String [] {"test"}, _cache, null, true); 1989 1990 assertNotNull(report); 1991 assertFalse(report.hasError()); 1992 1993 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org11", "mod11.2", "1.0")).exists()); 1994 assertTrue(_ivy.getArchiveFileInCache(_cache, "org11", "mod11.2", "1.0", "mod11.2", "jar", "jar").exists()); 1995 1996 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org11", "mod11.1", "1.0")).exists()); 1997 assertFalse(_ivy.getArchiveFileInCache(_cache, "org11", "mod11.1", "1.0", "mod11.1", "jar", "jar").exists()); 1998 } 1999 2000 public void testResolveDualChain() throws Exception { 2001 Ivy ivy = new Ivy(); 2002 ivy.configure(ResolveTest.class.getResource("dualchainresolverconf.xml")); 2003 2004 DependencyResolver resolver = ivy.getResolver("default"); 2005 assertNotNull(resolver); 2006 assertTrue(resolver instanceof DualResolver); 2007 2008 ivy.resolve(ResolveTest.class.getResource("ivy-dualchainresolver.xml"), null, new String [] {"default"}, new File ("build/cache"), null, true); 2010 2011 assertTrue(new File ("build/cache/xerces/xerces/ivy-2.6.2.xml").exists()); 2012 assertTrue(new File ("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists()); 2013 assertTrue(new File ("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists()); 2014 2015 new File ("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").delete(); 2017 new File ("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").delete(); 2018 assertFalse(new File ("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists()); 2019 assertFalse(new File ("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists()); 2020 ivy.resolve(ResolveTest.class.getResource("ivy-dualchainresolver.xml"), null, new String [] {"default"}, new File ("build/cache"), null, true); 2021 2022 assertTrue(new File ("build/cache/xerces/xerces/ivy-2.6.2.xml").exists()); 2023 assertTrue(new File ("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists()); 2024 assertTrue(new File ("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists()); 2025 } 2026 2027 2028 public void testBug148() throws Exception { 2029 Ivy ivy = new Ivy(); 2030 ivy.configure(new File ("test/repositories/bug148/ivyconf.xml")); 2031 2032 ivy.resolve(ResolveTest.class.getResource("ivy-148.xml"), null, new String [] {"*"}, new File ("build/cache"), null, true); 2033 2034 assertTrue(new File ("build/cache/jtv-foo/bar/ivy-1.1.0.0.xml").exists()); 2035 assertTrue(new File ("build/cache/jtv-foo/bar/jars/bar-1.1.0.0.jar").exists()); 2036 assertTrue(new File ("build/cache/idautomation/barcode/ivy-4.10.xml").exists()); 2037 assertTrue(new File ("build/cache/idautomation/barcode/jars/LinearBarCode-4.10.jar").exists()); 2038 } 2039 2040 public void testBug148b() throws Exception { 2041 Ivy ivy = new Ivy(); 2042 ivy.configure(new File ("test/repositories/bug148/ivyconf.xml")); 2043 2044 ivy.resolve(ResolveTest.class.getResource("ivy-148b.xml"), null, new String [] {"*"}, new File ("build/cache"), null, true); 2045 2046 assertTrue(new File ("build/cache/jtv-foo/bar/ivy-1.1.0.0.xml").exists()); 2047 assertTrue(new File ("build/cache/jtv-foo/bar/jars/bar-1.1.0.0.jar").exists()); 2048 assertTrue(new File ("build/cache/idautomation/barcode/ivy-4.10.xml").exists()); 2049 assertTrue(new File ("build/cache/idautomation/barcode/jars/LinearBarCode-4.10.jar").exists()); 2050 } 2051 2052 public void testBadFiles() throws Exception { 2053 Ivy ivy = new Ivy(); 2054 ivy.configure(new File ("test/repositories/badfile/ivyconf.xml")); 2055 2056 try { 2057 ivy.resolve(new File ("test/repositories/badfile/ivys/ivy-badorg.xml").toURL(), null, new String [] {"*"}, new File ("build/cache"), null, true); 2058 fail("bad org should have raised an exception !"); 2059 } catch (Exception ex) { 2060 } 2062 try { 2063 ivy.resolve(new File ("test/repositories/badfile/ivys/ivy-badmodule.xml").toURL(), null, new String [] {"*"}, new File ("build/cache"), null, true); 2064 fail("bad module should have raised an exception !"); 2065 } catch (Exception ex) { 2066 } 2068 try { 2069 ivy.resolve(new File ("test/repositories/badfile/ivys/ivy-badrevision.xml").toURL(), null, new String [] {"*"}, new File ("build/cache"), null, true); 2070 fail("bad revision should have raised an exception !"); 2071 } catch (Exception ex) { 2072 } 2074 } 2075 2076 public void testTransitiveSetting() throws Exception { 2077 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.4/ivys/ivy-0.3.xml").toURL(), 2080 null, new String [] {"*"}, _cache, null, true); 2081 assertNotNull(report); 2082 ModuleDescriptor md = report.getModuleDescriptor(); 2083 assertNotNull(md); 2084 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.4", "0.3"); 2085 assertEquals(mrid, md.getModuleRevisionId()); 2086 2087 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2088 2089 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 2091 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 2092 2093 assertTrue(!_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 2094 assertTrue(!_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 2095 } 2096 2097 public void testResolverDirectlyUsingCache() throws Exception { 2098 Ivy ivy = new Ivy(); 2099 ivy.configure(ResolveTest.class.getResource("badcacheconf.xml")); 2100 File depIvyFileInCache = ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")); 2101 FileUtil.copy(File.createTempFile("test", "xml"), depIvyFileInCache, null); ResolveReport report = ivy.resolve(new File ("test/repositories/1/org2/mod2.4/ivys/ivy-0.3.xml").toURL(), 2103 null, new String [] {"*"}, _cache, null, true); 2104 2105 assertNotNull(report); 2106 ModuleDescriptor md = report.getModuleDescriptor(); 2107 assertNotNull(md); 2108 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.4", "0.3"); 2109 assertEquals(mrid, md.getModuleRevisionId()); 2110 2111 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2112 2113 assertTrue(depIvyFileInCache.exists()); 2115 assertTrue(!ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 2116 } 2117 2118 public void testVisibility1() throws Exception { 2119 _ivy.resolve(new File ("test/repositories/2/mod8.2/ivy-1.0.xml").toURL(), 2120 null, new String [] {"*"}, _cache, null, true); 2121 2122 assertFalse(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.0", "a-private", "txt", "txt").exists()); 2123 } 2124 2125 public void testVisibility2() throws Exception { 2126 _ivy.resolve(new File ("test/repositories/2/mod8.3/ivy-1.0.xml").toURL(), 2127 null, new String [] {"private"}, _cache, null, true); 2128 2129 assertFalse(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.0", "a-private", "txt", "txt").exists()); 2130 assertTrue(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.0", "a", "txt", "txt").exists()); 2131 } 2132 2133 public void testVisibility3() throws Exception { 2134 _ivy.resolve(new File ("test/repositories/2/mod8.4/ivy-1.0.xml").toURL(), 2135 null, new String [] {"*"}, _cache, null, true); 2136 2137 assertFalse(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.0", "a-private", "txt", "txt").exists()); 2138 assertTrue(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.0", "a", "txt", "txt").exists()); 2139 } 2140 2141 public void testVisibility4() throws Exception { 2142 _ivy.resolve(new File ("test/repositories/2/mod8.4/ivy-1.1.xml").toURL(), 2143 null, new String [] {"*"}, _cache, null, true); 2144 2145 assertTrue(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.1", "a-private", "txt", "txt").exists()); 2146 assertTrue(_ivy.getArchiveFileInCache(_cache, "org8", "mod8.1", "1.1", "a", "txt", "txt").exists()); 2147 } 2148 2149 2154 public void testConfigurationMapping1() throws Exception { 2155 Ivy ivy = new Ivy(); 2156 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2157 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/1/ivy.xml").toURL(), 2158 null, new String [] {"*"}, _cache, null, true); 2159 2160 ConfigurationResolveReport conf = report.getConfigurationReport("default"); 2161 2162 assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf); 2163 assertDoesntContainArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf); 2164 assertContainsArtifact("test", "b", "1.0.2", "b", "txt", "txt", conf); 2165 assertDoesntContainArtifact("test", "b", "1.0.2", "b-bt", "txt", "txt", conf); 2166 assertContainsArtifact("test", "c", "1.0.2", "c", "txt", "txt", conf); 2167 assertDoesntContainArtifact("test", "c", "1.0.2", "c-bt", "txt", "txt", conf); 2168 } 2169 2170 public void testConfigurationMapping2() throws Exception { 2171 Ivy ivy = new Ivy(); 2172 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2173 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/2/ivy.xml").toURL(), 2174 null, new String [] {"*"}, _cache, null, true); 2175 2176 ConfigurationResolveReport conf = report.getConfigurationReport("default"); 2177 2178 assertContainsArtifact("test", "a", "1.0.1", "a", "txt", "txt", conf); 2179 assertDoesntContainArtifact("test", "a", "1.0.1", "a-bt", "txt", "txt", conf); 2180 assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf); 2181 assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf); 2182 assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf); 2183 assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf); 2184 } 2185 2186 public void testConfigurationMapping3() throws Exception { 2187 Ivy ivy = new Ivy(); 2188 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2189 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/3/ivy.xml").toURL(), 2190 null, new String [] {"buildtime"}, _cache, null, true); 2191 2192 ConfigurationResolveReport conf = report.getConfigurationReport("buildtime"); 2193 2194 assertContainsArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf); 2195 assertDoesntContainArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf); 2196 assertContainsArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf); 2197 assertDoesntContainArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf); 2198 assertContainsArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf); 2199 assertDoesntContainArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf); 2200 } 2201 2202 public void testConfigurationMapping4() throws Exception { 2203 Ivy ivy = new Ivy(); 2204 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2205 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/4/ivy.xml").toURL(), 2206 null, new String [] {"default"}, _cache, null, true); 2207 2208 ConfigurationResolveReport conf = report.getConfigurationReport("default"); 2209 2210 assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf); 2211 assertDoesntContainArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf); 2212 assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf); 2213 assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf); 2214 assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf); 2215 assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf); 2216 } 2217 2218 public void testConfigurationMapping5() throws Exception { 2219 Ivy ivy = new Ivy(); 2220 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2221 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/5/ivy.xml").toURL(), 2222 null, new String [] {"*"}, _cache, null, true); 2223 2224 ConfigurationResolveReport conf = report.getConfigurationReport("default"); 2225 2226 assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf); 2227 assertDoesntContainArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf); 2228 assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf); 2229 assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf); 2230 assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf); 2231 assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf); 2232 } 2233 2234 public void testConfigurationMapping6() throws Exception { 2235 Ivy ivy = new Ivy(); 2236 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2237 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/6/ivy.xml").toURL(), 2238 null, new String [] {"default", "buildtime"}, _cache, null, true); 2239 2240 ConfigurationResolveReport conf = report.getConfigurationReport("default"); 2241 2242 assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf); 2243 assertDoesntContainArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf); 2244 assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf); 2245 assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf); 2246 assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf); 2247 assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf); 2248 } 2249 2250 public void testConfigurationMapping7() throws Exception { 2251 Ivy ivy = new Ivy(); 2252 ivy.configure(new File ("test/repositories/IVY-84/ivyconf.xml")); 2253 ResolveReport report = ivy.resolve(new File ("test/repositories/IVY-84/tests/7/ivy.xml").toURL(), 2254 null, new String [] {"buildtime", "default"}, _cache, null, true); 2255 2256 ConfigurationResolveReport conf = report.getConfigurationReport("default"); 2257 2258 assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf); 2259 assertDoesntContainArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf); 2260 assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf); 2261 assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf); 2262 assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf); 2263 assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf); 2264 } 2265 2266 public void testIVY97() throws Exception { 2267 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org9/mod9.2/ivys/ivy-1.0.xml").toURL(), 2270 null, new String [] {"*"}, _cache, null, true); 2271 assertNotNull(report); 2272 ModuleDescriptor md = report.getModuleDescriptor(); 2273 assertNotNull(md); 2274 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org9", "mod9.2", "1.0"); 2275 assertEquals(mrid, md.getModuleRevisionId()); 2276 2277 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2278 2279 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org9", "mod9.1", "1.0")).exists()); 2281 assertTrue(_ivy.getArchiveFileInCache(_cache, "org9", "mod9.1", "1.0", "mod9.1", "jar", "jar").exists()); 2282 2283 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 2284 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 2285 } 2286 2287 public void testResolveTransitiveExcludesSimple() throws Exception { 2288 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.5/ivys/ivy-0.6.xml").toURL(), 2291 null, new String [] {"*"}, _cache, null, true); 2292 assertNotNull(report); 2293 ModuleDescriptor md = report.getModuleDescriptor(); 2294 assertNotNull(md); 2295 ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.5", "0.6"); 2296 assertEquals(mrid, md.getModuleRevisionId()); 2297 2298 assertTrue(_ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2299 2300 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.3", "0.7")).exists()); 2301 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.3", "0.7", "mod2.3", "jar", "jar").exists()); 2302 2303 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org2", "mod2.1", "0.3")).exists()); 2304 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 2305 assertFalse(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 2306 } 2307 2308 public void testResolveTransitiveExcludesDiamond1() throws Exception { 2309 _ivy.resolve(new File ("test/repositories/1/org2/mod2.6/ivys/ivy-0.6.xml").toURL(), 2313 null, new String [] {"*"}, _cache, null, true); 2314 2315 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 2316 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 2317 } 2318 2319 public void testResolveTransitiveExcludesDiamond2() throws Exception { 2320 _ivy.resolve(new File ("test/repositories/1/org2/mod2.6/ivys/ivy-0.7.xml").toURL(), 2324 null, new String [] {"*"}, _cache, null, true); 2325 2326 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 2327 assertFalse(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 2328 } 2329 2330 public void testResolveTransitiveExcludesDiamond3() throws Exception { 2331 _ivy.resolve(new File ("test/repositories/1/org2/mod2.6/ivys/ivy-0.8.xml").toURL(), 2335 null, new String [] {"*"}, _cache, null, true); 2336 2337 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 2338 assertTrue(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 2339 } 2340 2341 public void testResolveTransitiveExcludes2() throws Exception { 2342 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.6/ivys/ivy-0.9.xml").toURL(), 2345 null, new String [] {"*"}, _cache, null, true); 2346 ModuleDescriptor md = report.getModuleDescriptor(); 2347 assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.9"), md.getModuleRevisionId()); 2348 2349 assertFalse(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21A", "jar", "jar").exists()); 2350 assertFalse(_ivy.getArchiveFileInCache(_cache, "org2", "mod2.1", "0.3", "art21B", "jar", "jar").exists()); 2351 } 2352 2353 public void testResolveExcludesModule() throws Exception { 2354 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org2/mod2.6/ivys/ivy-0.10.xml").toURL(), 2357 null, new String [] {"*"}, _cache, null, true); 2358 ModuleDescriptor md = report.getModuleDescriptor(); 2359 assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.10"), md.getModuleRevisionId()); 2360 2361 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists()); 2362 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists()); 2363 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 2364 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 2365 } 2366 2367 public void testResolveExceptConfiguration() throws Exception { 2368 _ivy.resolve(new File ("test/repositories/2/mod10.2/ivy-2.0.xml").toURL(), 2370 null, new String [] {"*"}, _cache, null, true); 2371 2372 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.1", "art51A", "jar", "jar").exists()); 2373 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.1", "art51B", "jar", "jar").exists()); 2374 } 2375 2376 public void testResolveFallbackConfiguration() throws Exception { 2377 _ivy.resolve(new File ("test/repositories/2/mod10.2/ivy-1.0.xml").toURL(), 2379 null, new String [] {"*"}, _cache, null, true); 2380 2381 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 2382 } 2383 2384 public void testResolveFallbackConfiguration2() throws Exception { 2385 _ivy.resolve(new File ("test/repositories/2/mod10.2/ivy-1.1.xml").toURL(), 2387 null, new String [] {"*"}, _cache, null, true); 2388 2389 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 2390 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 2391 } 2392 2393 public void testResolveFallbackConfiguration3() throws Exception { 2394 _ivy.resolve(new File ("test/repositories/2/mod10.2/ivy-1.2.xml").toURL(), 2396 null, new String [] {"*"}, _cache, null, true); 2397 2398 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 2399 assertTrue(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 2400 } 2401 2402 public void testResolveFallbackConfiguration4() throws Exception { 2403 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod10.2/ivy-1.3.xml").toURL(), 2405 null, new String [] {"*"}, _cache, null, true); 2406 assertFalse(report.hasError()); 2407 2408 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists()); 2409 assertFalse(_ivy.getArchiveFileInCache(_cache, "org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists()); 2410 } 2411 2412 public void testResolveMaven2() throws Exception { 2413 Ivy ivy = new Ivy(); 2415 ivy.configure(new File ("test/repositories/m2/ivyconf.xml")); 2416 ResolveReport report = ivy.resolve(new File ("test/repositories/m2/fr/jayasoft/test3/1.0/test3-1.0.pom").toURL(), 2417 null, new String [] {"*"}, _cache, null, true); 2418 assertNotNull(report); 2419 ModuleDescriptor md = report.getModuleDescriptor(); 2420 assertNotNull(md); 2421 ModuleRevisionId mrid = ModuleRevisionId.newInstance("fr.jayasoft", "test3", "1.0"); 2422 assertEquals(mrid, md.getModuleRevisionId()); 2423 2424 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2425 2426 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("fr.jayasoft", "test2", "1.0")).exists()); 2428 assertTrue(ivy.getArchiveFileInCache(_cache, "fr.jayasoft", "test2", "1.0", "test2", "jar", "jar").exists()); 2429 2430 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("fr.jayasoft", "test", "1.0")).exists()); 2431 assertTrue(ivy.getArchiveFileInCache(_cache, "fr.jayasoft", "test", "1.0", "test", "jar", "jar").exists()); 2432 } 2433 2434 public void testNamespaceMapping() throws Exception { 2435 Ivy ivy = new Ivy(); 2437 ivy.configure(new File ("test/repositories/namespace/ivyconf.xml")); 2438 ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-namespace.xml"), 2439 null, new String [] {"*"}, _cache, null, true); 2440 assertNotNull(report); 2441 ModuleDescriptor md = report.getModuleDescriptor(); 2442 assertNotNull(md); 2443 ModuleRevisionId mrid = ModuleRevisionId.newInstance("jayasoft", "namespace", "1.0"); 2444 assertEquals(mrid, md.getModuleRevisionId()); 2445 2446 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2447 2448 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("systemorg", "systemmod", "1.0")).exists()); 2450 assertTrue(ivy.getArchiveFileInCache(_cache, "systemorg", "systemmod", "1.0", "A", "jar", "jar").exists()); 2451 } 2452 2453 public void testNamespaceMapping2() throws Exception { 2454 Ivy ivy = new Ivy(); 2456 ivy.configure(new File ("test/repositories/namespace/ivyconf.xml")); 2457 ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-namespace2.xml"), 2458 null, new String [] {"*"}, _cache, null, true); 2459 assertNotNull(report); 2460 ModuleDescriptor md = report.getModuleDescriptor(); 2461 assertNotNull(md); 2462 ModuleRevisionId mrid = ModuleRevisionId.newInstance("jayasoft", "namespace", "2.0"); 2463 assertEquals(mrid, md.getModuleRevisionId()); 2464 2465 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2466 2467 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("systemorg", "systemmod2", "1.0")).exists()); 2469 assertTrue(ivy.getArchiveFileInCache(_cache, "systemorg", "systemmod2", "1.0", "B", "jar", "jar").exists()); 2470 2471 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("systemorg", "systemmod", "1.0")).exists()); 2472 assertTrue(ivy.getArchiveFileInCache(_cache, "systemorg", "systemmod", "1.0", "A", "jar", "jar").exists()); 2473 } 2474 2475 public void testNamespaceMapping3() throws Exception { 2476 Ivy ivy = new Ivy(); 2478 ivy.configure(new File ("test/repositories/namespace/ivyconf.xml")); 2479 ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-namespace3.xml"), 2480 null, new String [] {"*"}, _cache, null, true); 2481 assertNotNull(report); 2482 ModuleDescriptor md = report.getModuleDescriptor(); 2483 assertNotNull(md); 2484 ModuleRevisionId mrid = ModuleRevisionId.newInstance("jayasoft", "namespace", "3.0"); 2485 assertEquals(mrid, md.getModuleRevisionId()); 2486 2487 assertTrue(ivy.getResolvedIvyFileInCache(_cache, mrid).exists()); 2488 2489 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("systemorg2", "system-2", "1.0")).exists()); 2491 assertTrue(ivy.getArchiveFileInCache(_cache, "systemorg2", "system-2", "1.0", "2", "jar", "jar").exists()); 2492 2493 assertTrue(ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("systemorg2", "system-1", "1.0")).exists()); 2494 assertTrue(ivy.getArchiveFileInCache(_cache, "systemorg2", "system-1", "1.0", "1", "jar", "jar").exists()); 2495 } 2496 2497 public void testNamespaceMapping4() throws Exception { 2498 Ivy ivy = new Ivy(); 2501 ivy.configure(new File ("test/repositories/namespace/ivyconf.xml")); 2502 ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-namespace4.xml"), 2503 null, new String [] {"*"}, _cache, null, true); 2504 assertNotNull(report); 2505 ModuleDescriptor md = report.getModuleDescriptor(); 2506 assertNotNull(md); 2507 ModuleRevisionId mrid = ModuleRevisionId.newInstance("jayasoft", "namespace", "4.0"); 2508 assertEquals(mrid, md.getModuleRevisionId()); 2509 2510 assertTrue(report.hasError()); 2511 } 2512 2513 public void testIVY151() throws Exception { 2514 Ivy ivy = new Ivy(); 2515 ivy.configure(new File ("test/repositories/multirevisions/ivyconf.xml")); 2516 ResolveReport report = ivy.resolve(new File ("test/repositories/multirevisions/ivy.xml").toURL(), null, new String [] {"compile", "test"}, _cache, null, true); 2517 2518 assertNotNull(report); 2519 assertNotNull(report.getUnresolvedDependencies()); 2520 assertEquals("Number of unresolved dependencies not correct", 0, report.getUnresolvedDependencies().length); 2521 } 2522 2523 public void testCheckRevision() throws Exception { 2524 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod12.2/ivy-1.0.xml").toURL(), 2527 null, new String [] {"*"}, _cache, null, true); 2528 2529 assertTrue(report.hasError()); 2530 2531 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org12", "mod12.1", "1.0")).exists()); 2532 assertFalse(_ivy.getArchiveFileInCache(_cache, "org12", "mod12.1", "1.0", "mod12.1", "jar", "jar").exists()); 2533 2534 assertFalse(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 2535 assertFalse(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 2536 } 2537 2538 public void testTrustRevision() throws Exception { 2539 2542 ((BasicResolver)_ivy.getResolver("2-ivy")).setCheckconsistency(false); 2543 2544 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod12.2/ivy-1.0.xml").toURL(), 2545 null, new String [] {"*"}, _cache, null, true); 2546 2547 assertFalse(report.hasError()); 2548 2549 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org12", "mod12.1", "1.0")).exists()); 2550 assertTrue(_ivy.getArchiveFileInCache(_cache, "org12", "mod12.1", "1.0", "mod12.1", "jar", "jar").exists()); 2551 2552 assertTrue(_ivy.getIvyFileInCache(_cache, ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists()); 2553 assertTrue(_ivy.getArchiveFileInCache(_cache, "org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists()); 2554 } 2555 2556 public void testTransitiveConfMapping() throws Exception { 2557 2565 ResolveReport report = _ivy.resolve(new File ("test/repositories/2/mod13.3/ivy-1.0.xml").toURL(), 2566 null, new String [] {"*"}, _cache, null, true); 2567 2568 assertFalse(report.hasError()); 2569 2570 assertEquals(3, report.getConfigurationReport("compile").getArtifactsNumber()); 2571 assertEquals(0, report.getConfigurationReport("j2ee").getArtifactsNumber()); 2572 } 2573 2574 public void testExtraAttributes() throws Exception { 2575 Ivy ivy = new Ivy(); 2576 ivy.configure(new File ("test/repositories/extra-attributes/ivyconf.xml")); 2577 2578 ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att.xml"), 2579 null, new String [] {"*"}, _cache, null, false); 2580 assertFalse(report.hasError()); 2581 2582 assertTrue(new File (_cache, "jayasoft/mymodule/task1/1854/ivy.xml").exists()); 2583 assertTrue(new File (_cache, "jayasoft/mymodule/task1/1854/mymodule-windows.jar").exists()); 2584 assertTrue(new File (_cache, "jayasoft/mymodule/task1/1854/mymodule-linux.jar").exists()); 2585 } 2586 2587 public void testBranches1() throws Exception { 2588 Ivy ivy = new Ivy(); 2589 ivy.configure(new File ("test/repositories/branches/ivyconf.xml")); 2590 2591 ResolveReport report = ivy.resolve(new File ("test/repositories/branches/bar/bar1/trunk/1/ivy.xml").toURL(), 2592 null, new String [] {"*"}, _cache, null, false); 2593 assertFalse(report.hasError()); 2594 2595 assertTrue(_ivy.getArchiveFileInCache(_cache, "foo", "foo1", "3", "foo1", "jar", "jar").exists()); 2596 } 2597 2598 public void testBranches2() throws Exception { 2599 Ivy ivy = new Ivy(); 2600 ivy.configure(new File ("test/repositories/branches/ivyconf.xml")); 2601 2602 ResolveReport report = ivy.resolve(new File ("test/repositories/branches/bar/bar1/trunk/2/ivy.xml").toURL(), 2603 null, new String [] {"*"}, _cache, null, false); 2604 assertFalse(report.hasError()); 2605 2606 assertTrue(_ivy.getArchiveFileInCache(_cache, "foo", "foo1", "4", "foo1", "jar", "jar").exists()); 2607 } 2608 2609 public void testBranches3() throws Exception { 2610 Ivy ivy = new Ivy(); 2611 ivy.configure(new File ("test/repositories/branches/ivyconf-defaultbranch1.xml")); 2612 2613 ResolveReport report = ivy.resolve(new File ("test/repositories/branches/bar/bar1/trunk/1/ivy.xml").toURL(), 2614 null, new String [] {"*"}, _cache, null, false); 2615 assertFalse(report.hasError()); 2616 2617 assertTrue(_ivy.getArchiveFileInCache(_cache, "foo", "foo1", "4", "foo1", "jar", "jar").exists()); 2618 } 2619 2620 public void testBranches4() throws Exception { 2621 Ivy ivy = new Ivy(); 2622 ivy.configure(new File ("test/repositories/branches/ivyconf.xml")); 2623 2624 ResolveReport report = ivy.resolve(new File ("test/repositories/branches/bar/bar1/trunk/3/ivy.xml").toURL(), 2625 null, new String [] {"*"}, _cache, null, false); 2626 assertFalse(report.hasError()); 2627 2628 assertTrue(_ivy.getArchiveFileInCache(_cache, "foo", "foo1", "3", "foo1", "jar", "jar").exists()); 2629 assertTrue(_ivy.getArchiveFileInCache(_cache, "bar", "bar2", "2", "bar2", "jar", "jar").exists()); 2630 } 2631 2632 public void testBranches5() throws Exception { 2633 Ivy ivy = new Ivy(); 2634 ivy.configure(new File ("test/repositories/branches/ivyconf-fooonbranch1.xml")); 2635 2636 ResolveReport report = ivy.resolve(new File ("test/repositories/branches/bar/bar1/trunk/3/ivy.xml").toURL(), 2637 null, new String [] {"*"}, _cache, null, false); 2638 assertFalse(report.hasError()); 2639 2640 assertTrue(_ivy.getArchiveFileInCache(_cache, "foo", "foo1", "4", "foo1", "jar", "jar").exists()); 2641 assertTrue(_ivy.getArchiveFileInCache(_cache, "bar", "bar2", "2", "bar2", "jar", "jar").exists()); 2642 } 2643 2644 public void testExternalArtifacts() throws Exception { 2645 Ivy ivy = new Ivy(); 2646 ivy.setVariable("test.base.url", new File ("test/repositories/external-artifacts").toURL().toString()); 2647 ivy.configure(new File ("test/repositories/external-artifacts/ivyconf.xml")); 2648 2649 ResolveReport report = ivy.resolve(new File ("test/repositories/external-artifacts/ivy.xml").toURL(), 2650 null, new String [] {"*"}, _cache, null, false); 2651 assertFalse(report.hasError()); 2652 2653 assertTrue(_ivy.getArchiveFileInCache(_cache, "jayasoft", "A", "1.0", "a", "jar", "jar").exists()); 2654 assertTrue(_ivy.getArchiveFileInCache(_cache, "jayasoft", "B", "2.0", "b", "jar", "jar").exists()); 2655 assertTrue(_ivy.getArchiveFileInCache(_cache, "jayasoft", "C", "3.0", "C", "jar", "jar").exists()); 2656 } 2657 2658 2659 2663 private void assertContainsArtifact(String org, String module, String rev, String artName, String type, String ext, ConfigurationResolveReport conf) { 2664 Artifact art = getArtifact(org, module, rev, artName, type, ext); 2665 if (!containsArtifact(art, conf.getDownloadedArtifactsReports())) { 2666 fail("artifact "+art+" should be part of "+conf.getConfiguration()+" from "+conf.getModuleDescriptor().getModuleRevisionId()); 2667 } 2668 } 2669 2670 private void assertDoesntContainArtifact(String org, String module, String rev, String artName, String type, String ext, ConfigurationResolveReport conf) { 2671 Artifact art = getArtifact(org, module, rev, artName, type, ext); 2672 if (containsArtifact(art, conf.getDownloadedArtifactsReports())) { 2673 fail("artifact "+art+" should NOT be part of "+conf.getConfiguration()+" from "+conf.getModuleDescriptor().getModuleRevisionId()); 2674 } 2675 } 2676 2677 private Artifact getArtifact(String org, String module, String rev, String artName, String type, String ext) { 2678 return new DefaultArtifact(ModuleRevisionId.newInstance(org, module, rev), new Date (), artName, type, ext); 2679 } 2680 2681 private boolean containsArtifact(Artifact art, ArtifactDownloadReport[] adr) { 2682 for (int i = 0; i < adr.length; i++) { 2683 Artifact artifact = adr[i].getArtifact(); 2684 if (artifact.getModuleRevisionId().equals(art.getModuleRevisionId()) 2685 && artifact.getName().equals(art.getName()) 2686 && artifact.getType().equals(art.getType()) 2687 && artifact.getExt().equals(art.getExt())) { 2688 return true; 2689 } 2690 } 2691 return false; 2692 } 2693 2694} 2695 | Popular Tags |