SOLR-2307: followup to ensure consistent ordering of fields

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1060641 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2011-01-19 00:55:57 +00:00
parent fc57be7f36
commit 886004667a
2 changed files with 8 additions and 5 deletions

View File

@ -106,7 +106,8 @@ class PHPSerializedWriter extends JSONWriter {
@Override
public void writeDoc(String name, Collection<Fieldable> fields, Set<String> returnFields, Map pseudoFields) throws IOException {
ArrayList<Fieldable> single = new ArrayList<Fieldable>();
HashMap<String, MultiValueField> multi = new HashMap<String, MultiValueField>();
LinkedHashMap<String, MultiValueField> multi
= new LinkedHashMap<String, MultiValueField>();
for (Fieldable ff : fields) {
String fname = ff.name();
@ -203,8 +204,8 @@ class PHPSerializedWriter extends JSONWriter {
@Override
public void writeSolrDocument(String name, SolrDocument doc, Set<String> returnFields, Map pseudoFields) throws IOException {
HashMap <String,Object> single = new HashMap<String, Object>();
HashMap <String,Object> multi = new HashMap<String, Object>();
LinkedHashMap <String,Object> single = new LinkedHashMap<String, Object>();
LinkedHashMap <String,Object> multi = new LinkedHashMap<String, Object>();
int pseudoSize = pseudoFields != null ? pseudoFields.size() : 0;
for (String fname : doc.getFieldNames()) {

View File

@ -54,7 +54,8 @@ public class TestPHPSerializedResponseWriter extends SolrTestCaseJ4 {
rsp.add("data2", 42);
rsp.add("data3", true);
w.write(buf, req, rsp);
assertEquals(buf.toString(), "a:3:{s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;}");
assertEquals("a:3:{s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;}",
buf.toString());
req.close();
}
@ -94,7 +95,8 @@ public class TestPHPSerializedResponseWriter extends SolrTestCaseJ4 {
rsp.add("response", sdl);
w.write(buf, req, rsp);
assertEquals(buf.toString(), "a:1:{s:8:\"response\";a:3:{s:8:\"numFound\";i:0;s:5:\"start\";i:0;s:4:\"docs\";a:2:{i:0;a:6:{s:2:\"id\";s:1:\"1\";s:5:\"data1\";s:5:\"hello\";s:5:\"data4\";a:2:{s:7:\"data4.2\";s:7:\"hashmap\";s:7:\"data4.1\";s:5:\"hello\";}s:5:\"data5\";a:3:{i:0;s:7:\"data5.1\";i:1;s:7:\"data5.2\";i:2;s:7:\"data5.3\";}s:5:\"data2\";i:42;s:5:\"data3\";b:1;}i:1;a:1:{s:2:\"id\";s:1:\"2\";}}}}");
assertEquals("a:1:{s:8:\"response\";a:3:{s:8:\"numFound\";i:0;s:5:\"start\";i:0;s:4:\"docs\";a:2:{i:0;a:6:{s:2:\"id\";s:1:\"1\";s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;s:5:\"data4\";a:2:{s:7:\"data4.2\";s:7:\"hashmap\";s:7:\"data4.1\";s:5:\"hello\";}s:5:\"data5\";a:3:{i:0;s:7:\"data5.1\";i:1;s:7:\"data5.2\";i:2;s:7:\"data5.3\";}}i:1;a:1:{s:2:\"id\";s:1:\"2\";}}}}",
buf.toString());
req.close();
}