@Test void generatedConfigIsLoadable() throws Exception { String config = "<redpen-conf lang=\"en\">\n" + " <validators>\n" + " <validator name=\"SentenceLength\">\n" + " <property name=\"max_len\" value=\"100\"/>\n" + " </validator>\n" + " <validator name=\"InvalidSymbol\"/>\n" + " </validators>\n" + " <symbols>\n" + " <symbol name=\"EXCLAMATION_MARK\" value=\"！\" invalid-chars=\"!\" after-space=\"true\"/>\n" + " </symbols>\n" + "</redpen-conf>"; Configuration configuration = new ConfigurationLoader().loadFromString(config); exporter.export(configuration, out); assertEquals(config, out.toString()); }
public void export(Configuration config, OutputStream out) { try { XMLOutputFactory sf = XMLOutputFactory.newInstance(); XMLStreamWriter sax = new IndentingXMLStreamWriter(sf.createXMLStreamWriter(new OutputStreamWriter(out, UTF_8))); addRoot(config, sax); addValidators(config.getValidatorConfigs(), sax); addNonDefaultSymbols(config.getSymbolTable(), sax); sax.writeEndElement(); sax.flush(); } catch (XMLStreamException e) { throw new RuntimeException(e); } }
ConfigurationExporter { public void export(Configuration config, OutputStream out) { try { XMLOutputFactory sf = XMLOutputFactory.newInstance(); XMLStreamWriter sax = new IndentingXMLStreamWriter(sf.createXMLStreamWriter(new OutputStreamWriter(out, UTF_8))); addRoot(config, sax); addValidators(config.getValidatorConfigs(), sax); addNonDefaultSymbols(config.getSymbolTable(), sax); sax.writeEndElement(); sax.flush(); } catch (XMLStreamException e) { throw new RuntimeException(e); } } }
ConfigurationExporter { public void export(Configuration config, OutputStream out) { try { XMLOutputFactory sf = XMLOutputFactory.newInstance(); XMLStreamWriter sax = new IndentingXMLStreamWriter(sf.createXMLStreamWriter(new OutputStreamWriter(out, UTF_8))); addRoot(config, sax); addValidators(config.getValidatorConfigs(), sax); addNonDefaultSymbols(config.getSymbolTable(), sax); sax.writeEndElement(); sax.flush(); } catch (XMLStreamException e) { throw new RuntimeException(e); } }  }
ConfigurationExporter { public void export(Configuration config, OutputStream out) { try { XMLOutputFactory sf = XMLOutputFactory.newInstance(); XMLStreamWriter sax = new IndentingXMLStreamWriter(sf.createXMLStreamWriter(new OutputStreamWriter(out, UTF_8))); addRoot(config, sax); addValidators(config.getValidatorConfigs(), sax); addNonDefaultSymbols(config.getSymbolTable(), sax); sax.writeEndElement(); sax.flush(); } catch (XMLStreamException e) { throw new RuntimeException(e); } }  void export(Configuration config, OutputStream out); }
ConfigurationExporter { public void export(Configuration config, OutputStream out) { try { XMLOutputFactory sf = XMLOutputFactory.newInstance(); XMLStreamWriter sax = new IndentingXMLStreamWriter(sf.createXMLStreamWriter(new OutputStreamWriter(out, UTF_8))); addRoot(config, sax); addValidators(config.getValidatorConfigs(), sax); addNonDefaultSymbols(config.getSymbolTable(), sax); sax.writeEndElement(); sax.flush(); } catch (XMLStreamException e) { throw new RuntimeException(e); } }  void export(Configuration config, OutputStream out);  }