2018-02-09 16:51:13 +08:00
|
|
|
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* You may not use the identified files except in compliance with the Apache
|
|
|
|
* License, Version 2.0 (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.
|
|
|
|
*
|
2016-03-24 14:09:53 +08:00
|
|
|
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
|
2015-09-25 16:46:56 +08:00
|
|
|
* See LICENSE.md for relevant licenses.
|
|
|
|
*
|
|
|
|
* NAME
|
|
|
|
* 58. properties.js
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Testing getters and setters for oracledb and pool classes.
|
|
|
|
* This test aims to increase the code coverage rate.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2016-03-24 14:31:19 +08:00
|
|
|
'use strict';
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
var oracledb = require('oracledb');
|
2016-02-29 10:19:26 +08:00
|
|
|
var should = require('should');
|
|
|
|
var async = require('async');
|
|
|
|
var dbConfig = require('./dbconfig.js');
|
2015-11-15 05:56:07 +08:00
|
|
|
var assist = require('./dataTypeAssist.js');
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
describe('58. properties.js', function() {
|
|
|
|
|
2015-11-15 05:56:07 +08:00
|
|
|
describe('58.1 Oracledb Class', function() {
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2015-09-25 16:46:56 +08:00
|
|
|
var defaultValues = {};
|
|
|
|
|
|
|
|
before('save the default values', function() {
|
2017-06-14 09:54:15 +08:00
|
|
|
defaultValues.poolMin = oracledb.poolMin;
|
|
|
|
defaultValues.poolMax = oracledb.poolMax;
|
|
|
|
defaultValues.poolIncrement = oracledb.poolIncrement;
|
|
|
|
defaultValues.poolTimeout = oracledb.poolTimeout;
|
|
|
|
defaultValues.maxRows = oracledb.maxRows;
|
2017-12-12 06:56:12 +08:00
|
|
|
defaultValues.fetchArraySize = oracledb.fetchArraySize;
|
2017-06-14 09:54:15 +08:00
|
|
|
defaultValues.autoCommit = oracledb.autoCommit;
|
|
|
|
defaultValues.connectionClass = oracledb.connectionClass;
|
|
|
|
defaultValues.externalAuth = oracledb.externalAuth;
|
|
|
|
defaultValues.fetchAsString = oracledb.fetchAsString;
|
|
|
|
defaultValues.outFormat = oracledb.outFormat;
|
|
|
|
defaultValues.lobPrefetchSize = oracledb.lobPrefetchSize;
|
|
|
|
defaultValues.queueRequests = oracledb.queueRequests;
|
|
|
|
defaultValues.queueTimeout = oracledb.queueTimeout;
|
|
|
|
defaultValues.stmtCacheSize = oracledb.stmtCacheSize;
|
|
|
|
defaultValues.poolPingInterval = oracledb.poolPingInterval;
|
|
|
|
defaultValues.fetchAsBuffer = oracledb.fetchAsBuffer;
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
after('restore the values', function() {
|
2016-03-24 14:09:53 +08:00
|
|
|
oracledb.poolMin = defaultValues.poolMin;
|
|
|
|
oracledb.poolMax = defaultValues.poolMax;
|
|
|
|
oracledb.poolIncrement = defaultValues.poolIncrement;
|
|
|
|
oracledb.poolTimeout = defaultValues.poolTimeout;
|
|
|
|
oracledb.maxRows = defaultValues.maxRows;
|
2017-12-12 06:56:12 +08:00
|
|
|
oracledb.fetchArraySize = defaultValues.fetchArraySize;
|
2016-03-24 14:09:53 +08:00
|
|
|
oracledb.autoCommit = defaultValues.autoCommit;
|
2017-06-14 08:13:17 +08:00
|
|
|
oracledb.connectionClass = defaultValues.connectionClass;
|
2016-03-24 14:09:53 +08:00
|
|
|
oracledb.externalAuth = defaultValues.externalAuth;
|
|
|
|
oracledb.fetchAsString = defaultValues.fetchAsString;
|
|
|
|
oracledb.outFormat = defaultValues.outFormat;
|
2015-09-25 16:46:56 +08:00
|
|
|
oracledb.lobPrefetchSize = defaultValues.lobPrefetchSize;
|
2016-05-16 07:23:00 +08:00
|
|
|
oracledb.queueRequests = defaultValues.queueRequests;
|
|
|
|
oracledb.queueTimeout = defaultValues.queueTimeout;
|
|
|
|
oracledb.stmtCacheSize = defaultValues.stmtCacheSize;
|
2017-06-14 09:54:15 +08:00
|
|
|
oracledb.poolPingInterval = defaultValues.poolPingInterval;
|
|
|
|
oracledb.fetchAsBuffer = defaultValues.fetchAsBuffer;
|
|
|
|
});
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2015-09-25 16:46:56 +08:00
|
|
|
it('58.1.1 poolMin', function() {
|
|
|
|
var t = oracledb.poolMin;
|
|
|
|
oracledb.poolMin = t + 1;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.poolMin);
|
|
|
|
(oracledb.poolMin).should.eql(defaultValues.poolMin + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.2 poolMax', function() {
|
|
|
|
var t = oracledb.poolMax;
|
|
|
|
oracledb.poolMax = t + 1;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.poolMax);
|
|
|
|
(oracledb.poolMax).should.eql(defaultValues.poolMax + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.3 poolIncrement', function() {
|
|
|
|
var t = oracledb.poolIncrement;
|
|
|
|
oracledb.poolIncrement = t + 1;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.poolIncrement);
|
|
|
|
(oracledb.poolIncrement).should.eql(defaultValues.poolIncrement + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.4 poolTimeout', function() {
|
|
|
|
var t = oracledb.poolTimeout;
|
|
|
|
oracledb.poolTimeout = t + 1;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.poolTimeout);
|
|
|
|
(oracledb.poolTimeout).should.eql(defaultValues.poolTimeout + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.5 maxRows', function() {
|
|
|
|
var t = oracledb.maxRows;
|
|
|
|
oracledb.maxRows = t + 1;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.maxRows);
|
|
|
|
(oracledb.maxRows).should.eql(defaultValues.maxRows + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-12-12 06:56:12 +08:00
|
|
|
it('58.1.6 fetchArraySize', function() {
|
|
|
|
var t = oracledb.fetchArraySize;
|
|
|
|
oracledb.fetchArraySize = t + 1;
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-12-12 06:56:12 +08:00
|
|
|
t.should.eql(defaultValues.fetchArraySize);
|
|
|
|
(oracledb.fetchArraySize).should.eql(defaultValues.fetchArraySize + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.7 autoCommit', function() {
|
|
|
|
var t = oracledb.autoCommit;
|
|
|
|
oracledb.autoCommit = !t;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.autoCommit);
|
|
|
|
(oracledb.autoCommit).should.eql( !defaultValues.autoCommit );
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-10-15 09:49:10 +08:00
|
|
|
it('58.1.8 version (read-only)', function() {
|
2017-06-14 06:38:08 +08:00
|
|
|
(oracledb.version).should.be.a.Number();
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.version = 5;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
it('58.1.9 connectionClass', function() {
|
|
|
|
var t = oracledb.connectionClass;
|
|
|
|
oracledb.connectionClass = 'DEVPOOL';
|
|
|
|
var cclass = oracledb.connectionClass;
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.equal(t, '');
|
|
|
|
should.strictEqual(cclass, 'DEVPOOL');
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.10 externalAuth', function() {
|
|
|
|
var t = oracledb.externalAuth;
|
|
|
|
oracledb.externalAuth = !t;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.externalAuth);
|
|
|
|
(oracledb.externalAuth).should.eql( !defaultValues.externalAuth );
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.11 fetchAsString', function() {
|
|
|
|
var t = oracledb.fetchAsString;
|
|
|
|
oracledb.fetchAsString = [oracledb.DATE];
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.fetchAsString);
|
|
|
|
(oracledb.fetchAsString).should.not.eql(defaultValues.fetchAsString);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.12 outFormat', function() {
|
|
|
|
var t = oracledb.outFormat;
|
|
|
|
oracledb.outFormat = oracledb.OBJECT;
|
|
|
|
|
|
|
|
t.should.eql(oracledb.ARRAY);
|
|
|
|
(oracledb.outFormat).should.not.eql(defaultValues.outFormat);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.1.13 lobPrefetchSize', function() {
|
|
|
|
var t = oracledb.lobPrefetchSize;
|
|
|
|
oracledb.lobPrefetchSize = t + 1;
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.lobPrefetchSize);
|
|
|
|
(oracledb.lobPrefetchSize).should.eql(defaultValues.lobPrefetchSize + 1);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-10-15 09:46:20 +08:00
|
|
|
|
2015-10-15 09:49:10 +08:00
|
|
|
it('58.1.14 oracleClientVersion (read-only)', function () {
|
2018-02-06 10:18:24 +08:00
|
|
|
var t = oracledb.oracleClientVersion;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-10-15 09:49:10 +08:00
|
|
|
|
2017-06-14 08:13:17 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.oracleClientVersion = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2015-10-15 09:46:20 +08:00
|
|
|
|
2016-05-16 07:23:00 +08:00
|
|
|
it('58.1.15 queueRequests', function() {
|
|
|
|
var t = oracledb.queueRequests;
|
|
|
|
oracledb.queueRequests = false;
|
|
|
|
|
|
|
|
should.equal(t, true);
|
|
|
|
should.notEqual(t, oracledb.queueRequests);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
|
|
|
it('58.1.16 queueTimeout', function() {
|
|
|
|
var t = oracledb.queueTimeout;
|
|
|
|
oracledb.queueTimeout = t + 1000;
|
|
|
|
|
|
|
|
should.equal(t, defaultValues.queueTimeout);
|
|
|
|
should.notEqual(oracledb.queueTimeout, defaultValues.queueTimeout);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
|
|
|
it('58.1.17 stmtCacheSize', function() {
|
|
|
|
var t = oracledb.stmtCacheSize;
|
|
|
|
oracledb.stmtCacheSize = t + 5;
|
|
|
|
|
|
|
|
should.equal(t, defaultValues.stmtCacheSize);
|
|
|
|
should.notEqual(oracledb.stmtCacheSize, defaultValues.stmtCacheSize);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('58.1.18 poolPingInterval', function() {
|
|
|
|
var t = oracledb.poolPingInterval;
|
|
|
|
oracledb.poolPingInterval = t + 100;
|
|
|
|
|
|
|
|
should.equal(t, defaultValues.poolPingInterval);
|
|
|
|
should.notEqual(oracledb.poolPingInterval, defaultValues.poolPingInterval);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('58.1.19 fetchAsBuffer', function() {
|
|
|
|
var t = oracledb.fetchAsBuffer;
|
|
|
|
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
|
|
|
|
|
|
|
|
t.should.eql(defaultValues.fetchAsBuffer);
|
|
|
|
(oracledb.fetchAsBuffer).should.not.eql(defaultValues.fetchAsBuffer);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('58.1.20 Negative - connectionClass ', function() {
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.connectionClass = NaN;
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('58.1.21 Negative - autoCommit', function() {
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.autoCommit = 2017;
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('58.1.22 Negative - outFormat', function() {
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.outFormat = 'abc';
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-06-29 14:16:01 +08:00
|
|
|
it('58.1.23 Negative - externalAuth', function() {
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.externalAuth = 2017;
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2018-02-06 10:18:24 +08:00
|
|
|
it('58.1.24 versionString (read-only)', function() {
|
|
|
|
var t = oracledb.versionString;
|
|
|
|
t.should.be.a.String();
|
|
|
|
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.versionString = t + "foobar";
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('58.1.25 versionSuffix (read-only)', function() {
|
|
|
|
var t = oracledb.versionSuffix;
|
|
|
|
|
|
|
|
if (t) // it could be a String, or undefined
|
|
|
|
t.should.be.a.String();
|
|
|
|
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.versionSuffix = t + "foobar";
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2018-03-27 13:01:20 +08:00
|
|
|
it('58.1.26 oracleClientVersionString (read-only)', function () {
|
|
|
|
var t = oracledb.oracleClientVersionString;
|
|
|
|
t.should.be.a.String();
|
|
|
|
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
oracledb.oracleClientVersion = t + "foobar";
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
}); // 58.1
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-11-15 05:56:07 +08:00
|
|
|
describe('58.2 Pool Class', function() {
|
2015-09-25 16:46:56 +08:00
|
|
|
var pool = null;
|
|
|
|
|
|
|
|
before(function(done) {
|
|
|
|
oracledb.createPool(
|
2017-06-14 09:54:15 +08:00
|
|
|
{
|
|
|
|
user: dbConfig.user,
|
|
|
|
password: dbConfig.password,
|
|
|
|
connectString: dbConfig.connectString
|
|
|
|
},
|
2015-09-25 16:46:56 +08:00
|
|
|
function(err, p) {
|
|
|
|
should.not.exist(err);
|
|
|
|
pool = p;
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
after(function(done) {
|
|
|
|
pool.terminate(function(err) {
|
|
|
|
should.not.exist(err);
|
|
|
|
done();
|
|
|
|
});
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.2.1 poolMin', function() {
|
|
|
|
var t = pool.poolMin;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.poolMin = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.2.2 poolMax', function() {
|
|
|
|
var t = pool.poolMax;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.poolMax = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.2.3 poolIncrement', function() {
|
|
|
|
var t = pool.poolIncrement;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.poolIncrement = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.2.4 poolTimeout', function() {
|
|
|
|
var t = pool.poolTimeout;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.poolTimeout = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
it('58.2.5 stmtCacheSize', function() {
|
|
|
|
var t = pool.stmtCacheSize;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.stmtCacheSize = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
|
|
|
it('58.2.6 connectionsInUse', function() {
|
|
|
|
var t = pool.connectionsInUse;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.connectionsInUse = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
|
|
|
it('58.2.7 connectionsOpen', function() {
|
|
|
|
var t = pool.connectionsOpen;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.connectionsOpen = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
it('58.2.8 queueRequests', function() {
|
2016-05-16 07:23:00 +08:00
|
|
|
var t = pool.queueRequests;
|
|
|
|
t.should.be.a.Boolean;
|
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.queueRequests = !t;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
it('58.2.9 queueTimeout', function() {
|
2016-05-16 07:23:00 +08:00
|
|
|
var t = pool.queueTimeout;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.queueTimeout = t + 1000;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('58.2.10 poolPingInterval', function() {
|
|
|
|
var t = pool.poolPingInterval;
|
|
|
|
t.should.be.a.Number();
|
|
|
|
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
pool.poolPingInterval = t + 100;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2016-05-16 07:23:00 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
}); // 58.2
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-11-15 05:56:07 +08:00
|
|
|
describe('58.3 Connection Class', function() {
|
2015-09-25 16:46:56 +08:00
|
|
|
var connection = null;
|
|
|
|
|
|
|
|
before('get one connection', function(done) {
|
2017-06-14 09:54:15 +08:00
|
|
|
oracledb.getConnection(
|
|
|
|
{
|
|
|
|
user: dbConfig.user,
|
|
|
|
password: dbConfig.password,
|
|
|
|
connectString: dbConfig.connectString
|
|
|
|
},
|
|
|
|
function(err, conn) {
|
|
|
|
should.not.exist(err);
|
|
|
|
connection = conn;
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
|
|
|
after('release connection', function(done) {
|
|
|
|
connection.release( function(err) {
|
|
|
|
should.not.exist(err);
|
|
|
|
done();
|
|
|
|
});
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-10-15 09:49:10 +08:00
|
|
|
it('58.3.1 Connection object initial toString values', function() {
|
2015-09-25 16:46:56 +08:00
|
|
|
connection.should.be.an.Object;
|
|
|
|
|
|
|
|
should.equal(connection.action, null);
|
|
|
|
should.equal(connection.module, null);
|
|
|
|
should.equal(connection.clientId, null);
|
|
|
|
|
2017-06-14 06:38:08 +08:00
|
|
|
(connection.stmtCacheSize).should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
(connection.stmtCacheSize).should.be.greaterThan(0);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-10-15 09:49:10 +08:00
|
|
|
it('58.3.2 stmtCacheSize (read-only)', function() {
|
2015-09-25 16:46:56 +08:00
|
|
|
var t = connection.stmtCacheSize;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
connection.stmtCacheSize = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-10-15 09:49:10 +08:00
|
|
|
it('58.3.3 clientId (write-only)', function() {
|
2017-06-14 09:54:15 +08:00
|
|
|
var t = connection.clientId;
|
|
|
|
should.strictEqual(t, null);
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
connection.clientId = 4;
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.doesNotThrow(
|
|
|
|
function() {
|
|
|
|
connection.clientId = "103.3";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
it('58.3.4 action (write-only)', function() {
|
|
|
|
var t = connection.action;
|
|
|
|
should.strictEqual(t, null);
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
connection.action = 4;
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.doesNotThrow(
|
|
|
|
function() {
|
|
|
|
connection.action = "103.3 action";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
it('58.3.5 module (write-only)', function() {
|
|
|
|
var t = connection.module;
|
|
|
|
should.strictEqual(t, null);
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
connection.module = 4;
|
|
|
|
},
|
|
|
|
/NJS-004: invalid value for property [\w]/
|
|
|
|
);
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.doesNotThrow(
|
|
|
|
function() {
|
|
|
|
connection.clientId = "103.3 module";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2015-09-25 16:46:56 +08:00
|
|
|
|
2015-10-15 09:49:10 +08:00
|
|
|
it('58.3.6 oracleServerVersion (read-only)', function () {
|
|
|
|
var t = connection.oracleServerVersion;
|
2017-06-14 06:38:08 +08:00
|
|
|
t.should.be.a.Number();
|
2015-10-15 09:49:10 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
connection.oracleServerVersion = t + 1;
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
2015-10-15 09:46:20 +08:00
|
|
|
});
|
|
|
|
|
2018-03-27 13:01:20 +08:00
|
|
|
it('58.3.7 oracleServerVersionString (read-only)', function () {
|
|
|
|
var t = connection.oracleServerVersionString;
|
|
|
|
t.should.be.a.String();
|
|
|
|
|
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
connection.oracleServerVersion = t + "foobar";
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
}); // 58.3
|
2015-11-15 05:56:07 +08:00
|
|
|
|
2015-11-15 06:09:11 +08:00
|
|
|
describe('58.4 ResultSet Class', function() {
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2016-03-24 14:31:19 +08:00
|
|
|
var tableName = "nodb_number";
|
2015-11-15 05:56:07 +08:00
|
|
|
var numbers = assist.data.numbers;
|
|
|
|
var connection = null;
|
|
|
|
var resultSet = null;
|
|
|
|
|
|
|
|
before('get resultSet class', function(done) {
|
|
|
|
async.series([
|
|
|
|
function(callback) {
|
2017-06-14 09:54:15 +08:00
|
|
|
oracledb.getConnection(
|
|
|
|
{
|
|
|
|
user: dbConfig.user,
|
|
|
|
password: dbConfig.password,
|
|
|
|
connectString: dbConfig.connectString
|
|
|
|
},
|
|
|
|
function(err, conn) {
|
|
|
|
should.not.exist(err);
|
|
|
|
connection = conn;
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
);
|
2015-11-15 05:56:07 +08:00
|
|
|
},
|
|
|
|
function(callback) {
|
|
|
|
assist.setUp(connection, tableName, numbers, callback);
|
|
|
|
},
|
|
|
|
function(callback) {
|
|
|
|
connection.execute(
|
2016-07-08 14:58:37 +08:00
|
|
|
"SELECT * FROM " + tableName + " ORDER BY num",
|
2015-11-15 05:56:07 +08:00
|
|
|
[],
|
|
|
|
{ resultSet: true, outFormat: oracledb.OBJECT },
|
|
|
|
function(err, result) {
|
|
|
|
should.not.exist(err);
|
|
|
|
resultSet = result.resultSet;
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
], done);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-11-15 05:56:07 +08:00
|
|
|
|
|
|
|
after( function(done) {
|
|
|
|
connection.execute(
|
2017-06-14 09:54:15 +08:00
|
|
|
"DROP TABLE " + tableName + " PURGE",
|
2015-11-15 05:56:07 +08:00
|
|
|
function(err) {
|
|
|
|
should.not.exist(err);
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2015-11-15 05:56:07 +08:00
|
|
|
connection.release( function(err) {
|
|
|
|
should.not.exist(err);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-11-15 05:56:07 +08:00
|
|
|
|
2017-08-01 12:14:43 +08:00
|
|
|
it('58.4.1 metaData (read-only)', function(done) {
|
2015-11-15 05:56:07 +08:00
|
|
|
should.exist(resultSet.metaData);
|
|
|
|
var t = resultSet.metaData;
|
|
|
|
t.should.eql( [ { name: 'NUM' }, { name: 'CONTENT' } ] );
|
2016-03-24 14:09:53 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
should.throws(
|
|
|
|
function() {
|
|
|
|
resultSet.metaData = {"foo": "bar"};
|
|
|
|
},
|
|
|
|
/NJS-014: [\w]+ is a read-only property/
|
|
|
|
);
|
2017-08-01 12:14:43 +08:00
|
|
|
resultSet.close(done);
|
2017-06-14 09:54:15 +08:00
|
|
|
});
|
2015-11-15 05:56:07 +08:00
|
|
|
|
2017-06-14 09:54:15 +08:00
|
|
|
}); // 58.4
|
|
|
|
});
|