Skip to content

1.0 tck #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 5, 2016
26 changes: 22 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
Expand All @@ -42,6 +42,7 @@ var runSequence = require('run-sequence');
var path = require('path');
var childProcess = require("child_process");
var minimist = require('minimist');
var cucumber = require('gulp-cucumber');

gulp.task('default', ["test"]);

Expand Down Expand Up @@ -89,10 +90,10 @@ gulp.task('build-browser-test', function(){
cb();
}))
.pipe( through.obj( function( testFiles, enc, cb) {
browserify({
browserify({
entries: testFiles,
cache: {},
debug: true
debug: true
}).transform(babelify.configure({
ignore: /external/
}))
Expand Down Expand Up @@ -131,7 +132,7 @@ gulp.task('all', function(cb){
});

gulp.task('test', function(cb){
runSequence('test-nodejs', 'test-browser', cb);
runSequence('test-nodejs', 'test-browser', 'run-tck', cb);
});

gulp.task('test-nodejs', ['nodejs'], function () {
Expand Down Expand Up @@ -186,6 +187,23 @@ gulp.task('download-neo4j', function() {
}
});

var featureFiles = 'https://s3-eu-west-1.amazonaws.com/remoting.neotechnology.com/driver-compliance/tck.tar.gz';
var featureHome = './build/tck';

gulp.task('download-tck', function() {
return download(featureFiles)
.pipe(decompress({strip: 1}))
.pipe(gulp.dest(featureHome));
});

gulp.task('run-tck', ['download-tck', 'nodejs'], function() {
return gulp.src(featureHome + "/*").pipe(cucumber({
'steps': 'test/v1/tck/steps/*.js',
'format': 'pretty',
'tags' : "~@in_dev"
}));
});

var runPowershell = function( cmd ) {
var spawn = childProcess.spawn, child;
child = spawn("powershell.exe",[
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"gulp-babel": "^5.2.1",
"gulp-batch": "^1.0.5",
"gulp-concat": "^2.6.0",
"gulp-cucumber": "^0.0.12",
"gulp-cucumber": "0.0.14",
"gulp-decompress": "^1.2.0",
"gulp-download": "^0.0.1",
"gulp-if": "^1.2.5",
Expand Down
10 changes: 4 additions & 6 deletions src/v1/integer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// 64-bit Integer library, originally from Long.js by dcodeIO
// https://github.com/dcodeIO/Long.js
// License Apache 2
Expand Down Expand Up @@ -94,7 +94,7 @@ class Integer {
if (this.isZero())
return '0';
var rem;
if (this.isNegative()) {
if (this.isNegative()) {
if (this.equals(Integer.MIN_VALUE)) {
// We need to change the Integer value before it can be negated, so we remove
// the bottom-most digit in this base and then recurse to do the rest.
Expand Down Expand Up @@ -162,7 +162,7 @@ class Integer {
*/
isZero() {
return this.high === 0 && this.low === 0;
}
}

/**
* Tests if this Integer's value is negative.
Expand Down Expand Up @@ -205,8 +205,6 @@ class Integer {
equals(other) {
if (!Integer.isInteger(other))
other = Integer.fromValue(other);
if ((this.high >>> 31) === 1 && (other.high >>> 31) === 1)
return false;
return this.high === other.high && this.low === other.low;
}

Expand Down Expand Up @@ -821,4 +819,4 @@ export default {
Integer,
int,
isInt
}
}
38 changes: 19 additions & 19 deletions src/v1/internal/buf.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,50 +57,50 @@ class BaseBuffer
* @param p
*/
getInt16 (p) {
return this.getInt8(p) << 8
| this.getUInt8(p + 1) & 0xFF;
return this.getInt8(p) << 8
| this.getUInt8(p + 1);
}

/**
* @param p
*/
getUInt16 (p) {
return this.getUInt8(p) << 8
| this.getUInt8(p + 1) & 0xFF;
return this.getUInt8(p) << 8
| this.getUInt8(p + 1);
}

/**
* @param p
*/
getInt32 (p) {
return this.getInt8(p) << 24
| this.getUInt8(p + 1) << 16 & 0xFF
| this.getUInt8(p + 2) << 8 & 0xFF
| this.getUInt8(p + 3) & 0xFF;
return this.getInt8(p) << 24
| this.getUInt8(p + 1) << 16
| this.getUInt8(p + 2) << 8
| this.getUInt8(p + 3);
}

/**
* @param p
*/
getUInt32 (p) {
return this.getUInt8(p) << 24
| this.getUInt8(p + 1) << 16 & 0xFF
| this.getUInt8(p + 2) << 8 & 0xFF
| this.getUInt8(p + 3) & 0xFF;
| this.getUInt8(p + 1) << 16
| this.getUInt8(p + 2) << 8
| this.getUInt8(p + 3);
}

/**
* @param p
*/
getInt64 (p) {
return this.getInt8(p) << 56
| this.getUInt8(p + 1) << 48 & 0xFF
| this.getUInt8(p + 2) << 40 & 0xFF
| this.getUInt8(p + 3) << 32 & 0xFF
| this.getUInt8(p + 4) << 24 & 0xFF
| this.getUInt8(p + 5) << 16 & 0xFF
| this.getUInt8(p + 6) << 8 & 0xFF
| this.getUInt8(p + 7) & 0xFF;
| this.getUInt8(p + 1) << 48
| this.getUInt8(p + 2) << 40
| this.getUInt8(p + 3) << 32
| this.getUInt8(p + 4) << 24
| this.getUInt8(p + 5) << 16
| this.getUInt8(p + 6) << 8
| this.getUInt8(p + 7);
}

/**
Expand All @@ -119,7 +119,7 @@ class BaseBuffer
*/
putInt16 ( p, val ) {
this.putInt8( p, val >> 8 );
this.putUInt8( p + 1, val & 0xFF );
this.putUInt8( p + 1, val & 0xFF );
}

/**
Expand Down
51 changes: 51 additions & 0 deletions src/v1/internal/ch-dummy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {CombinedBuffer} from './buf';
const observer = {
instance: null,
updateInstance: (instance) => {
observer.instance = instance
}
}

class DummyChannel {
constructor(opts) {
this.written = [];
}
write( buf ) {
this.written.push(buf);
observer.updateInstance(this);
}
toHex() {
var out = "";
for( var i=0; i<this.written.length; i++ ) {
out += this.written[i].toHex();
}
return out;
}
toBuffer () {
return new CombinedBuffer( this.written );
}
}

export default {
channel: DummyChannel,
observer: observer
}
6 changes: 4 additions & 2 deletions src/v1/internal/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ class Connection {
* Crete new connection to the provided url.
* @access private
* @param {string} url - 'neo4j'-prefixed URL to Neo4j Bolt endpoint
* @param {Channel} channel - Optionally inject Channel to be used.
* @return {Connection} - New connection
*/
function connect( url ) {
return new Connection( new Channel({
function connect( url, channel = null) {
channel = channel || Channel;
return new Connection( new channel({
host: host(url),
port: port(url)
}));
Expand Down
56 changes: 28 additions & 28 deletions src/v1/internal/packstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ class Structure {
for (var i = 0; i < this.fields.length; i++) {
if(i > 0) { fieldStr+=", " }
fieldStr += this.fields[i];
};

var util = require('util')
console.log(util.inspect(this));

}
return "Structure(" + this.signature + ", [" + this.fields + "])"
}
}
Expand Down Expand Up @@ -128,25 +124,26 @@ class Packer {
var high = x.high,
low = x.low;

this._ch.writeUInt8(INT_64);
this._ch.writeUInt32( high );
this._ch.writeUInt32( low );
// TODO Use the branches below to sort out most efficient packed format
// if (-0x10 <= x && x < 0x80) {
// this._ch.writeUInt8(x);
// } else if (-0x80 <= x && x < -0x10) {
// this._ch.writeUInt8(INT_8);
// this._ch.writeUInt8(x);
// } else if (-0x8000 <= x && x < 0x8000) {
// this._ch.writeUInt8(INT_16);
// this._ch.writeInt16(x);
// } else if (-0x80000000 <= x && x < 0x80000000) {
// this._ch.writeUInt8(INT_32);
// this._ch.writeInt32(x);
// } else {
//
// }

if (x.greaterThanOrEqual(-0x10) && x.lessThan(0x80)) {
this._ch.writeInt8(low);
}
else if (x.greaterThanOrEqual(-0x80) && x.lessThan(-0x10)) {
this._ch.writeUInt8(INT_8);
this._ch.writeInt8(low);
}
else if (x.greaterThanOrEqual(-0x8000) && x.lessThan(0x8000)) {
this._ch.writeUInt8(INT_16);
this._ch.writeInt16(low);
}
else if (x.greaterThanOrEqual(-0x80000000) && x.lessThan(0x80000000)) {
this._ch.writeUInt8(INT_32);
this._ch.writeInt32(low);
}
else {
this._ch.writeUInt8(INT_64);
this._ch.writeInt32(high);
this._ch.writeInt32(low);
}
}

packFloat(x) {
Expand All @@ -171,7 +168,7 @@ class Packer {
this._ch.writeBytes(bytes);
} else if (size < 0x100000000) {
this._ch.writeUInt8(STRING_32);
this._ch.writeUInt8((size/16777216>>0)%256); // TODO: Why is it shifting by 0 here?
this._ch.writeUInt8((size/16777216>>0)%256);
this._ch.writeUInt8((size/65536>>0)%256);
this._ch.writeUInt8((size/256>>0)%256);
this._ch.writeUInt8(size%256);
Expand All @@ -188,7 +185,9 @@ class Packer {
this._ch.writeUInt8(LIST_8)
this._ch.writeUInt8(size);
} else if (size < 0x10000) {
this._ch.writeUInt8(LIST_16, size/256>>0, size%256);
this._ch.writeUInt8(LIST_16);
this._ch.writeUInt8((size/256>>0)%256);
this._ch.writeUInt8(size%256);
} else if (size < 0x100000000) {
this._ch.writeUInt8(LIST_32);
this._ch.writeUInt8((size/16777216>>0)%256);
Expand Down Expand Up @@ -301,10 +300,11 @@ class Unpacker {
} else if (marker == INT_16) {
return int(buffer.readInt16());
} else if (marker == INT_32) {
return int(buffer.readInt32());
let b = buffer.readInt32();
return int(b);
} else if (marker == INT_64) {
let high = buffer.readInt32();
let low = buffer.readUInt32();
let low = buffer.readInt32();
return new Integer( low, high );
} else if (marker == STRING_8) {
return utf8.decode( buffer, buffer.readUInt8());
Expand Down
Loading