### Question:
XDOMOfficeDocument implements OfficeDocument { public String getTitle() { String title = getTitle(this.xdom); if (null != title) { title = title.replaceAll("[\n\r]", ""); if (title.length() > 255) { title = title.substring(0, 255); } } return title; } XDOMOfficeDocument(XDOM xdom, Map<String, byte[]> artifacts, ComponentManager componentManager); @Override XDOM getContentDocument(); @Override String getContentAsString(); String getContentAsString(String syntaxId); @Override Map<String, byte[]> getArtifacts(); String getTitle();  }### Answer:
@Test public void titleExtraction() throws Exception { String content = "content before title\n" + "%s Title %s\n" + "content after title."; XDOMOfficeDocument doc = createOfficeDocument(String.format(content, "=", "="), "xwiki/2.0"); assertEquals("Title", doc.getTitle()); doc = createOfficeDocument(String.format(content, "==", "=="), "xwiki/2.0"); assertEquals("Title", doc.getTitle()); doc = createOfficeDocument(String.format(content, "===", "==="), "xwiki/2.0"); assertEquals("Title", doc.getTitle()); doc = createOfficeDocument(String.format(content, "====", "===="), "xwiki/2.0"); assertEquals("Title", doc.getTitle()); doc = createOfficeDocument(String.format(content, "=====", "====="), "xwiki/2.0"); assertEquals("Title", doc.getTitle()); doc = createOfficeDocument(String.format(content, "======", "======"), "xwiki/2.0"); assertEquals("Title", doc.getTitle()); }