### Question:
AMSetupUtils { public static String readFile(ServletContext servletContext, String file) throws IOException { InputStream inputStream; if ((inputStream = getResourceAsStream(servletContext, file)) == null) { throw new IOException(file + " not found"); } return readStream(inputStream); } private  AMSetupUtils(); static String readFile(ServletContext servletContext, String file); static String getRandomString(); static int getFirstUnusedPort(String hostname, int start, int increment); static boolean isPortInUse(String hostname, int port); static Map<String, String> getRemoteServerInfo(String serverUrl, String userId, String password); static InputStream getResourceAsStream(ServletContext servletContext, String file);  }### Answer:
@Test(expectedExceptions = IOException.class) public void readFileShouldThrowIOExceptionIfFileNotFound() throws IOException { ServletContext context = mock(ServletContext.class); String file = "INVALID_FILE_NAME"; readFile(context, file); failBecauseExceptionWasNotThrown(IOException.class); }
@Test public void shouldReadFileUsingClassLoader() throws IOException { String file = "/AMSetupUtilsTestFile.txt"; String contents = readFile(null, file); assertThat(contents).isEqualTo("FILE_CONTENTS\n"); }