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);
}
}
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);
}
}
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;
}
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);
}
}
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);
}
}
Aggregations