[webbeans-commits] Webbeans SVN: r1703 - ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Feb 25 08:00:20 EST 2009
Author: alesj
Date: 2009-02-25 08:00:20 -0500 (Wed, 25 Feb 2009)
New Revision: 1703
Modified:
ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/AbstractContainersImpl.java
ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/JBossTestServicesContainersImpl.java
ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ProfileServiceContainersImpl.java
Log:
Make it portable with JDK5
Modified: ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/AbstractContainersImpl.java
===================================================================
--- ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/AbstractContainersImpl.java 2009-02-25 11:46:12 UTC (rev 1702)
+++ ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/AbstractContainersImpl.java 2009-02-25 13:00:20 UTC (rev 1703)
@@ -2,6 +2,7 @@
import java.io.DataOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
@@ -18,33 +19,33 @@
import org.jboss.webbeans.tck.integration.jbossas.util.DeploymentProperties;
/**
- *
+ *
* @author jeffgenender
* @author Pete Muir
*
*/
public abstract class AbstractContainersImpl implements Configurable, Containers
{
-
+
public static String JAVA_OPTS = " -ea";
-
+
public static final String JBOSS_HOME_PROPERTY_NAME = "jboss.home";
public static final String JAVA_OPTS_PROPERTY_NAME = "java.opts";
public static final String JBOSS_AS_DIR_PROPERTY_NAME = "jboss-as.dir";
public static final String JBOSS_BOOT_TIMEOUT_PROPERTY_NAME = "jboss.boot.timeout";
public static final String FORCE_RESTART_PROPERTY_NAME = "jboss.force.restart";
-
+
private static Logger log = Logger.getLogger(AbstractContainersImpl.class);
-
+
private final DeploymentProperties properties;
-
+
private Configuration configuration;
protected String jbossHome;
private String jbossHttpUrl;
private boolean jbossWasStarted;
private long bootTimeout;
private String javaOpts;
-
+
public AbstractContainersImpl()
{
this.properties = new DeploymentProperties();
@@ -53,21 +54,21 @@
protected static void copy(InputStream inputStream, File file) throws IOException
{
OutputStream os = new FileOutputStream(file);
- try
+ try
{
byte[] buf = new byte[1024];
int i = 0;
- while ((i = inputStream.read(buf)) != -1)
+ while ((i = inputStream.read(buf)) != -1)
{
os.write(buf, 0, i);
}
- }
- finally
+ }
+ finally
{
os.close();
}
- }
-
+ }
+
public void setConfiguration(Configuration configuration)
{
this.configuration = configuration;
@@ -91,14 +92,14 @@
return false;
}
}
- catch (Exception e)
+ catch (Exception e)
{
return false;
}
log.info("Successfully connected to JBoss AS at " + jbossHttpUrl);
return true;
}
-
+
public void setup() throws IOException
{
String jbossAsPath = properties.getStringValue(JBOSS_AS_DIR_PROPERTY_NAME, "../jboss-as", false);
@@ -110,14 +111,14 @@
File buildProperties = new File(jbossAsDir, "build.properties");
if (buildProperties.exists())
{
- System.getProperties().load(new FileReader(buildProperties));
+ loadProperties(buildProperties);
}
File localBuildProperties = new File(jbossAsDir, "local.build.properties");
if (localBuildProperties.exists())
{
- System.getProperties().load(new FileReader(localBuildProperties));
+ loadProperties(localBuildProperties);
}
- }
+ }
}
jbossHome = properties.getStringValue(JBOSS_HOME_PROPERTY_NAME, null, true);
javaOpts = properties.getStringValue(JAVA_OPTS_PROPERTY_NAME, "", false);
@@ -152,7 +153,7 @@
boolean interrupted = false;
while (timeoutTime > System.currentTimeMillis())
{
- if (isJBossUp())
+ if (isJBossUp())
{
log.info("Started JBoss instance");
return;
@@ -180,12 +181,25 @@
return;
}
}
-
- public String getJbossHome()
+
+ 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)
@@ -194,20 +208,20 @@
shutDownJBoss();
}
}
-
+
private void shutDownJBoss() throws IOException
{
launch("shutdown", "-S");
log.info("Shut down JBoss AS");
}
-
+
private void launch(String scriptFileName, String params) throws IOException
{
String osName = System.getProperty("os.name");
Runtime runtime = Runtime.getRuntime();
Process p = null;
- if (osName.startsWith("Windows"))
+ if (osName.startsWith("Windows"))
{
String command[] = {
"cmd.exe",
@@ -216,7 +230,7 @@
};
p = runtime.exec(command);
}
- else
+ else
{
String command[] = {
"sh",
@@ -229,24 +243,24 @@
dump(p.getInputStream());
}
- protected void dump(final InputStream is)
+ protected void dump(final InputStream is)
{
- new Thread(new Runnable()
+ new Thread(new Runnable()
{
- public void run()
+ public void run()
{
- try
+ try
{
DataOutputStream out = new DataOutputStream(new FileOutputStream(configuration.getOutputDirectory() + File.separator + "jboss.log"));
int c;
- while((c = is.read()) != -1)
+ while((c = is.read()) != -1)
{
out.writeByte(c);
}
is.close();
out.close();
}
- catch(IOException e)
+ catch(IOException e)
{
System.err.println("Error Writing/Reading Streams.");
}
@@ -254,5 +268,5 @@
}).start();
}
-
+
}
\ No newline at end of file
Modified: ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/JBossTestServicesContainersImpl.java
===================================================================
--- ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/JBossTestServicesContainersImpl.java 2009-02-25 11:46:12 UTC (rev 1702)
+++ ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/JBossTestServicesContainersImpl.java 2009-02-25 13:00:20 UTC (rev 1703)
@@ -10,12 +10,12 @@
public class JBossTestServicesContainersImpl extends AbstractContainersImpl
{
-
+
private Logger log = Logger.getLogger(JBossTestServicesContainersImpl.class);
-
+
private final JBossTestServices testServices;
private final File tmpdir;
-
+
public JBossTestServicesContainersImpl() throws Exception
{
this.testServices = new JBossTestServices(JBossTestServicesContainersImpl.class);
@@ -25,7 +25,7 @@
tmpdir.mkdir();
tmpdir.deleteOnExit();
}
-
+
public void deploy(InputStream archiveStream, String name) throws DeploymentException, IOException
{
File archive = new File(tmpdir, name);
@@ -38,9 +38,9 @@
catch (Exception e)
{
throw new DeploymentException("Error deploying " + name, e);
- }
+ }
}
-
+
public void undeploy(String name) throws IOException
{
try
@@ -49,14 +49,16 @@
}
catch (Exception e)
{
- throw new IOException("Error undeploying " + name, e);
+ IOException ioe = new IOException("Error undeploying " + name);
+ ioe.initCause(e);
+ throw ioe;
}
}
-
+
private String getTmpArchiveName(String name)
{
File file = new File(tmpdir, name);
return file.toURI().toString();
}
-
+
}
Modified: ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ProfileServiceContainersImpl.java
===================================================================
--- ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ProfileServiceContainersImpl.java 2009-02-25 11:46:12 UTC (rev 1702)
+++ ri/trunk/jboss-tck-runner/src/main/java/org/jboss/webbeans/tck/integration/jbossas/ProfileServiceContainersImpl.java 2009-02-25 13:00:20 UTC (rev 1703)
@@ -21,16 +21,16 @@
public class ProfileServiceContainersImpl extends AbstractContainersImpl
{
-
+
private Logger log = Logger.getLogger(ProfileServiceContainersImpl.class);
-
+
private final List<String> failedUndeployments;
-
+
private DeploymentManager deploymentManager;
private JBossTestServices testServices;
private final File tmpdir;
-
-
+
+
public ProfileServiceContainersImpl() throws Exception
{
this.testServices = new JBossTestServices(JBossTestServicesContainersImpl.class);
@@ -41,22 +41,24 @@
tmpdir.deleteOnExit();
this.failedUndeployments = new ArrayList<String>();
}
-
-
+
+
@Override
public void setup() throws IOException
{
super.setup();
- try
+ try
{
initDeploymentManager();
}
- catch (Exception e)
+ catch (Exception e)
{
- throw new IOException(e);
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
}
}
-
+
public void deploy(InputStream archiveStream, String name) throws DeploymentException, IOException
{
if (deploymentManager == null)
@@ -80,23 +82,25 @@
undeploy(name);
}
}
- catch (Exception e)
+ catch (Exception e)
{
- throw new IOException(e);
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
}
if (failure != null)
{
throw new DeploymentException(failure);
}
}
-
+
public void undeploy(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())
@@ -106,10 +110,12 @@
}
catch (Exception e)
{
- throw new IOException(e);
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
}
}
-
+
/**
* Obtain the Deployment Manager
* @throws Exception
@@ -125,9 +131,9 @@
// Init the VFS to setup the vfs* protocol handlers
VFS.init();
}
-
+
@Override
- public void cleanup() throws IOException
+ public void cleanup() throws IOException
{
super.cleanup();
List<String> remainingDeployments = new ArrayList<String>();
@@ -142,9 +148,11 @@
remainingDeployments.add(name);
}
}
- catch (Exception e)
+ catch (Exception e)
{
- throw new IOException(e);
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
}
}
if (remainingDeployments.size() > 0)
@@ -152,5 +160,5 @@
//log.error("Failed to undeploy these artifacts: " + remainingDeployments);
}
}
-
+
}
More information about the weld-commits
mailing list