OpenKeyWord  Build_ID: 457, Datum: 01.02.2020 07:45:48
Dont repeat yourself. - Do it once and only once!
Log2HTML.java
1 package okw.log.log2html;
2 
3 import java.io.BufferedWriter;
4 import java.io.File;
5 import java.io.FileOutputStream;
6 import java.io.FileWriter;
7 import java.io.IOException;
8 import java.io.InputStream;
9 import java.io.OutputStreamWriter;
10 import java.io.Writer;
11 import java.util.List;
12 import java.util.Locale;
13 import java.util.Stack;
14 
15 import com.fasterxml.jackson.databind.ObjectMapper;
16 import com.fasterxml.jackson.databind.SerializationFeature;
17 
18 import okw.log.ILogger;
19 
20 
21 // http://www.java-blog-buch.de/d-plugin-entwicklung-in-java/
22 
23 public class Log2HTML extends LogBaseNode implements ILogger
24 {
25 
26  // Das ist das Root-Objekt, der Pointer wird im Konstruktor zuerst auf den root/Wurzel gesetzt,
27  // LogBase Point2LogObject;
28  private Stack<LogBase> Pointer2LogBaseStack = new Stack<LogBase>();
29 
30 
31  // name des Features, welches hier getestet wird.
32  private String name = "";
33 
34  // result - das Ergebniss des Features welche hier representiert wird.
35  private String result = ""; // mögliche Werte "success"
36 
37  public Log2HTML()
38  {
39  this.myDuration.startTimer();
40  Pointer2LogBaseStack.push(this);
41  }
42 
43 
44  public Log2HTML( String featereName )
45  {
46  this.myDuration.startTimer();;
47  this.name = featereName;
48 
49  Pointer2LogBaseStack.push(this);
50  }
51 
52 
53  public void LogPass(String fpsMessage)
54  {
55  AllCount++;
56 
57  Pointer2LogBaseStack.peek().myLogs.add( new LogPass(Pointer2LogBaseStack.peek(), fpsMessage) );
58  }
59 
60 
61  public void LogPrint(String fpsMessage)
62  {
63  AllCount++;
64 
65  Pointer2LogBaseStack.peek().myLogs.add( new LogPrint(Pointer2LogBaseStack.peek(), fpsMessage) );
66  }
67 
68 
69  public void LogPrintDebug( String fpsMessage )
70  {
71  AllCount++;
72 
73  Pointer2LogBaseStack.peek().myLogs.add( new LogPrintDebug(Pointer2LogBaseStack.peek(), fpsMessage) );
74  }
75 
76 
77  public void LogWarning(String fpsMessage)
78  {
79  AllCount++;
80 
81  Pointer2LogBaseStack.peek().myLogs.add( new LogWarning(Pointer2LogBaseStack.peek(), fpsMessage) );
82  }
83 
84 
85  public void LogError(String fpsMessage)
86  {
87  AllCount++;
88 
89  Pointer2LogBaseStack.peek().myLogs.add( new LogError(Pointer2LogBaseStack.peek(), fpsMessage) );
90  }
91 
92 
93  public void LogException(String fpsMessage)
94  {
95  AllCount++;
96 
97  Pointer2LogBaseStack.peek().myLogs.add( new LogException(Pointer2LogBaseStack.peek(), fpsMessage) );
98  }
99 
100 
101  public void LogSourceLocation( String Start, String End, String featureName, String sourceType )
102  {
103  AllCount++;
104 
105  Pointer2LogBaseStack.peek().myLogs.add( new LogSourceLocation(Pointer2LogBaseStack.peek(), Start, End, featureName, sourceType) );
106  }
107 
108 
109  public void LogFunctionStart(String fps_FunctionName, String... fpsParameter)
110  {
111  AllCount++;
112 
113  LogBase myLog = new LogFunction( Pointer2LogBaseStack.peek(), fps_FunctionName, fpsParameter);
114 
115  // Timer starten
116  myLog.myDuration.startTimer();
117 
118  Pointer2LogBaseStack.peek().myLogs.add(myLog);
119  Pointer2LogBaseStack.push(myLog);
120 
121  }
122 
123 
124  public void LogFunctionStartDebug( String fps_FunctionName, String... fpsParameter )
125  {
126  AllCount++;
127 
128  LogBase myLog = new LogFunctionDebug( Pointer2LogBaseStack.peek(), fps_FunctionName, fpsParameter);
129 
130  // Timer starten
131  myLog.myDuration.startTimer();
132 
133  Pointer2LogBaseStack.peek().myLogs.add(myLog);
134  Pointer2LogBaseStack.push(myLog);
135  }
136 
137 
138  public void LogFunctionEnd()
139  {
140  LogBase myLog = Pointer2LogBaseStack.pop();
141  // Timer Stoppen...
142  myLog.myDuration.stopTimer();
143 
144  @SuppressWarnings( "unused" )
145  LogFunction myLogFunction = (LogFunction)myLog;
146 
147  if ( !(myLog.bError || myLog.bException) )
148  {
149  FunctionPass++;
150  }
151  }
152 
153 
154  public void LogFunctionEndDebug()
155  {
156  LogBase myLog = Pointer2LogBaseStack.pop();
157  // Timer Stoppen...
158  myLog.myDuration.stopTimer();
159 
160  @SuppressWarnings( "unused" )
161  LogFunctionDebug myLogFunction = (LogFunctionDebug)myLog;
162 
163  if ( !(myLog.bError || myLog.bException) )
164  {
165  FunctionPass++;
166  }
167  }
168 
169 
170  public void LogFunctionEndDebug( Boolean fpb_Return )
171  {
172  LogBase myLog = Pointer2LogBaseStack.pop();
173  // Timer Stoppen...
174  myLog.myDuration.stopTimer();
175 
176  LogFunctionDebug myLogFunction = (LogFunctionDebug)myLog;
177  myLogFunction.setReturn( fpb_Return.toString());
178 
179  if ( !(myLog.bError || myLog.bException) )
180  {
181  FunctionPass++;
182  }
183  }
184 
185 
186  public void LogFunctionEnd(Boolean Return)
187  {
188  LogBase myLog = Pointer2LogBaseStack.pop();
189  // Timer Stoppen...
190  myLog.myDuration.stopTimer();
191 
192  LogFunction myLogFunction = (LogFunction)myLog;
193  myLogFunction.setReturn( Return.toString());
194 
195  if ( !(myLog.bError || myLog.bException) )
196  {
197  FunctionPass++;
198  }
199  }
200 
201 
202  public void LogFunctionEnd( String fps_Return )
203  {
204  LogBase myLog = Pointer2LogBaseStack.pop();
205  // Timer Stoppen...
206  myLog.myDuration.stopTimer();
207 
208  LogFunction myLogFunction = (LogFunction)myLog;
209  myLogFunction.setReturn( fps_Return);
210 
211  if ( !(myLog.bError || myLog.bException) )
212  {
213  FunctionPass++;
214  }
215  }
216 
217 
218  public void LogFunctionEndDebug( String fps_Return )
219  {
220  LogBase myLog = Pointer2LogBaseStack.pop();
221  // Timer Stoppen...
222  myLog.myDuration.stopTimer();
223 
224  LogFunctionDebug myLogFunction = (LogFunctionDebug)myLog;
225  myLogFunction.setReturn( fps_Return);
226 
227  if ( !(myLog.bError || myLog.bException) )
228  {
229  FunctionPass++;
230  }
231  }
232 
233 
234  public void LogFunctionEnd( List<String> fps_Return )
235  {
236  LogBase myLog = Pointer2LogBaseStack.pop();
237  // Timer Stoppen...
238  myLog.myDuration.stopTimer();
239 
240  LogFunction myLogFunction = (LogFunction)myLog;
241 
242  // TODO: ein ResultListstring hier einhängen
243  myLogFunction.setReturn( fps_Return.toString());
244 
245  if ( !(myLog.bError || myLog.bException) )
246  {
247  FunctionPass++;
248  }
249  }
250 
251  public void LogFunctionEndDebug( List<String> fps_Return )
252  {
253  LogBase myLog = Pointer2LogBaseStack.pop();
254  // Timer Stoppen...
255  myLog.myDuration.stopTimer();
256 
257  LogFunctionDebug myLogFunction = (LogFunctionDebug)myLog;
258 
259  // TODO: ein ResultListstring hier einhängen
260  myLogFunction.setReturn( fps_Return.toString());
261 
262  if ( !(myLog.bError || myLog.bException) )
263  {
264  FunctionPass++;
265  }
266  }
267 
268 
269  public void LogTestcaseStart(String fps_FunctionName)
270  {
271  AllCount++;
272 
273  StopAllTimerAndEmptyStack();
274  Pointer2LogBaseStack.push( this );
275 
276  LogBase myLog = new LogTestcase( Pointer2LogBaseStack.peek(), fps_FunctionName);
277 
278  // Timer starten
279  myLog.myDuration.startTimer();
280 
281  Pointer2LogBaseStack.peek().myLogs.add(myLog);
282  Pointer2LogBaseStack.push(myLog);
283  }
284 
285  public void LogTestcaseEnd()
286  {
287  LogBase myLog = Pointer2LogBaseStack.pop();
288  // Timer Stoppen...
289  myLog.myDuration.stopTimer();
290 
291  @SuppressWarnings( "unused" )
292  LogTestcase myCheck = (LogTestcase)myLog;
293 
294  if ( !(myLog.bError || myLog.bException))
295  {
296  TestcasePass++;
297  }
298 
299  StopAllTimerAndEmptyStack();
300  }
301 
302 
303  public void LogKeyWordStart(String fps_FunctionName, String... fpsParameter)
304  {
305  AllCount++;
306 
307  LogBase myLog = new LogKeyword( Pointer2LogBaseStack.peek(), fps_FunctionName, fpsParameter);
308 
309  // Timer starten
310  myLog.myDuration.startTimer();
311 
312  Pointer2LogBaseStack.peek().myLogs.add(myLog);
313  Pointer2LogBaseStack.push(myLog);
314  }
315 
316 
317  public void LogKeyWordEnd()
318  {
319  LogBase myLog = Pointer2LogBaseStack.peek();
320  // Timer Stoppen...
321  myLog.myDuration.stopTimer();
322 
323  @SuppressWarnings( "unused" )
324  LogKeyword myCheck = (LogKeyword)myLog;
325 
326  if ( !(myLog.bError || myLog.bException))
327  {
328  myLog.KeyWordPass( );
329  }
330 
331  Pointer2LogBaseStack.pop();
332 
333  }
334 
335 
336  public void LogLocalACCallStart( String sourceExcerpt, String Type )
337  {
338  AllCount++;
339 
340  LogBase myLog = new LogLocalACCall( Pointer2LogBaseStack.peek(), sourceExcerpt, Type );
341 
342  // Timer starten
343  myLog.myDuration.startTimer();
344 
345  Pointer2LogBaseStack.peek().myLogs.add(myLog);
346  Pointer2LogBaseStack.push(myLog);
347  }
348 
349 
350  public void LogLocalACCallEnd()
351  {
352  LogBase myLog = Pointer2LogBaseStack.peek();
353  // Timer Stoppen...
354  myLog.myDuration.stopTimer();
355 
356  @SuppressWarnings( "unused" )
357  LogLocalACCall myCheck = (LogLocalACCall)myLog;
358 
359  if ( !(myLog.bError || myLog.bException))
360  {
361  myLog.LocalACCallPass( );
362  }
363 
364  Pointer2LogBaseStack.pop();
365  }
366 
396  public void LogStepStart( String categoryName, String categoryType,
397  String choiceValue, String featureName,
398  String localCategoryName, String sourceExcerpt,
399  String type )
400  {
401  AllCount++;
402 
403  LogBase myLog = new LogStep( Pointer2LogBaseStack.peek(), categoryName, categoryType, choiceValue, featureName, localCategoryName, sourceExcerpt, type );
404 
405  // Timer starten
406  myLog.myDuration.startTimer();
407 
408  Pointer2LogBaseStack.peek().myLogs.add( myLog );
409  Pointer2LogBaseStack.push( myLog );
410  }
411 
412 
413  public void LogStepEnd()
414  {
415  LogBase myLog = Pointer2LogBaseStack.peek();
416  // Timer Stoppen...
417  myLog.myDuration.stopTimer();
418 
419  @SuppressWarnings( "unused" )
420  LogStep myCheck = (LogStep)myLog;
421 
422  if ( !(myLog.bError || myLog.bException))
423  {
424  StepPass++;
425  }
426 
427  Pointer2LogBaseStack.pop();
428  }
429 
430 
431 
432 
433  public void LogRemoteACCallStart( String sourceExcerpt, String Type )
434  {
435  AllCount++;
436 
437  LogBase myLog = new LogRemoteACCall( Pointer2LogBaseStack.peek(), sourceExcerpt, Type );
438 
439  // Timer starten
440  myLog.myDuration.startTimer();
441 
442  Pointer2LogBaseStack.peek().myLogs.add(myLog);
443  Pointer2LogBaseStack.push(myLog);
444  }
445 
446 
447  public void LogRemoteACCallEnd()
448  {
449  LogBase myLog = Pointer2LogBaseStack.peek();
450  // Timer Stoppen...
451  myLog.myDuration.stopTimer();
452 
453  @SuppressWarnings( "unused" )
454  LogRemoteACCall myCheck = (LogRemoteACCall)myLog;
455 
456  if ( !(myLog.bError || myLog.bException))
457  {
458  StepPass++;
459  }
460 
461  Pointer2LogBaseStack.pop();
462  }
463 
464 
465  public void LogSequenceStart( String fpsKeywordName, String fpsWindowFN, String fpsSequenceName, String... fpsParameter)
466  {
467  AllCount++;
468 
469  LogBase myLog = new LogSequence( Pointer2LogBaseStack.peek(), fpsWindowFN, fpsSequenceName, fpsParameter);
470 
471  // Timer starten
472  myLog.myDuration.startTimer();
473 
474  Pointer2LogBaseStack.peek().myLogs.add(myLog);
475  Pointer2LogBaseStack.push(myLog);
476  }
477 
478 
479  public void LogSequenceEnd()
480  {
481  LogBase myLog = Pointer2LogBaseStack.peek();
482  // Timer Stoppen...
483  myLog.myDuration.stopTimer();
484 
485  @SuppressWarnings( "unused" )
486  LogSequence myCheck = (LogSequence)myLog;
487 
488  if ( !(myLog.bError || myLog.bException))
489  {
490  myLog.SequencePass();
491  }
492 
493  Pointer2LogBaseStack.pop();
494  }
495 
496 
497  private String getHTMLFooter()
498  {
499  StringBuilder myResult = new StringBuilder();
500 
501  myResult.append("</body>\n");
502  myResult.append("</html>\n");
503 
504  return myResult.toString();
505  }
506 
507 
508  private String getHTMLHeader() throws IOException
509  {
510  StringBuilder myResult = new StringBuilder();
511 
512  myResult.append("<!DOCTYPE html>\n");
513  myResult.append("<html lang=\"en\">\n");
514  myResult.append("<head>\n");
515  myResult.append("\t<title>TestPage Titel</title>\n");
516 
517  // -----------------------------------------
518  // OKW is utf-8 based...
519  myResult.append("\t<meta charset=\"utf-8\"/>\n");
520 
521  // -----------------------------------------
522  // insert Log2HTML.css direct into the HTML-Code: No link-refernce!
523 
524  myResult.append( "\t<style>\n" );
525  myResult.append( getStyleSheet() );
526  myResult.append( "\t</style>\n" );
527 
528  myResult.append("</head>\n");
529  myResult.append("<body>\n");
530  myResult.append( getFoldScript() );
531  myResult.append("<div class=OKW_Logo title='www.openkeyword.de'></div>\n");
532  myResult.append("<h1>OpenKeyWord Testlog</h1>\n");
533  return myResult.toString();
534  }
535 
536  private String getStyleSheet() throws IOException
537  {
538  StringBuilder myResult = new StringBuilder();
539 
540  ClassLoader loader = Thread.currentThread().getContextClassLoader();
541  InputStream is = loader.getResourceAsStream("Log2HTML.css");
542 
543  byte[] buffer = new byte[2048];
544  int length;
545 
546  while ((length = is.read(buffer)) != -1)
547  {
548  myResult.append(new String(buffer, 0, length));
549  }
550  is.close();
551 
552  return myResult.toString();
553  }
554 
555  private String getFoldScript() throws IOException
556  {
557  StringBuilder myResult = new StringBuilder();
558 
559  ClassLoader loader = Thread.currentThread().getContextClassLoader();
560  InputStream is = loader.getResourceAsStream("folder.script");
561 
562  byte[] buffer = new byte[2048];
563  int length;
564 
565  while ((length = is.read(buffer)) != -1)
566  {
567  myResult.append(new String(buffer, 0, length));
568  }
569  is.close();
570 
571  return myResult.toString();
572  }
573 
574 
575  private String getHTMLStatistics()
576  {
577  StringBuilder myResult = new StringBuilder();
578 
579  myResult.append("<h2>Test Statistics</h2>\n");
580 
581 
582  myResult.append("<table class='statistics'>\n");
583 
584  myResult.append("\t<thead class='statistics'>\n");
585  myResult.append("\t\t<tr class='statistics'>\n");
586  myResult.append("\t\t\t<th></th>\n");
587  myResult.append("\t\t\t<th>Count</th>\n");
588  myResult.append("\t\t\t<th colspan='3'></th>\n");
589  myResult.append("\t\t</tr>\n");
590  myResult.append("\t</thead>\n");
591 
592 
593  // myResult.append("\t<tbody>\n");
594 
595  myResult.append("\t\t<tr>\n");
596  myResult.append("\t\t\t<td class='right'>Errors:</td>\n");
597  myResult.append("\t\t\t<td class='center'>" + ErrorCount.toString() + "</td>\n");
598  myResult.append("\t\t\t<td colspan='3'></td>\n");
599  myResult.append("\t\t</tr>\n");
600 
601  myResult.append("\t\t<tr>\n");
602  myResult.append("\t\t\t<td class='right'>Exceptions:</td>\n");
603  myResult.append("\t\t\t<td class='center'>" + ExceptionCount.toString() + "</td>\n");
604  myResult.append("\t\t\t<td colspan='3'></td>\n"); myResult.append("\t\t</tr>\n");
605 
606  myResult.append("\t\t<tr>\n");
607  myResult.append("\t\t\t<td class='right'>Warnings:</td>\n");
608  myResult.append("\t\t\t<td class='center'>" + WarningCount.toString() + "</td>\n");
609  myResult.append("\t\t\t<td colspan='3'></td>\n"); myResult.append("\t\t</tr>\n");
610 
611  myResult.append("\t\t<tr>\n");
612  myResult.append("\t\t\t<td class='right'>Passed:</td>\n");
613  myResult.append("\t\t\t<td class='center'>" + PassedCount.toString() + "</td>\n");
614  myResult.append("\t\t\t<td colspan='3'></td>\n"); myResult.append("\t\t</tr>\n");
615 
616 
617  myResult.append("\t\t<tr class='statistics'>\n");
618  myResult.append("\t\t\t<th></th>\n");
619  myResult.append("\t\t\t<th class='widthfix'>Count</th>\n");
620  myResult.append("\t\t\t<th class='widthfix'>Pass</th>\n");
621  myResult.append("\t\t\t<th class='widthfix'>Fail</th>\n");
622  myResult.append("\t\t\t<th>Pass-Fail-Rate</th>\n");
623  myResult.append("\t\t</tr>\n");
624 
625  myResult.append("\t\t<tr>\n");
626  myResult.append("\t\t\t<td class='right'>Test cases:</td>\n");
627  myResult.append("\t\t\t<td class='center'>" + TestcaseCount.toString() + "</td>\n");
628  myResult.append("\t\t\t<td class='center'>" + TestcasePass.toString() + "</td>\n");
629  myResult.append("\t\t\t<td class='center'>" + TestcaseFail.toString() + "</td>\n");
630  myResult.append("\t\t\t<td>" + getFailPassBar(TestcaseFail, TestcaseCount - TestcaseFail) + "</td>\n");
631  myResult.append("\t\t</tr>\n");
632 
633 
634  myResult.append("\t\t<tr>\n");
635  myResult.append("\t\t\t<td class='right'>Sequences:</td>\n");
636  myResult.append("\t\t\t<td class='center'>" + SequenceCount.toString() + "</td>\n");
637  myResult.append("\t\t\t<td class='center'>" + SequencePass.toString() + "</td>\n");
638  myResult.append("\t\t\t<td class='center'>" + SequenceFail.toString() + "</td>\n");
639  myResult.append("\t\t\t<td >" + getFailPassBar(SequenceFail, SequenceCount - SequenceFail) + "</td>\n");
640  myResult.append("\t\t</tr>\n");
641 
642  myResult.append("\t\t<tr>\n");
643  myResult.append("\t\t\t<td class='right'>Keywords:</td>\n");
644  myResult.append("\t\t\t<td class='center'>" + KeyWordCount.toString() + "</td>\n");
645  myResult.append("\t\t\t<td class='center'>" + KeyWordPass.toString() + "</td>\n");
646  myResult.append("\t\t\t<td class='center'>" + KeyWordFail.toString() + "</td>\n");
647  myResult.append("\t\t\t<td>" + getFailPassBar(KeyWordFail, KeyWordCount-KeyWordFail) + "</td>\n");
648  myResult.append("\t\t</tr>\n");
649 
650  myResult.append("\t\t<tr class='statistics'>\n");
651  myResult.append("\t\t\t<th colspan='5'>Timer</th>\n");
652  myResult.append("\t\t</tr>\n");
653 
654 
655  myResult.append("\t\t<tr>\n");
656  myResult.append("\t\t\t<td class='right'>Start time:</td>\n");
657  myResult.append("\t\t\t<td class='center' colspan='4'>" + this.myDuration.getStartTime() + "</td>\n");
658  myResult.append("\t\t</tr>\n");
659 
660  myResult.append("\t\t<tr>\n");
661  myResult.append("\t\t\t<td class='right'>End time:</td>\n");
662  myResult.append("\t\t\t<td class='center' colspan='4'>" + this.myDuration.getEndTime() + "</td>\n");
663  myResult.append("\t\t</tr>\n");
664  myResult.append("</table>\n");
665 
666  return myResult.toString();
667  }
668 
669 
670  private String getFailPassBar(int FailCount, int PassCount)
671  {
672  StringBuilder myResult = new StringBuilder();
673 
674  if (FailCount+PassCount > 0)
675  {
676  float lfFailRate = FailCount * 100f / (FailCount + PassCount );
677  float lfPassRate = 100f - lfFailRate;
678 
679  myResult.append("<div class='pass-fail-graph'>\n");
680  myResult.append("\t<div class='pass-bar' style='width: " + String.format (Locale.ENGLISH, "%.2f", lfPassRate) + "%'></div>\n");
681  myResult.append("\t<div class='fail-bar' style='width: " + String.format (Locale.ENGLISH, "%.2f", lfFailRate) + "%'></div>\n");
682  myResult.append("</div>\n");
683  }
684 
685  return myResult.toString();
686  }
687 
688 
689  public void old_Result2HTML(String fpsFilename)
690  {
691 
692  StringBuilder myResult = new StringBuilder();
693 
694  try{
695 
696  StopAllTimerAndEmptyStack();
697 
698  myResult.append(getHTMLHeader());
699  myResult.append(getHTMLStatistics());
700 
701  myResult.append("<h2>Result Log</h2>\n");
702  myResult.append(getHTMLResult());
703  myResult.append(getHTMLFooter());
704 
705  File fileDir = new File( fpsFilename );
706 
707  Writer out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(fileDir), "UTF8"));
708 
709  out.append(myResult.toString());
710 
711  out.flush();
712  out.close();
713  }
714  catch(Exception e)
715  {
716  System.out.print(e.getMessage());
717  }
718  }
719 
720  public void Result2HTML( String fpsFilename )
721  {
722 
723  StringBuilder myResult = new StringBuilder();
724 
725  try
726  {
727 
728  StopAllTimerAndEmptyStack();
729 
730  myResult.append( getHTMLHeader() );
731  myResult.append( getHTMLStatistics() );
732 
733  myResult.append( "<h2>Result Log</h2>\n" );
734  myResult.append( getHTMLResult() );
735  myResult.append( getHTMLFooter() );
736 
737  FileWriter fw = new FileWriter( fpsFilename );
738  BufferedWriter bw = new BufferedWriter( fw );
739 
740  bw.write( myResult.toString() );
741 
742  bw.close();
743  }
744  catch (Exception e)
745  {
746  System.out.print( e.getMessage() );
747  }
748  }
749 
750  protected String getHTMLResult()
751  {
752  StringBuilder sbResult = new StringBuilder();
753 
754  for( LogBase myLog: this.myLogs )
755  {
756  sbResult.append( myLog.getHTMLResult() );
757  }
758 
759  return sbResult.toString();
760  }
761 
762 
763  public String Result2JSON( String fpsFileName )
764  {
765  StringBuilder myJSON = new StringBuilder();
766  String myJSONReturn = "";
767 
768  try
769  {
770  StopAllTimerAndEmptyStack();
771 
772  myJSON.append( getJSONHeader() );
773  myJSON.append( this.jsonStructureComma( "statistics", this.getJSONStatistics() ) );
774 
775  myJSON.append( this.jsonArray( "features", this.jsonArrayElement( this.getJSONResult() )));
776  myJSON.append( getJSONFooter());
777 
778  myJSONReturn = this.beautify( myJSON.toString() );
779 
780  System.out.print( myJSON.toString() );
781 
782  // Write jason-File
783  FileWriter fw = new FileWriter( fpsFileName );
784  BufferedWriter bw = new BufferedWriter(fw);
785 
786  bw.write( myJSONReturn );
787 
788  bw.close();
789  }
790  catch(Exception e)
791  {
792  System.out.print(e.getMessage());
793  }
794 
795  return myJSONReturn;
796  }
797 
798 
799  private String getJSONHeader()
800  {
801  StringBuilder myResult = new StringBuilder();
802 
803  myResult.append("{");
804 
805  return myResult.toString();
806  }
807 
808 
809  protected String getJSONResult()
810  {
811  StringBuilder myJSON = new StringBuilder();
812  StringBuilder myJSONForLoop = new StringBuilder();
813 
814  //
815  myJSON.append( this.jsonElementComma( "name", this.name ) );
816  myJSON.append( this.jsonElement( "result", this.result ) );
817 
818  Boolean GreaterOne = false;
819 
820  for( LogBase myLog: this.myLogs )
821  {
822  if (GreaterOne) myJSONForLoop.append( ", " );
823  else GreaterOne = true;
824  myJSONForLoop.append( this.jsonArrayElement( myLog.getJSONResult() ) ) ;
825 
826  }
827 
828  if (GreaterOne)
829  myJSON.append( ", " + this.jsonArray( "tests", myJSONForLoop.toString() ) );
830 
831 
832 
833 
834  return myJSON.toString();
835  }
836 
837  private String getJSONFooter()
838  {
839  StringBuilder myResult = new StringBuilder();
840 
841  myResult.append("}");
842 
843  return myResult.toString();
844  }
845 
846  String beautify(String json)
847 {
848 
849  String myReturn = "";
850 
851  ObjectMapper mapper = new ObjectMapper();
852  mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
853  Object obj;
854  try
855  {
856  obj = mapper.readValue(json, Object.class);
857  myReturn = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
858  }
859  catch ( Exception e)
860  {
861  // TODO Auto-generated catch block
862  e.printStackTrace();
863  }
864 
865 
866  return myReturn;
867  }
868 
869  protected void abort()
870  {
871  }
872 
873 
874  public void ResOpenList( String fps_ListHeader )
875  {
876  AllCount++;
877 
878  LogBase myLog = new ResultList( Pointer2LogBaseStack.peek(), fps_ListHeader);
879 
880  // Timer starten
881  myLog.myDuration.startTimer();
882 
883  Pointer2LogBaseStack.peek().myLogs.add(myLog);
884  Pointer2LogBaseStack.push(myLog);
885  }
886 
887 
888  public void ResOpenListDebug( String fps_ListHeader )
889  {
890  AllCount++;
891 
892  LogBase myLog = new ResultListDebug( Pointer2LogBaseStack.peek(), fps_ListHeader);
893 
894  // Timer starten
895  myLog.myDuration.startTimer();
896 
897  Pointer2LogBaseStack.peek().myLogs.add(myLog);
898  Pointer2LogBaseStack.push(myLog);
899  }
900 
901 
902  private void StopAllTimerAndEmptyStack()
903  {
904 
905  if (Pointer2LogBaseStack.size() > 1 )
906  {
907  Pointer2LogBaseStack.peek().abort();
908  }
909 
910  while (!Pointer2LogBaseStack.isEmpty())
911  {
912  Pointer2LogBaseStack.pop().myDuration.stopTimer();
913  }
914  }
915 
916 
917  public void ResCloseList()
918  {
919  LogBase myLog = Pointer2LogBaseStack.pop();
920 
921  // Timer Stoppen...
922  myLog.myDuration.stopTimer();
923 
924  @SuppressWarnings( "unused" )
925  ResultList myResultList = (ResultList)myLog;
926 
927  if ( (!myLog.bError) || (!myLog.bException))
928  {
929  FunctionPass++;
930  }
931  }
932 
933 
934  public void ResCloseListDebug()
935  {
936  LogBase myLog = Pointer2LogBaseStack.peek();
937  // Timer Stoppen...
938  myLog.myDuration.stopTimer();
939 
940  @SuppressWarnings( "unused" )
941  ResultListDebug myResultList = (ResultListDebug)myLog;
942 
943  if ( (!myLog.bError) || (!myLog.bException))
944  {
945  FunctionPass++;
946  }
947 
948  Pointer2LogBaseStack.pop();
949  }
950 
951 
952  public void setDebugMode( Boolean fpbDebugMode )
953  {
954 
955  }
956 
957 
958  @Override
959  protected void TestcaseCount()
960  {
961  this.TestcaseCount++;
962  }
963 
964  @Override
965  protected void TestcaseFail()
966  {
967  this.TestcaseFail++;
968  }
969 
970  @Override
971  protected void TestcasePass()
972  {
973  this.TestcasePass++;
974  }
975 
976  @Override
977  protected void FunctionCount()
978  {
979  this.FunctionCount++;
980  }
981 
982  @Override
983  protected void FunctionFail()
984  {
985  this.FunctionFail++;
986  }
987 
988  @Override
989  protected void FunctionPass()
990  {
991  this.FunctionPass++;
992  }
993 
994  @Override
995  protected void KeyWordCount()
996  {
997  this.KeyWordCount++;
998  }
999 
1000  @Override
1001  protected void KeyWordFail()
1002  {
1003  this.KeyWordFail++;
1004  }
1005 
1006  @Override
1007  protected void KeyWordPass()
1008  {
1009  this.KeyWordPass++;
1010  }
1011 
1012  @Override
1013  protected void SequenceCount()
1014  {
1015  this.SequenceCount++;
1016  }
1017 
1018  @Override
1019  protected void SequenceFail()
1020  {
1021  this.SequenceFail++;
1022  }
1023 
1024  @Override
1025  protected void SequencePass()
1026  {
1027  this.SequencePass++;
1028  }
1029 
1030  // Sub
1031  @Override
1032  protected void StepCount()
1033  {
1034  this.StepCount++;
1035  }
1036 
1037  @Override
1038  protected void StepFail()
1039  {
1040  this.StepFail++;
1041  }
1042 
1043  @Override
1044  protected void StepPass()
1045  {
1046  this.StepPass++;
1047  }
1048 
1049 
1050  // LocalACCall
1051  @Override
1052  protected void LocalACCallCount()
1053  {
1054  this.LocalACCallCount++;
1055  }
1056 
1057  @Override
1058  protected void LocalACCallFail()
1059  {
1060  this.LocalACCallFail++;
1061  }
1062 
1063  @Override
1064  protected void LocalACCallPass()
1065  {
1066  this.LocalACCallPass++;
1067  }
1068 
1069  // RemoteACCall
1070  @Override
1071  protected void RemoteACCallCount()
1072  {
1073  this.RemoteACCallCount++;
1074  }
1075 
1076  @Override
1077  protected void RemoteACCallFail()
1078  {
1079  this.RemoteACCallFail++;
1080  }
1081 
1082  @Override
1083  protected void RemoteACCallPass()
1084  {
1085  this.RemoteACCallPass++;
1086  }
1087 }
okw.log.log2html.Log2HTML.LogException
void LogException(String fpsMessage)
LogException: Logs an exception to the results.
Definition: Log2HTML.java:93
okw.log.ILogger
Debug Logs are not a part of Interface.
Definition: ILogger.java:54
okw.log.log2html.Log2HTML.LogSequenceStart
void LogSequenceStart(String fpsKeywordName, String fpsWindowFN, String fpsSequenceName, String... fpsParameter)
LogSequenceStart: Begin of a Sequence.
Definition: Log2HTML.java:465
okw.log.log2html.Log2HTML.LogLocalACCallEnd
void LogLocalACCallEnd()
LogLocalACCallEnd: End of a local AC call.
Definition: Log2HTML.java:350
okw.log.log2html.Log2HTML.LogFunctionEnd
void LogFunctionEnd(List< String > fps_Return)
LogFunctionEnd:
Definition: Log2HTML.java:234
okw.log.log2html.Log2HTML.ResOpenList
void ResOpenList(String fps_ListHeader)
LogFunctionStartDebug: Opens a debug outline level with the .
Definition: Log2HTML.java:874
okw.log.log2html.Log2HTML.LogKeyWordStart
void LogKeyWordStart(String fps_FunctionName, String... fpsParameter)
LogKeyWordStart:
Definition: Log2HTML.java:303
okw.log.log2html.Log2HTML.ResCloseListDebug
void ResCloseListDebug()
ResCloseListDebug:
Definition: Log2HTML.java:934
okw.log.log2html.Log2HTML.ResOpenListDebug
void ResOpenListDebug(String fps_ListHeader)
Öffnet eine neue debug Ergenis-Ebene mit der gegebenen Überschrift.
Definition: Log2HTML.java:888
okw.log.log2html.Log2HTML.LogStepEnd
void LogStepEnd()
LogStepEnd: Log End of (Test) Step.
Definition: Log2HTML.java:413
okw.log.log2html.ResultList
Definition: ResultList.java:5
okw.log.log2html.Log2HTML.LogTestcaseEnd
void LogTestcaseEnd()
LogTestcaseEnd:
Definition: Log2HTML.java:285
okw.log.log2html.LogBaseNode
Definition: LogBaseNode.java:3
okw.log.log2html.Log2HTML.LogFunctionEnd
void LogFunctionEnd()
LogFunctionEnd:
Definition: Log2HTML.java:138
okw.log.log2html.Log2HTML.setDebugMode
void setDebugMode(Boolean fpbDebugMode)
setDebugMode:
Definition: Log2HTML.java:952
okw.log.log2html.Log2HTML.LogKeyWordEnd
void LogKeyWordEnd()
LogKeyWordEnd:
Definition: Log2HTML.java:317
okw.log.log2html.Log2HTML.LogWarning
void LogWarning(String fpsMessage)
LogWarning: Logs an error message to the result.
Definition: Log2HTML.java:77
okw.log.log2html.Log2HTML
Definition: Log2HTML.java:23
okw.log.log2html.Log2HTML.LogError
void LogError(String fpsMessage)
LogError: Logs an error message to the result.
Definition: Log2HTML.java:85
okw.log.log2html.ResultListDebug
Definition: ResultListDebug.java:5
okw.log.log2html.Log2HTML.LogSourceLocation
void LogSourceLocation(String Start, String End, String featureName, String sourceType)
LogSourceLocation: Logs location of Source in Harmony.
Definition: Log2HTML.java:101
okw.log.log2html.Log2HTML.LogStepStart
void LogStepStart(String categoryName, String categoryType, String choiceValue, String featureName, String localCategoryName, String sourceExcerpt, String type)
Log markiert den Start eines Steps.
Definition: Log2HTML.java:396
okw.log.log2html.Log2HTML.LogFunctionEndDebug
void LogFunctionEndDebug()
LogFunctionEndDebug:
Definition: Log2HTML.java:154
okw.log.log2html.Log2HTML.LogFunctionEndDebug
void LogFunctionEndDebug(String fps_Return)
LogFunctionEndDebug(String):
Definition: Log2HTML.java:218
okw.log.log2html.Log2HTML.LogFunctionEndDebug
void LogFunctionEndDebug(Boolean fpb_Return)
LogFunctionEndDebug(Boolean):
Definition: Log2HTML.java:170
okw.log.log2html.Log2HTML.LogFunctionEndDebug
void LogFunctionEndDebug(List< String > fps_Return)
LogFunctionEndDebug:
Definition: Log2HTML.java:251
okw.log.log2html.LogTestcase
Definition: LogTestcase.java:3
okw.log.log2html.Log2HTML.LogPass
void LogPass(String fpsMessage)
LogPass: Logs an error message to the result.
Definition: Log2HTML.java:53
okw.log.log2html.LogBase
Definition: LogBase.java:7
okw.log.log2html.Log2HTML.LogFunctionStartDebug
void LogFunctionStartDebug(String fps_FunctionName, String... fpsParameter)
LogFunctionStartDebug:
Definition: Log2HTML.java:124
okw.log.log2html.LogSequence
Definition: LogSequence.java:3
okw.log.log2html.Log2HTML.LogSequenceEnd
void LogSequenceEnd()
LogSequenceEnd:
Definition: Log2HTML.java:479
okw.log.log2html.Log2HTML.LogTestcaseStart
void LogTestcaseStart(String fps_FunctionName)
LogTestcaseStart:
Definition: Log2HTML.java:269
okw.log.log2html.LogKeyword
Definition: LogKeyword.java:3
okw.log.log2html.Log2HTML.LogFunctionStart
void LogFunctionStart(String fps_FunctionName, String... fpsParameter)
LogFunctionStart:
Definition: Log2HTML.java:109
okw.log.log2html.LogFunctionDebug
Definition: LogFunctionDebug.java:5
okw.log.log2html.Log2HTML.ResCloseList
void ResCloseList()
ResCloseList: Closes the outline level.
Definition: Log2HTML.java:917
okw.log.log2html.Log2HTML.LogPrintDebug
void LogPrintDebug(String fpsMessage)
LogPrintDebug:
Definition: Log2HTML.java:69
okw.log.log2html.Log2HTML.LogFunctionEnd
void LogFunctionEnd(Boolean Return)
LogFunctionEnd(Boolean):
Definition: Log2HTML.java:186
okw.log.log2html.Log2HTML.LogRemoteACCallStart
void LogRemoteACCallStart(String sourceExcerpt, String Type)
LogRemoteACCallStart: Start of a remote AC call.
Definition: Log2HTML.java:433
okw.log.log2html.LogStep
Definition: LogStep.java:3
okw.log.log2html.Log2HTML.LogFunctionEnd
void LogFunctionEnd(String fps_Return)
LogFunctionEnd(String):
Definition: Log2HTML.java:202
okw.log.log2html.LogFunction
Definition: LogFunction.java:5
okw.log.log2html.Log2HTML.LogLocalACCallStart
void LogLocalACCallStart(String sourceExcerpt, String Type)
LogLocalACCallStart: Start of a local AC call.
Definition: Log2HTML.java:336
okw.log.log2html.LogRemoteACCall
Definition: LogRemoteACCall.java:3
okw.log.log2html.Log2HTML.LogPrint
void LogPrint(String fpsMessage)
LogPrint: Prints the given message to the results.
Definition: Log2HTML.java:61
okw.log.log2html.LogLocalACCall
Definition: LogLocalACCall.java:3
okw.log.log2html.Log2HTML.LogRemoteACCallEnd
void LogRemoteACCallEnd()
LogRemoteACCallEnd: End of a remote AC call.
Definition: Log2HTML.java:447