1 /*
2 * Created on 10-Oct-2003
3 *
4 */
5 package org.johndavidtaylor.beans.beanpeeler;
6
7
8 import java.beans.PropertyDescriptor;
9
10 import junit.framework.TestCase;
11
12 /***
13 * @author jdt
14 *
15 * junit TestCase for BeanProperty
16 */
17 public class BeanPropertyTest extends TestCase {
18
19 /***
20 * Constructor for BeanProperty.
21 * @param arg0
22 */
23 public BeanPropertyTest(String arg0) {
24 super(arg0);
25 }
26
27 public static void main(String[] args) {
28 junit.swingui.TestRunner.run(BeanPropertyTest.class);
29 }
30
31
32 private BeanPeeler.BeanProperty beanProperty;
33 private BeanPeeler beanpeeler;
34 /*
35 * @see TestCase#setUp()
36 */
37 protected void setUp() throws Exception {
38 super.setUp();
39 beanpeeler = new BeanPeeler(new Object());
40 PropertyDescriptor pd = new PropertyDescriptor("Foo", MyProperty.class );
41 beanProperty = beanpeeler.new BeanProperty(pd);
42 }
43
44 /***
45 * The BeanProperty wraps a stringy type, so shouldn't be a tag
46 *
47 */
48 public void testIsCorrectType() {
49 assertFalse("Not a tag type",beanProperty.isTagType());
50 assertFalse("Not a custom type",beanProperty.isCustom());
51 }
52 /***
53 * Should be valid
54 *
55 */
56 public void testIsValid() {
57 assertTrue("Is valid", beanProperty.isValid());
58 }
59
60 public void testBeanPropertyNameCorrect() {
61 assertEquals("name correct","Foo",beanProperty.getName());
62 }
63
64 /*
65 * @see TestCase#tearDown()
66 */
67 protected void tearDown() throws Exception {
68 super.tearDown();
69 }
70
71 /***
72 * A convenience class supplied to supply a property to the PropertyDescriptor constructor
73 *
74 * @author jdt
75 *
76 */
77 private class MyProperty {
78 private String foo= new String();
79
80
81
82 /***
83 * @return
84 */
85 public String getFoo() {
86 return foo;
87 }
88
89 /***
90 * @param string
91 */
92 public void setFoo(String string) {
93 foo = string;
94 }
95
96 }
97
98 }
This page was automatically generated by Maven