KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > ant > IvyFindRevisionTest


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * #SNAPSHOT#
5  */

6 package fr.jayasoft.ivy.ant;
7
8 import java.io.File JavaDoc;
9
10 import junit.framework.TestCase;
11
12 import org.apache.tools.ant.Project;
13 import org.apache.tools.ant.taskdefs.Delete;
14
15 public class IvyFindRevisionTest extends TestCase {
16     private File JavaDoc _cache;
17     private IvyFindRevision _findRevision;
18     
19     protected void setUp() throws Exception JavaDoc {
20         createCache();
21         Project project = new Project();
22         project.setProperty("ivy.conf.file", "test/repositories/ivyconf.xml");
23
24         _findRevision = new IvyFindRevision();
25         _findRevision.setProject(project);
26     }
27
28     private void createCache() {
29         _cache = new File JavaDoc("build/cache");
30         _cache.mkdirs();
31     }
32     
33     protected void tearDown() throws Exception JavaDoc {
34         cleanCache();
35     }
36
37     private void cleanCache() {
38         Delete del = new Delete();
39         del.setProject(new Project());
40         del.setDir(_cache);
41         del.execute();
42     }
43
44     public void testProperty() throws Exception JavaDoc {
45         _findRevision.setOrganisation("org1");
46         _findRevision.setModule("mod1.1");
47         _findRevision.setRevision("1.0");
48         _findRevision.setProperty("test.revision");
49         _findRevision.execute();
50         assertEquals("1.0", _findRevision.getProject().getProperty("test.revision"));
51     }
52     
53     public void testLatest() throws Exception JavaDoc {
54         _findRevision.setOrganisation("org1");
55         _findRevision.setModule("mod1.1");
56         _findRevision.setRevision("latest.integration");
57         _findRevision.execute();
58         assertEquals("2.0", _findRevision.getProject().getProperty("ivy.revision"));
59     }
60     
61     public void testLatestSubversion() throws Exception JavaDoc {
62         _findRevision.setOrganisation("org1");
63         _findRevision.setModule("mod1.1");
64         _findRevision.setRevision("1.0+");
65         _findRevision.execute();
66         assertEquals("1.0.1", _findRevision.getProject().getProperty("ivy.revision"));
67     }
68     
69 }
70
Popular Tags