org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData Java Examples

The following examples show how to use org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PiranhaServerDeployableContainer.java    From piranha with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    LOGGER.info("Starting Piranha Micro");

    microOuterDeployer = new MicroOuterDeployer(configuration);

    Set<String> servletNames = microOuterDeployer.deploy(archive);

    HTTPContext httpContext = new HTTPContext("localhost", configuration.getPort());
    for (String servletName : servletNames) {
        httpContext.add(new Servlet(servletName, "/"));
    }

    ProtocolMetaData protocolMetaData = new ProtocolMetaData();
    protocolMetaData.addContext(httpContext);

    return protocolMetaData;
}
 
Example #2
Source File: KeycloakOnUndertow.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    if (isRemoteMode()) {
        log.infof("Skipped deployment of '%s' as we are in remote mode!", archive.getName());
        return new ProtocolMetaData();
    }

    DeploymentInfo di = getDeplotymentInfoFromArchive(archive);

    ClassLoader parentCl = Thread.currentThread().getContextClassLoader();
    UndertowWarClassLoader classLoader = new UndertowWarClassLoader(parentCl, archive);
    Thread.currentThread().setContextClassLoader(classLoader);

    try {
        undertow.deploy(di);
    } finally {
        Thread.currentThread().setContextClassLoader(parentCl);
    }

    deployedArchivesToContextPath.put(archive.getName(), di.getContextPath());

    return new ProtocolMetaData().addContext(
            createHttpContextForDeploymentInfo(di));
}
 
Example #3
Source File: FurnaceProtocol.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public ContainerMethodExecutor getExecutor(FurnaceProtocolConfiguration protocolConfiguration,
         ProtocolMetaData metaData, CommandCallback callback)
{
   if (metaData == null)
   {
      return new ContainerMethodExecutor()
      {
         @Override
         public TestResult invoke(TestMethodExecutor arg0)
         {
            return TestResult.skipped();
         }
      };
   }

   Collection<FurnaceHolder> contexts = metaData.getContexts(FurnaceHolder.class);
   if (contexts.size() == 0)
   {
      throw new IllegalArgumentException(
               "No " + Furnace.class.getName() + " found in " + ProtocolMetaData.class.getName() + ". " +
                        "Furnace protocol can not be used");
   }
   return new FurnaceTestMethodExecutor(protocolConfiguration, contexts.iterator().next());
}
 
Example #4
Source File: RemoteInitialContextObserver.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void beforeSuite(@Observes final BeforeEnrichment event) {
    final ProtocolMetaData metaData = protocolMetadata.get();
    if(metaData == null || !metaData.hasContext(HTTPContext.class)) {
        return;
    }

    try {
        Thread.currentThread().getContextClassLoader().loadClass(REMOTE_INITIAL_CONTEXT_FACTORY);

        final HTTPContext httpContext = metaData.getContexts(HTTPContext.class).iterator().next();
        final Properties props = new Properties();
        props.setProperty(Context.INITIAL_CONTEXT_FACTORY, REMOTE_INITIAL_CONTEXT_FACTORY);
        props.setProperty(Context.PROVIDER_URL, "http://" + httpContext.getHost() + ":" + httpContext.getPort() + "/tomee/ejb");

        Context existing = null;
        try {
            existing = existingContext.get();
        } catch (final Throwable t) {
            // no-op
        }

        final Context proxyInstance = (Context) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[]{Context.class}, new MultipleContextHandler(props, existing));
        context.set(new InitialContextWrapper(proxyInstance)); // cause ContextProducer of arquillian supports InitialContext
    } catch (final ClassNotFoundException | NamingException e) {
        // no-op
    }
}
 
Example #5
Source File: AbstractJettyAppServerTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployingAndUndeploying() throws Exception {
    // given
    WebArchive archive = ShrinkWrap.create(WebArchive.class,"archive.war")
            .addClasses(ExampleRest.class);

    JettyAppServer server = new JettyAppServer();
    Response responseFromTheApp = null;

    // when
    try {
        server.start();
        ProtocolMetaData data = server.deploy(archive);

        HTTPContext servletContext = data.getContexts(HTTPContext.class).iterator().next();
        URI appURI = servletContext.getServlets().get(0).getBaseURI();

        server.undeploy(archive);

        Client client = ClientBuilder.newClient();
        responseFromTheApp = client.target(appURI).request().get();
    } finally {
        server.stop();
    }

    // assert
    Assert.assertNotNull(responseFromTheApp);
    Assert.assertEquals(404, responseFromTheApp.getStatus());
}
 
Example #6
Source File: AbstractJettyAppServerTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployingRESTApp() throws Exception {
    // given
    WebArchive archive = ShrinkWrap.create(WebArchive.class,"archive.war")
            .addClasses(ExampleRest.class);

    JettyAppServer server = new JettyAppServer();
    Response responseFromTheApp = null;

    // when
    try {
        server.start();
        ProtocolMetaData data = server.deploy(archive);

        HTTPContext servletContext = data.getContexts(HTTPContext.class).iterator().next();
        URI appURI = servletContext.getServlets().get(0).getBaseURI();

        Client client = ClientBuilder.newClient();
        responseFromTheApp = client.target(appURI).request().get();
    } finally {
        server.stop();
    }

    // assert
    Assert.assertNotNull(responseFromTheApp);
    Assert.assertEquals(200, responseFromTheApp.getStatus());
}
 
Example #7
Source File: AbstractJettyAppServerTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployingServletApp() throws Exception {
    // given
    WebArchive archive = ShrinkWrap.create(WebArchive.class,"archive.war")
            .addClasses(ExampleServlet.class);

    JettyAppServer server = new JettyAppServer();
    Response responseFromTheApp = null;

    // when
    try {
        server.start();
        ProtocolMetaData data = server.deploy(archive);

        HTTPContext servletContext = data.getContexts(HTTPContext.class).iterator().next();
        URI appURI = servletContext.getServletByName(TEST_SERVLET_NAME).getBaseURI().resolve(TEST_SERVLET_URL_MAPPING);

        Client client = ClientBuilder.newClient();
        responseFromTheApp = client.target(appURI).request().get();
    } finally {
        server.stop();
    }

    // assert
    Assert.assertNotNull(responseFromTheApp);
    Assert.assertEquals(200, responseFromTheApp.getStatus());
}
 
Example #8
Source File: ServiceManagers.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static ProtocolMetaData protocolMetaData(final AppInfo info) {
    final org.apache.openejb.server.ServiceManager smp = org.apache.openejb.server.ServiceManager.get();
    if (smp != null && SimpleServiceManager.class.isInstance(smp)) {
        final ServerService[] daemons = SimpleServiceManager.class.cast(smp).getDaemons();
        for (final ServerService ss : daemons) {
            if ("httpejbd".equals(ss.getName())) {
                if (info.webApps.size() == 1) {
                    return newHttpProtocolMetaData(ss, info.webApps.iterator().next().contextRoot);
                }
                return newHttpProtocolMetaData(ss, info.appId);
            }
        }
    }
    return null;
}
 
Example #9
Source File: TargetController.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    return deployment(new Callable<ProtocolMetaData>() {
        @SuppressWarnings("unchecked")
        @Override
        public ProtocolMetaData call() throws Exception {
            return delegate.deploy(archive);
        }
    });
}
 
Example #10
Source File: DaemonProtocol.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see org.jboss.arquillian.container.test.spi.client.protocol.Protocol#getExecutor(org.jboss.arquillian.container.test.spi.client.protocol.ProtocolConfiguration,
 * org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData,
 * org.jboss.arquillian.container.test.spi.command.CommandCallback)
 */
@Override
public ContainerMethodExecutor getExecutor(final DaemonProtocolConfiguration protocolConfiguration,
                                           final ProtocolMetaData metaData, final CommandCallback callback) {
    final Collection<DeploymentContext> contexts = metaData.getContexts(DeploymentContext.class);
    assert contexts.size() == 1 : "Should be exactly one deployment context";
    final DeploymentContext context = contexts.iterator().next();
    return new DaemonMethodExecutor(context);
}
 
Example #11
Source File: DaemonProtocol.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see org.jboss.arquillian.container.test.spi.client.protocol.Protocol#getExecutor(org.jboss.arquillian.container.test.spi.client.protocol.ProtocolConfiguration,
 * org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData,
 * org.jboss.arquillian.container.test.spi.command.CommandCallback)
 */
@Override
public ContainerMethodExecutor getExecutor(final DaemonProtocolConfiguration protocolConfiguration,
                                           final ProtocolMetaData metaData, final CommandCallback callback) {
    final Collection<DeploymentContext> contexts = metaData.getContexts(DeploymentContext.class);
    assert contexts.size() == 1 : "Should be exactly one deployment context";
    final DeploymentContext context = contexts.iterator().next();
    return new DaemonMethodExecutor(context);
}
 
Example #12
Source File: WildFlySwarmContainer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    BootstrapUtil.convertSwarmSystemPropertiesToThorntail();

    StartupTimeout startupTimeout = this.testClass.getAnnotation(StartupTimeout.class);
    if (startupTimeout != null) {
        setTimeout(startupTimeout.value());
    }

    this.delegateContainer = new UberjarSimpleContainer(this.containerContext.get(), this.deploymentContext.get(), this.testClass);

    try {
        this.delegateContainer
                .setJavaVmArguments(this.getJavaVmArguments())
                .requestedMavenArtifacts(this.requestedMavenArtifacts)
                .start(archive);
        // start wants to connect to the remote container, which isn't up until now, so
        // we override start above and call it here instead
        super.start();

        ProtocolMetaData metaData = new ProtocolMetaData();
        metaData.addContext(createDeploymentContext(archive.getId()));

        return metaData;
    } catch (Throwable e) {
        if (e instanceof LifecycleException) {
            e = e.getCause();
        }
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
Example #13
Source File: WildFlySwarmContainer.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    StartupTimeout startupTimeout = this.testClass.getAnnotation(StartupTimeout.class);
    if (startupTimeout != null) {
        setTimeout(startupTimeout.value());
    }


    if (this.testClass.getAnnotation(InVM.class) != null) {
        this.delegateContainer = new InVMSimpleContainer(this.testClass);
    } else {
        this.delegateContainer = new UberjarSimpleContainer(this.testClass);
    }
    try {
        this.delegateContainer
                .requestedMavenArtifacts(this.requestedMavenArtifacts)
                .start(archive);
        // start wants to connect to the remote container, which isn't up until now, so
        // we override start above and call it here instead
        super.start();

        ProtocolMetaData metaData = new ProtocolMetaData();
        metaData.addContext(createDeploymentContext(archive.getId()));

        return metaData;
    } catch (Exception e) {
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
Example #14
Source File: MeecrowaveContainer.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@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)));
}
 
Example #15
Source File: QuarkusProtocol.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public ContainerMethodExecutor getExecutor(QuarkusProtocolConfiguration protocolConfiguration, ProtocolMetaData metaData,
        CommandCallback callback) {
    return injector.get().inject(new QuarkusMethodExecutor());
}
 
Example #16
Source File: ChameleonContainer.java    From arquillian-container-chameleon with Apache License 2.0 4 votes vote down vote up
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    return target.deploy(archive);
}
 
Example #17
Source File: JettyAppServer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    log.info("Deploying archive " + archive.getName());

    if (!(archive instanceof WebArchive)) {
        throw new IllegalArgumentException("JettyContainer only supports WebArchives.");
    }

    WebArchive webArchive = (WebArchive) archive;

    try {
        KeycloakAdapterApp app = appProvider.createApp(webArchive);
        WebAppContext webAppContext = (WebAppContext) app.getContextHandler();


        addAdditionalConfigurations(webAppContext);

        setContextRoot(webArchive, app, webAppContext);

        if (app.usesOIDCAuthenticator()) {
            addOIDCAuthenticator(webAppContext);
        }

        if (app.usesSAMLAuthenticator()) {
            addSAMLAuthenticator(webAppContext);
        }

        if (app.usesJaxrs()) {
            addRestEasyServlet(webArchive, webAppContext);
        }

        setEmbeddedClassloaderForDeployment(webAppContext);

        deployer.addApp(app);
        deployer.requestAppGoal(app, AppLifeCycle.STARTED);

        deployedApps.put(archive.getId(), app);

        HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort());
        ServletHandler servletHandler = webAppContext.getServletHandler();

        for (ServletHolder servlet : servletHandler.getServlets()) {
            log.debugf("Servlet context mapping: %s => %s", servlet.getName(), servlet.getContextPath());
            httpContext.add(new Servlet(servlet.getName(), servlet.getContextPath()));
        }

        if (log.isInfoEnabled()) {
            for (ServletMapping mapping : server.getChildHandlerByClass(ServletHandler.class).getServletMappings()) {
                log.debugf("Servlet mapping: %s => %s", mapping.getServletName(), Arrays.toString(mapping.getPathSpecs()));
            }
        }

        return new ProtocolMetaData().addContext(httpContext);
    } catch (Exception e) {
        throw new DeploymentException("Unable to deploy archive", e);
    }
}
 
Example #18
Source File: UndertowAppServer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    log.info("Deploying archive " + archive.getName());

    // Remove jsps
    String ioTMPDir = System.getProperty("java.io.tmpdir", ""); // My Intellij and Terminal stores tmp directory in this property
    if (!ioTMPDir.isEmpty()) {
        ioTMPDir = ioTMPDir.endsWith("/") ? ioTMPDir : ioTMPDir + "/";
        File tmpUndertowJSPDirectory = new File(ioTMPDir + "org/apache/jsp");
        if (tmpUndertowJSPDirectory.exists()) {
            try {
                FileUtils.deleteDirectory(tmpUndertowJSPDirectory);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    DeploymentInfo di;
    if (archive instanceof UndertowWebArchive) {
        di = ((UndertowWebArchive) archive).getDeploymentInfo();
    } else if (archive instanceof WebArchive) {
        WebArchive webArchive = (WebArchive)archive;

        Optional<Node> applicationClassNode = archive.getContent(archivePath ->
                archivePath.get().startsWith("/WEB-INF/classes/") && archivePath.get().endsWith("Application.class"))
                .values().stream().findFirst();

        if (isJaxrsApp(webArchive)) {
            di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive,
                    undertow.undertowDeployment(discoverPathAnnotatedClasses(webArchive)));
        } else if (applicationClassNode.isPresent()) {
            String applicationPath = applicationClassNode.get().getPath().get();

            ResteasyDeployment deployment = new ResteasyDeployment();
            deployment.setApplicationClass(extractClassName(applicationPath));
            di = new UndertowDeployerHelper().getDeploymentInfo(configuration, (WebArchive) archive, undertow.undertowDeployment(deployment));
        } else {
            di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive);
        }
    } else {
        throw new IllegalArgumentException("UndertowContainer only supports UndertowWebArchive or WebArchive.");
    }

    if ("ROOT.war".equals(archive.getName())) {
        di.setContextPath("/");
    }

    ClassLoader parentCl = Thread.currentThread().getContextClassLoader();
    UndertowWarClassLoader classLoader = new UndertowWarClassLoader(parentCl, archive);
    Thread.currentThread().setContextClassLoader(classLoader);

    try {
        undertow.deploy(di);
    } finally {
        Thread.currentThread().setContextClassLoader(parentCl);
    }

    deployedArchivesToContextPath.put(archive.getName(), di.getContextPath());

    return new ProtocolMetaData().addContext(
            createHttpContextForDeploymentInfo(di));
}
 
Example #19
Source File: SimpleUndertowLoadBalancerContainer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    throw new UnsupportedOperationException("Not implemented");
}
 
Example #20
Source File: KeycloakQuarkusServerDeployableContainer.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    return null;
}
 
Example #21
Source File: EmbeddedTomEEContainer.java    From tomee with Apache License 2.0 4 votes vote down vote up
@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();
            current.setContextClassLoader(ParentClassLoaderFinder.Helper.get()); // multiple deployments, don't leak a loader
            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);

        startCdiContexts(name); // ensure tests can use request/session scopes even if we don't have a request

        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);
    }
}
 
Example #22
Source File: ServiceManagers.java    From tomee with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example #23
Source File: OpenEJBDeployableContainer.java    From tomee with Apache License 2.0 4 votes vote down vote up
@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);

        // try to switch module context jndi to let test use java:module naming
        // we could put the managed bean in the war but then test class should respect all the
        // 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();
        final ClassLoader classLoader = loader == null ? info.appCtx.getClassLoader() : loader;

        TestObserver.ClassLoaders classLoaders = this.classLoader.get();
        if (classLoaders == null) {
            classLoaders = new TestObserver.ClassLoaders();
            this.classLoader.set(classLoaders);
        }
        classLoaders.register(archive.getName(), classLoader);
    } 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();
}
 
Example #24
Source File: ManagedSEDeployableContainer.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    LOGGER.info("Deploying " + archive.getName());

    // First of all clear the list of previously materialized deployments - otherwise the class path would grow indefinitely
    materializedFiles.clear();

    // Create a new classpath
    classpathDependencies.clear();

    if (ClassPath.isRepresentedBy(archive)) {
        for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) {
            Asset asset = child.getAsset();
            if (asset instanceof ArchiveAsset) {
                Archive<?> assetArchive = ((ArchiveAsset) asset).getArchive();
                if (ClassPathDirectory.isRepresentedBy(assetArchive)) {
                    materializeDirectory(assetArchive);
                } else {
                    materializeArchive(assetArchive);
                }
            }
        }
    } else {
        materializeArchive(archive);
    }

    Properties systemProperties = getSystemProperties(archive);
    readJarFilesFromDirectory();
    addTestResourcesDirectory(systemProperties);

    List<String> processCommand = buildProcessCommand(systemProperties);
    logExecutedCommand(processCommand);
    // Launch the process
    final ProcessBuilder processBuilder = new ProcessBuilder(processCommand);

    String path = systemProperties.getProperty("container.user.dir");
    if (path != null) {
        processBuilder.directory(new File(path));
    }

    processBuilder.environment().put("JAVA_HOME", new File(System.getProperty(SYSPROP_KEY_JAVA_HOME)).getAbsolutePath());

    processBuilder.redirectErrorStream(true);
    processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
    processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);

    try {
        process = processBuilder.start();
    } catch (final IOException e) {
        throw new DeploymentException("Could not start process", e);
    }

    int finalWaitTime = debugModeEnabled ? (3 * waitTime) : waitTime;

    // Wait for socket connection
    if (!isServerStarted(host, port, finalWaitTime)) {
        throw new DeploymentException("Child JVM process failed to start within " + finalWaitTime + " seconds.");
    }
    if (!isJMXTestRunnerMBeanRegistered(host, port, finalWaitTime)) {
        throw new DeploymentException("JMXTestRunnerMBean not registered within " + finalWaitTime + " seconds.");
    }

    ProtocolMetaData protocolMetaData = new ProtocolMetaData();
    protocolMetaData.addContext(new JMXContext(host, port));
    return protocolMetaData;
}
 
Example #25
Source File: UserLogin.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
public void prepare(@Observes AfterDeploy event, ProtocolMetaData data) {
    this.protocolMetaData = data;
}
 
Example #26
Source File: ArquillianSuiteExtension.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
public void storeProtocolMetaData(@Observes ProtocolMetaData protocolMetaData) {
    cachedProtocolMetaData = protocolMetaData;
}