[jboss-cvs] JBossAS SVN: r112145 - branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Aug 28 02:12:57 EDT 2011


Author: bmaxwell
Date: 2011-08-28 02:12:56 -0400 (Sun, 28 Aug 2011)
New Revision: 112145

Modified:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteAllTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteDefaultTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteEarTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteSarTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteTestCase.java
Log:
[JBPAPP-6517] fix testcase to not specify localhost, use JBossTestCase deploy/undeploy

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteAllTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteAllTestCase.java	2011-08-26 21:09:54 UTC (rev 112144)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteAllTestCase.java	2011-08-28 06:12:56 UTC (rev 112145)
@@ -27,6 +27,11 @@
  */
 public class CheckCompleteAllTestCase extends CheckCompleteTestCase
 {     
+
+   public CheckCompleteAllTestCase(String name)
+   {
+      super(name);
+   }
   
    // this will check complete on any deployment that can have children
    public void testCheckSubDeploymentCompleteDeployerAll()

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteDefaultTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteDefaultTestCase.java	2011-08-26 21:09:54 UTC (rev 112144)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteDefaultTestCase.java	2011-08-28 06:12:56 UTC (rev 112145)
@@ -45,6 +45,12 @@
  */
 public class CheckCompleteDefaultTestCase extends CheckCompleteTestCase
 {      
+
+   public CheckCompleteDefaultTestCase(String name)
+   {
+      super(name);
+   }
+
    // this is without the deployer
    public void testDefaultWithoutCheckSubDeploymentCompleteDeployer()
    {

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteEarTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteEarTestCase.java	2011-08-26 21:09:54 UTC (rev 112144)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteEarTestCase.java	2011-08-28 06:12:56 UTC (rev 112145)
@@ -27,6 +27,12 @@
  */
 public class CheckCompleteEarTestCase extends CheckCompleteTestCase
 {     
+
+   public CheckCompleteEarTestCase(String name)
+   {
+      super(name);
+   }
+
    // this will check complete on just ear deployments
    public void testCheckSubDeploymentCompleteDeployerEAROnly()
    {

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteSarTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteSarTestCase.java	2011-08-26 21:09:54 UTC (rev 112144)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteSarTestCase.java	2011-08-28 06:12:56 UTC (rev 112145)
@@ -27,6 +27,12 @@
  */
 public class CheckCompleteSarTestCase extends CheckCompleteTestCase
 {     
+
+   public CheckCompleteSarTestCase(String name)
+   {
+      super(name);
+   }
+
    // this will check complete on just sar deployments
    public void testCheckSubDeploymentCompleteDeployerSAROnly()
    {

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteTestCase.java	2011-08-26 21:09:54 UTC (rev 112144)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/deployment/jbpapp6517/CheckCompleteTestCase.java	2011-08-28 06:12:56 UTC (rev 112145)
@@ -23,6 +23,8 @@
 
 import java.io.File;
 import java.net.URI;
+import java.net.URL;
+import java.security.Principal;
 import java.util.Properties;
 
 import javax.management.InstanceNotFoundException;
@@ -32,37 +34,48 @@
 import javax.naming.Context;
 import javax.naming.InitialContext;
 
-import junit.framework.TestCase;
-
 import org.jboss.deployment.MainDeployerMBean;
 import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
 import org.jboss.security.SecurityAssociation;
 import org.jboss.security.SimplePrincipal;
+import org.jboss.test.JBossTestCase;
 
+
 /**
  * @author bmaxwell
  *
  */
-public abstract class CheckCompleteTestCase extends TestCase
+public abstract class CheckCompleteTestCase extends JBossTestCase
 {
    public static String objectNameString = "jboss.system:service=MainDeployer";
    
-   private static String host = "localhost";
+   protected String testEar = "jbpapp-6517.ear";
+   protected String testSar = "jbpapp-6517.sar";
    
-   protected String testEar = "file://" + new File("lib/jbpapp-6517.ear").getAbsolutePath();
-   protected String testSar = "file://" + new File("lib/jbpapp-6517.sar").getAbsolutePath();   
-   
    protected String checkCompleteDeployerAll = "file://" + new File("resources/org/jboss/test/deployment/jbpapp6517/checkSubDeploymentCompleteDeployerAll-jboss-beans.xml").getAbsolutePath();
    protected String checkCompleteDeployerEAR = "file://" + new File("resources/org/jboss/test/deployment/jbpapp6517/checkSubDeploymentCompleteDeployerEAR-jboss-beans.xml").getAbsolutePath();
    protected String checkCompleteDeployerSAR = "file://" + new File("resources/org/jboss/test/deployment/jbpapp6517/checkSubDeploymentCompleteDeployerSAR-jboss-beans.xml").getAbsolutePath();
    
    protected String earEjb3JMXName = "jboss.j2ee:ear=jbpapp-6517.ear,jar=jbpapp-6517-ejb.jar,name=HelloBean,service=EJB3";
    protected String sarEjb3JMXName = "jboss.j2ee:ear=jbpapp-6517.sar,jar=jbpapp-6517-ejb.jar,name=HelloBean,service=EJB3";
+
+   private Object[] previousSecurity = new Object[2];
    
-   public CheckCompleteTestCase()
+   public CheckCompleteTestCase(String name)
    {
-      init("admin","admin");
+      super(name);
    }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      setSecurity(new SimplePrincipal("admin"), "admin");
+   } 
+   protected void tearDown() throws Exception
+   {   
+      super.tearDown();
+      setSecurity((Principal)previousSecurity[0], previousSecurity[1]);      
+   }
    
    // TODO the tests are moved into different files since there is a bug where we can't deploy/undeploy the deployer - move them back when bug is fixed
    
@@ -244,74 +257,17 @@
    private static MBeanServerConnection getRMIServer() throws Exception
    {
      String connectorName = "jmx/rmi/RMIAdaptor";
-     RMIAdaptor server = (RMIAdaptor) getInitialContext(host).lookup(connectorName);
+     RMIAdaptor server = (RMIAdaptor) new InitialContext().lookup(connectorName);
      //invoke MainDeployer MBean service
      return server;
    }
 
-   private static InitialContext getInitialContext(String host) throws Exception
+   private void setSecurity(Principal username, Object password)
    {
-     if ( host == null )
-       return new InitialContext();
-     else
-     {
-       Properties props = new Properties();
-       props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
-       props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
-       props.put(Context.PROVIDER_URL, "jnp://"+host+":1099");
-       return new InitialContext(props);
-     }
-   }
-
-    private void init(String username, String password)
-    {
-     SecurityAssociation.setPrincipal(new SimplePrincipal(username));
-     SecurityAssociation.setCredential(password);
-    }
+      previousSecurity[0] = SecurityAssociation.getPrincipal();
+      previousSecurity[1] = SecurityAssociation.getCredential();
       
-   /**
-   * This is an example of getting the MainDeployer from the MBean Server and invoking deploy using 
-   * standard MBean reflective invoke commands
-   */
-   protected static void deploy(String deployURL) throws Exception
-   {
-      MainDeployerMBean mbean = null;
-      
-         ObjectName objectName = new ObjectName(objectNameString);
-         MBeanServerConnection server = getRMIServer();
-
-         // arguments for the invoke call
-         String operationName = "deploy"; // the method 
-         Object[] params = new Object[]
-         {deployURL}; // the arguments
-         String[] signature = new String[]
-         {String.class.getName()}; // the class type of the arguments
-
-         //Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) 
-         //throws InstanceNotFoundException, MBeanException, ReflectionException
-         Object returnValue = server.invoke(objectName, operationName, params, signature);      
+      SecurityAssociation.setPrincipal(username);
+      SecurityAssociation.setCredential(password);       
    }
-
-   /**
-   * This is an example of getting the MainDeployer from the MBean Server and invoking undeploy using 
-   * standard MBean reflective invoke commands
-   */
-   protected static void undeploy(String deployURL) throws Exception
-   {
-      MainDeployerMBean mbean = null;
-      
-         ObjectName objectName = new ObjectName(objectNameString);
-         MBeanServerConnection server = getRMIServer();
-         
-         // arguments for the invoke call
-         String operationName = "undeploy"; // the method 
-         Object[] params = new Object[]
-         {deployURL}; // the arguments
-         String[] signature = new String[]
-         {String.class.getName()}; // the class type of the arguments
-
-         //Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) 
-         //throws InstanceNotFoundException, MBeanException, ReflectionException
-         Object returnValue = server.invoke(objectName, operationName, params, signature);
-   }
 }



More information about the jboss-cvs-commits mailing list