Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lots of improvements for in-container tests
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1467 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
5 changed files
with
157 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jboss/ContainersImpl.java
This file was deleted.
Oops, something went wrong.
122 changes: 122 additions & 0 deletions
122
...s-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ContainersImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
jboss-tck-runner/src/main/resources/META-INF/web-beans-tck.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters