KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > IntrospectionHelperTest


1 /*
2  * Copyright 2000-2001,2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 package org.apache.tools.ant;
19
20 import junit.framework.TestCase;
21 import junit.framework.AssertionFailedError;
22 import java.io.File JavaDoc;
23 import java.lang.reflect.Method JavaDoc;
24 import java.lang.reflect.InvocationTargetException JavaDoc;
25 import java.util.Collections JavaDoc;
26 import java.util.Enumeration JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.Hashtable JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Locale JavaDoc;
32 import java.util.Map JavaDoc;
33 import org.apache.tools.ant.taskdefs.condition.Os;
34
35 /**
36  * JUnit 3 testcases for org.apache.tools.ant.IntrospectionHelper.
37  *
38  */

39
40 public class IntrospectionHelperTest extends TestCase {
41
42     private Project p;
43     private IntrospectionHelper ih;
44     private static final String JavaDoc projectBasedir = File.separator;
45
46     public IntrospectionHelperTest(String JavaDoc name) {
47         super(name);
48     }
49
50     public void setUp() {
51         p = new Project();
52         p.setBasedir(projectBasedir);
53         ih = IntrospectionHelper.getHelper(getClass());
54     }
55
56     public void testIsDynamic() {
57         assertTrue("Not dynamic", false == ih.isDynamic());
58     }
59
60     public void testIsContainer() {
61         assertTrue("Not a container", false == ih.isContainer());
62     }
63
64     public void testAddText() throws BuildException {
65         ih.addText(p, this, "test");
66         try {
67             ih.addText(p, this, "test2");
68             fail("test2 shouldn\'t be equal to test");
69         } catch (BuildException be) {
70             assertTrue(be.getException() instanceof AssertionFailedError);
71         }
72
73         ih = IntrospectionHelper.getHelper(String JavaDoc.class);
74         try {
75             ih.addText(p, "", "test");
76             fail("String doesn\'t support addText");
77         } catch (BuildException be) {
78         }
79     }
80
81     public void testGetAddTextMethod() {
82         Method JavaDoc m = ih.getAddTextMethod();
83         assertMethod(m, "addText", String JavaDoc.class, "test", "bing!");
84
85         ih = IntrospectionHelper.getHelper(String JavaDoc.class);
86         try {
87             m = ih.getAddTextMethod();
88         } catch (BuildException e) {}
89     }
90
91     public void testSupportsCharacters() {
92         assertTrue("IntrospectionHelperTest supports addText",
93                    ih.supportsCharacters());
94
95         ih = IntrospectionHelper.getHelper(String JavaDoc.class);
96         assertTrue("String doesn\'t support addText", !ih.supportsCharacters());
97     }
98
99     public void addText(String JavaDoc text) {
100         assertEquals("test", text);
101     }
102
103     public void testElementCreators() throws BuildException {
104         try {
105             ih.getElementType("one");
106             fail("don't have element type one");
107         } catch (BuildException be) {
108         }
109         try {
110             ih.getElementType("two");
111             fail("createTwo takes arguments");
112         } catch (BuildException be) {
113         }
114         try {
115             ih.getElementType("three");
116             fail("createThree returns void");
117         } catch (BuildException be) {
118         }
119         try {
120             ih.getElementType("four");
121             fail("createFour returns array");
122         } catch (BuildException be) {
123         }
124         try {
125             ih.getElementType("five");
126             fail("createFive returns primitive type");
127         } catch (BuildException be) {
128         }
129         assertEquals(String JavaDoc.class, ih.getElementType("six"));
130         assertEquals("test", ih.createElement(p, this, "six"));
131
132         try {
133             ih.getElementType("seven");
134             fail("addSeven takes two arguments");
135         } catch (BuildException be) {
136         }
137         try {
138             ih.getElementType("eight");
139             fail("addEight takes no arguments");
140         } catch (BuildException be) {
141         }
142         try {
143             ih.getElementType("nine");
144             fail("nine return non void");
145         } catch (BuildException be) {
146         }
147         try {
148             ih.getElementType("ten");
149             fail("addTen takes array argument");
150         } catch (BuildException be) {
151         }
152         try {
153             ih.getElementType("eleven");
154             fail("addEleven takes primitive argument");
155         } catch (BuildException be) {
156         }
157         try {
158             ih.getElementType("twelve");
159             fail("no primitive constructor for java.lang.Class");
160         } catch (BuildException be) {
161         }
162         assertEquals(StringBuffer JavaDoc.class, ih.getElementType("thirteen"));
163         assertEquals("test", ih.createElement(p, this, "thirteen").toString());
164
165         try {
166             ih.createElement(p, this, "fourteen");
167             fail("fourteen throws NullPointerException");
168         } catch (BuildException be) {
169             assertTrue(be.getException() instanceof NullPointerException JavaDoc);
170         }
171
172         try {
173             ih.createElement(p, this, "fourteen");
174             fail("fifteen throws NullPointerException");
175         } catch (BuildException be) {
176             assertTrue(be.getException() instanceof NullPointerException JavaDoc);
177         }
178     }
179
180     private Map JavaDoc getExpectedNestedElements() {
181         Map JavaDoc elemMap = new Hashtable JavaDoc();
182         elemMap.put("six", String JavaDoc.class);
183         elemMap.put("thirteen", StringBuffer JavaDoc.class);
184         elemMap.put("fourteen", StringBuffer JavaDoc.class);
185         elemMap.put("fifteen", StringBuffer JavaDoc.class);
186         return elemMap;
187     }
188
189     public void testGetNestedElements() {
190         Map JavaDoc elemMap = getExpectedNestedElements();
191         Enumeration JavaDoc e = ih.getNestedElements();
192         while (e.hasMoreElements()) {
193             String JavaDoc name = (String JavaDoc) e.nextElement();
194             Class JavaDoc expect = (Class JavaDoc) elemMap.get(name);
195             assertNotNull("Support for "+name+" in IntrospectioNHelperTest?",
196                           expect);
197             assertEquals("Return type of "+name, expect, ih.getElementType(name));
198             elemMap.remove(name);
199         }
200         assertTrue("Found all", elemMap.isEmpty());
201     }
202
203     public void testGetNestedElementMap() {
204         Map JavaDoc elemMap = getExpectedNestedElements();
205         Map JavaDoc actualMap = ih.getNestedElementMap();
206         for (Iterator JavaDoc i = actualMap.entrySet().iterator(); i.hasNext();) {
207             Map.Entry JavaDoc entry = (Map.Entry JavaDoc) i.next();
208             String JavaDoc elemName = (String JavaDoc) entry.getKey();
209             Class JavaDoc elemClass = (Class JavaDoc) elemMap.get(elemName);
210             assertNotNull("Support for " + elemName +
211                           " in IntrospectionHelperTest?", elemClass);
212             assertEquals("Type of " + elemName, elemClass, entry.getValue());
213             elemMap.remove(elemName);
214         }
215         assertTrue("Found all", elemMap.isEmpty());
216
217         // Check it's a read-only map.
218
try {
219             actualMap.clear();
220         } catch (UnsupportedOperationException JavaDoc e) {}
221     }
222
223     public void testGetElementMethod() {
224         assertElemMethod("six", "createSix", String JavaDoc.class, null);
225         assertElemMethod("thirteen", "addThirteen", null, StringBuffer JavaDoc.class);
226         assertElemMethod("fourteen", "addFourteen", null, StringBuffer JavaDoc.class);
227         assertElemMethod("fifteen", "createFifteen", StringBuffer JavaDoc.class, null);
228     }
229
230     private void assertElemMethod(String JavaDoc elemName, String JavaDoc methodName,
231                                   Class JavaDoc returnType, Class JavaDoc methodArg) {
232         Method JavaDoc m = ih.getElementMethod(elemName);
233         assertEquals("Method name", methodName, m.getName());
234         Class JavaDoc expectedReturnType = (returnType == null)? Void.TYPE: returnType;
235         assertEquals("Return type", expectedReturnType, m.getReturnType());
236         Class JavaDoc[] args = m.getParameterTypes();
237         if (methodArg != null) {
238             assertEquals("Arg Count", 1, args.length);
239             assertEquals("Arg Type", methodArg, args[0]);
240         } else {
241             assertEquals("Arg Count", 0, args.length);
242         }
243     }
244
245     public Object JavaDoc createTwo(String JavaDoc s) {
246         return null;
247     }
248
249     public void createThree() {}
250
251     public Object JavaDoc[] createFour() {
252         return null;
253     }
254
255     public int createFive() {
256         return 0;
257     }
258
259     public String JavaDoc createSix() {
260         return "test";
261     }
262
263     public StringBuffer JavaDoc createFifteen() {
264         throw new NullPointerException JavaDoc();
265     }
266
267     public void addSeven(String JavaDoc s, String JavaDoc s2) {}
268
269     public void addEight() {}
270
271     public String JavaDoc addNine(String JavaDoc s) {
272         return null;
273     }
274
275     public void addTen(String JavaDoc[] s) {}
276
277     public void addEleven(int i) {}
278
279     public void addTwelve(Class JavaDoc c) {}
280
281     public void addThirteen(StringBuffer JavaDoc sb) {
282         sb.append("test");
283     }
284
285     public void addFourteen(StringBuffer JavaDoc s) {
286         throw new NullPointerException JavaDoc();
287     }
288
289     public void testAttributeSetters() throws BuildException {
290         try {
291             ih.setAttribute(p, this, "one", "test");
292             fail("setOne doesn't exist");
293         } catch (BuildException be) {
294         }
295         try {
296             ih.setAttribute(p, this, "two", "test");
297             fail("setTwo returns non void");
298         } catch (BuildException be) {
299         }
300         try {
301             ih.setAttribute(p, this, "three", "test");
302             fail("setThree takes no args");
303         } catch (BuildException be) {
304         }
305         try {
306             ih.setAttribute(p, this, "four", "test");
307             fail("setFour takes two args");
308         } catch (BuildException be) {
309         }
310         try {
311             ih.setAttribute(p, this, "five", "test");
312             fail("setFive takes array arg");
313         } catch (BuildException be) {
314         }
315         try {
316             ih.setAttribute(p, this, "six", "test");
317             fail("Project doesn't have a String constructor");
318         } catch (BuildException be) {
319         }
320         ih.setAttribute(p, this, "seven", "2");
321         try {
322             ih.setAttribute(p, this, "seven", "3");
323             fail("2 shouldn't be equals to three");
324         } catch (BuildException be) {
325             assertTrue(be.getException() instanceof AssertionFailedError);
326         }
327         ih.setAttribute(p, this, "eight", "2");
328         try {
329             ih.setAttribute(p, this, "eight", "3");
330             fail("2 shouldn't be equals to three - as int");
331         } catch (BuildException be) {
332             assertTrue(be.getException() instanceof AssertionFailedError);
333         }
334         ih.setAttribute(p, this, "nine", "2");
335         try {
336             ih.setAttribute(p, this, "nine", "3");
337             fail("2 shouldn't be equals to three - as Integer");
338         } catch (BuildException be) {
339             assertTrue(be.getException() instanceof AssertionFailedError);
340         }
341         ih.setAttribute(p, this, "ten", "2");
342         try {
343             ih.setAttribute(p, this, "ten", "3");
344             fail(projectBasedir+"2 shouldn't be equals to "+projectBasedir+"3");
345         } catch (BuildException be) {
346             assertTrue(be.getException() instanceof AssertionFailedError);
347         }
348         ih.setAttribute(p, this, "eleven", "2");
349         try {
350             ih.setAttribute(p, this, "eleven", "on");
351             fail("on shouldn't be false");
352         } catch (BuildException be) {
353             assertTrue(be.getException() instanceof AssertionFailedError);
354         }
355         ih.setAttribute(p, this, "twelve", "2");
356         try {
357             ih.setAttribute(p, this, "twelve", "on");
358             fail("on shouldn't be false");
359         } catch (BuildException be) {
360             assertTrue(be.getException() instanceof AssertionFailedError);
361         }
362         ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project");
363         try {
364             ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.ProjectHelper");
365             fail("org.apache.tools.ant.Project shouldn't be equal to org.apache.tools.ant.ProjectHelper");
366         } catch (BuildException be) {
367             assertTrue(be.getException() instanceof AssertionFailedError);
368         }
369         try {
370             ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project2");
371             fail("org.apache.tools.ant.Project2 doesn't exist");
372         } catch (BuildException be) {
373             assertTrue(be.getException() instanceof ClassNotFoundException JavaDoc);
374         }
375         ih.setAttribute(p, this, "fourteen", "2");
376         try {
377             ih.setAttribute(p, this, "fourteen", "on");
378             fail("2 shouldn't be equals to three - as StringBuffer");
379         } catch (BuildException be) {
380             assertTrue(be.getException() instanceof AssertionFailedError);
381         }
382         ih.setAttribute(p, this, "fifteen", "abcd");
383         try {
384             ih.setAttribute(p, this, "fifteen", "on");
385             fail("o shouldn't be equal to a");
386         } catch (BuildException be) {
387             assertTrue(be.getException() instanceof AssertionFailedError);
388         }
389         ih.setAttribute(p, this, "sixteen", "abcd");
390         try {
391             ih.setAttribute(p, this, "sixteen", "on");
392             fail("o shouldn't be equal to a");
393         } catch (BuildException be) {
394             assertTrue(be.getException() instanceof AssertionFailedError);
395         }
396         ih.setAttribute(p, this, "seventeen", "17");
397         try {
398             ih.setAttribute(p, this, "seventeen", "3");
399             fail("17 shouldn't be equals to three");
400         } catch (BuildException be) {
401             assertTrue(be.getException() instanceof AssertionFailedError);
402         }
403         ih.setAttribute(p, this, "eightteen", "18");
404         try {
405             ih.setAttribute(p, this, "eightteen", "3");
406             fail("18 shouldn't be equals to three");
407         } catch (BuildException be) {
408             assertTrue(be.getException() instanceof AssertionFailedError);
409         }
410         ih.setAttribute(p, this, "nineteen", "19");
411         try {
412             ih.setAttribute(p, this, "nineteen", "3");
413             fail("19 shouldn't be equals to three");
414         } catch (BuildException be) {
415             assertTrue(be.getException() instanceof AssertionFailedError);
416         }
417     }
418
419     private Map JavaDoc getExpectedAttributes() {
420         Map JavaDoc attrMap = new Hashtable JavaDoc();
421         attrMap.put("seven", String JavaDoc.class);
422         attrMap.put("eight", Integer.TYPE);
423         attrMap.put("nine", Integer JavaDoc.class);
424         attrMap.put("ten", File JavaDoc.class);
425         attrMap.put("eleven", Boolean.TYPE);
426         attrMap.put("twelve", Boolean JavaDoc.class);
427         attrMap.put("thirteen", Class JavaDoc.class);
428         attrMap.put("fourteen", StringBuffer JavaDoc.class);
429         attrMap.put("fifteen", Character.TYPE);
430         attrMap.put("sixteen", Character JavaDoc.class);
431         attrMap.put("seventeen", Byte.TYPE);
432         attrMap.put("eightteen", Short.TYPE);
433         attrMap.put("nineteen", Double.TYPE);
434
435         /*
436          * JUnit 3.7 adds a getName method to TestCase - so we now
437          * have a name attribute in IntrospectionHelperTest if we run
438          * under JUnit 3.7 but not in earlier versions.
439          *
440          * Simply add it here and remove it after the tests.
441          */

442         attrMap.put("name", String JavaDoc.class);
443
444         return attrMap;
445     }
446
447     public void testGetAttributes() {
448         Map JavaDoc attrMap = getExpectedAttributes();
449         Enumeration JavaDoc e = ih.getAttributes();
450         while (e.hasMoreElements()) {
451             String JavaDoc name = (String JavaDoc) e.nextElement();
452             Class JavaDoc expect = (Class JavaDoc) attrMap.get(name);
453             assertNotNull("Support for "+name+" in IntrospectionHelperTest?",
454                           expect);
455             assertEquals("Type of "+name, expect, ih.getAttributeType(name));
456             attrMap.remove(name);
457         }
458         attrMap.remove("name");
459         assertTrue("Found all", attrMap.isEmpty());
460     }
461
462     public void testGetAttributeMap() {
463         Map JavaDoc attrMap = getExpectedAttributes();
464         Map JavaDoc actualMap = ih.getAttributeMap();
465         for (Iterator JavaDoc i = actualMap.entrySet().iterator(); i.hasNext();) {
466             Map.Entry JavaDoc entry = (Map.Entry JavaDoc) i.next();
467             String JavaDoc attrName = (String JavaDoc) entry.getKey();
468             Class JavaDoc attrClass = (Class JavaDoc) attrMap.get(attrName);
469             assertNotNull("Support for " + attrName +
470                           " in IntrospectionHelperTest?", attrClass);
471             assertEquals("Type of " + attrName, attrClass, entry.getValue());
472             attrMap.remove(attrName);
473         }
474         attrMap.remove("name");
475         assertTrue("Found all", attrMap.isEmpty());
476
477         // Check it's a read-only map.
478
try {
479             actualMap.clear();
480         } catch (UnsupportedOperationException JavaDoc e) {}
481     }
482
483     public void testGetAttributeMethod() {
484         assertAttrMethod("seven", "setSeven", String JavaDoc.class,
485                          "2", "3");
486         assertAttrMethod("eight", "setEight", Integer.TYPE,
487                          new Integer JavaDoc(2), new Integer JavaDoc(3));
488         assertAttrMethod("nine", "setNine", Integer JavaDoc.class,
489                          new Integer JavaDoc(2), new Integer JavaDoc(3));
490         assertAttrMethod("ten", "setTen", File JavaDoc.class,
491                          new File JavaDoc(projectBasedir + 2), new File JavaDoc("toto"));
492         assertAttrMethod("eleven", "setEleven", Boolean.TYPE,
493                          Boolean.FALSE, Boolean.TRUE);
494         assertAttrMethod("twelve", "setTwelve", Boolean JavaDoc.class,
495                          Boolean.FALSE, Boolean.TRUE);
496         assertAttrMethod("thirteen", "setThirteen", Class JavaDoc.class,
497                          Project.class, Map JavaDoc.class);
498         assertAttrMethod("fourteen", "setFourteen", StringBuffer JavaDoc.class,
499                          new StringBuffer JavaDoc("2"), new StringBuffer JavaDoc("3"));
500         assertAttrMethod("fifteen", "setFifteen", Character.TYPE,
501                          new Character JavaDoc('a'), new Character JavaDoc('b'));
502         assertAttrMethod("sixteen", "setSixteen", Character JavaDoc.class,
503                          new Character JavaDoc('a'), new Character JavaDoc('b'));
504         assertAttrMethod("seventeen", "setSeventeen", Byte.TYPE,
505                          new Byte JavaDoc((byte)17), new Byte JavaDoc((byte)10));
506         assertAttrMethod("eightteen", "setEightteen", Short.TYPE,
507                          new Short JavaDoc((short)18), new Short JavaDoc((short)10));
508         assertAttrMethod("nineteen", "setNineteen", Double.TYPE,
509                          new Double JavaDoc(19), new Double JavaDoc((short)10));
510
511         try {
512             assertAttrMethod("onehundred", null, null, null, null);
513             fail("Should have raised a BuildException!");
514         } catch (BuildException e) {}
515     }
516
517     private void assertAttrMethod(String JavaDoc attrName, String JavaDoc methodName,
518                                   Class JavaDoc methodArg, Object JavaDoc arg, Object JavaDoc badArg) {
519         Method JavaDoc m = ih.getAttributeMethod(attrName);
520         assertMethod(m, methodName, methodArg, arg, badArg);
521     }
522
523     public int setTwo(String JavaDoc s) {
524         return 0;
525     }
526
527     public void setThree() {}
528
529     public void setFour(String JavaDoc s1, String JavaDoc s2) {}
530
531     public void setFive(String JavaDoc[] s) {}
532
533     public void setSix(Project p) {}
534
535     public void setSeven(String JavaDoc s) {
536         assertEquals("2", s);
537     }
538
539     public void setEight(int i) {
540         assertEquals(2, i);
541     }
542
543     public void setNine(Integer JavaDoc i) {
544         assertEquals(2, i.intValue());
545     }
546
547     public void setTen(File JavaDoc f) {
548         String JavaDoc path = f.getAbsolutePath();
549         if (Os.isFamily("unix") || Os.isFamily("openvms")) {
550             assertEquals(projectBasedir+"2", path);
551         } else if (Os.isFamily("netware")) {
552             assertEquals(projectBasedir+"2", path.toLowerCase(Locale.US));
553         } else {
554             assertEquals(":"+projectBasedir+"2",
555                          path.toLowerCase(Locale.US).substring(1));
556         }
557     }
558
559     public void setEleven(boolean b) {
560         assertTrue(!b);
561     }
562
563     public void setTwelve(Boolean JavaDoc b) {
564         assertTrue(!b.booleanValue());
565     }
566
567     public void setThirteen(Class JavaDoc c) {
568         assertEquals(Project.class, c);
569     }
570
571     public void setFourteen(StringBuffer JavaDoc sb) {
572         assertEquals("2", sb.toString());
573     }
574
575     public void setFifteen(char c) {
576         assertEquals(c, 'a');
577     }
578
579     public void setSixteen(Character JavaDoc c) {
580         assertEquals(c.charValue(), 'a');
581     }
582
583     public void setSeventeen(byte b) {
584         assertEquals(17, b);
585     }
586
587     public void setEightteen(short s) {
588         assertEquals(18, s);
589     }
590
591     public void setNineteen(double d) {
592         assertEquals(19, d, 1e-6);
593     }
594
595     public void testGetExtensionPoints() {
596         List JavaDoc extensions = ih.getExtensionPoints();
597         final int adders = 2;
598         assertEquals("extension count", adders, extensions.size());
599
600         // this original test assumed something about the order of
601
// add(Number) and addConfigured(Map) returned by reflection.
602
// Unfortunately the assumption doesn't hold for all VMs
603
// (failed on MacOS X using JDK 1.4.2_05) and the possible
604
// combinatorics are too hard to check. We really only want
605
// to ensure that the more derived Hashtable can be found
606
// before Map.
607
// assertExtMethod(extensions.get(0), "add", Number.class,
608
// new Integer(2), new Integer(3));
609

610         // addConfigured(Hashtable) should come before addConfigured(Map)
611
assertExtMethod(extensions.get(adders - 2),
612                         "addConfigured", Hashtable JavaDoc.class,
613                         makeTable("key", "value"), makeTable("1", "2"));
614
615         assertExtMethod(extensions.get(adders - 1), "addConfigured", Map JavaDoc.class,
616                         new HashMap JavaDoc(), makeTable("1", "2"));
617     }
618
619     private void assertExtMethod(Object JavaDoc mo, String JavaDoc methodName, Class JavaDoc methodArg,
620                                  Object JavaDoc arg, Object JavaDoc badArg) {
621         assertMethod((Method JavaDoc) mo, methodName, methodArg, arg, badArg);
622     }
623
624     private void assertMethod(Method JavaDoc m, String JavaDoc methodName, Class JavaDoc methodArg,
625                               Object JavaDoc arg, Object JavaDoc badArg) {
626         assertEquals("Method name", methodName, m.getName());
627         assertEquals("Return type", Void.TYPE, m.getReturnType());
628         Class JavaDoc[] args = m.getParameterTypes();
629         assertEquals("Arg Count", 1, args.length);
630         assertEquals("Arg Type", methodArg, args[0]);
631
632         try {
633             m.invoke(this, new Object JavaDoc[] { arg });
634         } catch (IllegalAccessException JavaDoc e) {
635             throw new BuildException(e);
636         } catch (InvocationTargetException JavaDoc e) {
637             throw new BuildException(e);
638         }
639
640         try {
641             m.invoke(this, new Object JavaDoc[] { badArg });
642             fail("Should have raised an assertion exception");
643         } catch (IllegalAccessException JavaDoc e) {
644             throw new BuildException(e);
645         } catch (InvocationTargetException JavaDoc e) {
646             Throwable JavaDoc t = e.getTargetException();
647             assertTrue(t instanceof junit.framework.AssertionFailedError);
648         }
649     }
650
651     public List JavaDoc add(List JavaDoc l) {
652         // INVALID extension point
653
return null;
654     }
655
656     // see comments in testGetExtensionPoints
657
// public void add(Number n) {
658
// // Valid extension point
659
// assertEquals(2, n.intValue());
660
// }
661

662     public void add(List JavaDoc l, int i) {
663         // INVALID extension point
664
}
665
666     public void addConfigured(Map JavaDoc m) {
667         // Valid extension point
668
assertTrue(m.size() == 0);
669     }
670
671     public void addConfigured(Hashtable JavaDoc h) {
672         // Valid extension point, more derived than Map above, but *after* it!
673
assertEquals(makeTable("key", "value"), h);
674     }
675
676     private Hashtable JavaDoc makeTable(Object JavaDoc key, Object JavaDoc value) {
677         Hashtable JavaDoc table = new Hashtable JavaDoc();
678         table.put(key, value);
679         return table;
680     }
681
682 } // IntrospectionHelperTest
683

684
Popular Tags