|
1 | 1 | create or replace package body test_annot_throws_exception |
2 | 2 | is |
3 | 3 | g_tests_results clob; |
| 4 | + g_results_other_schema clob; |
4 | 5 |
|
5 | 6 | procedure recollect_tests_results is |
6 | 7 | pragma autonomous_transaction; |
|
25 | 26 | e_some_exception exception; |
26 | 27 | pragma exception_init(e_some_exception, -20207); |
27 | 28 |
|
28 | | - end;]'; |
| 29 | + end; |
| 30 | + ]'; |
29 | 31 |
|
30 | | - l_package_spec := ' |
31 | | - create package annotated_package_with_throws is |
| 32 | + l_package_spec := q'[ |
| 33 | + create or replace package annotated_package_with_throws is |
| 34 | + |
| 35 | + c_local_error_no constant number := -20211; |
| 36 | + e_some_local_exception exception; |
| 37 | + pragma exception_init(e_some_local_exception, -20212); |
| 38 | + |
32 | 39 | --%suite(Dummy package to test annotation throws) |
33 | 40 |
|
34 | 41 | --%test(Throws same annotated exception) |
|
95 | 102 | --%throws(exc_pkg.c_e_mix_missin,utter_rubbish) |
96 | 103 | procedure mixed_list_notexi; |
97 | 104 |
|
| 105 | + --%test(Success referencing an exception variable when running from another schema) |
| 106 | + --%throws(exc_pkg.e_some_exception) |
| 107 | + procedure named_exc_pragma_run_from_another_schema; |
| 108 | + |
| 109 | + --%test(Success referencing a numeric exception variable when running from another schema) |
| 110 | + --%throws(exc_pkg.c_e_list_1) |
| 111 | + procedure exc_number_var_run_from_another_schema; |
| 112 | + |
| 113 | + --%test(Success referencing an exception variable without package name when running from another schema) |
| 114 | + --%throws(e_some_local_exception) |
| 115 | + procedure named_exc_pragma_run_from_another_schema_no_package_name; |
| 116 | + |
| 117 | + --%test(Success referencing a numeric exception variable without package name when running from another schema) |
| 118 | + --%throws(c_local_error_no) |
| 119 | + procedure exc_number_var_run_from_another_schema_no_package_name; |
| 120 | + |
98 | 121 | --%test(Success resolve and match named exception defined in pragma exception init) |
99 | 122 | --%throws(exc_pkg.e_some_exception) |
100 | 123 | procedure named_exc_pragma; |
|
123 | 146 | --%throws(exc_pkg.c_e_dummy); |
124 | 147 | procedure bad_exc_const; |
125 | 148 | end; |
126 | | - '; |
| 149 | + ]'; |
127 | 150 |
|
128 | 151 | l_package_body := ' |
129 | | - create package body annotated_package_with_throws is |
| 152 | + create or replace package body annotated_package_with_throws is |
130 | 153 | procedure raised_same_exception is |
131 | 154 | begin |
132 | 155 | raise_application_error(-20145, ''Test error''); |
|
208 | 231 | raise_application_error(exc_pkg.c_e_mix_missin,''Test''); |
209 | 232 | end; |
210 | 233 |
|
| 234 | + procedure named_exc_pragma_run_from_another_schema is |
| 235 | + begin |
| 236 | + raise exc_pkg.e_some_exception; |
| 237 | + end; |
| 238 | + |
| 239 | + procedure exc_number_var_run_from_another_schema is |
| 240 | + begin |
| 241 | + raise_application_error(exc_pkg.c_e_list_1,''Test''); |
| 242 | + end; |
| 243 | + |
| 244 | + procedure named_exc_pragma_run_from_another_schema_no_package_name is |
| 245 | + begin |
| 246 | + raise e_some_local_exception; |
| 247 | + end; |
| 248 | + |
| 249 | + procedure exc_number_var_run_from_another_schema_no_package_name is |
| 250 | + begin |
| 251 | + raise_application_error(c_local_error_no,''Test''); |
| 252 | + end; |
| 253 | + |
211 | 254 | procedure named_exc_pragma is |
212 | 255 | begin |
213 | 256 | raise exc_pkg.e_some_exception; |
|
312 | 355 |
|
313 | 356 | procedure one_valid_exception_number is |
314 | 357 | begin |
315 | | - ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[\.0-9]+ sec\]\s*$','m'); |
| 358 | + ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[,\.0-9]+ sec\]\s*$','m'); |
316 | 359 | ut.expect(g_tests_results).to_match('one_valid_exception_number\s*Invalid parameter value ".*" for "--%throws" annotation. Parameter ignored.','m'); |
317 | 360 | end; |
318 | 361 |
|
|
357 | 400 | ut.expect(g_tests_results).to_match('^\s*Success resolve and match named exception defined in pragma exception init \[[,\.0-9]+ sec\]\s*$','m'); |
358 | 401 | ut.expect(g_tests_results).not_to_match('named_exc_pragma'); |
359 | 402 | end; |
360 | | - |
| 403 | + |
| 404 | + procedure run_from_another_schema is |
| 405 | + begin |
| 406 | + ut3_tester_helper.run_helper.run(('ut3_tester.annotated_package_with_throws')); |
| 407 | + g_results_other_schema := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); |
| 408 | + end; |
| 409 | + |
| 410 | + procedure named_exc_pragma_run_from_another_schema is |
| 411 | + begin |
| 412 | + ut.expect(g_results_other_schema).to_match('^\s*Success referencing an exception variable when running from another schema \[[,\.0-9]+ sec\]\s*$','m'); |
| 413 | + ut.expect(g_results_other_schema).not_to_match('named_exc_pragma_run_from_another_schema'); |
| 414 | + end; |
| 415 | + |
| 416 | + procedure named_exc_pragma_run_from_another_schema_no_package_name is |
| 417 | + begin |
| 418 | + ut.expect(g_results_other_schema).to_match('^\s*Success referencing an exception variable without package name when running from another schema \[[,\.0-9]+ sec\]\s*$','m'); |
| 419 | + ut.expect(g_results_other_schema).not_to_match('named_exc_pragma_run_from_another_schema_no_package_name'); |
| 420 | + end; |
| 421 | + |
| 422 | + procedure exc_number_var_run_from_another_schema_no_package_name is |
| 423 | + begin |
| 424 | + ut.expect(g_results_other_schema).to_match('^\s*Success referencing a numeric exception variable without package name when running from another schema \[[,\.0-9]+ sec\]\s*$','m'); |
| 425 | + ut.expect(g_results_other_schema).not_to_match('exc_number_var_run_from_another_schema_no_package_name'); |
| 426 | + end; |
| 427 | + |
| 428 | + procedure exc_number_var_run_from_another_schema is |
| 429 | + begin |
| 430 | + ut.expect(g_results_other_schema).to_match('^\s*Success referencing a numeric exception variable when running from another schema \[[,\.0-9]+ sec\]\s*$','m'); |
| 431 | + ut.expect(g_results_other_schema).not_to_match('exc_number_var_run_from_another_schema'); |
| 432 | + end; |
| 433 | + |
361 | 434 | procedure named_exc_ora is |
362 | 435 | begin |
363 | 436 | ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception \[[,\.0-9]+ sec\]\s*$','m'); |
|
0 commit comments