UrlStreamFactory implements InputStreamFactory { @Override public long getExpectedSize() throws IOException { if (!url.getProtocol().equals("http")){ return url.openConnection().getContentLength(); } return getSizeOfHttpResource(); } UrlStreamFactory(URL url); @Override InputStream openStream(); @Override long getExpectedSize();  }
@Test public void reportsContentLengthAsSize() throws Exception { URL url = new URL("http: long expectedSize = new UrlStreamFactory(url).getExpectedSize(); assertThat(expectedSize, is(12L)); }