@@ -152,7 +152,7 @@ describe('218. aq2.js', function() {
152
152
}
153
153
} ) ; // 218.2
154
154
155
- it . skip ( '218.3 Enqueue a JSON ' , async ( ) => {
155
+ it ( '218.3 Negative - enqueue a raw JavaScript object directly ' , async ( ) => {
156
156
try {
157
157
const addrData = {
158
158
NAME : "John Smith" ,
@@ -164,14 +164,43 @@ describe('218. aq2.js', function() {
164
164
objQueueName ,
165
165
{ payloadType : objType }
166
166
) ;
167
+ testsUtil . assertThrowsAsync (
168
+ async ( ) => {
169
+ await queue1 . enqOne ( addrData ) ;
170
+ } ,
171
+ / N J S - 0 7 0 /
172
+ ) ;
173
+ /* NJS-070: message must be a string, buffer, database object or
174
+ an object containing a payload property which itself is a string,
175
+ buffer or database object */
176
+
177
+ } catch ( err ) {
178
+ should . not . exist ( err ) ;
179
+ }
180
+ } ) ; // 218.3
181
+
182
+ it . skip ( '218.4 getQueue() without options' , async ( ) => {
183
+ try {
184
+ const addrData = {
185
+ NAME : "Changjie" ,
186
+ ADDRESS : "200 Oracle Parkway Redwood City, CA US 94065"
187
+ } ;
188
+
189
+ // Enqueue
190
+ const queue1 = await conn . getQueue (
191
+ objQueueName ,
192
+ //{ payloadType: objType }
193
+ ) ;
194
+ const objClass = await conn . getDbObjectClass ( objType ) ;
195
+ const message = new objClass ( addrData ) ;
167
196
// const message = new queue1.payloadTypeClass(addrData);
168
- await queue1 . enqOne ( addrData ) ;
197
+ await queue1 . enqOne ( message ) ;
169
198
await conn . commit ( ) ;
170
199
171
200
// Dequeue
172
201
const queue2 = await conn . getQueue (
173
202
objQueueName ,
174
- { payloadType : objType }
203
+ // { payloadType: objType }
175
204
) ;
176
205
const msg = await queue2 . deqOne ( ) ;
177
206
await conn . commit ( ) ;
@@ -181,30 +210,28 @@ describe('218. aq2.js', function() {
181
210
} catch ( err ) {
182
211
should . not . exist ( err ) ;
183
212
}
184
- } ) ; // 218.3
213
+ } ) ; // 218.4
185
214
186
- it . skip ( '218.4 getQueue() without options ' , async ( ) => {
215
+ it . skip ( '218.5 Enqueue a DB object as payload attribute ' , async ( ) => {
187
216
try {
188
217
const addrData = {
189
218
NAME : "Changjie" ,
190
- ADDRESS : "200 Oracle Parkway Redwood City, CA US 94065"
219
+ ADDRESS : "400 Oracle Parkway Redwood City, CA US 94065"
191
220
} ;
192
221
193
222
// Enqueue
194
223
const queue1 = await conn . getQueue (
195
224
objQueueName ,
196
- // { payloadType: objType }
225
+ { payloadType : objType }
197
226
) ;
198
- const objClass = await conn . getDbObjectClass ( objType ) ;
199
- const message = new objClass ( addrData ) ;
200
- // const message = new queue1.payloadTypeClass(addrData);
201
- await queue1 . enqOne ( message ) ;
227
+ const message = new queue1 . payloadTypeClass ( addrData ) ;
228
+ await queue1 . enqOne ( { payload : message } ) ;
202
229
await conn . commit ( ) ;
203
230
204
231
// Dequeue
205
232
const queue2 = await conn . getQueue (
206
233
objQueueName ,
207
- // { payloadType: objType }
234
+ { payloadType : objType }
208
235
) ;
209
236
const msg = await queue2 . deqOne ( ) ;
210
237
await conn . commit ( ) ;
@@ -214,5 +241,35 @@ describe('218. aq2.js', function() {
214
241
} catch ( err ) {
215
242
should . not . exist ( err ) ;
216
243
}
217
- } ) ; // 218.4
244
+ } ) ; // 218.5
245
+
246
+ it . skip ( '218.6 Enqueue a JavaScript object as payload attribute' , async ( ) => {
247
+ try {
248
+ const addrData = {
249
+ NAME : "Chris" ,
250
+ ADDRESS : "400 Oracle Parkway Redwood City, CA US 94065"
251
+ } ;
252
+
253
+ // Enqueue
254
+ const queue1 = await conn . getQueue (
255
+ objQueueName ,
256
+ { payloadType : objType }
257
+ ) ;
258
+ await queue1 . enqOne ( { payload : addrData } ) ;
259
+ await conn . commit ( ) ;
260
+
261
+ // Dequeue
262
+ const queue2 = await conn . getQueue (
263
+ objQueueName ,
264
+ { payloadType : objType }
265
+ ) ;
266
+ const msg = await queue2 . deqOne ( ) ;
267
+ await conn . commit ( ) ;
268
+ should . exist ( msg ) ;
269
+ should . strictEqual ( msg . payload . NAME , addrData . NAME ) ;
270
+ should . strictEqual ( msg . payload . ADDRESS , addrData . ADDRESS ) ;
271
+ } catch ( err ) {
272
+ should . not . exist ( err ) ;
273
+ }
274
+ } ) ; // 218.6
218
275
} ) ;
0 commit comments