@@ -241,7 +241,6 @@ describe('185. runCQN.js', function() {
241241
242242 it ( '185.4 Negative - provide invalid SQL in CQN option' , async ( ) => {
243243 try {
244-
245244 const TABLE = 'nodb_tab_cqn_4' ;
246245 const myCallback = async function ( message ) {
247246 console . log ( message ) ;
@@ -369,4 +368,99 @@ describe('185. runCQN.js', function() {
369368 }
370369 } ) ; // 185.6
371370
371+ it ( '185.7 Negative - unsubscribe multiple times' , async ( ) => {
372+ try {
373+ const TABLE = 'nodb_tab_cqn_7' ;
374+ let sql =
375+ `CREATE TABLE ${ TABLE } (
376+ k NUMBER
377+ )` ;
378+ let plsql = testsUtil . sqlCreateTable ( TABLE , sql ) ;
379+ await conn . execute ( plsql ) ;
380+
381+ const myCallback = async function ( message ) {
382+ // console.log(message);
383+ should . strictEqual ( message . registered , true ) ;
384+ } ;
385+
386+ const options = {
387+ callback : myCallback ,
388+ sql : `SELECT * FROM ${ TABLE } WHERE k > :bv` ,
389+ binds : { bv : 100 } ,
390+ timeout : 20 ,
391+ qos : oracledb . SUBSCR_QOS_QUERY | oracledb . SUBSCR_QOS_ROWIDS
392+ } ;
393+
394+ await conn . subscribe ( 'sub7' , options ) ;
395+
396+ sql = `INSERT INTO ${ TABLE } VALUES (101)` ;
397+ await conn . execute ( sql ) ;
398+
399+ plsql = `BEGIN DBMS_SESSION.SLEEP(2); END;` ;
400+ await conn . execute ( plsql ) ;
401+ await conn . commit ( ) ;
402+
403+ await conn . unsubscribe ( 'sub7' ) ;
404+
405+ sql = `DROP TABLE ${ TABLE } PURGE` ;
406+ await conn . execute ( sql ) ;
407+
408+ await assert . rejects (
409+ async ( ) => {
410+ await conn . unsubscribe ( 'sub7' ) ;
411+ } ,
412+ / N J S - 0 6 1 /
413+ ) ;
414+ // NJS-061: invalid subscription
415+ } catch ( err ) {
416+ should . not . exist ( err ) ;
417+ }
418+
419+ } ) ; // 185.7
420+
421+ it ( '185.8 Negative - unsubscribe nonexistent subscriptions' , async ( ) => {
422+ try {
423+ await assert . rejects (
424+ async ( ) => {
425+ await conn . unsubscribe ( 'nonexist' ) ;
426+ } ,
427+ / N J S - 0 6 1 /
428+ ) ;
429+ // NJS-061: invalid subscription
430+ } catch ( err ) {
431+ should . not . exist ( err ) ;
432+ }
433+ } ) ; // 185.8
434+
435+ // An variation of 185.4
436+ it ( '185.9 Negative - unsubscribe the subscription which throwed error when subscribed' , async ( ) => {
437+ try {
438+ const TABLE = 'nodb_tab_cqn_9' ;
439+ const myCallback = async function ( message ) {
440+ console . log ( message ) ;
441+ } ;
442+
443+ const options = {
444+ callback : myCallback ,
445+ sql : `DELETE FROM ${ TABLE } WHERE k > :bv` ,
446+ binds : { bv : 100 } ,
447+ timeout : 20 ,
448+ qos : oracledb . SUBSCR_QOS_QUERY
449+ } ;
450+
451+ await assert . rejects (
452+ async ( ) => {
453+ await conn . subscribe ( 'sub9' , options ) ;
454+ } ,
455+ / D P I - 1 0 1 3 /
456+ ) ;
457+ // DPI-1013: not supported
458+
459+ conn . unsubscribe ( 'sub9' ) ;
460+
461+ } catch ( err ) {
462+ should . not . exist ( err ) ;
463+ }
464+ } ) ; // 185.9
465+
372466} ) ;
0 commit comments