garydgregory commented on code in PR #630:
URL: https://github.com/apache/commons-io/pull/630#discussion_r1623207046
##########
src/test/java/org/apache/commons/io/build/URIOriginTest.java:
##########
@@ -35,4 +39,21 @@ public void beforeEach() {
setOriginRw(new URIOrigin(Paths.get(FILE_NAME_RW).toUri()));
}
+ @Test
+ void testGetInputStreamHttpURI() throws Exception {
+ final String uri = "https://example.com";
+ final AbstractOrigin.URIOrigin origin = new
AbstractOrigin.URIOrigin(new URI(uri));
+ try (final InputStream in = origin.getInputStream()) {
+ assertNotEquals(-1, in.read());
+ }
+ }
+
+ @Test
+ void testGetInputStreamHttps() throws Exception {
+ final String uri = "https://example.com";
+ final AbstractOrigin.URIOrigin origin = new
AbstractOrigin.URIOrigin(new URI(uri));
+ try (final InputStream in = origin.getInputStream()) {
+ assertNotEquals(-1, in.read());
+ }
+ }
Review Comment:
Add tests for 'http' just like you have 'https'. Use JUnit parameterized
tests to reduce code duplication.
##########
src/main/java/org/apache/commons/io/build/AbstractOrigin.java:
##########
@@ -402,6 +402,13 @@ public Path getPath() {
return Paths.get(get());
}
+ @Override
+ public InputStream getInputStream(final OpenOption... options) throws
IOException {
+ if ("http".equalsIgnoreCase(get().getScheme()) ||
"https".equalsIgnoreCase(get().getScheme())) {
Review Comment:
This method should only call `get()` and `getScheme()` once.
Don't override the file systems for these two schemes. You should check if a
file system is installed already that handles HTTP[S] before overriding NIO
Path handling; use `org.apache.commons.io.file.spi.FileSystemProviders`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]