File tree Expand file tree Collapse file tree 4 files changed +50
-3
lines changed
main/java/org/hibernate/tool
test/java/org/hibernate/tool/api/xml Expand file tree Collapse file tree 4 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 22 * Created on 17-Dec-2004
33 *
44 */
5- package org .hibernate .tool .internal .xml ;
5+ package org .hibernate .tool .api .xml ;
66
77import java .io .File ;
88import java .io .IOException ;
1111import java .nio .file .Files ;
1212import java .nio .file .Paths ;
1313
14+ import org .hibernate .tool .internal .xml .XMLPrettyPrinterStrategyFactory ;
15+
1416/**
1517 * @author max
1618 *
Original file line number Diff line number Diff line change 1010import java .util .Set ;
1111
1212import org .hibernate .tool .api .export .ArtifactCollector ;
13- import org .hibernate .tool .internal .xml .XMLPrettyPrinter ;
13+ import org .hibernate .tool .api .xml .XMLPrettyPrinter ;
1414
1515/**
1616 * Callback class that all exporters are given to allow better feedback and
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ private static XMLPrettyPrinterStrategy loadFromSystemProperty() {
3030 throw new RuntimeException (e );
3131 }
3232 }
33-
3433 return null ;
3534 }
3635}
Original file line number Diff line number Diff line change 1+ package org .hibernate .tool .api .xml ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+
5+ import java .io .File ;
6+ import java .io .PrintWriter ;
7+ import java .nio .file .Files ;
8+
9+ import org .junit .jupiter .api .BeforeEach ;
10+ import org .junit .jupiter .api .Test ;
11+ import org .junit .jupiter .api .io .TempDir ;
12+
13+ public class XMLPrettyPrinterTest {
14+
15+ private static final String XML_BEFORE = "<foo><bar>foobar</bar></foo>" ;
16+
17+ private static final String XML_AFTER =
18+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
19+ "<foo>\n " +
20+ " <bar>foobar</bar>\n " +
21+ "</foo>\n " ;
22+
23+ private static final String fileName = "foobarfile.xml" ;
24+
25+ @ TempDir
26+ private File tempDir ;
27+
28+ private File xmlFile = null ;
29+
30+ @ BeforeEach
31+ public void beforeEach () throws Exception {
32+ xmlFile = new File (tempDir , fileName );
33+ PrintWriter writer = new PrintWriter (xmlFile );
34+ writer .print (XML_BEFORE );
35+ writer .flush ();
36+ writer .close ();
37+ }
38+
39+ @ Test
40+ public void testXmlPrettyPrintDefault () throws Exception {
41+ XMLPrettyPrinter .prettyPrintFile (xmlFile );
42+ String result = Files .readString (xmlFile .toPath ());
43+ assertEquals (XML_AFTER , result );
44+ }
45+
46+ }
You can’t perform that action at this time.
0 commit comments