Browse files

Add test to verify JSON.stringify works in document conversion

  • Loading branch information...
1 parent c6504e5 commit 5415d3fe5e1152f954b0a33a03ca7d0cb3236dbe Robert Newson committed Jan 10, 2012
Showing with 17 additions and 0 deletions.
  1. +5 −0 NEWS
  2. +12 −0 src/test/java/com/github/rnewson/couchdb/lucene/DocumentConverterTest.java
View
5 NEWS
@@ -1,3 +1,8 @@
+Version 0.9.0 (Unreleased)
+
+* Upgrade to Rhino 1.7R3
+* Add JSON.stringify support (see above)
+
Version 0.8.0
-------------
View
12 src/test/java/com/github/rnewson/couchdb/lucene/DocumentConverterTest.java
@@ -151,6 +151,18 @@ public void testRuntimeException() throws Exception {
assertThat(result.size(), is(0));
}
+ @Test
+ public void testJSONStringify() throws Exception {
+ final DocumentConverter converter = new DocumentConverter(
+ context,
+ view("function(doc) {var ret=new Document(); "
+ + " ret.add(JSON.stringify({\"foo\":\"bar\"}), {\"field\":\"s\",\"store\":\"yes\"}); return ret;}"));
+ final Collection<Document> result = converter.convert(
+ doc("{_id:\"hello\"}"), settings(), null);
+ assertThat(result.size(), is(1));
+ assertThat(result.iterator().next().getValues("s")[0], is("{\"foo\":\"bar\"}"));
+ }
+
@Test(expected=EvaluatorException.class)
public void testBadCode() throws Exception {
final DocumentConverter converter = new DocumentConverter(

0 comments on commit 5415d3f

Please sign in to comment.