Skip to content

Commit bfa79ae

Browse files
committed
Update AQ dequeue tests
1 parent 0d0b453 commit bfa79ae

File tree

3 files changed

+44
-94
lines changed

3 files changed

+44
-94
lines changed

test/aq2.js

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const oracledb = require('oracledb');
2929
const should = require('should');
3030
const dbconfig = require('./dbconfig.js');
3131
const testsUtil = require('./testsUtil.js');
32+
const assert = require('assert');
3233

3334
describe('218. aq2.js', function() {
3435

@@ -179,34 +180,23 @@ describe('218. aq2.js', function() {
179180
}
180181
}); // 218.3
181182

182-
it.skip('218.4 getQueue() without options on DB Object data', async () => {
183+
it('218.4 Negative - getQueue() without options on DB Object data', async () => {
183184
try {
184185
const addrData = {
185186
NAME: "Changjie",
186187
ADDRESS: "200 Oracle Parkway Redwood City, CA US 94065"
187188
};
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);
196-
// const message = new queue1.payloadTypeClass(addrData);
197-
await queue1.enqOne(message);
198-
await conn.commit();
199-
200-
// Dequeue
201-
const queue2 = await conn.getQueue(
202-
objQueueName,
203-
//{ payloadType: objType }
189+
await assert.rejects(
190+
async () => {
191+
const queue1 = await conn.getQueue(objQueueName);
192+
const objClass = await conn.getDbObjectClass(objType);
193+
const message = new objClass(addrData);
194+
await queue1.enqOne(message);
195+
},
196+
/DPI-1071/
204197
);
205-
const msg = await queue2.deqOne();
206-
await conn.commit();
207-
should.exist(msg);
208-
should.strictEqual(msg.payload.NAME, addrData.NAME);
209-
should.strictEqual(msg.payload.ADDRESS, addrData.ADDRESS);
198+
// DPI-1071: payload type in message properties must match
199+
// the payload type of the queue
210200
} catch (err) {
211201
should.not.exist(err);
212202
}
@@ -274,34 +264,26 @@ describe('218. aq2.js', function() {
274264
}); // 218.6
275265

276266
// A variation of 218.4
277-
it.skip('218.7 Set payloadType as oracledb.DB_TYPE_OBJECT', async () => {
267+
it('218.7 Negative - Set payloadType as oracledb.DB_TYPE_OBJECT', async () => {
278268
try {
279269
const addrData = {
280270
NAME: "Changjie",
281271
ADDRESS: "200 Oracle Parkway Redwood City, CA US 94065"
282272
};
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 }
273+
await assert.rejects(
274+
async () => {
275+
const queue1 = await conn.getQueue(
276+
objQueueName,
277+
{ payloadType: oracledb.DB_TYPE_OBJECT }
278+
);
279+
const objClass = await conn.getDbObjectClass(objType);
280+
const message = new objClass(addrData);
281+
await queue1.enqOne(message);
282+
},
283+
{
284+
message: 'NJS-007: invalid value for "payloadType" in parameter 2'
285+
}
299286
);
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);
305287
} catch (err) {
306288
should.not.exist(err);
307289
}

test/aq3.js

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -230,51 +230,4 @@ describe('219. aq3.js', function() {
230230
}
231231
}); // 219.7
232232

233-
it.skip('219.8 getQueue() with options on RAW data', async () => {
234-
try {
235-
// Enqueue
236-
const queue1 = await conn.getQueue(
237-
rawQueueName,
238-
{ payloadType: oracledb.DB_TYPE_RAW }
239-
);
240-
const messageString = 'The default value of payloadType is "oracledb.DB_TYPE_RAW"';
241-
await queue1.enqOne(messageString);
242-
await conn.commit();
243-
244-
// Dequeue
245-
const queue2 = await conn.getQueue(rawQueueName);
246-
const msg = await queue2.deqOne();
247-
await conn.commit();
248-
249-
should.exist(msg);
250-
should.strictEqual(msg.payload.toString(), messageString);
251-
252-
} catch (err) {
253-
should.not.exist(err);
254-
}
255-
}); // 219.8
256-
257-
it.skip('219.9 Negative - getQueue() with invalid payloadType option', async () => {
258-
try {
259-
// Enqueue
260-
const queue1 = await conn.getQueue(
261-
rawQueueName,
262-
{ payloadType: oracledb.DB_TYPE_OBJECT }
263-
);
264-
const messageString = 'The default value of payloadType is "oracledb.DB_TYPE_RAW"';
265-
await queue1.enqOne(messageString);
266-
await conn.commit();
267-
268-
// Dequeue
269-
const queue2 = await conn.getQueue(rawQueueName);
270-
const msg = await queue2.deqOne();
271-
await conn.commit();
272-
273-
should.exist(msg);
274-
should.strictEqual(msg.payload.toString(), messageString);
275-
276-
} catch (err) {
277-
should.not.exist(err);
278-
}
279-
}); // 219.9
280-
});
233+
});

test/list.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,5 +4596,20 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
45964596
217.2 examples/aqoptions.js
45974597
217.3 examples/aqmulti.js
45984598

4599-
218. aq2.js
4600-
218.1 examples/aqobject.js
4599+
218. aq2.js
4600+
218.1 examples/aqobject.js
4601+
- 218.2 The read-only property "payloadTypeClass"
4602+
218.3 Negative - enqueue a raw JavaScript object directly
4603+
218.4 Negative - getQueue() without options on DB Object data
4604+
218.5 Enqueue a DB object as payload attribute
4605+
218.6 Enqueue a JavaScript object as payload attribute
4606+
218.7 Negative - Set payloadType as oracledb.DB_TYPE_OBJECT
4607+
4608+
219. aq3.js
4609+
219.1 The read-only property "name" of AqQueue Class
4610+
- 219.2 The read-only property "payloadType"
4611+
- 219.3 The read-only property "payloadTypeName"
4612+
219.4 Negative - Set "maxMessages" argument to be -5
4613+
219.5 Negative - Set "maxMessages" argument to be 0
4614+
219.6 Enqueue a Buffer
4615+
219.7 enqMany() mixes enqueuing string and buffer

0 commit comments

Comments
 (0)