35
35
36
36
var oracledb = require ( 'oracledb' ) ;
37
37
var should = require ( 'should' ) ;
38
- var async = require ( 'async' ) ;
39
38
var dbConfig = require ( './dbconfig.js' ) ;
40
- var assist = require ( './dataTypeAssist.js' ) ;
41
39
42
40
describe ( '52. connClose.js' , function ( ) {
43
41
44
- it ( '52.1 can not set property value after connection closes' , function ( done ) {
42
+ it ( '52.1 can not set property, stmtCacheSize, after connection closes' , function ( done ) {
45
43
oracledb . getConnection (
46
44
dbConfig ,
47
45
function ( err , connection ) {
@@ -63,22 +61,27 @@ describe('52. connClose.js', function() {
63
61
) ;
64
62
} ) ; // 52.1
65
63
66
- it ( '52.2 can not get property value after connection closes' , function ( done ) {
64
+ it ( '52.2 can not set property, clientId, after connection closes' , function ( done ) {
67
65
oracledb . getConnection (
68
66
dbConfig ,
69
67
function ( err , connection ) {
70
68
should . not . exist ( err ) ;
71
69
72
70
connection . release ( function ( err ) {
73
71
should . not . exist ( err ) ;
74
- should . strictEqual ( connection . stmtCacheSize , undefined ) ;
72
+ should . throws (
73
+ function ( ) {
74
+ connection . clientId = "52.3" ;
75
+ } ,
76
+ / N J S - 0 0 3 : i n v a l i d c o n n e c t i o n /
77
+ ) ;
75
78
done ( ) ;
76
79
} ) ;
77
80
}
78
81
) ;
79
82
} ) ; // 52.2
80
83
81
- it ( '52.3 can not set clientId property value ' , function ( done ) {
84
+ it ( '52.3 can not set property, module ' , function ( done ) {
82
85
oracledb . getConnection (
83
86
dbConfig ,
84
87
function ( err , connection ) {
@@ -88,7 +91,7 @@ describe('52. connClose.js', function() {
88
91
should . not . exist ( err ) ;
89
92
should . throws (
90
93
function ( ) {
91
- connection . clientId = "52.3 " ;
94
+ connection . module = "52.4 " ;
92
95
} ,
93
96
/ N J S - 0 0 3 : i n v a l i d c o n n e c t i o n /
94
97
) ;
@@ -98,7 +101,7 @@ describe('52. connClose.js', function() {
98
101
) ;
99
102
} ) ; // 52.3
100
103
101
- it ( '52.4 can not set module property value ' , function ( done ) {
104
+ it ( '52.4 can not set property, action ' , function ( done ) {
102
105
oracledb . getConnection (
103
106
dbConfig ,
104
107
function ( err , connection ) {
@@ -108,7 +111,7 @@ describe('52. connClose.js', function() {
108
111
should . not . exist ( err ) ;
109
112
should . throws (
110
113
function ( ) {
111
- connection . module = "52.4 " ;
114
+ connection . module = "52.5 " ;
112
115
} ,
113
116
/ N J S - 0 0 3 : i n v a l i d c o n n e c t i o n /
114
117
) ;
@@ -118,140 +121,193 @@ describe('52. connClose.js', function() {
118
121
) ;
119
122
} ) ; // 52.4
120
123
121
- it ( '52.5 can not set action property value ' , function ( done ) {
124
+ it ( '52.5 can not call method, execute() ' , function ( done ) {
122
125
oracledb . getConnection (
123
126
dbConfig ,
124
127
function ( err , connection ) {
125
128
should . not . exist ( err ) ;
126
129
127
130
connection . release ( function ( err ) {
128
131
should . not . exist ( err ) ;
129
- should . throws (
130
- function ( ) {
131
- connection . module = "52.5" ;
132
- } ,
133
- / N J S - 0 0 3 : i n v a l i d c o n n e c t i o n /
132
+ connection . execute (
133
+ "select sysdate from dual" ,
134
+ function ( err , result ) {
135
+ should . not . exist ( result ) ;
136
+ should . exist ( err ) ;
137
+ should . strictEqual (
138
+ err . message ,
139
+ "NJS-003: invalid connection"
140
+ ) ;
141
+ done ( ) ;
142
+ }
134
143
) ;
135
- done ( ) ;
136
144
} ) ;
137
145
}
138
146
) ;
139
147
} ) ; // 52.5
140
148
141
- it ( '52.6 can not get oracleServerVersion property value ' , function ( done ) {
149
+ it ( '52.6 can not call method, break() ' , function ( done ) {
142
150
oracledb . getConnection (
143
151
dbConfig ,
144
152
function ( err , connection ) {
145
153
should . not . exist ( err ) ;
146
154
147
155
connection . release ( function ( err ) {
148
156
should . not . exist ( err ) ;
149
- should . strictEqual ( connection . oracleServerVersion , undefined ) ;
150
- done ( ) ;
157
+
158
+ connection . break ( function ( err ) {
159
+ should . exist ( err ) ;
160
+ should . strictEqual (
161
+ err . message ,
162
+ "NJS-003: invalid connection"
163
+ ) ;
164
+ done ( ) ;
165
+ } ) ;
151
166
} ) ;
152
167
}
153
168
) ;
154
169
} ) ; // 52.6
155
170
156
- it ( '52.7 can not call execute() method ' , function ( done ) {
171
+ it ( '52.7 can not call method, commit() ' , function ( done ) {
157
172
oracledb . getConnection (
158
173
dbConfig ,
159
174
function ( err , connection ) {
160
175
should . not . exist ( err ) ;
161
176
162
177
connection . release ( function ( err ) {
163
178
should . not . exist ( err ) ;
164
- connection . execute (
165
- "select sysdate from dual" ,
166
- function ( err , result ) {
167
- should . not . exist ( result ) ;
168
- should . exist ( err ) ;
169
- should . strictEqual (
170
- err . message ,
171
- "NJS-003: invalid connection"
172
- ) ;
173
- done ( ) ;
174
- }
175
- ) ;
179
+
180
+ connection . commit ( function ( err ) {
181
+ should . exist ( err ) ;
182
+ should . strictEqual (
183
+ err . message ,
184
+ "NJS-003: invalid connection"
185
+ ) ;
186
+ done ( ) ;
187
+ } ) ;
176
188
} ) ;
177
189
}
178
190
) ;
179
191
} ) ; // 52.7
180
192
181
- it ( '52.8 can not get metaData property after connection closes' , function ( done ) {
182
- var tableName = "nodb_number" ;
183
- var numbers = assist . data . numbers ;
184
- var connection = null ;
185
- var resultSet = null ;
186
-
187
- async . series ( [
188
- function getConn ( callback ) {
189
- oracledb . getConnection (
190
- dbConfig ,
191
- function ( err , conn ) {
192
- should . not . exist ( err ) ;
193
- connection = conn ;
194
- callback ( ) ;
195
- }
196
- ) ;
197
- } ,
198
- function ( callback ) {
199
- assist . setUp ( connection , tableName , numbers , callback ) ;
200
- } ,
201
- function getResultSet ( callback ) {
202
- connection . execute (
203
- "SELECT * FROM " + tableName + " ORDER BY num" ,
204
- [ ] ,
205
- { resultSet : true , outFormat : oracledb . OBJECT } ,
206
- function ( err , result ) {
207
- should . not . exist ( err ) ;
208
- resultSet = result . resultSet ;
209
- callback ( ) ;
210
- }
211
- ) ;
212
- } ,
213
- function verifyMetaData ( callback ) {
214
- should . exist ( resultSet . metaData ) ;
215
- var t = resultSet . metaData ;
216
- t . should . eql ( [ { name : 'NUM' } , { name : 'CONTENT' } ] ) ;
217
- resultSet . close ( callback ) ;
218
- } ,
219
- function closeConn ( callback ) {
193
+ it ( '52.8 can not call method, createLob()' , function ( done ) {
194
+ oracledb . getConnection (
195
+ dbConfig ,
196
+ function ( err , connection ) {
197
+ should . not . exist ( err ) ;
198
+
220
199
connection . release ( function ( err ) {
221
200
should . not . exist ( err ) ;
222
- callback ( ) ;
201
+
202
+ connection . createLob ( oracledb . CLOB , function ( err , lob ) {
203
+ should . exist ( err ) ;
204
+ should . not . exist ( lob ) ;
205
+ should . strictEqual (
206
+ err . message ,
207
+ "NJS-003: invalid connection"
208
+ ) ;
209
+ done ( ) ;
210
+ } ) ;
223
211
} ) ;
224
- } ,
225
- function getMetaData ( callback ) {
226
- should . strictEqual ( resultSet . metaData , undefined ) ;
227
- callback ( ) ;
228
- } ,
229
- function getConn ( callback ) {
230
- oracledb . getConnection (
231
- dbConfig ,
232
- function ( err , conn ) {
233
- should . not . exist ( err ) ;
234
- connection = conn ;
235
- callback ( ) ;
236
- }
237
- ) ;
238
- } ,
239
- function dropTable ( callback ) {
240
- connection . execute (
241
- "DROP TABLE " + tableName + " PURGE" ,
242
- function ( err ) {
243
- should . not . exist ( err ) ;
244
- callback ( ) ;
245
- }
246
- ) ;
247
- } ,
248
- function closeConn ( callback ) {
212
+ }
213
+ ) ;
214
+ } ) ; // 52.8
215
+
216
+ it ( '52.9 can not call method, queryStream()' , function ( done ) {
217
+ oracledb . getConnection (
218
+ dbConfig ,
219
+ function ( err , connection ) {
220
+ should . not . exist ( err ) ;
221
+
222
+ connection . release ( function ( err ) {
223
+ should . not . exist ( err ) ;
224
+
225
+ var stream = connection . queryStream ( "select sysdate from dual" ) ;
226
+ should . exist ( stream ) ;
227
+
228
+ stream . on ( "data" , function ( data ) {
229
+ should . not . exist ( data ) ;
230
+ } ) ;
231
+
232
+ stream . on ( "end" , function ( ) {
233
+ done ( new Error ( "should not emit 'end' event!" ) ) ;
234
+ } ) ;
235
+
236
+ stream . on ( "error" , function ( err ) {
237
+ should . exist ( err ) ;
238
+ should . strictEqual (
239
+ err . message ,
240
+ "NJS-003: invalid connection"
241
+ ) ;
242
+ done ( ) ;
243
+ } ) ;
244
+ } ) ;
245
+ }
246
+ ) ;
247
+ } ) ; // 52.9
248
+
249
+ it ( '52.10 can not call release() multiple times' , function ( done ) {
250
+ oracledb . getConnection (
251
+ dbConfig ,
252
+ function ( err , connection ) {
253
+ should . not . exist ( err ) ;
254
+
249
255
connection . release ( function ( err ) {
250
256
should . not . exist ( err ) ;
251
- callback ( ) ;
257
+
258
+ connection . release ( function ( err ) {
259
+ should . exist ( err ) ;
260
+ should . strictEqual (
261
+ err . message ,
262
+ "NJS-003: invalid connection"
263
+ ) ;
264
+ done ( ) ;
265
+ } ) ;
252
266
} ) ;
253
- } ,
254
- ] , done ) ;
255
- } ) ;
267
+ }
268
+ ) ;
269
+ } ) ; // 52.10
270
+
271
+ it ( '52.11 can not call method, rollback()' , function ( done ) {
272
+ oracledb . getConnection (
273
+ dbConfig ,
274
+ function ( err , connection ) {
275
+ should . not . exist ( err ) ;
276
+
277
+ connection . release ( function ( err ) {
278
+ should . not . exist ( err ) ;
279
+
280
+ connection . rollback ( function ( err ) {
281
+ should . exist ( err ) ;
282
+ should . strictEqual (
283
+ err . message ,
284
+ "NJS-003: invalid connection"
285
+ ) ;
286
+ done ( ) ;
287
+ } ) ;
288
+ } ) ;
289
+ }
290
+ ) ;
291
+ } ) ; // 52.11
292
+
293
+ it ( "52.12 can access properties of closed connection without error" , function ( done ) {
294
+ oracledb . getConnection (
295
+ dbConfig ,
296
+ function ( err , connection ) {
297
+ should . not . exist ( err ) ;
298
+
299
+ connection . release ( function ( err ) {
300
+ should . not . exist ( err ) ;
301
+
302
+ should . strictEqual ( connection . stmtCacheSize , undefined ) ;
303
+ should . strictEqual ( connection . oracleServerVersion , undefined ) ;
304
+ should . strictEqual ( connection . action , null ) ;
305
+ should . strictEqual ( connection . clientId , null ) ;
306
+ should . strictEqual ( connection . module , null ) ;
307
+ done ( ) ;
308
+ } ) ;
309
+ }
310
+ ) ;
311
+ } ) ; // 52.12
256
312
257
- } ) ;
313
+ } ) ;
0 commit comments