Skip to content

Commit aba9467

Browse files
committed
LOB test portability changes
1 parent 2e77b9b commit aba9467

File tree

3 files changed

+13
-336
lines changed

3 files changed

+13
-336
lines changed

test/dataTypeClob.js

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* 51 onwards are for other tests
3737
*
3838
*****************************************************************************/
39-
"use strict"
39+
"use strict";
4040

4141
var oracledb = require('oracledb');
4242
var fs = require('fs');
@@ -222,45 +222,6 @@ describe('40. dataTypeClob.js', function() {
222222

223223
}) // 40.1.1
224224

225-
it('40.1.2 catches Error event correctly', function(done) {
226-
var lobErrorEvent = false;
227-
setTimeout( function() {
228-
lobErrorEvent.should.equal(true, "LOB should catch the 'error' event!");
229-
done();
230-
}, 1000);
231-
232-
connection.execute(
233-
"INSERT INTO oracledb_myclobs (num, content) VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv",
234-
{ n: 2, lobbv: {type: oracledb.CLOB, dir: oracledb.BIND_OUT} },
235-
{ autoCommit: true },
236-
function(err, result) {
237-
should.not.exist(err);
238-
(result.rowsAffected).should.be.exactly(1);
239-
(result.outBinds.lobbv.length).should.be.exactly(1);
240-
241-
var inStream = fs.createReadStream(inFileName);
242-
var lob = result.outBinds.lobbv[0];
243-
244-
lob.on('error', function(err) {
245-
should.exist(err, "lob.on 'error' event");
246-
(err.message).should.startWith('ORA-22990');
247-
// ORA-22990: LOB locators cannot span transactions
248-
lobErrorEvent = true;
249-
});
250-
251-
inStream.on('error', function(err) {
252-
should.not.exist(err, "inStream.on 'error' event");
253-
});
254-
255-
inStream.on('end', function() {
256-
connection.commit( function(err) {
257-
should.not.exist(err);
258-
});
259-
});
260-
inStream.pipe(lob);
261-
}
262-
);
263-
})
264225
}) // 40.1
265226

266227
describe('40.2 stores null value correctly', function() {

test/list.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@
374374
40. dataTypeClob.js
375375
40.1 testing CLOB data type
376376
40.1.1 stores CLOB value correctly
377-
40.1.2 catches Error event correctly
378377
40.2 stores null value correctly
379378
40.2.1 testing Null, Empty string and Undefined
380379

@@ -489,17 +488,8 @@
489488
58.3.4 action (write-only)
490489
58.3.5 module (write-only)
491490
58.3.6 oracleServerVersion (read-only)
492-
58.4 Lob Class
493-
58.4.1 chunkSize (read-only)
494-
58.4.2 length (read-only)
495-
58.4.3 pieceSize - default value is chunkSize
496-
58.4.4 pieceSize - can be increased
497-
58.4.5 pieceSize - can be decreased
498-
58.4.6 pieceSize - can be zero
499-
58.4.6 pieceSize - cannot be less than zero
500-
58.4.7 type (read-only)
501-
58.5 ResultSet Class
502-
58.5.1 metaData (read-only)
491+
58.4 ResultSet Class
492+
58.4.1 metaData (read-only)
503493

504494
59. lobResultSet.js
505495
59.1 CLOB data
@@ -509,4 +499,11 @@
509499
60.1 PL/SQL OUT CLOB parameters can also be bound as STRING
510500
60.2 The returned length is limited to the maximum size
511501

512-
61.
502+
61. checkClassesTypes.js
503+
61.1 Oracledb class
504+
61.2 Connection class
505+
61.3 Lob Class
506+
507+
62. lobProperties.js
508+
509+
63. lobErrorEvent.js

test/properties.js

Lines changed: 2 additions & 283 deletions
Original file line numberDiff line numberDiff line change
@@ -398,288 +398,7 @@ describe('58. properties.js', function() {
398398

399399
}) // 58.3
400400

401-
describe('58.4 Lob Class', function() {
402-
403-
var connection = null;
404-
var clobTableName = "oracledb_myclobs";
405-
var blobTableName = "oracledb_myblobs";
406-
var clob = null,
407-
blob = null;
408-
var defaultValues = {};
409-
410-
beforeEach('prepare CLOB/BLOB tables', function(done) {
411-
async.series([
412-
function(cb) {
413-
oracledb.getConnection(credential, function(err, conn) {
414-
should.not.exist(err);
415-
connection = conn;
416-
cb();
417-
});
418-
},
419-
function(cb) {
420-
assist.createTable(connection, clobTableName, cb);
421-
},
422-
function(cb) {
423-
assist.createTable(connection, blobTableName, cb);
424-
},
425-
function insertClobData(cb) {
426-
427-
var sql = "INSERT INTO " + clobTableName +
428-
" VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv";
429-
var id = 1;
430-
var bindVar = { n: id, lobbv: { type: oracledb.CLOB, dir: oracledb.BIND_OUT } };
431-
var inFileName = './test/clobexample.txt';
432-
433-
insertLob(sql, bindVar, inFileName, cb);
434-
},
435-
function insertBlobData(cb) {
436-
437-
var sql = "INSERT INTO " + blobTableName +
438-
" VALUES(:n, EMPTY_BLOB()) RETURNING content INTO :lobbv";
439-
var id = 1;
440-
var bindVar = { n: id, lobbv: { type: oracledb.BLOB, dir: oracledb.BIND_OUT } };
441-
var inFileName = './test/fuzzydinosaur.jpg';
442-
443-
insertLob(sql, bindVar, inFileName, cb);
444-
},
445-
function getClobData(cb) {
446-
getLob(clobTableName, cb);
447-
},
448-
function getBlobData(cb) {
449-
getLob(blobTableName, cb);
450-
},
451-
function keepOriginalValue(cb) {
452-
defaultValues.chunkSize = clob.chunkSize;
453-
cb();
454-
}
455-
], done);
456-
}) // before
457-
458-
afterEach('drop tables, release connection', function(done) {
459-
async.series([
460-
function(cb) {
461-
clob.pieceSize = defaultValues.chunkSize;
462-
blob.pieceSize = defaultValues.chunkSize;
463-
cb();
464-
},
465-
function(cb) {
466-
dropTable(clobTableName, cb);
467-
},
468-
function(cb) {
469-
dropTable(blobTableName, cb);
470-
},
471-
function(cb) {
472-
connection.release( function(err) {
473-
should.not.exist(err);
474-
cb();
475-
});
476-
}
477-
], done);
478-
}) // after
479-
480-
481-
it('58.4.1 chunkSize (read-only)', function() {
482-
var t1 = clob.chunkSize,
483-
t2 = blob.chunkSize;
484-
485-
t1.should.be.a.Number;
486-
t2.should.be.a.Number;
487-
t1.should.eql(defaultValues.chunkSize);
488-
t1.should.eql(t2);
489-
490-
try {
491-
clob.chunkSize = t1 + 1;
492-
} catch(err) {
493-
should.exist(err);
494-
// console.log(err.message);
495-
// Cannot assign to read only property 'chunkSize' of #<Lob>
496-
}
497-
498-
try {
499-
blob.chunkSize = t2 + 1;
500-
} catch(err) {
501-
should.exist(err);
502-
// console.log(err.message);
503-
// Cannot assign to read only property 'chunkSize' of #<Lob>
504-
}
505-
}) // 58.4.1
506-
507-
it('58.4.2 length (read-only)', function() {
508-
var t1 = clob.length,
509-
t2 = blob.length;
510-
511-
t1.should.be.a.Number;
512-
t2.should.be.a.Number;
513-
514-
t1.should.not.eql(t2);
515-
516-
try {
517-
clob.length = t1 + 1;
518-
} catch(err) {
519-
should.exist(err);
520-
//console.log(err.message);
521-
// Cannot set property length of #<Lob> which has only a getter
522-
}
523-
524-
try {
525-
blob.length = t2 + 1;
526-
} catch(err) {
527-
should.exist(err);
528-
//console.log(err.message);
529-
// Cannot set property length of #<Lob> which has only a getter
530-
}
531-
532-
})
533-
534-
it('58.4.3 pieceSize - default value is chunkSize', function() {
535-
var t1 = clob.pieceSize,
536-
t2 = blob.pieceSize;
537-
538-
t1.should.eql(defaultValues.chunkSize);
539-
t2.should.eql(defaultValues.chunkSize);
540-
})
541-
542-
it('58.4.4 pieceSize - can be increased', function() {
543-
var defaultChunkSize = defaultValues.chunkSize;
544-
var incresedVal = defaultChunkSize * 5;
545-
546-
clob.pieceSize *= 5;
547-
blob.pieceSize *= 5;
548-
(clob.pieceSize).should.eql(incresedVal);
549-
(blob.pieceSize).should.eql(incresedVal);
550-
})
551-
552-
it('58.4.5 pieceSize - can be decreased', function() {
553-
var defaultChunkSize = defaultValues.chunkSize;
554-
555-
defaultChunkSize.should.greaterThan(500);
556-
var decreaseVal = defaultChunkSize - 500;
557-
558-
clob.pieceSize -= 500;
559-
blob.pieceSize -= 500;
560-
(clob.pieceSize).should.eql(decreaseVal);
561-
(blob.pieceSize).should.eql(decreaseVal);
562-
})
563-
564-
it('58.4.6 pieceSize - can be zero', function() {
565-
clob.pieceSize = 0;
566-
blob.pieceSize = 0;
567-
568-
(clob.pieceSize).should.eql(0);
569-
(blob.pieceSize).should.eql(0);
570-
})
571-
572-
it('58.4.6 pieceSize - cannot be less than zero', function() {
573-
try {
574-
clob.pieceSize = -100;
575-
} catch(err) {
576-
should.exist(err);
577-
(err.message).should.startWith('NJS-004');
578-
// NJS-004: invalid value for property pieceSize
579-
}
580-
581-
try {
582-
blob.pieceSize = -100;
583-
} catch(err) {
584-
should.exist(err);
585-
(err.message).should.startWith('NJS-004');
586-
// NJS-004: invalid value for property pieceSize
587-
}
588-
})
589-
590-
it('58.4.7 type (read-only)', function() {
591-
var t1 = clob.type,
592-
t2 = blob.type;
593-
594-
t1.should.eql(oracledb.CLOB);
595-
t2.should.eql(oracledb.BLOB);
596-
597-
try {
598-
clob.type = t2;
599-
} catch(err) {
600-
should.exist(err);
601-
// console.log(err);
602-
// [TypeError: Cannot set property type of #<Lob> which has only a getter]
603-
}
604-
605-
try {
606-
blob.type = t1;
607-
} catch(err) {
608-
should.exist(err);
609-
// console.log(err);
610-
// [TypeError: Cannot set property type of #<Lob> which has only a getter]
611-
}
612-
})
613-
614-
function getLob(tableName, cb)
615-
{
616-
connection.execute(
617-
"SELECT content FROM " + tableName + " WHERE num = : id",
618-
{ id: 1 },
619-
function(err, result) {
620-
should.not.exist(err);
621-
var lob = result.rows[0][0];
622-
should.exist(lob);
623-
624-
if (tableName == clobTableName) {
625-
clob = lob;
626-
// console.log("Get clob data");
627-
} else if (tableName == blobTableName) {
628-
blob = lob;
629-
// console.log("Get blob data");
630-
} else {
631-
console.log("passing wrong table name.");
632-
}
633-
634-
cb();
635-
}
636-
);
637-
}
638-
639-
function dropTable(tableName, cb)
640-
{
641-
connection.execute(
642-
"DROP TABLE " + tableName,
643-
function(err) {
644-
should.not.exist(err);
645-
cb();
646-
}
647-
);
648-
}
649-
650-
function insertLob(sql, bindVar, inFileName, cb)
651-
{
652-
connection.execute(
653-
sql,
654-
bindVar,
655-
function(err, result) {
656-
should.not.exist(err);
657-
var lob = result.outBinds.lobbv[0];
658-
var inStream = fs.createReadStream(inFileName);
659-
660-
inStream.on('end', function() {
661-
connection.commit( function(err) {
662-
should.not.exist(err);
663-
cb();
664-
});
665-
});
666-
667-
inStream.on('error', function(err) {
668-
should.not.exist(err);
669-
});
670-
671-
lob.on('error', function(err) {
672-
should.not.exist(err);
673-
});
674-
675-
inStream.pipe(lob);
676-
}
677-
);
678-
}
679-
680-
}) // 58.4
681-
682-
describe('58.5 ResultSet Class', function() {
401+
describe('58.4 ResultSet Class', function() {
683402

684403
var tableName = "oracledb_number";
685404
var numbers = assist.data.numbers;
@@ -727,7 +446,7 @@ describe('58. properties.js', function() {
727446
);
728447
})
729448

730-
it('58.5.1 metaData (read-only)', function() {
449+
it('58.4.1 metaData (read-only)', function() {
731450
should.exist(resultSet.metaData);
732451
var t = resultSet.metaData;
733452
t.should.eql( [ { name: 'NUM' }, { name: 'CONTENT' } ] );

0 commit comments

Comments
 (0)