FileSchemeStrategy implements SchemeStrategy { @Override public InputStream getInputStream(final String sessionId, final URI uri, final RequestMethod method, final long timeout, final Collection<KeyValuePair> parameters) throws BadFetchError { try { final String scheme = uri.getScheme(); final String path = uri.getPath(); final URI fragmentLessUri = new URI(scheme, null, path, null); if (LOGGER.isDebugEnabled()) { LOGGER.debug("reading '" + fragmentLessUri + "'..."); } final File file = new File(fragmentLessUri); return new FileInputStream(file); } catch (java.io.FileNotFoundException e) { throw new BadFetchError(e.getMessage(), e); } catch (java.lang.IllegalArgumentException e) { throw new BadFetchError(e.getMessage(), e); } catch (URISyntaxException e) { throw new BadFetchError(e.getMessage(), e); } } FileSchemeStrategy(); @Override String getScheme(); @Override InputStream getInputStream(final String sessionId, final URI uri,
            final RequestMethod method, final long timeout,
            final Collection<KeyValuePair> parameters); @Override void sessionClosed(final String sessionId); static final String SCHEME_NAME; }
@Test public void testGetInputStream() throws Exception, JVoiceXMLEvent { final URL file = this.getClass().getResource("/hello.vxml"); final URI uri = file.toURI(); InputStream in = strategy.getInputStream(null, uri, null, 5000, null); Assert.assertNotNull(in); in.close(); }
@Test public void testGetInputStreamFragment() throws Exception, JVoiceXMLEvent { final URL file = this.getClass().getResource("/hello.vxml"); final URI uri = file.toURI(); final URI fragmentUri = new URI(uri.toString() + "#fragment"); InputStream in = strategy.getInputStream(null, fragmentUri, null, 5000, null); Assert.assertNotNull(in); in.close(); }