Skip to content

Commit b820128

Browse files
authored
Merge pull request #460 from ali-ince/1.7-add-neo4j-scheme
Add neo4j scheme as a direct alias for bolt+routing
2 parents fa9f543 + d86c307 commit b820128

File tree

4 files changed

+39
-31
lines changed

4 files changed

+39
-31
lines changed

src/v1/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ const logging = {
227227
function driver(url, authToken, config = {}) {
228228
assertString(url, 'Bolt URL');
229229
const parsedUrl = urlUtil.parseDatabaseUrl(url);
230-
if (parsedUrl.scheme === 'bolt+routing') {
230+
if (['bolt+routing', 'neo4j'].indexOf(parsedUrl.scheme) !== -1) {
231231
return new RoutingDriver(ServerAddress.fromUrl(parsedUrl.hostAndPort), parsedUrl.query, USER_AGENT, authToken, config);
232232
} else if (parsedUrl.scheme === 'bolt') {
233233
if (!isEmptyObjectOrNull(parsedUrl.query)) {

test/internal/node/routing.driver.boltkit.test.js

+36-28
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,14 @@ describe('routing driver with stub server', () => {
3939
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
4040
});
4141

42-
it('should discover servers', done => {
43-
if (!boltStub.supported) {
44-
done();
45-
return;
46-
}
47-
// Given
48-
const server = boltStub.start('./test/resources/boltstub/discover_servers_and_read.script', 9001);
49-
50-
boltStub.run(() => {
51-
const driver = boltStub.newDriver('bolt+routing://127.0.0.1:9001');
52-
// When
53-
const session = driver.session();
54-
session.run("MATCH (n) RETURN n.name").then(() => {
55-
56-
session.close();
57-
// Then
58-
expect(hasAddressInConnectionPool(driver, '127.0.0.1:9001')).toBeTruthy();
59-
assertHasRouters(driver, ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]);
60-
assertHasReaders(driver, ["127.0.0.1:9002", "127.0.0.1:9003"]);
61-
assertHasWriters(driver, ["127.0.0.1:9001"]);
62-
63-
driver.close();
64-
server.exit(code => {
65-
expect(code).toEqual(0);
66-
done();
67-
});
68-
});
69-
});
42+
it('should discover servers with bolt+routing scheme', done => {
43+
testDiscovery('bolt+routing', done)
7044
});
7145

46+
it('should discover servers with neo4j scheme', done => {
47+
testDiscovery('neo4j', done)
48+
})
49+
7250
it('should discover IPv6 servers', done => {
7351
if (!boltStub.supported) {
7452
done();
@@ -2168,6 +2146,36 @@ describe('routing driver with stub server', () => {
21682146
});
21692147
});
21702148

2149+
function testDiscovery(scheme, done) {
2150+
if (!boltStub.supported) {
2151+
done()
2152+
return
2153+
}
2154+
// Given
2155+
const server = boltStub.start('./test/resources/boltstub/discover_servers_and_read.script', 9001)
2156+
2157+
boltStub.run(() => {
2158+
const driver = boltStub.newDriver(`${scheme}://127.0.0.1:9001`)
2159+
// When
2160+
const session = driver.session()
2161+
session.run('MATCH (n) RETURN n.name').then(() => {
2162+
2163+
session.close()
2164+
// Then
2165+
expect(hasAddressInConnectionPool(driver, '127.0.0.1:9001')).toBeTruthy()
2166+
assertHasRouters(driver, ['127.0.0.1:9001', '127.0.0.1:9002', '127.0.0.1:9003'])
2167+
assertHasReaders(driver, ['127.0.0.1:9002', '127.0.0.1:9003'])
2168+
assertHasWriters(driver, ['127.0.0.1:9001'])
2169+
2170+
driver.close()
2171+
server.exit(code => {
2172+
expect(code).toEqual(0)
2173+
done()
2174+
})
2175+
})
2176+
})
2177+
}
2178+
21712179
function testAddressPurgeOnDatabaseError(query, accessMode, done) {
21722180
if (!boltStub.supported) {
21732181
done();

test/internal/url-util.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ describe('url-util', () => {
724724
});
725725

726726
it('should parse URLs with port 80', () => {
727-
['http', 'https', 'ws', 'wss', 'bolt', 'bolt+routing'].forEach(scheme => {
727+
['http', 'https', 'ws', 'wss', 'bolt', 'bolt+routing', 'neo4j'].forEach(scheme => {
728728
verifyUrl(`${scheme}://localhost:80`, {
729729
scheme: scheme,
730730
host: 'localhost',

test/v1/stress.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ describe('stress tests', () => {
299299
}
300300

301301
function verifyServers(context) {
302-
const routing = DATABASE_URI.indexOf('bolt+routing') === 0;
302+
const routing = DATABASE_URI.indexOf('bolt+routing') === 0 || DATABASE_URI.indexOf('neo4j') === 0
303303

304304
if (routing) {
305305
return verifyCausalClusterMembers(context);

0 commit comments

Comments
 (0)