[jboss-cvs] JBossAS SVN: r107578 - in trunk: testsuite/imports/sections and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 12 23:53:44 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-08-12 23:53:44 -0400 (Thu, 12 Aug 2010)
New Revision: 107578
Modified:
trunk/system/src/main/java/org/jboss/system/server/profileservice/deployers/VDFDeploymentBuilder.java
trunk/testsuite/imports/sections/cluster.xml
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeploymentRepoAddContentTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHotDeployUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterStartupTestCase.java
Log:
[JBAS-8328] Fix (thanks to E. Muckenhuber) + beef up testsuite to include zipped archives
Modified: trunk/system/src/main/java/org/jboss/system/server/profileservice/deployers/VDFDeploymentBuilder.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/profileservice/deployers/VDFDeploymentBuilder.java 2010-08-13 03:44:02 UTC (rev 107577)
+++ trunk/system/src/main/java/org/jboss/system/server/profileservice/deployers/VDFDeploymentBuilder.java 2010-08-13 03:53:44 UTC (rev 107578)
@@ -21,14 +21,17 @@
*/
package org.jboss.system.server.profileservice.deployers;
-import java.util.ArrayList;
-import java.util.List;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.profileservice.deployment.DeploymentBuilder;
import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.system.server.profileservice.repository.LegacyProfileDeploymentFactory.WorkaroundProfileDeployment;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
/**
@@ -47,19 +50,15 @@
/** The vfs deployment factory. */
private static final VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
-
- /** The attachment processor. */
- private final List<DeploymentAttachmentsProcessor<Deployment>> attachmentProcessors = new ArrayList<DeploymentAttachmentsProcessor<Deployment>>();
+ private final StructureMetaDataBuilder deploymentProcessor = new StructureMetaDataBuilder();
+
public static VDFDeploymentBuilder getInstance()
{
return instance;
}
- protected VDFDeploymentBuilder()
- {
- attachmentProcessors.add(new StructureMetaDataBuilder());
- }
+ private VDFDeploymentBuilder() { }
public Deployment createDeployment(ProfileDeployment profileDeployment)
{
@@ -70,21 +69,24 @@
}
else
{
- d = deploymentFactory.createVFSDeployment(profileDeployment.getName(), profileDeployment.getRoot());
+ VirtualFile vf = profileDeployment.getRoot();
+ // The ones created using the {@code AutoUnmounter}
+ if(profileDeployment instanceof WorkaroundProfileDeployment)
+ {
+ try
+ {
+ vf = VFS.getChild(new URI(profileDeployment.getName()));
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ d = deploymentFactory.createVFSDeployment(profileDeployment.getName(), vf);
}
- for(DeploymentAttachmentsProcessor<Deployment> processor : attachmentProcessors)
- {
- processor.processDeployment(profileDeployment, d);
- }
+
+ deploymentProcessor.processDeployment(profileDeployment, d);
return d;
}
-
- public void addAttachmentsProcessor(DeploymentAttachmentsProcessor<Deployment> processor)
- {
- synchronized(attachmentProcessors)
- {
- attachmentProcessors.add(processor);
- }
- }
}
Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml 2010-08-13 03:44:02 UTC (rev 107577)
+++ trunk/testsuite/imports/sections/cluster.xml 2010-08-13 03:53:44 UTC (rev 107578)
@@ -60,16 +60,34 @@
</fileset>
</jar>
- <!-- MBeans for testing Clustered DeploymentRepository additions -->
+ <!-- Deployments for testing Clustered DeploymentRepository (i.e. farming) -->
<copy todir="${build.lib}" overwrite="true">
<fileset dir="${build.resources}/cluster/profileservice"/>
- </copy>
-
- <!-- MBeans for testing Clustered DeploymentRepository additions -->
- <copy todir="${build.lib}" overwrite="true">
<fileset dir="${build.resources}/cluster/farm/hotdeploy"/>
</copy>
+
+ <mkdir dir="${build.resources}/test-configs/cluster-profilesvc-0/farm"/>
+ <mkdir dir="${build.resources}/test-configs/cluster-profilesvc-1/farm"/>
+
+ <war warfile="${build.resources}/test-configs/cluster-profilesvc-0/farm/farmE.war">
+ <fileset dir="${source.resources}/test-configs/cluster-profilesvc-0/farm/farmA.war">
+ <include name="**/*"/>
+ </fileset>
+ </war>
+ <war warfile="${build.resources}/test-configs/cluster-profilesvc-1/farm/farmF.war">
+ <fileset dir="${source.resources}/test-configs/cluster-profilesvc-1/farm/farmB.war">
+ <include name="**/*"/>
+ </fileset>
+ </war>
+
+ <copy file="${build.resources}/test-configs/cluster-profilesvc-0/farm/farmE.war"
+ tofile="${build.lib}/hd-add-zipped.war"/>
+
+ <copy file="${build.lib}/hd-add-zipped.war" tofile="${build.lib}/hd-mod-zipped.war"/>
+ <copy file="${build.lib}/hd-mod-zipped.war" tofile="${build.resources}/test-configs/cluster-profilesvc-0/farm/hd-mod-zipped.war"/>
+ <copy file="${build.lib}/hd-mod-zipped.war" tofile="${build.resources}/test-configs/cluster-profilesvc-1/farm/hd-mod-zipped.war"/>
+
<!-- MC beans for testing partition restart -->
<copy todir="${build.lib}"
file="${build.resources}/cluster/partition/partition-restart-jboss-beans.xml"
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeploymentRepoAddContentTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeploymentRepoAddContentTestCase.java 2010-08-13 03:44:02 UTC (rev 107577)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeploymentRepoAddContentTestCase.java 2010-08-13 03:53:44 UTC (rev 107578)
@@ -44,11 +44,9 @@
import org.jboss.test.JBossClusteredTestCase;
/**
+ * Tests adding content to the farm deployment repo via the ProfileService API.
*
- *
* @author Brian Stansberry
- *
- * @version $Revision: $
*/
public class ClusteredDeploymentRepoAddContentTestCase
extends JBossClusteredTestCase implements ProgressListener
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHotDeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHotDeployUnitTestCase.java 2010-08-13 03:44:02 UTC (rev 107577)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterHotDeployUnitTestCase.java 2010-08-13 03:53:44 UTC (rev 107578)
@@ -27,6 +27,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.util.Properties;
import javax.management.MBeanServerConnection;
@@ -34,6 +35,8 @@
import javax.naming.Context;
import javax.naming.InitialContext;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
@@ -43,6 +46,9 @@
import org.jboss.test.JBossClusteredTestCase;
/**
+ * Tests hot deployment of farm/ folder content updated by direct manipulation
+ * of the filesystem.
+ *
* @author Brian Stansberry
*
*/
@@ -102,6 +108,9 @@
// New dir
checkContentRemoved("jboss.system:service=HDAddDirTestThreadPool", 0);
+ // New zip
+ checkWebContent("/hd-add-zipped/index.html", HttpURLConnection.HTTP_NOT_FOUND, 0);
+
// Simple removal
checkContent("jboss.system:service=HDRemoveTestThreadPool", "RemoveFarmThreadPool", 0);
@@ -115,7 +124,10 @@
checkContent("jboss.system:service=HDModifyNestedTestThreadPool", "UnmodifiedNestedFarmThreadPool", 0);
// Simple mod
- checkContent("jboss.system:service=HDModifyTestThreadPool", "UnmodifiedFarmThreadPool", 0);
+ checkContent("jboss.system:service=HDModifyTestThreadPool", "UnmodifiedFarmThreadPool", 0);
+
+ // Zipped mod
+ checkWebContent("/hd-mod-zipped/index.html", HttpURLConnection.HTTP_OK, 0);
}
private void performModifications() throws Exception
@@ -123,6 +135,9 @@
// Simple add
copyFile(farmDir, "hd-add-deployment-service.xml");
+ // Add of zipped content
+ copyFile(farmDir, "hd-add-zipped.war");
+
// Nested add
File dir = new File(farmDir, "hd-nestedAdd");
dir.mkdir();
@@ -133,6 +148,9 @@
dir.mkdir();
copyFile(dir, "hd-add-dir-deployment-service.xml");
+ // Add of zipped content
+ copyFile(farmDir, "hd-add-zipped.war");
+
// Simple removal
File toRemove = new File(farmDir, "hd-remove-deployment-service.xml");
removeFile(toRemove);
@@ -169,6 +187,9 @@
// New dir
checkContent("jboss.system:service=HDAddDirTestThreadPool", "AddDirFarmThreadPool", 0);
+ // New zip
+ checkWebContent("/hd-add-zipped/index.html", HttpURLConnection.HTTP_OK, 0);
+
// Simple removal
checkContentRemoved("jboss.system:service=HDRemoveTestThreadPool", 0);
@@ -183,6 +204,9 @@
// Simple mod
checkContent("jboss.system:service=HDModifyTestThreadPool", "ModifiedFarmThreadPool", 0);
+
+ // Zipped mod
+ checkWebContent("/hd-mod-zipped/index.html", HttpURLConnection.HTTP_OK, 0);
}
/**
@@ -353,6 +377,48 @@
assertTrue(objectName + " -- node1 OK", node1OK);
}
+ private void checkWebContent(String relativePath, int expectedResponse, long timeout) throws Exception
+ {
+ boolean node0OK = false;
+ boolean node1OK = false;
+
+ String[] hosts = getHttpURLs();
+ GetMethod get0 = new GetMethod(hosts[0] + relativePath);
+ GetMethod get1 = new GetMethod(hosts[1] + relativePath);
+
+ long deadline = System.currentTimeMillis() + timeout;
+ do
+ {
+ if (!node0OK)
+ {
+ try
+ {
+ node0OK = (new HttpClient().executeMethod(get0) == expectedResponse);
+ }
+ catch (Exception ignored) {}
+ }
+ if (!node1OK)
+ {
+ try
+ {
+ node1OK = (new HttpClient().executeMethod(get1) == expectedResponse);
+ }
+ catch (Exception ignored) {}
+ }
+
+ if (node0OK && node1OK)
+ {
+ break;
+ }
+
+ Thread.sleep(200);
+ }
+ while (System.currentTimeMillis() < deadline);
+
+ assertTrue(hosts[0] + relativePath + " -- node0 OK", node0OK);
+ assertTrue(hosts[1] + relativePath + " -- node1 OK", node1OK);
+ }
+
/**
* Does some file copies into the dirs the test normally uses.
* Just a tool for debugging
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterStartupTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterStartupTestCase.java 2010-08-13 03:44:02 UTC (rev 107577)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/FarmedClusterStartupTestCase.java 2010-08-13 03:53:44 UTC (rev 107578)
@@ -70,11 +70,21 @@
assertEquals("Node1FarmThreadPool", adaptors[1].getAttribute(oname, "Name"));
}
+ /**
+ * Confirms an exploded war replicated from node0 to node1
+ *
+ * @throws Exception
+ */
public void testFarmAWar() throws Exception
{
checkAvailable("/farmA/index.html");
}
+ /**
+ * Confirms an exploded war replicated from node1 to node0
+ *
+ * @throws Exception
+ */
public void testFarmBWar() throws Exception
{
checkAvailable("/farmB/index.html");
@@ -96,8 +106,28 @@
GetMethod get = new GetMethod(getHttpURLs()[0] +index);
assertEquals("farmD is unavailable on node0", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
get = new GetMethod(getHttpURLs()[1] +index);
- assertEquals("farmD is unavailable on node0", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
+ assertEquals("farmD is unavailable on node1", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
}
+
+ /**
+ * Confirms a zipped war replicated from node0 to node1
+ *
+ * @throws Exception
+ */
+ public void testFarmEWar() throws Exception
+ {
+ checkAvailable("/farmE/index.html");
+ }
+
+ /**
+ * Confirms a zipped war replicated from node1 to node0
+ *
+ * @throws Exception
+ */
+ public void testFarmFWar() throws Exception
+ {
+ checkAvailable("/farmF/index.html");
+ }
private void checkAvailable(String url) throws Exception, IOException, HttpException
{
@@ -106,6 +136,6 @@
GetMethod get = new GetMethod(getHttpURLs()[0] +url);
assertEquals(url + " is available on node0", HttpURLConnection.HTTP_OK, client.executeMethod(get));
get = new GetMethod(getHttpURLs()[1] +url);
- assertEquals(url + " is available on node0", HttpURLConnection.HTTP_OK, client.executeMethod(get));
+ assertEquals(url + " is available on node1", HttpURLConnection.HTTP_OK, client.executeMethod(get));
}
}
More information about the jboss-cvs-commits
mailing list