Search in sources :

Example 1 with OpenEJBTCKRuntimeException

use of org.apache.openejb.tck.OpenEJBTCKRuntimeException in project tomee by apache.

the class AbstractContainers method writeToFile.

protected void writeToFile(final File file, final InputStream archive) {
    if (!file.getParentFile().exists()) {
        file.getParentFile().mkdirs();
    }
    try {
        final FileOutputStream fos = new FileOutputStream(file);
        final byte[] buffer = new byte[4096];
        int bytesRead;
        while ((bytesRead = archive.read(buffer)) > -1) {
            fos.write(buffer, 0, bytesRead);
        }
        Util.close(fos);
    } catch (Exception e) {
        throw new OpenEJBTCKRuntimeException(e);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) IOException(java.io.IOException)

Example 2 with OpenEJBTCKRuntimeException

use of org.apache.openejb.tck.OpenEJBTCKRuntimeException in project tomee by apache.

the class ContainersImplTomEE method undeploy.

@Override
public void undeploy(final String name) throws IOException {
    if (appInfo == null) {
        if (!(exception instanceof DeploymentException)) {
            System.out.println("Nothing to undeploy" + name);
        }
        return;
    }
    System.out.println("Undeploying " + name);
    try {
        deployer.undeploy(appInfo.path);
    } catch (final Exception e) {
        e.printStackTrace();
        throw new OpenEJBTCKRuntimeException(e);
    }
    final File toDelete;
    if (currentFile != null && (toDelete = currentFile.getParentFile()).exists()) {
        System.out.println("deleting " + toDelete.getAbsolutePath());
        delete(toDelete);
    }
}
Also used : DeploymentException(org.jboss.testharness.api.DeploymentException) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) File(java.io.File) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) IOException(java.io.IOException) ValidationException(org.apache.openejb.config.ValidationException) DeploymentException(org.jboss.testharness.api.DeploymentException)

Example 3 with OpenEJBTCKRuntimeException

use of org.apache.openejb.tck.OpenEJBTCKRuntimeException in project tomee by apache.

the class FullRestartContainer method deploy.

@Override
public boolean deploy(final InputStream archive, final String name) throws IOException {
    if (name.endsWith("war")) {
        currentFile = new File(WEBAPP_DIR, name);
    } else {
        currentFile = new File(APPS_DIR, name);
    }
    System.out.println(currentFile);
    writeToFile(currentFile, archive);
    final int port = ServerLocal.getPort(-1);
    if (port > 0) {
        server = new RemoteServer(100, true);
        server.setPortStartup(port);
    } else {
        throw new OpenEJBTCKRuntimeException("Please set the tomee port using the system property 'server.http.port'");
    }
    try {
        server.start();
    } catch (final Exception e) {
        server.destroy();
        e.printStackTrace();
        throw e;
    }
    return (exception = lookup().exception()) == null;
}
Also used : OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) File(java.io.File) RemoteServer(org.apache.openejb.config.RemoteServer) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) IOException(java.io.IOException) DeploymentException(org.jboss.testharness.api.DeploymentException)

Example 4 with OpenEJBTCKRuntimeException

use of org.apache.openejb.tck.OpenEJBTCKRuntimeException in project tomee by apache.

the class ContainersImplTomEE method lookup.

private Deployer lookup() {
    final Options options = new Options(System.getProperties());
    final Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
    props.put(Context.PROVIDER_URL, options.get(Context.PROVIDER_URL, "http://localhost:" + port + "/tomee/ejb"));
    final String deployerJndi = System.getProperty("openejb.deployer.jndiname", "openejb/DeployerBusinessRemote");
    try {
        final InitialContext context = new InitialContext(props);
        return (Deployer) context.lookup(deployerJndi);
    } catch (final Exception e) {
        throw new OpenEJBTCKRuntimeException(e);
    }
}
Also used : Options(org.apache.openejb.loader.Options) RemoteInitialContextFactory(org.apache.openejb.client.RemoteInitialContextFactory) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) Deployer(org.apache.openejb.assembler.Deployer) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) IOException(java.io.IOException) ValidationException(org.apache.openejb.config.ValidationException) DeploymentException(org.jboss.testharness.api.DeploymentException)

Example 5 with OpenEJBTCKRuntimeException

use of org.apache.openejb.tck.OpenEJBTCKRuntimeException in project tomee by apache.

the class FullRestartContainer method lookup.

private ExceptionManagerFacade lookup() {
    final Options options = new Options(System.getProperties());
    final Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
    final int port = ServerLocal.getPort(-1);
    if (port > 0) {
        System.out.println("provider url = " + "http://localhost:" + port + "/tomee/ejb");
        props.put(Context.PROVIDER_URL, options.get(Context.PROVIDER_URL, "http://localhost:" + port + "/tomee/ejb"));
    } else {
        throw new OpenEJBTCKRuntimeException("Please set the tomee port using the system property 'server.http.port'");
    }
    try {
        final InitialContext context = new InitialContext(props);
        return (ExceptionManagerFacade) context.lookup("openejb/ExceptionManagerFacadeBusinessRemote");
    } catch (final Exception e) {
        throw new OpenEJBTCKRuntimeException(e);
    }
}
Also used : Options(org.apache.openejb.loader.Options) ExceptionManagerFacade(org.apache.tomee.catalina.facade.ExceptionManagerFacade) RemoteInitialContextFactory(org.apache.openejb.client.RemoteInitialContextFactory) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) OpenEJBTCKRuntimeException(org.apache.openejb.tck.OpenEJBTCKRuntimeException) IOException(java.io.IOException) DeploymentException(org.jboss.testharness.api.DeploymentException)

Aggregations

IOException (java.io.IOException)5 OpenEJBTCKRuntimeException (org.apache.openejb.tck.OpenEJBTCKRuntimeException)5 DeploymentException (org.jboss.testharness.api.DeploymentException)4 File (java.io.File)2 Properties (java.util.Properties)2 InitialContext (javax.naming.InitialContext)2 RemoteInitialContextFactory (org.apache.openejb.client.RemoteInitialContextFactory)2 ValidationException (org.apache.openejb.config.ValidationException)2 Options (org.apache.openejb.loader.Options)2 FileOutputStream (java.io.FileOutputStream)1 Deployer (org.apache.openejb.assembler.Deployer)1 RemoteServer (org.apache.openejb.config.RemoteServer)1 ExceptionManagerFacade (org.apache.tomee.catalina.facade.ExceptionManagerFacade)1