Refine search
public void removeKubernetesResourcesAtClassScope(@Observes(precedence = -10) AfterClass afterClass, final KubernetesClient kubernetesClient) { final TestClass testClass = afterClass.getTestClass(); log.info(String.format("Deleting environment for %s", testClass.getName())); deleteResources(testClass.getJavaClass().getName(), kubernetesClient); }
private IstioResource[] findAnnotations(TestClass testClass) { if (testClass.isAnnotationPresent(IstioResource.class)) { return new IstioResource[] {testClass.getAnnotation(IstioResource.class)}; } else { if (testClass.isAnnotationPresent(IstioResource.List.class)) { return testClass.getAnnotation(IstioResource.List.class).value(); } } return new IstioResource[0]; }
/** * Execution method delegating the anotated method for "AfterDeploy" * * @param event * The observed event * @param testClass * The testclass with the annotation */ public final void executeAfterDeploy(@Observes AfterDeploy event, TestClass testClass) { execute(testClass.getMethods(AfterDeployment.class)); }
/** * Returns all resources defined for this test class * including those defined on the test method level. */ public Collection<T> getDescriptors(TestClass testClass) { final List<T> descriptors = new ArrayList<T>(); for (Method testMethod : testClass.getMethods(resourceAnnotation)) { descriptors.addAll(getDescriptorsDefinedFor(testMethod)); } descriptors.addAll(obtainClassLevelDescriptor(testClass.getAnnotation(resourceAnnotation))); return descriptors; }
public void start(@Observes(precedence = Integer.MIN_VALUE) BeforeTestLifecycleEvent event, KubernetesClient client, Session session) { String pkg = event.getTestClass().getJavaClass().getPackage().getName(); String className = event.getTestClass().getJavaClass().getSimpleName(); String methodName = event.getTestMethod().getName(); ConfigMaps.updateConfigMapTestStatus(client, session, trimName(pkg, className, methodName), "RUNNING"); }
public void executeSleep(@Observes BeforeClass beforeClass) { final TestClass testClass = beforeClass.getTestClass(); if (ReflectionUtil.isClassWithAnnotation(testClass.getJavaClass(), Sleep.class)) { final Sleep sleep = testClass.getAnnotation(Sleep.class); executeSleep(sleep); } }
public void applyIstioResourcesAtClassScope(@Observes(precedence = -20) BeforeClass beforeClass, final IstioClient istioClient) { final TestClass testClass = beforeClass.getTestClass(); log.info(String.format("Creating Istio resource for %s", testClass.getName())); createResources(createResourceKey(testClass), istioClient, findAnnotations(testClass)); }
public void observeBeforeClass(@Observes(precedence = Integer.MAX_VALUE) BeforeClass event) { TestClassReport testClassReport = new TestClassReport(); testClassReport.setTestClassName(event.getTestClass().getName()); testClassReport.setRunAsClient(event.getTestClass().isAnnotationPresent(RunAsClient.class)); testClassReport.setReportMessage(ReportMessageParser.parseTestClassReportMessage(event.getTestClass().getJavaClass())); reporter.get().getLastTestSuiteReport().getTestClassReports().add(testClassReport); reporter.get().setTestClassReport(testClassReport); }
/** * BeforeClass * @param event The event * @param registry The container registry */ public void beforeClass(@Observes BeforeClass event, ContainerRegistry registry) { for (Container container : registry.getContainers()) { DeployableContainer dc = container.getDeployableContainer(); if (dc instanceof EmbeddedJCAContainer) { EmbeddedJCAContainer ejc = (EmbeddedJCAContainer)dc; if (event.getTestClass().isAnnotationPresent(Configuration.class)) { Configuration c = event.getTestClass().getAnnotation(Configuration.class); ejc.setAutoActivate(c.autoActivate()); } } } } }
/** * Initializes the {@link Injector}. * * @param beforeClass the before class event */ public void initInjector(@Observes BeforeClass beforeClass) { TestClass testClass; Injector injector; testClass = beforeClass.getTestClass(); if (isGuiceTest(testClass)) { if (hasCustomInjector(testClass)) { injector = getCustomInjector(testClass); } else if (testClass.isAnnotationPresent(GuiceWebConfiguration.class)) { injector = getServletContextInjector(); } else { // otherwise creates the injector injector = createInjector(testClass); log.fine("Successfully created guice injector for model class: " + testClass.getName()); } if (injector != null) { injectorInstance.set(injector); } } }
public boolean hasPersistenceTestAnnotation() { return testClass.getAnnotation(PersistenceTest.class) != null; }
/** * Checks if the given test class is annotated by the annotation {@link @RunAsClient} * * @param testClass to be checked * @return whether if the given test class is annotated by the annotation {@link @RunAsClient} */ public static boolean isAnnotatedRunAsClient(TestClass testClass) { return testClass.isAnnotationPresent(RunAsClient.class); } }
public Method getMethod(Class<? extends Annotation> annotation) { Method[] methods = getMethods(annotation); if (methods.length > 0) { return methods[0]; } return null; }
/** * @param testClass * The Test case {@link Class} * * @throws IllegalArgumentException * if testCase is null */ public ClassEvent(Class<?> testClass) { this(new TestClass(testClass)); }
@Override protected String asynchronousDelayErrorMessage() { return String.format("Error waiting for template resources to deploy from class %s method %s", testClass.getName(), testMethod.getName()); }
public void beforeTestClassCreateSharedAsciidoctorInstance(@Observes(precedence = -100) BeforeClass beforeClass) { if (isSharedInstanceRequired(beforeClass.getTestClass().getJavaClass(), Asciidoctor.class)) { scopedAsciidoctor.get().setSharedAsciidoctor( Asciidoctor.Factory.create()); } }
public void executeHealthCheck(@Observes BeforeClass beforeClass) { final TestClass testClass = beforeClass.getTestClass(); if (ReflectionUtil.isClassWithAnnotation(testClass.getJavaClass(), HealthCheck.class)) { final HealthCheck healthCheck = testClass.getAnnotation(HealthCheck.class); executeHealthCheck(healthCheck); } }
public void removeIstioResourcesAtClassScope(@Observes(precedence = 20) AfterClass afterClass, final IstioClient istioClient) { final TestClass testClass = afterClass.getTestClass(); log.info(String.format("Deleting Istio resource for %s", testClass.getName())); deleteResources(createResourceKey(testClass), istioClient, findRestoreAnnotations(testClass)); }
/** * BeforeClass * @param event The event * @param registry The container registry */ public void beforeClass(@Observes BeforeClass event, ContainerRegistry registry) { for (Container container : registry.getContainers()) { DeployableContainer dc = container.getDeployableContainer(); if (dc instanceof EmbeddedJCAContainer) { EmbeddedJCAContainer ejc = (EmbeddedJCAContainer)dc; if (event.getTestClass().isAnnotationPresent(Configuration.class)) { Configuration c = event.getTestClass().getAnnotation(Configuration.class); ejc.setAutoActivate(c.autoActivate()); } } } } }
public T getAnnotationOnClassLevel() { return testClass.getAnnotation(annotationClass); }