KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > varia > AttributeChangeNotificationFilterTEST


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.varia;
9
10 import java.io.ByteArrayInputStream;
11 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
13 import java.io.ObjectInputStream;
14 import java.io.ObjectOutputStream;
15
16 import java.util.Vector;
17
18 import junit.framework.TestCase;
19
20 import javax.management.*;
21
22 /**
23  *
24  * @author <a HREF="mailto:juha@jboss.org">Juha Lindfors</a>.
25  */

26 public class AttributeChangeNotificationFilterTEST
27   extends TestCase
28 {
29
30   // Constructor ---------------------------------------------------------------
31

32   /**
33    * Construct the test
34    */

35   public AttributeChangeNotificationFilterTEST(String s)
36   {
37     super(s);
38   }
39
40   // Tests ---------------------------------------------------------------------
41

42   public void testGetEnabledAttributes()
43   {
44       AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
45       
46       assertTrue(filter.getEnabledAttributes().size() == 0);
47       
48       filter.enableAttribute("foo");
49       filter.enableAttribute("bar");
50       
51       assertTrue(filter.getEnabledAttributes().size() == 2);
52   }
53
54   public void testDisableAttribute()
55   {
56      AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
57      
58      filter.enableAttribute("foo");
59      filter.enableAttribute("bar");
60      
61      assertTrue(filter.getEnabledAttributes().size() == 2);
62      
63      filter.disableAttribute("foo");
64      
65      assertTrue(filter.getEnabledAttributes().size() == 1);
66      assertTrue(filter.getEnabledAttributes().get(0).equals("bar"));
67      
68      filter.disableAllAttributes();
69      
70      assertTrue(filter.getEnabledAttributes().size() == 0);
71      
72   }
73
74 }
75
Popular Tags