Source Code Cross Referenced for IMethodCodeUTestI.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » codecoverage » v2 » 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 » Test Coverage » GroboUtils » net.sourceforge.groboutils.codecoverage.v2 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)IMethodCodeUTestI.java
003:         *
004:         * Copyright (C) 2002,2003 Matt Albrecht
005:         * groboclown@users.sourceforge.net
006:         * http://groboutils.sourceforge.net
007:         *
008:         *  Permission is hereby granted, free of charge, to any person obtaining a
009:         *  copy of this software and associated documentation files (the "Software"),
010:         *  to deal in the Software without restriction, including without limitation
011:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
012:         *  and/or sell copies of the Software, and to permit persons to whom the 
013:         *  Software is furnished to do so, subject to the following conditions:
014:         *
015:         *  The above copyright notice and this permission notice shall be included in 
016:         *  all copies or substantial portions of the Software. 
017:         *
018:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
019:         *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
020:         *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
021:         *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
022:         *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
023:         *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
024:         *  DEALINGS IN THE SOFTWARE.
025:         */
026:
027:        package net.sourceforge.groboutils.codecoverage.v2;
028:
029:        import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
030:        import net.sourceforge.groboutils.codecoverage.v2.module.DefaultAnalysisMetaData;
031:        import net.sourceforge.groboutils.junit.v1.iftc.ImplFactory;
032:        import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestCase;
033:        import net.sourceforge.groboutils.junit.v1.iftc.InterfaceTestSuite;
034:
035:        import org.apache.bcel.classfile.Method;
036:
037:        /**
038:         * Tests the IMethodCode interface.
039:         *
040:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
041:         * @version   $Date: 2004/04/15 05:48:27 $
042:         * @since     December 28, 2002
043:         */
044:        public class IMethodCodeUTestI extends InterfaceTestCase {
045:            //-------------------------------------------------------------------------
046:            // Standard JUnit Class-specific declarations
047:
048:            private static final Class THIS_CLASS = IMethodCodeUTestI.class;
049:            private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
050:
051:            public IMethodCodeUTestI(String name, ImplFactory f) {
052:                super (name, IMethodCode.class, f);
053:            }
054:
055:            public IMethodCode createIMethodCode() {
056:                return (IMethodCode) createImplObject();
057:            }
058:
059:            //-------------------------------------------------------------------------
060:            // Tests
061:
062:            public void testGetOriginalMethod1() {
063:                IMethodCode mc = createIMethodCode();
064:                Method m = mc.getOriginalMethod();
065:                assertNotNull("Must not return null original method.", m);
066:            }
067:
068:            public void testGetMethod1() {
069:                IMethodCode mc = createIMethodCode();
070:                assertNotNull("Method name is null.", mc.getMethodName());
071:            }
072:
073:            public void testGetClassName1() {
074:                IMethodCode mc = createIMethodCode();
075:                assertNotNull("Class name is null.", mc.getClassName());
076:            }
077:
078:            public void testGetInstructionCount1() {
079:                IMethodCode mc = createIMethodCode();
080:                int count = mc.getInstructionCount();
081:                assertTrue("Count is not valid", count >= 0);
082:            }
083:
084:            public void testMethodName1() {
085:                IMethodCode mc = createIMethodCode();
086:                Method m = mc.getOriginalMethod();
087:                String name = mc.getMethodName();
088:                assertEquals(
089:                        "Method name doesn't match returned method's name", m
090:                                .getName()
091:                                + m.getSignature(), name);
092:            }
093:
094:            public void testInstructionConsistency1() {
095:                IMethodCode mc = createIMethodCode();
096:                int count = mc.getInstructionCount();
097:                for (int i = 0; i < count; ++i) {
098:                    assertNotNull("Null instruction at position " + i + ".", mc
099:                            .getInstructionAt(i));
100:                }
101:            }
102:
103:            public void testInstructionConsistency2() {
104:                IMethodCode mc = createIMethodCode();
105:                int count = mc.getInstructionCount();
106:                try {
107:                    mc.getInstructionAt(-1);
108:                    fail("Did not throw excption w/ -1 index.");
109:                } catch (IndexOutOfBoundsException e) {
110:                    // test exception
111:                }
112:
113:                try {
114:                    mc.getInstructionAt(count);
115:                    fail("Did not throw exception w/ " + count + " index.");
116:                } catch (IndexOutOfBoundsException e) {
117:                    // test exception
118:                }
119:            }
120:
121:            public void testMarkInstruction1() {
122:                IMethodCode mc = createIMethodCode();
123:                int count = mc.getInstructionCount();
124:                if (count <= 0) {
125:                    DOC.getLog().warn(
126:                            "No instructions to mark for '" + mc + "'.");
127:                    return;
128:                }
129:
130:                // something to test
131:                //   note: we can mark the last index + one over it!
132:                for (int i = 0; i <= count; ++i) {
133:                    IAnalysisMetaData meta = new DefaultAnalysisMetaData("",
134:                            "", (byte) 0);
135:                    mc.markInstruction(i, meta);
136:                }
137:            }
138:
139:            public void testMarkInstruction2() {
140:                IMethodCode mc = createIMethodCode();
141:
142:                try {
143:                    IAnalysisMetaData meta = new DefaultAnalysisMetaData("",
144:                            "", (byte) 0);
145:                    mc.markInstruction(-1, meta);
146:                    fail("Did not throw IndexOutOfBoundsException.");
147:                } catch (IndexOutOfBoundsException e) {
148:                    // test exception
149:                }
150:            }
151:
152:            public void testMarkInstruction4() {
153:                IMethodCode mc = createIMethodCode();
154:                int count = mc.getInstructionCount();
155:
156:                try {
157:                    IAnalysisMetaData meta = new DefaultAnalysisMetaData("",
158:                            "", (byte) 0);
159:                    mc.markInstruction(count + 1, meta);
160:                    fail("Did not throw IndexOutOfBoundsException.");
161:                } catch (IndexOutOfBoundsException e) {
162:                    // test exception
163:                }
164:            }
165:
166:            public void testMarkInstruction5() {
167:                IMethodCode mc = createIMethodCode();
168:                int count = mc.getInstructionCount();
169:
170:                // even if the instruction count is == 0, we can still mark it,
171:                // hence this will be a valid test for 'null' metadata.
172:
173:                // something to test
174:                try {
175:                    mc.markInstruction(0, null);
176:                    fail("Did not throw IllegalArgumentException.");
177:                } catch (IllegalArgumentException e) {
178:                    // test exception
179:                }
180:            }
181:
182:            //-------------------------------------------------------------------------
183:            // Standard JUnit declarations
184:
185:            public static InterfaceTestSuite suite() {
186:                InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
187:
188:                return suite;
189:            }
190:
191:            public static void main(String[] args) {
192:                String[] name = { THIS_CLASS.getName() };
193:
194:                // junit.textui.TestRunner.main( name );
195:                // junit.swingui.TestRunner.main( name );
196:
197:                junit.textui.TestRunner.main(name);
198:            }
199:
200:            /**
201:             * 
202:             * @exception Exception thrown under any exceptional condition.
203:             */
204:            protected void setUp() throws Exception {
205:                super .setUp();
206:
207:                // set ourself up
208:            }
209:
210:            /**
211:             * 
212:             * @exception Exception thrown under any exceptional condition.
213:             */
214:            protected void tearDown() throws Exception {
215:                // tear ourself down
216:
217:                super.tearDown();
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.