Skip to content

Commit

Permalink
ARQ-69 ARQ-104 New multi context event based core with new Test frame…
Browse files Browse the repository at this point in the history
…work integration
  • Loading branch information
aslakknutsen committed Apr 20, 2010
1 parent 663c979 commit cb69649
Show file tree
Hide file tree
Showing 70 changed files with 3,619 additions and 438 deletions.
7 changes: 6 additions & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@
<artifactId>jetty-embedded</artifactId>
<version>${version.jetty_jetty}</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.3</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
6 changes: 6 additions & 0 deletions impl-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
<!--
External Projects
-->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
*/
package org.jboss.arquillian.impl;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.jboss.arquillian.spi.ApplicationArchiveGenerator;
import org.jboss.arquillian.spi.ApplicationArchiveProcessor;
import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
import org.jboss.arquillian.spi.AuxiliaryArchiveProcessor;
import org.jboss.arquillian.spi.DeploymentPackager;
import org.jboss.arquillian.spi.ServiceLoader;
import org.jboss.arquillian.spi.AuxiliaryArchiveProcessor;
import org.jboss.arquillian.spi.ApplicationArchiveProcessor;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;

/**
* Responsible for
Expand Down Expand Up @@ -61,7 +63,11 @@ public Archive<?> generate(Class<?> testCase)
List<Archive<?>> auxiliaryArchives = loadAuxiliaryArchives();
applyAuxiliaryProcessors(auxiliaryArchives);

return packager.generateDeployment(applicationArchive, auxiliaryArchives);
Archive<?> deployment = packager.generateDeployment(applicationArchive, auxiliaryArchives);

deployment.as(ZipExporter.class).exportZip(new File("test.ear"), true);

return deployment;
}

private List<Archive<?>> loadAuxiliaryArchives()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
*/
package org.jboss.arquillian.impl;

import org.jboss.arquillian.impl.container.ContainerController;
import org.jboss.arquillian.impl.container.ContainerDeployer;
import org.jboss.arquillian.impl.container.Controlable;
import org.jboss.arquillian.spi.ContainerMethodExecutor;
import org.jboss.arquillian.spi.DeployableContainer;
import org.jboss.arquillian.spi.DeploymentException;
import org.jboss.arquillian.spi.LifecycleException;
import org.jboss.arquillian.impl.context.ClientProfileBuilder;
import org.jboss.arquillian.impl.context.ContainerProfileBuilder;
import org.jboss.arquillian.impl.context.ContextLifecycleManager;
import org.jboss.arquillian.impl.context.ProfileBuilder;
import org.jboss.arquillian.impl.context.StandaloneProfileBuilder;
import org.jboss.arquillian.spi.Configuration;
import org.jboss.arquillian.spi.ContainerConfiguration;
import org.jboss.arquillian.spi.ContainerProfile;
import org.jboss.arquillian.spi.ServiceLoader;
import org.jboss.arquillian.spi.TestMethodExecutor;
import org.jboss.arquillian.spi.TestResult;
import org.jboss.arquillian.spi.TestResult.Status;
import org.jboss.arquillian.spi.util.TestEnrichers;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.arquillian.spi.TestRunnerAdaptor;

/**
* DeployableTestBuilder
Expand All @@ -39,71 +36,80 @@
public class DeployableTestBuilder
{
private DeployableTestBuilder() {}

public static DeployableTest build(Object config)

private static ContainerProfile profile = null;

public static void setProfile(ContainerProfile profile)
{
Controlable controller = null;
Deployer deployer = null;

// TODO: lookup service loader impl from configuration
ServiceLoader serviceLoader = new DynamicServiceLoader();
Validate.notNull(profile, "Profile must be specified");

if(DeployableTest.isInContainer())
{
controller = new InContainerContainer();
deployer = new InContainerContainer();
}
else
{
DeployableContainer container = serviceLoader.onlyOne(DeployableContainer.class);
// TODO: lookup controller / deployer from configuration
controller = new ContainerController(container);
deployer = new ContainerDeployer(container);
}
DeployableTestBuilder.profile = profile;
}

public static ContainerProfile getProfile()
{
return DeployableTestBuilder.profile;
}

return new DeployableTest(
controller,
deployer,
serviceLoader);
/**
* @return
*/
public static TestRunnerAdaptor build()
{
return build(DeployableTestBuilder.profile);
}

private static class InContainerContainer implements Controlable, Deployer
// TODO: fix the ContainerProfile loading/selecting
public static TestRunnerAdaptor build(Configuration configuration)
{
@Override
public void start() throws LifecycleException
ContainerProfile profile = DeployableTestBuilder.profile;
ContainerConfiguration activeConfiguration = configuration.getActiveContainerConfiguration();
if(activeConfiguration != null && profile == null)
{
profile = activeConfiguration.getContainerProfile();
}

@Override
public void stop() throws LifecycleException
return build(profile, configuration);
}

public static TestRunnerAdaptor build(ContainerProfile profile)
{
return build(profile, new XmlConfigurationBuilder().build());
}

public static TestRunnerAdaptor build(ContainerProfile profile, Configuration configuration)
{
ProfileBuilder profileBuilder = null;
switch(profile)
{
case STANDALONE:
profileBuilder = new StandaloneProfileBuilder();
break;
case CONTAINER:
profileBuilder = new ContainerProfileBuilder();
break;
case CLIENT:
profileBuilder = new ClientProfileBuilder();
break;
default: // TODO: create profile builders dynamic
throw new IllegalArgumentException("Unknon profile " + profile);
}
return build(profileBuilder, configuration);
}

/**
* @param profileBuilder
* @return
*/
public static TestRunnerAdaptor build(ProfileBuilder profileBuilder, Configuration configuration)
{
ServiceLoader serviceLoader = new DynamicServiceLoader();

@Override
public ContainerMethodExecutor deploy(Archive<?> archive) throws DeploymentException
{
return new ContainerMethodExecutor()
{
@Override
public TestResult invoke(TestMethodExecutor testMethodExecutor)
{
try
{
TestEnrichers.enrich(testMethodExecutor.getInstance());
testMethodExecutor.invoke();
return new TestResultImpl(Status.PASSED);
}
catch (Throwable e)
{
return new TestResultImpl(Status.FAILED, e);
}
}
};
}
ContextLifecycleManager eventManager = new ContextLifecycleManager(
configuration,
profileBuilder,
serviceLoader
);

@Override
public void undeploy(Archive<?> archive) throws DeploymentException
{
}
return new EventTestRunnerAdaptor(eventManager);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.jboss.arquillian.impl;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.spi.ApplicationArchiveGenerator;
Expand All @@ -39,7 +40,15 @@ public Archive<?> generateApplicationArchive(Class<?> testCase)
Method deploymentMethod = findDeploymentMethod(testCase);
if(deploymentMethod == null)
{
throw new RuntimeException("No static method annotated with " + Deployment.class.getName() + " found");
throw new IllegalArgumentException("No method annotated with " + Deployment.class.getName() + " found");
}
if(!Modifier.isStatic(deploymentMethod.getModifiers()))
{
throw new IllegalArgumentException("Method annotated with " + Deployment.class.getName() + " is not static");
}
if(!Archive.class.isAssignableFrom(deploymentMethod.getReturnType()))
{
throw new IllegalArgumentException("Method annotated with " + Deployment.class.getName() + " must have return type " + Archive.class.getName());
}
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public <T> T onlyOne(Class<T> serviceClass)
Collection<T> providers = DefaultServiceLoader.load(serviceClass).getProviders();
if(providers == null || providers.size() == 0)
{
throw new RuntimeException("No implementation found for: " + serviceClass.getName() + ", check classpath");
throw new IllegalStateException("No implementation found for: " + serviceClass.getName() + ", check classpath");
}
if(providers.size() > 1)
{
throw new RuntimeException("Mutiple implementations found for: " + serviceClass.getName() + ", check classpath");
throw new IllegalStateException("Mutiple implementations found for: " + serviceClass.getName() + ", check classpath");
}
return providers.iterator().next();
}
Expand Down
Loading

0 comments on commit cb69649

Please sign in to comment.