URLConnection extends java.net.URLConnection { @Override public InputStream getInputStream() throws IOException { connect(); if (getDoInput()) { InputStream is = new FileInputStream(this.file); if (getUseCaches()) { is = new BufferedInputStream(is); } return is; } throw new UnknownServiceException("E2"); } protected  URLConnection(URL url); @Override String getHeaderField(int index); @Override String getHeaderField(String name); @Override String getHeaderFieldKey(int index); @Override Map<String, List<String>> getHeaderFields(); @Override void connect(); @Override OutputStream getOutputStream(); @Override InputStream getInputStream();  }
@Test public void getInputStream() throws IOException { String line; try (InputStream is = this.connection.getInputStream()) { try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { line = br.readLine(); } } assertEquals("TEST1: FOR UNIT TEST ONLY", line); }