Author: pete.muir(a)jboss.org
Date: 2009-03-13 13:59:25 -0400 (Fri, 13 Mar 2009)
New Revision: 1981
Added:
ri/trunk/impl/src/test/debug-resources/
ri/trunk/impl/src/test/debug-resources/META-INF/
ri/trunk/impl/src/test/debug-resources/META-INF/web-beans-tck.properties
ri/trunk/impl/src/test/resources/jndi.properties
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/HarnessServletListener.java
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java
Removed:
ri/trunk/impl/src/test/resources/log4j.xml
ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/AbstractContainersImpl.java
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java
Modified:
ri/trunk/impl/pom.xml
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java
ri/trunk/impl/src/test/resources/META-INF/web-beans-tck.properties
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/client/web.xml
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/TestRunner.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/ServletTestRunner.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java
test-harness/trunk/impl/src/main/resources/org/jboss/testharness/impl/packaging/war/web.xml
test-harness/trunk/jboss/src/main/resources/log4j.xml
Log:
Improvements to harness,
Modified: ri/trunk/impl/pom.xml
===================================================================
--- ri/trunk/impl/pom.xml 2009-03-13 17:32:51 UTC (rev 1980)
+++ ri/trunk/impl/pom.xml 2009-03-13 17:59:25 UTC (rev 1981)
@@ -117,6 +117,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-jboss-as-5</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
@@ -150,4 +156,129 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>incontainer</id>
+ <activation>
+ <property>
+ <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.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <overWrite>true</overWrite>
+
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.el</groupId>
+ <artifactId>el-ri</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-surefire-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <suiteXmlFile>unit-tests.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ <systemProperties>
+ <property>
+ <name>org.jboss.testharness.standalone</name>
+ <value>false</value>
+ </property>
+ <property>
+ <name>jboss-as.dir</name>
+ <value>../jboss-as</value>
+ </property>
+ <property>
+ <name>jboss.force.restart</name>
+ <value>true</value>
+ </property>
+ <property>
+
<name>org.jboss.testharness.runIntegrationTests</name>
+ <value>true</value>
+ </property>
+ <property>
+
<name>org.jboss.testharness.libraryDirectory</name>
+ <value>target/dependency/lib</value>
+ </property>
+ <property>
+
<name>org.jboss.testharness.outputDirectory</name>
+ <value>target</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>write-artifacts-to-disk</id>
+ <activation>
+ <property>
+ <name>dumpArtifacts</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-test-artifacts</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.jboss.testharness.api.TCK</mainClass>
+ <classpathScope>test</classpathScope>
+ <systemProperties>
+ <systemProperty>
+ <key>dumpArtifacts</key>
+ <value>true</value>
+ </systemProperty>
+ <systemProperty>
+ <key>org.jboss.testharness.outputDirectory</key>
+ <value>target/test-artifacts</value>
+ </systemProperty>
+ <systemProperty>
+ <key>org.jboss.testharness.libraryDirectory</key>
+ <value>target/dependency/lib</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
</project>
Added: ri/trunk/impl/src/test/debug-resources/META-INF/web-beans-tck.properties
===================================================================
--- ri/trunk/impl/src/test/debug-resources/META-INF/web-beans-tck.properties
(rev 0)
+++ ri/trunk/impl/src/test/debug-resources/META-INF/web-beans-tck.properties 2009-03-13
17:59:25 UTC (rev 1981)
@@ -0,0 +1,7 @@
+# Configuration for running incontainer tests from your IDE
+# Alter the path webbeans accordingly (relative from the tck/impl dir)
+org.jboss.testharness.standalone=false
+jboss-as.dir=../../webbeans/jboss-as
+jboss.force.restart=false
+org.jboss.testharness.libraryDirectory=../../webbeans/impl/target/dependency/lib
+org.jboss.testharness.runIntegrationTests=true
\ No newline at end of file
Property changes on:
ri/trunk/impl/src/test/debug-resources/META-INF/web-beans-tck.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java
===================================================================
---
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -17,6 +17,7 @@
import org.testng.ITestContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
public abstract class AbstractWebBeansTest extends AbstractTest
{
@@ -58,9 +59,15 @@
public static boolean visited = false;
@Override
+ @BeforeSuite
public void beforeSuite(ITestContext context) throws Exception
{
- getCurrentConfiguration().setStandaloneContainers(new StandaloneContainersImpl());
+ if (!isInContainer())
+ {
+ getCurrentConfiguration().setStandaloneContainers(new
StandaloneContainersImpl());
+
getCurrentConfiguration().getExtraPackages().add(AbstractWebBeansTest.class.getPackage().getName());
+ }
+ super.beforeSuite(context);
}
@BeforeMethod
Modified: ri/trunk/impl/src/test/resources/META-INF/web-beans-tck.properties
===================================================================
--- ri/trunk/impl/src/test/resources/META-INF/web-beans-tck.properties 2009-03-13 17:32:51
UTC (rev 1980)
+++ ri/trunk/impl/src/test/resources/META-INF/web-beans-tck.properties 2009-03-13 17:59:25
UTC (rev 1981)
@@ -1 +1,3 @@
-org.jboss.testharness.spi.StandaloneContainers=org.jboss.webbeans.test.unit.StandaloneContainersImpl
\ No newline at end of file
+org.jboss.testharness.spi.StandaloneContainers=org.jboss.webbeans.test.unit.StandaloneContainersImpl
+org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
+org.jboss.testharness.testPackage=org.jboss.webbeans.test
\ No newline at end of file
Added: ri/trunk/impl/src/test/resources/jndi.properties
===================================================================
--- ri/trunk/impl/src/test/resources/jndi.properties (rev 0)
+++ ri/trunk/impl/src/test/resources/jndi.properties 2009-03-13 17:59:25 UTC (rev 1981)
@@ -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
\ No newline at end of file
Property changes on: ri/trunk/impl/src/test/resources/jndi.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/test/resources/log4j.xml
===================================================================
--- ri/trunk/impl/src/test/resources/log4j.xml 2009-03-13 17:32:51 UTC (rev 1980)
+++ ri/trunk/impl/src/test/resources/log4j.xml 2009-03-13 17:59:25 UTC (rev 1981)
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE
log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
-
- <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%-5p [%c{6}]
%m%n"/>
- </layout>
- </appender>
-
- <!-- ############### Embedded EJB3 ################# -->
- <category name="org.jboss">
- <priority value="ERROR"/>
- </category>
- <category name="com.arjuna">
- <priority value="ERROR"/>
- </category>
-
- <!-- ############### Hibernate logging ################# -->
-
- <category name="org.hibernate">
- <priority value="ERROR"/>
- </category>
-
- <!--
- <category name="org.hibernate.SQL">
- <priority value="TRACE"/>
- </category>
-
- <category name="org.hibernate.type">
- <priority value="TRACE"/>
- </category>
-
- <category name="org.hibernate.loader">
- <priority value="TRACE"/>
- </category>
- <category name="org.hibernate.cache">
- <priority value="TRACE"/>
- </category>
- -->
-
- <!-- ############### Web Beans logging ################### -->
-
- <category name="org.jboss.webbeans">
- <priority value="WARN"/>
- </category>
-
- <root>
- <priority value="INFO"/>
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</log4j:configuration>
Deleted: ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml
===================================================================
--- ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml 2009-03-13 17:32:51 UTC (rev
1980)
+++ ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml 2009-03-13 17:59:25 UTC (rev
1981)
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE
log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
-
- <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p
[%c{6}] %m%n"/>
- </layout>
- <filter class="org.apache.log4j.varia.StringMatchFilter">
- <param name="AcceptOnMatch" value="false" />
- <param name="StringToMatch" value="Failure while notifying an
observer of event [a]" />
- </filter>
- </appender>
-
- <!-- ############### Embedded EJB3 ################# -->
- <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>
-
- <!-- ############### Hibernate logging ################# -->
-
- <category name="org.hibernate">
- <priority value="ERROR"/>
- </category>
-
- <!--
- <category name="org.hibernate.SQL">
- <priority value="TRACE"/>
- </category>
-
- <category name="org.hibernate.type">
- <priority value="TRACE"/>
- </category>
-
- <category name="org.hibernate.loader">
- <priority value="TRACE"/>
- </category>
- <category name="org.hibernate.cache">
- <priority value="TRACE"/>
- </category>
- -->
-
- <!-- ############### Web Beans logging ################### -->
-
- <category name="org.jboss.webbeans">
- <priority value="WARN"/>
- </category>
-
- <category name="org.jboss.webbeans.tck">
- <priority value="INFO"/>
- </category>
-
- <category name="org.jboss.jsr299">
- <priority value="INFO"/>
- </category>
-
- <root>
- <priority value="INFO"/>
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</log4j:configuration>
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -23,6 +23,15 @@
public void beforePhase(PhaseEvent event)
{
+ try
+ {
+ JSR299ConfigurationImpl.get();
+ }
+ catch (NoClassDefFoundError e)
+ {
+ e.printStackTrace();
+ e.getCause().printStackTrace();
+ }
if (event.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES))
{
try
Modified:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/client/web.xml
===================================================================
---
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/client/web.xml 2009-03-13
17:32:51 UTC (rev 1980)
+++
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/client/web.xml 2009-03-13
17:59:25 UTC (rev 1981)
@@ -34,6 +34,10 @@
<servlet-name>Conversation Status Servlet</servlet-name>
<url-pattern>/conversation-status</url-pattern>
</servlet-mapping>
+
+ <listener>
+
<listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
<session-config>
<session-timeout>10</session-timeout>
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -14,6 +14,7 @@
import static org.jboss.testharness.api.Configuration.STANDALONE_PROPERTY_NAME;
import static org.jboss.testharness.api.Configuration.TEST_PACKAGE_PROPERTY_NAME;
+import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.api.Configurable;
import org.jboss.testharness.api.Configuration;
import org.jboss.testharness.api.ConfigurationBuilder;
@@ -47,10 +48,12 @@
*/
public ConfigurationBuilder init()
{
-
configuration.setInContainerTestLauncher(getInstanceValue(TestLauncher.PROPERTY_NAME,
TestLauncher.class, configuration.isRunIntegrationTests() ||
!configuration.isStandalone()));
- configuration.setContainers(getInstanceValue(Containers.PROPERTY_NAME,
Containers.class, !configuration.isStandalone() ||
configuration.isRunIntegrationTests()));
-
configuration.setStandaloneContainers(getInstanceValue(StandaloneContainers.PROPERTY_NAME,
StandaloneContainers.class, configuration.isStandalone()));
-
+ if (!AbstractTest.isInContainer())
+ {
+
configuration.setInContainerTestLauncher(getInstanceValue(TestLauncher.PROPERTY_NAME,
TestLauncher.class, configuration.isRunIntegrationTests() ||
!configuration.isStandalone()));
+ configuration.setContainers(getInstanceValue(Containers.PROPERTY_NAME,
Containers.class, !configuration.isStandalone() ||
configuration.isRunIntegrationTests()));
+
configuration.setStandaloneContainers(getInstanceValue(StandaloneContainers.PROPERTY_NAME,
StandaloneContainers.class, configuration.isStandalone()));
+ }
return this;
}
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -239,6 +239,10 @@
public void dumpArtifacts(String basePackageName)
{
+ if (basePackageName == null)
+ {
+ throw new IllegalArgumentException("Cannot dump artifacts as no package to
dump from set. Specify org.jboss.testharness.testPackage");
+ }
List<ArtifactDescriptor> artifacts = createArtifacts(basePackageName);
File file = new File(configuration.getOutputDirectory());
if (!file.exists())
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -8,6 +8,7 @@
import java.io.Writer;
import org.apache.log4j.Logger;
+import org.jboss.testharness.api.Configuration;
import org.jboss.testharness.impl.ConfigurationImpl;
import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
import org.jboss.testharness.impl.packaging.ResourceDescriptorImpl;
@@ -71,6 +72,8 @@
{
Writer writer = new PrintWriter(os);
writer.write("className=" + declaringClass.getName() +
"\n");
+ writer.write(Configuration.STANDALONE_PROPERTY_NAME + "=false\n");
+
for (String line : ConfigurationImpl.get().getExtraDeploymentProperties())
{
writer.write(line + "\n");
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/TestRunner.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/TestRunner.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/TestRunner.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -5,7 +5,6 @@
import java.util.List;
import java.util.Set;
-import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.testng.RemoveExpectedExceptionsAnnotationTransformer;
import org.jboss.testharness.impl.util.DeploymentProperties;
import org.testng.ITestContext;
@@ -43,7 +42,6 @@
public void run(boolean ignoreExpectedExceptions)
{
- AbstractTest.setInContainer(true);
if (classNames.size() == 0)
{
DeploymentProperties deploymentProperties = new DeploymentProperties();
Added:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/HarnessServletListener.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/HarnessServletListener.java
(rev 0)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/HarnessServletListener.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -0,0 +1,22 @@
+package org.jboss.testharness.impl.runner.servlet;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.jboss.testharness.AbstractTest;
+
+public class HarnessServletListener implements ServletContextListener
+{
+
+ public void contextDestroyed(ServletContextEvent sce)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void contextInitialized(ServletContextEvent sce)
+ {
+ AbstractTest.setInContainer(true);
+ }
+
+}
Property changes on:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/HarnessServletListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/ServletTestRunner.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/ServletTestRunner.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/servlet/ServletTestRunner.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -10,7 +10,6 @@
import javax.servlet.http.HttpServletResponse;
import org.jboss.testharness.api.TestResult;
-import org.jboss.testharness.impl.ConfigurationImpl;
import org.jboss.testharness.impl.runner.TestResultImpl;
import org.jboss.testharness.impl.runner.TestRunner;
import org.testng.ITestResult;
@@ -23,7 +22,6 @@
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
- ConfigurationImpl.get().setStandalone(false);
TestRunner runner = new TestRunner();
String methodName = null;
if (req.getParameter("methodName") != null)
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java
===================================================================
---
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -166,7 +166,7 @@
}
else if (classes.size() > 1)
{
- throw new IllegalArgumentException("More than one implementation of "
+ expectedType.getSimpleName() + " specified by " + propertyName + ", not
sure which one to use!");
+ throw new IllegalArgumentException("More than one implementation of "
+ expectedType.getSimpleName() + " specified by " + propertyName + ", not
sure which one to use!" + classes);
}
return classes.iterator().next();
}
@@ -218,7 +218,7 @@
{
if (required)
{
- throw new IllegalArgumentException("Cannot find required property "
+ propertyName + ", check that it is specified");
+ throw new IllegalArgumentException("Cannot find required property "
+ propertyName + ", check that it is specified ");
}
else
{
@@ -227,7 +227,7 @@
}
else if (values.size() > 1)
{
- throw new IllegalArgumentException("More than one value given for " +
propertyName + ", not sure which one to use!");
+ throw new IllegalArgumentException("More than one value given for " +
propertyName + ", not sure which one to use! " + values);
}
else
{
Modified:
test-harness/trunk/impl/src/main/resources/org/jboss/testharness/impl/packaging/war/web.xml
===================================================================
---
test-harness/trunk/impl/src/main/resources/org/jboss/testharness/impl/packaging/war/web.xml 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/impl/src/main/resources/org/jboss/testharness/impl/packaging/war/web.xml 2009-03-13
17:59:25 UTC (rev 1981)
@@ -7,6 +7,10 @@
<display-name>JBoss Test Harness</display-name>
+ <listener>
+
<listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
+
<servlet>
<servlet-name>JBoss Test Harness Test Runner</servlet-name>
<servlet-class>org.jboss.testharness.impl.runner.servlet.ServletTestRunner</servlet-class>
Deleted:
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/AbstractContainersImpl.java
===================================================================
---
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/AbstractContainersImpl.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/AbstractContainersImpl.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -1,288 +0,0 @@
-package org.jboss.testharness.integration.jbossas;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.apache.log4j.Logger;
-import org.jboss.testharness.api.Configurable;
-import org.jboss.testharness.api.Configuration;
-import org.jboss.testharness.integration.jbossas.util.DeploymentProperties;
-import org.jboss.testharness.spi.Containers;
-
-/**
- *
- * @author jeffgenender
- * @author Pete Muir
- *
- */
-public abstract class AbstractContainersImpl implements Configurable, Containers
-{
-
- public static String JAVA_OPTS = " -ea";
-
- public static final String JBOSS_HOME_PROPERTY_NAME = "jboss.home";
- public static final String JAVA_OPTS_PROPERTY_NAME = "java.opts";
- public static final String JBOSS_AS_DIR_PROPERTY_NAME = "jboss-as.dir";
- public static final String JBOSS_BOOT_TIMEOUT_PROPERTY_NAME =
"jboss.boot.timeout";
- public static final String FORCE_RESTART_PROPERTY_NAME =
"jboss.force.restart";
- public static final String MAX_DEPLOYMENTS_PROPERTY_NAME =
"jboss.deployments.restart";
- public static final String SHUTDOWN_DELAY_PROPERTY_NAME =
"jboss.shutdown.delay";
- public static final String JBOSS_BIND_ADDRESS_PROPERTY_NAME =
"jboss.bind.address";
-
- private static Logger log = Logger.getLogger(AbstractContainersImpl.class);
-
- private final DeploymentProperties properties;
-
- private Configuration configuration;
- protected String jbossHome;
- private String jbossHttpUrl;
- private boolean jbossWasStarted;
- private long bootTimeout;
- private String javaOpts;
-
- private boolean forceRestart;
-
- protected int maxDeployments;
-
- private int jbossShutdownDelay;
-
- private String jbossBindAddress;
-
- public AbstractContainersImpl()
- {
- this.properties = new DeploymentProperties();
- }
-
- 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 boolean isJBossUp()
- {
- // Check that JBoss is up!
- try
- {
- URLConnection connection = new URL(jbossHttpUrl).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)
- {
- return false;
- }
- }
- catch (Exception e)
- {
- return false;
- }
- log.info("Successfully connected to JBoss AS at " + jbossHttpUrl);
- return true;
- }
-
- public void setup() throws IOException
- {
- String jbossAsPath = properties.getStringValue(JBOSS_AS_DIR_PROPERTY_NAME,
"../jboss-as", false);
- if (jbossAsPath != null)
- {
- File jbossAsDir = new File(jbossAsPath);
- if (jbossAsDir.isDirectory())
- {
- File buildProperties = new File(jbossAsDir, "build.properties");
- if (buildProperties.exists())
- {
- loadProperties(buildProperties);
- }
- File localBuildProperties = new File(jbossAsDir,
"local.build.properties");
- if (localBuildProperties.exists())
- {
- loadProperties(localBuildProperties);
- }
- }
- }
- jbossHome = properties.getStringValue(JBOSS_HOME_PROPERTY_NAME, null, true);
- jbossBindAddress = properties.getStringValue(JBOSS_BIND_ADDRESS_PROPERTY_NAME,
"localhost", false);
- configuration.setHost(jbossBindAddress + ":8080");
- this.jbossHttpUrl = "http://" + configuration.getHost() + "/";
- javaOpts = properties.getStringValue(JAVA_OPTS_PROPERTY_NAME, "",
false);
- javaOpts = javaOpts + JAVA_OPTS;
- File jbossHomeFile = new File(jbossHome);
- jbossHome = jbossHomeFile.getPath();
- log.info("Using JBoss instance in " + jbossHome + " at URL " +
jbossHttpUrl);
- this.bootTimeout = properties.getLongValue(JBOSS_BOOT_TIMEOUT_PROPERTY_NAME,
240000, false);
- this.forceRestart = properties.getBooleanValue(FORCE_RESTART_PROPERTY_NAME, false,
false);
- this.maxDeployments = properties.getIntValue(MAX_DEPLOYMENTS_PROPERTY_NAME, 25,
false);
- this.jbossShutdownDelay = properties.getIntValue(SHUTDOWN_DELAY_PROPERTY_NAME,
15000, false);
- restartJboss();
- }
-
- protected void restartJboss() throws IOException
- {
- if (forceRestart)
- {
- if (isJBossUp())
- {
- log.info("Shutting down JBoss instance as in force-restart mode");
- shutDownJBoss();
- try
- {
- Thread.sleep(jbossShutdownDelay);
- }
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
- }
- }
- if (!isJBossUp())
- {
- jbossWasStarted = true;
- launch("run", "--host=" + jbossBindAddress);
- log.info("Starting JBoss instance");
- // Wait for JBoss to come up
- long timeoutTime = System.currentTimeMillis() + bootTimeout;
- boolean interrupted = false;
- while (timeoutTime > System.currentTimeMillis())
- {
- if (isJBossUp())
- {
- log.info("Started JBoss instance");
- return;
- }
- try
- {
- Thread.sleep(200);
- }
- catch (InterruptedException e)
- {
- interrupted = true;
- }
- }
- if (interrupted)
- {
- Thread.currentThread().interrupt();
- }
- // If we got this far something went wrong
- log.warn("Unable to connect to JBoss instance after " + bootTimeout +
"ms, giving up!");
- launch("shutdown", "-S");
- throw new IllegalStateException("Error connecting to JBoss
instance");
- }
- }
-
- protected void loadProperties(File file) throws IOException
- {
- InputStream is = new FileInputStream(file);
- try
- {
- System.getProperties().load(is);
- }
- finally
- {
- is.close();
- }
- }
-
- public String getJbossHome()
- {
- return jbossHome;
- }
-
- public void cleanup() throws IOException
- {
- if (jbossWasStarted)
- {
- log.info("Shutting down JBoss instance");
- shutDownJBoss();
- }
- }
-
- private void shutDownJBoss() throws IOException
- {
- launch("shutdown", "-S");
- log.info("Shut down JBoss AS");
- }
-
- private void launch(String scriptFileName, String params) throws IOException
- {
- String osName = System.getProperty("os.name");
- Runtime runtime = Runtime.getRuntime();
-
- Process p = null;
- if (osName.startsWith("Windows"))
- {
- String command[] = {
- "cmd.exe",
- "/C",
- "set JAVA_OPTS=" + javaOpts + " & cd /D " +
jbossHome + "\\bin & " + scriptFileName + ".bat " + params
- };
- p = runtime.exec(command);
- }
- else
- {
- String command[] = {
- "sh",
- "-c",
- "cd " + jbossHome + "/bin;JAVA_OPTS=\"" +
javaOpts + "\" ./" + scriptFileName + ".sh " + params
- };
- p = runtime.exec(command);
- }
- dump(p.getErrorStream());
- dump(p.getInputStream());
- }
-
- protected void dump(final InputStream is)
- {
- new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- DataOutputStream out = new DataOutputStream(new
FileOutputStream(configuration.getOutputDirectory() + File.separator +
"jboss.log"));
- int c;
- while((c = is.read()) != -1)
- {
- out.writeByte(c);
- }
- is.close();
- out.close();
- }
- catch(IOException e)
- {
- System.err.println("Error Writing/Reading Streams.");
- }
- }
- }).start();
- }
-
-
-}
\ No newline at end of file
Copied:
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
(from rev 1975,
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/AbstractContainersImpl.java)
===================================================================
---
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
(rev 0)
+++
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -0,0 +1,287 @@
+package org.jboss.testharness.integration.jbossas;
+
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.log4j.Logger;
+import org.jboss.testharness.api.Configurable;
+import org.jboss.testharness.api.Configuration;
+import org.jboss.testharness.integration.jbossas.util.DeploymentProperties;
+import org.jboss.testharness.spi.Containers;
+
+/**
+ *
+ * @author jeffgenender
+ * @author Pete Muir
+ *
+ */
+public abstract class JBossASConnector implements Configurable, Containers
+{
+
+ public static String JAVA_OPTS = " -ea";
+
+ public static final String JBOSS_HOME_PROPERTY_NAME = "jboss.home";
+ public static final String JAVA_OPTS_PROPERTY_NAME = "java.opts";
+ public static final String JBOSS_AS_DIR_PROPERTY_NAME = "jboss-as.dir";
+ public static final String JBOSS_BOOT_TIMEOUT_PROPERTY_NAME =
"jboss.boot.timeout";
+ public static final String FORCE_RESTART_PROPERTY_NAME =
"jboss.force.restart";
+ public static final String MAX_DEPLOYMENTS_PROPERTY_NAME =
"jboss.deployments.restart";
+ public static final String SHUTDOWN_DELAY_PROPERTY_NAME =
"jboss.shutdown.delay";
+ public static final String JBOSS_BIND_ADDRESS_PROPERTY_NAME =
"jboss.bind.address";
+
+ private static Logger log = Logger.getLogger(JBossASConnector.class);
+
+ private final DeploymentProperties properties;
+
+ private Configuration configuration;
+ protected String jbossHome;
+ private String jbossHttpUrl;
+ private boolean jbossWasStarted;
+ private long bootTimeout;
+ private String javaOpts;
+
+ private boolean forceRestart;
+
+ protected int maxDeployments;
+
+ private int jbossShutdownDelay;
+
+ private String jbossBindAddress;
+
+ public JBossASConnector()
+ {
+ this.properties = new DeploymentProperties();
+ }
+
+ 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 boolean isJBossUp()
+ {
+ // Check that JBoss is up!
+ try
+ {
+ URLConnection connection = new URL(jbossHttpUrl).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)
+ {
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ log.info("Connected to JBoss instance over http");
+ return true;
+ }
+
+ public void setup() throws IOException
+ {
+ String jbossAsPath = properties.getStringValue(JBOSS_AS_DIR_PROPERTY_NAME,
"../jboss-as", false);
+ if (jbossAsPath != null)
+ {
+ File jbossAsDir = new File(jbossAsPath);
+ if (jbossAsDir.isDirectory())
+ {
+ File buildProperties = new File(jbossAsDir, "build.properties");
+ if (buildProperties.exists())
+ {
+ loadProperties(buildProperties);
+ }
+ File localBuildProperties = new File(jbossAsDir,
"local.build.properties");
+ if (localBuildProperties.exists())
+ {
+ loadProperties(localBuildProperties);
+ }
+ }
+ }
+ jbossHome = properties.getStringValue(JBOSS_HOME_PROPERTY_NAME, null, true);
+ jbossBindAddress = properties.getStringValue(JBOSS_BIND_ADDRESS_PROPERTY_NAME,
"localhost", false);
+ configuration.setHost(jbossBindAddress + ":8080");
+ this.jbossHttpUrl = "http://" + configuration.getHost() + "/";
+ javaOpts = properties.getStringValue(JAVA_OPTS_PROPERTY_NAME, "",
false);
+ javaOpts = javaOpts + JAVA_OPTS;
+ File jbossHomeFile = new File(jbossHome);
+ jbossHome = jbossHomeFile.getPath();
+ log.info("Using JBoss instance " + jbossHome + " (" +
jbossHttpUrl + ")");
+ this.bootTimeout = properties.getLongValue(JBOSS_BOOT_TIMEOUT_PROPERTY_NAME,
240000, false);
+ this.forceRestart = properties.getBooleanValue(FORCE_RESTART_PROPERTY_NAME, false,
false);
+ this.maxDeployments = properties.getIntValue(MAX_DEPLOYMENTS_PROPERTY_NAME, 25,
false);
+ this.jbossShutdownDelay = properties.getIntValue(SHUTDOWN_DELAY_PROPERTY_NAME,
15000, false);
+ restartJboss();
+ }
+
+ protected void restartJboss() throws IOException
+ {
+ if (forceRestart)
+ {
+ if (isJBossUp())
+ {
+ log.info("Shutting down JBoss instance as in force-restart mode");
+ shutDownJBoss();
+ try
+ {
+ Thread.sleep(jbossShutdownDelay);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+ if (!isJBossUp())
+ {
+ jbossWasStarted = true;
+ launch("run", "--host=" + jbossBindAddress);
+ log.info("Starting JBoss instance");
+ // Wait for JBoss to come up
+ long timeoutTime = System.currentTimeMillis() + bootTimeout;
+ boolean interrupted = false;
+ while (timeoutTime > System.currentTimeMillis())
+ {
+ if (isJBossUp())
+ {
+ log.info("Started JBoss instance");
+ return;
+ }
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException e)
+ {
+ interrupted = true;
+ }
+ }
+ if (interrupted)
+ {
+ Thread.currentThread().interrupt();
+ }
+ // If we got this far something went wrong
+ log.warn("Unable to connect to JBoss instance after " + bootTimeout +
"ms, giving up!");
+ launch("shutdown", "-S");
+ throw new IllegalStateException("Error connecting to JBoss
instance");
+ }
+ }
+
+ protected void loadProperties(File file) throws IOException
+ {
+ InputStream is = new FileInputStream(file);
+ try
+ {
+ System.getProperties().load(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ public String getJbossHome()
+ {
+ return jbossHome;
+ }
+
+ public void cleanup() throws IOException
+ {
+ if (jbossWasStarted)
+ {
+ log.info("Shutting down JBoss instance");
+ shutDownJBoss();
+ }
+ }
+
+ private void shutDownJBoss() throws IOException
+ {
+ launch("shutdown", "-S");
+ }
+
+ private void launch(String scriptFileName, String params) throws IOException
+ {
+ String osName = System.getProperty("os.name");
+ Runtime runtime = Runtime.getRuntime();
+
+ Process p = null;
+ if (osName.startsWith("Windows"))
+ {
+ String command[] = {
+ "cmd.exe",
+ "/C",
+ "set JAVA_OPTS=" + javaOpts + " & cd /D " +
jbossHome + "\\bin & " + scriptFileName + ".bat " + params
+ };
+ p = runtime.exec(command);
+ }
+ else
+ {
+ String command[] = {
+ "sh",
+ "-c",
+ "cd " + jbossHome + "/bin;JAVA_OPTS=\"" +
javaOpts + "\" ./" + scriptFileName + ".sh " + params
+ };
+ p = runtime.exec(command);
+ }
+ dump(p.getErrorStream());
+ dump(p.getInputStream());
+ }
+
+ protected void dump(final InputStream is)
+ {
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ DataOutputStream out = new DataOutputStream(new
FileOutputStream(configuration.getOutputDirectory() + File.separator +
"jboss.log"));
+ int c;
+ while((c = is.read()) != -1)
+ {
+ out.writeByte(c);
+ }
+ is.close();
+ out.close();
+ }
+ catch(IOException e)
+ {
+ System.err.println("Error Writing/Reading Streams.");
+ }
+ }
+ }).start();
+ }
+
+
+}
\ No newline at end of file
Deleted:
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java
===================================================================
---
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java 2009-03-13
17:32:51 UTC (rev 1980)
+++
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -1,219 +0,0 @@
-package org.jboss.testharness.integration.jbossas;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map.Entry;
-
-import javax.naming.InitialContext;
-
-import org.apache.log4j.Logger;
-import org.jboss.deployers.client.spi.IncompleteDeploymentException;
-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.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.testharness.api.DeploymentException;
-import org.jboss.virtual.VFS;
-
-public class ProfileServiceContainersImpl extends AbstractContainersImpl
-{
-
- private Logger log = Logger.getLogger(ProfileServiceContainersImpl.class);
-
- private final List<String> failedUndeployments;
-
- private DeploymentManager deploymentManager;
- private final File tmpdir;
- private int deploymentCounter = 0;
-
-
- public ProfileServiceContainersImpl() throws Exception
- {
- tmpdir = new File(System.getProperty("java.io.tmpdir"),
"org.jboss.webbeans.tck.integration.jbossas");
- tmpdir.mkdir();
- tmpdir.deleteOnExit();
- this.failedUndeployments = new ArrayList<String>();
- }
-
-
- @Override
- public void setup() throws IOException
- {
- super.setup();
- try
- {
- initDeploymentManager();
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
-
- public void deploy(InputStream archiveStream, String name) throws DeploymentException,
IOException
- {
- if (deploymentManager == null)
- {
- throw new IllegalStateException("setup() has not been called!");
- }
- 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();
- doUndeploy(name);
- }
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- if (failure != null)
- {
- if (failure.getCause() instanceof IncompleteDeploymentException)
- {
- IncompleteDeploymentException incompleteDeploymentException =
(IncompleteDeploymentException) failure.getCause();
- for (Entry<String, Throwable> entry :
incompleteDeploymentException.getIncompleteDeployments().getContextsInError().entrySet())
- {
- if (entry.getKey().endsWith(name + "/_WebBeansBootstrap"))
- {
- throw new DeploymentException(entry.getValue());
- }
- }
- }
- throw new DeploymentException(failure);
- }
- }
-
- private void doUndeploy(String name) throws IOException
- {
- try
- {
- DeploymentProgress stopProgress =
deploymentManager.stop(DeploymentPhase.APPLICATION, name);
- stopProgress.run();
-
- DeploymentProgress undeployProgress =
deploymentManager.undeploy(DeploymentPhase.APPLICATION, name);
- undeployProgress.run();
- if (undeployProgress.getDeploymentStatus().isFailed())
- {
- failedUndeployments.add(name);
- }
- else
- {
- deploymentCounter++;
- }
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
-
- public void undeploy(String name) throws IOException
- {
- try
- {
- doUndeploy(name);
- }
- finally
- {
- if (deploymentCounter >= maxDeployments)
- {
- deploymentCounter = 0;
- // Let everything stablise
- removeFailedUnDeployments();
- try
- {
- Thread.sleep(5000);
- }
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
- restartJboss();
- try
- {
- initDeploymentManager();
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
- }
- }
-
- /**
- * Obtain the Deployment Manager
- * @throws Exception
- */
- protected void initDeploymentManager() throws Exception
- {
- String profileName = "default";
- InitialContext ctx = new InitialContext();
- 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();
- }
-
- @Override
- public void cleanup() throws IOException
- {
- removeFailedUnDeployments();
- super.cleanup();
- }
-
- private void removeFailedUnDeployments() throws IOException
- {
- List<String> remainingDeployments = new ArrayList<String>();
- for (String name : failedUndeployments)
- {
- try
- {
- DeploymentProgress undeployProgress =
deploymentManager.undeploy(DeploymentPhase.APPLICATION, name);
- undeployProgress.run();
- if (undeployProgress.getDeploymentStatus().isFailed())
- {
- remainingDeployments.add(name);
- }
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
- if (remainingDeployments.size() > 0)
- {
- //log.error("Failed to undeploy these artifacts: " +
remainingDeployments);
- }
- failedUndeployments.clear();
- }
-
-}
Added:
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java
===================================================================
---
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java
(rev 0)
+++
test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java 2009-03-13
17:59:25 UTC (rev 1981)
@@ -0,0 +1,219 @@
+package org.jboss.testharness.integration.jbossas;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.naming.InitialContext;
+
+import org.apache.log4j.Logger;
+import org.jboss.deployers.client.spi.IncompleteDeploymentException;
+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.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.virtual.VFS;
+
+public class ProfileServiceContainersImpl extends JBossASConnector
+{
+
+ private Logger log = Logger.getLogger(ProfileServiceContainersImpl.class);
+
+ private final List<String> failedUndeployments;
+
+ private DeploymentManager deploymentManager;
+ private final File tmpdir;
+ private int deploymentCounter = 0;
+
+
+ public ProfileServiceContainersImpl() throws Exception
+ {
+ tmpdir = new File(System.getProperty("java.io.tmpdir"),
"org.jboss.webbeans.tck.integration.jbossas");
+ tmpdir.mkdir();
+ tmpdir.deleteOnExit();
+ this.failedUndeployments = new ArrayList<String>();
+ }
+
+
+ @Override
+ public void setup() throws IOException
+ {
+ super.setup();
+ try
+ {
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ public void deploy(InputStream archiveStream, String name) throws DeploymentException,
IOException
+ {
+ if (deploymentManager == null)
+ {
+ throw new IllegalStateException("setup() has not been called!");
+ }
+ 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();
+ doUndeploy(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ if (failure != null)
+ {
+ if (failure.getCause() instanceof IncompleteDeploymentException)
+ {
+ IncompleteDeploymentException incompleteDeploymentException =
(IncompleteDeploymentException) failure.getCause();
+ for (Entry<String, Throwable> entry :
incompleteDeploymentException.getIncompleteDeployments().getContextsInError().entrySet())
+ {
+ if (entry.getKey().endsWith(name + "/_WebBeansBootstrap"))
+ {
+ throw new DeploymentException(entry.getValue());
+ }
+ }
+ }
+ throw new DeploymentException(failure);
+ }
+ }
+
+ private void doUndeploy(String name) throws IOException
+ {
+ try
+ {
+ DeploymentProgress stopProgress =
deploymentManager.stop(DeploymentPhase.APPLICATION, name);
+ stopProgress.run();
+
+ DeploymentProgress undeployProgress =
deploymentManager.undeploy(DeploymentPhase.APPLICATION, name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ failedUndeployments.add(name);
+ }
+ else
+ {
+ deploymentCounter++;
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ public void undeploy(String name) throws IOException
+ {
+ try
+ {
+ doUndeploy(name);
+ }
+ finally
+ {
+ if (deploymentCounter >= maxDeployments)
+ {
+ deploymentCounter = 0;
+ // Let everything stablise
+ removeFailedUnDeployments();
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ restartJboss();
+ try
+ {
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ }
+ }
+
+ /**
+ * Obtain the Deployment Manager
+ * @throws Exception
+ */
+ protected void initDeploymentManager() throws Exception
+ {
+ String profileName = "default";
+ InitialContext ctx = new InitialContext();
+ 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();
+ }
+
+ @Override
+ public void cleanup() throws IOException
+ {
+ removeFailedUnDeployments();
+ super.cleanup();
+ }
+
+ private void removeFailedUnDeployments() throws IOException
+ {
+ List<String> remainingDeployments = new ArrayList<String>();
+ for (String name : failedUndeployments)
+ {
+ try
+ {
+ DeploymentProgress undeployProgress =
deploymentManager.undeploy(DeploymentPhase.APPLICATION, name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ remainingDeployments.add(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ if (remainingDeployments.size() > 0)
+ {
+ //log.error("Failed to undeploy these artifacts: " +
remainingDeployments);
+ }
+ failedUndeployments.clear();
+ }
+
+}
Modified: test-harness/trunk/jboss/src/main/resources/log4j.xml
===================================================================
--- test-harness/trunk/jboss/src/main/resources/log4j.xml 2009-03-13 17:32:51 UTC (rev
1980)
+++ test-harness/trunk/jboss/src/main/resources/log4j.xml 2009-03-13 17:59:25 UTC (rev
1981)
@@ -6,7 +6,7 @@
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p
[%c{6}] %m%n"/>
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p
[%c{2}] %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.StringMatchFilter">
<param name="AcceptOnMatch" value="false" />
@@ -60,7 +60,7 @@
<priority value="INFO"/>
</category>
- <category name="org.jboss.jsr299">
+ <category name="org.jboss.testharness">
<priority value="INFO"/>
</category>