Skip to content

Commit cd394c7

Browse files
committed
Fixed test execution on 12.1.
Added wrapper procedure `purge_cache` in `ut_annotation_manager` Changed tests to use wrapper procedure.
1 parent aafca84 commit cd394c7

9 files changed

Lines changed: 106 additions & 109 deletions

File tree

source/api/ut.pks

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ create or replace package ut authid current_user as
119119
a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
120120
);
121121

122-
/*
123-
Helper procedure to set NLS session parameter for date processing in refcursor.
124-
It needs to be called before refcursor is open in order to have DATE data type data in refcursor
125-
properly transformed into XML format as a date-time element.
126-
If the function is not called before opening a cursor to be compared, the DATE data is compared using default NLS setting for date.
127-
*/
122+
/**
123+
* Helper procedure to set NLS session parameter for date processing in refcursor.
124+
* It needs to be called before refcursor is open in order to have DATE data type data in refcursor
125+
* properly transformed into XML format as a date-time element.
126+
* If the function is not called before opening a cursor to be compared, the DATE data is compared using default NLS setting for date.
127+
*/
128128
procedure set_nls;
129129

130-
/*
131-
Helper procedure to reset NLS session parameter to it's original state.
132-
It needs to be called after refcursor is open in order restore the original session state and keep the NLS date setting at default.
133-
*/
130+
/**
131+
* Helper procedure to reset NLS session parameter to it's original state.
132+
* It needs to be called after refcursor is open in order restore the original session state and keep the NLS date setting at default.
133+
*/
134134
procedure reset_nls;
135135

136136
end ut;

source/core/annotations/ut_annotation_cache_manager.pkb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ create or replace package body ut_annotation_cache_manager as
6262
in (select i.cache_id
6363
from ut_annotation_cache_info i
6464
join table (a_objects) o
65-
using (object_name, object_type, object_owner)
65+
on o.object_name = i.object_name
66+
and o.object_type = i.object_type
67+
and o.object_owner = i.object_owner
6668
);
6769

6870
merge into ut_annotation_cache_info i

source/core/annotations/ut_annotation_manager.pkb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,10 @@ create or replace package body ut_annotation_manager as
208208

209209
end;
210210

211+
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
212+
begin
213+
ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type);
214+
end;
215+
211216
end ut_annotation_manager;
212217
/

source/core/annotations/ut_annotation_manager.pks

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@ create or replace package ut_annotation_manager authid current_user as
4242
*/
4343
procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2);
4444

45+
/**
46+
* Removes cached information about annotations for objects of specified type and specified owner
47+
*
48+
* @param a_object_owner owner of objects to purge annotations for
49+
* @param a_object_type type of objects to purge annotations for
50+
*/
51+
procedure purge_cache(a_object_owner varchar2, a_object_type varchar2);
52+
4553
end ut_annotation_manager;
4654
/

test/annotations/ut_annotation_cache_manager/test_annotation_cache_manager.pkb

Lines changed: 0 additions & 74 deletions
This file was deleted.

test/annotations/ut_annotation_cache_manager/test_annotation_cache_manager.pks

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/install_tests.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ whenever oserror exit failure rollback
1212
@@ut_reporters/test_coveralls_reporter.pks
1313
@ut_expectations/test_expectations_cursor.pks
1414
@@ut_runner/test_ut_runner.pks
15-
@@annotations/ut_annotation_manager/test_annotation_manager.pks
16-
@@annotations/ut_annotation_cache_manager/test_annotation_cache_manager.pks
15+
@@ut_annotation_manager/test_annotation_manager.pks
1716

1817
@core.pkb
1918
@ut_utils/test_ut_utils.pkb
@@ -26,8 +25,7 @@ whenever oserror exit failure rollback
2625
@@ut_reporters/test_coveralls_reporter.pkb
2726
@ut_expectations/test_expectations_cursor.pkb
2827
@@ut_runner/test_ut_runner.pkb
29-
@@annotations/ut_annotation_manager/test_annotation_manager.pkb
30-
@@annotations/ut_annotation_cache_manager/test_annotation_cache_manager.pkb
28+
@@ut_annotation_manager/test_annotation_manager.pkb
3129

3230
set linesize 200
3331
set define on

test/annotations/ut_annotation_manager/test_annotation_manager.pkb renamed to test/ut_annotation_manager/test_annotation_manager.pkb

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,39 @@ create or replace package body test_annotation_manager is
6464
commit;
6565
end;
6666

67+
procedure setup_cache is
68+
pragma autonomous_transaction;
69+
begin
70+
create_dummy_test_package();
71+
execute immediate q'[create or replace procedure dummy_test_procedure as
72+
--%some_annotation(some_text)
73+
--%rollback(manual)
74+
begin
75+
null;
76+
end;]';
77+
execute immediate q'[create or replace procedure ut3.dummy_test_procedure as
78+
--%some_annotation(some_text)
79+
--%rollback(manual)
80+
begin
81+
null;
82+
end;]';
83+
ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE');
84+
ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PROCEDURE');
85+
ut3.ut_annotation_manager.rebuild_annotation_cache('UT3','PROCEDURE');
86+
end;
87+
88+
procedure cleanup_cache is
89+
pragma autonomous_transaction;
90+
begin
91+
delete from ut3.ut_annotation_cache_info
92+
where object_type = 'PROCEDURE' and object_owner in ('UT3',user)
93+
or object_type = 'PACKAGE' and object_owner = user and object_name = 'DUMMY_TEST_PACKAGE';
94+
drop_dummy_test_package();
95+
execute immediate q'[drop procedure dummy_test_procedure]';
96+
execute immediate q'[drop procedure ut3.dummy_test_procedure]';
97+
end;
98+
99+
67100

68101
procedure add_new_package is
69102
l_actual_cache_id integer;
@@ -143,7 +176,8 @@ create or replace package body test_annotation_manager is
143176

144177
open l_actual for
145178
select annotation_position, annotation_name, annotation_text, subobject_name
146-
from ut3.ut_annotation_cache where cache_id = l_actual_cache_id;
179+
from ut3.ut_annotation_cache where cache_id = l_actual_cache_id
180+
order by annotation_position;
147181

148182
open l_expected for
149183
select 1 as annotation_position, 'suite' as annotation_name,
@@ -183,7 +217,8 @@ create or replace package body test_annotation_manager is
183217

184218
open l_actual for
185219
select annotation_position, annotation_name, annotation_text, subobject_name
186-
from ut3.ut_annotation_cache where cache_id = l_actual_cache_id;
220+
from ut3.ut_annotation_cache where cache_id = l_actual_cache_id
221+
order by annotation_position;
187222

188223
open l_expected for
189224
select 1 as annotation_position, 'suite' as annotation_name,
@@ -219,7 +254,8 @@ create or replace package body test_annotation_manager is
219254

220255
open l_actual for
221256
select annotation_position, annotation_name, annotation_text, subobject_name
222-
from ut3.ut_annotation_cache where cache_id = l_actual_cache_id;
257+
from ut3.ut_annotation_cache where cache_id = l_actual_cache_id
258+
order by annotation_position;
223259

224260
open l_expected for
225261
select 1 as annotation_position, 'suite' as annotation_name,
@@ -249,5 +285,36 @@ create or replace package body test_annotation_manager is
249285
ut.expect(l_actual).to_be_empty();
250286
end;
251287

288+
procedure test_purge_schema_type is
289+
l_actual sys_refcursor;
290+
begin
291+
292+
open l_actual for
293+
select * from ut3.ut_annotation_cache_info
294+
where object_owner = user and object_type = 'PROCEDURE';
295+
ut.expect(l_actual).not_to_be_empty();
296+
297+
--Act
298+
ut3.ut_annotation_cache_manager.purge_cache(user,'PROCEDURE');
299+
300+
--Assert
301+
open l_actual for
302+
select * from ut3.ut_annotation_cache_info
303+
where object_owner = user and object_type = 'PROCEDURE';
304+
--Cache purged for object owner/type
305+
ut.expect(l_actual).to_be_empty();
306+
open l_actual for
307+
select * from ut3.ut_annotation_cache_info
308+
where object_owner = user and object_type = 'PACKAGE';
309+
--Cache not purged for other types
310+
ut.expect(l_actual).not_to_be_empty();
311+
open l_actual for
312+
select * from ut3.ut_annotation_cache_info
313+
where object_owner != user and object_type = 'PROCEDURE';
314+
--Cache not purged for other owners
315+
ut.expect(l_actual).not_to_be_empty();
316+
317+
end;
318+
252319
end test_annotation_manager;
253320
/

test/annotations/ut_annotation_manager/test_annotation_manager.pks renamed to test/ut_annotation_manager/test_annotation_manager.pks

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@ create or replace package test_annotation_manager is
4242
--%beforetest(create_dummy_test_package)
4343
procedure no_data_for_dropped_object;
4444

45+
procedure setup_cache;
46+
procedure cleanup_cache;
47+
48+
--%test(Purges cache for a given schema and object type)
49+
--%beforetest(setup_cache)
50+
--%aftertest(cleanup_cache)
51+
procedure test_purge_schema_type;
52+
4553
end test_annotation_manager;
4654
/

0 commit comments

Comments
 (0)