Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-5712

JUnit Tests Teleporter does not (compile) work on Windows as expected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • JUnit Tests Teleporter 1.0.6
    • Testing
    • None
    • Windows 7 + Cygwin
    • Patch

    Description

      Checked out sling trunk, the build fails on Windows 7 because of 3 failing tests on Teleporter module .
      See attachment "TEST-org.apache.sling.testing.teleporter.client.ClassResourceVisitorTest.xml"

      This happens because the tests expectation is to find the resources with a path unix like.
      Originally I tried to fix the issue by putting as expectation in the tests code like

           assertResource(new File("/somepath/two.txt").getPath(), "two");
      

      instead of

           assertResource("/somepath/two.txt", "two");
      

      to have the expectation not OS dependent.

      This was a good fix for the failing tests under Teleporter module but unfortunately this fix causes RepoInitIT integration test failure because the resource name returned by Teleporter ClassResourceVisitor used to create test bundles inside ClientSideTeleporter#buildTestBundle must use '/' style slashes, not '\' because of undocumented quirks of JDK:
      see org.ops4j.pax.tinybundles.core.intern.RawBuilder#build
      adding one entry into jars using class java.util.jar.JarEntry with entry name like "\name" will create a jar containing a folder with an empty name containing the resource.
      Unfortunately resources in Windows are returned with a path with backslashes.

      see attachments: "TEST-org.apache.sling.repoinit.it.RepoInitIT.xml" "tinybundle-bundle-with-back-slash-as-resource-name.jar"

      So I had to do a dirty fix: replace inside ClassResourceVisitor#processFile all "\" with "/".
      Will be correct to do a fix inside JDK or TinyBundles library, but it depends also by what is expected to have in resourcePath parameter of method ClassResourceVisitor.Processor#process; a resource name with "\" or "/" regardless of operating system.

      See "windows.patch"

      Attachments

        1. SanitizeResourceNameTest.patch
          1 kB
          Emanuele Lombardi
        2. TEST-org.apache.sling.repoinit.it.RepoInitIT.xml
          8 kB
          Emanuele Lombardi
        3. TEST-org.apache.sling.testing.teleporter.client.ClassResourceVisitorTest.xml
          9 kB
          Emanuele Lombardi
        4. TEST-org.apache.sling.testing.teleporter.client.SanitizeResourceNameTest.xml
          9 kB
          Emanuele Lombardi
        5. tinybundle-bundle-with-back-slash-as-resource-name.jar
          9 kB
          Emanuele Lombardi
        6. windows.patch
          3 kB
          Emanuele Lombardi

        Activity

          People

            bdelacretaz Bertrand Delacretaz
            lelelombardi@libero.it Emanuele Lombardi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: