-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBX-2916: Move XMLPrettyPrinter to the API and offer the ability to s…
…pecify the XMLPrettyPrinterStrategy - Move class 'org.hibernate.tool.internal.xml.XMLPrettyPrinter' to 'org.hibernate.tool.api.xml.XMLPrettyPrinter' - Add a new test class 'org.hibernate.tool.api.xml.XMLPrettyPrinterTest' Signed-off-by: Koen Aers <[email protected]>
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
orm/src/test/java/org/hibernate/tool/api/xml/XMLPrettyPrinterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.hibernate.tool.api.xml; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.File; | ||
import java.io.PrintWriter; | ||
import java.nio.file.Files; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
public class XMLPrettyPrinterTest { | ||
|
||
private static final String XML_BEFORE = "<foo><bar>foobar</bar></foo>"; | ||
|
||
private static final String XML_AFTER = | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + | ||
"<foo>\n" + | ||
" <bar>foobar</bar>\n" + | ||
"</foo>\n"; | ||
|
||
private static final String fileName = "foobarfile.xml"; | ||
|
||
@TempDir | ||
private File tempDir; | ||
|
||
private File xmlFile = null; | ||
|
||
@BeforeEach | ||
public void beforeEach() throws Exception { | ||
xmlFile = new File(tempDir, fileName); | ||
PrintWriter writer = new PrintWriter(xmlFile); | ||
writer.print(XML_BEFORE); | ||
writer.flush(); | ||
writer.close(); | ||
} | ||
|
||
@Test | ||
public void testXmlPrettyPrintDefault() throws Exception { | ||
XMLPrettyPrinter.prettyPrintFile(xmlFile); | ||
String result = Files.readString(xmlFile.toPath()); | ||
assertEquals(XML_AFTER, result); | ||
} | ||
|
||
} |