Skip to content

Commit

Permalink
Lots of improvements for in-container tests
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1467 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Feb 9, 2009
1 parent 7631ec6 commit 1c8b904
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 58 deletions.
34 changes: 31 additions & 3 deletions jboss-tck-runner/pom.xml
Expand Up @@ -20,7 +20,6 @@
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-ri</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -50,14 +49,38 @@

<profiles>
<profile>
<id>integration-tests</id>
<id>incontainer</id>
<activation>
<property>
<name>integration</name>
<name>incontainer</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>generate-test-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-porting-package</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
Expand All @@ -69,6 +92,11 @@
<tasks>
<java classname="org.jboss.jsr299.tck.api.TCK" classpathref="maven.test.classpath" failonerror="true" fork="true">
<jvmarg line="-DrunSuite=true"/>
<jvmarg line="-Dorg.jboss.jsr299.tck.standalone=false"/>
<jvmarg line="-DjbossHome=/Applications/jboss-5.0.0.GA"/>
<jvmarg line="-Dorg.jboss.jsr299.tck.deploymentDelay=8000"/>
<jvmarg line="-DdumpConfiguration=true" />
<jvmarg line="-Dorg.jboss.jsr299.tck.libraryDirectory=${project.build.directory}/dependency/lib"/>
</java>
</tasks>
</configuration>
Expand Down

This file was deleted.

@@ -0,0 +1,122 @@
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;

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


public class ContainersImpl implements Containers, Configurable
{

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

public static final String JBOSS_HOME_PROPERTY_NAME = "jbossHome";

private File deployDir;
private Configuration configuration;

private boolean validated;

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
{
URLConnection connection = new URL(url).openConnection();
if (!(connection instanceof HttpURLConnection))
{
throw new IllegalStateException("Not an http connection! " + connection);
}
HttpURLConnection httpConnection = (HttpURLConnection) connection;
httpConnection.connect();
if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_OK)
{
throw new IllegalStateException("Error connecting to JBoss AS at " + url);
}
}
catch (Exception e)
{
throw new IllegalStateException("Cannot connect to JBoss AS", e);
}
log.info("Successfully connected to JBoss AS at " + url);

}

public ContainersImpl() throws MalformedURLException, IOException
{

}



public void deploy(InputStream archive, String name) throws Exception
{
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 Exception
{
File file = new File(deployDir, name);
if (file.exists())
{
//file.delete();
}
Thread.sleep(1000);
}

}
@@ -1 +1,2 @@
org.jboss.jsr299.tck.spi.Containers=org.jboss.webbeans.tck.integration.ContainersImpl
org.jboss.jsr299.tck.spi.Containers=org.jboss.webbeans.tck.integration.jbossas.ContainersImpl
org.jboss.jsr299.tck.api.TestLauncher=org.jboss.jsr299.tck.impl.runner.servlet.ServletTestLauncher
4 changes: 2 additions & 2 deletions jboss-tck-runner/src/test/resources/log4j.xml
Expand Up @@ -12,7 +12,7 @@

<!-- ############### Embedded EJB3 ################# -->
<category name="org.jboss">
<priority value="INFO"/>
<priority value="ERROR"/>
</category>
<category name="com.arjuna">
<priority value="ERROR"/>
Expand Down Expand Up @@ -44,7 +44,7 @@
<!-- ############### Web Beans logging ################### -->

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

<root>
Expand Down

0 comments on commit 1c8b904

Please sign in to comment.