KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > api > AutomaticBeanTest


1 package com.puppycrawl.tools.checkstyle.api;
2
3 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
4 import junit.framework.TestCase;
5
6 public class AutomaticBeanTest extends TestCase
7 {
8     private class TestBean extends AutomaticBean
9     {
10         private String JavaDoc mName = null;
11
12         public void setName(String JavaDoc aName)
13         {
14             mName = aName;
15         }
16     }
17
18     DefaultConfiguration mConf = null;
19
20     TestBean mTestBean = new TestBean();
21
22     public void setUp()
23     {
24         mConf = new DefaultConfiguration("testConf");
25     }
26
27     public void testNoSuchAttribute()
28     {
29         mConf.addAttribute("NonExisting", "doesn't matter");
30         try {
31             mTestBean.configure(mConf);
32             fail("AutomaticBean.configure() accepted nonexisting attribute name");
33         }
34         catch (CheckstyleException ex)
35         {
36             // expected exception
37
}
38         assertEquals(mTestBean.mName, null);
39
40     }
41 }
42
Popular Tags