use of org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet in project tomee by apache.
the class TomEEContainer method addServlets.
public void addServlets(final HTTPContext httpContext, final AppInfo appInfo) {
for (final WebAppInfo webApps : appInfo.webApps) {
for (final ServletInfo servlet : webApps.servlets) {
// weird but arquillian url doesn't match the servlet url but its context
String clazz = servlet.servletClass;
if (clazz == null) {
clazz = servlet.servletName;
if (clazz == null) {
continue;
}
}
httpContext.add(new Servlet(clazz, webApps.contextRoot));
/*
for (String mapping : servlet.mappings) {
httpContext.add(new Servlet(servlet.servletClass, startWithSlash(uniqueSlash(webApps.contextRoot, mapping))));
}
*/
}
}
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet in project tomee by apache.
the class OpenEJBDeployableContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
final DeploymentInfo info;
try {
final Closeables cl = new Closeables();
closeablesProducer.set(cl);
info = quickDeploy(archive, testClass.get(), cl);
// container rules (CDI) which is not the case with this solution
if (archive.getName().endsWith(".war")) {
final List<BeanContext> beanContexts = info.appCtx.getBeanContexts();
if (beanContexts.size() > 1) {
final Iterator<BeanContext> it = beanContexts.iterator();
while (it.hasNext()) {
final BeanContext next = it.next();
if (ModuleTestContext.class.isInstance(next.getModuleContext()) && BeanContext.Comp.class != next.getBeanClass()) {
for (final BeanContext b : beanContexts) {
if (b.getModuleContext() != next.getModuleContext()) {
ModuleTestContext.class.cast(next.getModuleContext()).setModuleJndiContextOverride(b.getModuleContext().getModuleJndiContext());
break;
}
}
break;
}
}
}
}
servletContextProducer.set(info.appServletContext);
sessionProducer.set(info.appSession);
appInfoProducer.set(info.appInfo);
appContextProducer.set(info.appCtx);
final ClassLoader loader = info.appCtx.getWebContexts().isEmpty() ? info.appCtx.getClassLoader() : info.appCtx.getWebContexts().iterator().next().getClassLoader();
classLoader.set(loader == null ? info.appCtx.getClassLoader() : loader);
} catch (final Exception e) {
throw new DeploymentException("can't deploy " + archive.getName(), e);
}
// if service manager is started allow @ArquillianResource URL injection
if (PROPERTIES.containsKey(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE)) {
final ProtocolMetaData metaData = ServiceManagers.protocolMetaData(appInfoProducer.get());
HTTPContext http = null;
for (final WebAppInfo webapp : info.appInfo.webApps) {
for (final ServletInfo servletInfo : webapp.servlets) {
if (http == null) {
http = HTTPContext.class.cast(metaData.getContexts().iterator().next());
http.add(new Servlet(servletInfo.servletName, webapp.contextRoot));
}
}
for (final ClassListInfo classListInfo : webapp.webAnnotatedClasses) {
for (final String path : classListInfo.list) {
if (!path.contains("!")) {
continue;
}
if (http == null) {
http = HTTPContext.class.cast(metaData.getContexts().iterator().next());
}
http.add(new Servlet(path.substring(path.lastIndexOf('!') + 2).replace(".class", "").replace("/", "."), webapp.contextRoot));
}
}
}
if (metaData != null) {
return metaData;
}
}
return new ProtocolMetaData();
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet in project tomee by apache.
the class ServiceManagers method newHttpProtocolMetaData.
private static ProtocolMetaData newHttpProtocolMetaData(final ServerService ss, final String contextRoot) {
final HTTPContext httpContext = new HTTPContext(ss.getIP(), ss.getPort());
httpContext.add(new Servlet("ArquillianServletRunner", contextRoot));
return new ProtocolMetaData().addContext(httpContext);
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet in project tomee by apache.
the class EmbeddedTomEEContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
try {
/* don't do it since it should be configurable
final File tempDir = Files.createTempDir();
final File file = new File(tempDir, name);
*/
final String name = archive.getName();
final Dump dump = this.dumpFile(archive);
final File file = dump.getFile();
if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(name)) {
ARCHIVES.put(archive, file);
this.container.deploy(name, file);
}
final AppInfo info = this.container.getInfo(name);
final String context = this.getArchiveNameWithoutExtension(archive);
final HTTPContext httpContext = new HTTPContext(this.configuration.getHost(), this.configuration.getHttpPort());
httpContext.add(new Servlet("ArquillianServletRunner", "/" + context));
this.addServlets(httpContext, info);
// ensure tests can use request/session scopes even if we don't have a request
startCdiContexts(name);
classLoader.set(SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(info.appId).getClassLoader());
return new ProtocolMetaData().addContext(httpContext);
} catch (final Exception e) {
throw new DeploymentException("Unable to deploy", e);
}
}
Aggregations