Source Code Cross Referenced for TestCaseLogger.java in  » Testing » TestGen4J » com » spikesource » spiketestgen » 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 » Testing » TestGen4J » com.spikesource.spiketestgen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * TestCaseLogger.java
003:         * TestGen4J is licensed under Open Software License 2.1
004:         * For details, please refer to:
005:         * http://www.opensource.org/licenses/osl-2.1.php   
006:         */package com.spikesource.spiketestgen;
007:
008:        import java.io.BufferedWriter;
009:        import java.io.File;
010:        import java.io.FileWriter;
011:        import java.io.IOException;
012:
013:        /**
014:         * Generates LogTestCase.java that logs successful and failed test cases
015:         * while test case execution.
016:         *
017:         * @version 0.1.4-alpha
018:         * @author Manish Marathe
019:         */
020:        public class TestCaseLogger {
021:            /**
022:             * This method logs the test cases which are failed.
023:             *
024:             * @param outputDIR
025:             *                      Name of output directory.
026:             * @throws IOException
027:             *                      Throws IOException.
028:             */
029:            public final void logTestCase(final String outputDIR)
030:                    throws IOException {
031:
032:                BufferedWriter out = logTestCase1(outputDIR);
033:                logTestCase2(out, outputDIR);
034:                logTestCase3(out, outputDIR);
035:                logTestCase4(out, outputDIR);
036:                out.write("/**");
037:                out.newLine();
038:                out.write("* Creates an XML file to store");
039:                out.newLine();
040:                out.write("* failed test cases.");
041:                out.newLine();
042:                out.newLine();
043:                out.write("* @param outputDIR");
044:                out.newLine();
045:                out.write("*                   Name of the output directory.");
046:                out.newLine();
047:                out.write("* @throws IOException");
048:                out.newLine();
049:                out.write("*                      " + "Throws IOException.");
050:                out.newLine();
051:                out.write("*/");
052:                out.newLine();
053:                out.newLine();
054:                out.write(" public static void createFailedXMLDataFile(");
055:                out.newLine();
056:                out.write("  final String outputDIR) throws IOException {");
057:                out.newLine();
058:                out.newLine();
059:                out
060:                        .write("  File file = new File(outputDIR, \"failedData.xml\");");
061:                out.newLine();
062:                out.write("  BufferedWriter out = new");
063:                out.newLine();
064:                out.write("     BufferedWriter(new FileWriter(file, true));");
065:                out.newLine();
066:                out.write("  out.write(\"<?xml version = \\\"1.0\\\" "
067:                        + "encoding = \\\"UTF-8\\\"?>\");");
068:                out.newLine();
069:                out.write("  out.newLine();");
070:                out.newLine();
071:                out.write("  out.write(\"<tests xmlns:xsi = \\\"http://\"");
072:                out.newLine();
073:                out.write(" + \"www.w3.org/2001/XMLSchema-instance\\\"\");");
074:                out.newLine();
075:                out.write("  out.newLine();");
076:                out.newLine();
077:                out
078:                        .write("  out.write(\"        xsi:noNamespaceSchemaLocation\"");
079:                out.newLine();
080:                out
081:                        .write("     + \"= \\\"/root/workspace/spiketestgen/src/com/\"");
082:                out.newLine();
083:                out
084:                        .write("     + \"spikesource/unitfab/failedData.xsd\\\">\");");
085:                out.newLine();
086:                out.write("  out.newLine();");
087:                out.newLine();
088:                out.write("  out.flush();");
089:                out.newLine();
090:                out.write("  out.close();");
091:                out.newLine();
092:                out.write(" }");
093:                out.newLine();
094:                out.newLine();
095:                out.write("/**");
096:                out.newLine();
097:                out.write("* Ends XML file that stores failed test cases.");
098:                out.newLine();
099:                out.newLine();
100:                out.write("* @param outputDIR");
101:                out.newLine();
102:                out.write("*                   Name of the output directory.");
103:                out.newLine();
104:                out.write("* @throws IOException");
105:                out.newLine();
106:                out.write("*                      " + "Throws IOException.");
107:                out.newLine();
108:                out.write("*/");
109:                out.newLine();
110:                out.newLine();
111:                out.write(" public static void endFailedXMLDataFile(");
112:                out.newLine();
113:                out.write("  final String outputDIR) throws IOException {");
114:                out.newLine();
115:                out.newLine();
116:                out
117:                        .write("  File file = new File(outputDIR, \"failedData.xml\");");
118:                out.newLine();
119:                out.write("  BufferedWriter out = new");
120:                out.newLine();
121:                out.write("    BufferedWriter(new FileWriter(file, true));");
122:                out.newLine();
123:                out.write("  out.write(\"</tests>\");");
124:                out.newLine();
125:                out.write("  out.flush();");
126:                out.newLine();
127:                out.write("  out.close();");
128:                out.newLine();
129:                out.write(" }");
130:                out.newLine();
131:                out.newLine();
132:
133:                out.write("/**");
134:                out.newLine();
135:                out.write("* Ends XML file that stores failed test cases.");
136:                out.newLine();
137:                out.newLine();
138:                out.write("* @param outputDIR");
139:                out.newLine();
140:                out.write("*                   Name of the output directory.");
141:                out.newLine();
142:                out.write("* @throws IOException");
143:                out.newLine();
144:                out.write("*                      " + "Throws IOException.");
145:                out.newLine();
146:                out.write("*/");
147:                out.newLine();
148:                out.newLine();
149:                out.write(" public static void createFailedTestLog(");
150:                out.newLine();
151:                out.write("  final String outputDIR) throws IOException {");
152:                out.newLine();
153:                out.newLine();
154:                out.write("  File file = new File("
155:                        + "outputDIR, \"TestFailure.log\");");
156:                out.newLine();
157:                out.write("  BufferedWriter out = new");
158:                out.newLine();
159:                out.write("    BufferedWriter(new FileWriter(file, true));");
160:                out.newLine();
161:                out.write("  out.write(\"This File contains Test Cases ");
162:                out.write("which failed\");");
163:                out.newLine();
164:                out.write("  out.newLine();");
165:                out.newLine();
166:                out.write("  out.newLine();");
167:                out.newLine();
168:                out.write("  out.newLine();");
169:                out.newLine();
170:                out.write("  out.flush();");
171:                out.newLine();
172:                out.write("  out.close();");
173:                out.newLine();
174:                out.write(" }");
175:                out.newLine();
176:                out.write("}");
177:                out.newLine();
178:                out.newLine();
179:                out.flush();
180:                out.close();
181:            }
182:
183:            /**
184:             * LogTestCase 1.
185:             *
186:             * @param outputDIR
187:             *                      Output Directory.
188:             * @return
189:             *                      BufferedWriter object.
190:             * @throws IOException
191:             *                      Throws IOException.
192:             */
193:            public final BufferedWriter logTestCase1(final String outputDIR)
194:                    throws IOException {
195:                BufferedWriter out;
196:                String testClassFileName = "LogTestCase.java";
197:                File file = new File(outputDIR, testClassFileName);
198:
199:                if (file.exists()) {
200:                    file.delete();
201:                }
202:
203:                out = new BufferedWriter(new FileWriter(file, true));
204:                out.write("/**");
205:                out.newLine();
206:                out.write("* Generated by TestGen4J.");
207:                out.newLine();
208:                out.write("* Copyright (C) 2005 SpikeSource, Inc.");
209:                out.newLine();
210:                out.write("*/");
211:                out.newLine();
212:                out.newLine();
213:                out.write("import java.io.BufferedWriter;");
214:                out.newLine();
215:                out.write("import java.io.File;");
216:                out.newLine();
217:                out.write("import java.io.FileWriter;");
218:                out.newLine();
219:                out.write("import java.io.IOException;");
220:                out.newLine();
221:                out.newLine();
222:                out.write("/**");
223:                out.newLine();
224:                out.write("* This class log successful and failed test cases.");
225:                out.newLine();
226:                out.write("*/");
227:                out.newLine();
228:                out.write("public final class LogTestCase {");
229:                out.newLine();
230:                out.newLine();
231:                out.write("/**");
232:                out.newLine();
233:                out.write("* Local object of PackageTestSuite class.");
234:                out.newLine();
235:                out.write("*/");
236:                out.newLine();
237:                out.newLine();
238:                out.write("    private static PackageTestSuite pkgsuite;");
239:                out.newLine();
240:                out.newLine();
241:                out.write("/**");
242:                out.newLine();
243:                out.write("* Private constructor for LogTestCase.");
244:                out.newLine();
245:                out.write("*/");
246:                out.newLine();
247:                out.newLine();
248:                out.write(" private LogTestCase() {");
249:                out.newLine();
250:                out.newLine();
251:                out.write(" }");
252:                out.newLine();
253:                out.newLine();
254:                out.write("/**");
255:                out.newLine();
256:                out.write("* Logs successful test cases for original");
257:                out.newLine();
258:                out.write("* method having more than one arguments.");
259:                out.newLine();
260:                out.newLine();
261:                out.write("* @param testClassName");
262:                out.newLine();
263:                out.write("*                      Name of the test class.");
264:                out.newLine();
265:                out.write("* @param methodName");
266:                out.newLine();
267:                out.write("*                      Test method name.");
268:                out.newLine();
269:                out.write("* @param parameters");
270:                out.newLine();
271:                out.write("*                      "
272:                        + "Arguments of the original method.");
273:                out.newLine();
274:                out.newLine();
275:                out.write("* @param successfulTestCase");
276:                out.newLine();
277:                out.write("*                      "
278:                        + "Successful test case number.");
279:                out.newLine();
280:                out.newLine();
281:                out.write("* @throws IOException");
282:                out.newLine();
283:                out.write("*                      " + "Throws IOException.");
284:                out.newLine();
285:                out.write("*/");
286:                out.newLine();
287:                out.newLine();
288:                out.write(" public static void logSuccessfulTest(");
289:                out.newLine();
290:                out.write("    final String testClassName,");
291:                out.newLine();
292:                out.write("    final String methodName,");
293:                out.newLine();
294:                out.write("    final Object[] parameters,");
295:                out.newLine();
296:                out.write("    final String successfulTestCase)");
297:                out.newLine();
298:                out.write("     throws IOException {");
299:                out.newLine();
300:                out.newLine();
301:                out.write("    File logFile = new File(\"" + outputDIR
302:                        + "\" , \"TestSuccess.log\");");
303:                out.newLine();
304:                out.write("    BufferedWriter out;");
305:                out.newLine();
306:                out.newLine();
307:                out.write("    out = new BufferedWriter(");
308:                out.newLine();
309:                out.write("        new FileWriter(logFile, true));");
310:                out.newLine();
311:                out
312:                        .write("    out.write(\"***********************************\"");
313:                out.newLine();
314:                out.write("       + \"*************************************\"");
315:                out.newLine();
316:                out.write("       + \"**************\"); out.newLine();");
317:                out.newLine();
318:                out.write("    out.write(\"* Congratulation: Asserting test\"");
319:                out.newLine();
320:                out.write("       + \"result Succeed\"); out.newLine();");
321:                out.newLine();
322:                out.write("    out.write(\"* Test Class: \""
323:                        + "       + testClassName); out.newLine();");
324:                out.newLine();
325:                out.write("    out.write(\"* Test Method: \""
326:                        + "       + methodName); out.newLine();");
327:                out.newLine();
328:                out.write("    out.write(\"* Test Case No: \""
329:                        + "       + successfulTestCase); out.newLine();");
330:                out.newLine();
331:                out.newLine();
332:                out.write("    for (int i = 0;");
333:                out.newLine();
334:                out.write("      i < parameters.length;");
335:                out.newLine();
336:                out.write("    i++) {");
337:                out.newLine();
338:                out.write("            if (parameters[i] == null) {");
339:                out.newLine();
340:                out.write("              out.write(\"* var\" + (i + 1)");
341:                out.newLine();
342:                out
343:                        .write("               + \": Value--> NULL\"); out.newLine();");
344:                out.newLine();
345:                out.write("            } else {");
346:                out.newLine();
347:                out.write("              out.write(\"* var\" + (i + 1)");
348:                out.newLine();
349:                out.write("               + \" : Value--> \" + parameters[i].");
350:                out.newLine();
351:                out.write("               toString()); out.newLine();");
352:                out.newLine();
353:                out.write("            }");
354:                out.newLine();
355:                out.write("         }");
356:                out.newLine();
357:                out.newLine();
358:                out
359:                        .write("    out.write(\"***********************************\"");
360:                out.newLine();
361:                out.write("       + \"*************************************\"");
362:                out.newLine();
363:                out.write("       + \"**************\"); out.newLine();");
364:                out.newLine();
365:                out.newLine();
366:                out.write("    out.flush();");
367:                out.newLine();
368:                out.write("    out.close();");
369:                out.newLine();
370:                out.write("  }");
371:                out.newLine();
372:                out.newLine();
373:                out.flush();
374:                return out; //out.close();
375:            }
376:
377:            /**
378:             * LogTestCase Method 2.
379:             *
380:             * @param out
381:             *                       BufferedWriter Object.
382:             * @param outputDIR
383:             *                       Output directory.
384:             * @throws IOException
385:             *                       Throws IOException.
386:             */
387:            public final void logTestCase2(final BufferedWriter out,
388:                    final String outputDIR) throws IOException {
389:
390:                out.write("/**");
391:                out.newLine();
392:                out.write("* Logs successful test cases for original");
393:                out.newLine();
394:                out.write("* method having only one arguments.");
395:                out.newLine();
396:                out.newLine();
397:                out.write("* @param testClassName");
398:                out.newLine();
399:                out.write("*                      Name of the test class.");
400:                out.newLine();
401:                out.write("* @param methodName");
402:                out.newLine();
403:                out.write("*                      Test method name.");
404:                out.newLine();
405:                out.write("* @param parameters");
406:                out.newLine();
407:                out.write("*                      "
408:                        + "Argument of the original method.");
409:                out.newLine();
410:                out.newLine();
411:                out.write("* @param successfulTestCase");
412:                out.newLine();
413:                out.write("*                      "
414:                        + "Successful test case number.");
415:                out.newLine();
416:                out.newLine();
417:                out.write("* @throws IOException");
418:                out.newLine();
419:                out.write("*                      " + "Throws IOException.");
420:                out.newLine();
421:                out.write("*/");
422:                out.newLine();
423:                out.newLine();
424:                out.write(" public static void logSuccessfulTest(");
425:                out.newLine();
426:                out.write("    final String testClassName,");
427:                out.newLine();
428:                out.write("    final String methodName,");
429:                out.newLine();
430:                out.write("    final Object parameters,");
431:                out.newLine();
432:                out.write("    final String successfulTestCase)");
433:                out.newLine();
434:                out.write("     throws IOException {");
435:                out.newLine();
436:                out.newLine();
437:                out.write("    File logFile = new File(\"" + outputDIR
438:                        + "\" , \"TestSuccess.log\");");
439:                out.newLine();
440:                out.write("    BufferedWriter out;");
441:                out.newLine();
442:                out.newLine();
443:                out.write("    out = new BufferedWriter(");
444:                out.newLine();
445:                out.write("        new FileWriter(logFile, true));");
446:                out.newLine();
447:                out
448:                        .write("    out.write(\"***********************************\"");
449:                out.newLine();
450:                out.write("       + \"*************************************\"");
451:                out.newLine();
452:                out.write("       + \"**************\"); out.newLine();");
453:                out.newLine();
454:                out.write("    out.write(\"* Congratulation: Asserting test\"");
455:                out.newLine();
456:                out.write("       + \"result Succeed\"); out.newLine();");
457:                out.newLine();
458:                out.write("    out.write(\"* Test Class: \""
459:                        + "       + testClassName); out.newLine();");
460:                out.newLine();
461:                out.write("    out.write(\"* Test Method: \""
462:                        + "       + methodName); out.newLine();");
463:                out.newLine();
464:                out.write("    out.write(\"* Test Case No: \""
465:                        + "       + successfulTestCase); out.newLine();");
466:                out.newLine();
467:                out.newLine();
468:                out.write("    if (parameters == null) {");
469:                out.newLine();
470:                out.write("              out.write(\"* var1\"");
471:                out.newLine();
472:                out
473:                        .write("               + \": Value--> NULL\"); out.newLine();");
474:                out.newLine();
475:                out.write("    } else {");
476:                out.newLine();
477:                out.write("              out.write(\"* var1\"");
478:                out.newLine();
479:                out.write("               + \" : Value--> \" + parameters.");
480:                out.newLine();
481:                out.write("               toString()); out.newLine();");
482:                out.newLine();
483:                out.write("    }");
484:                out.newLine();
485:                out.newLine();
486:                out
487:                        .write("    out.write(\"***********************************\"");
488:                out.newLine();
489:                out.write("       + \"*************************************\"");
490:                out.newLine();
491:                out.write("       + \"**************\"); out.newLine();");
492:                out.newLine();
493:                out.newLine();
494:                out.write("    out.flush();");
495:                out.newLine();
496:                out.write("    out.close();");
497:                out.newLine();
498:                out.write("  }");
499:                out.newLine();
500:                out.newLine();
501:                out.flush(); //out.close();
502:            }
503:
504:            /**
505:             * LogTestCase Method 3.
506:             *
507:             * @param out
508:             *                      BufferedWriter object.
509:             * @param outputDIR
510:             *                      Output Directory.
511:             * @throws IOException
512:             *                      Throws IOException.
513:             */
514:            public final void logTestCase3(final BufferedWriter out,
515:                    final String outputDIR) throws IOException {
516:
517:                out.write("/**");
518:                out.newLine();
519:                out.write("* Logs failed test cases for original");
520:                out.newLine();
521:                out.write("* method having more than one arguments.");
522:                out.newLine();
523:                out.newLine();
524:                out.write("* @param testClassName");
525:                out.newLine();
526:                out.write("*                      Name of the test class.");
527:                out.newLine();
528:                out.write("* @param methodName");
529:                out.newLine();
530:                out.write("*                      Test method name.");
531:                out.newLine();
532:                out.write("* @param parameters");
533:                out.newLine();
534:                out.write("*                      "
535:                        + "Argument of the original method.");
536:                out.newLine();
537:                out.newLine();
538:                out.write("* @param failedTestCase");
539:                out.newLine();
540:                out.write("*                      "
541:                        + "Failed test case number.");
542:                out.newLine();
543:                out.newLine();
544:                out.write("* @param error");
545:                out.newLine();
546:                out.write("*                      " + "Error description.");
547:                out.newLine();
548:                out.newLine();
549:                out.write("* @throws IOException");
550:                out.newLine();
551:                out.write("*                      " + "Throws IOException.");
552:                out.newLine();
553:                out.write("*/");
554:                out.newLine();
555:                out.newLine();
556:                out.write(" public static void logFailedTest(");
557:                out.newLine();
558:                out.write("    final String testClassName,");
559:                out.newLine();
560:                out.write("    final String methodName,");
561:                out.newLine();
562:                out.write("    final Object[] parameters,");
563:                out.newLine();
564:                out.write("    final String failedTestCase,");
565:                out.newLine();
566:                out.write("    final String error)");
567:                out.newLine();
568:                out.write("     throws IOException {");
569:                out.newLine();
570:                out.newLine();
571:                out.write("    File logFile = new File(\"" + outputDIR
572:                        + "\", \"TestFailure.log\");");
573:                out.newLine();
574:                out.write("    File failedXMLDataFile = new File(");
575:                out.newLine();
576:                out.write("     \"" + outputDIR + "\" , \"failedData.xml\");");
577:                out.newLine();
578:                out.write("    BufferedWriter out;");
579:                out.newLine();
580:                out.newLine();
581:                out.write("    if (!pkgsuite.excludeFileExists) {");
582:                out.newLine();
583:                out.write("       out = new BufferedWriter(new FileWriter(");
584:                out.newLine();
585:                out.write("          failedXMLDataFile, true));");
586:                out.newLine();
587:                out.write("       out.write(\"                <class name\"");
588:                out.newLine();
589:                out
590:                        .write("       + \"= \\\"\" + testClassName + \"\\\" > \");");
591:                out.newLine();
592:                out.write("       out.newLine();");
593:                out.newLine();
594:                out.write("       out.write(\"                        ");
595:                out.write("       <method name\"");
596:                out.newLine();
597:                out
598:                        .write("       + \"= \\\"\" + methodName + \"\\\" test-case\"");
599:                out.newLine();
600:                out
601:                        .write("       + \"= \\\"\" + failedTestCase + \"\\\" > \");");
602:                out.newLine();
603:                out.write("       out.newLine();");
604:                out.newLine();
605:                out.write("       out.write(\"                        ");
606:                out.write("</method>\");");
607:                out.newLine();
608:                out.write("       out.newLine();");
609:                out.newLine();
610:                out.write("       out.write(\"                </class>\");");
611:                out.newLine();
612:                out.write("       out.newLine();");
613:                out.newLine();
614:                out.write("       out.flush();");
615:                out.newLine();
616:                out.write("       out.close();");
617:                out.newLine();
618:                out.write("    }");
619:                out.newLine();
620:                out.newLine();
621:                out.write("    out = new BufferedWriter(new FileWriter(");
622:                out.newLine();
623:                out.write("        logFile, true));");
624:                out.newLine();
625:                out
626:                        .write("    out.write(\"***********************************\"");
627:                out.newLine();
628:                out.write("       + \"*************************************\"");
629:                out.newLine();
630:                out.write("       + \"**************\"); out.newLine();");
631:                out.newLine();
632:                out.newLine();
633:                out
634:                        .write("    out.write(\"* Error: \" + error); out.newLine();");
635:                out.newLine();
636:                out.write("    out.write(\"* Test Class: \" + testClassName);");
637:                out.newLine();
638:                out.write("    out.newLine();");
639:                out.newLine();
640:                out.write("    out.write(\"* Test Method: \" + methodName);");
641:                out.newLine();
642:                out.write("    out.newLine();");
643:                out.newLine();
644:                out.write("    out.write(\"* Failed Test Case: \" "
645:                        + "       + failedTestCase);");
646:                out.newLine();
647:                out.write("    out.newLine();");
648:                out.newLine();
649:                out.newLine();
650:                out.write("    for (int i = 0;");
651:                out.newLine();
652:                out.write("      i < parameters.length;");
653:                out.newLine();
654:                out.write("    i++) {");
655:                out.newLine();
656:                out.write("            if (parameters[i] == null) {");
657:                out.newLine();
658:                out.write("              out.write(\"* var\" + (i + 1)");
659:                out.newLine();
660:                out
661:                        .write("               + \": Value--> NULL\"); out.newLine();");
662:                out.newLine();
663:                out.write("            } else {");
664:                out.newLine();
665:                out.write("              out.write(\"* var\" + (i + 1)");
666:                out.newLine();
667:                out.write("               + \" : Value--> \" + parameters[i].");
668:                out.newLine();
669:                out.write("               toString()); out.newLine();");
670:                out.newLine();
671:                out.write("            }");
672:                out.newLine();
673:                out.write("         }");
674:                out.newLine();
675:                out.newLine();
676:                out
677:                        .write("    out.write(\"***********************************\"");
678:                out.newLine();
679:                out.write("       + \"*************************************\"");
680:                out.newLine();
681:                out.write("       + \"**************\"); out.newLine();");
682:                out.newLine();
683:                out.newLine();
684:                out.write("    out.flush();");
685:                out.newLine();
686:                out.write("    out.close();");
687:                out.newLine();
688:                out.write("  }");
689:                out.newLine();
690:                out.newLine();
691:                out.flush(); //out.close();
692:            }
693:
694:            /**
695:             * LogTestCase Method 4.
696:             *
697:             * @param out
698:             *                       BufferedWriter object.
699:             * @param outputDIR
700:             *                       Output directory.
701:             * @throws IOException
702:             *                       Throws IOException.
703:             */
704:            public final void logTestCase4(final BufferedWriter out,
705:                    final String outputDIR) throws IOException {
706:
707:                out.write("/**");
708:                out.newLine();
709:                out.write("* Logs failed test cases for original");
710:                out.newLine();
711:                out.write("* method having only one argument.");
712:                out.newLine();
713:                out.newLine();
714:                out.write("* @param testClassName");
715:                out.newLine();
716:                out.write("*                      Name of the test class.");
717:                out.newLine();
718:                out.write("* @param methodName");
719:                out.newLine();
720:                out.write("*                      Test method name.");
721:                out.newLine();
722:                out.write("* @param parameters");
723:                out.newLine();
724:                out.write("*                      "
725:                        + "Argument of the original method.");
726:                out.newLine();
727:                out.newLine();
728:                out.write("* @param failedTestCase");
729:                out.newLine();
730:                out.write("*                      "
731:                        + "Failed test case number.");
732:                out.newLine();
733:                out.newLine();
734:                out.write("* @param error");
735:                out.newLine();
736:                out.write("*                      " + "Error description.");
737:                out.newLine();
738:                out.newLine();
739:                out.write("* @throws IOException");
740:                out.newLine();
741:                out.write("*                      " + "Throws IOException.");
742:                out.newLine();
743:                out.write("*/");
744:                out.newLine();
745:                out.newLine();
746:                out.write(" public static void logFailedTest(");
747:                out.newLine();
748:                out.write("    final String testClassName,");
749:                out.newLine();
750:                out.write("    final String methodName,");
751:                out.newLine();
752:                out.write("    final Object parameters,");
753:                out.newLine();
754:                out.write("    final String failedTestCase,");
755:                out.newLine();
756:                out.write("    final String error)");
757:                out.newLine();
758:                out.write("     throws IOException {");
759:                out.newLine();
760:                out.newLine();
761:                out.write("    File logFile = new File(\"" + outputDIR
762:                        + "\", \"TestFailure.log\");");
763:                out.newLine();
764:                out.write("    File failedXMLDataFile = new File(");
765:                out.newLine();
766:                out.write("     \"" + outputDIR + "\" , \"failedData.xml\");");
767:                out.newLine();
768:                out.write("    BufferedWriter out;");
769:                out.newLine();
770:                out.newLine();
771:                out.write("    if (!pkgsuite.excludeFileExists) {");
772:                out.newLine();
773:                out.write("       out = new BufferedWriter(new FileWriter(");
774:                out.newLine();
775:                out.write("          failedXMLDataFile, true));");
776:                out.newLine();
777:                out.write("       out.write(\"                <class name\"");
778:                out.newLine();
779:                out
780:                        .write("       + \"= \\\"\" + testClassName + \"\\\" > \");");
781:                out.newLine();
782:                out.write("       out.newLine();");
783:                out.newLine();
784:                out.write("       out.write(\"                        ");
785:                out.write("       <method name\"");
786:                out.newLine();
787:                out
788:                        .write("       + \"= \\\"\" + methodName + \"\\\" test-case\"");
789:                out.newLine();
790:                out
791:                        .write("       + \"= \\\"\" + failedTestCase + \"\\\" > \");");
792:                out.newLine();
793:                out.write("       out.newLine();");
794:                out.newLine();
795:                out.write("       out.write(\"                        ");
796:                out.write("</method>\");");
797:                out.newLine();
798:                out.write("       out.newLine();");
799:                out.newLine();
800:                out.write("       out.write(\"                </class>\");");
801:                out.newLine();
802:                out.write("       out.newLine();");
803:                out.newLine();
804:                out.write("       out.flush();");
805:                out.newLine();
806:                out.write("       out.close();");
807:                out.newLine();
808:                out.write("    }");
809:                out.newLine();
810:                out.newLine();
811:                out.write("    out = new BufferedWriter(new FileWriter(");
812:                out.newLine();
813:                out.write("        logFile, true));");
814:                out.newLine();
815:                out
816:                        .write("    out.write(\"***********************************\"");
817:                out.newLine();
818:                out.write("       + \"*************************************\"");
819:                out.newLine();
820:                out.write("       + \"**************\"); out.newLine();");
821:                out.newLine();
822:                out.newLine();
823:                out
824:                        .write("    out.write(\"* Error: \" + error); out.newLine();");
825:                out.newLine();
826:                out.write("    out.write(\"* Test Class: \" + testClassName);");
827:                out.newLine();
828:                out.write("    out.newLine();");
829:                out.newLine();
830:                out.write("    out.write(\"* Test Method: \" + methodName);");
831:                out.newLine();
832:                out.write("    out.newLine();");
833:                out.newLine();
834:                out.write("    out.write(\"* Failed Test Case: \" "
835:                        + "       + failedTestCase);");
836:                out.newLine();
837:                out.write("    out.newLine();");
838:                out.newLine();
839:                out.newLine();
840:                out.write("            if (parameters == null) {");
841:                out.newLine();
842:                out.write("              out.write(\"* var1\"");
843:                out.newLine();
844:                out
845:                        .write("               + \": Value--> NULL\"); out.newLine();");
846:                out.newLine();
847:                out.write("            } else {");
848:                out.newLine();
849:                out.write("              out.write(\"* var1\"");
850:                out.newLine();
851:                out.write("               + \" : Value--> \" + parameters.");
852:                out.newLine();
853:                out.write("               toString()); out.newLine();");
854:                out.newLine();
855:                out.write("            }");
856:                out.newLine();
857:                out.newLine();
858:                out
859:                        .write("    out.write(\"***********************************\"");
860:                out.newLine();
861:                out.write("       + \"*************************************\"");
862:                out.newLine();
863:                out.write("       + \"**************\"); out.newLine();");
864:                out.newLine();
865:                out.newLine();
866:                out.write("    out.flush();");
867:                out.newLine();
868:                out.write("    out.close();");
869:                out.newLine();
870:                out.write("  }");
871:                out.newLine();
872:                out.newLine();
873:                out.flush(); //out.close();
874:            }
875:
876:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.