diff --git a/docs/about/authors.md b/docs/about/authors.md index 40700d995..ec79d645c 100644 --- a/docs/about/authors.md +++ b/docs/about/authors.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) ### utPLSQL v3 Major Contributors diff --git a/docs/about/license.md b/docs/about/license.md index 534a12ddf..3f6cffed3 100644 --- a/docs/about/license.md +++ b/docs/about/license.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Version Information diff --git a/docs/about/project-details.md b/docs/about/project-details.md index 9d003f57b..497d20418 100644 --- a/docs/about/project-details.md +++ b/docs/about/project-details.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # utPLSQL Project Details diff --git a/docs/about/support.md b/docs/about/support.md index e3787fa89..f1f3615b3 100644 --- a/docs/about/support.md +++ b/docs/about/support.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # How to get support diff --git a/docs/index.md b/docs/index.md index 8cee8860a..d448537b9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Introduction to utPLSQL diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index c2e24a6d5..556d97129 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Advanced data comparison diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 15e5394c7..922ab5227 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Annotations diff --git a/docs/userguide/best-practices.md b/docs/userguide/best-practices.md index b5a5a4dcd..cc41a86a5 100644 --- a/docs/userguide/best-practices.md +++ b/docs/userguide/best-practices.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Best Practices diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md index 7793b7b73..8de2fdb27 100644 --- a/docs/userguide/coverage.md +++ b/docs/userguide/coverage.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Coverage utPLSQL comes with a built-in coverage reporting engine. The code coverage reporting is based on the DBMS_PROFILER package provided with Oracle database. diff --git a/docs/userguide/exception-reporting.md b/docs/userguide/exception-reporting.md index 5ff9eca9c..be73ccf6d 100644 --- a/docs/userguide/exception-reporting.md +++ b/docs/userguide/exception-reporting.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Exception handling and reporting diff --git a/docs/userguide/expectations.md b/docs/userguide/expectations.md index d6508f9d0..2e030665b 100644 --- a/docs/userguide/expectations.md +++ b/docs/userguide/expectations.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Expectation concepts Validation of the code under test (the tested logic of procedure/function etc.) is performed by comparing the actual data against the expected data. diff --git a/docs/userguide/getting-started.md b/docs/userguide/getting-started.md index 79fc7caf8..babf5a51b 100644 --- a/docs/userguide/getting-started.md +++ b/docs/userguide/getting-started.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Getting started with TDD and utPLSQL diff --git a/docs/userguide/install.md b/docs/userguide/install.md index 7a982043c..060974505 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Downloading latest version of utPLSQL diff --git a/docs/userguide/querying_suites.md b/docs/userguide/querying_suites.md index f55cbce7d..488db9204 100644 --- a/docs/userguide/querying_suites.md +++ b/docs/userguide/querying_suites.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Qyerying for test suites diff --git a/docs/userguide/reporters.md b/docs/userguide/reporters.md index b46a97080..494f9ef6a 100644 --- a/docs/userguide/reporters.md +++ b/docs/userguide/reporters.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) utPLSQL provides the following reporting formats. diff --git a/docs/userguide/running-unit-tests.md b/docs/userguide/running-unit-tests.md index 951fdfa82..4cdc4fb7c 100644 --- a/docs/userguide/running-unit-tests.md +++ b/docs/userguide/running-unit-tests.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Running tests diff --git a/docs/userguide/upgrade.md b/docs/userguide/upgrade.md index 7aff312bf..fa03c5a19 100644 --- a/docs/userguide/upgrade.md +++ b/docs/userguide/upgrade.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.7.2808--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.2851--develop-blue.svg) # Upgrading from version 2 diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb index 8767d8d8b..e961ca908 100644 --- a/source/core/ut_expectation_processor.pkb +++ b/source/core/ut_expectation_processor.pkb @@ -88,7 +88,7 @@ create or replace package body ut_expectation_processor as begin add_expectation_result(ut_expectation_result(ut_utils.gc_failure, null, a_message)); end; - + function get_session_parameters return tt_nls_params is l_session_params tt_nls_params; begin diff --git a/source/core/ut_expectation_processor.pks b/source/core/ut_expectation_processor.pks index f58de2441..ab3b70f76 100644 --- a/source/core/ut_expectation_processor.pks +++ b/source/core/ut_expectation_processor.pks @@ -35,7 +35,7 @@ create or replace package ut_expectation_processor authid current_user as procedure add_expectation_result(a_expectation_result ut_expectation_result); procedure report_failure(a_message in varchar2); - + procedure set_xml_nls_params; procedure reset_nls_params; diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index b29e7fa60..dcf24f2e4 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -16,6 +16,13 @@ create or replace package body ut_utils is limitations under the License. */ + /** + * Constants regex used to validate XML name + */ + gc_invalid_first_xml_char constant varchar2(50) := '[^_a-zA-Z]'; + gc_invalid_xml_char constant varchar2(50) := '[^_a-zA-Z0-9\.-]'; + gc_full_valid_xml_name constant varchar2(50) := '^([_a-zA-Z])([_a-zA-Z0-9\.-])*$'; + function surround_with(a_value varchar2, a_quote_char varchar2) return varchar2 is begin return case when a_quote_char is not null then a_quote_char||a_value||a_quote_char else a_value end; @@ -737,5 +744,59 @@ create or replace package body ut_utils is return l_results; end; + function remove_error_from_stack(a_error_stack varchar2, a_ora_code number) return varchar2 is + l_caller_stack_line varchar2(4000); + l_ora_search_pattern varchar2(500) := '^ORA'||a_ora_code||': (.*)$'; + begin + l_caller_stack_line := regexp_replace(srcstr => a_error_stack + ,pattern => l_ora_search_pattern + ,replacestr => null + ,position => 1 + ,occurrence => 1 + ,modifier => 'm'); + return l_caller_stack_line; + end; + + /** + * Change string into unicode to match xmlgen format _00_ + * https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adxdb/generation-of-XML-data-from-relational-data.html#GUID-5BE09A7D-80D8-4734-B9AF-4A61F27FA9B2 + * secion v3.1.7.2851-develop + */ + function char_to_xmlgen_unicode(a_character varchar2) return varchar2 is + begin + return '_x00'||rawtohex(utl_raw.cast_to_raw(a_character))||'_'; + end; + + /** + * Build valid XML column name as element names can contain letters, digits, hyphens, underscores, and periods + */ + function build_valid_xml_name(a_preprocessed_name varchar2) return varchar2 is + l_post_processed varchar2(4000); + begin + for i in (select regexp_substr( a_preprocessed_name ,'(.{1})', 1, level, null, 1 ) AS string_char,level level_no + from dual connect by level <= regexp_count(a_preprocessed_name, '(.{1})')) + loop + if i.level_no = 1 and regexp_like(i.string_char,gc_invalid_first_xml_char) then + l_post_processed := l_post_processed || char_to_xmlgen_unicode(i.string_char); + elsif regexp_like(i.string_char,gc_invalid_xml_char) then + l_post_processed := l_post_processed || char_to_xmlgen_unicode(i.string_char); + else + l_post_processed := l_post_processed || i.string_char; + end if; + end loop; + return l_post_processed; + end; + + function get_valid_xml_name(a_name varchar2) return varchar2 is + l_valid_name varchar2(4000); + begin + if regexp_like(a_name,gc_full_valid_xml_name) then + l_valid_name := a_name; + else + l_valid_name := build_valid_xml_name(a_name); + end if; + return l_valid_name; + end; + end ut_utils; / diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 1e5588f7d..bfb3bc219 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -21,8 +21,8 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.7.2808-develop'; - + gc_version constant varchar2(50) := 'v3.1.7.2851-develop'; + subtype t_executable_type is varchar2(30); gc_before_all constant t_executable_type := 'beforeall'; gc_before_each constant t_executable_type := 'beforeeach'; @@ -109,6 +109,14 @@ create or replace package ut_utils authid definer is gc_value_too_large constant pls_integer := -20217; pragma exception_init (ex_value_too_large, -20217); + ex_xml_processing exception; + gc_xml_processing constant pls_integer := -19202; + pragma exception_init (ex_xml_processing, -19202); + + ex_failed_open_cur exception; + gc_failed_open_cur constant pls_integer := -20218; + pragma exception_init (ex_failed_open_cur, -20218); + gc_max_storage_varchar2_len constant integer := 4000; gc_max_output_string_length constant integer := 4000; gc_more_data_string constant varchar2(5) := '[...]'; @@ -368,6 +376,16 @@ create or replace package ut_utils authid definer is * Returns list of sub-type reporters for given list of super-type reporters */ function get_child_reporters(a_for_reporters ut_reporters_info := null) return ut_reporters_info; - + + /** + * Remove given ORA error from stack + */ + function remove_error_from_stack(a_error_stack varchar2, a_ora_code number) return varchar2; + + /** + * Check if xml name is valid if not build a valid name + */ + function get_valid_xml_name(a_name varchar2) return varchar2; + end ut_utils; / diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 6be8c2ad7..6e8453f45 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -18,8 +18,10 @@ create or replace package body ut_compound_data_helper is g_diff_count integer; type t_type_name_map is table of varchar2(128) index by binary_integer; + type t_types_no_length is table of varchar2(128) index by varchar2(128); g_type_name_map t_type_name_map; g_anytype_name_map t_type_name_map; + g_type_no_length_map t_types_no_length; g_compare_sql_template varchar2(4000) := q'[ @@ -78,13 +80,13 @@ create or replace package body ut_compound_data_helper is begin execute immediate q'[with expected_cols as ( - select access_path exp_column_name,column_position exp_col_pos, + select display_path exp_column_name,column_position exp_col_pos, replace(column_type_name,'VARCHAR2','CHAR') exp_col_type_compare, column_type_name exp_col_type from table(:a_expected) where parent_name is null and hierarchy_level = 1 and column_name is not null ), actual_cols as ( - select access_path act_column_name,column_position act_col_pos, + select display_path act_column_name,column_position act_col_pos, replace(column_type_name,'VARCHAR2','CHAR') act_col_type_compare, column_type_name act_col_type from table(:a_actual) where parent_name is null and hierarchy_level = 1 and column_name is not null @@ -231,7 +233,7 @@ create or replace package body ut_compound_data_helper is elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('DATE','TIMESTAMP','TIMESTAMP WITH TIME ZONE', 'TIMESTAMP WITH LOCAL TIME ZONE') then l_col_type := 'VARCHAR2(50)'; - elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('INTERVAL DAY TO SECOND','INTERVAL YEAR TO MONTH') then + elsif a_data_info.is_sql_diffable = 1 and type_no_length(a_data_info.column_type) then l_col_type := a_data_info.column_type; elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('VARCHAR2','CHAR') then l_col_type := 'VARCHAR2('||greatest(a_data_info.column_len,4000)||')'; @@ -571,6 +573,8 @@ create or replace package body ut_compound_data_helper is --clob/blob/xmltype/object/nestedcursor/nestedtable if a_type_name IN (g_type_name_map(dbms_sql.blob_type), g_type_name_map(dbms_sql.clob_type), + g_type_name_map(dbms_sql.long_type), + g_type_name_map(dbms_sql.long_raw_type), g_type_name_map(dbms_sql.bfile_type), g_anytype_name_map(dbms_types.typecode_namedcollection)) then @@ -597,6 +601,24 @@ create or replace package body ut_compound_data_helper is open l_diff_cursor for a_diff_cursor_text using a_self_id, a_other_id; return l_diff_cursor; end; + + function create_err_cursor_msg(a_error_stack varchar2) return varchar2 is + begin + return 'SQL exception thrown when fetching data from cursor:'|| + ut_utils.remove_error_from_stack(sqlerrm,ut_utils.gc_xml_processing)||chr(10)|| + ut_expectation_processor.who_called_expectation(a_error_stack)|| + 'Check the query and data for errors.'; + end; + + function type_no_length ( a_type_name varchar2) return boolean is + begin + return case + when g_type_no_length_map.exists(a_type_name) then + true + else + false + end; + end; begin g_anytype_name_map(dbms_types.typecode_date) := 'DATE'; @@ -643,6 +665,15 @@ begin g_type_name_map( dbms_sql.urowid_type ) := 'UROWID'; g_type_name_map( dbms_sql.user_defined_type ) := 'USER_DEFINED_TYPE'; g_type_name_map( dbms_sql.ref_type ) := 'REF_TYPE'; - + + + /** + * List of types that have no length but can produce a max_len from desc_cursor function. + */ + g_type_no_length_map('ROWID') := 'ROWID'; + g_type_no_length_map('INTERVAL DAY TO SECOND') := 'INTERVAL DAY TO SECOND'; + g_type_no_length_map('INTERVAL YEAR TO MONTH') := 'INTERVAL YEAR TO MONTH'; + g_type_no_length_map('BINARY_DOUBLE') := 'BINARY_DOUBLE'; + g_type_no_length_map('BINARY_FLOAT') := 'BINARY_FLOAT'; end; / diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index bf3182500..1c00d2263 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -92,5 +92,12 @@ create or replace package ut_compound_data_helper authid definer is function get_compare_cursor(a_diff_cursor_text in clob,a_self_id raw, a_other_id raw) return sys_refcursor; + function create_err_cursor_msg(a_error_stack varchar2) return varchar2; + + /* + * Function to return true or false if the type dont have an length + */ + function type_no_length ( a_type_name varchar2) return boolean; + end; / diff --git a/source/expectations/data_values/ut_cursor_column.tpb b/source/expectations/data_values/ut_cursor_column.tpb index 5f6f18c56..8f26f58aa 100644 --- a/source/expectations/data_values/ut_cursor_column.tpb +++ b/source/expectations/data_values/ut_cursor_column.tpb @@ -13,17 +13,24 @@ create or replace type body ut_cursor_column as self.column_len := a_col_max_len; --length of column self.column_name := TRIM( BOTH '''' FROM a_col_name); --name of the column self.column_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2 - self.access_path := case when a_access_path is null then + self.xml_valid_name := ut_utils.get_valid_xml_name(self.column_name); + self.display_path := case when a_access_path is null then self.column_name else a_access_path||'/'||self.column_name - end; --Access path used for incldue exclude eg/ TEST_DUMMY_OBJECT/VARCHAR2 - self.xml_valid_name := '"'||self.column_name||'"'; --User friendly column name - self.transformed_name := case when self.parent_name is null then - self.xml_valid_name - else - '"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.column_name)||'"' - end; --when is nestd we need to hash name to make sure we dont exceed 30 char + end; --Access path used for incldue exclude eg/ TEST_DUMMY_OBJECT/VARCHAR2 + self.access_path := case when a_access_path is null then + self.xml_valid_name + else + a_access_path||'/'||self.xml_valid_name + end; --Access path used for incldue exclude eg/ TEST_DUMMY_OBJECT/VARCHAR2 + self.transformed_name := case when length(self.xml_valid_name) > 30 then + '"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"' + when self.parent_name is null then + '"'||self.xml_valid_name||'"' + else + '"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"' + end; --when is nestd we need to hash name to make sure we dont exceed 30 char self.column_type := a_col_type; --column type e.g. user_defined , varchar2 self.column_schema := a_col_schema_name; -- schema name self.is_sql_diffable := case diff --git a/source/expectations/data_values/ut_cursor_column.tps b/source/expectations/data_values/ut_cursor_column.tps index 4b436051a..f55973e16 100644 --- a/source/expectations/data_values/ut_cursor_column.tps +++ b/source/expectations/data_values/ut_cursor_column.tps @@ -17,12 +17,13 @@ create or replace type ut_cursor_column force authid current_user as object ( */ parent_name varchar2(4000), access_path varchar2(4000), + display_path varchar2(4000), has_nested_col number(1,0), - transformed_name varchar2(32), + transformed_name varchar2(2000), hierarchy_level number, column_position number, - xml_valid_name varchar2(128), - column_name varchar2(128), + xml_valid_name varchar2(2000), + column_name varchar2(2000), column_type varchar2(128), column_type_name varchar2(128), column_schema varchar2(128), diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 947d907b5..ee929d097 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -103,6 +103,12 @@ create or replace type body ut_data_value_refcursor as exception when cursor_not_open then raise_application_error(-20155, 'Cursor is not open'); + when ut_utils.ex_xml_processing then + if l_cursor%isopen then + close l_cursor; + end if; + raise_application_error(ut_utils.gc_failed_open_cur, + ut_compound_data_helper.create_err_cursor_msg(dbms_utility.format_call_stack())); when others then if l_cursor%isopen then close l_cursor; @@ -118,7 +124,9 @@ create or replace type body ut_data_value_refcursor as dbms_lob.createtemporary(l_result, true); ut_utils.append_to_clob(l_result, 'Data-types:'||chr(10)); - ut_utils.append_to_clob( l_result, self.cursor_details.get_xml_children().getclobval() ); + if self.cursor_details.cursor_columns_info.count > 0 then + ut_utils.append_to_clob( l_result, self.cursor_details.get_xml_children().getclobval() ); + end if; ut_utils.append_to_clob(l_result,chr(10)||(self as ut_compound_data_value).to_string()); l_result_string := ut_utils.to_string(l_result,null); dbms_lob.freetemporary(l_result); diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index 394b643fd..959014a45 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -82,6 +82,28 @@ create or replace package body test_expectations_cursor is ut3.ut.reset_nls; end; + procedure success_on_same_data_float + as + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + -- Arrange + ut3.ut.set_nls; + open l_expected for + select cast(3.14 as binary_double) as pi_double, + cast(3.14 as binary_float) as pi_float + from dual; + open l_actual for + select cast(3.14 as binary_double) as pi_double, + cast(3.14 as binary_float) as pi_float + from dual; + --Act + ut3.ut.expect( l_actual ).to_equal( l_expected ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + ut3.ut.reset_nls; + end; + procedure success_on_empty as l_expected sys_refcursor; @@ -972,18 +994,16 @@ Rows: [ 4 differences ] procedure reports_on_exception_in_cursor as l_actual sys_refcursor; - l_error_code integer := -19202; --Error occurred in XML processing begin --Act open l_actual for select 1/0 as error_column from dual connect by level < 10; - begin ut3.ut.expect(l_actual).to_be_empty(); - --Assert - ut.fail('Expected '||l_error_code||' but nothing was raised'); - exception - when others then - ut.expect(sqlcode).to_equal(l_error_code); - end; + + ut.fail('Expected exception on cursor fetch'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%ORA-20218: SQL exception thrown when fetching data from cursor:% +%ORA-01476: divisor is equal to zero%Check the query and data for errors%'); end; procedure exception_when_closed_cursor @@ -2523,6 +2543,141 @@ Diff:% ut.expect(l_actual_message).to_be_like(l_expected_message); end; + procedure xml_error_actual is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_exp_message varchar2(32000); + begin + l_exp_message :='ORA-20218: SQL exception thrown when fetching data from cursor: +ORA-01476: divisor is equal to zero +at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2561 ut3.ut.expect(l_actual).to_equal(l_expected);% +Check the query and data for errors.'; + + open l_actual for + select 1 as test from dual; + open l_expected for + select 1/0 as test from dual; + + ut3.ut.expect(l_actual).to_equal(l_expected); + --Line that error relates to in expected messag + + ut.fail('Expected exception on cursor fetch'); + exception + when others then + ut.expect(sqlerrm).to_be_like(l_exp_message); + end; + + procedure xml_error_expected is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_exp_message varchar2(32000); + begin + + l_exp_message :='ORA-20218: SQL exception thrown when fetching data from cursor: +ORA-01476: divisor is equal to zero +at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2586 ut3.ut.expect(l_actual).to_equal(l_expected);% +Check the query and data for errors.'; + + open l_expected for + select 1/0 as test from dual; + open l_actual for + select 1 as test from dual; + + ut3.ut.expect(l_actual).to_equal(l_expected); + + ut.fail('Expected exception on cursor fetch'); + exception + when others then + ut.expect(sqlerrm).to_be_like(l_exp_message); + end; + + procedure no_length_datatypes is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + ut3.ut.set_nls; + open l_expected for + select cast(3.14 as binary_double) as pi_double, + cast(3.14 as binary_float) as pi_float, + rowid as row_rowid, + numtodsinterval(1.12345678912, 'day') row_ds_interval, + numtoyminterval(1.1, 'year') row_ym_interval + from dual; + + open l_actual for + select cast(3.14 as binary_double) as pi_double, + cast(3.14 as binary_float) as pi_float, + rowid as row_rowid, + numtodsinterval(1.12345678912, 'day') row_ds_interval, + numtoyminterval(1.1, 'year') row_ym_interval + from dual; + --Act + ut3.ut.expect( l_actual ).to_equal( l_expected ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + ut3.ut.reset_nls; + + end; + + procedure colon_part_of_columnname is + type t_key_val_rec is record( + key varchar2(100), + value varchar2(100)); + + l_act t_key_val_rec; + l_exp t_key_val_rec; + l_act_cur sys_refcursor; + l_exp_cur sys_refcursor; + begin + l_act.key := 'NAME'; + l_act.value := 'TEST'; + l_exp.key := 'NAME'; + l_exp.value := 'TEST'; + + OPEN l_act_cur FOR SELECT l_act.key, l_act.value + FROM dual; + + OPEN l_exp_cur FOR SELECT l_exp.key, l_exp.value + FROM dual; + + ut3.ut.expect(l_act_cur).to_equal(l_exp_cur); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure specialchar_part_of_colname is + l_act_cur sys_refcursor; + l_exp_cur sys_refcursor; + begin + + OPEN l_act_cur FOR SELECT 1 as "$Test", 2 as "&Test" + FROM dual; + + OPEN l_exp_cur FOR SELECT 1 as "$Test", 2 as "&Test" + FROM dual; + + ut3.ut.expect(l_act_cur).to_equal(l_exp_cur); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure nonxmlchar_part_of_colname is + l_act_cur sys_refcursor; + l_exp_cur sys_refcursor; + begin + + OPEN l_act_cur FOR SELECT 1 as "", 2 as "_Test", 3 as ".Test>" + FROM dual; + + OPEN l_exp_cur FOR SELECT 1 as "", 2 as "_Test", 3 as ".Test>" + FROM dual; + + ut3.ut.expect(l_act_cur).to_equal(l_exp_cur); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure insginificant_whitespace1 is l_actual sys_refcursor; l_expected sys_refcursor; @@ -2605,6 +2760,7 @@ Diff:% --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; + end; + end; / diff --git a/test/ut3_user/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks index aea72473d..d511ae7f7 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pks +++ b/test/ut3_user/expectations/test_expectations_cursor.pks @@ -17,6 +17,9 @@ create or replace package test_expectations_cursor is --%test(Gives success for identical data) procedure success_on_same_data; + --%test(Gives success for identical data with floats) + procedure success_on_same_data_float; + --%test(Gives success when both cursors are empty) procedure success_on_empty; @@ -390,12 +393,31 @@ create or replace package test_expectations_cursor is --%test(Cursor to contain duplicates fail) procedure to_contain_duplicates_fail; - + --%test(Display a message with a uer defined type with only type name not structure on equal) procedure udt_messg_format_eq; --%test(Display a message with a uer defined type with only type name not structure on empty) - procedure udt_messg_format_empt; + procedure udt_messg_format_empt; + + --%test(Fail to process a cursor for actual) + procedure xml_error_actual; + + --%test(Fail to process a cursor for expected) + procedure xml_error_expected; + + --%test(Check that cursor correctly handles no length dataypes) + procedure no_length_datatypes; + + --%test(Check that colon is converted properly fix #902) + procedure colon_part_of_columnname; + + --%test(Check that column name accept special characters fix #902) + procedure specialchar_part_of_colname; + + --%test(Check that column name accept non xml characters fix #902) + procedure nonxmlchar_part_of_colname; + /*Oracle Bug not readin properly in xmltable */ --%test ( Compare insiginificant whitespaces scenario 1 )