Source Code Cross Referenced for MBeanOperationInfoTEST.java in  » EJB-Server-JBoss-4.2.1 » jmx » test » compliance » metadata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » jmx » test.compliance.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package test.compliance.metadata;
023:
024:        import java.lang.reflect.Method;
025:
026:        import javax.management.MBeanOperationInfo;
027:        import javax.management.MBeanParameterInfo;
028:
029:        import junit.framework.AssertionFailedError;
030:        import junit.framework.TestCase;
031:
032:        /**
033:         * Tests MBeanOperationInfo.
034:         *
035:         * @author  <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
036:         * @version $Revision: 57200 $ 
037:         */
038:        public class MBeanOperationInfoTEST extends TestCase {
039:            public MBeanOperationInfoTEST(String s) {
040:                super (s);
041:            }
042:
043:            /**
044:             * Tests <tt>MBeanOperationInfo(String descr, Method m)</tt> constructor.
045:             */
046:            public void testConstructorWithMethod() {
047:                try {
048:                    Class c = this .getClass();
049:                    Method m = c.getMethod("testConstructorWithMethod",
050:                            new Class[0]);
051:
052:                    MBeanOperationInfo info = new MBeanOperationInfo(
053:                            "This is a description.", m);
054:
055:                    assertTrue(info.getDescription().equals(
056:                            "This is a description."));
057:                    assertTrue(info.getName().equals(m.getName()));
058:                    assertTrue(info.getReturnType().equals("void"));
059:                    assertTrue(info.getSignature().length == 0);
060:                    assertTrue(info.getImpact() == MBeanOperationInfo.UNKNOWN);
061:                } catch (AssertionFailedError e) {
062:                    throw e;
063:                } catch (Throwable t) {
064:                    t.printStackTrace();
065:                    fail("Unexpected error: " + t.toString());
066:                }
067:            }
068:
069:            /**
070:             * Tests <tt>MBeanOperationInfo(String name, String descr, MBeanParameterInfo[] sign, String returnType, int impact)</tt> constructor.
071:             */
072:            public void testConstructor() {
073:                try {
074:                    MBeanOperationInfo info = new MBeanOperationInfo(
075:                            "MyOperation",
076:                            "This is a description.",
077:                            new MBeanParameterInfo[] {
078:                                    new MBeanParameterInfo("FooParam",
079:                                            "java.lang.Object", "description"),
080:                                    new MBeanParameterInfo("BarParam",
081:                                            "java.lang.String", "description") },
082:                            "java.util.StringBuffer", MBeanOperationInfo.INFO);
083:
084:                    assertTrue(info.getDescription().equals(
085:                            "This is a description."));
086:                    assertTrue(info.getName().equals("MyOperation"));
087:                    assertTrue(info.getReturnType().equals(
088:                            "java.util.StringBuffer"));
089:                    assertTrue(info.getSignature().length == 2);
090:                    assertTrue(info.getImpact() == MBeanOperationInfo.INFO);
091:                    assertTrue(info.getSignature()[0].getName().equals(
092:                            "FooParam"));
093:                    assertTrue(info.getSignature()[1].getName().equals(
094:                            "BarParam"));
095:                    assertTrue(info.getSignature()[0].getDescription().equals(
096:                            "description"));
097:                    assertTrue(info.getSignature()[1].getDescription().equals(
098:                            "description"));
099:                    assertTrue(info.getSignature()[0].getType().equals(
100:                            "java.lang.Object"));
101:                    assertTrue(info.getSignature()[1].getType().equals(
102:                            "java.lang.String"));
103:
104:                } catch (AssertionFailedError e) {
105:                    throw e;
106:                } catch (Throwable t) {
107:                    t.printStackTrace();
108:                    fail("Unexpected error: " + t.toString());
109:                }
110:            }
111:
112:            /**
113:             * Tests the clone operation.
114:             */
115:            public void testClone() {
116:                try {
117:                    MBeanOperationInfo info = new MBeanOperationInfo(
118:                            "MyOperation",
119:                            "This is a description.",
120:                            new MBeanParameterInfo[] {
121:                                    new MBeanParameterInfo("FooParam",
122:                                            "java.lang.Object", "description"),
123:                                    new MBeanParameterInfo("BarParam",
124:                                            "java.lang.String", "description") },
125:                            "java.util.StringBuffer",
126:                            MBeanOperationInfo.ACTION_INFO);
127:
128:                    MBeanOperationInfo clone = (MBeanOperationInfo) info
129:                            .clone();
130:
131:                    assertTrue(clone.getDescription().equals(
132:                            "This is a description."));
133:                    assertTrue(clone.getName().equals("MyOperation"));
134:                    assertTrue(clone.getReturnType().equals(
135:                            "java.util.StringBuffer"));
136:                    assertTrue(clone.getSignature().length == 2);
137:                    assertTrue(clone.getImpact() == MBeanOperationInfo.ACTION_INFO);
138:                    assertTrue(clone.getSignature()[0].getName().equals(
139:                            "FooParam"));
140:                    assertTrue(clone.getSignature()[1].getName().equals(
141:                            "BarParam"));
142:                    assertTrue(clone.getSignature()[0].getDescription().equals(
143:                            "description"));
144:                    assertTrue(clone.getSignature()[1].getDescription().equals(
145:                            "description"));
146:                    assertTrue(clone.getSignature()[0].getType().equals(
147:                            "java.lang.Object"));
148:                    assertTrue(clone.getSignature()[1].getType().equals(
149:                            "java.lang.String"));
150:
151:                } catch (AssertionFailedError e) {
152:                    throw e;
153:                } catch (Throwable t) {
154:                    t.printStackTrace();
155:                    fail("Unexpected error: " + t.toString());
156:                }
157:            }
158:
159:            /**
160:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getName()</tt> accessor with empty name.
161:             */
162:            public void testGetNameEmpty() {
163:                try {
164:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
165:                            "",
166:                            "This is a description.",
167:                            new MBeanParameterInfo[] {
168:                                    new MBeanParameterInfo("FooParam",
169:                                            "java.lang.Object", "description"),
170:                                    new MBeanParameterInfo("BarParam",
171:                                            "java.lang.String", "description") },
172:                            "java.util.StringBuffer",
173:                            MBeanOperationInfo.ACTION_INFO);
174:                } catch (Exception e) {
175:                    return;
176:                }
177:                fail("empty name is not a valid java identifier");
178:            }
179:
180:            /**
181:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getName()</tt> accessor with <tt>null</tt> name.
182:             */
183:            public void testGetNameNull() {
184:                try {
185:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
186:                            null,
187:                            "This is a description.",
188:                            new MBeanParameterInfo[] {
189:                                    new MBeanParameterInfo("FooParam",
190:                                            "java.lang.Object", "description"),
191:                                    new MBeanParameterInfo("BarParam",
192:                                            "java.lang.String", "description") },
193:                            "java.util.StringBuffer",
194:                            MBeanOperationInfo.ACTION_INFO);
195:                } catch (Exception e) {
196:                    return;
197:                }
198:                fail("null name is not a valid java identifier");
199:            }
200:
201:            public void testGetNameInvalidType() {
202:                try {
203:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
204:                            "invalid type",
205:                            "This is a description.",
206:                            new MBeanParameterInfo[] {
207:                                    new MBeanParameterInfo("FooParam",
208:                                            "java.lang.Object", "description"),
209:                                    new MBeanParameterInfo("BarParam",
210:                                            "java.lang.String", "description") },
211:                            "java.util.StringBuffer",
212:                            MBeanOperationInfo.ACTION_INFO);
213:                } catch (Exception e) {
214:                    return;
215:                }
216:                fail("'invalid type' is not a valid java identifier");
217:            }
218:
219:            /**
220:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getDescription()</tt> accessor with <tt>null</tt> description.
221:             */
222:            public void testGetDescriptionNull() {
223:                try {
224:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
225:                            "SomeName",
226:                            null,
227:                            new MBeanParameterInfo[] {
228:                                    new MBeanParameterInfo("FooParam",
229:                                            "java.lang.Object", "description"),
230:                                    new MBeanParameterInfo("BarParam",
231:                                            "java.lang.String", "description") },
232:                            "java.util.StringBuffer",
233:                            MBeanOperationInfo.ACTION_INFO);
234:
235:                    assertTrue(info1.getDescription() == null);
236:
237:                } catch (AssertionFailedError e) {
238:                    throw e;
239:                } catch (Throwable t) {
240:                    t.printStackTrace();
241:                    fail("Unexpected error: " + t.toString());
242:                }
243:            }
244:
245:            /**
246:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getImpact()</tt> accessor with invalid value.
247:             */
248:            public void testGetImpactInvalid() {
249:                try {
250:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
251:                            "SomeName",
252:                            "some description",
253:                            new MBeanParameterInfo[] {
254:                                    new MBeanParameterInfo("FooParam",
255:                                            "java.lang.Object", "description"),
256:                                    new MBeanParameterInfo("BarParam",
257:                                            "java.lang.String", "description") },
258:                            "java.util.StringBuffer", -22342);
259:
260:                    // according to javadoc, getImpact() is only allowed to return a value that matches
261:                    // either ACTION, ACTION_INFO, INFO or UNKNOWN constant value.
262:                    if (info1.getImpact() != MBeanOperationInfo.ACTION)
263:                        if (info1.getImpact() != MBeanOperationInfo.INFO)
264:                            if (info1.getImpact() != MBeanOperationInfo.ACTION_INFO)
265:                                if (info1.getImpact() != MBeanOperationInfo.UNKNOWN)
266:
267:                                    // JPL: This fails in RI. The spec doesn't define how invalid impact types should be
268:                                    //      handled. This could be checked at construction time (early) or at getImpact()
269:                                    //      invocation time (late). Since behaviour is not specified, I've opted to check
270:                                    //      late and throw an JMRuntimeException in case there is an invalid impact value.
271:                                    fail("FAILS IN RI: MBeanOperation.getImpact() is only allowed to return values that match either ACTION, ACTION_INFO, INFO or UNKNOWN constant values.");
272:
273:                    // should not reach here unless -22342 has somehow become a valid impact value (in which case this test should be modified)
274:                    fail("ERROR IN TEST: invalid impact value test does not work correctly.");
275:                } catch (AssertionFailedError e) {
276:                    throw e;
277:                } catch (Exception e) {
278:                    return;
279:                }
280:                fail("Invalid impact");
281:            }
282:
283:            /**
284:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getSignature()</tt> with <tt>null</tt> signature.
285:             */
286:            public void testGetSignatureNull() {
287:                try {
288:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
289:                            "SomeName", "some description", null,
290:                            "java.util.StringBuffer", MBeanOperationInfo.ACTION);
291:
292:                    assertTrue(info1.getSignature().length == 0);
293:
294:                } catch (AssertionFailedError e) {
295:                    throw e;
296:                } catch (Throwable t) {
297:                    t.printStackTrace();
298:                    fail("Unexpected error: " + t.toString());
299:                }
300:            }
301:
302:            /**
303:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getSignature()</tt> with empty signature array.
304:             */
305:            public void testGetSignatureEmpty() {
306:                try {
307:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
308:                            "SomeName", "some description",
309:                            new MBeanParameterInfo[0],
310:                            "java.util.StringBuffer", MBeanOperationInfo.ACTION);
311:
312:                    assertTrue(info1.getSignature().length == 0);
313:
314:                } catch (AssertionFailedError e) {
315:                    throw e;
316:                } catch (Throwable t) {
317:                    t.printStackTrace();
318:                    fail("Unexpected error: " + t.toString());
319:                }
320:            }
321:
322:            /**
323:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getReturnType()</tt> with empty return type string.
324:             */
325:            public void testGetReturnTypeEmpty() {
326:                try {
327:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
328:                            "SomeName", "some description",
329:                            new MBeanParameterInfo[0], "",
330:                            MBeanOperationInfo.ACTION);
331:                } catch (Exception e) {
332:                    return;
333:                }
334:                fail("An empty return type is not a valid java identifier");
335:            }
336:
337:            /**
338:             * Tests <tt>MBeanOperationInfo</tt> creation and <tt>getReturnType()</tt> with <tt>null</tt> return type.
339:             */
340:            public void testGetReturnTypeNull() {
341:                try {
342:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
343:                            "SomeName", "some description",
344:                            new MBeanParameterInfo[0], "",
345:                            MBeanOperationInfo.ACTION);
346:                } catch (Exception e) {
347:                    return;
348:                }
349:                fail("A null return type is not a valid java identifier");
350:            }
351:
352:            public void testGetReturnTypeInvalid() {
353:                try {
354:                    MBeanOperationInfo info1 = new MBeanOperationInfo(
355:                            "SomeName", "some description",
356:                            new MBeanParameterInfo[0], "invalid type",
357:                            MBeanOperationInfo.ACTION);
358:                } catch (Exception e) {
359:                    return;
360:                }
361:                fail("'invalid type' return type is not a valid java identifier");
362:            }
363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.