[jboss-cvs] JBossAS SVN: r87888 - in trunk/testsuite/src/main/org/jboss/test: profileservice/override/restart/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 27 14:01:43 EDT 2009


Author: emuckenhuber
Date: 2009-04-27 14:01:43 -0400 (Mon, 27 Apr 2009)
New Revision: 87888

Modified:
   trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
merge profileservice testcases with 5_x branch.

Modified: trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/test/DeploymentManagerUnitTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -18,9 +18,12 @@
  * 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.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.util.Collection;
 
 import javax.naming.InitialContext;
@@ -29,8 +32,11 @@
 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;
+import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
@@ -38,7 +44,7 @@
 
 /**
  * Basic DeploymentManager test.
- * 
+ *
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -52,10 +58,10 @@
    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;
@@ -64,10 +70,10 @@
    {
       super(name);
    }
-   
+
    /**
     * Test the available profiles.
-    * 
+    *
     * @throws Exception
     */
    public void testAvaiableProfiles() throws Exception
@@ -78,11 +84,11 @@
       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
@@ -91,14 +97,17 @@
       {
          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);
             
-            Thread.sleep(50);
+            redeployCheckComplete(NESTED_DEPLOYMENT);
          }
       }
       catch(Exception e)
@@ -111,23 +120,23 @@
          stopAndRemove(new String[] { NESTED_DEPLOYMENT });
       }
    }
-   
+
    /**
     * Basic copyContent test to the default location.
-    * 
+    *
     * @throws Exception
     */
    public void testCopyContent() throws Exception
    {
       try
       {
-         // failed 
+         // failed
          deployFailed(true);
          // complete
          deployEmpty(true);
          // Test redeploy
          redeployCheckComplete(EMTPY_DEPLOYMENT);
-         // TODO implement prepare 
+         // TODO implement prepare
          prepareCheckComplete(EMTPY_DEPLOYMENT);
       }
       catch(Exception e)
@@ -141,17 +150,17 @@
             { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
       }
    }
-   
+
    /**
     * Basic noCopyContent test.
-    * 
+    *
     * @throws Exception
     */
    public void testNoCopyContent() throws Exception
    {
       try
       {
-         // failed 
+         // failed
          deployFailed(false);
          // complete
          deployEmpty(false);
@@ -171,10 +180,10 @@
             { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
       }
    }
-   
+
    /**
     * Test copyContent to the deployers target profile.
-    * 
+    *
     * @throws Exception
     */
    public void testDepoyersDir() throws Exception
@@ -182,7 +191,7 @@
       getDeploymentManager().loadProfile(deployersKey);
       try
       {
-         // failed 
+         // failed
          deployFailed(true);
          // complete
          deployEmpty(true);
@@ -208,51 +217,92 @@
          }
       }
    }
-   
+
    /**
     * 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();
+      ComponentType type = new ComponentType("MCBean", "ServerConfig");
+      ManagedComponent mc = mgtView.getComponent("jboss.system:type=ServerConfig", type);
+      assertNotNull(mc);
+      String homeDir = (String) ((SimpleValue) mc.getProperty("serverHomeDir").getValue()).getValue();
+      assertNotNull(homeDir);
+      
+      // Manually copy the deployment
+      copyFile(new File(homeDir, "deploy/"), HD_DEPLOYMENT);
+      // Wait for HDScanner
+      Thread.sleep(10000);
+      
+      // Reload mgtView
+      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 });
    }
 
+   private void copyFile(File dir, String filename) throws Exception
+   {
+      InputStream is = getDeployURL(filename).openStream();
+      try
+      {
+         File output = new File(dir, filename);
+         FileOutputStream fos = new FileOutputStream(output);
+         try
+         {
+            byte[] tmp = new byte[1024];
+            int read;
+            while((read = is.read(tmp)) > 0)
+            {
+               fos.write(tmp, 0, read);
+            }
+            fos.flush();
+         }
+         finally
+         {
+            fos.close();
+         }         
+      }
+      finally
+      {
+         is.close();
+      }
+   }
+   
    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, 
+      DeploymentProgress distribute = deployMgr.distribute(deploymentName,
             getDeployURL(deploymentName), copyContent);
       distribute.run();
       // Distribute always has to complete
@@ -260,46 +310,46 @@
       // 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);
@@ -317,7 +367,7 @@
          DeploymentProgress remove = deployMgr.remove(names);
          remove.run();
          assertComplete(remove);
-         
+
          String name = remove.getDeploymentID().getNames()[0];
          ManagementView mgtView = getManagementView();
          try
@@ -331,13 +381,13 @@
          }
       }
    }
-   
+
    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];
@@ -345,8 +395,9 @@
       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())
@@ -356,7 +407,7 @@
       //
       assertTrue(progress.getDeploymentStatus().isCompleted());
    }
-   
+
    DeploymentManager getDeploymentManager() throws Exception
    {
       if(this.deployMgr == null)
@@ -365,7 +416,7 @@
       }
       return deployMgr;
    }
-   
+
    ManagementView getManagementView() throws Exception
    {
       if(this.mgtView == null)
@@ -375,11 +426,11 @@
       this.mgtView.load();
       return this.mgtView;
    }
-   
+
    ProfileService getProfileService() throws Exception
    {
       InitialContext ctx = getInitialContext();
       return (ProfileService) ctx.lookup("ProfileService");
-   } 
-   
+   }
+
 }

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/JmsDestinationRestartUnitTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -112,7 +112,6 @@
          
          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);
          

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -27,8 +27,9 @@
 import org.jboss.test.profileservice.override.test.AbstractProfileServiceTest;
 
 /**
+ * Run after LocalDSRemoveTestCase to validate that the removal of the
+ * ProfileServiceTestRemoveDataSource has occurred.
  * 
- * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -26,6 +26,7 @@
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.RunState;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.test.profileservice.override.test.AbstractProfileServiceTest;
 
@@ -65,7 +66,9 @@
          
          property = mc.getProperty("max-pool-size");
          assertEquals("max-pool-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
-         
+         RunState state = mc.getRunState();
+         assertEquals(RunState.RUNNING, state);
+
          // This should work too
          ManagedComponent comp = getManagedComponent(mgtView, "ChangedDsJNDIName");
          assertNotNull(comp);

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/JmsDestinationOverrideTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -130,17 +130,26 @@
       // update security Config
       ManagedComponent queue = mgtView.getComponent("testQueueTemplate", type);
       assertNotNull(queue);
-      assertEquals("testQueueTemplate", queue.getName());
+      assertEquals("testQueueTemplate", queue.getName()); 
       
+      // Test with a empty value
+      queue.getProperty("securityConfig").setValue(new MapCompositeValueSupport(new HashMap<String, MetaValue>(), securityConfType));
+      mgtView.updateComponent(queue);
+      
+      //
+      mgtView = getManagementView();
+      queue = mgtView.getComponent("testQueueTemplate", type);
+      
       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);
+      MapCompositeValueSupport map= new MapCompositeValueSupport(values, securityConfType);
 
+      // Test a normal value 
       queue.getProperty("securityConfig").setValue(map);
       mgtView.updateComponent(queue);
-      
+
       mgtView = getManagementView();
       queue = mgtView.getComponent("testQueueTemplate", type);
       MapCompositeValueSupport securityConfig = (MapCompositeValueSupport) queue.getProperty("securityConfig").getValue();
@@ -148,10 +157,12 @@
       
       securityConfig.remove("publisher");
       
+      // Test remove
       mgtView.updateComponent(queue);
       securityConfig = (MapCompositeValueSupport) queue.getProperty("securityConfig").getValue();
       assertNotNull(securityConfig);
       assertNull(securityConfig.get("publisher"));
+      
    }
    
 

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -26,6 +26,8 @@
 import org.jboss.managed.api.ManagedComponent;
 
 /**
+ * Run before the LocalDSRemoveOverrideUnitTestCase
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -289,7 +289,7 @@
    public void testRemoveQueue() throws Exception
    {
       removeDeployment("testCreateQueue-service.xml");
-       ManagedComponent queue = getManagementView().getComponent("testCreateQueue", QueueType);
+	   ManagedComponent queue = getManagementView().getComponent("testCreateQueue", QueueType);
       assertNull("queue should be removed" + queue, queue);
    }
 
@@ -442,6 +442,7 @@
       String jndiName = getName();
       propValues.put("name", SimpleValueSupport.wrap(jndiName));
       propValues.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+      propValues.put("clustered", SimpleValueSupport.wrap(true));
       // Security config
       Map<String, MetaValue> values = new HashMap<String, MetaValue>();
       values.put("admin", createCompositeValue(true, true, true));

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-27 18:00:10 UTC (rev 87887)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-27 18:01:43 UTC (rev 87888)
@@ -46,19 +46,17 @@
 import org.jboss.managed.api.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.api.RunState;
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.GenericMetaType;
+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.GenericValue;
 import org.jboss.metatype.api.values.MapCompositeValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
@@ -471,12 +469,13 @@
 */
       p = props.get("security-domain");
       assertNotNull("security-domain", p);
-      GenericValue sdGV = (GenericValue) p.getValue();
-      assertNotNull(sdGV);
-      ManagedObject secDomain = (ManagedObject) sdGV.getValue();
-      // TODO, this should be non-null:
-      assertNotNull("security-domain.MO", secDomain);
-      log.info("security-domain.MO: "+secDomain);
+
+      CompositeMetaType secType = (CompositeMetaType) p.getMetaType();
+      assertNotNull(secType);
+      assertTrue(secType.containsItem("domain"));
+      assertTrue(secType.containsItem("securityDeploymentType"));
+
+      log.info("security-domain: "+secType);
    }
 
    /**
@@ -590,10 +589,10 @@
       ManagedProperty securityDomain = props.get("security-domain");
       assertNotNull("security-domain", securityDomain);
       MetaType securityDomainType = securityDomain.getMetaType();
-      assertTrue("security-domain type is a GenericMetaType", securityDomainType instanceof GenericMetaType);
+      assertTrue("security-domain type is a GenericMetaType", securityDomainType instanceof CompositeMetaType);
       log.debug("security-domain type: "+securityDomainType);
       MetaValue securityDomainValue = securityDomain.getValue();
-      assertTrue("security-domain value is a GenericValue", securityDomainValue instanceof GenericValue);
+      assertTrue("security-domain value is a GenericValue", securityDomainValue instanceof CompositeValue);
       log.debug("security-domain value: "+securityDomainValue);
    }
    
@@ -1104,7 +1103,7 @@
       ManagedProperty securityDomain = props.get("security-domain");
       assertNotNull("security-domain", securityDomain);
       MetaType securityDomainType = securityDomain.getMetaType();
-      assertTrue("security-domain type("+securityDomainType+") is a GenericMetaType", securityDomainType instanceof GenericMetaType);
+      assertTrue("security-domain type("+securityDomainType+") is a GenericMetaType", securityDomainType instanceof CompositeMetaType);
       log.debug("security-domain type: "+securityDomainType);
    }
 }




More information about the jboss-cvs-commits mailing list