### Question:
FileUploader { public String upload() throws IOException, URISyntaxException { ResponseValues response = new ResponseValues(); String thePermalink = null; Map<String, String> metaDataParts = getMetadataParts(); InputStream returnStream; if (metaDataParts.isEmpty()) { returnStream = myServer.postFile(new URL(myUrl), myFile, response); } else { returnStream = getServer().postFile(new URL(getUrl()), metaDataParts, getFile(), response); } try { if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { ObjectMapper mapper = JsonUtils.createMapper(); UploadResponse uploadResponse = mapper.readValue(returnStream, UploadResponse.class); if (uploadResponse.isSuccess()) { thePermalink = uploadResponse.getUrl(); } else { throw new IOException("File failed to upload."); } } else { throw new IOException(response.getResponseMessage()); } } finally { returnStream.close(); } return thePermalink; } FileUploader(File file, HttpServer server, String url); String upload(); File getFile(); HttpServer getServer(); String getUrl();  }### Answer:
@Test public void testUpload() throws IOException, ParserConfigurationException, URISyntaxException { Node stateNode = createStateNode(); String state = XMLUtilities.format(stateNode); File testFile = new File("testFile.state"); testFile.deleteOnExit(); boolean created = testFile.createNewFile(); assertTrue(created); FileOutputStream output = new FileOutputStream(testFile); output.write(state.getBytes(StringUtilities.DEFAULT_CHARSET)); output.close(); HttpServer server = createServer(); EasyMock.replay(server); FileUploader uploader = new FileUploader(testFile, server, ourUrl); String downloadUrl = uploader.upload(); EasyMock.verify(server); assertEquals(ourDownloadUrl, downloadUrl); }