Credit and test for #636

This commit is contained in:
James 2017-05-20 18:12:34 -04:00
parent 77109cb76b
commit 78643981f6
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package org.hl7.fhir.utilities.xhtml;
import static org.junit.Assert.*;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.junit.Test;
public class XhtmlParserTest {
private XhtmlParser p = new XhtmlParser();
/**
* See #636
*/
@Test
public void testParseLiteralByName() throws Exception {
String input = "<div>&alpha;</div>";
XhtmlDocument parsed = p.parse(input, null);
assertEquals(1, parsed.getChildNodes().size());
assertEquals(XhtmlNode.class, parsed.getChildNodes().get(0).getClass());
XhtmlNode node = parsed.getChildNodes().get(0);
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">α</div>", node.getValue());
}
/**
* See #636
*/
@Test
public void testParseLiteralByDecimal() throws Exception {
String input = "<div>&#945;</div>";
XhtmlDocument parsed = p.parse(input, null);
assertEquals(1, parsed.getChildNodes().size());
assertEquals(XhtmlNode.class, parsed.getChildNodes().get(0).getClass());
XhtmlNode node = parsed.getChildNodes().get(0);
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">α</div>", node.getValue());
}
/**
* See #636
*/
@Test
public void testParseLiteralByHex() throws Exception {
String input = "<div>&#x03B1;</div>";
XhtmlDocument parsed = p.parse(input, null);
assertEquals(1, parsed.getChildNodes().size());
assertEquals(XhtmlNode.class, parsed.getChildNodes().get(0).getClass());
XhtmlNode node = parsed.getChildNodes().get(0);
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">α</div>", node.getValue());
}
}

View File

@ -121,6 +121,10 @@
AppacheHttpClient did not always respect the charset in the response
Content-Type header. Thanks to Gijsbert van den Brink for the pull request!
</action>
<action type="fix" issue="636">
Fix XhtmlParser to correctly handle hexadecimal escaped literals. Thanks to
Gijsbert van den Brink for the Pull Request!
</action>
</release>
<release version="2.4" date="2017-04-19">
<action type="add">