Search in sources :

Example 6 with HTTPContext

use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project meecrowave by apache.

the class MeecrowaveContainer method deploy.

@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    final File dump = toArchiveDump(archive);
    archive.as(ZipExporter.class).exportTo(dump, true);
    final String context = sanitizeName(archive);
    container.deployWebapp(context, dump);
    final int port = configuration.isSkipHttp() ? configuration.getHttpsPort() : configuration.getHttpPort();
    return new ProtocolMetaData().addContext(new HTTPContext(configuration.getHost(), port).add(new Servlet("arquillian", context)));
}
Also used : ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) 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) File(java.io.File)

Example 7 with HTTPContext

use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project Payara by payara.

the class CommonPayaraManager method deploy.

public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    if (archive == null) {
        throw new IllegalArgumentException("archive must not be null");
    }
    final String archiveName = archive.getName();
    final ProtocolMetaData protocolMetaData = new ProtocolMetaData();
    try {
        InputStream deployment = archive.as(ZipExporter.class).exportAsInputStream();
        // Build up the POST form to send to Payara
        final FormDataMultiPart form = new FormDataMultiPart();
        form.bodyPart(new StreamDataBodyPart("id", deployment, archiveName));
        deploymentName = createDeploymentName(archiveName);
        addDeployFormFields(deploymentName, form);
        // Do Deploy the application on the remote Payara
        HTTPContext httpContext = payaraClient.doDeploy(deploymentName, form);
        protocolMetaData.addContext(httpContext);
    } catch (PayaraClientException e) {
        throw new DeploymentException("Could not deploy " + archiveName, e);
    }
    return protocolMetaData;
}
Also used : StreamDataBodyPart(org.glassfish.jersey.media.multipart.file.StreamDataBodyPart) InputStream(java.io.InputStream) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) FormDataMultiPart(org.glassfish.jersey.media.multipart.FormDataMultiPart) 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) PayaraClientException(fish.payara.arquillian.container.payara.clientutils.PayaraClientException)

Example 8 with HTTPContext

use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project Payara by payara.

the class PayaraClientService method doDeploy.

/**
 * Do deploy an application defined by a multipart form's fileds to a target server or a cluster
 * of GlassFish 3.1
 *
 * @param name - name of the appliacation form - a form of MediaType.MULTIPART_FORM_DATA_TYPE
 * @return subComponents - a map of SubComponents of the application
 */
public HTTPContext doDeploy(String name, FormDataMultiPart form) {
    // Deploy the application on the Payara server
    getClientUtil().POSTMultiPartRequest(APPLICATION, form);
    // Fetch the list of SubComponents of the application
    Map<String, Object> subComponentsResponse = getClientUtil().GETRequest(APPLICATION_COMPONENTS.replace("{application}", name));
    @SuppressWarnings("unchecked") Map<String, String> subComponents = (Map<String, String>) subComponentsResponse.get("properties");
    // Build up the HTTPContext object using the nodeAddress information
    HTTPContext httpContext = new HTTPContext(nodeAddress.getHost(), nodeAddress.getHttpPort());
    // Add the servlets to the HTTPContext
    String contextRoot = getApplicationContextRoot(name);
    if (subComponents != null) {
        for (Entry<String, String> subComponent : subComponents.entrySet()) {
            String componentName = subComponent.getKey().toString();
            if (WEBMODULE.equals(subComponent.getValue())) {
                @SuppressWarnings("unchecked") List<Map<String, Object>> children = (List<Map<String, Object>>) subComponentsResponse.get("children");
                // Override the application contextRoot by the webmodule's contextRoot
                contextRoot = resolveWebModuleContextRoot(componentName, children);
                resolveWebModuleSubComponents(name, componentName, contextRoot, httpContext);
            } else if (SERVLET.equals(subComponent.getValue())) {
                httpContext.add(new Servlet(componentName, contextRoot));
            }
        }
    }
    return httpContext;
}
Also used : Servlet(org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet) HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with HTTPContext

use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project tomee by apache.

the class TomEEContainer method deploy.

@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    try {
        final Dump dump = dumpFile(archive);
        final File file = dump.getFile();
        final String fileName = file.getName();
        if (dump.isCreated() && (fileName.endsWith(".war") || fileName.endsWith(".ear"))) {
            // extracted folder, TODO: openejb work dir is ignored here
            Files.deleteOnExit(new File(file.getParentFile(), fileName.substring(0, fileName.length() - 4)));
        }
        final AppInfo appInfo;
        final String archiveName = archive.getName();
        try {
            if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(archiveName)) {
                appInfo = doDeploy(archive, file);
                if (appInfo != null) {
                    moduleIds.put(archiveName, new DeployedApp(appInfo.path, file));
                    // "i" folder
                    Files.deleteOnExit(file);
                }
            } else {
                final String path = moduleIds.get(archiveName).path;
                AppInfo selected = null;
                for (final AppInfo info : getDeployedApps()) {
                    if (path.equals(info.path)) {
                        selected = info;
                        break;
                    }
                }
                appInfo = selected;
            }
            if (appInfo == null) {
                LOGGER.severe("appInfo was not found for " + file.getPath() + ", available are: " + apps());
                throw new OpenEJBException("can't get appInfo");
            }
        } catch (final OpenEJBException re) {
            // clean up in undeploy needs it
            moduleIds.put(archiveName, new DeployedApp(file.getPath(), file));
            throw re;
        }
        if (options.get("tomee.appinfo.output", false)) {
            Info.marshal(appInfo);
        }
        final HTTPContext httpContext = new HTTPContext(configuration.getHost(), configuration.getHttpPort());
        addArquillianServlet(archive, appInfo, archiveName, httpContext);
        addServlets(httpContext, appInfo);
        return new ProtocolMetaData().addContext(httpContext);
    } catch (final Exception e) {
        throw new DeploymentException("Unable to deploy", e);
    }
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) 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) NamingException(javax.naming.NamingException) UndeployException(org.apache.openejb.UndeployException) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) OpenEJBException(org.apache.openejb.OpenEJBException) IOException(java.io.IOException) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 10 with HTTPContext

use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext 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);
            final Thread current = Thread.currentThread();
            final ClassLoader loader = current.getContextClassLoader();
            // multiple deployments, don't leak a loader
            current.setContextClassLoader(ParentClassLoaderFinder.Helper.get());
            try {
                this.container.deploy(name, file);
            } finally {
                current.setContextClassLoader(loader);
            }
        }
        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);
        TestObserver.ClassLoaders classLoaders = this.classLoader.get();
        if (classLoaders == null) {
            classLoaders = new TestObserver.ClassLoaders();
            this.classLoader.set(classLoaders);
        }
        classLoaders.register(archive.getName(), 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) HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) TestObserver(org.apache.openejb.arquillian.common.TestObserver) 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) 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) File(java.io.File)

Aggregations

HTTPContext (org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext)10 ProtocolMetaData (org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)9 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)6 Servlet (org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet)5 File (java.io.File)4 NamingException (javax.naming.NamingException)4 LifecycleException (org.jboss.arquillian.container.spi.client.container.LifecycleException)4 IOException (java.io.IOException)3 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)3 ArrayList (java.util.ArrayList)2 TestObserver (org.apache.openejb.arquillian.common.TestObserver)2 AppInfo (org.apache.openejb.assembler.classic.AppInfo)2 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)2 PayaraVersion (fish.payara.arquillian.container.payara.PayaraVersion)1 PayaraClientException (fish.payara.arquillian.container.payara.clientutils.PayaraClientException)1 BufferingConsumer (fish.payara.arquillian.container.payara.process.BufferingConsumer)1 ConsoleReader (fish.payara.arquillian.container.payara.process.ConsoleReader)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 SecureRandom (java.security.SecureRandom)1