### Question:
AdditionalHeaderDefinition { public Map<String, HeaderDefinition> getDefinitions() { return definitions; } AdditionalHeaderDefinition(XMLTag doc); Map<String, HeaderDefinition> getDefinitions();  }### Answer:
@Test public void test_load_definitions2() throws Exception { XMLTag def = XMLDoc.newDocument(true).addRoot("additionalHeaders") .addTag("text") .addTag("firstLine").addText(":(") .addTag("beforeEachLine").addText(" ( ") .addTag("endLine").addText(":(") .addTag("firstLineDetectionPattern").addText("\\:\\(") .addTag("lastLineDetectionPattern").addText("\\:\\(") .addTag("allowBlankLines").addText("false") .addTag("isMultiline").addText("false"); System.out.println(def.toString()); AdditionalHeaderDefinition loader = new AdditionalHeaderDefinition(def); Header header = new Header(new UrlHeaderSource(getClass().getResource("/check/header.txt"), "UTF-8"), null); System.out.println(header.buildForDefinition(loader.getDefinitions().get("text"), false)); }
@Test public void test_advanced_definitions() throws Exception { XMLTag def = XMLDoc.newDocument(true).addRoot("additionalHeaders") .addTag("csregion") .addTag("firstLine").addText("#region LicenseEOLEOL#endregionEOL") .addTag("firstLineDetectionPattern").addText("#region.*^EOL/\\*\\*.*$") .addTag("lastLineDetectionPattern").addText("\\*/EOL#endregion") .addTag("allowBlankLines").addText("false") .addTag("isMultiline").addText("false"); AdditionalHeaderDefinition loader = new AdditionalHeaderDefinition(def); Header header = new Header(new UrlHeaderSource(getClass().getResource("/test-header1.txt"), "UTF-8"), null); final String content = FileUtils.read(new File("src/test/resources/test-header4.txt"), System.getProperty("file.encoding")); assertEquals(header.buildForDefinition(loader.getDefinitions().get("csregion"), content.indexOf("\n") == -1), content); }
@Test public void test_load_definitions() throws Exception { XMLTag def = XMLDoc.newDocument(true).addRoot("additionalHeaders") .addTag("xquery") .addTag("firstLine").addText("(:") .addTag("beforeEachLine").addText(" : ") .addTag("endLine").addText(" :)EOL") .addTag("firstLineDetectionPattern").addText("\\(\\:") .addTag("lastLineDetectionPattern").addText("\\:\\)") .addTag("allowBlankLines").addText("false") .addTag("isMultiline").addText("false"); System.out.println(def.toString()); AdditionalHeaderDefinition loader = new AdditionalHeaderDefinition(def); assertEquals(loader.getDefinitions().size(), 1); assertEquals(loader.getDefinitions().get("xquery").getType(), "xquery"); assertNull(loader.getDefinitions().get("xquery").getSkipLinePattern()); Header header = new Header(new UrlHeaderSource(getClass().getResource("/test-header1.txt"), "UTF-8"), null); final String content = FileUtils.read(new File("src/test/resources/test-header3.txt"), System.getProperty("file.encoding")); assertEquals(header.buildForDefinition(loader.getDefinitions().get("xquery"), content.indexOf("\n") == -1), content); }