[webbeans-commits] Webbeans SVN: r2336 - in test-harness/trunk: api/src/main/java/org/jboss/testharness and 12 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Apr 7 19:36:11 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-04-07 19:36:11 -0400 (Tue, 07 Apr 2009)
New Revision: 2336

Added:
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/PropertiesManager.java
   test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/
   test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java
   test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java
   test-harness/trunk/jboss/src/main/resources/META-INF/jboss-test-harness.properties
   test-harness/trunk/tests/src/test/resources/META-INF/jboss-test-harness.properties
Removed:
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/DeploymentProperties.java
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/Strings.java
   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/EnumerationIterable.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterator.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/ResourceLoadingException.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/SimpleResourceLoader.java
   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/util/
   test-harness/trunk/jboss/src/main/resources/META-INF/web-beans-tck.properties
   test-harness/trunk/tests/src/test/resources/META-INF/web-beans-tck.properties
Modified:
   test-harness/trunk/api/pom.xml
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/EnumerationIterable.java
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/EnumerationIterator.java
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/ResourceLoadingException.java
   test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/SimpleResourceLoader.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java
   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/jsr299/TCKArtifactDescriptor.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/TestRunner.java
   test-harness/trunk/jboss/
   test-harness/trunk/jboss/pom.xml
   test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
   test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
Log:
fix up proprety names, extract generic server connector code

Modified: test-harness/trunk/api/pom.xml
===================================================================
--- test-harness/trunk/api/pom.xml	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/api/pom.xml	2009-04-07 23:36:11 UTC (rev 2336)
@@ -33,6 +33,11 @@
 	<url>http://www.seamframework.org/WebBeans</url>
    
    <dependencies>
+   
+      <dependency>
+         <groupId>log4j</groupId>
+         <artifactId>log4j</artifactId>
+      </dependency>
 
    </dependencies>
 

Copied: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties (from rev 2333, test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util)

Deleted: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/DeploymentProperties.java
===================================================================
--- test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util/DeploymentProperties.java	2009-04-07 16:40:59 UTC (rev 2333)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/DeploymentProperties.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,233 +0,0 @@
-package org.jboss.testharness.integration.jbossas.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-/**
- * Utility class to load deployment properties
- * 
- * @author Pete Muir
- */
-public class DeploymentProperties
-{
-   // The resource bundle used to control Web Beans RI deployment
-   public static final String RESOURCE_BUNDLE = "META-INF/web-beans-tck.properties";
-   
-   private static final Logger log = Logger.getLogger(DeploymentProperties.class);
-   
-   // The class to work from
-   private SimpleResourceLoader resourceLoader;
-
-   /**
-    * Constructor
-    * 
-    * @param classLoader The classloader to work on
-    */
-   public DeploymentProperties()
-   {
-      this.resourceLoader = new SimpleResourceLoader();
-   }
-
-   /**
-    * Get a list of possible values for a given key.
-    * 
-    * First, System properties are tried, followed by the specified resource
-    * bundle (first in classpath only).
-    * 
-    * @param key The key to search for
-    * @return A list of possible values. An empty list is returned if there are
-    *         no matches.
-    */
-   public List<String> getPropertyValues(String key)
-   {
-      List<String> values = new ArrayList<String>();
-      addPropertiesFromSystem(key, values);
-      addPropertiesFromResourceBundle(key, values);
-      return values;
-   }
-
-   /**
-    * Adds matches from system properties
-    * 
-    * @param key The key to match
-    * @param values The currently found values
-    */
-   private void addPropertiesFromSystem(String key, List<String> values)
-   {
-      addProperty(key, System.getProperty(key), values);
-   }
-
-   /**
-    * Adds matches from detected resource bundles
-    * 
-    * @param key The key to match
-    * @param values The currently found values
-    */
-   private void addPropertiesFromResourceBundle(String key, List<String> values)
-   {
-      try
-      {
-         for (URL url : resourceLoader.getResources(RESOURCE_BUNDLE))
-         {
-            Properties properties = new Properties();
-            InputStream propertyStream = url.openStream();
-            try
-            {
-               properties.load(propertyStream);
-               addProperty(key, properties.getProperty(key), values);
-            }
-            finally
-            {
-               if (propertyStream != null)
-               {
-                  propertyStream.close();
-               }
-            }
-         }
-      }
-      catch (IOException e)
-      {
-         // No - op, file is optional
-      }
-   }
-
-   /**
-    * Add the property to the set of properties only if it hasn't already been
-    * added
-    * 
-    * @param key The key searched for
-    * @param value The value of the property
-    * @param values The currently found values
-    */
-   private void addProperty(String key, String value, List<String> values)
-   {
-      if (value != null)
-      {
-         values.add(value);
-      }
-
-   }
-   
-   /**
-    * Gets the possible implementation class for a given property for which the
-    * values are classanames
-    * 
-    * @param deploymentProperties The deployment properties object to use
-    * @param resourceLoader The resource laoder to use to attempt
-    * @param propertyName The name of the property to load
-    * @return A set of classes specified
-    */
-   @SuppressWarnings("unchecked")
-   public <T> Set<Class<T>> getClasses(String propertyName, Class<T> expectedType)
-   {
-      Set<Class<T>> classes = new HashSet<Class<T>>();
-      for (String className : getPropertyValues(propertyName))
-      {
-         try
-         {
-            classes.add((Class<T>) resourceLoader.classForName(className));
-         }
-         catch (ResourceLoadingException e)
-         {
-            //log.debug("Unable to load class " + className + " for property " + propertyName, e);
-         }
-      }
-      return classes;
-   }
-   
-   public <T> Class<T> getClassValue(String propertyName, Class<T> expectedType, boolean required)
-   {
-      Set<Class<T>> classes = getClasses(propertyName, expectedType);
-      if (classes.size() == 0)
-      {
-         if (required)
-         {
-            throw new IllegalArgumentException("Cannot find any implementations of " + expectedType.getSimpleName() + ", check that " + propertyName + " is specified");
-         }
-         else
-         {
-            return null;
-         }
-      }
-      else if (classes.size() > 1)
-      {
-         throw new IllegalArgumentException("More than one implementation of " + expectedType.getSimpleName() + " specified by " + propertyName + ", not sure which one to use!");
-      }
-      else
-      {
-         return classes.iterator().next(); 
-      }
-   }
-   
-   public <T> T getInstanceValue(String propertyName, Class<T> expectedType, boolean required)
-   {
-      Class<T> clazz = getClassValue(propertyName, expectedType, required);
-      if (clazz != null)
-      {
-         try
-         {
-            return clazz.newInstance();
-         }
-         catch (InstantiationException e)
-         {
-            throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
-         }
-         catch (IllegalAccessException e)
-         {
-            throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
-         }
-      }
-      else
-      {
-         return null;
-      }
-   }
-   
-   public boolean getBooleanValue(String propertyName, boolean _default, boolean required)
-   {
-      return Boolean.valueOf(getStringValue(propertyName, _default ? "true" : "false", required));
-   }
-   
-   public int getIntValue(String propertyName, int _default, boolean required)
-   {
-      return Integer.valueOf(getStringValue(propertyName, Integer.toString(_default), required)).intValue();
-   }
-   
-   public long getLongValue(String propertyName, long _default, boolean required)
-   {
-      return Long.valueOf(getStringValue(propertyName, Long.toString(_default), required)).longValue();
-   }
-   
-   public String getStringValue(String propertyName, String _default, boolean required)
-   {
-      List<String> values = getPropertyValues(propertyName);
-      if (values.size() == 0)
-      {
-         if (required)
-         {
-            throw new IllegalArgumentException("Cannot find required property " + propertyName + ", check that it is specified");
-         }
-         else
-         {
-            return _default;
-         }
-      }
-      else if (values.size() > 1)
-      {
-         throw new IllegalArgumentException("More than one value given for " + propertyName + ", not sure which one to use!");
-      }
-      else
-      {
-         return values.iterator().next();
-      }
-   }
-
-}
\ No newline at end of file

Modified: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/EnumerationIterable.java
===================================================================
--- test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util/EnumerationIterable.java	2009-04-07 16:40:59 UTC (rev 2333)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/EnumerationIterable.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,4 +1,4 @@
-package org.jboss.testharness.integration.jbossas.util;
+package org.jboss.testharness.properties;
 
 import java.util.Enumeration;
 import java.util.Iterator;

Modified: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/EnumerationIterator.java
===================================================================
--- test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util/EnumerationIterator.java	2009-04-07 16:40:59 UTC (rev 2333)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/EnumerationIterator.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,4 +1,4 @@
-package org.jboss.testharness.integration.jbossas.util;
+package org.jboss.testharness.properties;
 
 import java.util.Enumeration;
 import java.util.Iterator;

Added: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/PropertiesManager.java
===================================================================
--- test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/PropertiesManager.java	                        (rev 0)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/PropertiesManager.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -0,0 +1,231 @@
+package org.jboss.testharness.properties;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Utility class to load deployment properties
+ * 
+ * @author Pete Muir
+ */
+public class PropertiesManager
+{
+   // The resource bundle used to control Web Beans RI deployment
+   public static final String RESOURCE_BUNDLE = "META-INF/jboss-test-harness.properties";
+   
+   private static final Logger log = Logger.getLogger(PropertiesManager.class);
+   
+   // The class to work from
+   private SimpleResourceLoader resourceLoader;
+
+   /**
+    * Constructor
+    * 
+    * @param classLoader The classloader to work on
+    */
+   public PropertiesManager()
+   {
+      this.resourceLoader = new SimpleResourceLoader();
+   }
+
+   /**
+    * Get a list of possible values for a given key.
+    * 
+    * First, System properties are tried, followed by the specified resource
+    * bundle (first in classpath only).
+    * 
+    * @param key The key to search for
+    * @return A list of possible values. An empty list is returned if there are
+    *         no matches.
+    */
+   public Set<String> getPropertyValues(String key)
+   {
+      Set<String> values = new HashSet<String>();
+      addPropertiesFromSystem(key, values);
+      addPropertiesFromResourceBundle(key, values);
+      return values;
+   }
+
+   /**
+    * Adds matches from system properties
+    * 
+    * @param key The key to match
+    * @param values The currently found values
+    */
+   private void addPropertiesFromSystem(String key, Set<String> values)
+   {
+      addProperty(key, System.getProperty(key), values);
+   }
+
+   /**
+    * Adds matches from detected resource bundles
+    * 
+    * @param key The key to match
+    * @param values The currently found values
+    */
+   private void addPropertiesFromResourceBundle(String key, Set<String> values)
+   {
+      try
+      {
+         for (URL url : resourceLoader.getResources(RESOURCE_BUNDLE))
+         {
+            Properties properties = new Properties();
+            InputStream propertyStream = url.openStream();
+            try
+            {
+               properties.load(propertyStream);
+               addProperty(key, properties.getProperty(key), values);
+            }
+            finally
+            {
+               if (propertyStream != null)
+               {
+                  propertyStream.close();
+               }
+            }
+         }
+      }
+      catch (IOException e)
+      {
+         // No - op, file is optional
+      }
+   }
+
+   /**
+    * Add the property to the set of properties only if it hasn't already been
+    * added
+    * 
+    * @param key The key searched for
+    * @param value The value of the property
+    * @param values The currently found values
+    */
+   private void addProperty(String key, String value, Set<String> values)
+   {
+      if (value != null)
+      {
+         values.add(value);
+      }
+
+   }
+   
+   /**
+    * Gets the possible implementation class for a given property for which the
+    * values are classanames
+    * 
+    * @param deploymentProperties The deployment properties object to use
+    * @param resourceLoader The resource laoder to use to attempt
+    * @param propertyName The name of the property to load
+    * @return A set of classes specified
+    */
+   @SuppressWarnings("unchecked")
+   public <T> Set<Class<T>> getClasses(String propertyName, Class<T> expectedType)
+   {
+      Set<Class<T>> classes = new HashSet<Class<T>>();
+      for (String className : getPropertyValues(propertyName))
+      {
+         try
+         {
+            classes.add((Class<T>) resourceLoader.classForName(className));
+         }
+         catch (ResourceLoadingException e)
+         {
+            //log.debug("Unable to load class " + className + " for property " + propertyName, e);
+         }
+      }
+      return classes;
+   }
+   
+   public <T> Class<T> getClassValue(String propertyName, Class<T> expectedType, boolean required)
+   {
+      Set<Class<T>> classes = getClasses(propertyName, expectedType);
+      if (classes.size() == 0)
+      {
+         if (required)
+         {
+            throw new IllegalArgumentException("Cannot find any implementations of " + expectedType.getSimpleName() + ", check that " + propertyName + " is specified");
+         }
+         else
+         {
+            return null;
+         }
+      }
+      else if (classes.size() > 1)
+      {
+         throw new IllegalArgumentException("More than one implementation of " + expectedType.getSimpleName() + " specified by " + propertyName + ", not sure which one to use!");
+      }
+      else
+      {
+         return classes.iterator().next(); 
+      }
+   }
+   
+   public <T> T getInstanceValue(String propertyName, Class<T> expectedType, boolean required)
+   {
+      Class<T> clazz = getClassValue(propertyName, expectedType, required);
+      if (clazz != null)
+      {
+         try
+         {
+            return clazz.newInstance();
+         }
+         catch (InstantiationException e)
+         {
+            throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
+         }
+         catch (IllegalAccessException e)
+         {
+            throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
+         }
+      }
+      else
+      {
+         return null;
+      }
+   }
+   
+   public boolean getBooleanValue(String propertyName, boolean _default, boolean required)
+   {
+      return Boolean.valueOf(getStringValue(propertyName, _default ? "true" : "false", required));
+   }
+   
+   public int getIntValue(String propertyName, int _default, boolean required)
+   {
+      return Integer.valueOf(getStringValue(propertyName, Integer.toString(_default), required)).intValue();
+   }
+   
+   public long getLongValue(String propertyName, long _default, boolean required)
+   {
+      return Long.valueOf(getStringValue(propertyName, Long.toString(_default), required)).longValue();
+   }
+   
+   public String getStringValue(String propertyName, String _default, boolean required)
+   {
+      Set<String> values = getPropertyValues(propertyName);
+      if (values.size() == 0)
+      {
+         if (required)
+         {
+            throw new IllegalArgumentException("Cannot find required property " + propertyName + ", check that it is specified");
+         }
+         else
+         {
+            return _default;
+         }
+      }
+      else if (values.size() > 1)
+      {
+         throw new IllegalArgumentException("More than one value given for " + propertyName + ", not sure which one to use!");
+      }
+      else
+      {
+         return values.iterator().next();
+      }
+   }
+
+}
\ No newline at end of file

Modified: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/ResourceLoadingException.java
===================================================================
--- test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util/ResourceLoadingException.java	2009-04-07 16:40:59 UTC (rev 2333)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/ResourceLoadingException.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,4 +1,4 @@
-package org.jboss.testharness.integration.jbossas.util;
+package org.jboss.testharness.properties;
 
 
 /**

Modified: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/SimpleResourceLoader.java
===================================================================
--- test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util/SimpleResourceLoader.java	2009-04-07 16:40:59 UTC (rev 2333)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/SimpleResourceLoader.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,4 +1,4 @@
-package org.jboss.testharness.integration.jbossas.util;
+package org.jboss.testharness.properties;
 
 import java.io.IOException;
 import java.net.URL;

Deleted: test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/Strings.java
===================================================================
--- test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/util/Strings.java	2009-04-07 16:40:59 UTC (rev 2333)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/properties/Strings.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,30 +0,0 @@
-package org.jboss.testharness.integration.jbossas.util;
-
-import java.util.StringTokenizer;
-
-public class Strings
-{
-   static String[] split(String strings, String delims)
-   {
-      if (strings == null)
-      {
-         return new String[0];
-      }
-      else
-      {
-         StringTokenizer tokens = new StringTokenizer(strings, delims);
-         String[] result = new String[tokens.countTokens()];
-         int i = 0;
-         while (tokens.hasMoreTokens())
-         {
-            result[i++] = tokens.nextToken();
-         }
-         return result;
-      }
-   }
-   
-   public static boolean isEmpty(String string)
-   {
-      return string == null || string.length() == 0;
-   }
-}

Added: test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java
===================================================================
--- test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java	                        (rev 0)
+++ test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -0,0 +1,387 @@
+package org.jboss.testharness.spi.helpers;
+
+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.properties.PropertiesManager;
+
+public abstract class AbstractContainerConnector implements Configurable
+{
+   
+   public static String JAVA_OPTS = " -ea";
+   
+   public static final String JAVA_OPTS_PROPERTY_NAME = "org.jboss.testharness.container.javaOpts";
+   
+   private static final String BOOT_TIMEOUT_PROPERTY_NAME = "org.jboss.testharness.container.bootTimeout";
+   public static final String FORCE_RESTART_PROPERTY_NAME = "org.jboss.testharness.container.forceRestart";
+   public static final String HOST_PROPERTY_NAME = "org.jboss.testharness.container.host";
+   public static final String PORT_PROPERTY_NAME = "org.jboss.testharness.container.port";
+   public static final String SHUTDOWN_DELAY_PROPERTY_NAME = "org.jboss.testharness.container.shutdownDelay";
+   
+   public static final String EXTRA_CONFIGURATION_DIR_PROPERTY_NAME = "org.jboss.testharness.container.extraConfigurationDir";
+   
+   private static Logger log = Logger.getLogger(AbstractContainerConnector.class);
+   
+   private final PropertiesManager properties;
+   private Configuration configuration;
+   private boolean wasStarted;
+   
+   private String serverDirectory;
+   private String httpUrl;
+   private Long bootTimeout;
+   private String javaOpts;
+   private Boolean forceRestart;
+   private Integer shutdownDelay;
+   private String host;
+   private String port;
+
+   private String extraConfigurationDir;
+
+   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 AbstractContainerConnector() throws IOException
+   {
+      this.properties = new PropertiesManager();
+      String extraConfigurationDir = getExtraConfigurationDir();
+      if (extraConfigurationDir != null)
+      {
+         File extraConfiguration = new File(extraConfigurationDir);
+         if (extraConfiguration.isDirectory())
+         {
+            File buildProperties = new File(extraConfiguration, "build.properties");
+            if (buildProperties.exists())
+            {
+               loadProperties(buildProperties);
+            }
+            File localBuildProperties = new File(extraConfiguration, "local.build.properties");
+            if (localBuildProperties.exists())
+            {
+               loadProperties(localBuildProperties);
+            }
+         }
+      }
+   }
+
+   public void setConfiguration(Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+
+   /**
+    * Check that the server is up by attempting to connect to it's front page
+    * @return true if the connection was made
+    */
+   protected boolean isServerUp()
+   {
+      try
+      {
+         URLConnection connection = new URL(getHttpUrl()).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 server over http");
+      return true;
+   }
+
+   public void setup() throws IOException
+   {
+      configuration.setHost(getHost() + ":" + getPort());
+      log.info("Using server " + getServerDirectory() + " (" + getHttpUrl() + ")");
+      restartServer();
+   }
+
+   protected void restartServer() throws IOException
+   {
+      if (getForceRestart())
+      {
+         if (isServerUp())
+         {
+            log.info("Shutting down server as in force-restart mode");
+            shutdownServer();
+            try
+            {
+               Thread.sleep(getShutdownDelay());
+            }
+            catch (InterruptedException e)
+            {
+               Thread.currentThread().interrupt();
+            }
+         }
+      }
+      if (!isServerUp())
+      {
+         wasStarted = true;
+         startServer();
+         log.info("Starting server");
+         // Wait for server to come up
+         long timeoutTime = System.currentTimeMillis() + getServerBootTimeout();
+         boolean interrupted = false;
+         while (timeoutTime > System.currentTimeMillis())
+         {
+            if (isServerUp())
+            {
+               log.info("Started server");
+               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 server after " + getServerBootTimeout() + "ms, giving up!");
+         shutdownServer();
+         throw new IllegalStateException("Error connecting to server");
+      }
+   }
+
+   protected void loadProperties(File file) throws IOException
+   {
+      InputStream is = new FileInputStream(file);
+      try
+      {
+   		System.getProperties().load(is);
+      }
+      finally
+      {
+   	   is.close();
+      }
+   }
+
+   public void cleanup() throws IOException
+   {
+      if (wasStarted)
+      {
+         log.info("Shutting down server");
+         shutdownServer();
+      }
+   }
+
+   protected abstract void shutdownServer() throws IOException;
+   
+   protected abstract void startServer() throws IOException; 
+
+   protected void launch(String directory, String scriptFileName, String params) throws IOException
+   {
+      String osName = System.getProperty("os.name");
+      Runtime runtime = Runtime.getRuntime();
+      
+      directory = new File(directory).getPath();
+   
+      Process p = null;
+      if (osName.startsWith("Windows"))
+      {
+          String command[] = {
+                "cmd.exe",
+                "/C",
+                "set JAVA_OPTS=" + getJavaOpts() + " & cd /D " + directory + " & " + scriptFileName + ".bat " + params
+          };
+          p = runtime.exec(command);
+      }
+      else
+      {
+          String command[] = {
+                "sh",
+                "-c",
+                "cd " + directory + ";JAVA_OPTS=\"" + getJavaOpts() + "\" ./" + 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 + getLogName()));
+                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();
+   }
+
+   protected abstract String getServerHomePropertyName();
+   
+   protected String getServerDirectory()
+   {
+      if (serverDirectory == null)
+      {
+         serverDirectory = new File(getProperties().getStringValue(getServerHomePropertyName(), null, true)).getPath();
+      }
+      return serverDirectory;
+   }
+   
+   protected String getServerBootTimeoutPropertyName()
+   {
+      return BOOT_TIMEOUT_PROPERTY_NAME;
+   }
+   
+   protected Long getServerBootTimeout()
+   {
+      if (bootTimeout == null)
+      {
+         this.bootTimeout = getProperties().getLongValue(getServerBootTimeoutPropertyName(), 240000, false);
+      }
+      return bootTimeout;
+   }
+   
+   protected String getForceRestartPropertyName()
+   {
+      return FORCE_RESTART_PROPERTY_NAME;
+   }
+   
+   protected Boolean getForceRestart()
+   {
+      if (forceRestart == null)
+      {
+         this.forceRestart = this.forceRestart = getProperties().getBooleanValue(getForceRestartPropertyName(), false, false);
+      }
+      return forceRestart;
+   }
+   
+   protected String getHostPropertyName()
+   {
+      return HOST_PROPERTY_NAME;
+   }
+   
+   protected String getHost()
+   {
+      if (host == null)
+      {
+         host = getProperties().getStringValue(getHostPropertyName(), "localhost", false);
+      }
+      return host;
+   }
+   
+   protected String getPortPropertyName()
+   {
+      return PORT_PROPERTY_NAME;
+   }
+   
+   protected String getPort()
+   {
+      if (port == null)
+      {
+         port = getProperties().getStringValue(getPortPropertyName(), "8080", false);
+      }
+      return port;
+   }
+   
+   protected String getShutdownDelayPropertyName()
+   {
+      return SHUTDOWN_DELAY_PROPERTY_NAME;
+   }
+   
+   protected Integer getShutdownDelay()
+   {
+      if (shutdownDelay == null)
+      {
+         this.shutdownDelay = getProperties().getIntValue(SHUTDOWN_DELAY_PROPERTY_NAME, 15000, false);
+      }
+      return shutdownDelay;
+   }
+   
+   protected PropertiesManager getProperties()
+   {
+      return properties;
+   } 
+   
+   protected String getJavaOpts()
+   {
+      if (javaOpts == null)
+      {
+         javaOpts = getProperties().getStringValue(JAVA_OPTS_PROPERTY_NAME, "", false);
+         javaOpts = javaOpts + JAVA_OPTS;
+      }
+      return javaOpts;
+   }
+   
+   protected String getHttpUrl()
+   {
+      if (httpUrl == null)
+      {
+         this.httpUrl = "http://" + getHost() + ":" + getPort() + "/";
+      }
+      return httpUrl;
+   }
+   
+   protected String getExtraConfigurationDirPropertyName()
+   {
+      return EXTRA_CONFIGURATION_DIR_PROPERTY_NAME;
+   }
+   
+   protected abstract String getLogName(); 
+   
+   protected String getExtraConfigurationDir()
+   {
+      if (extraConfigurationDir == null)
+      {
+         this.extraConfigurationDir = getProperties().getStringValue(EXTRA_CONFIGURATION_DIR_PROPERTY_NAME, null, false);
+      }
+      return extraConfigurationDir;
+   }
+   
+}
\ No newline at end of file


Property changes on: test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -7,7 +7,7 @@
 import org.jboss.testharness.api.ConfigurationBuilder;
 import org.jboss.testharness.api.ResourceDescriptor;
 import org.jboss.testharness.api.TestLauncher;
-import org.jboss.testharness.impl.util.DeploymentProperties;
+import org.jboss.testharness.properties.PropertiesManager;
 import org.jboss.testharness.spi.Containers;
 import org.jboss.testharness.spi.StandaloneContainers;
 
@@ -18,7 +18,7 @@
    
    static
    {
-      DeploymentProperties properties = new DeploymentProperties();
+      PropertiesManager properties = new PropertiesManager();
       ConfigurationBuilder builder = properties.getInstanceValue(ConfigurationBuilder.PROPERTY_NAME, ConfigurationBuilder.class, false);
       if (builder == null)
       {

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-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -19,28 +19,28 @@
 import org.jboss.testharness.api.Configuration;
 import org.jboss.testharness.api.ConfigurationBuilder;
 import org.jboss.testharness.api.TestLauncher;
-import org.jboss.testharness.impl.util.DeploymentProperties;
+import org.jboss.testharness.properties.PropertiesManager;
 import org.jboss.testharness.spi.Containers;
 import org.jboss.testharness.spi.StandaloneContainers;
 
 public class PropertiesBasedConfigurationBuilder<T extends Configuration> implements ConfigurationBuilder
 {
    
-   private final DeploymentProperties deploymentProperties;
+   private final PropertiesManager propertiesManager;
    private final T configuration;
    
    public PropertiesBasedConfigurationBuilder(T configuration)
    {
-      this.deploymentProperties = new DeploymentProperties();
+      this.propertiesManager = new PropertiesManager();
       this.configuration = configuration;
       
-      configuration.setOutputDirectory(deploymentProperties.getStringValue(OUTPUT_DIRECTORY_PROPERTY_NAME, DEFAULT_OUTPUT_DIRECTORY, false));
-      configuration.setStandalone(deploymentProperties.getBooleanValue(STANDALONE_PROPERTY_NAME, DEFAULT_STANDALONE, false));
-      configuration.setRunIntegrationTests(deploymentProperties.getBooleanValue(RUN_INTEGRATION_TESTS_PROPERTY_NAME, DEFAULT_RUN_INTEGRATION_TESTS, false));
-      configuration.setConnectTimeout(deploymentProperties.getIntValue(CONNECT_TIMEOUT_PROPERTY_NAME, DEFAULT_CONNECT_DELAY, false));
-      configuration.setLibraryDirectory(deploymentProperties.getStringValue(LIBRARY_DIRECTORY_PROPERTY_NAME, DEFAULT_LIBRARY_DIRECTORY, false));
-      configuration.setHost(deploymentProperties.getStringValue(HOST_PROPERTY_NAME, DEFAULT_HOST, false));
-      configuration.setTestPackage(deploymentProperties.getStringValue(TEST_PACKAGE_PROPERTY_NAME, null, false));
+      configuration.setOutputDirectory(propertiesManager.getStringValue(OUTPUT_DIRECTORY_PROPERTY_NAME, DEFAULT_OUTPUT_DIRECTORY, false));
+      configuration.setStandalone(propertiesManager.getBooleanValue(STANDALONE_PROPERTY_NAME, DEFAULT_STANDALONE, false));
+      configuration.setRunIntegrationTests(propertiesManager.getBooleanValue(RUN_INTEGRATION_TESTS_PROPERTY_NAME, DEFAULT_RUN_INTEGRATION_TESTS, false));
+      configuration.setConnectTimeout(propertiesManager.getIntValue(CONNECT_TIMEOUT_PROPERTY_NAME, DEFAULT_CONNECT_DELAY, false));
+      configuration.setLibraryDirectory(propertiesManager.getStringValue(LIBRARY_DIRECTORY_PROPERTY_NAME, DEFAULT_LIBRARY_DIRECTORY, false));
+      configuration.setHost(propertiesManager.getStringValue(HOST_PROPERTY_NAME, DEFAULT_HOST, false));
+      configuration.setTestPackage(propertiesManager.getStringValue(TEST_PACKAGE_PROPERTY_NAME, null, false));
    }
    
    /* (non-Javadoc)
@@ -59,7 +59,7 @@
    
    protected <T> T getInstanceValue(String propertyName, Class<T> expectedType, boolean required)
    {
-      T instance = deploymentProperties.getInstanceValue(propertyName, expectedType, required);
+      T instance = propertiesManager.getInstanceValue(propertyName, expectedType, required);
       if (instance instanceof Configurable)
       {
          ((Configurable) instance).setConfiguration(configuration);
@@ -75,9 +75,9 @@
       return configuration;
    }
    
-   protected DeploymentProperties getDeploymentProperties()
+   protected PropertiesManager getDeploymentProperties()
    {
-      return deploymentProperties;
+      return propertiesManager;
    }
    
 }

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-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/jsr299/TCKArtifactDescriptor.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -12,7 +12,7 @@
 import org.jboss.testharness.impl.ConfigurationImpl;
 import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
 import org.jboss.testharness.impl.packaging.ResourceDescriptorImpl;
-import org.jboss.testharness.impl.util.DeploymentProperties;
+import org.jboss.testharness.properties.PropertiesManager;
 
 public class TCKArtifactDescriptor extends ArtifactDescriptor
 {
@@ -41,7 +41,7 @@
          try
          {
             deploymentProperties = getDeploymentProperties(getDeclaringClass());
-            getResources().add(new ResourceDescriptorImpl(getClassesRoot() + DeploymentProperties.RESOURCE_BUNDLE, deploymentProperties));
+            getResources().add(new ResourceDescriptorImpl(getClassesRoot() + PropertiesManager.RESOURCE_BUNDLE, deploymentProperties));
          }
          catch (IOException e)
          {

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-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/runner/TestRunner.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -6,7 +6,7 @@
 import java.util.Set;
 
 import org.jboss.testharness.impl.testng.RemoveExpectedExceptionsAnnotationTransformer;
-import org.jboss.testharness.impl.util.DeploymentProperties;
+import org.jboss.testharness.properties.PropertiesManager;
 import org.testng.ITestContext;
 import org.testng.ITestResult;
 import org.testng.TestNG;
@@ -44,8 +44,8 @@
    {
       if (classNames.size() == 0)
       {
-         DeploymentProperties deploymentProperties = new DeploymentProperties();
-         this.classNames = deploymentProperties.getPropertyValues("className");
+         PropertiesManager propertiesManager = new PropertiesManager();
+         this.classNames = propertiesManager.getPropertyValues("className");
       }
       TestNG testNG = new TestNG(false);
       testNG.setVerbose(0);

Deleted: 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-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,238 +0,0 @@
-package org.jboss.testharness.impl.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-/**
- * Utility class to load deployment properties
- * 
- * @author Pete Muir
- */
-public class DeploymentProperties
-{
-   // The resource bundle used to control Web Beans RI deployment
-   public static final String RESOURCE_BUNDLE = "META-INF/web-beans-tck.properties";
-   
-   private static final Logger log = Logger.getLogger(DeploymentProperties.class);
-   
-   // The class to work from
-   private SimpleResourceLoader resourceLoader;
-
-   /**
-    * Constructor
-    * 
-    * @param classLoader The classloader to work on
-    */
-   public DeploymentProperties()
-   {
-      this.resourceLoader = new SimpleResourceLoader();
-   }
-
-   /**
-    * Get a list of possible values for a given key.
-    * 
-    * First, System properties are tried, followed by the specified resource
-    * bundle (first in classpath only).
-    * 
-    * @param key The key to search for
-    * @return A list of possible values. An empty list is returned if there are
-    *         no matches.
-    */
-   public Set<String> getPropertyValues(String key)
-   {
-      Set<String> values = new HashSet<String>();
-      addPropertiesFromSystem(key, values);
-      addPropertiesFromResourceBundle(key, values);
-      return values;
-   }
-
-   /**
-    * Adds matches from system properties
-    * 
-    * @param key The key to match
-    * @param values The currently found values
-    */
-   private void addPropertiesFromSystem(String key, Set<String> values)
-   {
-      addProperty(key, System.getProperty(key), values);
-   }
-
-   /**
-    * Adds matches from detected resource bundles
-    * 
-    * @param key The key to match
-    * @param values The currently found values
-    */
-   private void addPropertiesFromResourceBundle(String key, Set<String> values)
-   {
-      try
-      {
-         for (URL url : resourceLoader.getResources(RESOURCE_BUNDLE))
-         {
-            Properties properties = new Properties();
-            InputStream propertyStream = url.openStream();
-            try
-            {
-               properties.load(propertyStream);
-               addProperty(key, properties.getProperty(key), values);
-            }
-            finally
-            {
-               if (propertyStream != null)
-               {
-                  propertyStream.close();
-               }
-            }
-         }
-      }
-      catch (IOException e)
-      {
-         // No - op, file is optional
-      }
-   }
-
-   /**
-    * Add the property to the set of properties only if it hasn't already been
-    * added
-    * 
-    * @param key The key searched for
-    * @param value The value of the property
-    * @param values The currently found values
-    */
-   private void addProperty(String key, String value, Set<String> values)
-   {
-      if (value != null)
-      {
-         String[] properties = Strings.split(value, ":");
-         for (String property : properties)
-         {
-            values.add(property);
-         }
-
-      }
-   }
-   
-   /**
-    * Gets the possible implementation class for a given property for which the
-    * values are classanames
-    * 
-    * @param deploymentProperties The deployment properties object to use
-    * @param resourceLoader The resource laoder to use to attempt
-    * @param propertyName The name of the property to load
-    * @return A set of classes specified
-    */
-   @SuppressWarnings("unchecked")
-   public <T> Set<Class<T>> getClasses(String propertyName, Class<T> expectedType)
-   {
-      Set<Class<T>> classes = new HashSet<Class<T>>();
-      for (String className : getPropertyValues(propertyName))
-      {
-         try
-         {
-            classes.add((Class<T>) resourceLoader.classForName(className));
-         }
-         catch (ResourceLoadingException e)
-         {
-            //log.debug("Unable to load class " + className + " for property " + propertyName, e);
-         }
-      }
-      return classes;
-   }
-   
-   public <T> Class<? extends T> getClassValue(String propertyName, Class<T> expectedType, Class<? extends T> defaultType, boolean required)
-   {
-      Set<Class<? extends T>> classes = new HashSet<Class<? extends T>>();
-      classes.addAll(getClasses(propertyName, expectedType));
-      if (classes.size() == 0)
-      {
-         if (defaultType != null)
-         {
-            classes.add(defaultType);
-         }
-         else if (required)
-         {
-            throw new IllegalArgumentException("Cannot find any implementations of " + expectedType.getSimpleName() + ", check that " + propertyName + " is specified");
-         }
-         else
-         {
-            return null;
-         }
-      }
-      else if (classes.size() > 1)
-      {
-         throw new IllegalArgumentException("More than one implementation of " + expectedType.getSimpleName() + " specified by " + propertyName + ", not sure which one to use!" + classes);
-      }
-      return classes.iterator().next();
-   }
-   
-   public <T> T getInstanceValue(String propertyName, Class<T> expectedType, boolean required)
-   {
-      return getInstanceValue(propertyName, expectedType, null, required);
-   }
-   
-   
-   public <T> T getInstanceValue(String propertyName, Class<T> expectedType, Class<? extends T> defaultType, boolean required)
-   {
-      Class<? extends T> clazz = getClassValue(propertyName, expectedType, defaultType, required);
-      if (clazz != null)
-      {
-         try
-         {
-            return clazz.newInstance();
-         }
-         catch (InstantiationException e)
-         {
-            throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
-         }
-         catch (IllegalAccessException e)
-         {
-            throw new IllegalStateException("Error instantiating " + clazz + " specified by " + propertyName, e);
-         }
-      }
-      else
-      {
-         return null;
-      }
-   }
-   
-   public boolean getBooleanValue(String propertyName, boolean _default, boolean required)
-   {
-      return Boolean.valueOf(getStringValue(propertyName, _default ? "true" : "false", required));
-   }
-   
-   public int getIntValue(String propertyName, int _default, boolean required)
-   {
-      return Integer.valueOf(getStringValue(propertyName, Integer.toString(_default), required)).intValue();
-   }
-   
-   public String getStringValue(String propertyName, String _default, boolean required)
-   {
-      Set<String> values = getPropertyValues(propertyName);
-      if (values.size() == 0)
-      {
-         if (required)
-         {
-            throw new IllegalArgumentException("Cannot find required property " + propertyName + ", check that it is specified ");
-         }
-         else
-         {
-            return _default;
-         }
-      }
-      else if (values.size() > 1)
-      {
-         throw new IllegalArgumentException("More than one value given for " + propertyName + ", not sure which one to use! " + values);
-      }
-      else
-      {
-         return values.iterator().next();
-      }
-   }
-
-}
\ No newline at end of file

Deleted: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterable.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterable.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterable.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,37 +0,0 @@
-package org.jboss.testharness.impl.util;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-/**
- * An Enumeration -> Iteratble adaptor
- *  
- * @author Pete Muir
- * @see org.jboss.webbeans.util.EnumerationIterator
- */
-class EnumerationIterable<T> implements Iterable<T>
-{
-   // The enumeration-iteartor
-   private EnumerationIterator<T> iterator;
-   
-   /**
-    * Constructor
-    * 
-    * @param enumeration The enumeration
-    */
-   public EnumerationIterable(Enumeration<T> enumeration)
-   {
-      this.iterator = new EnumerationIterator<T>(enumeration);
-   }
-   
-   /**
-    * Gets an iterator
-    * 
-    * @return The iterator
-    */
-   public Iterator<T> iterator()
-   {
-      return iterator;
-   }
-   
-}
\ No newline at end of file

Deleted: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterator.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterator.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/EnumerationIterator.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,55 +0,0 @@
-package org.jboss.testharness.impl.util;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-/**
- * An enumeration -> iterator adapter
- *  
- * @author Pete Muir
- */
- at SuppressWarnings("unchecked")
-class EnumerationIterator<T> implements Iterator<T>
-{
-   // The enumeration
-   private Enumeration e;
-
-   /**
-    * Constructor
-    * 
-    * @param e The enumeration
-    */
-   public EnumerationIterator(Enumeration e)
-   {
-      this.e = e;
-   }
-
-   /**
-    * Indicates if there are more items to iterate
-    * 
-    * @return True if more, false otherwise
-    */
-   public boolean hasNext()
-   {
-      return e.hasMoreElements();
-   }
-
-   /**
-    * Gets the next item
-    * 
-    * @return The next items
-    */
-   public T next()
-   {
-      return (T) e.nextElement();
-   }
-
-   /**
-    * Removes an item. Not supported
-    */
-   public void remove()
-   {
-      throw new UnsupportedOperationException();
-   }
-   
-}
\ No newline at end of file

Deleted: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/ResourceLoadingException.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/ResourceLoadingException.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/ResourceLoadingException.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,53 +0,0 @@
-package org.jboss.testharness.impl.util;
-
-
-/**
- * Exception thrown when errors occur while loading resource
- * 
- * @author Pete Muir
- *
- */
-class ResourceLoadingException extends RuntimeException
-{
-   private static final long serialVersionUID = 1L;
-
-   /**
-    * Constructor
-    */
-   public ResourceLoadingException()
-   {
-      super();
-   }
-
-   /**
-    * Constructor
-    * 
-    * @param message The message
-    * @param throwable The exception
-    */
-   public ResourceLoadingException(String message, Throwable throwable)
-   {
-      super(message, throwable);
-   }
-
-   /**
-    * Constructor
-    * 
-    * @param message The message
-    */
-   public ResourceLoadingException(String message)
-   {
-      super(message);
-   }
-
-   /**
-    * Constructor
-    * 
-    * @param throwable The exception
-    */
-   public ResourceLoadingException(Throwable throwable)
-   {
-      super(throwable);
-   }
-   
-}
\ No newline at end of file

Deleted: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/SimpleResourceLoader.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/SimpleResourceLoader.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/SimpleResourceLoader.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,43 +0,0 @@
-package org.jboss.testharness.impl.util;
-
-import java.io.IOException;
-import java.net.URL;
-
-class SimpleResourceLoader
-{
-   
-   public Class<?> classForName(String name)
-   {
-      
-      try
-      {
-         return Class.forName(name);
-      }
-      catch (ClassNotFoundException e)
-      {
-         throw new ResourceLoadingException(e);
-      }
-      catch (NoClassDefFoundError e)
-      {
-         throw new ResourceLoadingException(e);
-      }
-   }
-   
-   public URL getResource(String name)
-   {
-      return getClass().getResource(name);
-   }
-   
-   public Iterable<URL> getResources(String name)
-   {
-      try
-      {
-         return new EnumerationIterable<URL>(getClass().getClassLoader().getResources(name));
-      }
-      catch (IOException e)
-      {
-         throw new ResourceLoadingException(e);
-      }
-   }
-   
-}
\ No newline at end of file


Property changes on: test-harness/trunk/jboss
___________________________________________________________________
Name: svn:ignore
   - 
.classpath

target

.project

.settings

   + 
.classpath

target

.project

.settings

bin


Modified: test-harness/trunk/jboss/pom.xml
===================================================================
--- test-harness/trunk/jboss/pom.xml	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/jboss/pom.xml	2009-04-07 23:36:11 UTC (rev 2336)
@@ -7,9 +7,9 @@
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.jboss.test-harness</groupId>
-   <artifactId>jboss-test-harness-jboss-as-5</artifactId>
-   <name>JBoss Test Harness deployment for JBoss AS 5</name>
-   <description>Implements the JBoss Test Harness deployment SPI for JBoss AS 5</description>
+   <artifactId>jboss-test-harness-jboss-as-50</artifactId>
+   <name>JBoss Test Harness deployment for JBoss AS 5.0.x</name>
+   <description>Implements the JBoss Test Harness deployment SPI for JBoss AS 5.0.x</description>
 
    <dependencies>
 
@@ -18,30 +18,6 @@
          <artifactId>jboss-test-harness-api</artifactId>
       </dependency>
 
-      <!--      <dependency>-->
-      <!--         <groupId>org.jboss.naming</groupId>-->
-      <!--         <artifactId>jnp-client</artifactId>-->
-      <!--         <scope>runtime</scope>-->
-      <!--      </dependency>-->
-      <!--      -->
-      <!--      <dependency>-->
-      <!--         <groupId>org.jboss.aspects</groupId>-->
-      <!--         <artifactId>jboss-security-aspects</artifactId>-->
-      <!--         <scope>runtime</scope>-->
-      <!--      </dependency>-->
-      <!--      -->
-      <!--      <dependency>-->
-      <!--         <groupId>org.jboss.aspects</groupId>-->
-      <!--         <artifactId>jboss-remoting-aspects</artifactId>-->
-      <!--         <scope>runtime</scope>-->
-      <!--      </dependency>-->
-      <!--      -->
-      <!--      <dependency>-->
-      <!--         <groupId>oswego-concurrent</groupId>-->
-      <!--         <artifactId>concurrent</artifactId>-->
-      <!--         <scope>runtime</scope>-->
-      <!--      </dependency>-->
-<!---->
       <dependency>
          <groupId>org.jboss.integration</groupId>
          <artifactId>jboss-profileservice-spi</artifactId>

Modified: 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/JBossASConnector.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,21 +1,11 @@
 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;
+import org.jboss.testharness.spi.helpers.AbstractContainerConnector;
 
 /**
  *
@@ -23,265 +13,48 @@
  * @author Pete Muir
  *
  */
-public abstract class JBossASConnector implements Configurable, Containers
+public abstract class JBossASConnector extends AbstractContainerConnector implements Containers
 {
+   
+   private static final String SERVER_HOME_PROPERTY_NAME = "jboss.home";
+   
+   private String jbossBinDirectory; 
 
-   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()
+   public JBossASConnector() throws IOException
    {
-      this.properties = new DeploymentProperties();
+     
    }
 
-   protected static void copy(InputStream inputStream, File file) throws IOException
+   @Override
+   protected String getServerHomePropertyName()
    {
-      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();
-     }
+      return SERVER_HOME_PROPERTY_NAME;
    }
-
-   public void setConfiguration(Configuration configuration)
+   
+   protected void shutdownServer() throws IOException
    {
-      this.configuration = configuration;
+      launch(getJBossBinDirectory(), "shutdown", "-S");
    }
-
-   protected boolean isJBossUp()
+   
+   @Override
+   protected void startServer() throws IOException
    {
-      // 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;
+      launch(getJBossBinDirectory(), "run", "--host=" + getHost());
    }
-
-   public void setup() throws IOException
+   
+   protected String getJBossBinDirectory()
    {
-      String jbossAsPath = properties.getStringValue(JBOSS_AS_DIR_PROPERTY_NAME, "../jboss-as", false);
-      if (jbossAsPath != null)
+      if (jbossBinDirectory == 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);
-            }
-         }
+         jbossBinDirectory = new File(getServerDirectory() + "/bin").getPath();
       }
-      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();
+      return jbossBinDirectory;
    }
    
-   protected void restartJboss() throws IOException
+   @Override
+   protected String getLogName()
    {
-      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");
-      }
+      return "jboss.log";
    }
 
-   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

Copied: test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java (from rev 2333, 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/ProfileServiceConnector.java	                        (rev 0)
+++ test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -0,0 +1,236 @@
+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 ProfileServiceConnector extends JBossASConnector
+{
+
+   private 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;
+
+
+   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, 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 + "/_WebBeansBootstrapBean"))
+               {
+                  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 >= getMaxDeployments())
+         {
+            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, 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();
+   }
+   
+   protected String getMaxDeploymentsPropertyName()
+   {
+      return MAX_DEPLOYMENTS_PROPERTY_NAME;
+   }
+   
+   protected Integer getMaxDeployments()
+   {
+      if (maxDeployments == null)
+      {
+         this.maxDeployments = getProperties().getIntValue(getMaxDeploymentsPropertyName(), 25, false);
+      }
+      return maxDeployments;
+   }
+
+}

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-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/jboss/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceContainersImpl.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -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 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 + "/_WebBeansBootstrapBean"))
-               {
-                  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();
-   }
-
-}

Copied: test-harness/trunk/jboss/src/main/resources/META-INF/jboss-test-harness.properties (from rev 2333, test-harness/trunk/jboss/src/main/resources/META-INF/web-beans-tck.properties)
===================================================================
--- test-harness/trunk/jboss/src/main/resources/META-INF/jboss-test-harness.properties	                        (rev 0)
+++ test-harness/trunk/jboss/src/main/resources/META-INF/jboss-test-harness.properties	2009-04-07 23:36:11 UTC (rev 2336)
@@ -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

Deleted: test-harness/trunk/jboss/src/main/resources/META-INF/web-beans-tck.properties
===================================================================
--- test-harness/trunk/jboss/src/main/resources/META-INF/web-beans-tck.properties	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/jboss/src/main/resources/META-INF/web-beans-tck.properties	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1,3 +0,0 @@
-org.jboss.testharness.spi.Containers=org.jboss.testharness.integration.jbossas.ProfileServiceContainersImpl
-org.jboss.testharness.connectDelay=1500
-org.jboss.testharness.connectRetries=8
\ No newline at end of file

Modified: test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
===================================================================
--- test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java	2009-04-07 23:36:11 UTC (rev 2336)
@@ -71,7 +71,7 @@
       File applicationXml = new File(metaInf, "application.xml");
       assert applicationXml.length() > 0;
       
-      File webBeansTckProperties = new File(metaInf, "web-beans-tck.properties");
+      File webBeansTckProperties = new File(metaInf, "jboss-test-harness.properties");
       assert webBeansTckProperties.isFile();
       assert webBeansTckProperties.length() > 0;
       
@@ -128,7 +128,7 @@
       }
       is.close();
       assert fileNames.contains("META-INF/application.xml");
-      assert fileNames.contains("META-INF/web-beans-tck.properties");
+      assert fileNames.contains("META-INF/jboss-test-harness.properties");
       assert fileNames.contains("lib/jboss-test-harness.jar");
       assert fileNames.contains(DummyTest.class.getName() + ".jar");
       assert fileNames.contains(DummyTest.class.getName() + ".war");

Copied: test-harness/trunk/tests/src/test/resources/META-INF/jboss-test-harness.properties (from rev 2334, test-harness/trunk/tests/src/test/resources/META-INF/web-beans-tck.properties)
===================================================================
--- test-harness/trunk/tests/src/test/resources/META-INF/jboss-test-harness.properties	                        (rev 0)
+++ test-harness/trunk/tests/src/test/resources/META-INF/jboss-test-harness.properties	2009-04-07 23:36:11 UTC (rev 2336)
@@ -0,0 +1 @@
+org.jboss.testharness.api.ConfigurationBuilder=org.jboss.testharness.test.impl.mock.MockConfigurationBuilder
\ No newline at end of file


Property changes on: test-harness/trunk/tests/src/test/resources/META-INF/jboss-test-harness.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: test-harness/trunk/tests/src/test/resources/META-INF/web-beans-tck.properties
===================================================================
--- test-harness/trunk/tests/src/test/resources/META-INF/web-beans-tck.properties	2009-04-07 21:24:58 UTC (rev 2335)
+++ test-harness/trunk/tests/src/test/resources/META-INF/web-beans-tck.properties	2009-04-07 23:36:11 UTC (rev 2336)
@@ -1 +0,0 @@
-org.jboss.testharness.api.ConfigurationBuilder=org.jboss.testharness.test.impl.mock.MockConfigurationBuilder
\ No newline at end of file




More information about the weld-commits mailing list