Skip to content

Commit

Permalink
Merge pull request neo4j#3664 from davidegrohmann/merge-2.1-master
Browse files Browse the repository at this point in the history
Merge 2.1 in master
  • Loading branch information
davidegrohmann committed Dec 15, 2014
2 parents 2c268f8 + e4458fa commit 14f2c64
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
Expand All @@ -41,7 +43,7 @@ public static Properties properties( Map<String, Object> properties )
return new Properties( properties );
}

private final Map<String, Object> properties = new HashMap<>();
private final SortedMap<String, Object> properties = new TreeMap<>();

private Properties( Property[] properties )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class BatchOperations
protected static final String METHOD_KEY = "method";
protected static final String BODY_KEY = "body";
protected static final String TO_KEY = "to";
protected static final JsonFactory jsonFactory = new JsonFactory();
protected static final JsonFactory jsonFactory = new JsonFactory().disable( JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM );
protected final WebServer webServer;
protected final ObjectMapper mapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected JsonGenerator _createUTF8JsonGenerator( OutputStream out, IOContext ct
return gen;
}
};
factory.enable( JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM );
factory.disable( JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM );
return factory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private enum State

private State currentState = State.EMPTY;

private static final JsonFactory JSON_FACTORY = new JsonFactory( new Neo4jJsonCodec() );
private static final JsonFactory JSON_FACTORY = new JsonFactory( new Neo4jJsonCodec() ).disable( JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM );
private final JsonGenerator out;
private final URI baseUri;
private final StringLogger log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.ObjectMapper;

import org.codehaus.jackson.map.SerializationConfig;
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.PropertyContainer;

public class Neo4jJsonCodec extends ObjectMapper
{

public Neo4jJsonCodec()
{
getSerializationConfig().without( SerializationConfig.Feature.FLUSH_AFTER_WRITE_VALUE );
}

@Override
public void writeValue( JsonGenerator out, Object value ) throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.*;
import org.codehaus.jackson.map.JsonMappingException;

import org.neo4j.helpers.collection.PrefetchingIterator;
Expand All @@ -51,7 +48,7 @@

public class StatementDeserializer extends PrefetchingIterator<Statement>
{
private static final JsonFactory JSON_FACTORY = new JsonFactory().setCodec( new Neo4jJsonCodec() );
private static final JsonFactory JSON_FACTORY = new JsonFactory().setCodec( new Neo4jJsonCodec() ).disable( JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM );
private static final Map<String, Object> NO_PARAMETERS = unmodifiableMap( map() );
private static final Iterator<Neo4jError> NO_ERRORS = emptyIterator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class PagedTraverserDocIT extends ExclusiveServerTestBase
private static final String PAGED_TRAVERSE_LINK_REL = "paged_traverse";
private static final int SHORT_LIST_LENGTH = 33;
private static final int LONG_LIST_LENGTH = 444;
private static final int VERY_LONG_LIST_LENGTH = LONG_LIST_LENGTH*2;

@ClassRule
public static TemporaryFolder staticFolder = new TemporaryFolder();
Expand Down Expand Up @@ -415,10 +416,10 @@ public void should201WithAcceptHtmlHeader()
public void shouldHaveTransportEncodingChunkedOnResponseHeader()
{
// given
theStartNode = createLinkedList( SHORT_LIST_LENGTH, server.getDatabase() );
theStartNode = createLinkedList( VERY_LONG_LIST_LENGTH, server.getDatabase() );

// when
JaxRsResponse response = createStreamingPagedTraverserWithTimeoutInMinutesAndPageSize( 60, 1 );
JaxRsResponse response = createStreamingPagedTraverserWithTimeoutInMinutesAndPageSize( 60, 1000 );

// then
assertEquals( 201, response.getStatus() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import org.neo4j.graphdb.ExecutionPlanDescription;
import org.neo4j.graphdb.Node;
Expand Down Expand Up @@ -309,7 +311,7 @@ public void shouldSerializeNodeAsMapOfProperties() throws Exception
// then
String result = output.toString( "UTF-8" );
assertEquals( "{\"results\":[{\"columns\":[\"node\"]," +
"\"data\":[{\"row\":[{\"d\":[1,0,1,2],\"e\":[\"a\",\"b\",\"ääö\"],\"b\":true,\"c\":[1,0,1,2],\"a\":12}]}]}]," +
"\"data\":[{\"row\":[{\"a\":12,\"b\":true,\"c\":[1,0,1,2],\"d\":[1,0,1,2],\"e\":[\"a\",\"b\",\"ääö\"]}]}]}]," +
"\"errors\":[]}", result );
}

Expand All @@ -320,15 +322,15 @@ public void shouldSerializeNestedEntities() throws Exception
ByteArrayOutputStream output = new ByteArrayOutputStream();
ExecutionResultSerializer serializer = new ExecutionResultSerializer( output, null, DEV_NULL );

Node a = node(1, properties(property("foo", 12)));
Node a = node( 1, properties( property( "foo", 12 ) ) );
Node b = node( 2, properties( property( "bar", false ) ) );
Relationship r = relationship( 1, properties( property( "baz", "quux" ) ), a, "FRAZZLE", b );
Result executionResult = mockExecutionResult( map(
"nested", map(
"nested", new TreeMap<>( map(
"node", a,
"edge", r,
"path", path( a, link( r, b ) )
) ) );
) ) ) );

// when
serializer.statementResult( executionResult, false );
Expand All @@ -337,7 +339,7 @@ public void shouldSerializeNestedEntities() throws Exception
// then
String result = output.toString( "UTF-8" );
assertEquals( "{\"results\":[{\"columns\":[\"nested\"]," +
"\"data\":[{\"row\":[{\"node\":{\"foo\":12},\"edge\":{\"baz\":\"quux\"},\"path\":[{\"foo\":12},{\"baz\":\"quux\"},{\"bar\":false}]}]}]}]," +
"\"data\":[{\"row\":[{\"edge\":{\"baz\":\"quux\"},\"node\":{\"foo\":12},\"path\":[{\"foo\":12},{\"baz\":\"quux\"},{\"bar\":false}]}]}]}]," +
"\"errors\":[]}", result );
}

Expand Down Expand Up @@ -801,7 +803,7 @@ private static Result mockExecutionResult( Map<String, Object>... rows )
@SafeVarargs
private static Result mockExecutionResult( ExecutionPlanDescription planDescription, Map<String, Object>... rows )
{
Set<String> keys = new HashSet<>();
Set<String> keys = new TreeSet<>();
for ( Map<String, Object> row : rows )
{
keys.addAll( row.keySet() );
Expand Down

0 comments on commit 14f2c64

Please sign in to comment.