Commons Compress
  1. Commons Compress
  2. COMPRESS-205

Unit tests can fail when path to project is non-trivial (fix in description)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:
      None

      Description

      return factory.createCompressorInputStream(new BufferedInputStream(new FileInputStream(new File(rsc.getFile()))));

      can fail to find the files for testing e.g. /root/.jenkins/jobs/Commons%20Compress/workspace/target/test-classes/test.txt (No such file or directory)

      This can be fixed by simply opening the stream from the URL:

      private CompressorInputStream getStreamFor(String resource)
      throws CompressorException, IOException

      { final URL rsc = classLoader.getResource(resource); assertNotNull("Could not find resource "+resource,rsc); return factory.createCompressorInputStream( new BufferedInputStream(rsc.openStream())); }

        Activity

        Hide
        Daniel Lowe added a comment -

        Diff of changes that should fix this (generated by TortoiseHG)

        Show
        Daniel Lowe added a comment - Diff of changes that should fix this (generated by TortoiseHG)
        Hide
        Stefan Bodewig added a comment -

        Some of our tests will need real File instances (at least those of ZipFile and some Pack200 ones), but we could make thse tests conditional or use JUnit4 assumptions. I'll look into it a bit later.

        Show
        Stefan Bodewig added a comment - Some of our tests will need real File instances (at least those of ZipFile and some Pack200 ones), but we could make thse tests conditional or use JUnit4 assumptions. I'll look into it a bit later.
        Hide
        Stefan Bodewig added a comment -

        I've extracted the common "get file from src/test/resources via classloader" logic and used that all over the place. It would be good if you could verify svn revision 1439043 works for you.

        Show
        Stefan Bodewig added a comment - I've extracted the common "get file from src/test/resources via classloader" logic and used that all over the place. It would be good if you could verify svn revision 1439043 works for you.
        Hide
        Daniel Lowe added a comment -

        That fixes the problem for me. Thanks for looking into this.

        Show
        Daniel Lowe added a comment - That fixes the problem for me. Thanks for looking into this.

          People

          • Assignee:
            Unassigned
            Reporter:
            Daniel Lowe
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development