| 1 7 package fr.jayasoft.ivy; 8 9 import java.io.File ; 10 11 import org.apache.tools.ant.Project; 12 import org.apache.tools.ant.taskdefs.Delete; 13 14 import fr.jayasoft.ivy.matcher.PatternMatcher; 15 16 import junit.framework.TestCase; 17 18 public class InstallTest extends TestCase { 19 20 public void testSimple() throws Exception { 21 Ivy ivy = new Ivy(); 22 ivy.configure(new File ("test/repositories/ivyconf.xml")); 23 24 ivy.install(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), 25 ivy.getDefaultResolver().getName(), 26 "install", true, true, true, null, _cache, PatternMatcher.EXACT); 27 28 assertTrue(new File ("build/test/install/org1/mod1.2/ivy-2.0.xml").exists()); 29 assertTrue(new File ("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists()); 30 } 31 32 public void testDependencies() throws Exception { 33 Ivy ivy = new Ivy(); 34 ivy.configure(new File ("test/repositories/ivyconf.xml")); 35 36 ivy.install(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 37 ivy.getDefaultResolver().getName(), 38 "install", true, true, true, null, _cache, PatternMatcher.EXACT); 39 40 assertTrue(new File ("build/test/install/org1/mod1.1/ivy-1.0.xml").exists()); 41 assertTrue(new File ("build/test/install/org1/mod1.1/mod1.1-1.0.jar").exists()); 42 43 assertTrue(new File ("build/test/install/org1/mod1.2/ivy-2.0.xml").exists()); 44 assertTrue(new File ("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists()); 45 } 46 47 public void testNotTransitive() throws Exception { 48 Ivy ivy = new Ivy(); 49 ivy.configure(new File ("test/repositories/ivyconf.xml")); 50 51 ivy.install(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), 52 ivy.getDefaultResolver().getName(), 53 "install", false, true, true, null, _cache, PatternMatcher.EXACT); 54 55 assertTrue(new File ("build/test/install/org1/mod1.1/ivy-1.0.xml").exists()); 56 assertTrue(new File ("build/test/install/org1/mod1.1/mod1.1-1.0.jar").exists()); 57 58 assertFalse(new File ("build/test/install/org1/mod1.2/ivy-2.0.xml").exists()); 59 assertFalse(new File ("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists()); 60 } 61 62 public void testRegexpMatcher() throws Exception { 63 Ivy ivy = new Ivy(); 64 ivy.configure(new File ("test/repositories/ivyconf.xml")); 65 66 ivy.install(ModuleRevisionId.newInstance("org1", ".*", ".*"), 67 "1", 68 "install", false, true, true, null, _cache, PatternMatcher.REGEXP); 69 70 assertTrue(new File ("build/test/install/org1/mod1.1/ivy-1.0.xml").exists()); 71 assertTrue(new File ("build/test/install/org1/mod1.1/mod1.1-1.0.jar").exists()); 72 73 assertTrue(new File ("build/test/install/org1/mod1.1/ivy-1.1.xml").exists()); 74 assertTrue(new File ("build/test/install/org1/mod1.1/mod1.1-1.1.jar").exists()); 75 76 assertTrue(new File ("build/test/install/org1/mod1.2/ivy-2.0.xml").exists()); 77 assertTrue(new File ("build/test/install/org1/mod1.2/mod1.2-2.0.jar").exists()); 78 79 assertTrue(new File ("build/test/install/org1/mod1.3/ivy-B-3.0.xml").exists()); 82 assertTrue(new File ("build/test/install/org1/mod1.3/ivy-A-3.0.xml").exists()); 83 assertTrue(new File ("build/test/install/org1/mod1.3/mod1.3-A-3.0.jar").exists()); 84 assertTrue(new File ("build/test/install/org1/mod1.3/mod1.3-B-3.0.jar").exists()); 85 86 assertTrue(new File ("build/test/install/org1/mod1.4/ivy-1.0.1.xml").exists()); 87 } 88 89 90 91 private File _cache; 92 protected void setUp() throws Exception { 93 createCache(); 94 } 95 96 private void createCache() { 97 _cache = new File ("build/cache"); 98 _cache.mkdirs(); 99 } 100 101 protected void tearDown() throws Exception { 102 cleanCache(); 103 cleanInstall(); 104 } 105 106 private void cleanCache() { 107 Delete del = new Delete(); 108 del.setProject(new Project()); 109 del.setDir(_cache); 110 del.execute(); 111 } 112 private void cleanInstall() { 113 Delete del = new Delete(); 114 del.setProject(new Project()); 115 del.setDir(new File ("build/test/install")); 116 del.execute(); 117 } 118 } 119 | Popular Tags |