KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > modelmbean > ModelMBeanNotificationInfoTest


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.javax.management.modelmbean;
10
11 import javax.management.Descriptor JavaDoc;
12 import javax.management.modelmbean.DescriptorSupport JavaDoc;
13 import javax.management.modelmbean.ModelMBeanNotificationInfo JavaDoc;
14
15 import junit.framework.TestCase;
16
17 /**
18  * @version $Revision: 1.4 $
19  * @see
20  */

21
22 public class ModelMBeanNotificationInfoTest extends TestCase
23 {
24
25    public ModelMBeanNotificationInfoTest(String JavaDoc s)
26    {
27       super(s);
28    }
29
30    public void setUp() throws Exception JavaDoc
31    {
32       super.setUp();
33    }
34
35    public void tearDown() throws Exception JavaDoc
36    {
37       super.tearDown();
38    }
39
40    public void testSeverityField() throws Exception JavaDoc
41    {
42       // testcase for bug #775742, #744423 and #775739
43
// this should work ok
44
Descriptor JavaDoc descriptor = new DescriptorSupport JavaDoc(new String JavaDoc[]{"name", "descriptortype", "severity"},
45                                                     new String JavaDoc[]{"aNotification", "notification", "6"});
46       ModelMBeanNotificationInfo JavaDoc notification
47               = new ModelMBeanNotificationInfo JavaDoc(new String JavaDoc[]{"type1"}, "aNotification", "A description", descriptor);
48       assertSame(descriptor.getFieldValue("notification"), notification.getDescriptor().getFieldValue("notification"));
49
50       descriptor = new DescriptorSupport JavaDoc(new String JavaDoc[]{"name", "descriptortype", "severity"},
51                                          new String JavaDoc[]{"aNotification", "notification", "0"});
52       notification
53       = new ModelMBeanNotificationInfo JavaDoc(new String JavaDoc[]{"type1"}, "aNotification", "A description", descriptor);
54       assertSame(descriptor.getFieldValue("notification"), notification.getDescriptor().getFieldValue("notification"));
55    }
56
57    public void testCaseInsensitiveDescriptorType()
58    {
59       DescriptorSupport JavaDoc ds = new DescriptorSupport JavaDoc(new String JavaDoc[]{
60          "name=badthing",
61          "descriptorType=NOTification",
62          "severity=1"
63       });
64       ModelMBeanNotificationInfo JavaDoc info =
65               new ModelMBeanNotificationInfo JavaDoc(new String JavaDoc[]{"bad.thing"},
66                                              "badthing",
67                                              "The bad thing happened",
68                                              ds);
69    }
70 }
71
Popular Tags