|
18 | 18 |
|
19 | 19 | import static org.junit.Assert.assertEquals;
|
20 | 20 |
|
| 21 | +import java.io.IOException; |
21 | 22 | import java.io.StringReader;
|
22 | 23 |
|
23 | 24 | import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
| 25 | +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
24 | 26 | import org.junit.Test;
|
25 | 27 |
|
26 | 28 | /**
|
@@ -111,7 +113,29 @@ public void testCombineKeys()
|
111 | 113 | assertEquals( "RHS", mergeResult.getChildren( "property" )[2].getChild( "value" ).getValue() );
|
112 | 114 | assertEquals( "right", p2.getChild( "value" ).getInputLocation() );
|
113 | 115 | }
|
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 | + |
| 130 | + @Test |
| 131 | + public void testIsNotEmptyNegatesIsEmpty() |
| 132 | + { |
| 133 | + assertEquals( !Xpp3DomUtils.isEmpty( null ), Xpp3DomUtils.isNotEmpty( null ) ); |
| 134 | + assertEquals( !Xpp3DomUtils.isEmpty( "" ), Xpp3DomUtils.isNotEmpty( "" ) ); |
| 135 | + assertEquals( !Xpp3DomUtils.isEmpty( " " ), Xpp3DomUtils.isNotEmpty( " " ) ); |
| 136 | + assertEquals( !Xpp3DomUtils.isEmpty( "someValue" ), Xpp3DomUtils.isNotEmpty( "someValue" ) ); |
| 137 | + } |
| 138 | + |
115 | 139 | private static class FixedInputLocationBuilder
|
116 | 140 | implements Xpp3DomBuilder.InputLocationBuilder
|
117 | 141 | {
|
|
0 commit comments