Skip to content

Commit

Permalink
Switch to JMX based deployer
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1501 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Feb 12, 2009
1 parent 8852af6 commit 4564554
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 82 deletions.
13 changes: 13 additions & 0 deletions jboss-tck-runner/pom.xml
Expand Up @@ -27,6 +27,11 @@
<artifactId>webbeans-porting-package</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.test</groupId>
<artifactId>jboss-test</artifactId>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand All @@ -40,6 +45,14 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<scope>test</scope>
<type>pom</type>
</dependency>


</dependencies>

<build>
Expand Down
@@ -1,11 +1,11 @@
package org.jboss.webbeans.tck.integration.jbossas;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

Expand All @@ -14,40 +14,39 @@
import org.jboss.jsr299.tck.api.Configuration;
import org.jboss.jsr299.tck.spi.Containers;


public class ContainersImpl implements Containers, Configurable
public abstract class AbstractContainersImpl implements Configurable, Containers
{

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

public static final String JBOSS_HOME_PROPERTY_NAME = "jbossHome";
private static Logger log = Logger.getLogger(AbstractContainersImpl.class);

private File deployDir;
private Configuration configuration;

private boolean validated;

protected boolean validated;

protected static void copy(InputStream inputStream, File file) throws IOException
{
OutputStream os = new FileOutputStream(file);
try
{
byte[] buf = new byte[1024];
int i = 0;
while ((i = inputStream.read(buf)) != -1)
{
os.write(buf, 0, i);
}
}
finally
{
os.close();
}
}

public void setConfiguration(Configuration configuration)
{
this.configuration = configuration;


}

protected void validate()
{
String jbossHome = System.getProperty(JBOSS_HOME_PROPERTY_NAME);
if (jbossHome == null)
{
throw new IllegalArgumentException("-DjbossHome must be set");
}
deployDir = new File(jbossHome, "server/default/deploy");
if (!deployDir.isDirectory())
{
throw new IllegalArgumentException(deployDir.getPath() + " is not a directory");
}
log.info("Deploying TCK artifacts to " + deployDir.getPath());

// Check that JBoss is up!
String url = "http://" + configuration.getHost() + "/";
try
Expand All @@ -71,60 +70,10 @@ protected void validate()
log.info("Successfully connected to JBoss AS at " + url);

}

public ContainersImpl() throws MalformedURLException, IOException
{

}



public void deploy(InputStream archive, String name) throws IOException
{
if (!validated)
{
validate();
}
File file = new File(deployDir, name);
log.info("Deploying test " + name);
file.createNewFile();
copy(archive, file);
}

private static void copy(InputStream inputStream, File file) throws IOException
{
OutputStream os = new FileOutputStream(file);
try
{
byte[] buf = new byte[1024];
int i = 0;
while ((i = inputStream.read(buf)) != -1)
{
os.write(buf, 0, i);
}
}
finally
{
os.close();
}
}

public void undeploy(String name) throws IOException

public AbstractContainersImpl()
{
File file = new File(deployDir, name);
if (file.exists())
{
file.delete();
}
try
{
// Give the app a chance to undeploy
Thread.sleep(1000);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
super();
}

}
}
@@ -0,0 +1,65 @@
package org.jboss.webbeans.tck.integration.jbossas;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import org.apache.log4j.Logger;
import org.jboss.jsr299.tck.api.Configurable;
import org.jboss.jsr299.tck.spi.Containers;


public class FileSystemContainersImpl extends AbstractContainersImpl
{

private static Logger log = Logger.getLogger(FileSystemContainersImpl.class);

public static final String JBOSS_HOME_PROPERTY_NAME = "jbossHome";

private File deployDir;

public FileSystemContainersImpl() throws IOException
{
String jbossHome = System.getProperty(JBOSS_HOME_PROPERTY_NAME);
if (jbossHome == null)
{
throw new IllegalArgumentException("-DjbossHome must be set");
}
deployDir = new File(jbossHome, "server/default/deploy");
if (!deployDir.isDirectory())
{
throw new IllegalArgumentException(deployDir.getPath() + " is not a directory");
}
log.info("Deploying TCK artifacts to " + deployDir.getPath());
}

public void deploy(InputStream archive, String name) throws IOException
{
if (!validated)
{
validate();
}
File file = new File(deployDir, name);
log.info("Deploying test " + name);
file.createNewFile();
copy(archive, file);
}

public void undeploy(String name) throws IOException
{
File file = new File(deployDir, name);
if (file.exists())
{
file.delete();
}
try
{
// Give the app a chance to undeploy
Thread.sleep(1000);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}

}
@@ -0,0 +1,59 @@
package org.jboss.webbeans.tck.integration.jbossas;
import java.io.File;
import java.io.InputStream;

import org.apache.log4j.Logger;
import org.jboss.test.JBossTestServices;


public class JBossTestServicesContainersImpl extends AbstractContainersImpl
{

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

private final JBossTestServices testServices;
private final File tmpdir;

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

public void deploy(InputStream archiveStream, String name) throws Exception
{
if (!validated)
{
validate();
}
File archive = new File(tmpdir, name);
archive.deleteOnExit();
copy(archiveStream, archive);
testServices.deploy(getTmpArchiveName(name));
}

public void undeploy(String name) throws Exception
{
testServices.undeploy(getTmpArchiveName(name));
try
{
// Give the app a chance to undeploy
Thread.sleep(1000);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}

private String getTmpArchiveName(String name)
{
File file = new File(tmpdir, name);
return file.toURI().toString();
}

}
@@ -1,4 +1,4 @@
org.jboss.jsr299.tck.spi.Containers=org.jboss.webbeans.tck.integration.jbossas.ContainersImpl
org.jboss.jsr299.tck.spi.Containers=org.jboss.webbeans.tck.integration.jbossas.JBossTestServicesContainersImpl
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
4 changes: 4 additions & 0 deletions jboss-tck-runner/src/test/resources/jndi.properties
@@ -0,0 +1,4 @@
#jboss JNDI properties
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
9 changes: 7 additions & 2 deletions jboss-tck-runner/src/test/resources/log4j.xml
Expand Up @@ -14,6 +14,11 @@
<category name="org.jboss">
<priority value="ERROR"/>
</category>

<category name="org.jboss.test">
<priority value="ERROR"/>
</category>

<category name="com.arjuna">
<priority value="ERROR"/>
</category>
Expand Down Expand Up @@ -44,11 +49,11 @@
<!-- ############### Web Beans logging ################### -->

<category name="org.jboss.webbeans">
<priority value="ERROR"/>
<priority value="WARN"/>
</category>

<category name="org.jboss.jsr299">
<priority value="INFO"/>
<priority value="WARN"/>
</category>

<root>
Expand Down

0 comments on commit 4564554

Please sign in to comment.