Search in sources :

Example 1 with DeploymentException

use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.

the class ManagedSEDeployableContainer method getSystemProperties.

private Properties getSystemProperties(final Archive<?> archive) throws DeploymentException {
    Node systemPropertiesNode = archive.get(ClassPath.SYSTEM_PROPERTIES_ARCHIVE_PATH);
    if (systemPropertiesNode != null) {
        try (InputStream in = systemPropertiesNode.getAsset().openStream()) {
            Properties systemProperties = new Properties();
            systemProperties.load(in);
            return systemProperties;
        } catch (IOException e) {
            throw new DeploymentException("Could not load system properties", e);
        }
    }
    return null;
}
Also used : InputStream(java.io.InputStream) Node(org.jboss.shrinkwrap.api.Node) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) IOException(java.io.IOException) Properties(java.util.Properties)

Example 2 with DeploymentException

use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.

the class FileDeploymentUtils method materializeSubdirectories.

public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException {
    for (Node child : node.getChildren()) {
        if (child.getAsset() == null) {
            materializeSubdirectories(entryDirectory, child);
        } else {
            if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) {
                // Do not materialize the marker file
                continue;
            }
            // E.g. META-INF/my-super-descriptor.xml
            File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar));
            File resoureDirectory = resourceFile.getParentFile();
            if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) {
                throw new DeploymentException("Could not create class path directory: " + entryDirectory);
            }
            resourceFile.createNewFile();
            try (InputStream in = child.getAsset().openStream();
                OutputStream out = new FileOutputStream(resourceFile)) {
                copy(in, out);
            }
            child.getPath().get();
        }
    }
}
Also used : InputStream(java.io.InputStream) Node(org.jboss.shrinkwrap.api.Node) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) File(java.io.File)

Example 3 with DeploymentException

use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.

the class FileDeploymentUtils method materializeClass.

public static void materializeClass(File entryDirectory, ClassAsset classAsset) throws DeploymentException, IOException {
    File classDirectory;
    if (classAsset.getSource().getPackage() != null) {
        classDirectory = new File(entryDirectory, classAsset.getSource().getPackage().getName().replace(DELIMITER_CLASS_NAME_PATH, File.separatorChar));
        if (!classDirectory.mkdirs()) {
            throw new DeploymentException("Could not create class package directory: " + classDirectory);
        }
    } else {
        classDirectory = entryDirectory;
    }
    File classFile = new File(classDirectory, classAsset.getSource().getSimpleName().concat(EXTENSION_CLASS));
    classFile.createNewFile();
    try (InputStream in = classAsset.openStream();
        OutputStream out = new FileOutputStream(classFile)) {
        copy(in, out);
    }
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) File(java.io.File)

Example 4 with DeploymentException

use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.

the class TomEEContainer method undeploy.

@Override
public void undeploy(final Archive<?> archive) throws DeploymentException {
    final String archiveName = archive.getName();
    if (configuration.isSingleDeploymentByArchiveName(archiveName)) {
        return;
    }
    final DeployedApp deployed = moduleIds.remove(archiveName);
    try {
        if (deployed == null) {
            LOGGER.warning(archiveName + " was not deployed");
            return;
        }
        doUndeploy(deployed);
    } catch (final Exception e) {
        throw new DeploymentException("Unable to undeploy " + archiveName, e);
    } finally {
        if (deployed != null && !configuration.isSingleDumpByArchiveName()) {
            LOGGER.info("cleaning " + deployed.file.getAbsolutePath());
            // "i" folder
            Files.delete(deployed.file);
            final File pathFile = new File(deployed.path);
            if (!deployed.path.equals(deployed.file.getAbsolutePath()) && pathFile.exists()) {
                LOGGER.info("cleaning " + pathFile);
                Files.delete(pathFile);
            }
            final File parentFile = deployed.file.getParentFile();
            final File[] parentChildren = parentFile.listFiles();
            if (parentChildren == null || parentChildren.length == 0) {
                Files.delete(deployed.file.getParentFile());
            }
        }
    }
}
Also used : DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) 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)

Example 5 with DeploymentException

use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.

the class EmbeddedTomEEContainer method undeploy.

@Override
public void undeploy(final Archive<?> archive) throws DeploymentException {
    final String name = archive.getName();
    stopCdiContexts(name);
    if (configuration.isSingleDeploymentByArchiveName(name)) {
        return;
    }
    try {
        this.container.undeploy(name);
    } catch (final Exception e) {
        throw new DeploymentException("Unable to undeploy", e);
    }
    final File file = ARCHIVES.remove(archive);
    if (!configuration.isSingleDumpByArchiveName()) {
        final File folder = new File(file.getParentFile(), file.getName().substring(0, file.getName().length() - 4));
        if (folder.exists()) {
            Files.delete(folder);
        }
        Files.delete(file);
        final File parentFile = file.getParentFile();
        final File[] parentChildren = parentFile.listFiles();
        if (parentChildren == null || parentChildren.length == 0) {
            Files.delete(file.getParentFile());
        }
    }
}
Also used : DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) File(java.io.File) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException)

Aggregations

DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)15 File (java.io.File)9 IOException (java.io.IOException)9 LifecycleException (org.jboss.arquillian.container.spi.client.container.LifecycleException)8 NamingException (javax.naming.NamingException)6 ProtocolMetaData (org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)4 Node (org.jboss.shrinkwrap.api.Node)4 InputStream (java.io.InputStream)3 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)3 AppInfo (org.apache.openejb.assembler.classic.AppInfo)3 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)3 HTTPContext (org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext)3 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 Properties (java.util.Properties)2 AppContext (org.apache.openejb.AppContext)2 NoSuchApplicationException (org.apache.openejb.NoSuchApplicationException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 UndeployException (org.apache.openejb.UndeployException)2 LightweightWebAppBuilder (org.apache.openejb.web.LightweightWebAppBuilder)2