[jboss-cvs] JBossAS SVN: r87340 - in trunk: profileservice/src/main/org/jboss/profileservice/management/upload and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 15 08:26:23 EDT 2009
Author: emuckenhuber
Date: 2009-04-15 08:26:23 -0400 (Wed, 15 Apr 2009)
New Revision: 87340
Added:
trunk/testsuite/src/main/org/jboss/test/deployers/test/
trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
trunk/testsuite/src/resources/deployers/hd-jboss-beans.xml
Removed:
trunk/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java
trunk/testsuite/build.xml
trunk/testsuite/imports/sections/deployers.xml
trunk/testsuite/imports/sections/profileservice.xml
trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java
Log:
port [JBAS-6708], [JBAS-6709] expose deployment status
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -46,6 +46,7 @@
import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
import org.jboss.logging.Logger;
import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentState;
import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.Fields;
import org.jboss.managed.api.ManagedComponent;
@@ -146,6 +147,7 @@
/** The state mappings. */
private Map<String, String> stateMappings = new HashMap<String, String>();
+ private Map<String, String> deploymentStateMappings = new HashMap<String, String>();
/** The dispatcher handles ManagedOperation dispatches */
private RuntimeComponentDispatcher dispatcher;
@@ -175,6 +177,10 @@
stateMappings.put("Create", RunState.STARTING.name());
stateMappings.put("Start", RunState.STARTING.name());
stateMappings.put("Installed", RunState.RUNNING.name());
+ // Set default deployment state mappings for managed deployments
+ deploymentStateMappings.put("**ERROR**", DeploymentState.FAILED.name());
+ deploymentStateMappings.put("Not Installed", DeploymentState.STOPPED.name());
+ deploymentStateMappings.put("Installed", DeploymentState.STARTED.name());
}
public void start() throws Exception
@@ -188,7 +194,7 @@
release();
}
- public boolean load()
+ public synchronized boolean load()
{
// If the profile is not modified do nothing
if(isReload() == false)
@@ -218,7 +224,7 @@
try
{
//
- processManagedDeployment(md, null, 0, trace);
+ processManagedDeployment(md, null, DeploymentState.STARTED, 0, trace);
}
catch(Exception e)
{
@@ -231,7 +237,7 @@
// Now create a ManagedDeployment for the platform beans
Map<String, ManagedObject> platformMBeanMOs = ManagementFactoryUtils.getPlatformMBeanMOs(managedObjFactory);
ManagedDeploymentImpl platformMBeans = new ManagedDeploymentImpl("JDK PlatformMBeans", "PlatformMBeans", null,
- null, platformMBeanMOs);
+ platformMBeanMOs);
List<ManagedObject> gcMbeans = ManagementFactoryUtils.getGarbageCollectorMXBeans(managedObjFactory);
Map<String, ManagedObject> gcMOs = new HashMap<String, ManagedObject>();
for (ManagedObject mo : gcMbeans)
@@ -245,19 +251,17 @@
for (ManagedObject mo : mpoolMBeans)
mpoolMOs.put(mo.getName(), mo);
ManagedDeploymentImpl gcMD = new ManagedDeploymentImpl("GarbageCollectorMXBeans", "GarbageCollectorMXBeans",
- null, null, gcMOs);
+ null, gcMOs);
platformMBeans.getChildren().add(gcMD);
- ManagedDeploymentImpl mmMD = new ManagedDeploymentImpl("MemoryManagerMXBeans", "MemoryManagerMXBeans", null,
- null, mmMOs);
+ ManagedDeploymentImpl mmMD = new ManagedDeploymentImpl("MemoryManagerMXBeans", "MemoryManagerMXBeans", null, mmMOs);
platformMBeans.getChildren().add(mmMD);
- ManagedDeploymentImpl mpoolMD = new ManagedDeploymentImpl("MemoryPoolMXBeans", "MemoryPoolMXBeans", null, null,
- mpoolMOs);
+ ManagedDeploymentImpl mpoolMD = new ManagedDeploymentImpl("MemoryPoolMXBeans", "MemoryPoolMXBeans", null, mpoolMOs);
platformMBeans.getChildren().add(mpoolMD);
try
{
// Create the ManagedComponents
- processManagedDeployment(platformMBeans, null, 0, trace);
+ processManagedDeployment(platformMBeans, null, DeploymentState.STARTED, 0, trace);
}
catch(Exception e)
{
@@ -309,8 +313,27 @@
try
{
ManagedDeployment md = getManagedDeployment(deployment);
- processManagedDeployment(md, key, 0, trace);
+ processRootManagedDeployment(md, key, trace);
}
+ catch(DeploymentException e)
+ {
+ // FIXME Assume a undeployed (stopped) deployment
+ String deploymentName = deployment.getName();
+ ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
+ deployment.getRoot().getName());
+
+ int i = deploymentName.lastIndexOf(".");
+ if(i != -1 && (i + 1) < deploymentName.length())
+ {
+ String guessedType = deploymentName.substring(i + 1, deploymentName.length());
+ if(guessedType.endsWith("/"))
+ guessedType = guessedType.substring(0, guessedType.length() -1 );
+ md.setTypes(new HashSet<String>(1));
+ md.addType(guessedType);
+ }
+
+ processManagedDeployment(md, key, DeploymentState.STOPPED, 0, trace);
+ }
catch(Exception e)
{
log.debug("Failed to create ManagedDeployment for: " + deployment.getName(), e);
@@ -350,15 +373,32 @@
}
/**
+ * Process the root managed deployment. This gets
+ * the deployment state for this deployment, which will
+ * get populated to the child deployments as well.
+ *
+ * @param md the managed deployment
+ * @param profile the associated profile key
+ * @param trace is trace enabled
+ * @throws Exception for any error
+ */
+ protected void processRootManagedDeployment(ManagedDeployment md, ProfileKey profile, boolean trace) throws Exception
+ {
+ DeploymentState state = getDeploymentState(md);
+ processManagedDeployment(md, profile, state, 0, trace);
+ }
+
+ /**
* Process managed deployment.
*
* @param md the managed deployment
* @param profile the associated profile key
+ * @param state the deployment state
* @param level depth level
* @param trace is trace enabled
* @throws Exception for any error
*/
- protected void processManagedDeployment(ManagedDeployment md, ProfileKey profile, int level, boolean trace) throws Exception
+ protected void processManagedDeployment(ManagedDeployment md, ProfileKey profile, DeploymentState state, int level, boolean trace) throws Exception
{
String name = md.getName();
if (trace)
@@ -366,6 +406,11 @@
Map<String, ManagedObject> mos = md.getManagedObjects();
if (trace)
log.trace(name + " ManagedObjects_ " + level + ": " + mos);
+
+ // Set the deployment state
+ if(state != null && md instanceof ManagedDeploymentImpl)
+ ((ManagedDeploymentImpl)md).setDeploymentState(state);
+
for(ManagedObject mo : mos.values())
{
processManagedObject(mo, md);
@@ -388,7 +433,8 @@
{
for(ManagedDeployment mdChild : mdChildren)
{
- processManagedDeployment(mdChild, profile, level + 1, trace);
+ // process the child deployments, with the state of the parent.
+ processManagedDeployment(mdChild, profile, state, level + 1, trace);
}
}
}
@@ -623,14 +669,12 @@
RunState state = comp.getRunState();
if (state == RunState.UNKNOWN && dispatcher != null)
{
- //TODO, update RuntimeComponentDispatcher
- AbstractRuntimeComponentDispatcher xdispatcher = (AbstractRuntimeComponentDispatcher) dispatcher;
Object name = comp.getComponentName();
if (name == null && runtimeMO != null)
name = runtimeMO.getComponentName();
if (name != null)
{
- String stateString = xdispatcher.getState(name);
+ String stateString = getControllerState(name);
String runStateString = stateMappings.get(stateString);
state = RunState.valueOf(runStateString);
if (comp instanceof MutableManagedComponent)
@@ -642,6 +686,34 @@
}
return state;
}
+
+ protected DeploymentState getDeploymentState(ManagedDeployment md)
+ {
+ DeploymentState state = md.getDeploymentState();
+ if(state == DeploymentState.UNKNOWN && dispatcher != null)
+ {
+ Object name = md.getName();
+ if(name != null)
+ {
+ String stateString = getControllerState(name);
+ String deploymenStateString = deploymentStateMappings.get(stateString);
+ state = DeploymentState.valueOf(deploymenStateString);
+ }
+ }
+ return state;
+ }
+
+ protected String getControllerState(Object name)
+ {
+ String state = null;
+ if(dispatcher != null)
+ {
+ //TODO, update RuntimeComponentDispatcher
+ AbstractRuntimeComponentDispatcher xdispatcher = (AbstractRuntimeComponentDispatcher) dispatcher;
+ state = xdispatcher.getState(name);
+ }
+ return state;
+ }
/**
* Process generic value.
@@ -1006,7 +1078,7 @@
// Process the deployment
ManagedDeployment md = getMainDeployer().getManagedDeployment(deploymentName);
- processManagedDeployment(md, getDefaulProfiletKey(), 0, log.isTraceEnabled());
+ processRootManagedDeployment(md, getDefaulProfiletKey(), log.isTraceEnabled());
}
public void process() throws DeploymentException
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -154,6 +154,12 @@
{
return Collections.emptySet();
}
+
+ @Override
+ public boolean isMutable()
+ {
+ return false;
+ }
}
}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -222,12 +222,21 @@
log.info("Handle stream, deploymentTarget: " + deploymentTarget);
deploymentTarget.setContentIS(contentIS);
String[] names = deploymentTarget.getNames();
+
// Add deployment content to the repository
String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS);
+
+ // FIXME make deployment visible to management view
+ VirtualFile vf = deploymentRepository.getDeploymentContent(repositoryName);
+ ProfileDeployment deployment = createDeployment(vf);
+ deploymentRepository.addDeployment(deployment.getName(), deployment);
+ deploymentRepository.lockDeploymentContent(deployment.getName());
+
log.info("End handle stream, repositoryName: " + repositoryName);
// Return the repository names
String[] rnames = {repositoryName};
deploymentTarget.setRepositoryNames(rnames);
+
return new InvocationResponse(repositoryName);
}
@@ -288,6 +297,7 @@
}
// CheckComplete
deployer.process();
+
// TODO check if there is still a deploymentContext ?
log.info("End stop, "+ deployments);
}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -99,15 +99,20 @@
* @throws URISyntaxException
*/
@Override
- protected String[] distribute(DeploymentID dtID) throws IOException, URISyntaxException
+ protected String[] distribute(DeploymentID dtID) throws Exception
{
URL contentURL = dtID.getContentURL();
log.info("Begin distribute, content url: " + contentURL);
// Create the virtual file
VirtualFile vf = VFS.getRoot(contentURL);
- String name = vf.toURI().toString();
- this.transientDeployments.put(name, vf);
+
+ // FIXME make deployment visible to management view
+ ProfileDeployment deployment = createDeployment(vf);
+ this.transientProfile.addDeployment(deployment);
+
+ String name = deployment.getName();
+ this.transientDeployments.put(name, vf);
log.info("End distribute, " + name);
return new String[] { name };
@@ -119,20 +124,16 @@
String deploymentName = resolveDeploymentName(name);
if(deploymentName != null)
{
- // Create deployment
- VirtualFile vf = this.transientDeployments.get(deploymentName);
- ProfileDeployment deployment = createDeployment(vf);
- // Add to transient profile
+ //
+ ProfileDeployment deployment = this.transientProfile.getDeployment(deploymentName);
+ // FIXME update the timestamp
this.transientProfile.addDeployment(deployment);
return deployment;
}
else
{
- // Create deployment
- VirtualFile vf = deploymentRepository.getDeploymentContent(name);
- ProfileDeployment deployment = createDeployment(vf);
- // Add deployment repository
- deploymentRepository.addDeployment(deployment.getName(), deployment);
+ // unlock
+ ProfileDeployment deployment = deploymentRepository.getDeployment(name);
deploymentRepository.unlockDeploymentContent(deployment.getName());
return deployment;
}
@@ -144,8 +145,10 @@
String deploymentName = resolveDeploymentName(name);
if(deploymentName != null)
{
- // Remove from profile
- return this.transientProfile.removeDeployment(deploymentName);
+ ProfileDeployment deployment = this.transientProfile.getDeployment(deploymentName);
+ // FIXME update the timestamp
+ this.transientProfile.addDeployment(deployment);
+ return deployment;
}
else
{
@@ -164,6 +167,8 @@
{
// Remove from local cache
this.transientDeployments.remove(deploymentName);
+ // Remove from profile
+ this.transientProfile.removeDeployment(deploymentName);
}
else
{
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractDeploymentRepository.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -188,14 +188,20 @@
{
if( log.isTraceEnabled() )
log.trace("lockDeploymentContent, "+vfsPath);
- return setDeploymentContentFlags(vfsPath, DeploymentContentFlags.LOCKED);
+ int flag = setDeploymentContentFlags(vfsPath, DeploymentContentFlags.LOCKED);
+ // FIXME update the lastModified for the ManagementView to check the DeploymentStatus
+ updateLastModfied();
+ return flag;
}
public int unlockDeploymentContent(String vfsPath)
{
if( log.isTraceEnabled() )
log.trace("unlockDeploymentContent, "+vfsPath);
- return clearDeploymentContentFlags(vfsPath, DeploymentContentFlags.LOCKED);
+ int flag = clearDeploymentContentFlags(vfsPath, DeploymentContentFlags.LOCKED);
+ // FIXME update the lastModified for the ManagementView to check the DeploymentStatus
+ updateLastModfied();
+ return flag;
}
public int getDeploymentContentFlags(String vfsPath)
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -35,6 +35,7 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.zip.ZipInputStream;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.ProfileKey;
@@ -114,6 +115,26 @@
updateLastModfied();
}
+ @Override
+ public void addDeployment(String vfsPath, ProfileDeployment d) throws Exception
+ {
+ // Suspend hot deployment checking
+ if( log.isTraceEnabled() )
+ log.trace("Aquiring content write lock");
+ lockWrite();
+ try
+ {
+ internalAddDeployment(vfsPath, d);
+ }
+ finally
+ {
+ // Allow hot deployment checking
+ unlockWrite();
+ if(log.isTraceEnabled())
+ log.trace("Released content write lock");
+ }
+ }
+
public Collection<ModificationInfo> getModifiedDeployments() throws Exception
{
return Collections.emptySet();
@@ -184,7 +205,7 @@
}
// Lock the content
- lockDeploymentContent(repositoryName);
+ setDeploymentContentFlags(repositoryName, DeploymentContentFlags.LOCKED);
}
finally
{
@@ -198,6 +219,31 @@
public ProfileDeployment removeDeployment(String vfsPath) throws Exception
{
+ return removeDeployment(vfsPath, true);
+ }
+
+ /**
+ * Internal add the deployment, without locking the repository.
+ *
+ * @param vfsPath - the name of the deployment
+ * @param deployment - the deployment
+ * @throws Exception
+ */
+ protected void internalAddDeployment(String vfsPath, ProfileDeployment deployment) throws Exception
+ {
+ super.addDeployment(vfsPath, deployment);
+ }
+
+ /**
+ * Remove deployment.
+ *
+ * @param vfsPath the vfs path
+ * @param deleteFile do we delete the file
+ * @return found profile deployment
+ * @throws Exception for any error
+ */
+ protected ProfileDeployment removeDeployment(String vfsPath, boolean deleteFile) throws Exception
+ {
// Suspend hot deployment checking
if( log.isTraceEnabled() )
log.trace("Aquiring content write lock");
@@ -208,7 +254,7 @@
ProfileDeployment deployment = getDeployment(vfsPath);
VirtualFile root = deployment.getRoot();
- if(root != null)
+ if(deleteFile && root != null)
{
// Delete the file
if(root.delete() == false)
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.profileservice.spi.DeploymentContentFlags;
@@ -80,7 +81,7 @@
{
boolean trace = log.isTraceEnabled();
Collection<ProfileDeployment> apps = getDeployments();
- ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
+ List<ModificationInfo> modified = new ArrayList<ModificationInfo>();
if (trace)
log.trace("Checking applications for modifications");
if (trace)
@@ -128,23 +129,7 @@
}
}
// Now check for additions
- for (URI applicationDir : getRepositoryURIs())
- {
- VirtualFile deployDir = getCachedVirtualFile(applicationDir);
- ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
- addedDeployments(added, deployDir);
- for (VirtualFile vf : added)
- {
- // Create deployment
- ProfileDeployment ctx = createDeployment(vf);
- // Create modification info
- ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
- // Add
- modified.add(info);
- addDeployment(ctx.getName(), ctx);
- getChecker().addStructureRoot(vf);
- }
- }
+ checkForAdditions(modified);
}
}
finally
@@ -158,7 +143,47 @@
updateLastModfied();
return modified;
}
-
+
+ /**
+ * Check for additions.
+ *
+ * @param modified the modified list
+ * @throws Exception for any error
+ */
+ protected void checkForAdditions(List<ModificationInfo> modified) throws Exception
+ {
+ for (URI applicationDir : getRepositoryURIs())
+ {
+ VirtualFile deployDir = getCachedVirtualFile(applicationDir);
+ List<VirtualFile> added = new ArrayList<VirtualFile>();
+ addedDeployments(added, deployDir);
+ applyAddedDeployments(applicationDir, modified, added);
+ }
+ }
+
+ /**
+ * Apply added deployments.
+ *
+ * @param applicationDir the app dir
+ * @param modified the modifed list
+ * @param added the added deployments
+ * @throws Exception for any error
+ */
+ protected void applyAddedDeployments(URI applicationDir, List<ModificationInfo> modified, List<VirtualFile> added) throws Exception
+ {
+ for (VirtualFile vf : added)
+ {
+ // Create deployment
+ ProfileDeployment ctx = createDeployment(vf);
+ // Create modification info
+ ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+ // Add
+ modified.add(info);
+ internalAddDeployment(ctx.getName(), ctx);
+ getChecker().addStructureRoot(vf);
+ }
+ }
+
@Override
protected void cleanUpRoot(VirtualFile vf)
{
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -343,7 +343,7 @@
}
// Lock the content
- lockDeploymentContent(vfsPath);
+ setDeploymentContentFlags(repositoryName, DeploymentContentFlags.LOCKED);
}
finally
{
Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/testsuite/build.xml 2009-04-15 12:26:23 UTC (rev 87340)
@@ -853,6 +853,7 @@
<include name="org/jboss/test/profileservice/test/*TestCase.class"/>
<include name="org/jboss/test/profileservice/override/test/*TestCase.class"/>
<!-- deployers + seam -->
+ <include name="org/jboss/test/deployers/test/*UnitTestCase.class"/>
<include name="org/jboss/test/deployers/client/test/*UnitTestCase.class"/>
<include name="org/jboss/test/deployers/ear/test/*UnitTestCase.class"/>
<include name="org/jboss/test/deployers/ejb/test/*UnitTestCase.class"/>
@@ -867,6 +868,7 @@
<exclude name="org/jboss/test/profileservice/test/*TestCase.class"/>
<exclude name="org/jboss/test/profileservice/override/test/*TestCase.class"/>
<!-- deployers + seam -->
+ <exclude name="org/jboss/test/deployers/test/*UnitTestCase.class"/>
<exclude name="org/jboss/test/deployers/client/test/*UnitTestCase.class"/>
<exclude name="org/jboss/test/deployers/ear/test/*UnitTestCase.class"/>
<exclude name="org/jboss/test/deployers/ejb/test/*UnitTestCase.class"/>
@@ -1066,6 +1068,10 @@
<target name="tests-profileservice" description="Tests with the full featured profile service">
<create-profileservice-config baseconf="default" conf="profileservice"/>
<server:start name="profileservice"/>
+ <!-- copy a deployment which should get picked up by the hdScanner -->
+ <copy file="${build.lib}/hd-jboss-beans.xml"
+ todir="${jboss.dist}/server/profileservice/deploy" />
+
<run-junit
junit.patternset="profileservice.includes"
junit.configuration="profileservice"
Modified: trunk/testsuite/imports/sections/deployers.xml
===================================================================
--- trunk/testsuite/imports/sections/deployers.xml 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/testsuite/imports/sections/deployers.xml 2009-04-15 12:26:23 UTC (rev 87340)
@@ -411,7 +411,14 @@
<include name="deployment-web-jboss.war"/>
</fileset>
</ear>
-
+
+ <copy tofile="${build.lib}/hd-jboss-beans.xml"
+ file="${build.resources}/deployers/hd-jboss-beans.xml"/>
+ <copy tofile="${build.lib}/deployers-empty-jboss-beans.xml"
+ file="${build.resources}/deployers/failed/empty-jboss-beans.xml"/>
+ <copy tofile="${build.lib}/deployers-failing-jboss-beans.xml"
+ file="${build.resources}/deployers/failed/failing-jboss-beans.xml"/>
+
</target>
</project>
Modified: trunk/testsuite/imports/sections/profileservice.xml
===================================================================
--- trunk/testsuite/imports/sections/profileservice.xml 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/testsuite/imports/sections/profileservice.xml 2009-04-15 12:26:23 UTC (rev 87340)
@@ -57,6 +57,9 @@
</zipfileset>
</jar>
+ <copy tofile="${build.lib}/profileservice-remove-ds.xml"
+ file="${build.resources}/profileservice/override/profileservice-remove-ds.xml"/>
+
<copy tofile="${build.lib}/profileservice-test-ds.xml"
file="${build.resources}/profileservice/override/profileservice-test-ds.xml"/>
Deleted: trunk/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -1,286 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.deployers;
-
-import java.util.Collection;
-
-import javax.naming.InitialContext;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.test.JBossTestCase;
-
-/**
- * Basic DeploymentManager test.
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-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 deployers target profile. */
- final static ProfileKey deployersKey = new ProfileKey("deployers");
-
- /** The deployment manager. */
- private DeploymentManager deployMgr;
-
- public DeploymentManagerUnitTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Test the available profiles.
- *
- * @throws Exception
- */
- public void testAvaiableProfiles() throws Exception
- {
- Collection<ProfileKey> keys = getDeploymentManager().getProfiles();
- assertNotNull(keys);
- log.debug("available keys: " + keys);
- keys.contains(new ProfileKey("applications"));
- keys.contains(deployersKey);
- }
-
- /**
- * Test a override of the applications, without
- * removing/stopping them before.
- *
- * @throws Exception
- */
- public void testDistributeOverride() throws Exception
- {
- try
- {
- //
- DeploymentProgress start = distributeAndStart(NESTED_DEPLOYMENT, true);
- assertComplete(start);
- //
- start = distributeAndStart(NESTED_DEPLOYMENT, true);
- assertComplete(start);
- }
- finally
- {
- stopAndRemove(new String[] { NESTED_DEPLOYMENT });
- }
- }
-
- /**
- * Basic copyContent test to the default location.
- *
- * @throws Exception
- */
- public void testCopyContent() throws Exception
- {
- try
- {
- // failed
- deployFailed(true);
- // complete
- deployEmpty(true);
- // Test redeploy
- redeployCheckComplete(EMTPY_DEPLOYMENT);
- // TODO implement prepare
- prepareCheckComplete(EMTPY_DEPLOYMENT);
- }
- finally
- {
- stopAndRemove(new String[]
- { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
- }
- }
-
- /**
- * Basic noCopyContent test.
- *
- * @throws Exception
- */
- public void testNoCopyContent() throws Exception
- {
- try
- {
- // failed
- deployFailed(false);
- // complete
- deployEmpty(false);
- // test redeploy
- redeployCheckComplete(EMTPY_DEPLOYMENT);
- // TODO implement prepare
- prepareCheckComplete(EMTPY_DEPLOYMENT);
- }
- finally
- {
- stopAndRemove(new String[]
- { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
- }
- }
-
- /**
- * Test copyContent to the deployers target profile.
- *
- * @throws Exception
- */
- public void testDepoyersDir() throws Exception
- {
- getDeploymentManager().loadProfile(deployersKey);
- try
- {
- // failed
- deployFailed(true);
- // complete
- deployEmpty(true);
- // Test redeploy
- redeployCheckComplete(EMTPY_DEPLOYMENT);
- }
- finally
- {
- try
- {
- stopAndRemove(new String[]
- { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
- }
- finally
- {
- // Make sure that we release the profile
- getDeploymentManager().releaseProfile();
- }
- }
- }
-
- void deployFailed(boolean isCopyContent) throws Exception
- {
- DeploymentProgress start = distributeAndStart(FAILING_DEPLOYMENT, isCopyContent);
- assertFailed(start);
- }
-
- void deployEmpty(boolean isCopyContent) throws Exception
- {
- DeploymentProgress start = distributeAndStart(EMTPY_DEPLOYMENT, isCopyContent);
- assertComplete(start);
- }
-
- DeploymentProgress distributeAndStart(String deploymentName, boolean copyContent) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- // Distribute
- DeploymentProgress distribute = deployMgr.distribute(deploymentName,
- getDeployURL(deploymentName), copyContent);
- distribute.run();
- // Distribute always have to work
- assertComplete(distribute);
-
- // Get the repository names
- String[] uploadedNames = distribute.getDeploymentID().getRepositoryNames();
- assertNotNull(uploadedNames);
-
- // Start
- DeploymentProgress start = deployMgr.start(uploadedNames);
- start.run();
- // Return the start deployment progress
- return start;
- }
-
- void redeployCheckComplete(String name) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- // Redeploy
- DeploymentProgress redeploy = deployMgr.redeploy(name);
- redeploy.run();
- assertComplete(redeploy);
- }
-
- void prepareCheckComplete(String name) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- // Prepare
- DeploymentProgress prepare = deployMgr.prepare(name);
- prepare.run();
- assertComplete(prepare);
- }
-
- void stopAndRemove(String[] names) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- try
- {
- DeploymentProgress stop = deployMgr.stop(names);
- stop.run();
- assertComplete(stop);
- }
- finally
- {
- DeploymentProgress remove = deployMgr.remove(names);
- remove.run();
- assertComplete(remove);
- }
- }
-
- void assertFailed(DeploymentProgress progress) throws Exception
- {
- assertFalse(progress.getDeploymentStatus().isCompleted());
- assertTrue(progress.getDeploymentStatus().isFailed());
- }
-
- void assertComplete(DeploymentProgress progress) throws Exception
- {
- if(progress.getDeploymentStatus().isFailed())
- {
- throw new RuntimeException("deployment failed.", progress.getDeploymentStatus().getFailure());
- }
- //
- assertTrue(progress.getDeploymentStatus().isCompleted());
- }
-
- DeploymentManager getDeploymentManager() throws Exception
- {
- if(this.deployMgr == null)
- {
- this.deployMgr = getProfileService().getDeploymentManager();
- }
- return deployMgr;
- }
-
- ProfileService getProfileService() throws Exception
- {
- InitialContext ctx = getInitialContext();
- return (ProfileService) ctx.lookup("ProfileService");
- }
-
-}
Copied: trunk/testsuite/src/main/org/jboss/test/deployers/test (from rev 87159, branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test)
Deleted: trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java 2009-04-11 10:59:43 UTC (rev 87159)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -1,385 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.deployers.test;
-
-import java.util.Collection;
-
-import javax.naming.InitialContext;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.managed.api.DeploymentState;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.test.JBossTestCase;
-
-/**
- * Basic DeploymentManager test.
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-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";
- /** A deployment picked up by the HDScanner. */
- final static String HD_DEPLOYMENT = "hd-jboss-beans.xml";
-
- /** The deployers target profile. */
- final static ProfileKey deployersKey = new ProfileKey("deployers");
-
- /** The deployment manager. */
- private DeploymentManager deployMgr;
- private ManagementView mgtView;
-
- public DeploymentManagerUnitTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Test the available profiles.
- *
- * @throws Exception
- */
- public void testAvaiableProfiles() throws Exception
- {
- Collection<ProfileKey> keys = getDeploymentManager().getProfiles();
- assertNotNull(keys);
- log.debug("available keys: " + keys);
- keys.contains(new ProfileKey("applications"));
- keys.contains(deployersKey);
- }
-
- /**
- * Test a override of the applications, without
- * removing/stopping them before.
- *
- * @throws Exception
- */
- public void testDistributeOverride() throws Exception
- {
- try
- {
- for(int i = 0; i < 5; i++)
- {
- //
- DeploymentProgress start = distributeAndStart(NESTED_DEPLOYMENT, true, false);
- assertComplete(start);
- // disable stopped check, as it was started before
- start = distributeAndStart(NESTED_DEPLOYMENT, true, false);
- assertComplete(start);
-
- Thread.sleep(50);
- }
- }
- catch(Exception e)
- {
- log.debug("Failed ", e);
- throw e;
- }
- finally
- {
- stopAndRemove(new String[] { NESTED_DEPLOYMENT });
- }
- }
-
- /**
- * Basic copyContent test to the default location.
- *
- * @throws Exception
- */
- public void testCopyContent() throws Exception
- {
- try
- {
- // failed
- deployFailed(true);
- // complete
- deployEmpty(true);
- // Test redeploy
- redeployCheckComplete(EMTPY_DEPLOYMENT);
- // TODO implement prepare
- prepareCheckComplete(EMTPY_DEPLOYMENT);
- }
- catch(Exception e)
- {
- log.debug("Failed ", e);
- throw e;
- }
- finally
- {
- stopAndRemove(new String[]
- { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
- }
- }
-
- /**
- * Basic noCopyContent test.
- *
- * @throws Exception
- */
- public void testNoCopyContent() throws Exception
- {
- try
- {
- // failed
- deployFailed(false);
- // complete
- deployEmpty(false);
- // test redeploy
- redeployCheckComplete(EMTPY_DEPLOYMENT);
- // TODO implement prepare
- prepareCheckComplete(EMTPY_DEPLOYMENT);
- }
- catch(Exception e)
- {
- log.error("Failed ", e);
- throw e;
- }
- finally
- {
- stopAndRemove(new String[]
- { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
- }
- }
-
- /**
- * Test copyContent to the deployers target profile.
- *
- * @throws Exception
- */
- public void testDepoyersDir() throws Exception
- {
- getDeploymentManager().loadProfile(deployersKey);
- try
- {
- // failed
- deployFailed(true);
- // complete
- deployEmpty(true);
- // Test redeploy
- redeployCheckComplete(EMTPY_DEPLOYMENT);
- }
- catch(Exception e)
- {
- log.debug("Failed ", e);
- throw e;
- }
- finally
- {
- try
- {
- stopAndRemove(new String[]
- { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
- }
- finally
- {
- // Make sure that we release the profile
- getDeploymentManager().releaseProfile();
- }
- }
- }
-
- /**
- * Test the hd deployment. This deployment will get copied
- * to the deploy folder after the server is started. This
- * deployment needs to get picked up by the HDScanner and
- * should be available to the ManagementView.
- *
- * @throws Exception
- */
- public void testHotDeploymentBeans() throws Exception
- {
- ManagementView mgtView = getManagementView();
- ManagedDeployment md = mgtView.getDeployment(HD_DEPLOYMENT);
- assertNotNull("hd-beans not deployed", md);
- assertEquals("deployment started", DeploymentState.STARTED, md.getDeploymentState());
-
- stopAndRemove(new String[] { HD_DEPLOYMENT });
- }
-
- void deployFailed(boolean isCopyContent) throws Exception
- {
- DeploymentProgress start = distributeAndStart(FAILING_DEPLOYMENT, isCopyContent);
- assertFailed(start);
- assertDeploymentState(start.getDeploymentID(), DeploymentState.FAILED);
- }
-
- void deployEmpty(boolean isCopyContent) throws Exception
- {
- DeploymentProgress start = distributeAndStart(EMTPY_DEPLOYMENT, isCopyContent);
- assertComplete(start);
- assertDeploymentState(start.getDeploymentID(), DeploymentState.STARTED);
- }
-
- DeploymentProgress distributeAndStart(String deploymentName, boolean copyContent) throws Exception
- {
- return distributeAndStart(deploymentName, copyContent, true);
- }
-
- DeploymentProgress distributeAndStart(String deploymentName, boolean copyContent, boolean checkStopped) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- // Distribute
- DeploymentProgress distribute = deployMgr.distribute(deploymentName,
- getDeployURL(deploymentName), copyContent);
- distribute.run();
- // Distribute always has to complete
- assertComplete(distribute);
- // check if the app is stopped
- if(checkStopped)
- assertDeploymentState(distribute.getDeploymentID(), DeploymentState.STOPPED);
-
- // Get the repository names
- String[] uploadedNames = distribute.getDeploymentID().getRepositoryNames();
- assertNotNull(uploadedNames);
-
- // Start
- DeploymentProgress start = deployMgr.start(uploadedNames);
- start.run();
- // Return the start deployment progress
- return start;
- }
-
- void redeployCheckComplete(String name) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- // Redeploy
- DeploymentProgress redeploy = deployMgr.redeploy(name);
- redeploy.run();
- assertComplete(redeploy);
- assertDeploymentState(redeploy.getDeploymentID(), DeploymentState.STARTED);
- }
-
- void prepareCheckComplete(String name) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- // Prepare
- DeploymentProgress prepare = deployMgr.prepare(name);
- prepare.run();
- assertComplete(prepare);
- }
-
- void stopAndRemove(String[] names) throws Exception
- {
- // The deployment manager
- DeploymentManager deployMgr = getDeploymentManager();
-
- try
- {
- DeploymentProgress stop = deployMgr.stop(names);
- stop.run();
- assertComplete(stop);
- assertDeploymentState(stop.getDeploymentID(), DeploymentState.STOPPED);
- }
- catch(Exception e)
- {
- log.debug("stopAndRemove Failed ", e);
- throw e;
- }
- finally
- {
- DeploymentProgress remove = deployMgr.remove(names);
- remove.run();
- assertComplete(remove);
-
- String name = remove.getDeploymentID().getNames()[0];
- ManagementView mgtView = getManagementView();
- try
- {
- mgtView.getDeployment(name);
- fail("Did not see NoSuchDeploymentException");
- }
- catch(NoSuchDeploymentException ok)
- {
- //
- }
- }
- }
-
- void assertFailed(DeploymentProgress progress) throws Exception
- {
- assertFalse(progress.getDeploymentStatus().isCompleted());
- assertTrue(progress.getDeploymentStatus().isFailed());
- }
-
- void assertDeploymentState(DeploymentID DtID, DeploymentState state) throws Exception
- {
- String name = DtID.getNames()[0];
- ManagementView mgtView = getManagementView();
- ManagedDeployment md = mgtView.getDeployment(name);
- assertNotNull(name, md);
- assertEquals("deployment: " + name, state, md.getDeploymentState());
- }
-
- void assertComplete(DeploymentProgress progress) throws Exception
- {
- if(progress.getDeploymentStatus().isFailed())
- {
- throw new RuntimeException("deployment failed.", progress.getDeploymentStatus().getFailure());
- }
- //
- assertTrue(progress.getDeploymentStatus().isCompleted());
- }
-
- DeploymentManager getDeploymentManager() throws Exception
- {
- if(this.deployMgr == null)
- {
- this.deployMgr = getProfileService().getDeploymentManager();
- }
- return deployMgr;
- }
-
- ManagementView getManagementView() throws Exception
- {
- if(this.mgtView == null)
- {
- this.mgtView = getProfileService().getViewManager();
- }
- this.mgtView.load();
- return this.mgtView;
- }
-
- ProfileService getProfileService() throws Exception
- {
- InitialContext ctx = getInitialContext();
- return (ProfileService) ctx.lookup("ProfileService");
- }
-
-}
Copied: trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java (from rev 87159, branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -0,0 +1,385 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers.test;
+
+import java.util.Collection;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Basic DeploymentManager test.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+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";
+ /** A deployment picked up by the HDScanner. */
+ final static String HD_DEPLOYMENT = "hd-jboss-beans.xml";
+
+ /** The deployers target profile. */
+ final static ProfileKey deployersKey = new ProfileKey("deployers");
+
+ /** The deployment manager. */
+ private DeploymentManager deployMgr;
+ private ManagementView mgtView;
+
+ public DeploymentManagerUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the available profiles.
+ *
+ * @throws Exception
+ */
+ public void testAvaiableProfiles() throws Exception
+ {
+ Collection<ProfileKey> keys = getDeploymentManager().getProfiles();
+ assertNotNull(keys);
+ log.debug("available keys: " + keys);
+ keys.contains(new ProfileKey("applications"));
+ keys.contains(deployersKey);
+ }
+
+ /**
+ * Test a override of the applications, without
+ * removing/stopping them before.
+ *
+ * @throws Exception
+ */
+ public void testDistributeOverride() throws Exception
+ {
+ try
+ {
+ for(int i = 0; i < 5; i++)
+ {
+ //
+ DeploymentProgress start = distributeAndStart(NESTED_DEPLOYMENT, true, false);
+ assertComplete(start);
+ // disable stopped check, as it was started before
+ start = distributeAndStart(NESTED_DEPLOYMENT, true, false);
+ assertComplete(start);
+
+ Thread.sleep(50);
+ }
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed ", e);
+ throw e;
+ }
+ finally
+ {
+ stopAndRemove(new String[] { NESTED_DEPLOYMENT });
+ }
+ }
+
+ /**
+ * Basic copyContent test to the default location.
+ *
+ * @throws Exception
+ */
+ public void testCopyContent() throws Exception
+ {
+ try
+ {
+ // failed
+ deployFailed(true);
+ // complete
+ deployEmpty(true);
+ // Test redeploy
+ redeployCheckComplete(EMTPY_DEPLOYMENT);
+ // TODO implement prepare
+ prepareCheckComplete(EMTPY_DEPLOYMENT);
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed ", e);
+ throw e;
+ }
+ finally
+ {
+ stopAndRemove(new String[]
+ { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
+ }
+ }
+
+ /**
+ * Basic noCopyContent test.
+ *
+ * @throws Exception
+ */
+ public void testNoCopyContent() throws Exception
+ {
+ try
+ {
+ // failed
+ deployFailed(false);
+ // complete
+ deployEmpty(false);
+ // test redeploy
+ redeployCheckComplete(EMTPY_DEPLOYMENT);
+ // TODO implement prepare
+ prepareCheckComplete(EMTPY_DEPLOYMENT);
+ }
+ catch(Exception e)
+ {
+ log.error("Failed ", e);
+ throw e;
+ }
+ finally
+ {
+ stopAndRemove(new String[]
+ { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
+ }
+ }
+
+ /**
+ * Test copyContent to the deployers target profile.
+ *
+ * @throws Exception
+ */
+ public void testDepoyersDir() throws Exception
+ {
+ getDeploymentManager().loadProfile(deployersKey);
+ try
+ {
+ // failed
+ deployFailed(true);
+ // complete
+ deployEmpty(true);
+ // Test redeploy
+ redeployCheckComplete(EMTPY_DEPLOYMENT);
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed ", e);
+ throw e;
+ }
+ finally
+ {
+ try
+ {
+ stopAndRemove(new String[]
+ { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
+ }
+ finally
+ {
+ // Make sure that we release the profile
+ getDeploymentManager().releaseProfile();
+ }
+ }
+ }
+
+ /**
+ * Test the hd deployment. This deployment will get copied
+ * to the deploy folder after the server is started. This
+ * deployment needs to get picked up by the HDScanner and
+ * should be available to the ManagementView.
+ *
+ * @throws Exception
+ */
+ public void testHotDeploymentBeans() throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ ManagedDeployment md = mgtView.getDeployment(HD_DEPLOYMENT);
+ assertNotNull("hd-beans not deployed", md);
+ assertEquals("deployment started", DeploymentState.STARTED, md.getDeploymentState());
+
+ stopAndRemove(new String[] { HD_DEPLOYMENT });
+ }
+
+ void deployFailed(boolean isCopyContent) throws Exception
+ {
+ DeploymentProgress start = distributeAndStart(FAILING_DEPLOYMENT, isCopyContent);
+ assertFailed(start);
+ assertDeploymentState(start.getDeploymentID(), DeploymentState.FAILED);
+ }
+
+ void deployEmpty(boolean isCopyContent) throws Exception
+ {
+ DeploymentProgress start = distributeAndStart(EMTPY_DEPLOYMENT, isCopyContent);
+ assertComplete(start);
+ assertDeploymentState(start.getDeploymentID(), DeploymentState.STARTED);
+ }
+
+ DeploymentProgress distributeAndStart(String deploymentName, boolean copyContent) throws Exception
+ {
+ return distributeAndStart(deploymentName, copyContent, true);
+ }
+
+ DeploymentProgress distributeAndStart(String deploymentName, boolean copyContent, boolean checkStopped) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ // Distribute
+ DeploymentProgress distribute = deployMgr.distribute(deploymentName,
+ getDeployURL(deploymentName), copyContent);
+ distribute.run();
+ // Distribute always has to complete
+ assertComplete(distribute);
+ // check if the app is stopped
+ if(checkStopped)
+ assertDeploymentState(distribute.getDeploymentID(), DeploymentState.STOPPED);
+
+ // Get the repository names
+ String[] uploadedNames = distribute.getDeploymentID().getRepositoryNames();
+ assertNotNull(uploadedNames);
+
+ // Start
+ DeploymentProgress start = deployMgr.start(uploadedNames);
+ start.run();
+ // Return the start deployment progress
+ return start;
+ }
+
+ void redeployCheckComplete(String name) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ // Redeploy
+ DeploymentProgress redeploy = deployMgr.redeploy(name);
+ redeploy.run();
+ assertComplete(redeploy);
+ assertDeploymentState(redeploy.getDeploymentID(), DeploymentState.STARTED);
+ }
+
+ void prepareCheckComplete(String name) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ // Prepare
+ DeploymentProgress prepare = deployMgr.prepare(name);
+ prepare.run();
+ assertComplete(prepare);
+ }
+
+ void stopAndRemove(String[] names) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ try
+ {
+ DeploymentProgress stop = deployMgr.stop(names);
+ stop.run();
+ assertComplete(stop);
+ assertDeploymentState(stop.getDeploymentID(), DeploymentState.STOPPED);
+ }
+ catch(Exception e)
+ {
+ log.debug("stopAndRemove Failed ", e);
+ throw e;
+ }
+ finally
+ {
+ DeploymentProgress remove = deployMgr.remove(names);
+ remove.run();
+ assertComplete(remove);
+
+ String name = remove.getDeploymentID().getNames()[0];
+ ManagementView mgtView = getManagementView();
+ try
+ {
+ mgtView.getDeployment(name);
+ fail("Did not see NoSuchDeploymentException");
+ }
+ catch(NoSuchDeploymentException ok)
+ {
+ //
+ }
+ }
+ }
+
+ void assertFailed(DeploymentProgress progress) throws Exception
+ {
+ assertFalse(progress.getDeploymentStatus().isCompleted());
+ assertTrue(progress.getDeploymentStatus().isFailed());
+ }
+
+ void assertDeploymentState(DeploymentID DtID, DeploymentState state) throws Exception
+ {
+ String name = DtID.getNames()[0];
+ ManagementView mgtView = getManagementView();
+ ManagedDeployment md = mgtView.getDeployment(name);
+ assertNotNull(name, md);
+ assertEquals("deployment: " + name, state, md.getDeploymentState());
+ }
+
+ void assertComplete(DeploymentProgress progress) throws Exception
+ {
+ if(progress.getDeploymentStatus().isFailed())
+ {
+ throw new RuntimeException("deployment failed.", progress.getDeploymentStatus().getFailure());
+ }
+ //
+ assertTrue(progress.getDeploymentStatus().isCompleted());
+ }
+
+ DeploymentManager getDeploymentManager() throws Exception
+ {
+ if(this.deployMgr == null)
+ {
+ this.deployMgr = getProfileService().getDeploymentManager();
+ }
+ return deployMgr;
+ }
+
+ ManagementView getManagementView() throws Exception
+ {
+ if(this.mgtView == null)
+ {
+ this.mgtView = getProfileService().getViewManager();
+ }
+ this.mgtView.load();
+ return this.mgtView;
+ }
+
+ ProfileService getProfileService() throws Exception
+ {
+ InitialContext ctx = getInitialContext();
+ return (ProfileService) ctx.lookup("ProfileService");
+ }
+
+}
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java 2009-04-15 12:23:20 UTC (rev 87339)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java 2009-04-15 12:26:23 UTC (rev 87340)
@@ -21,11 +21,23 @@
*/
package org.jboss.test.profileservice.override.restart.test;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.KnownComponentTypes;
import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
import org.jboss.test.profileservice.override.test.AbstractProfileServiceTest;
/**
@@ -37,6 +49,23 @@
public class JmsDestinationRestartUnitTestCase extends AbstractProfileServiceTest
{
+ /** The meta type. */
+ protected static final MapCompositeMetaType securityConfType;
+
+ /** The composite meta type. */
+ public static MutableCompositeMetaType composite;
+
+ static
+ {
+ // Create the meta type
+ composite = new MutableCompositeMetaType("SecurityConfig", "The security config");
+ composite.addItem("read", "read permission", SimpleMetaType.BOOLEAN);
+ composite.addItem("write", "write permission", SimpleMetaType.BOOLEAN);
+ composite.addItem("create", "create permission", SimpleMetaType.BOOLEAN);
+ composite.freeze();
+ securityConfType = new MapCompositeMetaType(composite);
+ }
+
public JmsDestinationRestartUnitTestCase(String name)
{
super(name);
@@ -69,6 +98,37 @@
undeployPackage(new String[] { deploymentName });
}
}
+
+ public void testQueueTemplate() throws Exception
+ {
+ final String deploymentName = "testQueueTemplate-service.xml";
+ try
+ {
+ ManagementView mgtView = getManagementView();
+
+ ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
+ ManagedComponent queue = mgtView.getComponent("testQueueTemplate", type);
+ assertNotNull(queue);
+
+ Map<String, MetaValue> values = new HashMap<String, MetaValue>();
+ values.put("admin", createCompositeValue(true, true, true));
+ values.put("publisher", createCompositeValue(true, true, false));
+ values.put("user", createCompositeValue(false, false, false));
+ MapCompositeValueSupport map = new MapCompositeValueSupport(values, securityConfType);
+
+ ManagedProperty p = queue.getProperty("securityConfig");
+ assertNotNull("security config property", p);
+ MetaValue v = p.getValue();
+ assertNotNull("securityConfig", v);
+ //
+ assertTrue("security equals", map.equals(v));
+ }
+ finally
+ {
+ undeployPackage(new String[] { deploymentName });
+ }
+ }
+
public void testTopic() throws Exception
{
@@ -98,6 +158,17 @@
undeployPackage(new String[] { deploymentName });
}
}
-
+
+ protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create)
+ {
+ Map<String, MetaValue> map = new HashMap<String, MetaValue>();
+
+ map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
+ map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
+ map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));
+
+ return new CompositeValueSupport(composite, map);
+ }
+
}
Copied: trunk/testsuite/src/resources/deployers/hd-jboss-beans.xml (from rev 87159, branches/Branch_5_x/testsuite/src/resources/deployers/hd-jboss-beans.xml)
===================================================================
--- trunk/testsuite/src/resources/deployers/hd-jboss-beans.xml (rev 0)
+++ trunk/testsuite/src/resources/deployers/hd-jboss-beans.xml 2009-04-15 12:26:23 UTC (rev 87340)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Empty deployment, to test hot-deployment -->
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list