Permalink
Browse files

exposing faulty double-string parsing in the batch REST processing, r…

…elated to #113
  • Loading branch information...
1 parent 0bc2d11 commit d2d2e1b52d2ae86be1a4fb4e73d2cb245e730a54 @peterneubauer committed Dec 19, 2011
@@ -26,6 +26,7 @@
import java.util.Map;
import org.json.JSONException;
+import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.graphdb.Node;
import org.neo4j.kernel.impl.annotations.Documented;
@@ -356,6 +357,38 @@ public void shouldHandleUnicodeGetCorrectly() throws JsonParseException, ClientH
testBatch(anode, asian);
testBatch(gnode, german);
}
+
+ @Test
+ @Ignore
+ @Graph("Peter likes Production\\\"Code\"")
+ public void shouldHandleEscapedStrings() throws JsonParseException, ClientHandlerException,
+ UniformInterfaceException, JSONException {
+ String string = "Production\\\"Code\"";
+ Node gnode = getNode( string );
+ assertEquals( gnode.getProperty( "name" ), string );
+ Map<String, Object> map = JsonHelper.jsonToMap( gen.get()
+ .expectedStatus( 200 )
+ .get( getNodeUri( gnode ) )
+ .entity() );
+ assertTrue( ((Map)map.get( "data" )).get("name").equals(string) );
+ testBatch(gnode, string);
+// String jsonString = new PrettyJSON()
+// .array()
+// .object()
+// .key("method") .value("PUT")
+// .key("to") .value("/node/"+gnode.getId()+"/properties")
+// .key("body") .object().key( "name" ).value( "string\\ and \"test\"" ).endObject()
+// .endObject()
+// .endArray()
+// .toString();
+// String entity = gen.get()
+// .expectedStatus( 200 )
+// .payload( jsonString )
+// .post( batchUri() )
+// .entity();
+// assertEquals( gnode.getProperty( "name" ), string );
+// assertTrue( ((Map)map.get( "b" )).get("name").equals(string) );
+ }
private void testBatch( Node anode, String asian )
{
@@ -103,6 +103,7 @@ public Response performBatchOperations( @Context UriInfo uriInfo, InputStream bo
} else if(field.equals(ID_KEY)) {
jobId = jp.getIntValue();
} else if(field.equals(BODY_KEY)) {
+ //TODO: this swallows escapes like "\\"
jobBody = StreamingJsonUtils.readCurrentValueAsString(jp, token);
}
}

0 comments on commit d2d2e1b

Please sign in to comment.