KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > notification > AttributeChangeNotificationFilterTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package test.compliance.notification;
9
10 import javax.management.AttributeChangeNotificationFilter;
11
12 import junit.framework.TestCase;
13
14 /**
15  *
16  * @author <a HREF="mailto:juha@jboss.org">Juha Lindfors</a>.
17  */

18 public class AttributeChangeNotificationFilterTestCase
19   extends TestCase
20 {
21
22   // Constructor ---------------------------------------------------------------
23

24   /**
25    * Construct the test
26    */

27   public AttributeChangeNotificationFilterTestCase(String s)
28   {
29     super(s);
30   }
31
32   // Tests ---------------------------------------------------------------------
33

34   public void testGetEnabledAttributes()
35   {
36       AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
37       
38       assertTrue(filter.getEnabledAttributes().size() == 0);
39       
40       filter.enableAttribute("foo");
41       filter.enableAttribute("bar");
42       
43       assertTrue(filter.getEnabledAttributes().size() == 2);
44   }
45
46   public void testDisableAttribute()
47   {
48      AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
49      
50      filter.enableAttribute("foo");
51      filter.enableAttribute("bar");
52      
53      assertTrue(filter.getEnabledAttributes().size() == 2);
54      
55      filter.disableAttribute("foo");
56      
57      assertTrue(filter.getEnabledAttributes().size() == 1);
58      assertTrue(filter.getEnabledAttributes().get(0).equals("bar"));
59      
60      filter.disableAllAttributes();
61      
62      assertTrue(filter.getEnabledAttributes().size() == 0);
63      
64   }
65
66 }
67
Popular Tags