@Test(expected = IOException.class) public void readConfigThrowsException_whenStreamBreaks() throws IOException { InputStream fileStream = mock(InputStream.class); when(fileStream.read(any(), anyInt(), anyInt())).thenThrow(new IOException("Error")); ConnectorUtils.readConfig(fileStream); }
static String readConfig(InputStream inputStream) throws IOException { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { pw.println(line); } pw.close(); } catch (IOException e) { LOGGER.error("IOException reading mappings :: {}", e.getMessage()); throw (e); } return sw.toString(); }
ConnectorUtils { static String readConfig(InputStream inputStream) throws IOException { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { pw.println(line); } pw.close(); } catch (IOException e) { LOGGER.error("IOException reading mappings :: {}", e.getMessage()); throw (e); } return sw.toString(); } }
ConnectorUtils { static String readConfig(InputStream inputStream) throws IOException { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { pw.println(line); } pw.close(); } catch (IOException e) { LOGGER.error("IOException reading mappings :: {}", e.getMessage()); throw (e); } return sw.toString(); }  }
ConnectorUtils { static String readConfig(InputStream inputStream) throws IOException { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { pw.println(line); } pw.close(); } catch (IOException e) { LOGGER.error("IOException reading mappings :: {}", e.getMessage()); throw (e); } return sw.toString(); }   }
ConnectorUtils { static String readConfig(InputStream inputStream) throws IOException { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { pw.println(line); } pw.close(); } catch (IOException e) { LOGGER.error("IOException reading mappings :: {}", e.getMessage()); throw (e); } return sw.toString(); }    }