[jboss-cvs] JBossAS SVN: r87159 - in branches/Branch_5_x: testsuite and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 11 06:59:44 EDT 2009
Author: emuckenhuber
Date: 2009-04-11 06:59:43 -0400 (Sat, 11 Apr 2009)
New Revision: 87159
Added:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/
branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
branches/Branch_5_x/testsuite/src/resources/deployers/hd-jboss-beans.xml
Removed:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
Modified:
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java
branches/Branch_5_x/testsuite/build.xml
branches/Branch_5_x/testsuite/imports/sections/deployers.xml
branches/Branch_5_x/testsuite/imports/sections/profileservice.xml
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java
Log:
run deploymentManager within tests-profileservice, add basic HD test
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java 2009-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java 2009-04-11 10:59:43 UTC (rev 87159)
@@ -114,6 +114,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();
@@ -202,6 +222,18 @@
}
/**
+ * 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
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java 2009-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java 2009-04-11 10:59:43 UTC (rev 87159)
@@ -30,9 +30,9 @@
import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.profileservice.spi.DeploymentContentFlags;
import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
import org.jboss.virtual.VirtualFile;
/**
@@ -179,7 +179,7 @@
ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
// Add
modified.add(info);
- addDeployment(ctx.getName(), ctx);
+ internalAddDeployment(ctx.getName(), ctx);
getChecker().addStructureRoot(vf);
}
}
Modified: branches/Branch_5_x/testsuite/build.xml
===================================================================
--- branches/Branch_5_x/testsuite/build.xml 2009-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/testsuite/build.xml 2009-04-11 10:59:43 UTC (rev 87159)
@@ -856,6 +856,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"/>
@@ -869,6 +870,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"/>
@@ -1070,6 +1072,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: branches/Branch_5_x/testsuite/imports/sections/deployers.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/deployers.xml 2009-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/testsuite/imports/sections/deployers.xml 2009-04-11 10:59:43 UTC (rev 87159)
@@ -387,7 +387,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: branches/Branch_5_x/testsuite/imports/sections/profileservice.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/profileservice.xml 2009-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/testsuite/imports/sections/profileservice.xml 2009-04-11 10:59:43 UTC (rev 87159)
@@ -56,11 +56,6 @@
<include name="testEarDeployment-application.xml"/>
</zipfileset>
</jar>
-
- <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"/>
<copy tofile="${build.lib}/profileservice-remove-ds.xml"
file="${build.resources}/profileservice/override/profileservice-remove-ds.xml"/>
Deleted: 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-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java 2009-04-11 10:59:43 UTC (rev 87159)
@@ -1,365 +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.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";
-
- /** 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();
- }
- }
- }
-
- 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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java (from rev 87158, branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java)
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java 2009-04-11 10:59:43 UTC (rev 87159)
@@ -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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java 2009-04-10 21:32:11 UTC (rev 87158)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java 2009-04-11 10:59:43 UTC (rev 87159)
@@ -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);
+ }
+
}
Added: branches/Branch_5_x/testsuite/src/resources/deployers/hd-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/hd-jboss-beans.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/hd-jboss-beans.xml 2009-04-11 10:59:43 UTC (rev 87159)
@@ -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