Make XhtmlNode$Location serializable

Addresses jamesagnew/hapi-fhir#1422.
This commit is contained in:
John Grimes 2020-04-12 11:35:13 +10:00
parent 4bd0d60e5c
commit 952e6c6e6b
2 changed files with 15 additions and 1 deletions

View File

@ -50,6 +50,7 @@ package org.hl7.fhir.utilities.xhtml;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -67,7 +68,8 @@ public class XhtmlNode implements IBaseXhtml {
private static final long serialVersionUID = -4362547161441436492L;
public static class Location {
public static class Location implements Serializable {
private static final long serialVersionUID = -4079302502900219721L;
private int line;
private int column;
public Location(int line, int column) {

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.utilities.tests;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.junit.Test;
import org.slf4j.Logger;
@ -71,4 +74,13 @@ public class XhtmlNodeTest {
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\"><img src=\"http://pbs.twimg.com/profile_images/544507893991485440/r_vo3uj2_bigger.png\" alt=\"Twitter Avatar\"/>@fhirabend</div>", output);
}
@Test
public void testSerializable() throws IOException {
XhtmlNode node = new XhtmlNode();
node.setValueAsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><div xmlns=\"http://www.w3.org/1999/xhtml\">Test</div>");
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(node);
}
}