Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
169c7c2
Adding additional installation of utPLSQL framework into schema ut3_r…
jgebal Jul 21, 2017
248b243
Changer install.sh to be runnable from both `sqlplus` and `sqlcl`.
jgebal Jul 22, 2017
c79afbd
Trying to test ut3 using ut3 framework installed in separate schema.
jgebal Jul 23, 2017
adbb543
Testing schema `UT3` with tests in schema `UT3_TESTER` and most recen…
jgebal Jul 28, 2017
746eb07
Moved test_annotations from commit a56231c9b232418f589709d5672c1bee23…
Pazus Jul 30, 2017
fe4b993
actualized ut_utils tests to current state of old tests
Pazus Jul 30, 2017
b7c5917
implemented matcher tests
Pazus Jul 30, 2017
2bde41a
Merge remote-tracking branch 'remotes/upstream/develop' into feature/…
Pazus Jul 30, 2017
74f6bc9
splitted old and new tests
Pazus Jul 30, 2017
266ac1f
added test_output_buffer tests
Pazus Jul 30, 2017
fdc2513
Merge branch 'develop' into feature/using_released_to_test_develop
jgebal Aug 2, 2017
d34c9a6
Updated test script to capture failed tests and return non-zero exit …
jgebal Aug 2, 2017
da01280
Merge remote-tracking branch 'upstream/feature/sonar_test_reporter_fi…
jgebal Aug 3, 2017
1b2dd8c
Enabling tests.
jgebal Aug 3, 2017
cc400cb
Fixing utplsql-cli run invocation.
jgebal Aug 3, 2017
34b94de
Enabling coverage for the framework.
jgebal Aug 3, 2017
e2dccea
Merge branch 'feature/sonar_test_reporter_fix' into feature/using_rel…
jgebal Aug 5, 2017
6155357
Changed the cli call to use doc reporter only once
jgebal Aug 5, 2017
d5abea9
enabled test
Pazus Aug 5, 2017
2155b99
added ut_suite_manager tests
Pazus Aug 5, 2017
37e5533
fixed references in test_suite_manager.pkb
Pazus Aug 5, 2017
adb9320
implemented clone of develop branch
Pazus Aug 5, 2017
c6d482c
simple structure
Pazus Aug 5, 2017
c004cc5
Merge remote-tracking branch 'remotes/upstream/develop' into feature/…
Pazus Aug 5, 2017
e678a4e
change to coverage be run for the main branch not the testing branch
Pazus Aug 5, 2017
4121aaf
changed path to sources
Pazus Aug 6, 2017
33ddecc
Update install_and_run_tests.sh
jgebal Aug 6, 2017
7ba703e
Update ut_sonar_test_reporter.tpb
jgebal Aug 6, 2017
ae9fd09
Update .travis.yml
jgebal Aug 6, 2017
97e408c
Update install_and_run_tests.sh
jgebal Aug 6, 2017
067595f
Update .travis.yml
jgebal Aug 6, 2017
dcce789
Update .travis.yml
jgebal Aug 6, 2017
01691eb
Update install_and_run_tests.sh
jgebal Aug 6, 2017
94cd8c6
Switch to new `utplsql-cli` again
jgebal Aug 6, 2017
bf0bd31
Back to old utlplsq-cli
jgebal Aug 6, 2017
d486456
Testing fix on utPLSQL-cli
viniciusam Aug 7, 2017
c0b1a5f
Testing new client build
viniciusam Aug 7, 2017
8e1ab7c
Added source schema parameter
viniciusam Aug 7, 2017
c2af62a
Adding coveralls reporter to check how coveralls handles multiple cov…
jgebal Aug 7, 2017
9180a2b
Merge branch 'feature/remove_pessimistic_coverage_on_project' into fe…
jgebal Aug 7, 2017
7cf00f0
Renamed `tests` directory to `old_tests`.
jgebal Aug 9, 2017
16e5a06
Disabled test due to failures on US7ASCII code page on 12.1 DB
jgebal Aug 13, 2017
cd0d954
Added test for `ut_coverage_sonar_reporter`
jgebal Aug 13, 2017
b330e74
Added test for `ut_coveralls_reporter`
jgebal Aug 13, 2017
c960d44
Fixed failing tests and refactored sonar reporter.
jgebal Aug 13, 2017
41b4849
Fixed issues with framework accessing wrong tables when running self-…
jgebal Aug 17, 2017
48b6b33
Merge remote-tracking branch 'upstream/develop' into feature/using_re…
jgebal Aug 17, 2017
8badb71
Fixed failing test after rename of `tests` to `old_tests`.
jgebal Aug 17, 2017
57902fc
Merge remote-tracking branch 'upstream/develop' into feature/using_re…
jgebal Aug 18, 2017
ff9865a
Moved new test to the old_tests
jgebal Aug 18, 2017
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
actualized ut_utils tests to current state of old tests
  • Loading branch information
Pazus committed Jul 30, 2017
commit fe4b99339b582ebb756fee5bf7f74ca0ba36a521
365 changes: 261 additions & 104 deletions test/ut_utils/test_ut_utils.pkb
Original file line number Diff line number Diff line change
@@ -1,130 +1,287 @@
create or replace package body test_ut_utils as
create or replace package body test_ut_utils is

procedure clob_to_table_test(
a_clob clob, a_expected ut3.ut_varchar2_list,
a_delimiter varchar2 := ',',
a_overflow_limit integer := 1000
) is
l_result ut3.ut_varchar2_list;
begin
--Act
l_result := ut3.ut_utils.clob_to_table(a_clob, a_overflow_limit, a_delimiter);
--Assert
ut.expect(anydata.convertCollection(l_result)).to_( equal(anydata.convertCollection(a_expected)) );
end;
gv_nls_value nls_session_parameters.value%type;

procedure clob_to_table_by_delim is
procedure common_clob_to_table_exec(p_clob varchar2, p_delimiter varchar2, p_expected_list ut3.ut_varchar2_list, p_limit number) is
begin
execute immediate 'declare
l_clob clob := '''||p_clob||''';
l_delimiter varchar2(1) := '''||p_delimiter||''';
l_expected ut3.ut_varchar2_list := :p_expected_list;
l_result ut3.ut_varchar2_list;
l_limit integer := '||p_limit||q'[;
l_result_str varchar2(32767);
l_errors integer := 0;
function compare_element(a_element_id integer, a_expected ut3.ut_varchar2_list, a_actual ut3.ut_varchar2_list) return integer is
begin
clob_to_table_test( a_clob => 'a,b,c,d', a_expected => ut3.ut_varchar2_list('a','b','c','d') );
if a_expected.exists(a_element_id) and a_actual.exists(a_element_id) then
if a_expected(a_element_id) = a_actual(a_element_id) or a_expected(a_element_id) is null and a_actual(a_element_id) is null then
return 0;
else
dbms_output.put('a_expected('||a_element_id||')='||a_expected(a_element_id)||' | a_actual('||a_element_id||')='||a_actual(a_element_id));
end if;
end if;
if not a_expected.exists(a_element_id) then
dbms_output.put('a_expected('||a_element_id||') does not exist ');
end if;
if not a_actual.exists(a_element_id) then
dbms_output.put('a_actual('||a_element_id||') does not exist ');
end if;
dbms_output.put_line(null);
return 1;
end;
begin
--Act
select column_value bulk collect into l_result from table( ut3.ut_utils.clob_to_table(l_clob, l_limit, l_delimiter) );
for i in 1 .. l_result.count loop
l_result_str := l_result_str||''''||l_result(i)||''''||l_delimiter;
end loop;
l_result_str := rtrim(l_result_str,l_delimiter);
--Assert
for i in 1 .. greatest(l_expected.count, l_result.count) loop
l_errors := l_errors + compare_element(i, l_expected, l_result);
end loop;
ut.expect(l_errors).to_equal(0);
end;]' using p_expected_list;
end;

--%test(clob_to_table returns empty table for null clob)
procedure clob_to_table_null_data is
procedure test_clob_to_table is
begin
common_clob_to_table_exec('a,b,c,d', ',', ut3.ut_varchar2_list('a','b','c','d'), 1000);
common_clob_to_table_exec( '', ',', ut3.ut_varchar2_list(), 1000);
common_clob_to_table_exec( '1,b,c,d', '', ut3.ut_varchar2_list('1,b,','c,d'), 4);
common_clob_to_table_exec( 'abcdefg,hijk,axa,a', ',', ut3.ut_varchar2_list('abc','def','g','hij','k','axa','a'), 3);
common_clob_to_table_exec( ',a,,c,d,', ',', ut3.ut_varchar2_list('','a','','c','d',''), 1000);
end;

procedure test_to_char is
begin
ut.expect(ut3.ut_utils.test_result_to_char(-1),'test unknown').to_equal('Unknown(-1)');
ut.expect(ut3.ut_utils.test_result_to_char(null),'test unknown').to_equal('Unknown(NULL)');
ut.expect(ut3.ut_utils.test_result_to_char(ut3.ut_utils.tr_success),'test unknown').to_equal(ut3.ut_utils.tr_success_char);
end;

procedure test_to_string_blob is
l_text varchar2(32767) := 'A test char';
l_value blob := utl_raw.cast_to_raw(l_text);
l_expected varchar2(32767) := ''''||rawtohex(l_value)||'''';
l_result varchar2(32767);
begin
clob_to_table_test( a_clob => null, a_expected => ut3.ut_varchar2_list() );
l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result).to_equal(l_expected);
end;

procedure test_to_string_clob is
l_value clob := 'A test char';
l_expected varchar2(32767) := ''''||l_value||'''';
l_result varchar2(32767);
begin
l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result).to_equal(l_expected);
end;

procedure test_to_string_date is
l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss');
l_expected varchar2(100) := '2016-12-31T23:59:59';
l_result varchar2(32767);
begin
l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result).to_equal(l_expected);
end;

procedure to_string_null is
begin
ut.expect(ut3.ut_utils.to_String(to_blob(NULL))).to_equal('NULL');
ut.expect(ut3.ut_utils.to_String(to_clob(NULL))).to_equal('NULL');
ut.expect(ut3.ut_utils.to_String(to_date(NULL))).to_equal('NULL');
ut.expect(ut3.ut_utils.to_String(to_number(NULL))).to_equal('NULL');
ut.expect(ut3.ut_utils.to_String(to_timestamp(NULL))).to_equal('NULL');
end;

procedure to_string is
l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff');
l_value2 timestamp(9) with local time zone:= to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff');
l_value3 timestamp(9) with time zone := to_timestamp_tz('2016-12-31 23:59:59.123456789 -8:00', 'yyyy-mm-dd hh24:mi:ss.ff tzh:tzm');
l_value4 varchar2(20) := 'A test char';
l_expected varchar2(100);
l_result varchar2(100);
l_delimiter varchar2(10);
begin
select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS';
l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789';

l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);

l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789';
l_result := ut3.ut_utils.to_String(l_value2);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);

--%test(clob_to_table splits table by char limit when no delimiter)
procedure clob_to_table_char_limit is
begin
clob_to_table_test(
a_clob => '1,2,3,4',
a_expected => ut3.ut_varchar2_list('1,2,','3,4'),
a_delimiter => '',
a_overflow_limit => 4
);
l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789 -08:00';
l_result := ut3.ut_utils.to_String(l_value3);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);

l_expected := ''''||l_value4||'''';
l_result := ut3.ut_utils.to_String(l_value4);
ut.expect(l_result,'Returns a varchar2 eclosed in quotes').to_equal(l_expected);

end;

procedure to_string_big_blob is
l_text clob := lpad('A test char',32767,'1')||lpad('1',32767,'1');
l_value blob;
l_result varchar2(32767);
function clob_to_blob(p_clob clob) return blob
as
l_blob blob;
l_dest_offset integer := 1;
l_source_offset integer := 1;
l_lang_context integer := dbms_lob.default_lang_ctx;
l_warning integer := dbms_lob.warn_inconvertible_char;
begin
dbms_lob.createtemporary(l_blob, true);
dbms_lob.converttoblob(
dest_lob =>l_blob,
src_clob =>p_clob,
amount =>DBMS_LOB.LOBMAXSIZE,
dest_offset =>l_dest_offset,
src_offset =>l_source_offset,
blob_csid =>DBMS_LOB.DEFAULT_CSID,
lang_context=>l_lang_context,
warning =>l_warning
);
return l_blob;
end;
begin
l_value := clob_to_blob(l_text);
--Act
l_result := ut3.ut_utils.to_String(l_value);
--Assert
ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length);
ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string);

--%test(clob_to_table splits table by char limit on overflow and continues by delimiter)
procedure clob_to_table_char_limit_delim is
end;

procedure to_string_big_clob is
l_value clob := lpad('A test char',32767,'1')||lpad('1',32767,'1');
l_result varchar2(32767);
begin
clob_to_table_test(
a_clob => 'abcdefg,hijk,axa,a',
a_expected => ut3.ut_varchar2_list('abc','def','g','hij','k','axa','a'),
a_overflow_limit => 3
);
--Act
l_result := ut3.ut_utils.to_String(l_value);
--Assert
ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length);
ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string);
end;

--%test(clob_to_table returns empty lines for null data between delimiter)
procedure clob_to_table_empty_lines is

procedure to_string_big_number is
l_value number := 1234567890123456789012345678901234567890;
l_expected varchar2(100) := '1234567890123456789012345678901234567890';
l_result varchar2(100);
begin
clob_to_table_test(
a_clob => ',a,,c,d,',
a_expected => ut3.ut_varchar2_list('','a','','c','d','')
);
--Act
l_result := ut3.ut_utils.to_String(l_value);
--Assert
ut.expect(l_result).TO_equal(l_expected);
end;

--%test(test_result_to_char)
procedure test_result_to_char is

procedure to_string_big_varchar2 is
l_value varchar2(32767) := lpad('A test char',32767,'1');
l_result varchar2(32767);
begin
ut.expect( ut3.ut_utils.test_result_to_char(NULL)).to_equal('Unknown(NULL)');
ut.expect( ut3.ut_utils.test_result_to_char(-1)).to_equal('Unknown(-1)');
ut.expect( ut3.ut_utils.test_result_to_char(ut3.ut_utils.tr_disabled)).to_equal(ut3.ut_utils.tr_disabled_char);
ut.expect( ut3.ut_utils.test_result_to_char(ut3.ut_utils.tr_success)).to_equal(ut3.ut_utils.tr_success_char);
ut.expect( ut3.ut_utils.test_result_to_char(ut3.ut_utils.tr_failure)).to_equal(ut3.ut_utils.tr_failure_char);
ut.expect( ut3.ut_utils.test_result_to_char(ut3.ut_utils.tr_error)).to_equal(ut3.ut_utils.tr_error_char);
--Act
l_result := ut3.ut_utils.to_String(l_value);
--Assert
ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length);
ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string);
end;

--%test(to_test_result converts boolean value to test result integer)
procedure to_test_result is
procedure to_string_big_tiny_number is
l_value number := 0.123456789012345678901234567890123456789;
l_expected varchar2(100);
l_result varchar2(100);
l_delimiter varchar2(1);
begin
ut.expect( ut3.ut_utils.to_test_result(true)).to_equal(ut3.ut_utils.tr_success);
ut.expect( ut3.ut_utils.to_test_result(false)).to_equal(ut3.ut_utils.tr_failure);
ut.expect( ut3.ut_utils.to_test_result(null)).to_equal(ut3.ut_utils.tr_failure);
end;
--Act
select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS';
l_expected := l_delimiter||'123456789012345678901234567890123456789';

l_result := ut3.ut_utils.to_String(l_value);

--Assert
ut.expect(l_result).TO_equal(l_expected);

--%test(to_string on null blob)
procedure to_string_null_blob is
end;

procedure test_table_to_clob is
procedure exec_table_to_clob(a_list ut3.ut_varchar2_list, a_delimiter varchar2, a_expected clob) is
l_result clob;
begin
l_result := ut3.ut_utils.table_to_clob(a_list, a_delimiter);

ut.expect(l_result).to_equal(a_expected, a_nulls_are_equal => true);
end;
begin
ut.expect( ut3.ut_utils.to_string(to_blob(null)) ).to_equal('NULL');
exec_table_to_clob(null, ',', '');
exec_table_to_clob(ut3.ut_varchar2_list(), ',', '');
exec_table_to_clob(ut3.ut_varchar2_list('a', 'b', 'c', 'd'), ',', 'a,b,c,d');
exec_table_to_clob(ut3.ut_varchar2_list('1,b,', 'c,d'), ',', '1,b,,c,d');
exec_table_to_clob(ut3.ut_varchar2_list('', 'a', '', 'c', 'd', ''), ',', ',a,,c,d,');
end;

--%test(to_string on blob)
procedure to_string_blob is
l_text varchar2(32767) := 'A test char';
l_value blob := utl_raw.cast_to_raw(l_text);
l_expected varchar2(32767) := ''''||rawtohex(l_value)||'''';
procedure test_append_with_multibyte is
l_lines sys.dbms_preprocessor.source_lines_t;
l_result clob;
begin
ut.expect( ut3.ut_utils.to_string(l_value) ).to_equal(l_expected);
l_lines := sys.dbms_preprocessor.get_post_processed_source(
object_type => 'PACKAGE',
schema_name => user,
object_name => 'TST_CHARS'
);

for i in 1..l_lines.count loop
l_result := null;
ut3.ut_utils.append_to_clob(l_result, l_lines(i));

--Assert
ut.expect(dbms_lob.getlength(l_result),'Error for index '||i).to_equal(dbms_lob.getlength(l_lines(i)));
end loop;
end;

-- --%test(to_string on null clob)
-- procedure to_string_null_clob;
-- --%test(to_string on clob)
-- procedure to_string_clob;
-- --%test(to_string on clob no surrounding quotes)
-- procedure to_string_clob_no_quotes;
-- --%test(to_string on clob other surrounding quotes)
-- procedure to_string_clob_other_quotes;
--
-- --%test(to_string on null number)
-- procedure to_string_null_number;
-- --%test(to_string on number)
-- procedure to_string_number;
--
-- --%test(to_string on null timestamp)
-- procedure to_string_null_timestamp;
-- --%test(to_string on timestamp)
-- procedure to_string_timestamp;
--
-- --%test(to_string on null timestamp with time zone)
-- procedure to_string_null_timestamp_tz;
-- --%test(to_string on timestamp with time zone)
-- procedure to_string_timestamp_tz;
--
-- --%test(to_string on null timestamp with local time zone)
-- procedure to_string_null_timestamp_ltz;
-- --%test(to_string on timestamp with local time zone)
-- procedure to_string_timestamp_ltz;
--
-- --%test(to_string on null varchar)
-- procedure to_string_null_varchar;
-- --%test(to_string on varchar)
-- procedure to_string_varchar;
-- --%test(to_string on varchar no surrounding quotes)
-- procedure to_string_varchar_no_quotes;
-- --%test(to_string on varchar non default surrounding quotes)
-- procedure to_string_varchar_other_quotes;
procedure setup_append_with_multibyte is
pragma autonomous_transaction;
begin
select value into gv_nls_value from nls_session_parameters where parameter = 'NLS_DATE_LANGUAGE';
execute immediate 'alter session set nls_date_language=ENGLISH';
execute immediate 'create or replace package tst_chars as
-- 2) Status of the process = �PE� with no linked data
end;';
execute immediate 'alter session set nls_date_language=RUSSIAN';

end;
procedure clean_append_with_multibyte is
pragma autonomous_transaction;
begin
execute immediate 'alter session set nls_date_language='||gv_nls_value;
execute immediate 'drop package tst_chars';
end;

procedure test_clob_to_table_multibyte is
l_varchar2_byte_limit integer := 32767;
l_workaround_byte_limit integer := 8191;
l_singlebyte_string_max_size varchar2(32767 char) := rpad('x',l_varchar2_byte_limit,'x');
l_twobyte_character char(1 char) := '�';
l_clob_multibyte clob := l_twobyte_character||l_singlebyte_string_max_size; --here we have 32769(2+32767) bytes and 32768 chars
l_expected ut3.ut_varchar2_list := ut3.ut_varchar2_list();
l_result ut3.ut_varchar2_list;
begin
l_expected.extend(1);
l_expected(1) := l_twobyte_character||substr(l_singlebyte_string_max_size,1,l_workaround_byte_limit-1);
--Act
l_result := ut3.ut_utils.clob_to_table(l_clob_multibyte);
--Assert
ut.expect(l_result(1)).to_equal(l_expected(1));
end;

end;
/
end test_ut_utils;
/
Loading