From 4859bd8b3000543fb673da5b5c83c15f2b3d835b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Tue, 27 Mar 2012 21:50:41 +0000 Subject: [PATCH] SOLR-2970 and SOLR-3281: Fix tests for IBM VM git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1306025 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/response/TestCSVResponseWriter.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java b/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java index 6d9a535c740..607d34b1c5c 100644 --- a/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java +++ b/solr/core/src/test/org/apache/solr/response/TestCSVResponseWriter.java @@ -26,6 +26,7 @@ import org.apache.solr.search.ReturnFields; import org.junit.*; import java.io.StringWriter; +import java.util.Arrays; public class TestCSVResponseWriter extends SolrTestCaseJ4 { @BeforeClass @@ -98,9 +99,9 @@ public class TestCSVResponseWriter extends SolrTestCaseJ4 { assertEquals("1,,hi\n2,\"hi,there\",\n" , h.query(req("q","id:[1 TO 2]", "wt","csv", "csv.header","false", "fl","id,v_ss,foo_s"))); - // test SOLR-2970 not returning non-stored fields by default - assertEquals("id,foo_b,foo_d,foo_s,foo_f,foo_i,foo_dt,foo_l,v_ss,v2_ss\n" - , h.query(req("q","id:3", "wt","csv", "csv.header","true", "fl","*", "rows","0"))); + // test SOLR-2970 not returning non-stored fields by default. Compare sorted list + assertEquals(sortHeader("v_ss,foo_b,v2_ss,foo_f,foo_i,foo_d,foo_s,foo_dt,id,foo_l\n") + , sortHeader(h.query(req("q","id:3", "wt","csv", "csv.header","true", "fl","*", "rows","0")))); // now test SolrDocumentList @@ -166,4 +167,13 @@ public class TestCSVResponseWriter extends SolrTestCaseJ4 { req.close(); } + /* + * Utility method to sort a comma separated list of strings, for easier comparison regardless of platform + */ + private String sortHeader(String input) { + String[] output = input.trim().split(","); + Arrays.sort(output); + return Arrays.toString(output); + } + } \ No newline at end of file