3 Replies Latest reply on Dec 22, 2007 12:50 AM by Scott Stark

    Making JBoss Test VFS aware

    Ales Justin Master

      When testing deployment/deployers I ran into some problems with URL mappings.
      This lead to a simple discovery that our Test project is completely VFS unaware. :-)

      The code that previously worked out-of-the-box (JBossTestServices)

       protected URL getDeployURL(final String filename)
       throws MalformedURLException
       {
       // First see if it is already a complete url.
       try
       {
       return new URL(filename);
       }
       catch (MalformedURLException e)
       {
       log.debug(filename + " is not a valid URL, " + e.getMessage());
       }
      
       // OK, lets see if we can figure out what it might be.
       String deployDir = System.getProperty("jbosstest.deploy.dir");
       if (deployDir == null)
       {
       deployDir = "output/lib";
       }
       String url = deployDir + "/" + filename;
       log.debug("Testing file: " + url);
       // try to canonicalize the strings a bit.
       File file = new File(url);
       if (file.exists())
       {
       log.debug(file.getAbsolutePath() + " is a valid file");
       return file.toURL();
       }
       else
       {
       log.debug("File does not exist, creating url: " + url);
       return new URL(url);
       }
       }
      

      now fails if there is no plain-mapping --> vfs-mapping in the middle.
      And for subdeployments, there is no such mapping, since old MainDeployer only keeps reference/mapping for the top level deployment.
      So if you want to do a isDeployed test for some subdeployment, there is no way to get a useful result unless you do some similar hacking:
       public boolean isDeployed(URL url)
       {
       String name = contextMap.get(url);
       if (name == null)
       {
       if (log.isTraceEnabled())
       log.trace("No such context: " + url);
       if (url == null)
       throw new IllegalArgumentException("Null url");
       String urlString = url.toString();
       // remove this once the JBoss-test is updated with VFS usage
       if (urlString.startsWith("vfs") == false)
       return checkDeployed("vfs" + urlString);
       else
       return checkDeployed(urlString);
       }
      
       return checkDeployed(name);
       }
      


      This is just one of the problems, I'm sure there are more VFS related issues.

      On the other hand, we're also missing some VFS performance tests.
      The current tests with Seam examples showed a horrible performance hit.
      We need to include this in both, VFS and AS tests.

      I can go and change the first issue(s), but would need some help on how to start/impl with the second, performance testing.

        • 1. Re: Making JBoss Test VFS aware
          Scott Stark Master

          I'm using JBossTestServices.getDeployURL without a problem, so what do you mean it fails?

          As for testing subdeployments based on name, there should be a isDeployed(URL url, String subpath) method for that.

          • 2. Re: Making JBoss Test VFS aware
            Ales Justin Master

             

            "scott.stark@jboss.org" wrote:
            I'm using JBossTestServices.getDeployURL without a problem, so what do you mean it fails?

            There is no problem with this method.
            I'm just saying if you did this before
            assertTrue(isDeployed(someAlreadyDeployedArtifact));
            

            it failed.
            It failed for me when doing Seam tests, for an example which, as seen in console, deployed normaly.
            Until I introduced mapping to this MainDeployer's method as well.
            But then all subdeployments checks failed. Dunno if this was ever supported in previous versions - e.g. jar entry being deployed check.

            "scott.stark@jboss.org" wrote:

            As for testing subdeployments based on name, there should be a isDeployed(URL url, String subpath) method for that.

            Yup.
            Or perhaps all this can be handled by VFS.
            Splitting the initial path into tokens, and then traversing via VFS contexts.

            • 3. Re: Making JBoss Test VFS aware
              Scott Stark Master

               

              "alesj" wrote:

              I'm just saying if you did this before
              assertTrue(isDeployed(someAlreadyDeployedArtifact));
              

              it failed.
              It failed for me when doing Seam tests, for an example which, as seen in console, deployed normaly.
              Until I introduced mapping to this MainDeployer's method as well.
              But then all subdeployments checks failed. Dunno if this was ever supported in previous versions - e.g. jar entry being deployed check.

              this is a problem with the legacy MainDeployer though, not the test code. The MainDeployer has to expect it will be accessed using a regular url that has to be resolved via the VFS. Checking the status of subdeployments given a url never was supported.