unit tests on windows creates directories outside of temp directory
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.
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.
Environment
Microsoft Windows
Acceptance / Success Criteria
None
Attachments
1
Lucidchart Diagrams
Activity
Show:
Seth Leger August 31, 2011 at 1:55 PM
Committed to 1.10 for inclusion in 1.9.91. Thanks!
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.