@@ -792,11 +792,11 @@ describe('71. lobBind1.js', function() {
792
792
793
793
} ) ; // 71.1.8
794
794
795
- it ( '71.1.9 Negative: BIND_INOUT, PL/SQL, String as bind IN Value' , function ( done ) {
795
+ it ( '71.1.9 BIND_INOUT, PL/SQL, a String as the bind IN Value' , function ( done ) {
796
796
797
797
var seq = 9 ;
798
- var inStr = "I love the sunshine today!" ,
799
- outStr = "A new day has come." ;
798
+ var inStr = "I love the sunshine today!" ;
799
+ var outStr = "A new day has come." ;
800
800
801
801
var proc = "CREATE OR REPLACE PROCEDURE nodb_proc_clob_inout3 \n" +
802
802
" (p_num IN NUMBER, p_inout IN OUT CLOB) \n" +
@@ -820,11 +820,26 @@ describe('71. lobBind1.js', function() {
820
820
io : { val : inStr , type : oracledb . CLOB , dir : oracledb . BIND_INOUT }
821
821
} ,
822
822
{ autoCommit : true } ,
823
- function ( err ) {
824
- should . exist ( err ) ;
825
- // NJS-011: encountered bind value and type mismatch in parameter 2
826
- ( err . message ) . should . startWith ( 'NJS-011:' ) ;
827
- cb ( ) ;
823
+ function ( err , result ) {
824
+ should . not . exist ( err ) ;
825
+ should . exist ( result ) ;
826
+ var lobout = result . outBinds . io ;
827
+
828
+ lobout . setEncoding ( "utf8" ) ;
829
+ var clobData = '' ;
830
+
831
+ lobout . on ( 'data' , function ( chunk ) {
832
+ clobData += chunk ;
833
+ } ) ;
834
+
835
+ lobout . on ( 'error' , function ( err ) {
836
+ should . not . exist ( err , "lob.on 'error' event!" ) ;
837
+ } ) ;
838
+
839
+ lobout . on ( 'end' , function ( ) {
840
+ should . strictEqual ( clobData , outStr ) ;
841
+ return cb ( ) ;
842
+ } ) ;
828
843
}
829
844
) ;
830
845
} ,
@@ -1541,7 +1556,7 @@ describe('71. lobBind1.js', function() {
1541
1556
1542
1557
} ) ; // 71.2.8
1543
1558
1544
- it ( '71.2.9 Negative: BIND_INOUT, PL/SQL, Buffer as bind IN value' , function ( done ) {
1559
+ it ( '71.2.9 BIND_INOUT, PL/SQL, a Buffer as the bind IN value' , function ( done ) {
1545
1560
1546
1561
var seq = 9 ;
1547
1562
var inBuf = assist . createBuffer ( 10 ) ;
@@ -1573,12 +1588,32 @@ describe('71. lobBind1.js', function() {
1573
1588
sql ,
1574
1589
bindvar ,
1575
1590
{ autoCommit : true } ,
1576
- function ( err ) {
1577
- should . exist ( err ) ;
1578
- ( err . message ) . should . startWith ( 'NJS-011:' ) ;
1579
- // NJS-011: encountered bind value and type mismatch in parameter 2
1591
+ function ( err , result ) {
1592
+ should . not . exist ( err ) ;
1593
+ should . exist ( result ) ;
1594
+ var lob = result . outBinds . io ;
1595
+ should . exist ( lob ) ;
1596
+
1597
+ var blobData , totalLength = 0 ;
1598
+ blobData = node6plus ? Buffer . alloc ( 0 ) : new Buffer ( 0 ) ;
1599
+
1600
+ lob . on ( 'data' , function ( chunk ) {
1601
+ totalLength = totalLength + chunk . length ;
1602
+ blobData = Buffer . concat ( [ blobData , chunk ] , totalLength ) ;
1603
+ } ) ;
1604
+
1605
+ lob . on ( 'error' , function ( err ) {
1606
+ should . not . exist ( err , "lob.on 'error' event." ) ;
1607
+ } ) ;
1608
+
1609
+ lob . on ( 'end' , function ( ) {
1610
+ fs . readFile ( jpgFileName , function ( err , originalData ) {
1611
+ should . not . exist ( err ) ;
1612
+ should . strictEqual ( totalLength , originalData . length ) ;
1613
+ return cb ( ) ;
1614
+ } ) ;
1615
+ } ) ;
1580
1616
1581
- cb ( ) ;
1582
1617
}
1583
1618
) ;
1584
1619
} ,
0 commit comments