### Question:
FileSystemURLFactory extends XWikiServletURLFactory { @Override public URL createAttachmentURL(String filename, String spaces, String name, String action, String querystring, String wiki, XWikiContext context) { try { return getURL(wiki, spaces, name, filename, null, context); } catch (Exception ex) { LOGGER.warn("Failed to save image for PDF export", ex); return super.createAttachmentURL(filename, spaces, name, action, null, wiki, context); } }  @Override URL createAttachmentURL(String filename, String spaces, String name, String action, String querystring,
        String wiki, XWikiContext context); @Override URL createAttachmentRevisionURL(String filename, String spaces, String name, String revision, String wiki,
        XWikiContext context); @Override URL createSkinURL(String filename, String skin, XWikiContext context); @Override URL createResourceURL(String filename, boolean forceSkinAction, XWikiContext context); @Override String getURL(URL url, XWikiContext context);  }### Answer:
@Test public void createAttachmentURLWhenAttachmentDoesntExist() throws Exception { Map<String, File> usedFiles = new HashMap<>(); this.oldcore.getXWikiContext().put("pdfexport-file-mapping", usedFiles); File tempDir = new File("target/FileSystemURLFactoryTest"); tempDir.mkdirs(); this.oldcore.getXWikiContext().put("pdfexportdir", tempDir); assertNull(this.urlFactory.createAttachmentURL("nonexisting.png", "space", "page", "view", null, this.oldcore.getXWikiContext())); assertEquals("Attachment [nonexisting.png] doesn't exist in [xwiki:space.page]. Generated content will have " + "invalid content (empty image or broken link)", this.logCapture.getMessage(0)); }