diff --git a/src/communication/bolt/v1/states/init.hpp b/src/communication/bolt/v1/states/init.hpp index 8b04ec30f..4e98b0ad2 100644 --- a/src/communication/bolt/v1/states/init.hpp +++ b/src/communication/bolt/v1/states/init.hpp @@ -33,7 +33,11 @@ State StateInitRun(Session &session) { if (UNLIKELY(marker != Marker::TinyStruct2)) { logger.debug("Expected TinyStruct2 marker, but received 0x{:02X}!", underlying_cast(marker)); - return State::Close; + logger.warn("The client sent malformed data, but we are continuing " + "because the official Neo4j Java driver sends malformed " + "data. D'oh!"); + // TODO: this should be uncommented when the Neo4j Java driver is fixed + //return State::Close; } query::TypedValue client_name; diff --git a/tests/drivers/.gitignore b/tests/drivers/.gitignore new file mode 100644 index 000000000..6ee22ede0 --- /dev/null +++ b/tests/drivers/.gitignore @@ -0,0 +1,7 @@ +# java driver +java/*.jar +java/*.class + +# javascript driver +javascript/node_modules +javascript/package-lock.json diff --git a/tests/drivers/java/run.sh b/tests/drivers/java/run.sh new file mode 100755 index 000000000..7ed961a2e --- /dev/null +++ b/tests/drivers/java/run.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +JAVA=java +JAVAC=javac + +if ! which $JAVA >/dev/null; then + echo "Please install java!" + exit 1 +fi + +if ! which $JAVAC >/dev/null; then + echo "Please install javac!" + exit 1 +fi + +DRIVER=neo4j-java-driver.jar + +if [ ! -f $DRIVER ]; then + wget -O $DRIVER http://central.maven.org/maven2/org/neo4j/driver/neo4j-java-driver/1.3.1/neo4j-java-driver-1.3.1.jar || exit 1 +fi + +javac -classpath .:$DRIVER test.java || exit 1 +java -classpath .:$DRIVER test || exit 1 diff --git a/tests/drivers/java/test.java b/tests/drivers/java/test.java new file mode 100644 index 000000000..ef777ab90 --- /dev/null +++ b/tests/drivers/java/test.java @@ -0,0 +1,38 @@ +import org.neo4j.driver.v1.*; +import org.neo4j.driver.v1.types.*; +import static org.neo4j.driver.v1.Values.parameters; +import java.util.*; + +public class test { + public static void main(String[] args) { + Config config = Config.build().withoutEncryption().toConfig(); + Driver driver = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic( "neo4j", "1234" ), config ); + + try ( Session session = driver.session() ) { + StatementResult rs1 = session.run( "MATCH (n) DETACH DELETE n" ); + System.out.println( "Database cleared." ); + + StatementResult rs2 = session.run( "CREATE (alice: Person {name: 'Alice', age: 22})" ); + System.out.println( "Record created." ); + + StatementResult rs3 = session.run( "MATCH (n) RETURN n" ); + System.out.println( "Record matched." ); + + List records = rs3.list(); + Record record = records.get( 0 ); + Node node = record.get( "n" ).asNode(); + if ( !node.get("name").asString().equals( "Alice" ) || node.get("age").asInt() != 22 ) { + System.out.println( "Data doesn't match!" ); + System.exit( 1 ); + } + + System.out.println( "All ok!" ); + } + catch ( Exception e ) { + System.out.println( e ); + System.exit( 1 ); + } + + driver.close(); + } +} diff --git a/tests/drivers/javascript/run.sh b/tests/drivers/javascript/run.sh new file mode 100755 index 000000000..a490cbbeb --- /dev/null +++ b/tests/drivers/javascript/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +NODE=nodejs +NPM=npm + +if ! which $NODE >/dev/null; then + echo "Please install Node.JS!" + exit 1 +fi + +if ! which $NPM >/dev/null; then + echo "Please install NPM!" + exit 1 +fi + +$NPM install neo4j-driver || exit 1 +$NODE test.js || exit 1 diff --git a/tests/drivers/javascript/test.js b/tests/drivers/javascript/test.js new file mode 100644 index 000000000..7abb2d358 --- /dev/null +++ b/tests/drivers/javascript/test.js @@ -0,0 +1,36 @@ +var neo4j = require('neo4j-driver').v1; +var driver = neo4j.driver("bolt://localhost:7687", + neo4j.auth.basic("neo4j", "1234"), + { encrypted: 'ENCRYPTION_OFF' }); +var session = driver.session(); + +function die() { + session.close(); + driver.close(); + process.exit(1); +} + +function run_query(query, callback) { + var run = session.run(query, {}); + run.then(callback).catch(function (error) { + console.log(error); + die(); + }); +} + +run_query("MATCH (n) DETACH DELETE n", function (result) { + console.log("Database cleared."); + run_query("CREATE (alice: Person {name: 'Alice', age: 22})", function (result) { + console.log("Record created."); + run_query("MATCH (n) RETURN n", function (result) { + console.log("Record matched."); + var alice = result.records[0].get("n"); + if(alice.labels[0] != "Person" || alice.properties["name"] != "Alice"){ + console.log("Data doesn't match!"); + die(); + } + console.log("All ok!"); + driver.close(); + }); + }); +}); diff --git a/tests/drivers/run.sh b/tests/drivers/run.sh new file mode 100755 index 000000000..0df212190 --- /dev/null +++ b/tests/drivers/run.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +pushd () { + command pushd "$@" > /dev/null +} + +popd () { + command popd "$@" > /dev/null +} + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR + +for i in *; do + if [ ! -d $i ]; then continue; fi + pushd $i + echo "Running: $i" + ./run.sh || exit 1 + echo + popd +done