[webbeans-commits] Webbeans SVN: r2666 - in test-harness/trunk: jboss51 and 13 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu May 7 12:16:42 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-05-07 12:16:42 -0400 (Thu, 07 May 2009)
New Revision: 2666
Added:
test-harness/trunk/jboss51/
test-harness/trunk/jboss51/pom.xml
test-harness/trunk/jboss51/src/
test-harness/trunk/jboss51/src/main/
test-harness/trunk/jboss51/src/main/java/
test-harness/trunk/jboss51/src/main/java/org/
test-harness/trunk/jboss51/src/main/java/org/jboss/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java
test-harness/trunk/jboss51/src/main/resources/
test-harness/trunk/jboss51/src/main/resources/META-INF/
test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties
test-harness/trunk/jboss51/src/main/resources/log4j.xml
test-harness/trunk/jboss51/src/test/
test-harness/trunk/jboss51/src/test/debug-resources/
test-harness/trunk/jboss51/src/test/debug-resources/META-INF/
test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties
test-harness/trunk/jboss51/src/test/java/
test-harness/trunk/jboss51/src/test/resources/
Modified:
test-harness/trunk/pom.xml
Log:
add jboss 5.1 connector
Property changes on: test-harness/trunk/jboss51
___________________________________________________________________
Name: svn:ignore
+
.classpath
.project
target
.settings
Added: test-harness/trunk/jboss51/pom.xml
===================================================================
--- test-harness/trunk/jboss51/pom.xml (rev 0)
+++ test-harness/trunk/jboss51/pom.xml 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>jboss-test-harness-parent</artifactId>
+ <groupId>org.jboss.test-harness</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-jboss-as-51</artifactId>
+ <name>JBoss Test Harness deployment for JBoss AS 5.1.x</name>
+ <description>Implements the JBoss Test Harness deployment SPI for JBoss AS 5.1.x</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <version>5.1.0.CR3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-client-spi</artifactId>
+ <version>2.0.6.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <type>pom</type>
+ <scope>runtime</scope>
+ <version>5.1.0.CR1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
===================================================================
--- test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java (rev 0)
+++ test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,60 @@
+package org.jboss.testharness.integration.jbossas;
+
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.testharness.spi.Containers;
+import org.jboss.testharness.spi.helpers.AbstractContainerConnector;
+
+/**
+ *
+ * @author jeffgenender
+ * @author Pete Muir
+ *
+ */
+public abstract class JBossASConnector extends AbstractContainerConnector implements Containers
+{
+
+ private static final String SERVER_HOME_PROPERTY_NAME = "jboss.home";
+
+ private String jbossBinDirectory;
+
+ public JBossASConnector() throws IOException
+ {
+
+ }
+
+ @Override
+ protected String getServerHomePropertyName()
+ {
+ return SERVER_HOME_PROPERTY_NAME;
+ }
+
+ protected void shutdownServer() throws IOException
+ {
+ launch(getJBossBinDirectory(), "shutdown", "-S");
+ }
+
+ @Override
+ protected void startServer() throws IOException
+ {
+ launch(getJBossBinDirectory(), "run", "--host=" + getHost());
+ }
+
+ protected String getJBossBinDirectory()
+ {
+ if (jbossBinDirectory == null)
+ {
+ jbossBinDirectory = new File(getServerDirectory() + "/bin").getPath();
+ }
+ return jbossBinDirectory;
+ }
+
+ @Override
+ protected String getLogName()
+ {
+ return "jboss.log";
+ }
+
+}
\ No newline at end of file
Added: test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java
===================================================================
--- test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java (rev 0)
+++ test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,252 @@
+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.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.virtual.VFS;
+
+public class ProfileServiceConnector extends JBossASConnector
+{
+
+ private final Logger log = Logger.getLogger(ProfileServiceConnector.class);
+
+ public static final String MAX_DEPLOYMENTS_PROPERTY_NAME = "max.deployments.restart";
+
+ private final List<String> failedUndeployments;
+
+ private DeploymentManager deploymentManager;
+ private final File tmpdir;
+ private int deploymentCounter = 0;
+ private Integer maxDeployments;
+
+ private Boolean forceRestart;
+
+
+ public ProfileServiceConnector() 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, archive.toURI().toURL(), true);
+ distribute.run();
+ DeploymentProgress progress = deploymentManager.start(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 + "/_WebBeansBootstrapBean"))
+ {
+ throw new DeploymentException(entry.getValue());
+ }
+ }
+ }
+ throw new DeploymentException(failure);
+ }
+ }
+
+ private void doUndeploy(String name) throws IOException
+ {
+ try
+ {
+ DeploymentProgress stopProgress = deploymentManager.stop(name);
+ stopProgress.run();
+
+ DeploymentProgress undeployProgress = deploymentManager.remove(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 >= getMaxDeployments())
+ {
+ // Force into force-restart mode
+ forceRestart = true;
+ deploymentCounter = 0;
+ // Let everything stablise
+ removeFailedUnDeployments();
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ restartServer();
+ 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);
+ // 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.remove(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();
+ }
+
+ protected String getMaxDeploymentsPropertyName()
+ {
+ return MAX_DEPLOYMENTS_PROPERTY_NAME;
+ }
+
+ protected Integer getMaxDeployments()
+ {
+ if (maxDeployments == null)
+ {
+ this.maxDeployments = getProperties().getIntValue(getMaxDeploymentsPropertyName(), 25, false);
+ }
+ return maxDeployments;
+ }
+
+ @Override
+ protected Boolean getForceRestart()
+ {
+ if (forceRestart == null)
+ {
+ return super.getForceRestart();
+ }
+ else
+ {
+ return forceRestart;
+ }
+ }
+
+}
Added: test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties
===================================================================
--- test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties (rev 0)
+++ test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,3 @@
+org.jboss.testharness.spi.Containers=org.jboss.testharness.integration.jbossas.ProfileServiceConnector
+org.jboss.testharness.connectDelay=1500
+org.jboss.testharness.connectRetries=8
\ No newline at end of file
Added: test-harness/trunk/jboss51/src/main/resources/log4j.xml
===================================================================
--- test-harness/trunk/jboss51/src/main/resources/log4j.xml (rev 0)
+++ test-harness/trunk/jboss51/src/main/resources/log4j.xml 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,58 @@
+<?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{2}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ############### JBoss ################# -->
+ <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>
+ -->
+
+ <category name="org.jboss.testharness">
+ <priority value="INFO"/>
+ </category>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Added: test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties
===================================================================
--- test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties (rev 0)
+++ test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties 2009-05-07 16:16:42 UTC (rev 2666)
@@ -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/jboss-tck-runner/target/dependency/lib
+org.jboss.testharness.runIntegrationTests=true
\ No newline at end of file
Modified: test-harness/trunk/pom.xml
===================================================================
--- test-harness/trunk/pom.xml 2009-05-07 15:36:15 UTC (rev 2665)
+++ test-harness/trunk/pom.xml 2009-05-07 16:16:42 UTC (rev 2666)
@@ -44,6 +44,7 @@
<module>impl</module>
<module>tests</module>
<module>jboss</module>
+ <module>jboss51</module>
<module>tomcat</module>
</modules>
More information about the weld-commits
mailing list