Skip to content

Commit

Permalink
Emit no closing tag in SimpleXmlEncoder#resetStream
Browse files Browse the repository at this point in the history
The `resetStream()` method in the `SimpleXmlEncoder` should not output a
closing root tag if no output was generated. See issue #249 for the same issue
in `closeStream`.
  • Loading branch information
cboehme committed Dec 17, 2015
1 parent 7a5bfa6 commit fce75dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ public void literal(final String name, final String value) {

@Override
protected void onResetStream() {
writeFooter();
if (!atStreamStart) {
writeFooter();
}
sendAndClearData();
atStreamStart = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package org.culturegraph.mf.stream.converter.xml;




import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -55,7 +52,7 @@ public void process(final String obj) {
}
});
resultCollector = new StringBuilder();
}
}

@Test
public void issue249_shouldNotEmitClosingRootTagOnCloseStreamIfNoOutputWasGenerated() {
Expand All @@ -64,6 +61,13 @@ public void issue249_shouldNotEmitClosingRootTagOnCloseStreamIfNoOutputWasGenera
assertTrue(getResultXml().isEmpty());
}

@Test
public void shouldNotEmitClosingRootTagOnResetStreamIfNoOutputWasGenerated() {
simpleXmlEncoder.resetStream();

assertTrue(getResultXml().isEmpty());
}

@Test
public void shouldOnlyEscapeXmlReservedCharacters() {
final StringBuilder builder = new StringBuilder();
Expand Down

0 comments on commit fce75dc

Please sign in to comment.