Skip to content

Commit 4b83f36

Browse files
committed
Add test exposing that dominant blank (but non-empty) values are
overwritten during merge
1 parent 8a9147a commit 4b83f36

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020

21+
import java.io.IOException;
2122
import java.io.StringReader;
2223

2324
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
25+
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
2426
import org.junit.Test;
2527

2628
/**
@@ -111,7 +113,20 @@ public void testCombineKeys()
111113
assertEquals( "RHS", mergeResult.getChildren( "property" )[2].getChild( "value" ).getValue() );
112114
assertEquals( "right", p2.getChild( "value" ).getInputLocation() );
113115
}
114-
116+
117+
@Test
118+
public void testOverwriteDominantBlankValue() throws XmlPullParserException, IOException {
119+
String lhs = "<parameter xml:space=\"preserve\"> </parameter>";
120+
121+
String rhs = "<parameter>recessive</parameter>";
122+
123+
Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) );
124+
Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new FixedInputLocationBuilder( "right" ) );
125+
126+
Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true );
127+
assertEquals( " ", mergeResult.getValue() );
128+
}
129+
115130
private static class FixedInputLocationBuilder
116131
implements Xpp3DomBuilder.InputLocationBuilder
117132
{

0 commit comments

Comments
 (0)