Author: mwringe
Date: 2010-06-17 11:55:10 -0400 (Thu, 17 Jun 2010)
New Revision: 3367
Modified:
components/wsrp/trunk/wsrp-producer-war/pom.xml
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java
Log:
GTNWSRP-46: Make the test run much faster, update cargo log config so we don't create
crazy logs during the tests.
Modified: components/wsrp/trunk/wsrp-producer-war/pom.xml
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/pom.xml 2010-06-17 15:31:45 UTC (rev 3366)
+++ components/wsrp/trunk/wsrp-producer-war/pom.xml 2010-06-17 15:55:10 UTC (rev 3367)
@@ -304,6 +304,8 @@
properties to enable this behaviour. -->
<jboss.deploy.dir>${jboss.server.home.dir}/conf</jboss.deploy.dir>
<test.deployables.dir>${basedir}/target/test-archives</test.deployables.dir>
+
<jboss.deploy.url.prefix>http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=</jboss.deploy.url.prefix>
+
<jboss.undeploy.url.prefix>http://localhost:8080//jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=undeploy&argType=java.net.URL&arg0=</jboss.undeploy.url.prefix>
</systemProperties>
</container>
<wait>false</wait>
@@ -327,6 +329,12 @@
<type>sar</type>
</deployable>
</deployables>
+ <configfiles>
+ <configfile>
+
<file>${basedir}/target/servers/jboss-5.1.0.GA-jdk6/jboss-5.1.0.GA/server/default/conf/jboss-log4j.xml</file>
+ <tofile>/conf/jboss-log4j.xml</tofile>
+ </configfile>
+ </configfiles>
</configuration>
</configuration>
<executions>
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java 2010-06-17
15:31:45 UTC (rev 3366)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java 2010-06-17
15:55:10 UTC (rev 3367)
@@ -23,11 +23,18 @@
package org.gatein.wsrp.producer;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
import java.nio.channels.FileChannel;
+import javax.net.ssl.HttpsURLConnection;
+
import junit.framework.TestCase;
import org.gatein.common.NotYetImplemented;
@@ -38,7 +45,7 @@
public abstract class WSRPProducerBaseTest extends TestCase
{
protected WSRPProducerImpl producer = WSRPProducerImpl.getInstance();
-
+
protected WSRPProducerBaseTest(String name) throws Exception
{
super(name);
@@ -46,44 +53,55 @@
public void deploy(String warFileName) throws Exception
{
- File archiveDirectory = getDirectory("test.deployables.dir");
- File deployDirectory = getDirectory("jboss.server.home.dir",
"deploy");
- File archiveFile = getArchive(warFileName, archiveDirectory, true);
- File deployArchive = getArchive(warFileName, deployDirectory, false);
-
- FileChannel inputChannel = new FileInputStream(archiveFile).getChannel();
- FileChannel outputChannel = new FileOutputStream(deployArchive).getChannel();
-
- inputChannel.transferTo(0, inputChannel.size(), outputChannel);
-
- Thread.currentThread().sleep(10000);
+ String deployURLPrefix = System.getProperty("jboss.deploy.url.prefix");
+ if (deployURLPrefix != null)
+ {
+ File archiveDirectory = getDirectory("test.deployables.dir");
+ File archiveFile = getArchive(warFileName, archiveDirectory);
+
+ String deployURLString = deployURLPrefix + archiveFile.getAbsolutePath();
+
+ URL deployURL = new URL(deployURLString);
+ URLConnection connection = deployURL.openConnection();
+
+ BufferedReader reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
+ reader.readLine();
+ reader.close();
+ }
+ else
+ {
+ throw new Exception ("Could not find the jboss.deploy.url.prefix system
property.");
+ }
}
public void undeploy(String warFileName) throws Exception
{
- File deployDirectory = getDirectory("jboss.server.home.dir",
"deploy");
- File archive = getArchive(warFileName, deployDirectory, true);
-
- archive.delete();
-
- Thread.currentThread().sleep(10000);
+ String undeployURLPrefix =
System.getProperty("jboss.undeploy.url.prefix");
+ if (undeployURLPrefix != null)
+ {
+ File archiveDirectory = getDirectory("test.deployables.dir");
+ File archiveFile = getArchive(warFileName, archiveDirectory);
+
+ String undeployURLString = undeployURLPrefix + archiveFile.getAbsolutePath();
+
+ URL undeployURL = new URL(undeployURLString);
+ URLConnection connection = undeployURL.openConnection();
+
+ BufferedReader reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
+ reader.readLine();
+ reader.close();
+ }
+ else
+ {
+ throw new Exception ("Could not find the jboss.deploy.url.prefix system
property.");
+ }
}
-
+
private File getDirectory (String property) throws Exception
{
- return getDirectory(property, null);
- }
-
- private File getDirectory (String property, String subDirectory) throws Exception
- {
String deployableProperty = System.getProperty(property);
if (deployableProperty != null)
{
- if (subDirectory != null)
- {
- deployableProperty += File.separator + subDirectory;
- }
-
File deployableDir = new File(deployableProperty);
if (deployableDir.exists() && deployableDir.isDirectory())
{
@@ -101,26 +119,19 @@
}
- private File getArchive(String fileName, File deployDirectory, boolean shouldExist)
throws Exception
+ private File getArchive(String fileName, File deployDirectory) throws Exception
{
if (fileName != null && deployDirectory != null &&
deployDirectory.exists() && deployDirectory.isDirectory())
{
File archiveFile = new File(deployDirectory.getAbsoluteFile() + File.separator
+ fileName);
- return archiveFile;
-// if (archiveFile.exists() && shouldExist)
-// {
-// return archiveFile;
-// }
-// else if (!archiveFile.exists() && !shouldExist)
-// {
-// return archiveFile;
-// }
-// else
-// {
-// //since its not what we are expecting we need to throw the opposite error
message
-// String existsString = shouldExist ? "does not exist" :
"exists";
-// throw new Exception("Archive " + fileName + " in directory
" + deployDirectory + " " + existsString + " which is not
expected.");
-// }
+ if (archiveFile.exists())
+ {
+ return archiveFile;
+ }
+ else
+ {
+ throw new Exception ("Archive " + fileName + " in directory
" + deployDirectory + " does not exist. Cannot deploy this file");
+ }
}
else
{