### Question:
BatikSVGRasterizer implements SVGRasterizer { @Override public File rasterizeToTemporaryFile(String content, int width, int height) throws IOException { String fileName = getTemporaryFileName(content, width, height); TemporaryResourceReference reference = new TemporaryResourceReference(TEMP_DIR_NAME, fileName, null); File out = this.temporaryResourceStore.getTemporaryFile(reference); if (rasterizeToFile(content, out, width, height)) { return out; } return null; }  @Override File rasterizeToTemporaryFile(String content, int width, int height); @Override TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height); @Override TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height,
        DocumentReference targetContext); @Override void rasterizeToResponse(String content, int width, int height);  }### Answer:
@Test public void rasterizeToTemporaryFileCreatesTemporaryFile() throws Exception { File tfile = this.mocker.getComponentUnderTest().rasterizeToTemporaryFile(VALID_SVG, 100, 200); Assert.assertEquals(this.temporaryFilePath, tfile.getAbsolutePath()); Assert.assertTrue(tfile.exists()); Assert.assertTrue(isPNG(tfile)); }
@Test public void rasterizeToTemporaryFileReusesFile() throws Exception { writeTestFile(this.temporaryFile); File tfile = this.mocker.getComponentUnderTest().rasterizeToTemporaryFile(VALID_SVG, 100, 200); Assert.assertEquals(this.temporaryFilePath, tfile.getAbsolutePath()); Assert.assertTrue(tfile.exists()); Assert.assertTrue(isTestFile(tfile)); }
@Test public void rasterizeToTemporaryFileReturnsNullOnExceptions() throws Exception { File tfile = this.mocker.getComponentUnderTest().rasterizeToTemporaryFile(INVALID_SVG, 0, 0); Assert.assertNull(tfile); }
@Test public void rasterizeToTemporaryFileReturnsNullWhenParentFolderCannotBeCreated() throws Exception { this.baseDirectory.getRoot().mkdirs(); writeTestFile(new File(this.baseDirectory.getRoot(), "temp")); File tfile = this.mocker.getComponentUnderTest().rasterizeToTemporaryFile(VALID_SVG, 100, 200); Assert.assertNull(tfile); }
@Test public void rasterizeToTemporaryFileThrowsExceptionWhenFileCannotBeCreated() throws Exception { this.temporaryFile.mkdirs(); try { this.mocker.getComponentUnderTest().rasterizeToTemporaryFile(VALID_SVG, 100, 200); Assert.fail(); } catch (IOException e) { } }