sahvx655-wq created FELIX-6838:
----------------------------------
Summary: ConfigInstallerTest and DirectoryWatcherTest fail due to
platform-dependent URI format in mock expectations
Key: FELIX-6838
URL: https://issues.apache.org/jira/browse/FELIX-6838
Project: Felix
Issue Type: Bug
Components: File Install
Reporter: sahvx655-wq
The unit tests {{ConfigInstallerTest}} and {{DirectoryWatcherTest}} may fail on
certain operating systems and filesystems due to platform-dependent URI
construction in mock expectations.
Currently, these tests construct expected file URIs by manually concatenating
strings, such as:
* {{"file:" + file}}
* {{"file:" + watchedDirectoryPath + '/' + bundleFileName}}
This approach assumes a specific path representation and may produce URI
strings that differ from those generated by standard Java URI conversion
methods.
For example, on Windows, file paths contain drive letters and backslashes,
while {{File.toURI()}} generates normalized URI representations. Since the
production code uses standard URL/URI conversion mechanisms, the manually
constructed mock expectations may not match the actual values, resulting in
mock verification failures.
Replace manual URI string construction in test expectations with
{{File.toURI().toString()}} so that tests use the same platform-independent URI
representation as the production code.
Specifically:
* In {{{}ConfigInstallerTest{}}}, replace manual {{"file:"}} prefix
construction with {{{}file.getAbsoluteFile().toURI().toString(){}}}.
* In {{{}DirectoryWatcherTest{}}}, replace manual bundle location construction
with {{{}new File(watchedDirectoryFile, bundleFileName).toURI().toString(){}}}.
This ensures consistent behavior across platforms and eliminates
URI-format-related test failures.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)