Output implements Verifiable { @Override public void verify() throws InvalidSyntaxException { if(nullOutput) return; if(isConsoleOutput()) return; if(!isAbsolute() && (relativePath==null || relativeTo==null)) throw new InvalidSyntaxException("output is neither absolute nor relative"); if(name==null) throw new InvalidSyntaxException("no strategy to calculate output filename is defined"); } Output(); void setRelativeTo(String relativeTo); void setRelativePath(String relativePath); void setAbsolute(String absolute); void setPrefix(String prefix); void setSuffix(String suffix); void setName(String name); void setNull(final boolean nullOutput); void setOutputProperties(final Properties props); void setOutputProperty(final String key, final String value); void unsetOutputProperty(final String key); boolean isNullOutput(); Properties getOutputProperties(); String getOutputProperty(final String key); File getDestinationFile(File sourceFile, HashMap<QName,ParameterValue> parameters); @Override void verify(); @Override String toString(); String toString(final String prefix); String getConsole(); void setConsole(String console); boolean isConsoleOutput(); String getId(); void setId(String id); static final HashMap<String,OutputPropertyEntry> VALID_OUTPUT_PROPERTIES; }
@Test public void testIndent() throws Exception { GauloisPipe piper = new GauloisPipe(configFactory); ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "./src/test/resources/outputParams.xml"); Config config = cu.buildConfig(emptyInputParams); config.verify(); piper.setConfig(config); piper.setInstanceName("OUTPUT_PARAMS"); piper.launch(); File expect = new File("./target/generated-test-files/source-output-indented.xml"); assertTrue("The file target/generated-test-files/source-output-indented.xml does not exists", expect.exists()); try (BufferedReader br = new BufferedReader(new FileReader(expect))) { String line = br.readLine(); assertTrue("output is not ISO-8859-1 encoded", line.contains("ISO-8859-1")); assertTrue("output is not indented (1)", !line.contains("<root>")); line=br.readLine(); assertEquals("output is not indented (2)", "<root>",line); line=br.readLine(); assertTrue("output is not indented (3)", line.startsWith(" ")); assertTrue("CDATA is not set in <information/>",line.contains("<![CDATA[")); assertTrue("CDATA is not set in <information/>",line.contains("]]>")); line=br.readLine(); assertEquals("problen in indentation","</root>",line); } }