1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
//-----------------------------------------------------------------------------
// Copyright (c) 2017, 2025, Oracle and/or its affiliates.
//
// This software is dual-licensed to you under the Universal Permissive License
// (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
// 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
// either license.
//
// If you elect to accept the software under the Apache License, Version 2.0,
// the following applies:
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// test_2600_msg_props.c
// Test suite for testing all the Message Properties related test cases.
//-----------------------------------------------------------------------------
#include "TestLib.h"
//-----------------------------------------------------------------------------
// dpiTest_2600()
// Call dpiConn_newMsgProps(); call dpiMsgProps_release() twice (error
// DPI-1002).
//-----------------------------------------------------------------------------
int dpiTest_2600(dpiTestCase *testCase, dpiTestParams *params)
{
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
dpiMsgProps_release(msgProps);
return dpiTestCase_expectError(testCase, "DPI-1002:");
}
//-----------------------------------------------------------------------------
// dpiTest_2601()
// Call each of the dpiMsgProps public functions with the props parameter set
// to NULL (error DPI-1002).
//-----------------------------------------------------------------------------
int dpiTest_2601(dpiTestCase *testCase, dpiTestParams *params)
{
const char *expectedError = "DPI-1002:";
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
dpiMsgProps_addRef(NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getNumAttempts(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getCorrelation(NULL, NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getDelay(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getDeliveryMode(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getEnqTime(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getExceptionQ(NULL, NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getExpiration(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getOriginalMsgId(NULL, NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getPriority(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_getState(NULL, NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_release(NULL);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_setCorrelation(NULL, NULL, 0);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_setDelay(NULL, 0);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_setExceptionQ(NULL, NULL, 0);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_setExpiration(NULL, 2);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_setOriginalMsgId(NULL, NULL, 0);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
dpiMsgProps_setPriority(NULL, 0);
if (dpiTestCase_expectError(testCase, expectedError) < 0)
return DPI_FAILURE;
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiTest_2602()
// Call dpiConn_newMsgProps(); call dpiMsgProps_setCorrelation(); call
// dpiMsgProps_getCorrelation() and verify that the value returned matches
// the value that was set (no error).
//-----------------------------------------------------------------------------
int dpiTest_2602(dpiTestCase *testCase, dpiTestParams *params)
{
const char *setValue = "_", *getValue;
uint32_t getValueLength;
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_setCorrelation(msgProps, setValue, strlen(setValue)) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_getCorrelation(msgProps, &getValue, &getValueLength) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiTestCase_expectStringEqual(testCase, getValue, getValueLength,
setValue, strlen(setValue)) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiTest_2603()
// Call dpiConn_newMsgProps(); call dpiMsgProps_setDelay(); call
// dpiMsgProps_getDelay() and verify that the value returned matches the
// value that was set (no error).
//-----------------------------------------------------------------------------
int dpiTest_2603(dpiTestCase *testCase, dpiTestParams *params)
{
int32_t setValue = 5, getValue;
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_setDelay(msgProps, setValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_getDelay(msgProps, &getValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiTestCase_expectUintEqual(testCase, getValue, setValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiTest_2604()
// Call dpiConn_newMsgProps(); call dpiMsgProps_setExpiration(); call
// dpiMsgProps_getExpiration() and verify that the value returned matches the
// value that was set (no error).
//-----------------------------------------------------------------------------
int dpiTest_2604(dpiTestCase *testCase, dpiTestParams *params)
{
int32_t setValue = 8, getValue;
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_setExpiration(msgProps, setValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_getExpiration(msgProps, &getValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiTestCase_expectUintEqual(testCase, getValue, setValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiTest_2605()
// Call dpiConn_newMsgProps(); call dpiMsgProps_setPriority(); call
// dpiMsgProps_getPriority() and verify that the value returned matches the
// value that was set (no error).
//-----------------------------------------------------------------------------
int dpiTest_2605(dpiTestCase *testCase, dpiTestParams *params)
{
int32_t setValue = 2, getValue;
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_setPriority(msgProps, setValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_getPriority(msgProps, &getValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiTestCase_expectUintEqual(testCase, getValue, setValue) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiTest_2606()
// Call dpiConn_newMsgProps(); call dpiMsgProps_setOriginalMsgId(); call
// dpiMsgProps_getOriginalMsgId() and verify that the value returned matches
// the value that was set (no error).
//-----------------------------------------------------------------------------
int dpiTest_2606(dpiTestCase *testCase, dpiTestParams *params)
{
const char *setValue = "id1", *getValue;
uint32_t getValueLength;
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_setOriginalMsgId(msgProps, setValue, strlen(setValue)) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_getOriginalMsgId(msgProps, &getValue, &getValueLength) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiTestCase_expectStringEqual(testCase, getValue, getValueLength,
setValue, strlen(setValue)) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiTest_2607()
// call dpiConn_newMsgProps(); call dpiMsgProps_setExceptionQ(); call
// dpiMsgProps_getExceptionQ() and verify that the value returned matches
// the value that was set (no error)
//-----------------------------------------------------------------------------
int dpiTest_2607(dpiTestCase *testCase, dpiTestParams *params)
{
const char *setValue = "excq", *getValue;
uint32_t getValueLength;
dpiMsgProps *msgProps;
dpiConn *conn;
if (dpiTestCase_getConnection(testCase, &conn) < 0)
return DPI_FAILURE;
if (dpiConn_newMsgProps(conn, &msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_setExceptionQ(msgProps, setValue, strlen(setValue)) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_getExceptionQ(msgProps, &getValue, &getValueLength) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiTestCase_expectStringEqual(testCase, getValue, getValueLength,
setValue, strlen(setValue)) < 0)
return dpiTestCase_setFailedFromError(testCase);
if (dpiMsgProps_release(msgProps) < 0)
return dpiTestCase_setFailedFromError(testCase);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// main()
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
dpiTestSuite_initialize(2600);
dpiTestSuite_addCase(dpiTest_2600,
"call dpiMsgProps_release() twice");
dpiTestSuite_addCase(dpiTest_2601,
"call all dpiMsgProps public functions with props param as NULL");
dpiTestSuite_addCase(dpiTest_2602,
"verify correlation is set as expected");
dpiTestSuite_addCase(dpiTest_2603,
"verify delay is set as expected");
dpiTestSuite_addCase(dpiTest_2604,
"verify expiration is set as expected");
dpiTestSuite_addCase(dpiTest_2605,
"verify priority is set as expected");
dpiTestSuite_addCase(dpiTest_2606,
"verify msgId is set as expected");
dpiTestSuite_addCase(dpiTest_2607,
"verify exceptionQ is set as expected");
return dpiTestSuite_run();
}
|