Search in sources :

Example 1 with Servlet

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))));

                }
                */
        }
    }
}
Also used : ServletInfo(org.apache.openejb.assembler.classic.ServletInfo) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) Servlet(org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet)

Example 2 with Servlet

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();
}
Also used : HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) NamingException(javax.naming.NamingException) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) IOException(java.io.IOException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) ClassListInfo(org.apache.openejb.assembler.classic.ClassListInfo) ServletInfo(org.apache.openejb.assembler.classic.ServletInfo) BeanContext(org.apache.openejb.BeanContext) ModuleTestContext(org.apache.openejb.ModuleTestContext) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) Servlet(org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) ProtocolMetaData(org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)

Example 3 with Servlet

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);
}
Also used : Servlet(org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet) HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) ProtocolMetaData(org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)

Example 4 with Servlet

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);
    }
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Servlet(org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet) HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) ProtocolMetaData(org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData) File(java.io.File) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Aggregations

Servlet (org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet)4 HTTPContext (org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext)3 ProtocolMetaData (org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)3 ServletInfo (org.apache.openejb.assembler.classic.ServletInfo)2 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)2 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)2 LifecycleException (org.jboss.arquillian.container.spi.client.container.LifecycleException)2 File (java.io.File)1 IOException (java.io.IOException)1 NamingException (javax.naming.NamingException)1 BeanContext (org.apache.openejb.BeanContext)1 ModuleTestContext (org.apache.openejb.ModuleTestContext)1 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)1 AppInfo (org.apache.openejb.assembler.classic.AppInfo)1 ClassListInfo (org.apache.openejb.assembler.classic.ClassListInfo)1 ContainerSystem (org.apache.openejb.spi.ContainerSystem)1