org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet Java Examples
The following examples show how to use
org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet.
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 |
@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: TomEEContainer.java From tomee with Apache License 2.0 | 6 votes |
protected void addArquillianServlet(final Archive<?> archive, final AppInfo appInfo, final String archiveName, final HTTPContext httpContext) { // Avoids "inconvertible types" error in windows build if (archiveName.endsWith(".war")) { httpContext.add(new Servlet("ArquillianServletRunner", "/" + getArchiveNameWithoutExtension(archive))); } else if (archiveName.endsWith(".ear") && appInfo.webApps.size() > 0) { final String contextRoot = System.getProperty("tomee.arquillian.ear.context", configuration.getWebContextToUseWithEars()); if (contextRoot != null) { httpContext.add(new Servlet("ArquillianServletRunner", ("/" + contextRoot).replace("//", "/"))); } else { for (final WebAppInfo web : appInfo.webApps) { // normally a single webapp is supported cause of arquillian resolution httpContext.add(new Servlet("ArquillianServletRunner", ("/" + web.contextRoot).replace("//", "/"))); } } } else { httpContext.add(new Servlet("ArquillianServletRunner", "/arquillian-protocol")); // needs another jar to add the fake webapp } }
Example #3
Source File: TomEEContainer.java From tomee with Apache License 2.0 | 6 votes |
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)))); } */ } } }
Example #4
Source File: MeecrowaveContainer.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
@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 #5
Source File: KeycloakOnUndertow.java From keycloak with Apache License 2.0 | 5 votes |
private HTTPContext createHttpContextForDeploymentInfo(DeploymentInfo deploymentInfo) { HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort()); final Map<String, ServletInfo> servlets = deploymentInfo.getServlets(); final Collection<ServletInfo> servletsInfo = servlets.values(); for (ServletInfo servletInfo : servletsInfo) { httpContext.add(new Servlet(servletInfo.getName(), deploymentInfo.getContextPath())); } return httpContext; }
Example #6
Source File: UndertowAppServer.java From keycloak with Apache License 2.0 | 5 votes |
private HTTPContext createHttpContextForDeploymentInfo(DeploymentInfo deploymentInfo) { HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort()); final Map<String, ServletInfo> servlets = deploymentInfo.getServlets(); final Collection<ServletInfo> servletsInfo = servlets.values(); for (ServletInfo servletInfo : servletsInfo) { httpContext.add(new Servlet(servletInfo.getName(), deploymentInfo.getContextPath())); } return httpContext; }
Example #7
Source File: OpenEJBDeployableContainer.java From tomee with Apache License 2.0 | 4 votes |
@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 #8
Source File: ServiceManagers.java From tomee with Apache License 2.0 | 4 votes |
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 #9
Source File: EmbeddedTomEEContainer.java From tomee with Apache License 2.0 | 4 votes |
@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 #10
Source File: JettyAppServer.java From keycloak with Apache License 2.0 | 4 votes |
@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); } }