Skip to content

Commit 178305c

Browse files
committed
Add more tests for AQ payloadType option
1 parent 5831209 commit 178305c

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

test/aq2.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('218. aq2.js', function() {
179179
}
180180
}); // 218.3
181181

182-
it.skip('218.4 getQueue() without options', async () => {
182+
it.skip('218.4 getQueue() without options on DB Object data', async () => {
183183
try {
184184
const addrData = {
185185
NAME: "Changjie",
@@ -272,4 +272,38 @@ describe('218. aq2.js', function() {
272272
should.not.exist(err);
273273
}
274274
}); // 218.6
275+
276+
// A variation of 218.4
277+
it.skip('218.7 Set payloadType as oracledb.DB_TYPE_OBJECT', async () => {
278+
try {
279+
const addrData = {
280+
NAME: "Changjie",
281+
ADDRESS: "200 Oracle Parkway Redwood City, CA US 94065"
282+
};
283+
284+
// Enqueue
285+
const queue1 = await conn.getQueue(
286+
objQueueName,
287+
{ payloadType: oracledb.DB_TYPE_OBJECT }
288+
);
289+
const objClass = await conn.getDbObjectClass(objType);
290+
const message = new objClass(addrData);
291+
// const message = new queue1.payloadTypeClass(addrData);
292+
await queue1.enqOne(message);
293+
await conn.commit();
294+
295+
// Dequeue
296+
const queue2 = await conn.getQueue(
297+
objQueueName,
298+
{ payloadType: oracledb.DB_TYPE_OBJECT }
299+
);
300+
const msg = await queue2.deqOne();
301+
await conn.commit();
302+
should.exist(msg);
303+
should.strictEqual(msg.payload.NAME, addrData.NAME);
304+
should.strictEqual(msg.payload.ADDRESS, addrData.ADDRESS);
305+
} catch (err) {
306+
should.not.exist(err);
307+
}
308+
}); // 218.7
275309
});

test/aq3.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,52 @@ describe('219. aq3.js', function() {
223223
should.not.exist(err);
224224
}
225225
}); // 219.7
226+
227+
it.skip('219.8 getQueue() with options on RAW data', async () => {
228+
try {
229+
// Enqueue
230+
const queue1 = await conn.getQueue(
231+
rawQueueName,
232+
{ payloadType: oracledb.DB_TYPE_RAW }
233+
);
234+
const messageString = 'The default value of payloadType is "oracledb.DB_TYPE_RAW"';
235+
await queue1.enqOne(messageString);
236+
await conn.commit();
237+
238+
// Dequeue
239+
const queue2 = await conn.getQueue(rawQueueName);
240+
const msg = await queue2.deqOne();
241+
await conn.commit();
242+
243+
should.exist(msg);
244+
should.strictEqual(msg.payload.toString(), messageString);
245+
246+
} catch (err) {
247+
should.not.exist(err);
248+
}
249+
}); // 219.8
250+
251+
it.skip('219.9 Negative - getQueue() with invalid payloadType option', async () => {
252+
try {
253+
// Enqueue
254+
const queue1 = await conn.getQueue(
255+
rawQueueName,
256+
{ payloadType: oracledb.DB_TYPE_OBJECT }
257+
);
258+
const messageString = 'The default value of payloadType is "oracledb.DB_TYPE_RAW"';
259+
await queue1.enqOne(messageString);
260+
await conn.commit();
261+
262+
// Dequeue
263+
const queue2 = await conn.getQueue(rawQueueName);
264+
const msg = await queue2.deqOne();
265+
await conn.commit();
266+
267+
should.exist(msg);
268+
should.strictEqual(msg.payload.toString(), messageString);
269+
270+
} catch (err) {
271+
should.not.exist(err);
272+
}
273+
}); // 219.9
226274
});

0 commit comments

Comments
 (0)