4 Replies Latest reply on Mar 12, 2008 12:06 PM by alesj

    VFSStructureBuilderUnitTestCase todo

    alesj

      How do you test if the classpath is correct?

      I currently get 1 ClassPathEntry with "" path, but VFSDeploymentContext::getClassPath returns null.
      Is this legit?

      This is how I currently do it:

       protected void checkClassPath(VFSDeploymentContext context, ContextInfo contextInfo) throws Exception
       {
       List<ClassPathEntry> classPathEntries = contextInfo.getClassPath();
       List<VirtualFile> classPath = context.getClassPath();
      
       if (classPathEntries == null)
       assertNull(classPath);
       else
       {
       int cpeSize = classPathEntries.size();
       int cpSize = classPath != null ? classPath.size() : 0;
       assertTrue(cpeSize >= cpSize);
       for(int i = 0; i < cpeSize; i++)
       {
       ClassPathEntry entry = classPathEntries.get(i);
       VirtualFile file = (i < cpSize) ? classPath.get(i) : null;
       String path = entry.getPath();
       if ("".equals(path))
       assertTrue(file == null || "".equals(file.getPathName()));
       else
       {
       assertNotNull(file);
       assertEquals(path, file.getPathName());
       }
       }
       }
       }
      


        • 1. Re: VFSStructureBuilderUnitTestCase todo

          These tests are broken in two ways. ;-)

          1) NO "" CONTEXT

           Deployment deployment = createDeployment();
           StructureMetaData structure = StructureMetaDataFactory.createStructureMetaData();
           MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
           attachments.addAttachment(StructureMetaData.class, structure);
          


          It is creating a structure with no contexts then comparing it against
          an artifical context it creates in the tests???? :-)

           protected void checkDeployment(DeploymentContext context, Deployment deployment) throws Exception
           {
           assertNotNull(context);
          
           assertEquals(deployment.getName(), context.getName());
          
           MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
           StructureMetaData structure = attachments.getAttachment(StructureMetaData.class);
           checkAttachments(context, deployment);
           checkDeployment(context, structure);
          
          // HERE!
          
           ContextInfo contextInfo = structure.getContext("");
           if (contextInfo == null)
           contextInfo = StructureMetaDataFactory.createContextInfo();
           checkContextInfo(context, contextInfo);
           }
          


          I should probably be adding the "" context to the stucture before running it
          through the builder.

          2) VFSStructureBuilderUnitTestCase SHOULD USE THE FILESYSTEM

          But , this is stupid anyway. Because the VFSStructureBuilderUnitTestCase
          should be creating the structure from the file system. ;-)
          The whole test needs cloning rather subclassing (and before you ask,
          you can remove the attachment checks since they are irrelevant to the test).

          • 2. Re: VFSStructureBuilderUnitTestCase todo
            alesj

             

            "adrian@jboss.org" wrote:

            2) VFSStructureBuilderUnitTestCase SHOULD USE THE FILESYSTEM

            But , this is stupid anyway. Because the VFSStructureBuilderUnitTestCase
            should be creating the structure from the file system. ;-)
            The whole test needs cloning rather subclassing (and before you ask,
            you can remove the attachment checks since they are irrelevant to the test).

            You mean running it over Structure deployers?

            • 3. Re: VFSStructureBuilderUnitTestCase todo

               

              "alesj" wrote:
              "adrian@jboss.org" wrote:

              2) VFSStructureBuilderUnitTestCase SHOULD USE THE FILESYSTEM

              But , this is stupid anyway. Because the VFSStructureBuilderUnitTestCase
              should be creating the structure from the file system. ;-)
              The whole test needs cloning rather subclassing (and before you ask,
              you can remove the attachment checks since they are irrelevant to the test).

              You mean running it over Structure deployers?


              Correct. But you should only need the explict structure deployer.
              There should be jboss-structure.xml files in the test deployments.

              • 4. Re: VFSStructureBuilderUnitTestCase todo
                alesj

                 

                "adrian@jboss.org" wrote:
                Correct. But you should only need the explict structure deployer.
                There should be jboss-structure.xml files in the test deployments.

                Already done. ;-)