/** * Converts a collection of strings into a collection of URIs. * @param names collection of strings to convert to URIs * @return collection of URIs */ public static List<URI> stringCollectionAsURIs( Collection<String> names) { List<URI> uris = new ArrayList<>(names.size()); for(String name : names) { try { uris.add(stringAsURI(name)); } catch (IOException e) { LOG.error("Error while processing URI: " + name, e); } } return uris; }
/** * Test for a relative path, os independent * @throws IOException */ public void testRelativePathAsURI() throws IOException { URI u = Util.stringAsURI(RELATIVE_FILE_PATH); LOG.info("Uri: " + u); assertNotNull(u); }
/** * Converts a collection of strings into a collection of URIs. * @param names collection of strings to convert to URIs * @return collection of URIs */ public static List<URI> stringCollectionAsURIs( Collection<String> names) { List<URI> uris = new ArrayList<URI>(names.size()); for(String name : names) { try { uris.add(stringAsURI(name)); } catch (IOException e) { LOG.error("Error while processing URI: " + name, e); } } return uris; } }
/** * Converts a collection of strings into a collection of URIs. * @param names collection of strings to convert to URIs * @return collection of URIs */ public static Collection<URI> stringCollectionAsURIs( Collection<String> names) { Collection<URI> uris = new ArrayList<URI>(names.size()); for(String name : names) { try { uris.add(stringAsURI(name)); } catch (IOException e) { LOG.error("Error while processing URI: " + name, e); } } return uris; } }
/** * Converts a collection of strings into a collection of URIs. * @param names collection of strings to convert to URIs * @return collection of URIs */ public static List<URI> stringCollectionAsURIs( Collection<String> names) { List<URI> uris = new ArrayList<URI>(names.size()); for(String name : names) { try { uris.add(stringAsURI(name)); } catch (IOException e) { LOG.error("Error while processing URI: " + name, e); } } return uris; } }
/** * Test for an OS dependent absolute paths. * @throws IOException */ public void testAbsolutePathAsURI() throws IOException { URI u = null; u = Util.stringAsURI(ABSOLUTE_PATH_WINDOWS); assertNotNull( "Uri should not be null for Windows path" + ABSOLUTE_PATH_WINDOWS, u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); u = Util.stringAsURI(ABSOLUTE_PATH_UNIX); assertNotNull("Uri should not be null for Unix path" + ABSOLUTE_PATH_UNIX, u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); }
/** * Test for a URI * @throws IOException */ public void testURI() throws IOException { LOG.info("Testing correct Unix URI: " + URI_UNIX); URI u = Util.stringAsURI(URI_UNIX); LOG.info("Uri: " + u); assertNotNull("Uri should not be null at this point", u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); assertEquals(URI_PATH_UNIX, u.getPath()); LOG.info("Testing correct windows URI: " + URI_WINDOWS); u = Util.stringAsURI(URI_WINDOWS); LOG.info("Uri: " + u); assertNotNull("Uri should not be null at this point", u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); assertEquals(URI_PATH_WINDOWS.replace("%20", " "), u.getPath()); } }
/** * Test for a relative path, os independent * @throws IOException */ @Test public void testRelativePathAsURI() throws IOException { URI u = Util.stringAsURI(RELATIVE_FILE_PATH); LOG.info("Uri: " + u); assertNotNull(u); }
/** * Test for an OS dependent absolute paths. * @throws IOException */ @Test public void testAbsolutePathAsURI() throws IOException { URI u = null; u = Util.stringAsURI(ABSOLUTE_PATH_WINDOWS); assertNotNull( "Uri should not be null for Windows path" + ABSOLUTE_PATH_WINDOWS, u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); u = Util.stringAsURI(ABSOLUTE_PATH_UNIX); assertNotNull("Uri should not be null for Unix path" + ABSOLUTE_PATH_UNIX, u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); }
/** * Test for a URI * @throws IOException */ @Test public void testURI() throws IOException { LOG.info("Testing correct Unix URI: " + URI_UNIX); URI u = Util.stringAsURI(URI_UNIX); LOG.info("Uri: " + u); assertNotNull("Uri should not be null at this point", u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); assertEquals(URI_PATH_UNIX, u.getPath()); LOG.info("Testing correct windows URI: " + URI_WINDOWS); u = Util.stringAsURI(URI_WINDOWS); LOG.info("Uri: " + u); assertNotNull("Uri should not be null at this point", u); assertEquals(URI_FILE_SCHEMA, u.getScheme()); assertEquals(URI_PATH_WINDOWS.replace("%20", " "), u.getPath()); } }