KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > system > controller > configure > value > javabean > test > JavaBeanValueTest


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.javabean.test;
23
24 import java.beans.IntrospectionException JavaDoc;
25
26 import javax.management.ObjectName JavaDoc;
27
28 import org.jboss.deployment.DeploymentException;
29 import org.jboss.test.system.controller.AbstractControllerTest;
30 import org.jboss.test.system.controller.support.BrokenDynamicMBeanAttributeInfoTypeNotFound;
31 import org.jboss.test.system.controller.support.BrokenDynamicMBeanNoAttributeInfoType;
32 import org.jboss.test.system.controller.support.JavaBean;
33 import org.jboss.test.system.controller.support.Simple;
34 import org.jboss.test.system.controller.support.SimpleMBean;
35
36 /**
37  * JavaBeanValueTest.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 1.1 $
41  */

42 public abstract class JavaBeanValueTest extends AbstractControllerTest
43 {
44    public JavaBeanValueTest(String JavaDoc name)
45    {
46       super(name);
47    }
48
49    public void testExplicitClass() throws Exception JavaDoc
50    {
51       javaBean();
52    }
53
54    public void testImplicitClass() throws Exception JavaDoc
55    {
56       javaBean();
57    }
58
59    public void testAttributeClassNotFound() throws Exception JavaDoc
60    {
61       assertDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException JavaDoc.class);
62    }
63
64    public void testAbstractAttributeClass() throws Exception JavaDoc
65    {
66       assertDeployFailure(SimpleMBean.OBJECT_NAME, InstantiationException JavaDoc.class);
67    }
68
69    public void testErrorInConstructor() throws Exception JavaDoc
70    {
71       assertDeployFailure(SimpleMBean.OBJECT_NAME, Error JavaDoc.class);
72    }
73
74    public void testNoAttributeInfoType() throws Exception JavaDoc
75    {
76       assertDeployFailure(BrokenDynamicMBeanNoAttributeInfoType.OBJECT_NAME, DeploymentException.class);
77    }
78
79    public void testAttributeInfoTypeNotFound() throws Exception JavaDoc
80    {
81       assertDeployFailure(BrokenDynamicMBeanAttributeInfoTypeNotFound.OBJECT_NAME, ClassNotFoundException JavaDoc.class);
82    }
83
84    public void testNoPropertyName() throws Exception JavaDoc
85    {
86       assertDeployFailure(SimpleMBean.OBJECT_NAME, IntrospectionException JavaDoc.class);
87    }
88
89    public void testEmptyPropertyName() throws Exception JavaDoc
90    {
91       assertDeployFailure(SimpleMBean.OBJECT_NAME, IntrospectionException JavaDoc.class);
92    }
93
94    public void testPropertyNotFound() throws Exception JavaDoc
95    {
96       assertDeployFailure(SimpleMBean.OBJECT_NAME, IntrospectionException JavaDoc.class);
97    }
98
99    public void testNoPropertyEditor() throws Exception JavaDoc
100    {
101       /* TODO testNoPropertyEditor
102       assertDeployFailure(SimpleMBean.OBJECT_NAME, IntrospectionException.class);
103       */

104    }
105
106    public void testNoPropertyValue() throws Exception JavaDoc
107    {
108       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
109       
110       assertInstall(name);
111       try
112       {
113          Simple test = getSimple();
114
115          JavaBean bean = test.getJavaBean();
116          assertNotNull(bean);
117          assertEquals("", bean.getProperty1());
118       }
119       finally
120       {
121          assertUninstall(name);
122       }
123    }
124
125    public void testErrorInProperty() throws Exception JavaDoc
126    {
127       assertDeployFailure(SimpleMBean.OBJECT_NAME, Error JavaDoc.class);
128    }
129    
130    protected void javaBean() throws Exception JavaDoc
131    {
132       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
133       
134       assertInstall(name);
135       try
136       {
137          Simple test = getSimple();
138
139          JavaBean bean = test.getJavaBean();
140          assertNotNull(bean);
141          assertEquals("property1", bean.getProperty1());
142          assertEquals(new Integer JavaDoc(10), bean.getProperty2());
143       }
144       finally
145       {
146          assertUninstall(name);
147       }
148    }
149 }
150
Popular Tags