[jboss-cvs] JBossAS SVN: r86164 - in branches/Branch_5_x: testsuite/src/main/org/jboss/test/deployers and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Mar 20 11:12:21 EDT 2009
Author: emuckenhuber
Date: 2009-03-20 11:12:21 -0400 (Fri, 20 Mar 2009)
New Revision: 86164
Modified:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java
Log:
[JBAS-5993] fix overriding deployments on distribute.
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java 2009-03-20 14:28:18 UTC (rev 86163)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java 2009-03-20 15:12:21 UTC (rev 86164)
@@ -238,20 +238,19 @@
{
boolean attach = true;
long lastModified = metaData.getLastModified();
- // Check exploded directories.
- // TODO recursive checks
- if(root.isLeaf() == true && root.isArchive() == false)
+ // Check directory
+ if(root.isLeaf() == false && root.isArchive() == false)
{
+ // TODO recursive checks
DeploymentStructureMetaData structure = metaData.getDeploymentStructure();
if(checkMetaDataModifications(root, structure, lastModified) == false)
return false;
}
else
{
+ // Otherwise we only check the root
if(lastModified < root.getLastModified())
- {
- return false;
- }
+ return false;
}
return attach;
}
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java 2009-03-20 14:28:18 UTC (rev 86163)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java 2009-03-20 15:12:21 UTC (rev 86164)
@@ -22,6 +22,7 @@
package org.jboss.system.server.profileservice.repository;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -57,7 +58,7 @@
/** Allowed deployments filter. */
private VirtualFileFilter deploymentFilter;
- /** The application phase deployment files keyed by VirtualFile URI string. */
+ /** The application files keyed by VirtualFile URI string. */
private final Map<String, VirtualFile> applicationVFCache = new ConcurrentHashMap<String, VirtualFile>();
/** The last time the profile was modified. */
@@ -118,8 +119,6 @@
public void addDeployment(String vfsPath, ProfileDeployment d) throws Exception
{
- if(vfsPath == null)
- throw new IllegalArgumentException("Null vfsPath");
if(d == null)
throw new IllegalArgumentException("Null deployment");
@@ -250,6 +249,13 @@
{
return new AbstractProfileDeployment(vf);
}
+
+ protected String addVirtualFileCache(VirtualFile vf) throws MalformedURLException, URISyntaxException
+ {
+ String uri = vf.toURI().toString();
+ this.applicationVFCache.put(uri, vf);
+ return uri;
+ }
protected VirtualFile getCachedVirtualFile(String name)
{
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java 2009-03-20 14:28:18 UTC (rev 86163)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java 2009-03-20 15:12:21 UTC (rev 86164)
@@ -67,6 +67,16 @@
super(key, uris);
}
+ public boolean isFailIfAlreadyExists()
+ {
+ return failIfAlreadyExists;
+ }
+
+ public void setFailIfAlreadyExists(boolean failIfAlreadyExists)
+ {
+ this.failIfAlreadyExists = failIfAlreadyExists;
+ }
+
/**
* Get the structure modified checker.
*
@@ -120,8 +130,12 @@
throw new FileNotFoundException("Failed to obtain content dir for phase: "+vfsPath);
File contentFile = new File(contentRoot, vfsPath);
- if(failIfAlreadyExists && contentFile.exists())
+ // Check if it already exists
+ boolean exists = contentFile.exists();
+ if(exists && isFailIfAlreadyExists())
throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
+
+ // Copy streams
FileOutputStream fos = new FileOutputStream(contentFile);
try
{
@@ -138,8 +152,12 @@
VirtualFile contentVF = VFS.getRoot(contentFile.toURI());
try
{
- contentVF = getCachedVirtualFile(contentVF.toURI());
- repositoryName = contentVF.toURI().toString();
+ // Add the new virtual file to the cache
+ repositoryName = addVirtualFileCache(contentVF);
+
+ // If exists do a cleanup
+ if(exists)
+ getChecker().removeStructureRoot(contentVF);
}
catch(URISyntaxException e)
{
@@ -210,7 +228,8 @@
log.trace(pathName + " was removed");
}
// Check for modification
- else if (getChecker().hasStructureBeenModified(root) || hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED))
+ else if (hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED)
+ || getChecker().hasStructureBeenModified(root))
{
long rootLastModified = root.getLastModified();
if (trace)
@@ -263,8 +282,14 @@
// Remove the deployment from the filesystem
ProfileDeployment deployment = getDeployment(vfsPath);
VirtualFile root = deployment.getRoot();
+
+ // Delete the file
if(root.delete() == false)
throw new IOException("Failed to delete: " + root);
+
+ // Remove the deployment from the structure checker.
+ getChecker().removeStructureRoot(root);
+
// Cleanup
return super.removeDeployment(deployment.getName());
}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java 2009-03-20 14:28:18 UTC (rev 86163)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java 2009-03-20 15:12:21 UTC (rev 86164)
@@ -34,9 +34,12 @@
*/
public class DeploymentManagerUnitTestCase extends JBossTestCase
{
-
+ /** A basic failing deployment. */
final static String FAILING_DEPLOYMENT = "deployers-failing-jboss-beans.xml";
+ /** A empty deployment, this will deploy ok. */
final static String EMTPY_DEPLOYMENT = "deployers-empty-jboss-beans.xml";
+ /** A simple nested deployment. */
+ final static String NESTED_DEPLOYMENT = "profileservice-datasource.ear";
/** The deployment manager. */
DeploymentManager deployMgr;
@@ -51,6 +54,32 @@
super.setUp();
}
+ public void testDistributeOverride() throws Exception
+ {
+ try
+ {
+ //
+ DeploymentProgress start = distributeAndStart(NESTED_DEPLOYMENT, true);
+ assertComplete(start);
+
+// stopAndRemove(new String[] {NESTED_DEPLOYMENT});
+
+// DeploymentProgress stop = getDeploymentManager().stop(new String[] {NESTED_DEPLOYMENT});
+// stop.run();
+// assertComplete(stop);
+//
+// Thread.currentThread().wait(5000);
+
+ //
+ start = distributeAndStart(NESTED_DEPLOYMENT, true);
+ assertComplete(start);
+ }
+ finally
+ {
+ stopAndRemove(new String[] {NESTED_DEPLOYMENT});
+ }
+ }
+
public void testCopyContent() throws Exception
{
try
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java 2009-03-20 14:28:18 UTC (rev 86163)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java 2009-03-20 15:12:21 UTC (rev 86164)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.profileservice.override.test;
-import java.net.MalformedURLException;
import java.net.URL;
import javax.naming.InitialContext;
@@ -77,7 +76,7 @@
protected String[] deployPackage(String name) throws Exception
{
DeploymentManager deployMgr = getDeploymentManager();
- URL contentURL = getVFSdeployURL(name);
+ URL contentURL = getDeployURL(name);
assertNotNull(contentURL);
@@ -209,15 +208,5 @@
assertTrue("DeploymentStatus.isCompleted: " + status, status.isCompleted());
assertFalse("DeploymentStatus.isFailed: " + status, status.isFailed());
}
-
- protected URL getVFSdeployURL(String name) throws MalformedURLException
- {
- // TODO - hack to get off JDK's url handling
- URL contentURL = getDeployURL(name);
- assertNotNull(contentURL);
- String urlString = contentURL.toExternalForm();
- int p = urlString.indexOf(":/");
- return new URL("vfszip" + urlString.substring(p));
- }
}
\ No newline at end of file
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java 2009-03-20 14:28:18 UTC (rev 86163)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java 2009-03-20 15:12:21 UTC (rev 86164)
@@ -61,10 +61,10 @@
ManagementView mgtView = getManagementView();
ManagedDeployment md = mgtView.getDeployment(deploymentName);
- assertNotNull(md);
+ assertNotNull("Null managed deployment.", md);
ManagedComponent mc = md.getComponent("ProfileServiceTestDS");
- assertNotNull(mc);
+ assertNotNull("Null managed component", mc);
// This should work too
ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceTestDS");
@@ -182,7 +182,7 @@
deployPackage(deploymentName);
ManagementView mgtView = getManagementView();
ManagedDeployment deployment = mgtView.getDeployment(deploymentName);
- assertNotNull(deployment);
+ assertNotNull("Null managed deployment", deployment);
assertNotNull(deployment.getChildren());
assertFalse(deployment.getChildren().isEmpty());
@@ -201,7 +201,7 @@
assertNotNull(md);
ManagedComponent mc = md.getComponent("ProfileServiceNestedTestDS");
- assertNotNull(mc);
+ assertNotNull("Null managed component", mc);
// This should work too
ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceNestedTestDS");
More information about the jboss-cvs-commits
mailing list