-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Extend url protocols #361
Extend url protocols #361
Conversation
Windows and your source code sits in a directory with spaces
* Raised visibility of ClasspathIterable.getPath(URL) * Created ResourceIteratorFactory interface * Factored FileResourceIterator creation into ResourceIteratorFactory implementation * Added services file for ResourceIteratorFactory
* Factored resource iterators into separate factories * There seems to be a classpath issue with the ZipResourceIterator, because when it's created by a factory loaded using the ServiceLoader class, it's unable to find some ZIP files (this was a problem in the cucumber-jython tests) the solution was to create the ZipThenFileResourceIteratorFallback class
* Cosmetic tweaks * Removed hard-coded dependency on ZipResourceIteratorFactory in ClasspathIterable
I didn't know about the Anyway - nice patch. I'll take a closer look when I have more time. |
I know right?? I didn't know about the You can probably follow a similar pattern for the |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Solution to #360: Unable to extend URL protocols handled by ClasspathIterable
I replaced the hard-coded dependencies on FileResourceIterator and ZipResourceIterator in the ClasspathIterable with a factory for loading resource iterators. Resource iterators are now created using ResourceIteratorFactory implementations and making these implementations available to the ClasspathIterable only requires a META-INF/services/cucumber.io.ResourceIteratorFactory file with the names of the implementing classes on each line.
The factory used by ClasspathIterable will try to find an appropriate factory to create resource iterators for each URL. If no appropriate factory is found, it will fall back to the ZipResourceIteratorFactory and then the FileResourceIteratorFactory. This means that existing behavior is not impacted by the changes.
There is a proof-of-concept test, cucumber.io.DelegatingResourceIteratorFactoryTest, which shows the META-INF/services/cucumber.io.ResourceIteratorFactory file in action. Other tests for fall-back capability with ZIP/File resource iterator factories would have been inconclusive because any test resources could exist either as a file or within a JAR depending on the test runtime environment.
Other changes: