Source Code Cross Referenced for InfoTortureTestCase.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » jbossmx » compliance » standard » 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 » testsuite » org.jboss.test.jbossmx.compliance.standard 
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 org.jboss.test.jbossmx.compliance.standard;
023:
024:        import javax.management.MBeanInfo;
025:        import javax.management.MBeanOperationInfo;
026:
027:        import junit.framework.Test;
028:        import junit.framework.TestSuite;
029:
030:        import org.jboss.test.jbossmx.compliance.TestCase;
031:        import org.jboss.test.jbossmx.compliance.standard.support.Torture;
032:        import org.jboss.util.platform.Java;
033:
034:        /**
035:         * Beat the heck out of the server's standard MBeanInfo
036:         *
037:         * @author  <a href="mailto:trevor@protocool.com">Trevor Squires</a>.
038:         * @author  <a href="mailto:dimitris@jboss.org">Dimitris Andreadis</a>.
039:         */
040:        public class InfoTortureTestCase extends TestCase {
041:            private static int attributeTestCount = 0;
042:            private static int operationTestCount = 0;
043:            private static int constructorTestCount = 0;
044:
045:            public InfoTortureTestCase(String s) {
046:                super (s);
047:            }
048:
049:            public static Test suite() {
050:                TestSuite testSuite = new TestSuite(
051:                        "All MBeanInfo Torture Tests for Standard MBeans");
052:
053:                Object mbean = new Torture();
054:                MBeanInfo info = InfoUtil.getMBeanInfo(mbean,
055:                        "test:type=mbeaninfo");
056:
057:                // Tests for valid constructors
058:                addConstructorTest(testSuite, info, Torture.class.getName(),
059:                        new String[0]);
060:                addConstructorTest(testSuite, info, Torture.class.getName(),
061:                        new String[] { String[][].class.getName() });
062:
063:                // make sure we are testing all exposed constructors (each ValidConstructorTest increments a counter
064:                // which is used to figure out whether we have adequate test coverage)
065:                testSuite.addTest(new TestCoverageTEST(
066:                        "Torture constructor list length",
067:                        constructorTestCount, info.getConstructors().length));
068:
069:                // Tests for attributes that should not be there
070:                addSpuriousAttributeTest(testSuite, info, "peachy");
071:                addSpuriousAttributeTest(testSuite, info, "Peachy");
072:                addSpuriousAttributeTest(testSuite, info, "suer");
073:                addSpuriousAttributeTest(testSuite, info, "settlement");
074:                addSpuriousAttributeTest(testSuite, info, "Result");
075:                addSpuriousAttributeTest(testSuite, info, "Multi");
076:
077:                // make sure remaining attributes are correct
078:                // Args are: Name, Type, Readable, Writable, IsIS
079:                addAttributeTest(testSuite, info, "NiceString", String.class
080:                        .getName(), true, true, false);
081:
082:                // JBAS-3746, conditionally exclude this test on JRockit 1.5
083:                boolean jrockit = System.getProperty("java.vm.name").indexOf(
084:                        "JRockit") > -1;
085:                if (Java.isVersion(Java.VERSION_1_5) && jrockit) {
086:                    // exclude the test but keep the test coverage count
087:                    ++attributeTestCount;
088:                } else {
089:                    // include the test
090:                    addAttributeTest(testSuite, info, "NiceBoolean",
091:                            boolean.class.getName(), true, true, true);
092:                }
093:
094:                addAttributeTest(testSuite, info, "Something", String.class
095:                        .getName(), false, true, false);
096:                addAttributeTest(testSuite, info, "Int", int.class.getName(),
097:                        false, true, false);
098:                addAttributeTest(testSuite, info, "IntArray", int[].class
099:                        .getName(), false, true, false);
100:                addAttributeTest(testSuite, info, "NestedIntArray",
101:                        int[][][].class.getName(), false, true, false);
102:                addAttributeTest(testSuite, info, "Integer", Integer.class
103:                        .getName(), false, true, false);
104:                addAttributeTest(testSuite, info, "IntegerArray",
105:                        Integer[].class.getName(), false, true, false);
106:                addAttributeTest(testSuite, info, "NestedIntegerArray",
107:                        Integer[][][].class.getName(), false, true, false);
108:                addAttributeTest(testSuite, info, "Myinteger", int.class
109:                        .getName(), true, false, false);
110:                addAttributeTest(testSuite, info, "MyintegerArray", int[].class
111:                        .getName(), true, false, false);
112:                addAttributeTest(testSuite, info, "MyNestedintegerArray",
113:                        int[][][].class.getName(), true, false, false);
114:                addAttributeTest(testSuite, info, "MyInteger", Integer.class
115:                        .getName(), true, false, false);
116:                addAttributeTest(testSuite, info, "MyIntegerArray",
117:                        Integer[].class.getName(), true, false, false);
118:                addAttributeTest(testSuite, info, "MyNestedIntegerArray",
119:                        Integer[][][].class.getName(), true, false, false);
120:                addAttributeTest(testSuite, info, "ready", boolean.class
121:                        .getName(), true, false, true);
122:
123:                // this is *not* an attribute, it must appear as an operation
124:                //addAttributeTest(testSuite, info, "Ready", Boolean.class.getName(), true, false, true);
125:
126:                // make sure we are testing all exposed attributes (each ValidAttributeTest increments a counter
127:                // which is used to figure out whether we have adequate test coverage)
128:                testSuite.addTest(new TestCoverageTEST(
129:                        "Torture attribute list length", attributeTestCount,
130:                        info.getAttributes().length));
131:
132:                // validate the operations
133:                // Args are: Name, impact, returnTypeString, SignatureAsStringArray
134:                addOperationTest(testSuite, info, "settlement",
135:                        MBeanOperationInfo.UNKNOWN, int.class.getName(),
136:                        new String[] { String.class.getName() });
137:                addOperationTest(testSuite, info, "getSomething",
138:                        MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(),
139:                        new String[0]);
140:                addOperationTest(testSuite, info, "ispeachy",
141:                        MBeanOperationInfo.UNKNOWN, boolean.class.getName(),
142:                        new String[] { int.class.getName() });
143:                addOperationTest(testSuite, info, "isPeachy",
144:                        MBeanOperationInfo.UNKNOWN, Boolean.class.getName(),
145:                        new String[] { int.class.getName() });
146:                addOperationTest(testSuite, info, "setMulti",
147:                        MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(),
148:                        new String[] { String.class.getName(),
149:                                Integer.class.getName() });
150:                addOperationTest(testSuite, info, "getResult",
151:                        MBeanOperationInfo.UNKNOWN, String.class.getName(),
152:                        new String[] { String.class.getName() });
153:                addOperationTest(testSuite, info, "setNothing",
154:                        MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(),
155:                        new String[0]);
156:                addOperationTest(testSuite, info, "getNothing",
157:                        MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(),
158:                        new String[0]);
159:                addOperationTest(testSuite, info, "doSomethingCrazy",
160:                        MBeanOperationInfo.UNKNOWN, String[][].class.getName(),
161:                        new String[] { Object[].class.getName(),
162:                                String[].class.getName(),
163:                                int[][][].class.getName() });
164:                // Hmmm... This fails in the RI (which causes the operation coverage test to fail too.
165:                // it's odd because in the RI issuer() isn't treated as an attribute and it doesn't
166:                // appear as an operation - it just disappears!
167:                addOperationTest(testSuite, info, "issuer",
168:                        MBeanOperationInfo.UNKNOWN, String.class.getName(),
169:                        new String[0]);
170:
171:                // this must appear as an operation, not an attribute
172:                addOperationTest(testSuite, info, "isReady",
173:                        MBeanOperationInfo.UNKNOWN, Boolean.class.getName(),
174:                        new String[0]);
175:
176:                // make sure we are testing all exposed operations (each ValidOperationTest increments a counter
177:                // which is used to figure out whether we have adequate test coverage)
178:                testSuite.addTest(new TestCoverageTEST(
179:                        "Torture operation list length", operationTestCount,
180:                        info.getOperations().length));
181:
182:                return testSuite;
183:            }
184:
185:            public static void addConstructorTest(TestSuite testSuite,
186:                    MBeanInfo info, String name, String[] signature) {
187:                testSuite.addTest(new ConstructorInfoTEST(
188:                        "InfoTortureSUITE constructor", info, name, signature));
189:                constructorTestCount++;
190:            }
191:
192:            public static void addSpuriousAttributeTest(TestSuite testSuite,
193:                    MBeanInfo info, String name) {
194:                testSuite.addTest(new SpuriousAttributeTEST(
195:                        "InfoTortureSUITE spuriousAttribute", info, name));
196:            }
197:
198:            public static void addAttributeTest(TestSuite testSuite,
199:                    MBeanInfo info, String name, String type, boolean read,
200:                    boolean write, boolean is) {
201:                testSuite.addTest(new AttributeInfoTEST(
202:                        "InfoTortureSUITE attribute", info, name, type, read,
203:                        write, is));
204:                attributeTestCount++;
205:            }
206:
207:            public static void addOperationTest(TestSuite testSuite,
208:                    MBeanInfo info, String name, int impact, String returnType,
209:                    String[] signature) {
210:                testSuite.addTest(new OperationInfoTEST(
211:                        "InfoTortureSUITE operation", info, name, impact,
212:                        returnType, signature));
213:                operationTestCount++;
214:            }
215:
216:            public static class TestCoverageTEST extends TestCase {
217:                private String msg;
218:                private int expected;
219:                private int got;
220:
221:                public TestCoverageTEST(String msg, int expected, int got) {
222:                    super ("testAdequateCoverage");
223:                    this .msg = msg;
224:                    this .expected = expected;
225:                    this .got = got;
226:                }
227:
228:                public void testAdequateCoverage() {
229:                    assertEquals(msg, expected, got);
230:                }
231:            }
232:
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.