KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > system > controller > configure > value > depends > test > DependencyValueTest


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.value.depends.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  * DependencyValueTest.
35  *
36  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
37  * @version $Revision: 1.1 $
38  */

39 public abstract class DependencyValueTest extends AbstractControllerTest
40 {
41    static ObjectName JavaDoc DEPENDS = ObjectNameFactory.create("jboss.test:type=depends");
42    
43    public DependencyValueTest(String JavaDoc name)
44    {
45       super(name);
46    }
47    
48    public void testDependency() throws Exception JavaDoc
49    {
50       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
51       assertInstall(name);
52       try
53       {
54          Simple simple = getSimple();
55          assertEquals(DEPENDS, simple.getObjectName());
56       }
57       finally
58       {
59          assertUninstall(name);
60       }
61    }
62    
63    public void testDependencyNested() throws Exception JavaDoc
64    {
65       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
66       assertInstall(name);
67       try
68       {
69          Simple simple = getSimple();
70          assertEquals(DEPENDS, simple.getObjectName());
71       }
72       finally
73       {
74          assertUninstall(name);
75       }
76    }
77    
78    public void testExplicitProxyType() throws Exception JavaDoc
79    {
80       proxyTest();
81    }
82    
83    public void testImplicitProxyType() throws Exception JavaDoc
84    {
85       proxyTest();
86    }
87    
88    public void testNoValue() throws Exception JavaDoc
89    {
90       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
91    }
92    
93    public void testEmptyValue() throws Exception JavaDoc
94    {
95       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
96    }
97    
98    public void testInvalidValue() throws Exception JavaDoc
99    {
100       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
101    }
102    
103    public void testUnknownElement() throws Exception JavaDoc
104    {
105       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
106    }
107    
108    public void testPatternValue() throws Exception JavaDoc
109    {
110       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
111    }
112    
113    public void testBrokenSetAttribute() throws Exception JavaDoc
114    {
115       assertDeployFailure(SimpleMBean.OBJECT_NAME, Error JavaDoc.class);
116    }
117    
118    public void testNoAttributeInfoType() throws Exception JavaDoc
119    {
120       assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class);
121    }
122    
123    public void testAttributeInfoTypeNotFound() throws Exception JavaDoc
124    {
125       assertDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException JavaDoc.class);
126    }
127    
128    public void testProxyTypeNotFound() throws Exception JavaDoc
129    {
130       assertDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException JavaDoc.class);
131    }
132    
133    public void testProxyTypeNotInterface() throws Exception JavaDoc
134    {
135       assertDeployFailure(SimpleMBean.OBJECT_NAME, IllegalArgumentException JavaDoc.class);
136    }
137    
138    protected void proxyTest() throws Exception JavaDoc
139    {
140       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
141       assertInstall(name);
142       try
143       {
144          Simple simple = getSimple();
145          Simple dependency = getMBean(Simple.class, DEPENDS, "Instance");
146
147          assertFalse(simple.isTouched());
148          assertFalse(dependency.isTouched());
149          
150          simple.touchProxy();
151
152          assertFalse(simple.isTouched());
153          assertTrue(dependency.isTouched());
154       }
155       finally
156       {
157          assertUninstall(name);
158       }
159    }
160    
161    protected Simple getDependency() throws Exception JavaDoc
162    {
163       return getMBean(Simple.class, DEPENDS, "Instance");
164    }
165 }
166
Popular Tags