@@ -152,7 +152,7 @@ describe('218. aq2.js', function() {
152152 }
153153 } ) ; // 218.2
154154
155- it . skip ( '218.3 Enqueue a JSON ' , async ( ) => {
155+ it ( '218.3 Negative - enqueue a raw JavaScript object directly ' , async ( ) => {
156156 try {
157157 const addrData = {
158158 NAME : "John Smith" ,
@@ -164,14 +164,43 @@ describe('218. aq2.js', function() {
164164 objQueueName ,
165165 { payloadType : objType }
166166 ) ;
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 ) ;
167196 // const message = new queue1.payloadTypeClass(addrData);
168- await queue1 . enqOne ( addrData ) ;
197+ await queue1 . enqOne ( message ) ;
169198 await conn . commit ( ) ;
170199
171200 // Dequeue
172201 const queue2 = await conn . getQueue (
173202 objQueueName ,
174- { payloadType : objType }
203+ // { payloadType: objType }
175204 ) ;
176205 const msg = await queue2 . deqOne ( ) ;
177206 await conn . commit ( ) ;
@@ -181,30 +210,28 @@ describe('218. aq2.js', function() {
181210 } catch ( err ) {
182211 should . not . exist ( err ) ;
183212 }
184- } ) ; // 218.3
213+ } ) ; // 218.4
185214
186- it . skip ( '218.4 getQueue() without options ' , async ( ) => {
215+ it . skip ( '218.5 Enqueue a DB object as payload attribute ' , async ( ) => {
187216 try {
188217 const addrData = {
189218 NAME : "Changjie" ,
190- ADDRESS : "200 Oracle Parkway Redwood City, CA US 94065"
219+ ADDRESS : "400 Oracle Parkway Redwood City, CA US 94065"
191220 } ;
192221
193222 // Enqueue
194223 const queue1 = await conn . getQueue (
195224 objQueueName ,
196- // { payloadType: objType }
225+ { payloadType : objType }
197226 ) ;
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 } ) ;
202229 await conn . commit ( ) ;
203230
204231 // Dequeue
205232 const queue2 = await conn . getQueue (
206233 objQueueName ,
207- // { payloadType: objType }
234+ { payloadType : objType }
208235 ) ;
209236 const msg = await queue2 . deqOne ( ) ;
210237 await conn . commit ( ) ;
@@ -214,5 +241,35 @@ describe('218. aq2.js', function() {
214241 } catch ( err ) {
215242 should . not . exist ( err ) ;
216243 }
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
218275} ) ;
0 commit comments