[jboss-cvs] JBossAS SVN: r94299 - branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 2 17:08:48 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-10-02 17:08:48 -0400 (Fri, 02 Oct 2009)
New Revision: 94299
Modified:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHugeDeploymentUnitTestCase.java
Log:
[JBAS-7102] Be a good boy and tidy up a bit
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHugeDeploymentUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHugeDeploymentUnitTestCase.java 2009-10-02 20:59:54 UTC (rev 94298)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHugeDeploymentUnitTestCase.java 2009-10-02 21:08:48 UTC (rev 94299)
@@ -57,7 +57,8 @@
public static final ProfileKey farmProfile = new ProfileKey("farm");
public static final String SCANNER_ONAME = "jboss.deployment:flavor=URL,type=DeploymentScanner";
private ManagementView activeView;
- private File farmDir;
+ private File farm0Dir;
+ private File farm1Dir;
/**
* Create a new FarmedClusterHotDeployUnitTestCase.
@@ -67,20 +68,69 @@
public FarmedClusterHugeDeploymentUnitTestCase(String name)
{
super(name);
- }
+ }
- public void testFarmHotDeployment() throws Exception
+ @Override
+ protected void setUp() throws Exception
{
+ super.setUp();
+
ManagementView mgtView = getManagementView(getNamingContext(0));
ComponentType type = new ComponentType("MCBean", "ServerConfig");
ManagedComponent mc = mgtView.getComponent("jboss.system:type=ServerConfig", type);
- assertNotNull(mc);
+ if (mc == null)
+ {
+ throw new IllegalStateException("No ServerConfig for node0 available");
+ }
String homeDir = (String) ((SimpleValue) mc.getProperty("serverHomeDir").getValue()).getValue();
- assertNotNull(homeDir);
+ if (homeDir == null)
+ {
+ throw new IllegalStateException("No serverHomeDir for node0 available");
+ }
- this.farmDir = new File(homeDir, "farm");
- assertTrue(farmDir + " exists", farmDir.exists());
+ this.farm0Dir = new File(homeDir, "farm");
+ mgtView = getManagementView(getNamingContext(1));
+ mc = mgtView.getComponent("jboss.system:type=ServerConfig", type);
+ if (mc == null)
+ {
+ throw new IllegalStateException("No ServerConfig for node1 available");
+ }
+ homeDir = (String) ((SimpleValue) mc.getProperty("serverHomeDir").getValue()).getValue();
+ if (homeDir == null)
+ {
+ throw new IllegalStateException("No serverHomeDir for node1 available");
+ }
+
+ this.farm1Dir = new File(homeDir, "farm");
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ super.tearDown();
+ }
+ finally
+ {
+ // Be a good boy and delete the huge files.
+ try
+ {
+ deleteHugeFile(farm0Dir);
+ }
+ finally
+ {
+ deleteHugeFile(farm1Dir);
+ }
+ }
+ }
+
+ public void testFarmHotDeployment() throws Exception
+ {
+ assertTrue(farm0Dir + " exists", farm0Dir.exists());
+
ObjectName scanner = new ObjectName(SCANNER_ONAME);
try
{
@@ -99,7 +149,7 @@
private void performModifications() throws Exception
{
// Create a war
- File dir = new File(farmDir, "huge.war");
+ File dir = new File(farm0Dir, "huge.war");
dir.mkdir();
// Add a file we can request to verify deployment
@@ -109,8 +159,9 @@
File huge = new File(dir, "huge.bin");
FileOutputStream fos = new FileOutputStream(huge);
BufferedOutputStream bos = new BufferedOutputStream(fos);
- for (int i = 0; i < 150 * 1024 * 1024; i++)
- bos.write(i);
+ int count = 150 * 1024 * 1024 / 4096;
+ for (int i = 0; i < count; i++)
+ bos.write(new byte[4096]);
bos.close();
// Add the deployment descriptor
@@ -144,7 +195,7 @@
node1ok = makeGet(client, getHttpURLs()[1] + "/huge/index.html", expectContent);
}
- if (System.nanoTime() - start > timeout)
+ if ((node0ok && node1ok) || (System.nanoTime() - start > timeout))
{
break;
}
@@ -253,4 +304,21 @@
}
}
+
+ private void deleteHugeFile(File farmDir)
+ {
+ if (farmDir.exists())
+ {
+ File war = new File(farmDir, "huge.war");
+ if (war.exists())
+ {
+ File huge = new File(war, "huge.bin");
+ if (huge.exists() && !huge.delete())
+ {
+ huge.deleteOnExit();
+ }
+ }
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list