[jboss-cvs] JBossAS SVN: r112133 - in branches/JBPAPP_5_1_JBPAPP-6716/testsuite: src/main/org/jboss/test/deployment and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 26 00:33:20 EDT 2011


Author: klape
Date: 2011-08-26 00:33:19 -0400 (Fri, 26 Aug 2011)
New Revision: 112133

Modified:
   branches/JBPAPP_5_1_JBPAPP-6716/testsuite/build.sh
   branches/JBPAPP_5_1_JBPAPP-6716/testsuite/src/main/org/jboss/test/deployment/JBPAPP6716UnitTestCase.java
Log:
[JBPAPP-6717] Modifying test case. (In progress)

Modified: branches/JBPAPP_5_1_JBPAPP-6716/testsuite/build.sh
===================================================================
--- branches/JBPAPP_5_1_JBPAPP-6716/testsuite/build.sh	2011-08-26 02:10:45 UTC (rev 112132)
+++ branches/JBPAPP_5_1_JBPAPP-6716/testsuite/build.sh	2011-08-26 04:33:19 UTC (rev 112133)
@@ -151,7 +151,7 @@
     ANT_OPTS="$ANT_OPTS -Dbuild.script=$0"
 
     # add some more memory
-    ANT_OPTS="$ANT_OPTS -Xmx2024m"
+    ANT_OPTS="$ANT_OPTS -Xmx1524m"
 
     # prevent default config beeing used
     ANT_OPTIONS="--noconfig $ANT_OPTIONS"

Modified: branches/JBPAPP_5_1_JBPAPP-6716/testsuite/src/main/org/jboss/test/deployment/JBPAPP6716UnitTestCase.java
===================================================================
--- branches/JBPAPP_5_1_JBPAPP-6716/testsuite/src/main/org/jboss/test/deployment/JBPAPP6716UnitTestCase.java	2011-08-26 02:10:45 UTC (rev 112132)
+++ branches/JBPAPP_5_1_JBPAPP-6716/testsuite/src/main/org/jboss/test/deployment/JBPAPP6716UnitTestCase.java	2011-08-26 04:33:19 UTC (rev 112133)
@@ -1,8 +1,4 @@
-/*
- * 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.
+ /* 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
@@ -32,6 +28,7 @@
 import java.util.Hashtable;
 import java.util.Properties;
 
+import javax.management.JMX;
 import javax.management.MBeanException;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
@@ -42,6 +39,7 @@
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.services.deployment.MBeanData;
 import org.jboss.test.JBossTestCase;
+import org.jboss.deployment.MainDeployerMBean;
 
 /**
  * JBPAPP-6716 MainDeployer tests
@@ -50,285 +48,81 @@
  */
 public class JBPAPP6716UnitTestCase extends JBossTestCase
 {
+   private MainDeployerMBean deployer;
+   private URL dummyUrl;
 
-   private ObjectName mainDeployer = ObjectNameFactory
-         .create("jboss.system:service=MainDeployer");  
-
-   public JBPAPP6716UnitTestCase(String name)
+   public JBPAPP6716UnitTestCase(String name) throws Exception
    {
       super(name);
    }
-   
-   /**
-    * Try to get a list of deployments
-    */
-   
-   
-   public void testRedeployURL() throws Exception
-   {
-	      log.info("+++ testRedeployURL");
-	      
-	      MBeanServerConnection server = getServer();
-	     
-	      String[] paramTypes = {"java.net.URL"};
-	      Object[] inputParams = new Object[1];
-	      //inputParams[0] = new URL("file:///home/YOUR-USER/temp/test.ear"); 
-	      
-	      inputParams[0] = new URL("file:///home/sappleto/jbossBuilds/JBPAPP_5_1/testsuite/output/lib/dummy.war");  //TODO  change to use resource available in JBPAPP-xyz branch
-	      
-	      try
-	      {
 
-	         log.info (server.invoke(mainDeployer, "redeploy", inputParams, paramTypes)); // just output at the moment
-	         
-	         assertTrue(((Boolean)server.invoke(mainDeployer, "isDeployed", inputParams, paramTypes)).booleanValue());  // did it deploy?
-	         
-	         assertTrue(isDeployed(server, inputParams));  // did it deploy?
-
-	      }
-	      catch (Exception e)
-	      {
-	    	 e.printStackTrace();
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
-
-   }
-   
-   public void testDeployNTimes() throws Exception
+   protected void setUp() throws Exception
    {
-	   
-	   
-	   int maxNum = (int)((Math.random()*10) + 1);
-	   
-	      log.info("+++ testDeployNTimes");
-	      log.info("will deploy "+maxNum+" times");
-	      
-	      for (int tries = 0; tries < maxNum; tries++)
-	      {
-		      log.info("redeployment number:"+tries);
-	          // sleep for 3 secs
-	          Thread.sleep(3000);
-	         
-		      MBeanServerConnection server = getServer();
-			     
-		      String[] paramTypes = {"java.net.URL"};
-		      Object[] inputParams = new Object[1];
-		      //inputParams[0] = new URL("file:///home/YOUR-USER/temp/test.ear"); 
-		      
-		      inputParams[0] = new URL("file:///home/sappleto/jbossBuilds/JBPAPP_5_1/testsuite/output/lib/dummy.war");  //TODO  change to use resource available in JBPAPP-xyz branch
-		      
-		      try
-		      {
-
-		         log.info (server.invoke(mainDeployer, "deploy", inputParams, paramTypes)); // just output at the moment
-		         
-		         assertTrue(((Boolean)server.invoke(mainDeployer, "isDeployed", inputParams, paramTypes)).booleanValue());  // did it deploy?
-		         
-		         assertTrue(isDeployed(server, inputParams));  // did it deploy?
-
-		      }
-		      catch (Exception e)
-		      {
-		    	 e.printStackTrace();
-		         super.fail("Caught exception, message: " + e.getMessage());
-		      }
-
-	      }
+      dummyUrl = getDeployURL("dummy.war");
+      MBeanServerConnection server = getServer();
+      ObjectName objectName = ObjectNameFactory.create("jboss.system:service=MainDeployer");
+      deployer = JMX.newMBeanProxy(server, objectName, MainDeployerMBean.class);
    }
    
-   
-   public void testReDeployNTimes() throws Exception
-   {
-	   
-	   
-	   int maxNum = (int)((Math.random()*10) + 1);
-	   
-	      log.info("+++ testReDeployNTimes");
-	      log.info("will redeploy "+maxNum+" times");
-	      
-	      for (int tries = 0; tries < maxNum; tries++)
-	      {
-		      log.info("redeployment number:"+tries);
-	          // sleep for 3 secs
-	          Thread.sleep(3000);
-	         
-		      MBeanServerConnection server = getServer();
-			     
-		      String[] paramTypes = {"java.net.URL"};
-		      Object[] inputParams = new Object[1];
-		      //inputParams[0] = new URL("file:///home/YOUR-USER/temp/test.ear"); 
-		      
-		      inputParams[0] = new URL("file:///home/sappleto/jbossBuilds/JBPAPP_5_1/testsuite/output/lib/dummy.war");  //TODO  change to use resource available in JBPAPP-xyz branch
-		      
-		      try
-		      {
+   //***** Deploy Tests *****//
 
-		         log.info (server.invoke(mainDeployer, "redeploy", inputParams, paramTypes)); // just output at the moment
-		         
-		         assertTrue(((Boolean)server.invoke(mainDeployer, "isDeployed", inputParams, paramTypes)).booleanValue());  // did it deploy?
-		         
-		         assertTrue(isDeployed(server, inputParams));  // did it deploy?
-
-		      }
-		      catch (Exception e)
-		      {
-		    	 e.printStackTrace();
-		         super.fail("Caught exception, message: " + e.getMessage());
-		      }
-
-	      }
-   }   
-   public void testRedeployString() throws Exception
+   public void testDeployNTimes() throws Exception
    {
-	      log.info("+++ testRedeployString");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      String [] string = new String[2];
-	      string[0]="file:///../../../../default/deploy/jboss-seam-numberguess.ear/"; //TODO change to a better resource
-	      
-	      try
-	      {
+      String dummyUrlString = dummyUrl.toExternalForm();
+      int maxNum = (int)((Math.random()*10) + 1);
+      
+      log.info("+++ testDeployNTimes");
+      log.info("will deploy "+maxNum+" times");
+      
+      for (int tries = 0; tries < maxNum; tries++)
+      {
+        log.info("Test iteration "+tries);
+         
+        try
+        {
+           //Deploy & undeploy with URL
+           deployer.deploy(dummyUrl);
+           assertTrue("Failed to deploy URL", isDeployed(dummyUrl, false));
 
-	         log.info (server.invoke(mainDeployer, "redeploy", string, null)); // just output at the moment
+           deployer.undeploy(dummyUrl);
+           assertTrue(dummyUrlString + " is not deployed when it should be", !isDeployed(dummyUrl, false));
 
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
+           //Deploy & undeploy with String
+           deployer.deploy(dummyUrlString);
+           assertTrue(isDeployed(dummyUrl, true));
 
-   }
-   
-   public void testUndeployString() throws Exception
-   {
-	      log.info("+++ testUndeployString");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      try
-	      {
+           deployer.undeploy(dummyUrlString);
+           assertTrue(!isDeployed(dummyUrl, true));
 
-	         log.info (server.invoke(mainDeployer, "listDeployedAsString", null, null)); // just output at the moment
+           //Redploy 
+           deployer.deploy(dummyUrl);
+           assertTrue(isDeployed(dummyUrl, false));
 
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
+           //With URL
+           deployer.redeploy(dummyUrl);
+           assertTrue(!isDeployed(dummyUrl, false));
 
+           //With String
+           deployer.redeploy(dummyUrlString);
+           assertTrue(!isDeployed(dummyUrl, true));
+        }
+        catch (Exception e)
+        {
+           e.printStackTrace();
+           super.fail("Caught exception, message: " + e.getMessage());
+        }
+      }
    }
    
-   public void testUndeployURL() throws Exception
-   {
-	      log.info("+++ testUndeployURL");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      try
-	      {
+   //***** Listing Methods *****//
 
-	         log.info (server.invoke(mainDeployer, "listDeployedAsString", null, null)); // just output at the moment
-
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
-
-   }
-   
-   
-   public void testDeployString() throws Exception
-   {
-	      log.info("+++ testDeployString");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      try
-	      {
-
-	         log.info (server.invoke(mainDeployer, "listDeployedAsString", null, null)); // just output at the moment
-
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
-
-   }   
-   
-   public void testDeployURL() throws Exception
-   {
-	      log.info("+++ testDeployURL");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      try
-	      {
-
-	         log.info (server.invoke(mainDeployer, "listDeployedAsString", null, null)); // just output at the moment
-
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
-
-   } 
-   
-
- 
-   
-   public void isDeployedString() throws Exception
-   {
-	      log.info("+++ testisDeployedURL");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      try
-	      {
-
-	         log.info (server.invoke(mainDeployer, "listDeployedAsString", null, null)); // just output at the moment
-
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
-
-   }   
- 
-   public void isDeployedURL() throws Exception
-   {
-	      log.info("+++ testisDeployedURL");
-	      
-	      MBeanServerConnection server = getServer();
-	      
-	      try
-	      {
-
-	         log.info (server.invoke(mainDeployer, "listDeployedAsString", null, null)); // just output at the moment
-
-	      }
-	      catch (Exception e)
-	      {
-	         super.fail("Caught exception, message: " + e.getMessage());
-	      }
-
-   } 
-
    public void testListDeployedAsString() throws Exception
    {
       log.info("+++ testListDeployedAsString");
       
-      MBeanServerConnection server = getServer();
-      
       try
       {
-
-         assertEquals("<pre>[]</pre>", server.invoke(mainDeployer, "listDeployedAsString", null, null));
-
+         assertEquals("<pre>[]</pre>", deployer.listDeployedAsString());
       }
       catch (Exception e)
       {
@@ -340,48 +134,40 @@
    {
       log.info("+++ testListDeployed");
       
-      MBeanServerConnection server = getServer();
-      
       try
       {
-
-         assertEquals("[]", server.invoke(mainDeployer, "listDeployed", null, null));
-
+         assertEquals("[]", deployer.listDeployed());
       }
       catch (Exception e)
       {
          super.fail("Caught exception, message: " + e.getMessage());
       }
-
    }
    
    /**
     * Verifies that a given module is acutally deployed. Waits for a while,
     * checking every few seconds, to see if the module has deployed yet.
     * 
-    * @param server
-    *           User to invoke methods on the dpeloyment service.
-    * @param module
-    *           The name of the module (must include the suffix).
+    * @param url The URL for which we're testing deployment
+    * @param asString Should we use URL or URL.toExternalForm() (String)?
     * @return
     */
-   private boolean isDeployed(MBeanServerConnection server, Object[] module)
+   private boolean isDeployed(URL url, boolean isString)
          throws Exception
    {
-      Boolean isDeployed = new Boolean(false);
+      boolean isDeployed = false;
       for (int tries = 0; tries < 5; tries++)
       {
          // sleep for 3 secs
          Thread.sleep(3000);
-         isDeployed = (Boolean) server.invoke(mainDeployer, "isDeployed", module , new String[] { "java.net.URL" });
+         if(isString)
+            isDeployed = deployer.isDeployed(url.toExternalForm());
+         else
+            isDeployed = deployer.isDeployed(url);
 
-         if (isDeployed.booleanValue())
-         {
+         if(isDeployed)
             break;
-         }
       }
-      log.info("Module '" + module + "' deployed: " + isDeployed);
-      return isDeployed.booleanValue();
+      return isDeployed;
    }   
-
 }



More information about the jboss-cvs-commits mailing list