File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
main/java/org/metafacture/xml
test/java/org/metafacture/xml Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 5353public final class SimpleXmlEncoder extends DefaultStreamPipe <ObjectReceiver <String >> {
5454
5555 public static final String ATTRIBUTE_MARKER = "~" ;
56+ public static final String DEFAULT_VALUE_TAG = "" ;
5657
5758 private static final String NEW_LINE = "\n " ;
5859 private static final String INDENT = "\t " ;
@@ -73,7 +74,7 @@ public final class SimpleXmlEncoder extends DefaultStreamPipe<ObjectReceiver<Str
7374 private String attributeMarker = ATTRIBUTE_MARKER ;
7475 private String rootTag = DefaultXmlPipe .DEFAULT_ROOT_TAG ;
7576 private String recordTag = DefaultXmlPipe .DEFAULT_RECORD_TAG ;
76- private String valueTag = DefaultXmlPipe . DEFAULT_VALUE_TAG ;
77+ private String valueTag = DEFAULT_VALUE_TAG ;
7778 private Map <String , String > namespaces = new HashMap <String , String >();
7879 private boolean writeRootTag = true ;
7980 private boolean writeXmlHeader = true ;
Original file line number Diff line number Diff line change 1919import static org .junit .Assert .assertEquals ;
2020import static org .junit .Assert .assertTrue ;
2121
22+ import org .metafacture .framework .helpers .DefaultObjectReceiver ;
23+ import org .metafacture .framework .helpers .DefaultXmlPipe ;
24+
2225import java .util .HashMap ;
2326import java .util .Map ;
2427
2528import org .junit .Before ;
2629import org .junit .Test ;
27- import org .metafacture .framework .helpers .DefaultObjectReceiver ;
2830
2931/**
3032 * Tests for class {@link SimpleXmlEncoder}.
@@ -251,6 +253,22 @@ public void issue379_testShouldEncodeConfiguredValueLiteralsAsText() {
251253 getResultXml ());
252254 }
253255
256+ @ Test
257+ public void issue379_testShouldNotEncodeUnconfiguredValueLiteralsAsText () {
258+ simpleXmlEncoder .startRecord ("" );
259+ simpleXmlEncoder .literal (DefaultXmlPipe .DEFAULT_VALUE_TAG , VALUE );
260+ simpleXmlEncoder .endRecord ();
261+ simpleXmlEncoder .closeStream ();
262+
263+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>" +
264+ "<records>" +
265+ "<record>" +
266+ "<value>value</value>" +
267+ "</record>" +
268+ "</records>" ,
269+ getResultXml ());
270+ }
271+
254272 @ Test
255273 public void testShouldEncodeMarkedLiteralsAsAttributes () {
256274 simpleXmlEncoder .startRecord ("" );
You can’t perform that action at this time.
0 commit comments