Skip to content

Commit

Permalink
Use profileservice to deploy tests
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1541 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Feb 16, 2009
1 parent 871d648 commit 1f62233
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 1 deletion.
@@ -0,0 +1,106 @@
package org.jboss.webbeans.tck.integration.jbossas;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.naming.InitialContext;

import org.apache.log4j.Logger;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
import org.jboss.jsr299.tck.api.DeploymentException;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileService;
import org.jboss.test.JBossTestServices;
import org.jboss.virtual.VFS;

public class ProfileServiceContainersImpl extends AbstractContainersImpl
{

private Logger log = Logger.getLogger(ProfileServiceContainersImpl.class);

private DeploymentManager deploymentManager;
private JBossTestServices testServices;
private final File tmpdir;


public ProfileServiceContainersImpl() throws Exception
{
this.testServices = new JBossTestServices(JBossTestServicesContainersImpl.class);
this.testServices.setUpLogging();
this.testServices.init();
tmpdir = new File(System.getProperty("java.io.tmpdir"), "org.jboss.webbeans.tck.integration.jbossas");
tmpdir.mkdir();
tmpdir.deleteOnExit();
}


@Override
public void setup() throws IOException
{
super.setup();

}

public void deploy(InputStream archiveStream, String name) throws DeploymentException, IOException
{
Exception failure = null;
try
{
File archive = new File(tmpdir, name);
archive.deleteOnExit();
copy(archiveStream, archive);
DeploymentProgress distribute = deploymentManager.distribute(name, DeploymentPhase.APPLICATION, archive.toURI().toURL(), true);
distribute.run();
DeploymentProgress progress = deploymentManager.start(DeploymentPhase.APPLICATION, name);
progress.run();
DeploymentStatus status = progress.getDeploymentStatus();
if (status.isFailed())
{
failure = status.getFailure();
undeploy(name);
}
}
catch (Exception e)
{
throw new IOException(e);
}
if (failure != null)
{
throw new DeploymentException(failure);
}
}

public void undeploy(String name) throws DeploymentException, IOException
{
try
{
deploymentManager.stop(DeploymentPhase.APPLICATION, name).run();
deploymentManager.undeploy(DeploymentPhase.APPLICATION, name).run();
}
catch (Exception e)
{
throw new IOException(e);
}
}

/**
* Obtain the Deployment Manager
* @throws Exception
*/
protected void initDeploymentManager() throws Exception
{
String profileName = "default";
InitialContext ctx = testServices.getInitialContext();
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
deploymentManager = ps.getDeploymentManager();
ProfileKey defaultKey = new ProfileKey(profileName);
deploymentManager.loadProfile(defaultKey, false);
// Init the VFS to setup the vfs* protocol handlers
VFS.init();
}

}
@@ -1,4 +1,4 @@
org.jboss.jsr299.tck.spi.Containers=org.jboss.webbeans.tck.integration.jbossas.JBossTestServicesContainersImpl
org.jboss.jsr299.tck.spi.Containers=org.jboss.webbeans.tck.integration.jbossas.ProfileServiceContainersImpl
org.jboss.jsr299.tck.api.TestLauncher=org.jboss.jsr299.tck.impl.runner.servlet.ServletTestLauncher
org.jboss.jsr299.tck.connectDelay=1500
org.jboss.jsr299.tck.connectRetries=8

0 comments on commit 1f62233

Please sign in to comment.