KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > resolver > ResolverTestHelper


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.resolver;
7
8 import junit.framework.Assert;
9 import fr.jayasoft.ivy.DependencyResolver;
10
11 /**
12  *
13  */

14 public class ResolverTestHelper {
15     static void assertOrganisationEntries(DependencyResolver resolver, String JavaDoc[] orgNames, OrganisationEntry[] orgs) {
16         Assert.assertNotNull(orgs);
17         Assert.assertEquals(orgNames.length, orgs.length);
18         assertOrganisationEntriesContains(resolver, orgNames, orgs);
19     }
20     
21     static void assertOrganisationEntriesContains(DependencyResolver resolver, String JavaDoc[] orgNames, OrganisationEntry[] orgs) {
22         Assert.assertNotNull(orgs);
23         for (int i = 0; i < orgNames.length; i++) {
24             boolean found = false;
25             for (int j = 0; j < orgs.length; j++) {
26                 if (orgNames[i].equals(orgs[j].getOrganisation())) {
27                     found = true;
28                     Assert.assertEquals(resolver, orgs[j].getResolver());
29                 }
30             }
31             Assert.assertTrue("organisation not found: "+orgNames[i], found);
32         }
33     }
34     
35     static void assertModuleEntries(DependencyResolver resolver, OrganisationEntry org, String JavaDoc[] names, ModuleEntry[] mods) {
36         Assert.assertNotNull(mods);
37         Assert.assertEquals(names.length, mods.length);
38         assertModuleEntriesContains(resolver, org, names, mods);
39     }
40     
41     
42     static void assertModuleEntriesContains(DependencyResolver resolver, OrganisationEntry org, String JavaDoc[] names, ModuleEntry[] mods) {
43         Assert.assertNotNull(mods);
44         for (int i = 0; i < names.length; i++) {
45             boolean found = false;
46             for (int j = 0; j < mods.length; j++) {
47                 if (names[i].equals(mods[j].getModule())) {
48                     found = true;
49                     Assert.assertEquals(resolver, mods[j].getResolver());
50                     Assert.assertEquals(org, mods[j].getOrganisationEntry());
51                 }
52             }
53             Assert.assertTrue("module not found: "+names[i], found);
54         }
55     }
56     
57     
58     static void assertRevisionEntries(DependencyResolver resolver, ModuleEntry mod, String JavaDoc[] names, RevisionEntry[] revs) {
59         Assert.assertNotNull(revs);
60         Assert.assertEquals(names.length, revs.length);
61         assertRevisionEntriesContains(resolver, mod, names, revs);
62     }
63     
64     static void assertRevisionEntriesContains(DependencyResolver resolver, ModuleEntry mod, String JavaDoc[] names, RevisionEntry[] revs) {
65         Assert.assertNotNull(revs);
66         for (int i = 0; i < names.length; i++) {
67             boolean found = false;
68             for (int j = 0; j < revs.length; j++) {
69                 if (names[i].equals(revs[j].getRevision())) {
70                     found = true;
71                     Assert.assertEquals(resolver, revs[j].getResolver());
72                     Assert.assertEquals(mod, revs[j].getModuleEntry());
73                 }
74             }
75             Assert.assertTrue("revision not found: "+names[i], found);
76         }
77     }
78     
79     static OrganisationEntry getEntry(OrganisationEntry[] orgs, String JavaDoc name) {
80         for (int i = 0; i < orgs.length; i++) {
81             if (name.equals(orgs[i].getOrganisation())) {
82                 return orgs[i];
83             }
84         }
85         Assert.fail("organisation not found: "+name);
86         return null; // for compilation only
87
}
88     
89     static ModuleEntry getEntry(ModuleEntry[] mods, String JavaDoc name) {
90         for (int i = 0; i < mods.length; i++) {
91             if (name.equals(mods[i].getModule())) {
92                 return mods[i];
93             }
94         }
95         Assert.fail("module not found: "+name);
96         return null; // for compilation only
97
}
98     
99 }
100
Popular Tags