2 Replies Latest reply on Nov 9, 2007 9:58 AM by Ales Justin

    AbstractDeploymentTest still using DeploymentContext

    Ales Justin Master

      Currently AbstractDeploymentTest class is still using DeploymentContext (DC), which as I remember should just be an implementation detail.

      I was able to easily refactor DC usage to DeploymentUnit (DU).
      Except for the DeploymentState (DS) code snippet:

       public void visit(DeploymentUnit info)
       {
       String shortName = shortNameFromDeploymentName(info.getName());
       log.info("Found deployment " + shortName);
       boolean found = expected.remove(shortName);
       if (found == false)
       fail(shortName + " not expected, or duplicate?");
       else
       {
       DeploymentState state = DeploymentState.DEPLOYED; // FIXME!!
       assertEquals("Should be fully deployed: " + shortName + " state=" + state, DeploymentState.DEPLOYED, state);
       }
       }
      


      If I want to get to DS, I need to expose this in MainDeployerMBean or again use DC.

      And this needs changing as well:
       protected void assertNotDeployed(String deployment) throws Exception
       {
       DeploymentUnit result = getDeploymentUnit(deployment);
       assertNull("Should not be deployed " + result, result);
       }
      

      Since this previously never returned null.
      Perhaps it will now with the new DU change ... need to test this.


        • 1. Re: AbstractDeploymentTest still using DeploymentContext
          Ales Justin Master

          OK, this DS check can be changed to this simple true/false:

          boolean deployed = isDeployed(info.getName());
          assertTrue("Should be fully deployed: " + shortName, deployed);
          

          Where 'isDeployed' is this:
           protected boolean isDeployed(String deployment) throws Exception
           {
           URL deployURL = getDeployURL(deployment);
           String[] sig = { URL.class.getName() };
           Object[] args = {deployURL};
           return invokeMainDeployer("isDeployed", args, sig, Boolean.class);
           }
          
           protected <T> T invokeMainDeployer(String methodName, Object[] args, String[] sig, Class<T> clazz) throws Exception
           {
           if (clazz == null)
           throw new IllegalArgumentException("Null class.");
          
           MBeanServerConnection server = getServer();
           Object result = server.invoke(MainDeployerMBean.OBJECT_NAME, methodName, args, sig);
           return clazz.cast(result);
           }
          


          • 2. Re: AbstractDeploymentTest still using DeploymentContext
            Ales Justin Master

             

            "alesj" wrote:

            And this needs changing as well:
             protected void assertNotDeployed(String deployment) throws Exception
             {
             DeploymentUnit result = getDeploymentUnit(deployment);
             assertNull("Should not be deployed " + result, result);
             }
            

            Since this previously never returned null.
            Perhaps it will now with the new DU change ... need to test this.

            As expected, change to DU doesn't change the behavior.
            e.g. NotClientDeploymentUnitTestCase gets 'deployed' w/o problems. :-(