Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong relative paths after using MavenJUnitTestRunner #14

Open
ferstl opened this issue Aug 25, 2016 · 0 comments
Open

Wrong relative paths after using MavenJUnitTestRunner #14

ferstl opened this issue Aug 25, 2016 · 0 comments

Comments

@ferstl
Copy link

ferstl commented Aug 25, 2016

I get wrong relative paths when using java.io.File#toPath() after executing tests with MavenJUnitTestRunner on Windows. For example, this call should return a path relative to the working directory, e.g. C:\Users\me\my-project:

new File(".").toPath().toAbsolutePath();

However, it returns a path relative to the directory structure of a previous plugin test, e.g. C:\Users\me\my-project\target\test-projects\MyPluginTest_graph[3.3.9]_my-test-project.

I think the reason for this behavior is that Embedded3xLauncher sets the user.dir system property. In case the default FileSystem has not been initialized up to this point (e.g. by creating a new File object or calling FileSystems.getDefault()), it will use the modified user.dir property as default directory for the whole lifetime of the JVM. This leads to wrong results in all subsequent code that uses relative paths.

Probably calling FileSystems.getDefault() right before setting the user.dir property would solve this problem. I am not sure if this is also a problem on other operating systems.

@ferstl ferstl changed the title Wrong relative paths after using MavenJUnitTestRunner Wrong relative paths after using MavenJUnitTestRunner Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant