private static String getFinalVideoName(After afterTestMethod) { final String className = afterTestMethod.getTestClass().getName().replace('.', '_'); final String methodName = afterTestMethod.getTestMethod().getName(); return className + "_" + methodName + ".flv"; } }
private static String getFinalVideoName(After afterTestMethod) { final String className = afterTestMethod.getTestClass().getName().replace('.', '_'); final String methodName = afterTestMethod.getTestMethod().getName(); return className + "_" + methodName + ".flv"; } }
private Method getTestMethod(@Observes AfterVideoRecorded event) { return event.getAfter().getTestMethod(); } }
public void removeKubernetesResourcesAtMethodScope(@Observes(precedence = -10) After afterMethod, final KubernetesClient kubernetesClient) { final TestClass testClass = afterMethod.getTestClass(); final Method testMethod = afterMethod.getTestMethod(); log.info(String.format("Deleting environment for %s method %s", testClass.getName(), testMethod.getName())); deleteResources(createResourceKey(testClass.getJavaClass(), testMethod), kubernetesClient); }
public void removeIstioResourcesAtMethodScope(@Observes(precedence = 20) After afterMethod, final IstioClient istioClient) { final TestClass testClass = afterMethod.getTestClass(); final Method testMethod = afterMethod.getTestMethod(); log.info(String.format("Deleting Istio resource for %s method %s", testClass.getName(), testMethod.getName())); deleteResources(createResourceKey(testMethod), istioClient, findRestoreAnnotations(testMethod)); }
public void removeKubernetesResourcesAtMethodScope(@Observes(precedence = -10) After afterMethod, final KubernetesClient kubernetesClient) { final TestClass testClass = afterMethod.getTestClass(); final Method testMethod = afterMethod.getTestMethod(); log.info(String.format("Deleting environment for %s method %s", testClass.getName(), testMethod.getName())); deleteResources(createResourceKey(testClass.getJavaClass(), testMethod), kubernetesClient); }
void cleanAfter(@Observes After after) { this.clean(after.getTestClass(), after.getTestMethod(), true); }
void cleanAfter(@Observes After after) { this.clean(after.getTestClass(), after.getTestMethod(), true); }
void cleanAfter(@Observes After after) { this.clean(after.getTestClass(), after.getTestMethod(), true); }
void cleanAfter(@Observes After after) { this.clean(after.getTestClass(), after.getTestMethod(), true); }
void cleanAfter(@Observes After after) { this.clean(after.getTestClass(), after.getTestMethod(), true); }
public void deleteOpenShiftResource(@Observes(precedence = -10) After event, OpenShiftAdapter client, CubeOpenShiftConfiguration cubeOpenShiftConfiguration) throws Exception { final TestClass testClass = event.getTestClass(); final Method testMethod = event.getTestMethod(); final Class<?> javaClass = testClass.getJavaClass(); final String templateKeyPrefix = createResourceKey(javaClass, testMethod); log.info(String.format("Deleting environment for %s method %s", testClass.getName(), testMethod.getName())); OpenShiftResourceFactory.deleteResources(javaClass, testMethod, client); OpenShiftResourceFactory.deleteTemplates(templateKeyPrefix, methodTemplateProcessor.getTemplates(), client, cubeOpenShiftConfiguration); }
when(after.getTestMethod()).thenReturn(VncRecorderLifecycleManagerTest.class.getMethod( "should_move_recording_if_configured_in_only_failing_and_failed_test"));
@Test public void should_move_recording_video() throws IOException, NoSuchMethodException { final File destination = temporaryFolder.newFolder("destination"); final File video = temporaryFolder.newFile("file.flv"); Files.write(video.toPath(), "Hello".getBytes()); when(seleniumContainers.getVideoRecordingFile()).thenReturn(video.toPath()); when(after.getTestClass()).thenReturn(new TestClass(VncRecorderLifecycleManagerTest.class)); when(after.getTestMethod()).thenReturn( VncRecorderLifecycleManagerTest.class.getMethod("should_move_recording_video")); 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 ); assertThat(new File(destination, "org_arquillian_cube_docker_drone_VncRecorderLifecycleManagerTest_should_move_recording_video.flv")) .exists() .hasContent("Hello"); }
@Test public void should_discard_recording_if_configured_in_only_failing_and_passed_test() 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_discard_recording_if_configured_in_only_failing_and_passed_test")); Map<String, String> conf = new HashMap<>(); conf.put("videoOutput", destination.getAbsolutePath()); conf.put("recordingMode", "ONLY_FAILING"); TestResult testResult = TestResult.passed(); VncRecorderLifecycleManager vncRecorderLifecycleManager = new VncRecorderLifecycleManager(); vncRecorderLifecycleManager.vnc = cube; vncRecorderLifecycleManager.afterVideoRecordedEvent = event; vncRecorderLifecycleManager.stopRecording(after, testResult, CubeDroneConfiguration.fromMap(conf), seleniumContainers ); assertThat(new File(destination, "org_arquillian_cube_docker_drone_VncRecorderLifecycleManagerTest_should_discard_recording_if_configured_in_only_failing_and_passed_test.flv")) .doesNotExist(); }
@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 gitHubReportEntries(@Observes After event) { final Method testMethod = event.getTestMethod(); final TestClass testClass = event.getTestClass(); final GitHub gitHubValue = getGitHubValue(testMethod, testClass); if (gitHubValue != null) { final GitHubGovernorConfiguration configuration = gitHubGovernorConfigurationInstance.get(); final String gitHubIssueURL = contructGitHubIssueURL(configuration, gitHubValue); final Class<? extends Detectable>[] detectables = gitHubValue.detector().value(); final Set<String> uniqDetectables = new TreeSet<String>(); for (final Class<? extends Detectable> detectable : detectables) { uniqDetectables.add(detectable.getSimpleName()); } String detectablesName = ""; for (final String detectable : uniqDetectables) { detectablesName += (detectablesName == "" ? "" : ",") + detectable; } final TableEntry gitHubDetector = new TableEntry(); gitHubDetector.setTableName("GitHubOptions"); gitHubDetector.getTableHead().getRow().addCells(new TableCellEntry("Force"), new TableCellEntry("Detector Value"), new TableCellEntry("Detector Strategy")); final TableRowEntry row = new TableRowEntry(); row.addCells(new TableCellEntry(String.valueOf(gitHubValue.force())), new TableCellEntry(String.valueOf(gitHubValue.detector().strategy().getSimpleName())), new TableCellEntry(detectablesName)); gitHubDetector.getTableBody().addRow(row); propertyReportEvent.fire(new PropertyReportEvent(new KeyValueEntry("GitHub URL", gitHubIssueURL))); propertyReportEvent.fire(new PropertyReportEvent(gitHubDetector)); } }
public void redmineReportEntries(@Observes After event) { final Method testMethod = event.getTestMethod(); final TestClass testClass = event.getTestClass(); final String redmineServerURL = redmineGovernorConfigurationInstance.get().getServer(); final Redmine redmineValue = getRedmineValue(testMethod, testClass); if (redmineValue != null) { final String issueURL = constructRedmineIssueURL(redmineServerURL, redmineValue.value()); final TableEntry redmineDetector = new TableEntry(); redmineDetector.setTableName("RedmineOptions"); redmineDetector.getTableHead().getRow().addCells(new TableCellEntry("Force")); final TableRowEntry row = new TableRowEntry(); row.addCells(new TableCellEntry(String.valueOf(redmineValue.force()))); redmineDetector.getTableBody().addRow(row); propertyReportEvent.fire(new PropertyReportEvent(new KeyValueEntry("Redmine URL", issueURL))); propertyReportEvent.fire(new PropertyReportEvent(redmineDetector)); } }