@@ -543,38 +543,40 @@ public TestCaseExecutionFile recordExeLog(TestCaseExecution execution) {
543
543
LOG .debug ("Starting to save Execution log File." );
544
544
545
545
TestCaseExecutionFile object = null ;
546
- String test = execution .getTest ();
547
- String testCase = execution .getTestCase ();
546
+ if ((execution != null ) && (execution .getExecutionLog () != null )) {
547
+ String test = execution .getTest ();
548
+ String testCase = execution .getTestCase ();
548
549
549
- try {
550
- Recorder recorder = this .initFilenames (execution .getId (), test , testCase , null , null , null , null , null , 0 , "exeLog" , "log" , false );
551
- File dir = new File (recorder .getFullPath ());
552
- dir .mkdirs ();
550
+ try {
551
+ Recorder recorder = this .initFilenames (execution .getId (), test , testCase , null , null , null , null , null , 0 , "exeLog" , "log" , false );
552
+ File dir = new File (recorder .getFullPath ());
553
+ dir .mkdirs ();
553
554
554
- File file = new File (recorder .getFullFilename ());
555
+ File file = new File (recorder .getFullFilename ());
555
556
556
- try (FileOutputStream fileOutputStream = new FileOutputStream (file );) {
557
- for (ExecutionLog executionLog : execution .getExecutionLog ()) {
558
- fileOutputStream .write (executionLog .getLogText ().getBytes ());
559
- fileOutputStream .write ("\r \n " .getBytes ());
560
- LOG .debug (executionLog .getLogText ());
561
- }
557
+ try (FileOutputStream fileOutputStream = new FileOutputStream (file );) {
558
+ for (ExecutionLog executionLog : execution .getExecutionLog ()) {
559
+ fileOutputStream .write (executionLog .getLogText ().getBytes ());
560
+ fileOutputStream .write ("\r \n " .getBytes ());
561
+ LOG .debug (executionLog .getLogText ());
562
+ }
562
563
563
- LOG .info ("File saved : {}" , recorder .getFullFilename ());
564
+ LOG .info ("File saved : {}" , recorder .getFullFilename ());
564
565
565
- // Index file created to database.
566
- object = testCaseExecutionFileFactory .create (0 , execution .getId (), recorder .getLevel (), "Execution Log" , recorder .getRelativeFilenameURL (), "TXT" , "" , null , "" , null );
567
- testCaseExecutionFileService .save (object );
566
+ // Index file created to database.
567
+ object = testCaseExecutionFileFactory .create (0 , execution .getId (), recorder .getLevel (), "Execution Log" , recorder .getRelativeFilenameURL (), "TXT" , "" , null , "" , null );
568
+ testCaseExecutionFileService .save (object );
568
569
569
- } catch (IOException ex ) {
570
+ } catch (IOException ex ) {
571
+ LOG .error (ex .toString (), ex );
572
+ } catch (WebDriverException ex ) {
573
+ LOG .debug ("Exception recording execution log on execution : {}" , execution .getId (), ex );
574
+ object = testCaseExecutionFileFactory .create (0 , execution .getId (), recorder .getLevel (), "Execution Log [ERROR]" , recorder .getRelativeFilenameURL (), "TXT" , "" , null , "" , null );
575
+ testCaseExecutionFileService .save (object );
576
+ }
577
+ } catch (CerberusException ex ) {
570
578
LOG .error (ex .toString (), ex );
571
- } catch (WebDriverException ex ) {
572
- LOG .debug ("Exception recording execution log on execution : {}" , execution .getId (), ex );
573
- object = testCaseExecutionFileFactory .create (0 , execution .getId (), recorder .getLevel (), "Execution Log [ERROR]" , recorder .getRelativeFilenameURL (), "TXT" , "" , null , "" , null );
574
- testCaseExecutionFileService .save (object );
575
579
}
576
- } catch (CerberusException ex ) {
577
- LOG .error (ex .toString (), ex );
578
580
}
579
581
return object ;
580
582
0 commit comments