use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData in project wildfly-swarm by wildfly-swarm.
the class WildFlySwarmContainer method deploy.
@Override
public synchronized ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
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);
}
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData in project keycloak by keycloak.
the class AbstractJettyAppServerTest method testDeployingServletApp.
@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());
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData in project keycloak by keycloak.
the class AbstractJettyAppServerTest method testDeployingAndUndeploying.
@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());
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData in project keycloak by keycloak.
the class JettyAppServer method deploy.
@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);
}
}
Aggregations