JDK 8 build fix: now test uses LinkedHashMap to avoid random position of attributes in XML.
This commit is contained in:
parent
a3ae739ca3
commit
48c803b693
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.xml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -31,24 +31,40 @@ public class XmlAppendableTest
|
|||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
XmlAppendable out = new XmlAppendable(b);
|
||||
Map<String,String> attr = new HashMap<>();
|
||||
|
||||
Map<String, String> attr = new LinkedHashMap<>();
|
||||
|
||||
out.open("test");
|
||||
|
||||
attr.put("name","attr value");
|
||||
attr.put("noval",null);
|
||||
attr.put("quotes","'\"");
|
||||
|
||||
|
||||
attr.put("name", "attr value");
|
||||
attr.put("noval", null);
|
||||
attr.put("quotes", "'\"");
|
||||
|
||||
out.tag("tag");
|
||||
out.tag("tag",attr);
|
||||
out.tag("tag",attr,"content");
|
||||
|
||||
out.open("level1").tag("tag","content").tag("tag","content").close();
|
||||
out.open("level1",attr).open("level2").tag("tag","content").tag("tag","content").close().close();
|
||||
|
||||
out.tag("tag", attr);
|
||||
out.tag("tag", attr, "content");
|
||||
|
||||
out.open("level1").tag("tag", "content").tag("tag", "content").close();
|
||||
out.open("level1", attr).open("level2").tag("tag", "content").tag("tag", "content").close().close();
|
||||
|
||||
out.close();
|
||||
|
||||
String s = b.toString();
|
||||
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test>\n <tag/>\n <tag quotes=\"'"\" name=\"attr value\" noval=\"\"/>\n <tag quotes=\"'"\" name=\"attr value\" noval=\"\">content</tag>\n <level1>\n <tag>content</tag>\n <tag>content</tag>\n </level1>\n <level1 quotes=\"'"\" name=\"attr value\" noval=\"\">\n <level2>\n <tag>content</tag>\n <tag>content</tag>\n </level2>\n </level1>\n</test>\n",s);
|
||||
|
||||
String expected = "" +
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<test>\n" +
|
||||
" <tag/>\n" +
|
||||
" <tag name=\"attr value\" noval=\"\" quotes=\"'"\"/>\n" +
|
||||
" <tag name=\"attr value\" noval=\"\" quotes=\"'"\">content</tag>\n" +
|
||||
" <level1>\n" +
|
||||
" <tag>content</tag>\n" +
|
||||
" <tag>content</tag>\n" +
|
||||
" </level1>\n" +
|
||||
" <level1 name=\"attr value\" noval=\"\" quotes=\"'"\">\n" +
|
||||
" <level2>\n" +
|
||||
" <tag>content</tag>\n" +
|
||||
" <tag>content</tag>\n" +
|
||||
" </level2>\n" +
|
||||
" </level1>\n" +
|
||||
"</test>\n";
|
||||
Assert.assertEquals(expected, b.toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue