@Test public void should_stop_vnc_by_default() throws IOException, NoSuchMethodException { final File destination = temporaryFolder.newFolder("destination"); final File video = temporaryFolder.newFile("file.flv"); when(seleniumContainers.getVideoRecordingFile()).thenReturn(video.toPath()); when(after.getTestClass()).thenReturn(new TestClass(VncRecorderLifecycleManagerTest.class)); when(after.getTestMethod()).thenReturn( VncRecorderLifecycleManagerTest.class.getMethod("should_stop_vnc_by_default")); Map<String, String> conf = new HashMap<>(); conf.put("videoOutput", destination.getAbsolutePath()); TestResult testResult = TestResult.passed(); VncRecorderLifecycleManager vncRecorderLifecycleManager = new VncRecorderLifecycleManager(); vncRecorderLifecycleManager.vnc = cube; vncRecorderLifecycleManager.afterVideoRecordedEvent = event; vncRecorderLifecycleManager.stopRecording(after, testResult, CubeDroneConfiguration.fromMap(conf), seleniumContainers ); verify(cube).stop(); verify(cube).destroy(); }
public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { try { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } } catch (CubeControlException e) { Logger.getLogger(VncRecorderLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop vnc", e); } }
VncRecorderLifecycleManager { public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { try { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } } catch (CubeControlException e) { Logger.getLogger(VncRecorderLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop vnc", e); } } }
VncRecorderLifecycleManager { public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { try { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } } catch (CubeControlException e) { Logger.getLogger(VncRecorderLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop vnc", e); } }  }
VncRecorderLifecycleManager { public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { try { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } } catch (CubeControlException e) { Logger.getLogger(VncRecorderLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop vnc", e); } }  void startRecording(@Observes Before beforeTestMethod, CubeDroneConfiguration cubeDroneConfiguration,
        CubeRegistry cubeRegistry); void stopRecording(@Observes After afterTestMethod, TestResult testResult,
        CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers); }
VncRecorderLifecycleManager { public void stopRecording(@Observes After afterTestMethod, TestResult testResult, CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers) { try { if (this.vnc != null) { vnc.stop(); Path finalLocation = null; if (shouldRecordOnlyOnFailure(testResult, cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } else { if (shouldRecordAlways(cubeDroneConfiguration)) { finalLocation = moveFromVolumeFolderToBuildDirectory(afterTestMethod, cubeDroneConfiguration, seleniumContainers); } } vnc.destroy(); this.afterVideoRecordedEvent.fire(new AfterVideoRecorded(afterTestMethod, finalLocation)); } } catch (CubeControlException e) { Logger.getLogger(VncRecorderLifecycleManager.class.getName()).log(Level.WARNING, "Failed to stop vnc", e); } }  void startRecording(@Observes Before beforeTestMethod, CubeDroneConfiguration cubeDroneConfiguration,
        CubeRegistry cubeRegistry); void stopRecording(@Observes After afterTestMethod, TestResult testResult,
        CubeDroneConfiguration cubeDroneConfiguration, SeleniumContainers seleniumContainers);  }