KickJava   Java API By Example, From Geeks To Geeks.

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


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

43 public abstract class DependsListAttributeTest extends AbstractControllerTest
44 {
45    static ObjectName JavaDoc DEPENDS1 = ObjectNameFactory.create("jboss.test:type=depends1");
46    static ObjectName JavaDoc[] DEPENDSLIST1 = new ObjectName JavaDoc[] { DEPENDS1 };
47    static ObjectName JavaDoc DEPENDS2 = ObjectNameFactory.create("jboss.test:type=depends2");
48    static ObjectName JavaDoc[] DEPENDSLIST2 = new ObjectName JavaDoc[] { DEPENDS2 };
49    static ObjectName JavaDoc[] DEPENDSLIST = new ObjectName JavaDoc[] { DEPENDS1, DEPENDS2 };
50    
51    public DependsListAttributeTest(String JavaDoc name)
52    {
53       super(name);
54    }
55    
56    protected void assertEquals(ObjectName JavaDoc[] expected, Collection JavaDoc<ObjectName JavaDoc> actual)
57    {
58       List JavaDoc<ObjectName JavaDoc> expectedList = Arrays.asList(expected);
59       assertEquals(expectedList, actual);
60    }
61    
62    public void testDependsListAttributeNone() throws Exception JavaDoc
63    {
64       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
65       assertInstall(name);
66       try
67       {
68          Simple simple = getSimple();
69          assertNull(simple.getObjectNamesAttribute1());
70          assertNull(simple.getObjectNamesAttribute2());
71       }
72       finally
73       {
74          assertUninstall(name);
75       }
76    }
77    
78    public void testDependsListAttributeOne() throws Exception JavaDoc
79    {
80       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
81       assertInstall(name);
82       try
83       {
84          Simple simple = getSimple();
85          assertEquals(DEPENDSLIST1, simple.getObjectNamesAttribute1());
86          assertNull(simple.getObjectNamesAttribute2());
87       }
88       finally
89       {
90          assertUninstall(name);
91       }
92    }
93    
94    public void testDependsListAttributeTwo() throws Exception JavaDoc
95    {
96       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
97       assertInstall(name);
98       try
99       {
100          Simple simple = getSimple();
101          assertEquals(DEPENDSLIST1, simple.getObjectNamesAttribute1());
102          assertEquals(DEPENDSLIST2, simple.getObjectNamesAttribute2());
103       }
104       finally
105       {
106          assertUninstall(name);
107       }
108    }
109    
110    public void testDependsListAttributeMultiple() throws Exception JavaDoc
111    {
112       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
113       assertInstall(name);
114       try
115       {
116          Simple simple = getSimple();
117          assertEquals(DEPENDSLIST, simple.getObjectNamesAttribute1());
118          assertNull(simple.getObjectNamesAttribute2());
119       }
120       finally
121       {
122          assertUninstall(name);
123       }
124    }
125    
126    public void testDependsListAttributeNested() throws Exception JavaDoc
127    {
128       ObjectName JavaDoc name = SimpleMBean.OBJECT_NAME;
129       assertInstall(name);
130       try
131       {
132          Simple simple = getSimple();
133          assertEquals(DEPENDSLIST1, simple.getObjectNamesAttribute1());
134          assertNull(simple.getObjectNamesAttribute2());
135       }
136       finally
137       {
138          assertUninstall(name);
139       }
140    }
141    
142    public void testDependsListAttributeNoValue() throws Exception JavaDoc
143    {
144       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
145    }
146    
147    public void testDependsListAttributeEmptyValue() throws Exception JavaDoc
148    {
149       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
150    }
151    
152    public void testDependsListAttributeInvalidValue() throws Exception JavaDoc
153    {
154       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
155    }
156    
157    public void testDependsListAttributeUnknownElement() throws Exception JavaDoc
158    {
159       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
160    }
161
162    public void testDependsListAttributePatternValue() throws Exception JavaDoc
163    {
164       assertDeployFailure(SimpleMBean.OBJECT_NAME, MalformedObjectNameException JavaDoc.class);
165    }
166    
167    public void testDependsListAttributeNotFound() throws Exception JavaDoc
168    {
169       assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class);
170    }
171    
172    public void testDependsListAttributeBrokenSetAttribute() throws Exception JavaDoc
173    {
174       assertDeployFailure(SimpleMBean.OBJECT_NAME, Error JavaDoc.class);
175    }
176 }
177
Popular Tags