forked from playframework/play1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[playframework#1094] play.libs.XML.serialize method calls Sun proprie…
…tary API Merge remote-tracking branch '1094/lighthouse-1094-patch'
- Loading branch information
Showing
2 changed files
with
57 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package play.libs; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.ByteArrayInputStream; | ||
|
||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.w3c.dom.Document; | ||
|
||
/** | ||
* Tests for {@link XML} class. | ||
*/ | ||
public class XMLTest { | ||
|
||
private static final String ORIGINAL_DOCUMENT = | ||
"<?xml version=\"1.0\"?>\n" + | ||
"<feed xmlns=\"http://www.w3.org/2005/Atom\">" + | ||
"<title>Awesome Blog</title>" + | ||
"<link href=\"http://blog.example.com/\"/>" + | ||
"</feed>"; | ||
private Document document; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
document = XML.getDocument(ORIGINAL_DOCUMENT); | ||
} | ||
|
||
private static String stripPreamble(String text) { | ||
return text.replaceFirst("<\\?[^?]+\\?>\\s*", ""); | ||
} | ||
|
||
@Test | ||
public void serializeShouldReturnWellFormedXml() throws Exception { | ||
String outputDocument = XML.serialize(document); | ||
assertEquals( | ||
stripPreamble(ORIGINAL_DOCUMENT), | ||
stripPreamble(outputDocument)); | ||
} | ||
} |