KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > classman > verifier > test > VerifierTestCase


1 /*
2  * Copyright (C) The Spice Group. All rights reserved.
3  *
4  * This software is published under the terms of the Spice
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.loom.classman.verifier.test;
9
10 import org.codehaus.loom.classman.metadata.ClassLoaderSetMetaData;
11 import org.codehaus.loom.classman.test.AbstractLoaderTestCase;
12 import org.codehaus.loom.classman.verifier.ClassLoaderVerifier;
13
14 /**
15  * TestCase for {@link org.codehaus.loom.classman.reader.ClassLoaderSetReader}.
16  *
17  * @author Peter Donald
18  */

19 public class VerifierTestCase
20     extends AbstractLoaderTestCase
21 {
22     public void testConfig1()
23         throws Exception JavaDoc
24     {
25         try
26         {
27             verifyResource( "config1.xml" );
28         }
29         catch( final Throwable JavaDoc t )
30         {
31             return;
32         }
33
34         fail( "Expected verify to fail as specified " +
35               "bad name for join" );
36     }
37
38     public void testConfig2()
39         throws Exception JavaDoc
40     {
41         try
42         {
43             verifyResource( "config2.xml" );
44         }
45         catch( final Throwable JavaDoc t )
46         {
47             return;
48         }
49
50         fail( "Expected verify to fail as specified " +
51               "bad name for classloader" );
52     }
53
54     public void testConfig3()
55         throws Exception JavaDoc
56     {
57         try
58         {
59             verifyResource( "config3.xml" );
60         }
61         catch( final Throwable JavaDoc t )
62         {
63             return;
64         }
65
66         fail( "Expected verify to fail as specified " +
67               "bad parent for classloader" );
68     }
69
70     public void testConfig4()
71         throws Exception JavaDoc
72     {
73         try
74         {
75             verifyResource( "config4.xml" );
76         }
77         catch( final Throwable JavaDoc t )
78         {
79             return;
80         }
81
82         fail( "Expected verify to fail as specified " +
83               "non existing ClassLoader in Join " +
84               "classloader-ref" );
85     }
86
87     public void testConfig5()
88         throws Exception JavaDoc
89     {
90         try
91         {
92             verifyResource( "config5.xml" );
93         }
94         catch( final Throwable JavaDoc t )
95         {
96             return;
97         }
98
99         fail( "Expected verify to fail as specified " +
100               "default classloader does not exist." );
101     }
102
103     public void testConfig6()
104         throws Exception JavaDoc
105     {
106         try
107         {
108             verifyResource( "config6.xml" );
109         }
110         catch( final Throwable JavaDoc t )
111         {
112             return;
113         }
114
115         fail( "Expected verify to fail as specified " +
116               "join classloader links against same " +
117               "classloader multiple times." );
118     }
119
120     public void testConfig7()
121         throws Exception JavaDoc
122     {
123         try
124         {
125             verifyResource( "config7.xml" );
126         }
127         catch( final Throwable JavaDoc t )
128         {
129             return;
130         }
131
132         fail( "Expected verify to fail as specified " +
133               "classloader has entry multiple times." );
134     }
135
136     public void testConfig8()
137         throws Exception JavaDoc
138     {
139         try
140         {
141             verifyResource( "config8.xml" );
142         }
143         catch( final Throwable JavaDoc t )
144         {
145             return;
146         }
147
148         fail( "Expected verify to fail as a " +
149               "join had same name as another join." );
150     }
151
152     public void testConfig9()
153         throws Exception JavaDoc
154     {
155         try
156         {
157             verifyResource( "config9.xml" );
158         }
159         catch( final Throwable JavaDoc t )
160         {
161             return;
162         }
163
164         fail( "Expected verify to fail as a " +
165               "join had same name as a " +
166               "classloader." );
167     }
168
169     public void testConfig10()
170         throws Exception JavaDoc
171     {
172         try
173         {
174             verifyResource( "config10.xml" );
175         }
176         catch( final Throwable JavaDoc t )
177         {
178             return;
179         }
180
181         fail( "Expected verify to fail as a " +
182               "join had same name as another " +
183               "predefined classloader." );
184     }
185
186     public void testConfig11()
187         throws Exception JavaDoc
188     {
189         try
190         {
191             verifyResource( "config11.xml" );
192         }
193         catch( final Throwable JavaDoc t )
194         {
195             return;
196         }
197
198         fail( "Expected verify to fail as a " +
199               "classloader had same name as another " +
200               "classloader." );
201     }
202
203     public void testConfig12()
204         throws Exception JavaDoc
205     {
206         try
207         {
208             verifyResource( "config12.xml" );
209         }
210         catch( final Throwable JavaDoc t )
211         {
212             return;
213         }
214
215         fail( "Expected verify to fail as a " +
216               "classloader had same name as a " +
217               "predefined classloader." );
218     }
219
220     public void testConfig13()
221         throws Exception JavaDoc
222     {
223         try
224         {
225             final ClassLoaderSetMetaData defs =
226                 buildFromResource( "config13.xml" );
227             verify( defs );
228         }
229         catch( final Throwable JavaDoc t )
230         {
231             return;
232         }
233
234         fail( "Expected verify to fail as a " +
235               "predefined had same name as another " +
236               "predefined." );
237     }
238
239     public void testConfig14()
240         throws Exception JavaDoc
241     {
242         try
243         {
244             final ClassLoaderSetMetaData defs =
245                 buildFromResource( "config14.xml" );
246             verify( defs );
247         }
248         catch( final Throwable JavaDoc t )
249         {
250             return;
251         }
252
253         fail( "Expected verify to fail as a " +
254               "predefined an empty name." );
255     }
256
257     public void testConfig15()
258         throws Exception JavaDoc
259     {
260         try
261         {
262             final ClassLoaderSetMetaData defs =
263                 buildFromResource( "config15.xml" );
264             verify( defs );
265         }
266         catch( final Throwable JavaDoc t )
267         {
268             return;
269         }
270
271         fail( "Expected verify to fail as a " +
272               "predefined has same name as join." );
273     }
274
275     public void testConfig16()
276         throws Exception JavaDoc
277     {
278         try
279         {
280             final ClassLoaderSetMetaData defs =
281                 buildFromResource( "config16.xml" );
282             verify( defs );
283         }
284         catch( final Throwable JavaDoc t )
285         {
286             fail( "Should be able to have a join as default classloader." );
287         }
288     }
289
290     public void testConfig17()
291         throws Exception JavaDoc
292     {
293         try
294         {
295             verifyResource( "config17.xml" );
296         }
297         catch( final Throwable JavaDoc t )
298         {
299             fail( "Expected verify to pass" );
300         }
301     }
302
303     private void verifyResource( final String JavaDoc resource )
304         throws Exception JavaDoc
305     {
306         final ClassLoaderSetMetaData defs = buildFromResource( resource );
307         verify( defs );
308     }
309
310     private void verify( final ClassLoaderSetMetaData defs )
311         throws Exception JavaDoc
312     {
313         final ClassLoaderVerifier verifier = new ClassLoaderVerifier();
314         verifier.verifyClassLoaderSet( defs );
315     }
316 }
317
Popular Tags