Skip to content

Commit

Permalink
WFARQ-12 Allow extending ArquillianConfig service
Browse files Browse the repository at this point in the history
Against 2.0 branch
  • Loading branch information
arcivanov committed Mar 8, 2016
1 parent 9cc0621 commit 091529f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public Archive<?> generateDeployment(TestDeployment testDeployment, Collection<P
try {
Collection<Archive<?>> auxArchives = testDeployment.getAuxiliaryArchives();
JavaArchive archive = generateArquillianServiceArchive(auxArchives);

Processor processor = new Processor(testDeployment, protocolProcessors);
processor.process(archive);

archiveHolder.setArchive(archive);
} catch (Exception ex) {
throw new IllegalStateException("Cannot generate arquillian service", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Set;

import org.jboss.arquillian.container.test.spi.util.ServiceLoader;
import org.jboss.arquillian.testenricher.msc.ServiceTargetAssociation;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.Attachments;
Expand All @@ -41,12 +42,14 @@
*
* @author Thomas.Diesler@jboss.com
*/
class ArquillianConfig implements Service<ArquillianConfig> {
public class ArquillianConfig implements Service<ArquillianConfig> {

private static final Logger log = Logger.getLogger(ArquillianConfig.class);

static final AttachmentKey<ArquillianConfig> KEY = AttachmentKey.create(ArquillianConfig.class);

private final List<ArquillianConfigServiceCustomizer> serviceCustomizers = new ArrayList<ArquillianConfigServiceCustomizer>();

private final ArquillianService arqService;
private final DeploymentUnit depUnit;
private final ServiceName serviceName;
Expand All @@ -63,11 +66,18 @@ static ServiceName getServiceName(DeploymentUnit depUnit) {
this.depUnit = depUnit;
this.serviceName = getServiceName(depUnit);
this.testClasses.addAll(testClasses);

for(ArquillianConfigServiceCustomizer customizer : ServiceLoader.load(ArquillianConfigServiceCustomizer.class)) {
serviceCustomizers.add(customizer);
}
}

ServiceBuilder<ArquillianConfig> buildService(ServiceTarget serviceTarget, ServiceController<?> depController) {
ServiceBuilder<ArquillianConfig> builder = serviceTarget.addService(getServiceName(), this);
builder.addDependency(depController.getName());
for(ArquillianConfigServiceCustomizer customizer : serviceCustomizers) {
customizer.customizeService(this, builder, depController);
}
return builder;
}

Expand All @@ -91,6 +101,10 @@ Class<?> loadClass(String className) throws ClassNotFoundException {
Module module = depUnit.getAttachment(Attachments.MODULE);
Class<?> testClass = module.getClassLoader().loadClass(className);

for(ArquillianConfigServiceCustomizer customizer : serviceCustomizers) {
customizer.customizeLoadClass(depUnit, testClass);
}

ServiceTargetAssociation.setServiceTarget(serviceTarget);
return testClass;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void transition(ServiceController<? extends Object> serviceController, Se
}
}
}
break;
case STARTING: {
ServiceName serviceName = serviceController.getName();
String simpleName = serviceName.getSimpleName();
Expand All @@ -125,6 +126,7 @@ public void transition(ServiceController<? extends Object> serviceController, Se
ArquillianConfigBuilder.handleParseAnnotations(depUnit);
}
}
break;
}
}
};
Expand Down

0 comments on commit 091529f

Please sign in to comment.