[jboss-svn-commits] JBoss Common SVN: r4789 - in arquillian/trunk: containers/jbossas-managed-5.1/src/test/java/org/jboss/arquillian/container/jbossas/managed_5_1 and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 21 04:59:06 EDT 2010
Author: aslak
Date: 2010-07-21 04:59:05 -0400 (Wed, 21 Jul 2010)
New Revision: 4789
Removed:
arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/utils/
arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/utils/
Modified:
arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASConfiguration.java
arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASLocalContainer.java
arquillian/trunk/containers/jbossas-managed-5.1/src/test/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASIntegrationTestCase.java
arquillian/trunk/containers/jbossas-managed-5.1/src/test/resources/arquillian.xml
arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASConfiguration.java
arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASLocalContainer.java
arquillian/trunk/containers/jbossas-managed-6/src/test/resources/arquillian.xml
arquillian/trunk/protocols/servlet-2.5/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager
Log:
ARQ-186 Added JVM Arguments support to Configuration of Managed JBoss AS Containers.
Modified: arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASConfiguration.java
===================================================================
--- arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASConfiguration.java 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASConfiguration.java 2010-07-21 08:59:05 UTC (rev 4789)
@@ -36,9 +36,11 @@
private String profileName = "default";
- private String jbossHome = null;
+ private String jbossHome = System.getenv("JBOSS_HOME");
- private String javaHome = null;
+ private String javaHome = System.getenv("JAVA_HOME");
+
+ private String javaVmArguments = "-Xmx512m -XX:MaxPermSize=128m";
public ContainerProfile getContainerProfile()
{
@@ -60,6 +62,13 @@
return httpPort;
}
+ /**
+ * Set the HTTP Connect port. <br/>
+ * This is not the JBoss AS HTTP Bind port, bind port must be set in the JBoss XML configuration.<br/>
+ * <b>Only set this if default http port is changed in JBoss AS!</b>
+ *
+ * @param httpPort HTTP Connect port
+ */
public void setHttpPort(int httpPort)
{
this.httpPort = httpPort;
@@ -98,4 +107,19 @@
{
return javaHome;
}
+
+ /**
+ * This will override the default ("-Xmx512m -XX:MaxPermSize=128m") startup JVM arguments.
+ *
+ * @param javaVmArguments use as start up arguments
+ */
+ public void setJavaVmArguments(String javaVmArguments)
+ {
+ this.javaVmArguments = javaVmArguments;
+ }
+
+ public String getJavaVmArguments()
+ {
+ return javaVmArguments;
+ }
}
Modified: arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASLocalContainer.java
===================================================================
--- arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASLocalContainer.java 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-5.1/src/main/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASLocalContainer.java 2010-07-21 08:59:05 UTC (rev 4789)
@@ -21,8 +21,8 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Logger;
-import org.jboss.arquillian.container.jbossas.managed_5_1.utils.AsLifecycleDelegate;
import org.jboss.arquillian.protocol.servlet_2_5.ServletMethodExecutor;
import org.jboss.arquillian.spi.Configuration;
import org.jboss.arquillian.spi.ContainerMethodExecutor;
@@ -30,10 +30,11 @@
import org.jboss.arquillian.spi.DeployableContainer;
import org.jboss.arquillian.spi.DeploymentException;
import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.jbossas.servermanager.Argument;
+import org.jboss.jbossas.servermanager.Property;
import org.jboss.jbossas.servermanager.Server;
import org.jboss.jbossas.servermanager.ServerController;
import org.jboss.jbossas.servermanager.ServerManager;
-import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
@@ -45,81 +46,71 @@
*/
public class JBossASLocalContainer implements DeployableContainer
{
- private static Logger log = Logger.getLogger(JBossASLocalContainer.class);
+ private static Logger log = Logger.getLogger(JBossASLocalContainer.class.getName());
- private static AsLifecycleDelegate delegate;
+ private JBossASConfiguration configuration;
- protected Server server;
-
protected ServerManager manager;
- private boolean wasStarted;
-
private final List<String> failedUndeployments = new ArrayList<String>();
- private boolean forceRestart = false;
-
- private int shutdownDelay = 15000;
-
- private int bootTimeout = 240000;
-
- private String host = "localhost";
-
- private String profile = "default";
-
- private int port = 8181;
-
- private JBossASConfiguration configuration;
-
- public JBossASLocalContainer()
- {
-
- }
-
/* (non-Javadoc)
- * @see org.jboss.arquillian.spi.DeployableContainer#setup(org.jboss.arquillian.spi.Context, org.jboss.arquillian.spi.Configuration)
- */
+ * @see org.jboss.arquillian.spi.DeployableContainer#setup(org.jboss.arquillian.spi.Context, org.jboss.arquillian.spi.Configuration)
+ */
public void setup(Context context, Configuration configuration)
{
this.configuration = configuration.getContainerConfig(JBossASConfiguration.class);
- host = this.configuration.getBindAddress();
- profile = this.configuration.getProfileName();
- port = this.configuration.getHttpPort();
+
+ manager = createAndConfigureServerManager();
}
-
+
/* (non-Javadoc)
- * @see org.jboss.arquillian.spi.DeployableContainer#start(org.jboss.arquillian.spi.Context)
- */
+ * @see org.jboss.arquillian.spi.DeployableContainer#start(org.jboss.arquillian.spi.Context)
+ */
public void start(Context context) throws LifecycleException
{
-
try
{
- startServerManager();
- restartServer();
+ Server server = manager.getServer(configuration.getProfileName());
+ if(ServerController.isServerStarted(server))
+ {
+ throw new LifecycleException("Could not start server, server is already running");
+ }
+
+ manager.startServer(server.getName());
}
catch (IOException e)
{
- throw new LifecycleException("Could not start local container", e);
+ throw new LifecycleException("Could not start remote container", e);
}
}
/* (non-Javadoc)
- * @see org.jboss.arquillian.spi.DeployableContainer#stop(org.jboss.arquillian.spi.Context)
- */
+ * @see org.jboss.arquillian.spi.DeployableContainer#stop(org.jboss.arquillian.spi.Context)
+ */
public void stop(Context context) throws LifecycleException
{
+ Server server = manager.getServer(configuration.getProfileName());
+ if(!server.isRunning())
+ {
+ throw new LifecycleException("Can not stop server. Server is not started");
+ }
try
{
removeFailedUnDeployments();
}
catch (Exception e)
{
- throw new LifecycleException("Could not clean up", e);
+ throw new LifecycleException("Could not clean up failed undeployments", e);
}
- if (wasStarted)
+
+ try
{
- stopServer();
+ manager.stopServer(server.getName());
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not stop server", e);
}
}
@@ -132,16 +123,16 @@
{
throw new IllegalArgumentException("Archive must be specified");
}
- if (manager == null || server == null)
+ if (manager == null)
{
- throw new IllegalStateException("start has not been called!");
+ throw new IllegalStateException("Container has not been setup");
}
final String deploymentName = archive.getName();
File file = new File(deploymentName);
archive.as(ZipExporter.class).exportZip(file, true);
- Exception failure = null;
+ Server server = manager.getServer(configuration.getProfileName());
try
{
server.deploy(file);
@@ -150,10 +141,6 @@
{
throw new DeploymentException("Could not deploy " + deploymentName, e);
}
- if (failure != null)
- {
- throw new DeploymentException("Failed to deploy " + deploymentName, failure);
- }
try
{
return new ServletMethodExecutor(new URL(server.getHttpUrl().toExternalForm() + "/"));
@@ -173,13 +160,14 @@
{
throw new IllegalArgumentException("Archive must be specified");
}
+ // we only need the File, not the content to undeploy.
File file = new File(archive.getName());
- archive.as(ZipExporter.class).exportZip(file, true);
undeploy(file);
}
private void undeploy(File file) throws DeploymentException
{
+ Server server = manager.getServer(configuration.getProfileName());
try
{
server.undeploy(file);
@@ -197,14 +185,14 @@
private void removeFailedUnDeployments() throws IOException
{
+ Server server = manager.getServer(configuration.getProfileName());
+
List<String> remainingDeployments = new ArrayList<String>();
for (String name : failedUndeployments)
{
-
try
{
server.undeploy(new File(name));
-
}
catch (Exception e)
{
@@ -215,19 +203,18 @@
}
if (remainingDeployments.size() > 0)
{
- log.error("Failed to undeploy these artifacts: " + remainingDeployments);
+ log.severe("Failed to undeploy these artifacts: " + remainingDeployments);
}
failedUndeployments.clear();
}
- protected void startServerManager()
+ /*
+ * Internal Helpers for Creating and Configuring ServerManager and Server.
+ */
+
+ private ServerManager createAndConfigureServerManager()
{
- manager = getDelegate().getServerManager();
- server = new Server();
- server.setName(profile);
- server.setHttpPort(port);
- server.setHost(host);
-
+ ServerManager manager = new ServerManager();
if(configuration.getJbossHome() != null)
{
manager.setJbossHome(configuration.getJbossHome());
@@ -236,123 +223,44 @@
{
manager.setJavaHome(configuration.getJavaHome());
}
-
- AsLifecycleDelegate.applyServerDefaults(server, manager);
+ manager.addServer(createAndConfigureServer());
+ return manager;
}
- protected void restartServer() throws IOException, LifecycleException
+ private Server createAndConfigureServer()
{
- if (getForceRestart())
- {
- if (isServerUp())
- {
- log.info("Shutting down server as in force-restart mode");
- stopServer();
- 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.info("Unable to connect to server after " + getServerBootTimeout() + "ms, giving up!");
- stopServer();
- throw new IllegalStateException("Error connecting to server");
- }
- }
+ Server server = new Server();
+ server.setName(configuration.getProfileName());
+ server.setHttpPort(configuration.getHttpPort());
+ server.setHost(configuration.getBindAddress());
+
+ server.setUsername("admin");
+ server.setPassword("admin");
+ server.setPartition(Long.toHexString(System.currentTimeMillis()));
- protected void stopServer() throws LifecycleException
- {
- try
- {
- getDelegate().stopJbossAs(profile);
- }
- catch (Throwable t)
- {
- throw new LifecycleException("could not stop local container", t);
- }
- }
+ // Set server's JVM arguments
+ setServerVMArgs(server, configuration.getJavaVmArguments());
- private void startServer() throws LifecycleException
- {
- try
- {
- getDelegate().startJbossAs(profile);
- }
- catch (Throwable t)
- {
- throw new LifecycleException("could not start local container", t);
- }
+ // Set server's system properties
+ Property prop = new Property();
+ prop.setKey("jbosstest.udp.ip_ttl");
+ prop.setValue("0");
+ server.addSysProperty(prop);
+ prop = new Property();
+ prop.setKey("java.endorsed.dirs");
+ prop.setValue(new File(configuration.getJbossHome(), "lib/endorsed").getAbsolutePath());
+ server.addSysProperty(prop);
+
+ return server;
}
- protected boolean isServerUp() throws IOException
+ private void setServerVMArgs(Server server, String arguments)
{
- return ServerController.isServerStarted(server);
- }
-
- protected synchronized static AsLifecycleDelegate getDelegate()
- {
- if (delegate == null)
+ for(String argument: arguments.split(" "))
{
- delegate = new AsLifecycleDelegate();
+ Argument arg = new Argument();
+ arg.setValue(argument);
+ server.addJvmArg(arg);
}
- return delegate;
}
-
- protected String getHost()
- {
- return host;
- }
-
- protected boolean getForceRestart()
- {
- return forceRestart;
- }
-
- protected int getShutdownDelay()
- {
- return shutdownDelay;
- }
-
- protected int getServerBootTimeout()
- {
- return bootTimeout;
- }
-
- protected int getPort()
- {
- return port;
- }
}
Modified: arquillian/trunk/containers/jbossas-managed-5.1/src/test/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASIntegrationTestCase.java
===================================================================
--- arquillian/trunk/containers/jbossas-managed-5.1/src/test/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASIntegrationTestCase.java 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-5.1/src/test/java/org/jboss/arquillian/container/jbossas/managed_5_1/JBossASIntegrationTestCase.java 2010-07-21 08:59:05 UTC (rev 4789)
@@ -36,7 +36,7 @@
* @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
* @version $Revision: $
*/
- at Ignore // TODO: Add auto extract of 5.1 container. No Maven based dist for 5.1, download from sourceforge?
+//@Ignore // TODO: Add auto extract of 5.1 container. No Maven based dist for 5.1, download from sourceforge?
@RunWith(Arquillian.class)
public class JBossASIntegrationTestCase
{
Modified: arquillian/trunk/containers/jbossas-managed-5.1/src/test/resources/arquillian.xml
===================================================================
--- arquillian/trunk/containers/jbossas-managed-5.1/src/test/resources/arquillian.xml 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-5.1/src/test/resources/arquillian.xml 2010-07-21 08:59:05 UTC (rev 4789)
@@ -2,13 +2,13 @@
<arquillian xmlns="http://jboss.com/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jboss="urn:arq:org.jboss.arquillian.jboss">
+ xmlns:jboss="urn:arq:org.jboss.arquillian.container.jbossas.managed_5_1">
<jboss:container>
<jbossHome>/home/aslak/dev/servers/jboss-5.1.0.GA/</jbossHome>
<javaHome>/usr/lib/jvm/java-6-openjdk</javaHome>
<bindAddress>127.0.0.1</bindAddress>
- <httpPort>8181</httpPort> <!-- WARN: this is not the bind port, but connect port. Bind port must be set in jboss xml config -->
+ <httpPort>8080</httpPort> <!-- WARN: this is not the bind port, but connect port. Bind port must be set in jboss xml config -->
</jboss:container>
</arquillian>
\ No newline at end of file
Modified: arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASConfiguration.java
===================================================================
--- arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASConfiguration.java 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASConfiguration.java 2010-07-21 08:59:05 UTC (rev 4789)
@@ -36,9 +36,12 @@
private String profileName = "default";
- private String jbossHome = null;
+ //
+ private String jbossHome = System.getenv("JBOSS_HOME");
- private String javaHome = null;
+ private String javaHome = System.getenv("JAVA_HOME");
+
+ private String javaVmArguments = "-Xmx512m -XX:MaxPermSize=128m";
public ContainerProfile getContainerProfile()
{
@@ -105,4 +108,19 @@
{
return javaHome;
}
+
+ /**
+ * This will override the default ("-Xmx512m -XX:MaxPermSize=128m") startup JVM arguments.
+ *
+ * @param javaVmArguments use as start up arguments
+ */
+ public void setJavaVmArguments(String javaVmArguments)
+ {
+ this.javaVmArguments = javaVmArguments;
+ }
+
+ public String getJavaVmArguments()
+ {
+ return javaVmArguments;
+ }
}
Modified: arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASLocalContainer.java
===================================================================
--- arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASLocalContainer.java 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-6/src/main/java/org/jboss/arquillian/container/jbossas/managed_6/JBossASLocalContainer.java 2010-07-21 08:59:05 UTC (rev 4789)
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.logging.Logger;
-import org.jboss.arquillian.container.jbossas.managed_6.utils.AsLifecycleDelegate;
import org.jboss.arquillian.protocol.servlet_3.ServletMethodExecutor;
import org.jboss.arquillian.spi.Configuration;
import org.jboss.arquillian.spi.ContainerMethodExecutor;
@@ -31,6 +30,8 @@
import org.jboss.arquillian.spi.DeployableContainer;
import org.jboss.arquillian.spi.DeploymentException;
import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.jbossas.servermanager.Argument;
+import org.jboss.jbossas.servermanager.Property;
import org.jboss.jbossas.servermanager.Server;
import org.jboss.jbossas.servermanager.ServerController;
import org.jboss.jbossas.servermanager.ServerManager;
@@ -47,46 +48,22 @@
{
private static Logger log = Logger.getLogger(JBossASLocalContainer.class.getName());
- private static AsLifecycleDelegate delegate;
+ private JBossASConfiguration configuration;
- protected Server server;
-
protected ServerManager manager;
- private boolean wasStarted;
-
private final List<String> failedUndeployments = new ArrayList<String>();
- private Boolean forceRestart = false;
-
- private Integer shutdownDelay = 15000;
-
- private Long bootTimeout = 240000L;
-
- private String host = "localhost";
-
- private int port = 8181;
-
- private String profile = "default";
-
- private JBossASConfiguration configuration;
-
- public JBossASLocalContainer()
- {
-
- }
-
/* (non-Javadoc)
* @see org.jboss.arquillian.spi.DeployableContainer#setup(org.jboss.arquillian.spi.Context, org.jboss.arquillian.spi.Configuration)
*/
public void setup(Context context, Configuration configuration)
{
this.configuration = configuration.getContainerConfig(JBossASConfiguration.class);
- host = this.configuration.getBindAddress();
- profile = this.configuration.getProfileName();
- port = this.configuration.getHttpPort();
+
+ manager = createAndConfigureServerManager();
}
-
+
/* (non-Javadoc)
* @see org.jboss.arquillian.spi.DeployableContainer#start(org.jboss.arquillian.spi.Context)
*/
@@ -94,8 +71,13 @@
{
try
{
- startServerManager();
- restartServer();
+ Server server = manager.getServer(configuration.getProfileName());
+ if(ServerController.isServerStarted(server))
+ {
+ throw new LifecycleException("Could not start server, server is already running");
+ }
+
+ manager.startServer(server.getName());
}
catch (IOException e)
{
@@ -108,17 +90,27 @@
*/
public void stop(Context context) throws LifecycleException
{
+ Server server = manager.getServer(configuration.getProfileName());
+ if(!server.isRunning())
+ {
+ throw new LifecycleException("Can not stop server. Server is not started");
+ }
try
{
removeFailedUnDeployments();
}
catch (Exception e)
{
- throw new LifecycleException("Could not clean up", e);
+ throw new LifecycleException("Could not clean up failed undeployments", e);
}
- if (wasStarted)
+
+ try
{
- stopServer();
+ manager.stopServer(server.getName());
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not stop server", e);
}
}
@@ -131,16 +123,16 @@
{
throw new IllegalArgumentException("Archive must be specified");
}
- if (manager == null || server == null)
+ if (manager == null)
{
- throw new IllegalStateException("start has not been called!");
+ throw new IllegalStateException("Container has not been setup");
}
final String deploymentName = archive.getName();
File file = new File(deploymentName);
archive.as(ZipExporter.class).exportZip(file, true);
- Exception failure = null;
+ Server server = manager.getServer(configuration.getProfileName());
try
{
server.deploy(file);
@@ -149,10 +141,6 @@
{
throw new DeploymentException("Could not deploy " + deploymentName, e);
}
- if (failure != null)
- {
- throw new DeploymentException("Failed to deploy " + deploymentName, failure);
- }
try
{
return new ServletMethodExecutor(new URL(server.getHttpUrl().toExternalForm() + "/"));
@@ -172,13 +160,14 @@
{
throw new IllegalArgumentException("Archive must be specified");
}
+ // we only need the File, not the content to undeploy.
File file = new File(archive.getName());
- archive.as(ZipExporter.class).exportZip(file, true);
undeploy(file);
}
private void undeploy(File file) throws DeploymentException
{
+ Server server = manager.getServer(configuration.getProfileName());
try
{
server.undeploy(file);
@@ -196,14 +185,14 @@
private void removeFailedUnDeployments() throws IOException
{
+ Server server = manager.getServer(configuration.getProfileName());
+
List<String> remainingDeployments = new ArrayList<String>();
for (String name : failedUndeployments)
{
-
try
{
server.undeploy(new File(name));
-
}
catch (Exception e)
{
@@ -219,14 +208,13 @@
failedUndeployments.clear();
}
- protected void startServerManager()
+ /*
+ * Internal Helpers for Creating and Configuring ServerManager and Server.
+ */
+
+ private ServerManager createAndConfigureServerManager()
{
- manager = getDelegate().getServerManager();
- server = new Server();
- server.setName(profile);
- server.setHttpPort(port);
- server.setHost(host);
-
+ ServerManager manager = new ServerManager();
if(configuration.getJbossHome() != null)
{
manager.setJbossHome(configuration.getJbossHome());
@@ -235,123 +223,44 @@
{
manager.setJavaHome(configuration.getJavaHome());
}
-
- AsLifecycleDelegate.applyServerDefaults(server, manager);
+ manager.addServer(createAndConfigureServer());
+ return manager;
}
- protected void restartServer() throws IOException, LifecycleException
+ private Server createAndConfigureServer()
{
- if (getForceRestart())
- {
- if (isServerUp())
- {
- log.info("Shutting down server as in force-restart mode");
- stopServer();
- 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.info("Unable to connect to server after " + getServerBootTimeout() + "ms, giving up!");
- stopServer();
- throw new IllegalStateException("Error connecting to server");
- }
- }
+ Server server = new Server();
+ server.setName(configuration.getProfileName());
+ server.setHttpPort(configuration.getHttpPort());
+ server.setHost(configuration.getBindAddress());
+
+ server.setUsername("admin");
+ server.setPassword("admin");
+ server.setPartition(Long.toHexString(System.currentTimeMillis()));
- protected void stopServer() throws LifecycleException
- {
- try
- {
- getDelegate().stopJbossAs(profile);
- }
- catch (Throwable t)
- {
- throw new LifecycleException("could not stop local container", t);
- }
- }
+ // Set server's JVM arguments
+ setServerVMArgs(server, configuration.getJavaVmArguments());
- private void startServer() throws LifecycleException
- {
- try
- {
- getDelegate().startJbossAs(profile);
- }
- catch (Throwable t)
- {
- throw new LifecycleException("could not start local container", t);
- }
+ // Set server's system properties
+ Property prop = new Property();
+ prop.setKey("jbosstest.udp.ip_ttl");
+ prop.setValue("0");
+ server.addSysProperty(prop);
+ prop = new Property();
+ prop.setKey("java.endorsed.dirs");
+ prop.setValue(new File(configuration.getJbossHome(), "lib/endorsed").getAbsolutePath());
+ server.addSysProperty(prop);
+
+ return server;
}
- protected boolean isServerUp() throws IOException
+ private void setServerVMArgs(Server server, String arguments)
{
- return ServerController.isServerStarted(server);
- }
-
- protected synchronized static AsLifecycleDelegate getDelegate()
- {
- if (delegate == null)
+ for(String argument: arguments.split(" "))
{
- delegate = new AsLifecycleDelegate();
+ Argument arg = new Argument();
+ arg.setValue(argument);
+ server.addJvmArg(arg);
}
- return delegate;
}
-
- protected String getHost()
- {
- return host;
- }
-
- protected Boolean getForceRestart()
- {
- return forceRestart;
- }
-
- protected Integer getShutdownDelay()
- {
- return shutdownDelay;
- }
-
- protected Long getServerBootTimeout()
- {
- return bootTimeout;
- }
-
- public int getPort()
- {
- return port;
- }
}
Modified: arquillian/trunk/containers/jbossas-managed-6/src/test/resources/arquillian.xml
===================================================================
--- arquillian/trunk/containers/jbossas-managed-6/src/test/resources/arquillian.xml 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/containers/jbossas-managed-6/src/test/resources/arquillian.xml 2010-07-21 08:59:05 UTC (rev 4789)
@@ -7,6 +7,7 @@
<jboss:container>
<jbossHome>target/jboss-6.0.0.20100429-M3</jbossHome>
<!-- <javaHome>/usr/lib/jvm/java-6-openjdk</javaHome> Will default o JAVA_HOME-->
+ <javaHome>/usr/lib/jvm/java-6-openjdk</javaHome>
<bindAddress>127.0.0.1</bindAddress>
<httpPort>8080</httpPort> <!-- WARN: this is not the bind port, but connect port. Bind port must be set in jboss xml config -->
</jboss:container>
Modified: arquillian/trunk/protocols/servlet-2.5/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager
===================================================================
--- arquillian/trunk/protocols/servlet-2.5/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager 2010-07-20 16:42:23 UTC (rev 4788)
+++ arquillian/trunk/protocols/servlet-2.5/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager 2010-07-21 08:59:05 UTC (rev 4789)
@@ -1 +1 @@
-org.jboss.arquillian.protocol.servlet.ServletProtocolDeploymentPackager
\ No newline at end of file
+org.jboss.arquillian.protocol.servlet_2_5.ServletProtocolDeploymentPackager
\ No newline at end of file
More information about the jboss-svn-commits
mailing list