Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
133ecae
Adding new API user.
lwasylow Mar 22, 2019
9db8f4b
Separating tests.
lwasylow Mar 23, 2019
13f772a
Merge branch 'develop' of github.com:utPLSQL/utPLSQL into feature/int…
lwasylow Mar 24, 2019
c56943e
Update properties
lwasylow Mar 24, 2019
5afba10
Change user that executes tests as helper that is super user.
lwasylow Mar 24, 2019
7cd92e7
Adding next set of tests migrated.
lwasylow Mar 24, 2019
e2561bc
Adding next set of tests migrated.
lwasylow Mar 25, 2019
887e46a
Fixing test package
lwasylow Mar 25, 2019
28dbd1e
Added set of tests:
lwasylow Mar 25, 2019
d7eb125
Adding set of tests :
lwasylow Mar 25, 2019
99e1099
Adding schema prefix to failing tests from 12.1
lwasylow Mar 25, 2019
04cd36c
Fixing development scripts
lwasylow Mar 25, 2019
3e98723
Fixed bug for deployments with uninstall included.
jgebal Mar 25, 2019
ba83f8f
Merge branch 'feature/introduce_testing_with_accurate_grants' of gith…
lwasylow Mar 26, 2019
0bf1d9e
FIX : removal of non existing types from uninstall script
lwasylow Mar 26, 2019
e914d96
INSTALL:Is it too many monkeys ?:)
lwasylow Mar 26, 2019
174dcbc
Adding set of tests:
lwasylow Mar 26, 2019
0c05daf
Adding set of tests:
lwasylow Mar 26, 2019
80783c3
Adding set of tests:
lwasylow Mar 28, 2019
c4b08af
Adding set of tests:
lwasylow Mar 28, 2019
0618616
Adding set of tests:
lwasylow Mar 28, 2019
29295b7
Adding set of tests:
lwasylow Mar 29, 2019
30b0cfe
Adding set of tests:
lwasylow Mar 29, 2019
3cc34ea
Adding tests
lwasylow Mar 29, 2019
a6a848d
Adding tests:
lwasylow Mar 30, 2019
858372c
Adding set of tests:
lwasylow Mar 31, 2019
620fd61
Adding extra tests:
lwasylow Mar 31, 2019
e6b0673
Merge branch 'develop' of github.com:utPLSQL/utPLSQL into feature/int…
lwasylow Mar 31, 2019
c508e79
Adding tests:
lwasylow Apr 1, 2019
858a675
Fixing broken test.
lwasylow Apr 1, 2019
1642f47
Adding test:
lwasylow Apr 1, 2019
30d27fe
Adding global setup
lwasylow Apr 1, 2019
3b07c6a
Merge branch 'develop' of github.com:utPLSQL/utPLSQL into feature/int…
lwasylow Apr 2, 2019
a8dfa14
Merge branch 'develop' of github.com:utPLSQL/utPLSQL into feature/int…
lwasylow Apr 2, 2019
5d3b18c
Update cleanup script after branching from random order branch
lwasylow Apr 2, 2019
b56d27a
Fixed invalid suitepath in `core` package.
jgebal Apr 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding set of tests:
core/annotations/test_annotation_parser
core/annotations/test_annot_throws_exception
core/annotations/test_annotation_manager
  • Loading branch information
lwasylow committed Mar 28, 2019
commit c4b08afaf378ee7b8cfdbe3f1e9272b658b19c22
8 changes: 8 additions & 0 deletions test/install_ut3_tester_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ alter session set plsql_optimize_level=0;
--Install tests
@@ut3_tester/core.pks
@@ut3_tester/core/annotations/test_before_after_annotations.pks
@@ut3_tester/core/annotations/test_annotation_parser.pks
@@ut3_tester/core/annotations/test_annot_throws_exception.pks
@@ut3_tester/core/annotations/test_annotation_manager.pks
@@ut3_tester/core/expectations/test_expectation_processor.pks


@@ut3_tester/core.pkb
@@ut3_tester/core/annotations/test_before_after_annotations.pkb
@@ut3_tester/core/annotations/test_annotation_parser.pkb
@@ut3_tester/core/expectations/test_expectation_processor.pkb
@@ut3_tester/core/annotations/test_annotation_manager.pkb
@@ut3_tester/core/annotations/test_annot_throws_exception.pkb


set linesize 200
set define on
Expand Down
375 changes: 375 additions & 0 deletions test/ut3_tester/core/annotations/test_annot_throws_exception.pkb
Original file line number Diff line number Diff line change
@@ -0,0 +1,375 @@
create or replace package body test_annot_throws_exception
is
g_tests_results clob;

procedure recollect_tests_results is
pragma autonomous_transaction;

l_package_spec varchar2(32737);
l_package_body varchar2(32737);
l_exception_spec varchar2(32737);
l_test_results ut3.ut_varchar2_list;
begin
l_exception_spec := q'[
create or replace package exc_pkg is
c_e_single_exc constant number := -20200;
c_e_dummy constant varchar2(10) := 'dummy';
c_e_varch_exc constant varchar2(10) := '-20201';
c_e_list_1 number := -20202;
c_e_list_2 constant number := -20203;
c_e_diff_exc constant number := -20204;
c_e_mix_list constant number := -20205;
c_e_mix_missin constant number := -20206;

e_some_exception exception;
pragma exception_init(e_some_exception, -20207);

end;]';

l_package_spec := '
create package annotated_package_with_throws is
--%suite(Dummy package to test annotation throws)

--%test(Throws same annotated exception)
--%throws(-20145)
procedure raised_same_exception;

--%test(Throws one of the listed exceptions)
--%throws(-20145,-20146, -20189 ,-20563)
procedure raised_one_listed_exception;

--%test(Leading zero is ignored in exception list)
--%throws(-01476)
procedure leading_0_exception_no;

--%test(Throws diff exception)
--%throws(-20144)
procedure raised_diff_exception;

--%test(Throws empty)
--%throws()
procedure empty_throws;

--%test(Ignores annotation and fails when exception was thrown)
--%throws(hello,784#,0-=234,,u1234)
procedure bad_paramters_with_except;

--%test(Ignores annotation and succeeds when no exception thrown)
--%throws(hello,784#,0-=234,,u1234)
procedure bad_paramters_without_except;

--%test(Detects a valid exception number within many invalid ones)
--%throws(7894562, operaqk, -=1, -1, pow74d, posdfk3)
procedure one_valid_exception_number;

--%test(Gives failure when a exception is expected and nothing is thrown)
--%throws(-20459, -20136, -20145)
procedure nothing_thrown;

--%test(Single exception defined as a constant number in package)
--%throws(exc_pkg.c_e_single_exc)
procedure single_exc_const_pkg;

--%test(Gives success when one of annotated exception using constant is thrown)
--%throws(exc_pkg.c_e_list_1,exc_pkg.c_e_list_2)
procedure list_of_exc_constant;

--%test(Gives failure when the raised exception is different that the annotated one using variable)
--%throws(exc_pkg.c_e_diff_exc)
procedure fail_not_match_exc;

--%test(Success when one of exception from mixed list of number and constant is thrown)
--%throws(exc_pkg.c_e_mix_list,-20105)
procedure mixed_exc_list;

--%test(Success when match exception even if other variable on list dont exists)
--%throws(exc_pkg.c_e_mix_missin,utter_rubbish)
procedure mixed_list_notexi;

--%test(Success resolve and match named exception defined in pragma exception init)
--%throws(exc_pkg.e_some_exception)
procedure named_exc_pragma;

--%test(Success resolve and match oracle named exception)
--%throws(NO_DATA_FOUND)
procedure named_exc_ora;

--%test(Success resolve and match oracle named exception dup val index)
--%throws(DUP_VAL_ON_INDEX)
procedure named_exc_ora_dup_ind;

--%test(Success map no data 100 to -1403)
--%throws(-1403)
procedure nodata_exc_ora;

--%test(Success for exception defined as varchar)
--%throws(exc_pkg.c_e_varch_exc)
procedure defined_varchar_exc;

--%test(Non existing constant exception)
--%throws(dummy.c_dummy);
procedure non_existing_const;

--%test(Bad exception constant)
--%throws(exc_pkg.c_e_dummy);
procedure bad_exc_const;

end;
';

l_package_body := '
create package body annotated_package_with_throws is
procedure raised_same_exception is
begin
raise_application_error(-20145, ''Test error'');
end;

procedure raised_one_listed_exception is
begin
raise_application_error(-20189, ''Test error'');
end;

procedure leading_0_exception_no is
x integer;
begin
x := 1 / 0;
end;

procedure raised_diff_exception is
begin
raise_application_error(-20143, ''Test error'');
end;

procedure empty_throws is
begin
raise_application_error(-20143, ''Test error'');
end;

procedure bad_paramters_with_except is
begin
raise_application_error(-20143, ''Test error'');
end;

procedure bad_paramters_without_except is
begin
null;
end;

procedure one_valid_exception_number is
begin
raise dup_val_on_index;
end;

procedure nothing_thrown is
begin
null;
end;

procedure single_exc_const_pkg is
begin
raise_application_error(exc_pkg.c_e_single_exc,''Test'');
end;

procedure list_of_exc_constant is
begin
raise_application_error(exc_pkg.c_e_list_1,''Test'');
end;

procedure fail_not_match_exc is
begin
raise NO_DATA_FOUND;
end;

procedure mixed_exc_list is
begin
raise_application_error(exc_pkg.c_e_mix_list,''Test'');
end;

procedure mixed_list_notexi is
begin
raise_application_error(exc_pkg.c_e_mix_missin,''Test'');
end;

procedure named_exc_pragma is
begin
raise exc_pkg.e_some_exception;
end;

procedure named_exc_ora is
begin
raise NO_DATA_FOUND;
end;

procedure named_exc_ora_dup_ind is
begin
raise DUP_VAL_ON_INDEX;
end;

procedure nodata_exc_ora is
begin
raise NO_DATA_FOUND;
end;

procedure defined_varchar_exc is
begin
raise_application_error(exc_pkg.c_e_varch_exc,''Test'');
end;

procedure non_existing_const is
begin
raise_application_error(-20143, ''Test error'');
end;

procedure bad_exc_const is
begin
raise_application_error(-20143, ''Test error'');
end;

end;
';

execute immediate l_exception_spec;
execute immediate l_package_spec;
execute immediate l_package_body;


select * bulk collect into l_test_results from table(ut3.ut.run(('annotated_package_with_throws')));

g_tests_results := ut3.ut_utils.table_to_clob(l_test_results);
end;

procedure throws_same_annotated_except is
begin
ut.expect(g_tests_results).to_match('^\s*Throws same annotated exception \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('raised_same_exception');
end;

procedure throws_one_of_annotated_excpt is
begin
ut.expect(g_tests_results).to_match('^\s*Throws one of the listed exceptions \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('raised_one_listed_exception');
end;

procedure throws_with_leading_zero is
begin
ut.expect(g_tests_results).to_match('^\s*Leading zero is ignored in exception list \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('leading_0_exception_no');
end;

procedure throws_diff_annotated_except is
begin
ut.expect(g_tests_results).to_match('^\s*Throws diff exception \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('raised_diff_exception\s+Actual: -20143 was expected to equal: -20144\s+ORA-20143: Test error\s+ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"');
end;

procedure throws_empty is
begin
ut.expect(g_tests_results).to_match('^\s*Throws empty \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('empty_throws\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"');
end;

procedure bad_paramters_with_except is
begin
ut.expect(g_tests_results).to_match('^\s*Ignores annotation and fails when exception was thrown \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('bad_paramters_with_except\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"');
end;

procedure bad_paramters_without_except is
begin
ut.expect(g_tests_results).to_match('^\s*Ignores annotation and succeeds when no exception thrown \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('bad_paramters_without_except');
end;

procedure one_valid_exception_number is
begin
ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('one_valid_exception_number');
end;

procedure nothing_thrown is
begin
ut.expect(g_tests_results).to_match('^\s*Gives failure when a exception is expected and nothing is thrown \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('nothing_thrown\s*Expected one of exceptions \(-20459, -20136, -20145\) but nothing was raised.');
end;

procedure single_exc_const_pkg is
begin
ut.expect(g_tests_results).to_match('^\s*Single exception defined as a constant number in package \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('single_exc_const_pkg');
end;

procedure list_of_exc_constant is
begin
ut.expect(g_tests_results).to_match('^\s*Gives success when one of annotated exception using constant is thrown \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('list_of_exc_constant');
end;

procedure fail_not_match_exc is
begin
ut.expect(g_tests_results).to_match('^\s*Gives failure when the raised exception is different that the annotated one using variable \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('fail_not_match_exc\s+Actual: -1403 was expected to equal: -20204\s+ORA-01403: no data found\s+ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"');
end;

procedure mixed_exc_list is
begin
ut.expect(g_tests_results).to_match('^\s*Success when one of exception from mixed list of number and constant is thrown \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('mixed_exc_list');
end;

procedure mixed_list_notexi is
begin
ut.expect(g_tests_results).to_match('^\s*Success when match exception even if other variable on list dont exists \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('mixed_list_notexi');
end;

procedure named_exc_pragma is
begin
ut.expect(g_tests_results).to_match('^\s*Success resolve and match named exception defined in pragma exception init \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('mixed_list_notexi');
end;

procedure named_exc_ora is
begin
ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('named_exc_ora');
end;

procedure named_exc_ora_dup_ind is
begin
ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception dup val index \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('named_exc_ora_dup_ind');
end;

procedure nodata_exc_ora is
begin
ut.expect(g_tests_results).to_match('^\s*Success map no data 100 to -1403 \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('nodata_exc_ora');
end;

procedure defined_varchar_exc is
begin
ut.expect(g_tests_results).to_match('^\s*Success for exception defined as varchar \[[,\.0-9]+ sec\]\s*$','m');
ut.expect(g_tests_results).not_to_match('defined_varchar_exc');
end;

procedure non_existing_const is
begin
ut.expect(g_tests_results).to_match('^\s*Non existing constant exception \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('non_existing_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"');
end;

procedure bad_exc_const is
begin
ut.expect(g_tests_results).to_match('^\s*Bad exception constant \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m');
ut.expect(g_tests_results).to_match('bad_exc_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"');
end;

procedure drop_test_package is
pragma autonomous_transaction;
begin
execute immediate 'drop package annotated_package_with_throws';
execute immediate 'drop package exc_pkg';
end;

end;
/
Loading