KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > system > controller > configure > attribute > test > AttributeTest


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.system.controller.configure.attribute.test;
23
24 import javax.management.ObjectName JavaDoc;
25
26 import org.jboss.deployment.DeploymentException;
27 import org.jboss.test.system.controller.AbstractControllerTest;
28 import org.jboss.test.system.controller.support.BrokenDynamicMBeanAttributes;
29 import org.jboss.test.system.controller.support.Simple;
30 import org.jboss.test.system.controller.support.SimpleMBean;
31
32 /**
33  * AttributeTest.
34  *
35  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
36  * @version $Revision: 1.1 $
37  */

38 public abstract class AttributeTest extends AbstractControllerTest
39 {
40    public AttributeTest(String JavaDoc name)
41    {
42       super(name);
43    }
44    
45    public void testAttributeNone() throws Exception JavaDoc
46    {
47       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
48       assertInstall(name);
49       try
50       {
51          Simple simple = getSimple();
52          assertNull(simple.getAttribute1());
53          assertNull(simple.getAttribute2());
54       }
55       finally
56       {
57          assertUninstall(name);
58       }
59    }
60    
61    public void testAttributeOne() throws Exception JavaDoc
62    {
63       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
64       assertInstall(name);
65       try
66       {
67          Simple simple = getSimple();
68          assertEquals("value1", simple.getAttribute1());
69          assertNull(simple.getAttribute2());
70       }
71       finally
72       {
73          assertUninstall(name);
74       }
75    }
76    
77    public void testAttributeTwo() throws Exception JavaDoc
78    {
79       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
80       assertInstall(name);
81       try
82       {
83          Simple simple = getSimple();
84          assertEquals("value1", simple.getAttribute1());
85          assertEquals("value2", simple.getAttribute2());
86       }
87       finally
88       {
89          assertUninstall(name);
90       }
91    }
92    
93    public void testAttributeNoValue() throws Exception JavaDoc
94    {
95       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
96       assertInstall(name);
97       try
98       {
99          Simple simple = getSimple();
100          assertNull(simple.getAttribute1());
101          assertNull(simple.getAttribute2());
102       }
103       finally
104       {
105          assertUninstall(name);
106       }
107    }
108    
109    public void testAttributeEmptyValue() throws Exception JavaDoc
110    {
111       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
112       assertInstall(name);
113       try
114       {
115          Simple simple = getSimple();
116          assertNull(simple.getAttribute1());
117          assertNull(simple.getAttribute2());
118       }
119       finally
120       {
121          assertUninstall(name);
122       }
123    }
124    
125    public void testAttributeNoName() throws Exception JavaDoc
126    {
127       assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class);
128    }
129    
130    public void testAttributeEmptyName() throws Exception JavaDoc
131    {
132       assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class);
133    }
134    
135    public void testAttributeBrokenGetAttributes() throws Exception JavaDoc
136    {
137       assertDeployFailure(BrokenDynamicMBeanAttributes.OBJECT_NAME, Error JavaDoc.class);
138    }
139    
140    public void testAttributeNotFound() throws Exception JavaDoc
141    {
142       assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class);
143    }
144    
145    public void testAttributeBrokenSetAttribute() throws Exception JavaDoc
146    {
147       assertDeployFailure(SimpleMBean.OBJECT_NAME, Error JavaDoc.class);
148    }
149 }
150
Popular Tags