org.jboss.arquillian.container.test.impl.client.deployment.event.GenerateDeployment Java Examples

The following examples show how to use org.jboss.arquillian.container.test.impl.client.deployment.event.GenerateDeployment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WildFlySwarmObserver.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unused", "unchecked"})
public void generate(@Observes(precedence = 100) final GenerateDeployment event) throws Exception {
    final Class testClass = event.getTestClass().getJavaClass();
    this.container.setTestClass(testClass);

    final List<Method> annotatedMethods = Stream.of(testClass.getDeclaredMethods())
            .filter(m -> m.isAnnotationPresent(ArtifactDependencies.class))
            .collect(Collectors.toList());

    if (annotatedMethods.size() > 1) {
        throw new IllegalArgumentException("Too many methods annotated with " + ArtifactDependencies.class.getName());
    }

    if (annotatedMethods.size() == 1) {
        final Method dependencyMethod = annotatedMethods.get(0);
        dependencyMethod.setAccessible(true);
        validate(dependencyMethod);

        this.container.setRequestedMavenArtifacts((List<String>) dependencyMethod.invoke(null));
    }
}
 
Example #2
Source File: WildFlySwarmObserver.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unused", "unchecked"})
public void generate(@Observes(precedence = 100) final GenerateDeployment event) throws Exception {
    final Class testClass = event.getTestClass().getJavaClass();
    this.container.setTestClass(testClass);

    final List<Method> annotatedMethods = Stream.of(testClass.getDeclaredMethods())
            .filter(m -> m.isAnnotationPresent(ArtifactDependencies.class))
            .collect(Collectors.toList());

    if (annotatedMethods.size() > 1) {
        throw new IllegalArgumentException("Too many methods annotated with " + ArtifactDependencies.class.getName());
    }

    if (annotatedMethods.size() == 1) {
        final Method dependencyMethod = annotatedMethods.get(0);
        dependencyMethod.setAccessible(true);
        validate(dependencyMethod);

        this.container.setRequestedMavenArtifacts((List<String>) dependencyMethod.invoke(null));
    }
}
 
Example #3
Source File: SuiteDeployer.java    From arquillian-suite-extension with Apache License 2.0 6 votes vote down vote up
/**
 * Startup event.
 *
 * @param event AfterStart event to catch
 */
public void startup(@Observes(precedence = -100) final BeforeSuite event) {
    if (extensionEnabled()) {
        debug("Catching BeforeSuite event {0}", event.toString());
        executeInClassScope(new Callable<Void>() {
            @Override
            public Void call() {
                generateDeploymentEvent.fire(new GenerateDeployment(new TestClass(deploymentClass)));
                suiteDeploymentScenario = classDeploymentScenario.get();
                return null;
            }
        });
        deployDeployments = true;
        extendedSuiteContext.get().activate();
        suiteDeploymentScenarioInstanceProducer.set(suiteDeploymentScenario);
    }
}
 
Example #4
Source File: SuiteDeployer.java    From arquillian-suite-extension with Apache License 2.0 5 votes vote down vote up
/**
 * Method ignoring GenerateDeployment events if deployment is already done.
 *
 * @param eventContext Event to check
 */
public void blockGenerateDeploymentWhenNeeded(@Observes EventContext<GenerateDeployment> eventContext) {
    if (!extensionEnabled()) {
        eventContext.proceed();
    }
    else if (suiteDeploymentGenerated) {
        // Do nothing with event.
        debug("Blocking GenerateDeployment event {0}", eventContext.getEvent().toString());
    } else {
        suiteDeploymentGenerated = true;
        debug("NOT Blocking GenerateDeployment event {0}", eventContext.getEvent().toString());
        eventContext.proceed();
    }
}
 
Example #5
Source File: ArquillianSuiteExtension.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
public void startup(@Observes(precedence = -100) ManagerStarted event, ArquillianDescriptor descriptor) {
    deploymentClass = getDeploymentClass(descriptor);

    executeInClassScope(new Callable<Void>() {
        public Void call() throws Exception {
            generateDeploymentEvent.fire(new GenerateDeployment(new TestClass(deploymentClass)));
            suiteDeploymentScenario = classDeploymentScenario.get();
            return null;
        }
    });
}