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


001:        /*
002:         * @(#)TestClassParserUTest.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.junit.v1.parser;
028:
029:        import junit.framework.Test;
030:        import junit.framework.TestCase;
031:        import junit.framework.TestSuite;
032:
033:        import java.io.IOException;
034:        import java.lang.reflect.Method;
035:        import java.util.Vector;
036:
037:        /**
038:         * Tests the TestClassParser class.
039:         *
040:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
041:         * @since     March 1, 2002
042:         * @version   $Date: 2003/05/24 17:15:47 $
043:         */
044:        public class TestClassParserUTest extends TestCase {
045:            //-------------------------------------------------------------------------
046:            // Standard JUnit Class-specific declarations
047:
048:            private static final Class THIS_CLASS = TestClassParserUTest.class;
049:
050:            //    private static final IJUnitDocumentor LOG = (new JUnitLog(THIS_CLASS)).getDocumentor();
051:
052:            public TestClassParserUTest(String name) {
053:                super (name);
054:            }
055:
056:            //-------------------------------------------------------------------------
057:            // Tests
058:
059:            public void testConstructor1() {
060:                try {
061:                    new TestClassParser(null);
062:                } catch (IllegalArgumentException e) {
063:                    // test exception?
064:                }
065:            }
066:
067:            public void testConstructor2() {
068:                new TestClassParser(getClass());
069:            }
070:
071:            public static class TesterNoTestMethods implements  Test {
072:                public int countTestCases() {
073:                    return 0;
074:                }
075:
076:                public void run(junit.framework.TestResult tr) {
077:                }
078:            }
079:
080:            public static class TesterOneTestMethod implements  Test {
081:                public int countTestCases() {
082:                    return 0;
083:                }
084:
085:                public void run(junit.framework.TestResult tr) {
086:                }
087:
088:                public void testMyTest() {
089:                }
090:            }
091:
092:            public static class TesterBadMethod implements  Test {
093:                public int countTestCases() {
094:                    return 0;
095:                }
096:
097:                public void run(junit.framework.TestResult tr) {
098:                }
099:
100:                public void usedForTesting() {
101:                }
102:
103:                protected void testUsedForTesting() {
104:                }
105:            }
106:
107:            private class StaticClass {
108:            }
109:
110:            public class InnerClass {
111:            }
112:
113:            public void testGetTestMethods1() {
114:                TestClassParser tcp = new TestClassParser(String.class);
115:                Method m[] = tcp.getTestMethods();
116:                assertNotNull("Must never return null.", m);
117:                assertEquals("String should have no test methods.", 0, m.length);
118:                assertTrue(
119:                        "Must never return the same array, but rather a copy.",
120:                        m != tcp.getTestMethods());
121:            }
122:
123:            public void testGetTestMethods2() {
124:                TestClassParser tcp = new TestClassParser(Runnable.class);
125:                Method m[] = tcp.getTestMethods();
126:                assertNotNull("Must never return null.", m);
127:                assertEquals("Runnable should have no test methods.", 0,
128:                        m.length);
129:                assertTrue(
130:                        "Must never return the same array, but rather a copy.",
131:                        m != tcp.getTestMethods());
132:            }
133:
134:            public void testGetTestMethods3() {
135:                TestClassParser tcp = new TestClassParser(StaticClass.class);
136:                Method m[] = tcp.getTestMethods();
137:                assertNotNull("Must never return null.", m);
138:                assertEquals("Runnable should have no test methods.", 0,
139:                        m.length);
140:                assertTrue(
141:                        "Must never return the same array, but rather a copy.",
142:                        m != tcp.getTestMethods());
143:            }
144:
145:            public void testGetTestMethods4() {
146:                TestClassParser tcp = new TestClassParser(InnerClass.class);
147:                Method m[] = tcp.getTestMethods();
148:                assertNotNull("Must never return null.", m);
149:                assertEquals("Runnable should have no test methods.", 0,
150:                        m.length);
151:                assertTrue(
152:                        "Must never return the same array, but rather a copy.",
153:                        m != tcp.getTestMethods());
154:            }
155:
156:            public void testGetTestMethods5() {
157:                TestClassParser tcp = new TestClassParser(
158:                        TesterNoTestMethods.class);
159:                Method m[] = tcp.getTestMethods();
160:                assertNotNull("Must never return null.", m);
161:                assertEquals("Runnable should have no test methods.", 0,
162:                        m.length);
163:                assertTrue(
164:                        "Must never return the same array, but rather a copy.",
165:                        m != tcp.getTestMethods());
166:            }
167:
168:            public void testGetTestMethods6() {
169:                TestClassParser tcp = new TestClassParser(
170:                        TesterOneTestMethod.class);
171:                Method m[] = tcp.getTestMethods();
172:                assertNotNull("Must never return null.", m);
173:                assertEquals("Runnable should have one test method.", 1,
174:                        m.length);
175:                assertTrue(
176:                        "Must never return the same array, but rather a copy.",
177:                        m != tcp.getTestMethods());
178:            }
179:
180:            public void testClearWarnings1() {
181:                TestClassParser tcp = new TestClassParser(
182:                        TesterOneTestMethod.class);
183:                tcp.clearWarnings();
184:            }
185:
186:            public void testClearWarnings2() {
187:                TestClassParser tcp = new TestClassParser(Object.class);
188:                tcp.clearWarnings();
189:            }
190:
191:            public void testGetName1() {
192:                TestClassParser tcp = new TestClassParser(
193:                        TesterOneTestMethod.class);
194:                String name = tcp.getName();
195:                assertEquals("Returned invalid test name.",
196:                        TesterOneTestMethod.class.getName(), name);
197:            }
198:
199:            public void testGetName2() {
200:                TestClassParser tcp = new TestClassParser(Object.class);
201:                String name = tcp.getName();
202:                assertEquals("Returned invalid test name.", Object.class
203:                        .getName(), name);
204:            }
205:
206:            public void testAddTestMethod1() throws Exception {
207:                TestClassParser tcp = new TestClassParser(
208:                        TesterOneTestMethod.class);
209:                int warningCount = tcp.getWarnings().length;
210:                Vector v = new Vector();
211:                Method m = THIS_CLASS.getMethod("testAddTestMethod1",
212:                        new Class[0]);
213:                v.addElement("testAddTestMethod1");
214:                tcp.addTestMethod(m, v);
215:
216:                // ensure that there are more warnings
217:                assertEquals("Incorrectly changed the warnings.", warningCount,
218:                        tcp.getWarnings().length);
219:            }
220:
221:            public void testAddTestMethod2() throws Exception {
222:                TestClassParser tcp = new TestClassParser(TesterBadMethod.class);
223:                int warningCount = tcp.getWarnings().length;
224:                Vector v = new Vector();
225:                Method m = TesterBadMethod.class.getMethod("usedForTesting",
226:                        new Class[0]);
227:                tcp.addTestMethod(m, v);
228:
229:                // ensure that there are more warnings
230:                assertEquals("Incorrectly changed the warnings.", warningCount,
231:                        tcp.getWarnings().length);
232:            }
233:
234:            /* this is tested elsewhere.
235:            public void testAddTestMethod3() throws Exception
236:            {
237:                TestClassParser tcp = new TestClassParser( TesterBadMethod.class );
238:                int warningCount = tcp.getWarnings().length;
239:                Vector v = new Vector();
240:                Method m = TesterBadMethod.class.getMethod( "testUsedForTesting", new Class[0] );
241:                tcp.addTestMethod( m, v );
242:                
243:                // ensure that there are more warnings
244:                assertEquals(
245:                    "Did not add an additional warning.",
246:                    warningCount + 1,
247:                    tcp.getWarnings().length );
248:            }
249:            
250:            
251:            
252:            //-------------------------------------------------------------------------
253:            // Standard JUnit declarations
254:            
255:            
256:            public static Test suite()
257:            {
258:                TestSuite suite = new TestSuite( THIS_CLASS );
259:                
260:                return suite;
261:            }
262:            
263:            public static void main( String[] args )
264:            {
265:                String[] name = { THIS_CLASS.getName() };
266:                
267:                // junit.textui.TestRunner.main( name );
268:                // junit.swingui.TestRunner.main( name );
269:                
270:                junit.textui.TestRunner.main( name );
271:            }
272:            
273:            
274:            /**
275:             * 
276:             * @exception Exception thrown under any exceptional condition.
277:             */
278:            protected void setUp() throws Exception {
279:                super .setUp();
280:
281:                // set ourself up
282:            }
283:
284:            /**
285:             * 
286:             * @exception Exception thrown under any exceptional condition.
287:             */
288:            protected void tearDown() throws Exception {
289:                // tear ourself down
290:
291:                super.tearDown();
292:            }
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.