KickJava   Java API By Example, From Geeks To Geeks.

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


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.MalformedObjectNameException JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26
27 import org.jboss.deployment.DeploymentException;
28 import org.jboss.mx.util.ObjectNameFactory;
29 import org.jboss.test.system.controller.AbstractControllerTest;
30 import org.jboss.test.system.controller.support.Simple;
31 import org.jboss.test.system.controller.support.SimpleMBean;
32
33 /**
34  * DependsAttributeTest.
35  *
36  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
37  * @version $Revision: 1.1 $
38  */

39 public abstract class DependsAttributeTest extends AbstractControllerTest
40 {
41    static ObjectName JavaDoc DEPENDS1 = ObjectNameFactory.create("jboss.test:type=depends1");
42    static ObjectName JavaDoc DEPENDS2 = ObjectNameFactory.create("jboss.test:type=depends2");
43    
44    public DependsAttributeTest(String JavaDoc name)
45    {
46       super(name);
47    }
48    
49    public void testDependsAttributeNone() throws Exception JavaDoc
50    {
51       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
52       assertInstall(name);
53       try
54       {
55          Simple simple = getSimple();
56          assertNull(simple.getObjectNameAttribute1());
57          assertNull(simple.getObjectNameAttribute2());
58       }
59       finally
60       {
61          assertUninstall(name);
62       }
63    }
64    
65    public void testDependsAttributeOne() throws Exception JavaDoc
66    {
67       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
68       assertInstall(name);
69       try
70       {
71          Simple simple = getSimple();
72          assertEquals(DEPENDS1, simple.getObjectNameAttribute1());
73          assertNull(simple.getObjectNameAttribute2());
74       }
75       finally
76       {
77          assertUninstall(name);
78       }
79    }
80    
81    public void testDependsAttributeTwo() throws Exception JavaDoc
82    {
83       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
84       assertInstall(name);
85       try
86       {
87          Simple simple = getSimple();
88          assertEquals(DEPENDS1, simple.getObjectNameAttribute1());
89          assertEquals(DEPENDS2, simple.getObjectNameAttribute2());
90       }
91       finally
92       {
93          assertUninstall(name);
94       }
95    }
96    
97    public void testDependsAttributeNested() throws Exception JavaDoc
98    {
99       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
100       assertInstall(name);
101       try
102       {
103          Simple simple = getSimple();
104          assertEquals(DEPENDS1, simple.getObjectNameAttribute1());
105          assertNull(simple.getObjectNameAttribute2());
106       }
107       finally
108       {
109          assertUninstall(name);
110       }
111    }
112    
113    public void testDependsAttributeNoValue() throws Exception JavaDoc
114    {
115       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
116    }
117    
118    public void testDependsAttributeEmptyValue() throws Exception JavaDoc
119    {
120       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
121    }
122    
123    public void testDependsAttributeInvalidValue() throws Exception JavaDoc
124    {
125       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
126    }
127    
128    public void testDependsAttributeUnknownElement() throws Exception JavaDoc
129    {
130       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
131    }
132    
133    public void testDependsAttributePatternValue() throws Exception JavaDoc
134    {
135       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
136    }
137    
138    public void testDependsAttributeNotFound() throws Exception JavaDoc
139    {
140       assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class);
141    }
142    
143    public void testDependsAttributeBrokenSetAttribute() throws Exception JavaDoc
144    {
145       assertDeployFailure(SimpleMBean.OBJECT_NAME, Error JavaDoc.class);
146    }
147 }
148
Popular Tags