Search in sources :

Example 1 with DefaultXmlFormatter

use of org.mybatis.generator.api.dom.DefaultXmlFormatter in project generator by mybatis.

the class XmlFileMergerTest method testThatFilesAreTheSameAfterMerge.

@Test
public void testThatFilesAreTheSameAfterMerge() throws Exception {
    DefaultXmlFormatter xmlFormatter = new DefaultXmlFormatter();
    Properties p = new Properties();
    p.setProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE, "true");
    CommentGenerator commentGenerator = new DefaultCommentGenerator();
    commentGenerator.addConfigurationProperties(p);
    Document document = new Document(XmlConstants.MYBATIS3_MAPPER_PUBLIC_ID, XmlConstants.MYBATIS3_MAPPER_SYSTEM_ID);
    document.setRootElement(getSqlMapElement(commentGenerator));
    GeneratedXmlFile generatedFile1 = new GeneratedXmlFile(document, "TestMapper.xml", "org.mybatis.test", "src", true, xmlFormatter);
    InputSource is1 = new InputSource(new StringReader(generatedFile1.getFormattedContent()));
    GeneratedXmlFile generatedFile2 = new GeneratedXmlFile(document, "TestMapper.xml", "org.mybatis.test", "src", true, xmlFormatter);
    InputSource is2 = new InputSource(new StringReader(generatedFile2.getFormattedContent()));
    String mergedSource = XmlFileMergerJaxp.getMergedSource(is1, is2, "TestMapper.xml");
    assertEquals(generatedFile1.getFormattedContent(), mergedSource);
}
Also used : DefaultXmlFormatter(org.mybatis.generator.api.dom.DefaultXmlFormatter) InputSource(org.xml.sax.InputSource) CommentGenerator(org.mybatis.generator.api.CommentGenerator) StringReader(java.io.StringReader) Properties(java.util.Properties) Document(org.mybatis.generator.api.dom.xml.Document) GeneratedXmlFile(org.mybatis.generator.api.GeneratedXmlFile) Test(org.junit.Test)

Aggregations

StringReader (java.io.StringReader)1 Properties (java.util.Properties)1 Test (org.junit.Test)1 CommentGenerator (org.mybatis.generator.api.CommentGenerator)1 GeneratedXmlFile (org.mybatis.generator.api.GeneratedXmlFile)1 DefaultXmlFormatter (org.mybatis.generator.api.dom.DefaultXmlFormatter)1 Document (org.mybatis.generator.api.dom.xml.Document)1 InputSource (org.xml.sax.InputSource)1