Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-4853

unit tests on windows creates directories outside of temp directory

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.90
    • Fix Version/s: 1.9.91
    • Component/s: Testing / JUnit
    • Security Level: Default (Default Security Scheme)
    • Labels:
      None
    • Environment:
      Microsoft Windows

      Description

      Build opennms on windows and try to run some of the unit tests that create files.

      Inside JUnitCollectorExectionListener.beforeTestMethod(), m_snmpRrdDirectory would have a path like C:\Users\roskens\AppData\Local\Temp\FileAnticipator_temp_1311971314792_007fcb8036ea13fd\snmp. But when we run the unit test configurations through the ConfigurationTestUtils class, the replacement ends up with C:\UsersroskensAppDataLocalTempFileAnticipator_temp_1311971314792_007fcb8036ea13fdsnmp\. So then later on the unit test fails because the its looking for the files under the real path, not the mashed up path.

      ConfigurationTestUtils.getConfigForResourceWithReplacements() does a replaceAll() which is where the problem is. The issue is that it does not deal

      One solution would be to wrap replacement[1] with Matcher.quoteReplacement() so that \'s and $'s are escaped properly for windows.

      String newConfig = buffer.toString();
      for (String[] replacement : replacements)

      { newConfig = newConfig.replaceAll(replacement[0], Matcher.quoteReplacement(replacement[1])); }

      return newConfig;

      It appears that the only problematic references to ConfigurationTestUtils methods which call getConfigForResourceWithReplacements() directly or indirectly are in the JUnitCollectorExecutionListener class, another solution would be to update the calls there.

        Attachments

          Activity

            People

            • Assignee:
              seth Seth Leger
              Reporter:
              ronald.roskens@biworldwide.com Ron Roskens
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: