File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
main/java/org/scijava/io/http
test/java/org/scijava/io/http Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ package org .scijava .io .http ;
3+
4+ import java .net .URI ;
5+ import java .net .URISyntaxException ;
6+
7+ import org .scijava .io .location .AbstractLocationResolver ;
8+ import org .scijava .io .location .Location ;
9+ import org .scijava .io .location .LocationResolver ;
10+ import org .scijava .plugin .Plugin ;
11+
12+ @ Plugin (type = LocationResolver .class )
13+ public class HTTPLocationResolver extends AbstractLocationResolver {
14+
15+ public HTTPLocationResolver () {
16+ super ("http" , "https" );
17+ }
18+
19+ @ Override
20+ public Location resolve (URI uri ) throws URISyntaxException {
21+ return new HTTPLocation (uri );
22+ }
23+ }
Original file line number Diff line number Diff line change 1+
2+ package org .scijava .io .http ;
3+
4+ import static org .junit .Assert .assertEquals ;
5+
6+ import java .io .IOException ;
7+ import java .net .URISyntaxException ;
8+
9+ import org .junit .Test ;
10+ import org .scijava .Context ;
11+ import org .scijava .io .handle .DataHandleService ;
12+ import org .scijava .io .location .Location ;
13+ import org .scijava .io .location .LocationService ;
14+
15+ public class HTTPLocationResolverTest {
16+
17+ final Context context = new Context ();
18+ final DataHandleService dataHandleService = context .service (
19+ DataHandleService .class );
20+ final LocationService resolver = context .service (LocationService .class );
21+
22+ /**
23+ * Tests the location creation with a file located on Github
24+ *
25+ * @throws URISyntaxException
26+ */
27+ @ Test
28+ public void testDataHandleRemote () throws IOException , URISyntaxException {
29+
30+ String url =
31+ "https://github.com/scijava/scijava-io-http/blob/master/src/test/resources/testfile?raw=true" ;
32+ final Location loc = new HTTPLocation (url );
33+ final Location locResolved = resolver .resolve (url );
34+
35+ assertEquals (loc , locResolved );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments