[jboss-cvs] JBossAS SVN: r93644 - in trunk/testsuite/src/main/org/jboss/test: profileservice/template/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 17 09:10:41 EDT 2009


Author: emuckenhuber
Date: 2009-09-17 09:10:41 -0400 (Thu, 17 Sep 2009)
New Revision: 93644

Added:
   trunk/testsuite/src/main/org/jboss/test/deployers/test/AbstractDeployTestBase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ConnectionFactoryUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
Modified:
   trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/DataSourceUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ManagementViewUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/PlatformMBeanUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java
Log:
update profileservice tests

Added: trunk/testsuite/src/main/org/jboss/test/deployers/test/AbstractDeployTestBase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/test/AbstractDeployTestBase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/test/AbstractDeployTestBase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -0,0 +1,247 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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 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.DeploymentOption;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDeployTestBase 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;
+   /** The management view. */
+   private ManagementView mgtView;
+   
+   public AbstractDeployTestBase(String name)
+   {
+      super(name);
+   }
+ 
+   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;
+   }
+   
+   DeploymentProgress distributeAndStart(String deploymentName, DeploymentOption... options) throws Exception
+   {
+      // The deployment manager
+      DeploymentManager deployMgr = getDeploymentManager();
+
+      // Distribute
+      DeploymentProgress distribute = deployMgr.distribute(deploymentName,
+            getDeployURL(deploymentName), options);
+      distribute.run();
+      // Distribute always has to complete
+      assertComplete(distribute);
+      // check if the app is stopped
+      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());
+      log.debug(md.getSimpleName() + " " + md.getTypes());
+   }
+
+   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/deployers/test/DeploymentManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -24,13 +24,10 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.net.URI;
 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.ComponentType;
 import org.jboss.managed.api.DeploymentState;
@@ -41,8 +38,8 @@
 import org.jboss.profileservice.spi.DeploymentOption;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.test.JBossTestCase;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * Basic DeploymentManager test.
@@ -50,24 +47,12 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class DeploymentManagerUnitTestCase extends JBossTestCase
+public class DeploymentManagerUnitTestCase extends AbstractDeployTestBase
 {
-   /** 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;
-
+   /** A deployment picked up by the HDScanner. */
+   private final static String HD_DEPLOYMENT = "hd-jboss-beans.xml";
+   
    public DeploymentManagerUnitTestCase(String name)
    {
       super(name);
@@ -134,6 +119,7 @@
          // complete
          deployEmpty(true);
          // Test redeploy
+         assertTrue(getDeploymentManager().isRedeploySupported());
          redeployCheckComplete(EMTPY_DEPLOYMENT);
          // TODO implement prepare
          prepareCheckComplete(EMTPY_DEPLOYMENT);
@@ -143,11 +129,8 @@
          log.debug("Failed ", e);
          throw e;
       }
-      finally
-      {
-         stopAndRemove(new String[]
-            { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
-      }
+      stopAndRemove(new String[]
+         { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
    }
 
    /**
@@ -164,6 +147,7 @@
          // complete
          deployEmpty(false);
          // test redeploy
+         assertTrue(getDeploymentManager().isRedeploySupported());
          redeployCheckComplete(EMTPY_DEPLOYMENT);
          // TODO implement prepare
          prepareCheckComplete(EMTPY_DEPLOYMENT);
@@ -173,11 +157,8 @@
          log.error("Failed ", e);
          throw e;
       }
-      finally
-      {
-         stopAndRemove(new String[]
-            { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
-      }
+      stopAndRemove(new String[]
+          { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
    }
 
    /**
@@ -193,7 +174,7 @@
          distributeAndStart(NESTED_DEPLOYMENT,
                new DeploymentOption[] { DeploymentOption.Explode});
 
-         // Test fail if exsits
+         // Test fail if exists
          DeploymentProgress override = getDeploymentManager().distribute(NESTED_DEPLOYMENT,
                getDeployURL(NESTED_DEPLOYMENT),
                new DeploymentOption[] { DeploymentOption.FailIfExists});
@@ -223,7 +204,11 @@
          // complete
          deployEmpty(true);
          // Test redeploy
+         assertTrue(getDeploymentManager().isRedeploySupported());
          redeployCheckComplete(EMTPY_DEPLOYMENT);
+         // stop and remove
+         stopAndRemove(new String[]
+             { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
       }
       catch(Exception e)
       {
@@ -232,20 +217,44 @@
       }
       finally
       {
-         try
-         {
-            stopAndRemove(new String[]
-               { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
-         }
-         finally
-         {
-            // Make sure that we release the profile
-            getDeploymentManager().releaseProfile();
-         }
+         // Make sure that we release the profile
+         getDeploymentManager().releaseProfile();
       }
    }
 
    /**
+    * Test some conflicts when deleting a file manually.
+    * This distributes a deployment into the deployers folder,
+    * where we don't perform HDScanning. We delete the file
+    * manually and then try to remove this file with the 
+    * DeploymentManager.
+    * 
+    * @throws Exception
+    */
+   public void testRemoveConflict() throws Exception
+   {
+      getDeploymentManager().loadProfile(deployersKey);
+      try
+      {
+         DeploymentProgress start = distributeAndStart(NESTED_DEPLOYMENT, true, false);
+         String deployed = start.getDeploymentID().getRepositoryNames()[0];
+         
+         // Delete the file manually
+         VFS.init();
+         VirtualFile f = VFS.getRoot(new URI(deployed));
+         assertTrue(deployed, f.exists());
+         assertTrue("deleted " + deployed, f.delete());
+         
+         stopAndRemove(new String[] { NESTED_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
@@ -267,7 +276,7 @@
       // Manually copy the deployment
       File output = copyFile(new File(homeDir, "deploy/"), HD_DEPLOYMENT);
       // Wait for HDScanner
-      Thread.sleep(10000);
+      Thread.sleep(8000);
       
       // Reload mgtView
       mgtView = getManagementView();
@@ -277,7 +286,7 @@
 
       output.delete();
       // Wait for HDScanner
-      Thread.sleep(10000);
+      Thread.sleep(8000);
       try
       {
          getManagementView().getDeployment(HD_DEPLOYMENT);
@@ -318,186 +327,5 @@
       }
       return output;
    }
-   
-   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;
-   }
-   
-   DeploymentProgress distributeAndStart(String deploymentName, DeploymentOption... options) throws Exception
-   {
-      // The deployment manager
-      DeploymentManager deployMgr = getDeploymentManager();
-
-      // Distribute
-      DeploymentProgress distribute = deployMgr.distribute(deploymentName,
-            getDeployURL(deploymentName), options);
-      distribute.run();
-      // Distribute always has to complete
-      assertComplete(distribute);
-      // check if the app is stopped
-      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());
-      log.debug(md.getSimpleName() + " " + md.getTypes());
-   }
-
-   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/template/test/JMSDestinationTemplateUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -21,6 +21,8 @@
  */ 
 package org.jboss.test.profileservice.template.test;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -68,12 +70,11 @@
 //      info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
 //      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
 //      
-//      info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
-//      info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
-//      info.getProperties().get("expiryQueue").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue")));
+//      info.getProperties().get("serverPeer").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "jboss.messaging.destination:service=Queue"));
+//      info.getProperties().get("DLQ").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "jboss.messaging.destination:service=Queue,name=PrivateDLQ"));
+//      info.getProperties().get("expiryQueue").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue"));
 //      info.getProperties().get("securityConfig").setValue(createComposityType());
 //      
-//      
 //      DeploymentTemplate t = new JmsDestinationTemplate();
 //      // Try to apply the template and delete the file afterwards
 //      t.applyTemplate(info);
@@ -85,11 +86,10 @@
 //            TopicServiceMO.class);
 //      
 //      info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
-//      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
-//      
-//      info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
-//      info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
-//      info.getProperties().get("expiryQueue").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue")));
+//      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));      
+//      info.getProperties().get("serverPeer").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "jboss.messaging.destination:service=Queue"));
+//      info.getProperties().get("DLQ").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "jboss.messaging.destination:service=Queue,name=PrivateDLQ"));      
+//      info.getProperties().get("expiryQueue").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue"));
 //      info.getProperties().get("securityConfig").setValue(createComposityType());
 //     
 //      DeploymentTemplate t = new JmsDestinationTemplate();
@@ -127,6 +127,12 @@
 
       return new CompositeValueSupport(compositeMetaType, map);
    }
+   
+   @Override
+   protected Collection<String> getExcludes()
+   {
+      return Collections.singleton("destinationType");
+   }
 
 }
 

Added: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ConnectionFactoryUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ConnectionFactoryUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ConnectionFactoryUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -0,0 +1,523 @@
+/*
+ * 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.profileservice.test;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
+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.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;
+
+/** Test of using ProfileService
+
+ @author Scott.Stark at jboss.org
+ @version $Revision: 93155 $
+ */
+public class ConnectionFactoryUnitTestCase extends AbstractProfileServiceTest
+{
+   
+   /**
+    * We need to define the order in which tests runs
+    * @return
+    * @throws Exception
+    */
+   public static Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+
+      // DataSource
+      suite.addTest(new ConnectionFactoryUnitTestCase("testAddDataSource"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testRemoveDataSource"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testAddXADataSource"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testRemoveXADataSource"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testAddTxConnectionFactory"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testRemoveTxConnectionFactory"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testAddTxXAConnectionFactory"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testRemoveTxXAConnectionFactory"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testAddNoTxConnectionFactory"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testRemoveNoTxConnectionFactory"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testAddNoTxDataSource"));
+      suite.addTest(new ConnectionFactoryUnitTestCase("testRemoveNoTxDataSource"));
+
+      return suite;
+   }
+
+   public ConnectionFactoryUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Test adding a new hsql DataSource deployment (JBAS-4671)
+    * @throws Exception
+    */
+   public void testAddDataSource() throws Exception
+   {
+      String jndiName = "TestLocalTxDs";
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+      addNonXaDsProperties(propValues, jndiName, "jboss-local-jdbc.rar", "javax.sql.DataSource");
+      createComponentTest("LocalTxDataSourceTemplate", propValues, "testLocalTxDs",
+         KnownComponentTypes.DataSourceTypes.LocalTx.getType(), jndiName);
+   }
+
+   public void testRemoveDataSource()
+      throws Exception
+   {
+      removeDeployment("testLocalTxDs-ds.xml");
+   }
+
+   /**
+    * Test adding a new hsql DataSource deployment
+    * @throws Exception
+    */
+   public void testAddXADataSource() throws Exception
+   {
+      String jndiName = "TestXaDs";
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+
+      addCommonDsProperties(propValues, jndiName, "jboss-xa-jdbc.rar", "javax.sql.DataSource");
+
+      propValues.put("xa-datasource-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
+      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
+      propValues.put("interleaving", SimpleValueSupport.wrap(true));
+
+      HashMap<String, String> xaPropValues = new HashMap<String, String>();
+      xaPropValues.put("URL", "jdbc:hsqldb");
+      xaPropValues.put("User", "sa");
+      xaPropValues.put("Password", "");
+
+      //MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
+      MetaValue metaValue = this.compositeValueMap(xaPropValues);
+      propValues.put("xa-datasource-properties", metaValue);
+
+      createComponentTest("XADataSourceTemplate", propValues, "testXaDs",
+         KnownComponentTypes.DataSourceTypes.XA.getType(), jndiName);
+ 
+      // Query the interleaving 
+      ManagementView mgtView = getManagementView();
+      ComponentType type = KnownComponentTypes.DataSourceTypes.XA.getType();
+      ManagedComponent txcf = mgtView.getComponent(jndiName, type);
+      assertNotNull(txcf);
+      ManagedProperty interleaving = txcf.getProperty("interleaving");
+      assertNotNull("interleaving", interleaving);
+      MetaValue interleavingMV = interleaving.getValue();
+      assertNotNull("interleaving.value", interleavingMV);
+      assertEquals("interleaving.value is true", SimpleValueSupport.wrap(Boolean.TRUE), interleavingMV);
+   }
+
+   /**
+    * removes the XADataSource created in the testAddXADataSource
+    * @throws Exception
+    */
+   public void testRemoveXADataSource()
+      throws Exception
+   {
+      removeDeployment("testXaDs-ds.xml");
+   }
+
+   /**
+    * Test adding a new tx-connection-factory deployment
+    * @throws Exception
+    */
+   public void testAddTxConnectionFactory() throws Exception
+   {
+      String jndiName = "TestTxCf";
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+
+      addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
+
+      Map<String, String> xaProps = new HashMap<String, String>();
+      xaProps.put("SessionDefaultType", "javax.jms.Topic");
+      xaProps.put("SessionDefaultType.type", "java.lang.String");
+      xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
+      xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
+      MetaValue metaValue = this.compositeValueMap(xaProps);
+
+      propValues.put("config-property", metaValue);
+
+      propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.FALSE));
+      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
+
+      // todo: how to set the specific domain?
+      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
+      //props.get("security-domain").setValue(secDomain);
+
+      createComponentTest("TxConnectionFactoryTemplate", propValues, "testTxCf",
+         new ComponentType("ConnectionFactory", "Tx"), jndiName);
+      // Query the interleaving 
+      ManagementView mgtView = getManagementView();
+      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
+      ManagedComponent txcf = mgtView.getComponent(jndiName, type);
+      assertNotNull(txcf);
+      ManagedProperty interleaving = txcf.getProperty("interleaving");
+      assertNotNull("interleaving", interleaving);
+      MetaValue interleavingMV = interleaving.getValue();
+      assertNotNull("interleaving.value", interleavingMV);
+      
+   }
+
+   /**
+    * removes the tx-connection-factory created in the testAddTxConnectionFactory
+    * @throws Exception
+    */
+   public void testRemoveTxConnectionFactory()
+      throws Exception
+   {
+      removeDeployment("testTxCf-ds.xml");
+   }
+
+   /**
+    * Test adding a new tx-connection-factory deployment with xa enabled
+    * @throws Exception
+    */
+   public void testAddTxXAConnectionFactory() throws Exception
+   {
+      String jndiName = "TestTxCf";
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+
+      addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
+
+      Map<String, String> xaProps = new HashMap<String, String>();
+      xaProps.put("SessionDefaultType", "javax.jms.Topic");
+      xaProps.put("SessionDefaultType.type", "java.lang.String");
+      xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
+      xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
+      MetaValue metaValue = this.compositeValueMap(xaProps);
+
+      propValues.put("config-property", metaValue);
+
+      propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
+      propValues.put("interleaving", SimpleValueSupport.wrap(Boolean.TRUE));
+
+      // todo: how to set the specific domain?
+      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
+      //props.get("security-domain").setValue(secDomain);
+
+      createComponentTest("TxConnectionFactoryTemplate", propValues, "testTxXACf",
+         new ComponentType("ConnectionFactory", "Tx"), jndiName);
+      // Query the interleaving 
+      ManagementView mgtView = getManagementView();
+      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
+      ManagedComponent txcf = mgtView.getComponent(jndiName, type);
+      assertNotNull(txcf);
+      ManagedProperty interleaving = txcf.getProperty("interleaving");
+      assertNotNull("interleaving", interleaving);
+      MetaValue interleavingMV = interleaving.getValue();
+      assertNotNull("interleaving.value", interleavingMV);
+      assertEquals(SimpleValueSupport.wrap(Boolean.TRUE), interleavingMV);
+   }
+
+   /**
+    * removes the tx-connection-factory created in the testAddXAConnectionFactory
+    * @throws Exception
+    */
+   public void testRemoveTxXAConnectionFactory()
+      throws Exception
+   {
+      removeDeployment("testTxXACf-ds.xml");
+   }
+
+   /**
+    * Test adding a new no-tx-datasource deployment (JBAS-4671)
+    * @throws Exception
+    */
+   public void testAddNoTxDataSource() throws Exception
+   {
+      String jndiName = "TestNoTxDs";
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+      addNonXaDsProperties(propValues, jndiName, "jboss-local-jdbc.rar", "javax.sql.DataSource");
+      createComponentTest("NoTxDataSourceTemplate", propValues, "testNoTxDs", KnownComponentTypes.DataSourceTypes.NoTx.getType(), jndiName);
+   }
+
+   public void testRemoveNoTxDataSource()
+      throws Exception
+   {
+      removeDeployment("testNoTxDs-ds.xml");
+   }
+
+   /**
+    * Test adding a new no-tx-connection-factory deployment
+    * @throws Exception
+    */
+   public void testAddNoTxConnectionFactory() throws Exception
+   {
+      String jndiName = "TestNoTxCf";
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+
+      addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
+
+      Map<String, String> xaProps = new HashMap<String, String>();
+      xaProps.put("SessionDefaultType", "javax.jms.Topic");
+      xaProps.put("SessionDefaultType.type", "java.lang.String");
+      xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
+      xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
+      MetaValue metaValue = this.compositeValueMap(xaProps);
+      propValues.put("config-property", metaValue);
+
+      propValues.put("config-property", 
+            new MapCompositeValueSupport(new HashMap<String, MetaValue>(),
+                  new MapCompositeMetaType(SimpleMetaType.STRING)));
+      // todo: how to set the specific domain?
+      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
+      //props.get("security-domain").setValue(secDomain);
+
+      ComponentType compType = new ComponentType("ConnectionFactory", "NoTx");
+      createComponentTest("NoTxConnectionFactoryTemplate", propValues, "testNoTxCf", compType, jndiName);
+
+      // Validate the config-property
+      ManagementView mgtView = getManagementView();
+      ManagedComponent dsMC = getManagedComponent(mgtView, compType, jndiName);
+      ManagedProperty configProperty = dsMC.getProperty("config-property");
+      assertNotNull(configProperty);
+      MetaValue value = configProperty.getValue();
+      assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
+      
+      MapCompositeValueSupport cValue = (MapCompositeValueSupport) value;
+      cValue.put("testKey", new SimpleValueSupport(SimpleMetaType.STRING, "testValue"));
+      
+      mgtView.updateComponent(dsMC);
+
+      mgtView = getManagementView();
+      dsMC = getManagedComponent(mgtView, compType, jndiName);
+      configProperty = dsMC.getProperty("config-property");
+      assertNotNull(configProperty);
+      cValue = (MapCompositeValueSupport) configProperty.getValue();
+      assertNotNull(cValue.get("testKey"));
+   }
+
+   /**
+    * removes the tx-connection-factory created in the testAddTxConnectionFactory
+    * @throws Exception
+    */
+   public void testRemoveNoTxConnectionFactory()
+      throws Exception
+   {
+      removeDeployment("testNoTxCf-ds.xml");
+   }
+
+
+   /**
+    * Validate that there is only 1 DefaultDS ManagedComponent
+    * @throws Exception
+    */
+   public void testJTAComponentCount()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      ComponentType type = new ComponentType("MCBean", "JTA");
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
+      int count = comps.size();
+      assertEquals("There is 1 MCBean:JTA ManagedComponent", 1, 1);
+      ManagedComponent comp = comps.iterator().next();
+      Map<String, ManagedProperty> props = comp.getProperties();
+      for(ManagedProperty prop : props.values())
+      {
+         log.info(prop+", : "+prop.getValue());
+      }
+   }
+
+   // Private and protected
+
+   private void addNonXaDsProperties(Map<String, MetaValue> propValues,
+                                     String jndiName,
+                                     String rarName,
+                                     String conDef)
+   {
+      addCommonDsProperties(propValues, jndiName, rarName, conDef);
+
+      propValues.put("transaction-isolation", SimpleValueSupport.wrap("TRANSACTION_SERIALIZABLE"));
+      propValues.put("user-name", SimpleValueSupport.wrap("sa"));
+      propValues.put("password", SimpleValueSupport.wrap(""));
+
+      // non xa ds
+      propValues.put("driver-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
+      propValues.put("connection-url", SimpleValueSupport.wrap("jdbc:hsqldb:."));
+      // A metadata type with a null type-mapping, JBAS-6215
+      MutableCompositeMetaType metadataType = new MutableCompositeMetaType("org.jboss.resource.metadata.mcf.DBMSMetaData", "metadata type");
+      metadataType.addItem("typeMapping", "The jdbc type mapping", SimpleMetaType.STRING);
+      HashMap<String, MetaValue> items = new HashMap<String, MetaValue>();
+      items.put("typeMapping", null);
+      CompositeValueSupport metadata = new CompositeValueSupport(metadataType, items);
+      propValues.put("metadata", metadata);
+
+      // todo: connection-properties
+   }
+
+   private void addCommonDsProperties(Map<String, MetaValue> propValues,
+                                              String jndiName,
+                                              String rarName,
+                                              String conDef)
+   {
+      addCommonCfProperties(propValues, jndiName, rarName, conDef);
+      propValues.put("new-connection-sql", SimpleValueSupport.wrap("CALL ABS(2.0)"));
+      propValues.put("check-valid-connection-sql", SimpleValueSupport.wrap("CALL ABS(1.0)"));
+      propValues.put("valid-connection-checker-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
+      propValues.put("exception-sorter-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter"));
+      propValues.put("stale-connection-checker-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
+      propValues.put("track-statements", SimpleValueSupport.wrap(""));
+      propValues.put("prepared-statement-cache-size", SimpleValueSupport.wrap(12));
+      propValues.put("share-prepared-statements", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("set-tx-query-timeout", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("query-timeout", SimpleValueSupport.wrap(new Integer(100)));
+      propValues.put("url-delimiter", SimpleValueSupport.wrap("+"));
+      propValues.put("url-selector-strategy-class-name", SimpleValueSupport.wrap("org.jboss.test.jca.support.MyURLSelector"));
+      propValues.put("use-try-lock", SimpleValueSupport.wrap(new Long(5000)));
+   }
+
+   private void addCommonCfProperties(Map<String, MetaValue> propValues,
+                                    String jndiName,
+                                    String rarName,
+                                    String conDef)
+   {
+      propValues.put("jndi-name", SimpleValueSupport.wrap(jndiName));
+      propValues.put("rar-name", SimpleValueSupport.wrap(rarName));
+      propValues.put("use-java-context", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("connection-definition", SimpleValueSupport.wrap(conDef));
+      //propValues.put("jmx-invoker-name", SimpleValueSupport.wrap("jboss:service=invoker,type=jrmp"));
+      propValues.put("min-pool-size", SimpleValueSupport.wrap(new Integer(0)));
+      propValues.put("max-pool-size", SimpleValueSupport.wrap(new Integer(11)));
+      propValues.put("blocking-timeout-millis", SimpleValueSupport.wrap(new Long(15000)));
+      propValues.put("idle-timeout-minutes", SimpleValueSupport.wrap(new Integer(111)));
+      propValues.put("prefill", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("background-validation", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("background-validation-millis", SimpleValueSupport.wrap(new Long(5000)));
+      propValues.put("validate-on-match", SimpleValueSupport.wrap(Boolean.FALSE));
+      propValues.put("use-strict-min", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("statistics-formatter", SimpleValueSupport.wrap("org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"));
+      propValues.put("isSameRM-override-value", SimpleValueSupport.wrap(Boolean.FALSE));
+      propValues.put("type-mapping", SimpleValueSupport.wrap("Hypersonic SQL"));
+      // todo: config-property
+      // todo: security-domain
+      // todo: depends
+      // todo: metadata
+      // todo: local-transaction
+   }
+
+   protected void createComponentTest(String templateName,
+                                    Map<String, MetaValue> propValues,
+                                    String deploymentName,
+                                    ComponentType componentType, String componentName)
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      DeploymentTemplateInfo dsInfo = mgtView.getTemplate(templateName);
+      assertNotNull("template " + templateName + " found", dsInfo);
+      Map<String, ManagedProperty> props = dsInfo.getProperties();
+
+      for(String propName : propValues.keySet())
+      {
+         ManagedProperty prop = props.get(propName);
+         // If the property does not exist on the template we don't set it
+         if(prop == null)
+            continue;
+         
+         log.debug("template property before: "+prop.getName()+","+prop.getValue());
+         assertNotNull("property " + propName + " found in template " + templateName, prop);
+         prop.setValue(propValues.get(propName));
+         log.debug("template property after: "+prop.getName()+","+prop.getValue());
+      }
+      
+      // Assert map composite
+      if(dsInfo.getProperties().get("config-property") != null)
+         assertTrue(dsInfo.getProperties().get("config-property").getMetaType() instanceof MapCompositeMetaType);
+      
+      mgtView.applyTemplate(deploymentName, dsInfo);
+
+      // reload the view
+      activeView = null;
+      mgtView = getManagementView();
+      ManagedComponent dsMC = getManagedComponent(mgtView, componentType, componentName);
+      assertNotNull(dsMC);
+
+      Set<String> mcPropNames = new HashSet<String>(dsMC.getPropertyNames());
+      for(String propName : propValues.keySet())
+      {
+         ManagedProperty prop = dsMC.getProperty(propName);
+         log.debug("Checking: "+propName);
+         assertNotNull(propName, prop);
+         Object propValue = prop.getValue();
+         Object expectedValue = propValues.get(propName);
+         if(propValue instanceof MetaValue)
+         {
+            if (prop.getMetaType().isComposite())
+            {
+               // TODO / FIXME - compare composites
+               log.warn("Not checking composite: "+propValue);
+            }
+            else
+            {
+               // Compare the MetaValues
+               assertEquals(prop.getName(), expectedValue, propValue);
+            }
+         }
+         else if(propValue != null)
+         {
+            fail(prop.getName()+" is not a MetaValue: "+propValue);
+         }
+
+         mcPropNames.remove(propName);
+      }
+
+      if(!mcPropNames.isEmpty())
+      {
+         log.warn(getName() + "> untested properties: " + mcPropNames);
+         for(String propName : mcPropNames)
+         {
+            ManagedProperty prop = dsMC.getProperty(propName);
+            log.info(prop);
+         }
+      }
+   }
+
+   public MapCompositeValueSupport compositeValueMap(Map<String,String> map)
+   {
+      // TODO: update MetaValueFactory for MapCompositeMetaType
+      // MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
+      MapCompositeValueSupport metaValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
+      for(String key : map.keySet())
+      {
+         MetaValue value = SimpleValueSupport.wrap(map.get(key));
+         metaValue.put(key, value);
+      }
+
+      return metaValue;
+   }
+
+}

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/DataSourceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DataSourceUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DataSourceUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -21,23 +21,13 @@
  */
 package org.jboss.test.profileservice.test;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-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.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;

Added: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -0,0 +1,227 @@
+/*
+ * 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.profileservice.test;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.RunState;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.TableValue;
+import org.jboss.test.ejb.proxy.beans.StatefulCounter;
+import org.jboss.test.ejb.proxy.beans.StatefulCounterHome;
+import org.jboss.test.ejb.proxy.beans.HandleRetrievalStatefulSessionInterceptor.RetrievalMethodHandle;
+import org.jboss.test.ejb.proxy.test.ProxyLogicTestCase;
+
+/**
+ * Tests JMX components exposed outside the MC
+ *
+ * @author Jason T. Greene
+ */
+public class JMXMappingUnitTestCase extends AbstractProfileServiceTest
+{
+   public JMXMappingUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(JMXMappingUnitTestCase.class, "ejbproxy-test.jar");
+   }
+
+   public void testEjbMetrics() throws Exception
+   {
+      getLog().debug(getName());
+
+      Object ref = getInitialContext().lookup("ejb/StatefulCounterEjb");
+      StatefulCounterHome home = (StatefulCounterHome) PortableRemoteObject.narrow(ref, StatefulCounterHome.class);
+      StatefulCounter counter = home.create();
+
+      assertEquals(1, counter.count());
+      assertEquals(2, counter.count());
+
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("EJB", "StatefulSession"));
+      for (ManagedComponent comp : comps)
+      {
+         System.out.println(comp.getName());
+         ManagedProperty property = comp.getProperty("DetypedInvocationStatistics");
+         if ("jboss.j2ee:jndiName=ejb/StatefulCounterEjb,service=EJB".equals(comp.getName()))
+         {
+            MetaValue value = property.getValue();
+            System.out.println("Value = " + value);
+            CompositeValue methodStatsMap = (CompositeValue)((CompositeValue) value).get("methodStats");
+            CompositeValue methodStats = (CompositeValue)methodStatsMap.get("count");
+            assertEquals(2L, ((SimpleValue)methodStats.get("count")).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find EJB!");
+   }
+
+   public void testWebApplicationManager()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebApplicationManager"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:host=localhost,path=/jmx-console,type=Manager".equals(comp.getName()))
+         {
+            assertEquals(16, ((SimpleValue)comp.getProperty("sessionIdLength").getValue()).getValue());
+            assertEquals("MD5", ((SimpleValue)comp.getProperty("algorithm").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find jmx-console Manager");
+   }
+
+   public void testServlet() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "Servlet"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:J2EEApplication=none,J2EEServer=none,WebModule=//localhost/jmx-console,j2eeType=Servlet,name=HtmlAdaptor".equals(comp.getName()))
+         {
+            assertEquals("jboss.web", ((SimpleValue)comp.getProperty("engineName").getValue()).getValue());
+
+            // Statistic
+            int requests = (Integer)((SimpleValue)comp.getProperty("requestCount").getValue()).getValue();
+            new URL("http://" + getServerHost() + ":8080/jmx-console/HtmlAdaptor").openStream().close();
+            assertEquals(requests + 1, ((SimpleValue)comp.getProperty("requestCount").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find HtmlAdapor servlet");
+   }
+
+   public void testWebApplication() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebApplication"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/jmx-console".equals(comp.getName()))
+         {
+            assertEquals("jboss", ((SimpleValue)comp.getProperty("server").getValue()).getValue());
+            ((SimpleValue)comp.getProperty("docBase").getValue()).getValue().toString().endsWith("jmx-console.war/");
+
+            return;
+         }
+      }
+
+      fail("Could not find jmx-console Web Application");
+   }
+
+   public void testWebHost() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebHost"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:host=localhost,type=Host".equals(comp.getName()))
+         {
+            assertEquals("localhost", ((SimpleValue)comp.getProperty("name").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find localhost Host");
+   }
+
+   public void testConnector() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebRequestProcessor"));
+      for (ManagedComponent comp : comps)
+      {
+         if (comp.getName().startsWith("jboss.web:name=http-"))
+         {
+            // Statistic
+            int requests = (Integer)((SimpleValue)comp.getProperty("requestCount").getValue()).getValue();
+            new URL("http://" + getServerHost() + ":8080/").openStream().close();
+            assertEquals(requests + 1, ((SimpleValue)comp.getProperty("requestCount").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find connector!");
+   }
+
+   public void testContextMO() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      mgtView.load();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("WAR", "Context"));
+      for (ManagedComponent comp : comps)
+      {
+         if (comp.getDeployment().getName().endsWith("jmx-console.war/"))
+         {
+            assertEquals("/jmx-console", ((SimpleValue)comp.getProperty("contextRoot").getValue()).getValue());
+            return;
+         }
+      }
+
+      fail("Could not find deployment context root!");
+   }
+
+   public void testRunState() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "WebHost"));
+      for (ManagedComponent comp : comps)
+      {
+         if ("jboss.web:host=localhost,type=Host".equals(comp.getName()))
+         {
+            assertEquals(RunState.RUNNING, comp.getRunState());
+            return;
+         }
+      }
+
+      fail("Could not find localhost Host");
+   }
+
+}
\ No newline at end of file

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -56,6 +56,8 @@
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.api.RunState;
 import org.jboss.managed.plugins.ManagedOperationMatcher;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
 import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.types.SimpleMetaType;
@@ -223,10 +225,45 @@
    public void testQueueOperations() throws Exception
    {
       ManagedComponent component = getManagementView().getComponent("testCreateQueue", QueueType);
+
+      // Send a few messages so the message based ops have values
+      sendQueueMsgs("testCreateQueue", component);
+
+      
       ManagedOperation o = getOperation(component, "listMessageCounterAsHTML", new String[0]);
       MetaValue v = o.invoke(new MetaValue[0]);
       assertNotNull("null operation return value", v);
-      log.debug("result" + v);
+      log.debug("result: " + v);
+      
+      
+      // JBAS-7024,
+      ManagedOperation listAllMessages = getOperation(component, "listAllMessages", new String[0]);
+      MetaType listAllMessagesRT = listAllMessages.getReturnType();
+      log.debug("listAllMessagesRT: " + listAllMessagesRT);
+      MetaValue listAllMessagesMV = listAllMessages.invoke(new MetaValue[0]);
+      assertNotNull("null operation return value", listAllMessagesMV);
+      log.debug("result: " + listAllMessagesMV);
+      MetaType resultType = listAllMessagesMV.getMetaType();
+      log.debug("resultType: "+resultType);
+      assertTrue("resultType instanceof CompositeMetaType", resultType instanceof CollectionMetaType);
+      CollectionMetaType resultCMT = (CollectionMetaType) resultType;
+      MetaType resultElementType = resultCMT.getElementType();
+      log.debug("resultElementType: "+resultElementType);
+      assertTrue("resultElementType instanceof CompositeMetaType", resultElementType instanceof CompositeMetaType);
+      log.debug("resultElementType: "+resultElementType);
+      CollectionValue listAllMessagesCV = (CollectionValue) listAllMessagesMV;
+      MetaValue[] listAllMessagesElements = listAllMessagesCV.getElements();
+      log.debug("listAllMessagesElements: "+listAllMessagesElements);
+      if(listAllMessagesElements.length > 0)
+      {
+         MetaValue m0 = listAllMessagesElements[0];
+         MetaType m0MT = m0.getMetaType();
+         assertTrue("m0MT.isComposite", m0MT.isComposite());
+         assertTrue("m0MT instanceof CompositeMetaType", m0MT instanceof CompositeMetaType);
+         assertTrue("m0 instanceof CompositeValue", m0 instanceof CompositeValue);
+         CompositeValue m0MV = (CompositeValue) m0;
+         log.debug("m0MV.values: "+m0MV.values());
+      }
    }
    
    public void testQueueRestart() throws Exception
@@ -303,7 +340,7 @@
       assertEquals("testCreateQueue2", queue2.getName());
       
    }
-
+   
    /**
     * JBAS-6939
     * @throws Exception

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ManagementViewUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ManagementViewUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ManagementViewUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -59,8 +59,16 @@
          {
             for(String deploymentName : deploymentNames)
             {
-               ManagedDeployment deployment = mgtView.getDeployment(deploymentName);
-               log.debug(deployment.getSimpleName());
+               try
+               {
+                  ManagedDeployment deployment = mgtView.getDeployment(deploymentName);
+                  log.debug(deployment.getSimpleName());
+               }
+               catch(Exception e)
+               {
+                  log.error("failed to get " + deploymentName, e);
+                  throw e;
+               }
             }
          }
       }

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/PlatformMBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/PlatformMBeanUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/PlatformMBeanUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -204,7 +204,9 @@
       MemoryUsage nonHeapMemoryUsageMU = ManagementFactoryUtils.unwrapMemoryUsage(nonHeapMemoryUsageMV);
       assertTrue(nonHeapMemoryUsageMU.getInit() >= 0);
       assertTrue(nonHeapMemoryUsageMU.getUsed() >= 1000);
-      assertTrue(nonHeapMemoryUsageMU.getMax() >= nonHeapMemoryUsageMU.getCommitted());
+      // Ignore undefined nonHeap max memory, seen with IBM JDK 6 
+      if(nonHeapMemoryUsageMU.getMax() != -1)
+    	  assertTrue(nonHeapMemoryUsageMU.getMax() >= nonHeapMemoryUsageMU.getCommitted());
       assertTrue(nonHeapMemoryUsageMU.getCommitted() >=  nonHeapMemoryUsageMU.getUsed());
       // objectPendingFinalizationCount
       ManagedProperty objectPendingFinalizationCount = props.get("objectPendingFinalizationCount");
@@ -302,7 +304,12 @@
       Set<ManagedOperation> ops = mo.getOperations();
       log.debug(ops);
 
-      assertEquals("Ops count is 8", 8, ops.size());
+      String javaSpecVersion = System.getProperty("java.specification.version");
+      if (javaSpecVersion.equals("1.5") || javaSpecVersion.equals("5.0"))
+         assertEquals(mo + " has wrong number of ManagedOperations.", 8, ops.size());
+      else if (javaSpecVersion.equals("1.6") || javaSpecVersion.equals("6.0"))
+         assertEquals(mo + " has wrong number of ManagedOperations.", 11, ops.size());
+
       ManagedOperation getThreadInfo = ManagedOperationMatcher.findOperation(ops,
             "getThreadInfo", SimpleMetaType.LONG_PRIMITIVE, SimpleMetaType.INTEGER_PRIMITIVE);
       assertNotNull("getThreadInfo", getThreadInfo);

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -34,7 +34,6 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.jboss.deployers.spi.management.KnownComponentTypes;
 import org.jboss.deployers.spi.management.KnownDeploymentTypes;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
@@ -49,13 +48,9 @@
 import org.jboss.metatype.api.types.CompositeMetaType;
 import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.MetaType;
-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.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
@@ -95,18 +90,6 @@
       suite.addTest(new ProfileServiceUnitTestCase("testUpdateDefaultDS"));
       suite.addTest(new ProfileServiceUnitTestCase("testDefaultDSOps"));
       suite.addTest(new ProfileServiceUnitTestCase("testDefaultDSStats"));
-      suite.addTest(new ProfileServiceUnitTestCase("testAddDataSource"));
-      suite.addTest(new ProfileServiceUnitTestCase("testRemoveDataSource"));
-      suite.addTest(new ProfileServiceUnitTestCase("testAddXADataSource"));
-      suite.addTest(new ProfileServiceUnitTestCase("testRemoveXADataSource"));
-      suite.addTest(new ProfileServiceUnitTestCase("testAddTxConnectionFactory"));
-      suite.addTest(new ProfileServiceUnitTestCase("testRemoveTxConnectionFactory"));
-      suite.addTest(new ProfileServiceUnitTestCase("testAddTxXAConnectionFactory"));
-      suite.addTest(new ProfileServiceUnitTestCase("testRemoveTxXAConnectionFactory"));
-      suite.addTest(new ProfileServiceUnitTestCase("testAddNoTxConnectionFactory"));
-      suite.addTest(new ProfileServiceUnitTestCase("testRemoveNoTxConnectionFactory"));
-      suite.addTest(new ProfileServiceUnitTestCase("testAddNoTxDataSource"));
-      suite.addTest(new ProfileServiceUnitTestCase("testRemoveNoTxDataSource"));
 
       return suite;
    }
@@ -510,6 +493,19 @@
    }
 
    /**
+    * Validate that the XADataSourceTemplate ManagedPropertys are values are of type MetaValue
+    * @throws Exception
+    */
+   public void testXADataSourceTemplateTemplatePropertiesAreMetaValues()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      DeploymentTemplateInfo dsInfo = mgtView.getTemplate("XADataSourceTemplate");
+      Map<String,ManagedProperty> props = dsInfo.getProperties();
+      validatePropertyMetaValues(props);
+   }
+   
+   /**
     * Validate that there is only 1 DefaultDS ManagedComponent
     * @throws Exception
     */
@@ -650,259 +646,8 @@
       assertTrue("result is a MetaValue", result instanceof MetaValue);
    }
 
-   /**
-    * Test adding a new hsql DataSource deployment (JBAS-4671)
-    * @throws Exception
-    */
-   public void testAddDataSource() throws Exception
-   {
-      String jndiName = "TestLocalTxDs";
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-      addNonXaDsProperties(propValues, jndiName, "jboss-local-jdbc.rar", "javax.sql.DataSource");
-      createComponentTest("LocalTxDataSourceTemplate", propValues, "testLocalTxDs",
-         KnownComponentTypes.DataSourceTypes.LocalTx.getType(), jndiName);
-   }
 
-   public void testRemoveDataSource()
-      throws Exception
-   {
-      removeDeployment("testLocalTxDs-ds.xml");
-   }
-
    /**
-    * Validate that the XADataSourceTemplate ManagedPropertys are values are of type MetaValue
-    * @throws Exception
-    */
-   public void testXADataSourceTemplateTemplatePropertiesAreMetaValues()
-      throws Exception
-   {
-      ManagementView mgtView = getManagementView();
-      DeploymentTemplateInfo dsInfo = mgtView.getTemplate("XADataSourceTemplate");
-      Map<String,ManagedProperty> props = dsInfo.getProperties();
-      validatePropertyMetaValues(props);
-   }
-   /**
-    * Test adding a new hsql DataSource deployment
-    * @throws Exception
-    */
-   public void testAddXADataSource() throws Exception
-   {
-      String jndiName = "TestXaDs";
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-
-      addCommonDsProperties(propValues, jndiName, "jboss-xa-jdbc.rar", "javax.sql.DataSource");
-
-      propValues.put("xa-datasource-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
-      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
-      propValues.put("interleaving", SimpleValueSupport.wrap(true));
-
-      HashMap<String, String> xaPropValues = new HashMap<String, String>();
-      xaPropValues.put("URL", "jdbc:hsqldb");
-      xaPropValues.put("User", "sa");
-      xaPropValues.put("Password", "");
-
-      //MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
-      MetaValue metaValue = this.compositeValueMap(xaPropValues);
-      propValues.put("xa-datasource-properties", metaValue);
-
-      createComponentTest("XADataSourceTemplate", propValues, "testXaDs",
-         KnownComponentTypes.DataSourceTypes.XA.getType(), jndiName);
-   }
-
-   /**
-    * removes the XADataSource created in the testAddXADataSource
-    * @throws Exception
-    */
-   public void testRemoveXADataSource()
-      throws Exception
-   {
-      removeDeployment("testXaDs-ds.xml");
-   }
-
-   /**
-    * Test adding a new tx-connection-factory deployment
-    * @throws Exception
-    */
-   public void testAddTxConnectionFactory() throws Exception
-   {
-      String jndiName = "TestTxCf";
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-
-      addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
-
-      Map<String, String> xaProps = new HashMap<String, String>();
-      xaProps.put("SessionDefaultType", "javax.jms.Topic");
-      xaProps.put("SessionDefaultType.type", "java.lang.String");
-      xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
-      xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
-      MetaValue metaValue = this.compositeValueMap(xaProps);
-
-      propValues.put("config-property", metaValue);
-
-      propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.FALSE));
-      propValues.put("interleaving", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
-
-      // todo: how to set the specific domain?
-      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
-      //props.get("security-domain").setValue(secDomain);
-
-      createComponentTest("TxConnectionFactoryTemplate", propValues, "testTxCf",
-         new ComponentType("ConnectionFactory", "Tx"), jndiName);
-      // Query the interleaving 
-      ManagementView mgtView = getManagementView();
-      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
-      ManagedComponent txcf = mgtView.getComponent(jndiName, type);
-      assertNotNull(txcf);
-      ManagedProperty interleaving = txcf.getProperty("interleaving");
-      assertNotNull("interleaving", interleaving);
-      MetaValue interleavingMV = interleaving.getValue();
-      assertNotNull("interleaving.value", interleavingMV);
-      
-   }
-
-   /**
-    * removes the tx-connection-factory created in the testAddTxConnectionFactory
-    * @throws Exception
-    */
-   public void testRemoveTxConnectionFactory()
-      throws Exception
-   {
-      removeDeployment("testTxCf-ds.xml");
-   }
-
-   /**
-    * Test adding a new tx-connection-factory deployment with xa enabled
-    * @throws Exception
-    */
-   public void testAddTxXAConnectionFactory() throws Exception
-   {
-      String jndiName = "TestTxCf";
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-
-      addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
-
-      Map<String, String> xaProps = new HashMap<String, String>();
-      xaProps.put("SessionDefaultType", "javax.jms.Topic");
-      xaProps.put("SessionDefaultType.type", "java.lang.String");
-      xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
-      xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
-      MetaValue metaValue = this.compositeValueMap(xaProps);
-
-      propValues.put("config-property", metaValue);
-
-      propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
-      propValues.put("interleaving", SimpleValueSupport.wrap(Boolean.TRUE));
-
-      // todo: how to set the specific domain?
-      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
-      //props.get("security-domain").setValue(secDomain);
-
-      createComponentTest("TxConnectionFactoryTemplate", propValues, "testTxXACf",
-         new ComponentType("ConnectionFactory", "Tx"), jndiName);
-      // Query the interleaving 
-      ManagementView mgtView = getManagementView();
-      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
-      ManagedComponent txcf = mgtView.getComponent(jndiName, type);
-      assertNotNull(txcf);
-      ManagedProperty interleaving = txcf.getProperty("interleaving");
-      assertNotNull("interleaving", interleaving);
-      MetaValue interleavingMV = interleaving.getValue();
-      assertNotNull("interleaving.value", interleavingMV);
-      assertEquals(SimpleValueSupport.wrap(Boolean.TRUE), interleavingMV);
-   }
-
-   /**
-    * removes the tx-connection-factory created in the testAddXAConnectionFactory
-    * @throws Exception
-    */
-   public void testRemoveTxXAConnectionFactory()
-      throws Exception
-   {
-      removeDeployment("testTxXACf-ds.xml");
-   }
-
-   /**
-    * Test adding a new no-tx-datasource deployment (JBAS-4671)
-    * @throws Exception
-    */
-   public void testAddNoTxDataSource() throws Exception
-   {
-      String jndiName = "TestNoTxDs";
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-      addNonXaDsProperties(propValues, jndiName, "jboss-local-jdbc.rar", "javax.sql.DataSource");
-      createComponentTest("NoTxDataSourceTemplate", propValues, "testNoTxDs", KnownComponentTypes.DataSourceTypes.NoTx.getType(), jndiName);
-   }
-
-   public void testRemoveNoTxDataSource()
-      throws Exception
-   {
-      removeDeployment("testNoTxDs-ds.xml");
-   }
-
-   /**
-    * Test adding a new no-tx-connection-factory deployment
-    * @throws Exception
-    */
-   public void testAddNoTxConnectionFactory() throws Exception
-   {
-      String jndiName = "TestNoTxCf";
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-
-      addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
-
-      Map<String, String> xaProps = new HashMap<String, String>();
-      xaProps.put("SessionDefaultType", "javax.jms.Topic");
-      xaProps.put("SessionDefaultType.type", "java.lang.String");
-      xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
-      xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
-      MetaValue metaValue = this.compositeValueMap(xaProps);
-      propValues.put("config-property", metaValue);
-
-      propValues.put("config-property", 
-            new MapCompositeValueSupport(new HashMap<String, MetaValue>(),
-                  new MapCompositeMetaType(SimpleMetaType.STRING)));
-      // todo: how to set the specific domain?
-      //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
-      //props.get("security-domain").setValue(secDomain);
-
-      ComponentType compType = new ComponentType("ConnectionFactory", "NoTx");
-      createComponentTest("NoTxConnectionFactoryTemplate", propValues, "testNoTxCf", compType, jndiName);
-
-      // Validate the config-property
-      ManagementView mgtView = getManagementView();
-      ManagedComponent dsMC = getManagedComponent(mgtView, compType, jndiName);
-      ManagedProperty configProperty = dsMC.getProperty("config-property");
-      assertNotNull(configProperty);
-      MetaValue value = configProperty.getValue();
-      assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
-      
-      MapCompositeValueSupport cValue = (MapCompositeValueSupport) value;
-      cValue.put("testKey", new SimpleValueSupport(SimpleMetaType.STRING, "testValue"));
-      
-      mgtView.updateComponent(dsMC);
-
-      mgtView = getManagementView();
-      dsMC = getManagedComponent(mgtView, compType, jndiName);
-      configProperty = dsMC.getProperty("config-property");
-      assertNotNull(configProperty);
-      cValue = (MapCompositeValueSupport) configProperty.getValue();
-      assertNotNull(cValue.get("testKey"));
-   }
-
-   /**
-    * removes the tx-connection-factory created in the testAddTxConnectionFactory
-    * @throws Exception
-    */
-   public void testRemoveNoTxConnectionFactory()
-      throws Exception
-   {
-      removeDeployment("testNoTxCf-ds.xml");
-   }
-
-
-   /**
     * Validate that there is only 1 DefaultDS ManagedComponent
     * @throws Exception
     */
@@ -924,82 +669,6 @@
 
    // Private and protected
 
-   private void addNonXaDsProperties(Map<String, MetaValue> propValues,
-                                     String jndiName,
-                                     String rarName,
-                                     String conDef)
-   {
-      addCommonDsProperties(propValues, jndiName, rarName, conDef);
-
-      propValues.put("transaction-isolation", SimpleValueSupport.wrap("TRANSACTION_SERIALIZABLE"));
-      propValues.put("user-name", SimpleValueSupport.wrap("sa"));
-      propValues.put("password", SimpleValueSupport.wrap(""));
-
-      // non xa ds
-      propValues.put("driver-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
-      propValues.put("connection-url", SimpleValueSupport.wrap("jdbc:hsqldb:."));
-      // A metadata type with a null type-mapping, JBAS-6215
-      MutableCompositeMetaType metadataType = new MutableCompositeMetaType("org.jboss.resource.metadata.mcf.DBMSMetaData", "metadata type");
-      metadataType.addItem("typeMapping", "The jdbc type mapping", SimpleMetaType.STRING);
-      HashMap<String, MetaValue> items = new HashMap<String, MetaValue>();
-      items.put("typeMapping", null);
-      CompositeValueSupport metadata = new CompositeValueSupport(metadataType, items);
-      propValues.put("metadata", metadata);
-
-      // todo: connection-properties
-   }
-
-   private void addCommonDsProperties(Map<String, MetaValue> propValues,
-                                              String jndiName,
-                                              String rarName,
-                                              String conDef)
-   {
-      addCommonCfProperties(propValues, jndiName, rarName, conDef);
-      propValues.put("new-connection-sql", SimpleValueSupport.wrap("CALL ABS(2.0)"));
-      propValues.put("check-valid-connection-sql", SimpleValueSupport.wrap("CALL ABS(1.0)"));
-      propValues.put("valid-connection-checker-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
-      propValues.put("exception-sorter-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter"));
-      propValues.put("stale-connection-checker-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
-      propValues.put("track-statements", SimpleValueSupport.wrap(""));
-      propValues.put("prepared-statement-cache-size", SimpleValueSupport.wrap(12));
-      propValues.put("share-prepared-statements", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("set-tx-query-timeout", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("query-timeout", SimpleValueSupport.wrap(new Integer(100)));
-      propValues.put("url-delimiter", SimpleValueSupport.wrap("+"));
-      propValues.put("url-selector-strategy-class-name", SimpleValueSupport.wrap("org.jboss.test.jca.support.MyURLSelector"));
-      propValues.put("use-try-lock", SimpleValueSupport.wrap(new Long(5000)));
-   }
-
-   private void addCommonCfProperties(Map<String, MetaValue> propValues,
-                                    String jndiName,
-                                    String rarName,
-                                    String conDef)
-   {
-      propValues.put("jndi-name", SimpleValueSupport.wrap(jndiName));
-      propValues.put("rar-name", SimpleValueSupport.wrap(rarName));
-      propValues.put("use-java-context", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("connection-definition", SimpleValueSupport.wrap(conDef));
-      //propValues.put("jmx-invoker-name", SimpleValueSupport.wrap("jboss:service=invoker,type=jrmp"));
-      propValues.put("min-pool-size", SimpleValueSupport.wrap(new Integer(0)));
-      propValues.put("max-pool-size", SimpleValueSupport.wrap(new Integer(11)));
-      propValues.put("blocking-timeout-millis", SimpleValueSupport.wrap(new Long(15000)));
-      propValues.put("idle-timeout-minutes", SimpleValueSupport.wrap(new Integer(111)));
-      propValues.put("prefill", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("background-validation", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("background-validation-millis", SimpleValueSupport.wrap(new Long(5000)));
-      propValues.put("validate-on-match", SimpleValueSupport.wrap(Boolean.FALSE));
-      propValues.put("use-strict-min", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
-      propValues.put("statistics-formatter", SimpleValueSupport.wrap("org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"));
-      propValues.put("isSameRM-override-value", SimpleValueSupport.wrap(Boolean.FALSE));
-      propValues.put("type-mapping", SimpleValueSupport.wrap("Hypersonic SQL"));
-      // todo: config-property
-      // todo: security-domain
-      // todo: depends
-      // todo: metadata
-      // todo: local-transaction
-   }
-
    protected void createComponentTest(String templateName,
                                     Map<String, MetaValue> propValues,
                                     String deploymentName,
@@ -1076,20 +745,6 @@
       }
    }
 
-   public MapCompositeValueSupport compositeValueMap(Map<String,String> map)
-   {
-      // TODO: update MetaValueFactory for MapCompositeMetaType
-      // MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
-      MapCompositeValueSupport metaValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
-      for(String key : map.keySet())
-      {
-         MetaValue value = SimpleValueSupport.wrap(map.get(key));
-         metaValue.put(key, value);
-      }
-
-      return metaValue;
-   }
-
    protected void validatePropertyMetaValues(Map<String, ManagedProperty> props)
    {
       HashMap<String, Object> invalidValues = new HashMap<String, Object>();

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java	2009-09-17 13:02:48 UTC (rev 93643)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/SecurityManagedObjectsTestCase.java	2009-09-17 13:10:41 UTC (rev 93644)
@@ -320,7 +320,7 @@
       // verify that the component has the expected managed properties.
       Map<String, ManagedProperty> properties = component.getProperties();
       assertNotNull(properties);
-      assertEquals("Unexpected number of properties", 14, properties.size());
+      assertEquals("Unexpected number of properties", 20, properties.size());
       assertTrue("Missing expected property: securityDomain", properties.containsKey("securityDomain"));
       assertTrue("Missing expected property: state", properties.containsKey("state"));
       // keystore and truststore configuration properties.




More information about the jboss-cvs-commits mailing list