KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > monitor > model > DescriberTest


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.monitor.model;
5
6 import java.util.HashMap JavaDoc;
7 import java.util.Map JavaDoc;
8
9 import junit.framework.TestCase;
10
11 import org.oddjob.framework.WrapDynaBean;
12
13 public class DescriberTest extends TestCase {
14
15     public static class O1 {
16         public Map JavaDoc describe() {
17             Map JavaDoc map = new HashMap JavaDoc();
18             map.put("fruit", "apples");
19             return map;
20         }
21     }
22
23     public void test1() {
24         Map JavaDoc d = Describer.describe(new O1());
25         assertEquals("apples", d.get("fruit"));
26     }
27     
28     public static class O2 {
29         public String JavaDoc getFruit() {
30             return "apples";
31         }
32     }
33     
34     public void test2() {
35         Map JavaDoc d = Describer.describe(new O2());
36         assertEquals("apples", d.get("fruit"));
37     }
38
39     public static class O3 {
40         public void setFruit(String JavaDoc fruit) {
41         }
42     }
43     
44     /**
45      * Bug in describe in beanutils for a dynabean without a read method.
46      *
47      */

48     public void testDynaBean() {
49         WrapDynaBean wrap = new WrapDynaBean(new O3());
50         Map JavaDoc d = Describer.describe(wrap);
51         // class is only property
52
assertEquals(1, d.size());
53     }
54     
55 }
56
Popular Tags