use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData in project camel by apache.
the class ManagedSEDeployableContainer method deploy.
@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;
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData 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;
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData 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);
}
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData 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);
}
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData 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)));
}
Aggregations