diff --git a/.travis.yml b/.travis.yml index ce865e05a..7e9d94ccf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,8 @@ env: - UT3_USER_PASSWORD=ut3 - UT3_TESTER=ut3_tester - UT3_TESTER_PASSWORD=ut3 + - UT3_TESTER_HELPER=ut3_tester_helper + - UT3_TESTER_HELPER_PASSWORD=ut3 - UT3_TABLESPACE=users # Environment for building a release - CURRENT_BRANCH=${TRAVIS_BRANCH} @@ -45,7 +47,7 @@ env: #utPLSQL released version directory - UTPLSQL_DIR="utPLSQL_latest_release" - SELFTESTING_BRANCH=${TRAVIS_BRANCH} - - UTPLSQL_CLI_VERSION="3.1.0" + - UTPLSQL_CLI_VERSION="3.1.6" # Maven - MAVEN_HOME=/usr/local/maven - MAVEN_CFG=$HOME/.m2 @@ -54,6 +56,7 @@ env: - ORACLE_VERSION="${DOCKER_TAG_12C:-12c-r1-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - ORACLE_VERSION="${DOCKER_TAG_12C2:-12c-r2-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" - ORACLE_VERSION="${DOCKER_TAG_18:-18c-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" + - ORACLE_VERSION="${DOCKER_TAG_19:-19c-se2-small}" CONNECTION_STR='127.0.0.1:1521/ORCLCDB' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs" cache: pip: true diff --git a/.travis/install.sh b/.travis/install.sh index e37cfa35f..bb117c67c 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -10,7 +10,7 @@ set verify off --alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6003,6009,6010,7206)'; alter session set plsql_optimize_level=0; -@install_headless.sql $UT3_OWNER $UT3_OWNER_PASSWORD +@install_headless_with_trigger.sql $UT3_OWNER $UT3_OWNER_PASSWORD SQL #Run this step only on second child job (12.1 - at it's fastest) @@ -25,14 +25,18 @@ if [[ "${TRAVIS_JOB_NUMBER}" =~ \.2$ ]]; then set verify off @uninstall_all.sql $UT3_OWNER + whenever sqlerror exit failure rollback declare v_leftover_objects_count integer; begin select sum(cnt) into v_leftover_objects_count - from (select count(1) cnt from dba_objects where owner = '$UT3_OWNER' - union all - select count(1) cnt from dba_synonyms where table_owner = '$UT3_OWNER' + from ( + select count(1) cnt from dba_objects where owner = '$UT3_OWNER' + where object_name not like 'PLSQL_PROFILER%' and object_name not like 'DBMSPCC_%' + union all + select count(1) cnt from dba_synonyms where table_owner = '$UT3_OWNER' + where table_name not like 'PLSQL_PROFILER%' and table_name not like 'DBMSPCC_%' ); if v_leftover_objects_count > 0 then raise_application_error(-20000, 'Not all objects were successfully uninstalled - leftover objects count='||v_leftover_objects_count); @@ -47,6 +51,8 @@ SQL alter session set plsql_optimize_level=0; @install.sql $UT3_OWNER + @install_ddl_trigger.sql $UT3_OWNER + @create_synonyms_and_grants_for_public.sql $UT3_OWNER SQL fi @@ -60,27 +66,37 @@ grant select any dictionary to $UT3_OWNER; grant create any procedure, drop any procedure, execute any procedure to $UT3_OWNER; SQL -#Create user that will own the tests +#Create user that will own the tests that are relevant to internal framework time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL set feedback off @create_utplsql_owner.sql $UT3_TESTER $UT3_TESTER_PASSWORD $UT3_TABLESPACE - ---needed for testing distributed transactions -grant create public database link to $UT3_TESTER; -grant drop public database link to $UT3_TESTER; -set feedback on ---Needed for testing coverage outside of main UT3 schema. -grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, select any dictionary to $UT3_TESTER; -revoke execute on dbms_crypto from $UT3_TESTER; -grant create job to $UT3_TESTER; +--needed for disabling DDL trigger and testint parser without trigger enabled/present +grant alter any trigger to ut3_tester; +grant administer database trigger to $UT3_TESTER; exit SQL -#Create additional UT3$USER# to test for special characters +#Create additional UT3$USER# to test for special characters and front end API testing time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL set feedback off @create_utplsql_owner.sql $UT3_USER $UT3_USER_PASSWORD $UT3_TABLESPACE ---Grant UT3 framework to UT3$USER# +--Grant UT3 framework to min user @create_user_grants.sql $UT3_OWNER $UT3_USER exit SQL + +#Create additional UT3_TESTER_HELPER that will provide a functions to allow min grant test user setup test +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +@create_utplsql_owner.sql $UT3_TESTER_HELPER $UT3_TESTER_HELPER_PASSWORD $UT3_TABLESPACE +--needed for testing distributed transactions +grant create public database link to $UT3_TESTER_HELPER; +grant drop public database link to $UT3_TESTER_HELPER; +set feedback on +--Needed for testing coverage outside of main UT3 schema. +grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type, select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table, select any dictionary, create any synonym, drop any synonym to $UT3_TESTER_HELPER; +grant create job to $UT3_TESTER_HELPER; +--Needed to allow for enable/disable of annotation triggers +grant administer database trigger to $UT3_TESTER_HELPER; +exit +SQL diff --git a/.travis/install_utplsql_release.sh b/.travis/install_utplsql_release.sh index 889e098da..6dc56c3f3 100755 --- a/.travis/install_utplsql_release.sh +++ b/.travis/install_utplsql_release.sh @@ -36,9 +36,14 @@ end; / SQL +INSTALL_FILE="install_headless_with_trigger.sql" +if [[ ! -f "${INSTALL_FILE}" ]]; then + INSTALL_FILE="install_headless.sql" +fi + "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <45 + Row No. 1 - Expected: 47 +``` + + + +Example of exclude + Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is excluded. This option can be useful in scenarios where you need to narrow-down the scope of test so that the test is only focused on very specific data. @@ -351,7 +431,7 @@ Unable to join sets: Please make sure that your join clause is not refferring to collection element ``` -***Note*** +**Note** >`join_by` option is slower to process as it needs to perform a cursor join. ## Defining item lists in option @@ -424,3 +504,5 @@ Finished in .046193 seconds 1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` + + diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index 4e888ee95..bf8137c70 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Annotations @@ -38,6 +38,7 @@ We strongly recommend putting package level annotations at the very top of packa | `--%disabled` | Package/procedure | Used to disable a suite or a test. Disabled suites/tests do not get executed, they are however marked and reported as disabled in a test run. | | `--%context()` | Package | Denotes start of a named context (sub-suite) in a suite package | | `--%endcontext` | Package | Denotes end of a nested context (sub-suite) in a suite package | +| `--%tags` | Package/procedure | Used to label a test or a suite for purpose of identification | ### Suite @@ -823,7 +824,7 @@ See [beforeall](#Beforeall) for more examples. Indicates specific setup procedure(s) to be executed for a test. The procedure(s) can be located either: - within current package (package name is optional) - within another package - + The annotation need to be placed alongside `--%test` annotation. The `--%beforetest` procedures are executed after invoking all `--%beforeeach` for a test. @@ -911,7 +912,7 @@ Finished in .015185 seconds Indicates specific cleanup procedure(s) to be executed for a test. The procedure(s) can be located either: - within current package (package name is optional) - within another package - + The annotation need to be placed alongside `--%test` annotation. If a test is marked as disabled the `--%aftertest` procedures are not invoked for that test. @@ -1221,6 +1222,98 @@ Finished in .035261 seconds ``` + +### Tags + +Tag is a label attached to the test or a suite path. It is used for identification and execution a group of tests / suites that share same tag. + +It allows us to group a tests / suites using a various categorization and place a test / suite in multiple buckets. Same tests can be group with other tests based on the functionality , frequency, type of output etc. + +e.q. + +```sql +--%tags(batch,daily,csv) +``` + +or + +```sql +--%tags(api,online,json) +``` + + + +Tags are defined as a coma separated list. When executing a test run with tag filter applied, framework will find all tests associated with given tags and execute them. Framework applies `OR` logic when resolving a tags so any tests / suites that match at least one tag will be included in the test run. + +When a suite gets tagged all of its children will automatically inherit a tag and get executed along the parent. Parent suit tests are not executed. but a suitepath hierarchy is kept. + +Sample tag package. + +```sql +create or replace package ut_sample_test IS + + --%suite(Sample Test Suite) + --%tag(suite1) + + --%test(Compare Ref Cursors) + --%tag(test1,sample) + procedure ut_refcursors1; + + --%test(Run equality test) + --%tag(test2,sample) + procedure ut_test; + +end ut_sample_test; +/ + +create or replace package body ut_sample_test is + + procedure ut_refcursors1 is + v_actual sys_refcursor; + v_expected sys_refcursor; + begin + open v_expected for select 1 as test from dual; + open v_actual for select 2 as test from dual; + + ut.expect(v_actual).to_equal(v_expected); + end; + + procedure ut_test is + begin + ut.expect(1).to_equal(0); + end; + +end ut_sample_test; +/ +``` + +Execution of the test is done by using a parameter `a_tags` + +```sql +select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'suite1')); +select * from table(ut.run(a_tags => 'test1,test2')); +select * from table(ut.run(a_tags => 'sample')); + +begin + ut.run(a_path => 'ut_sample_test',a_tags => 'suite1'); +end; +/ + +exec ut.run('ut_sample_test', a_tags => 'sample'); +``` + + + +Tags should adhere to following rules: + +- tags are case sensitive +- tags cannot be an empty string +- tags cannot contain spaces e.g. to create a multi-word `tag` please use underscores,dashes, dots etc. e.g. `test_of_batch` +- tags with empty spaces will be ignored during execution +- tags can contain special characters + + + ### Suitepath It is very likely that the application for which you are going to introduce tests consists of many different packages, procedures and functions. @@ -1346,9 +1439,9 @@ If `--%throws` annotation is specified with arguments and exception raised is no The framework will raise a warning, when `--%throws` annotation has invalid arguments or when no arguments were provided. Annotation `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. - + Please note that `NO_DATA_FOUND` exception is a special case in Oracle. To capture it use `NO_DATA_FOUND` named exception or `-1403` exception No. - +​ Example: ```sql create or replace package exc_pkg is diff --git a/docs/userguide/best-practices.md b/docs/userguide/best-practices.md index b47b90c91..1aa202e58 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.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Best Practices diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md index 4f2a30688..c24bfae19 100644 --- a/docs/userguide/coverage.md +++ b/docs/userguide/coverage.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-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 2a220efad..d772aed53 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.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Exception handling and reporting diff --git a/docs/userguide/expectations.md b/docs/userguide/expectations.md index 25de3c652..ccb88f21c 100644 --- a/docs/userguide/expectations.md +++ b/docs/userguide/expectations.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-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. @@ -272,7 +272,9 @@ begin end; ``` -Parameters `a_mask` and `a_escape_char` represent valid parameters of the [Oracle LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF52142) +Parameters `a_mask` and `a_escape_char` represent valid parameters of the [Oracle LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF52142). + +If you use Oracle Database version 11.2.0.4, you may run into Oracle Bug 14402514: WRONG RESULTS WITH LIKE ON CLOB USING ESCAPE CHARACTER. In this case we recommend to use `match` instead of `be_like`. ## be_not_null @@ -317,7 +319,7 @@ end; ## have_count Unary matcher that validates if the provided dataset count is equal to expected value. -Can be used with `refcursor` or `table type` +Can be used with `refcursor` , `json`or `table type` Usage: ```sql @@ -1175,7 +1177,218 @@ Finished in .048181 seconds ``` + +# Comparing Json objects + +utPLSQL is capable of comparing json data-types on Oracle 12.2 and above. + +### Notes on comparison of json data + +- Json data can contain objects, scalar or arrays. +- During comparison of json objects the order doesn't matter. +- During comparison of json arrays the index of element is taken into account +- To compare json you have to make sure its type of `json_element_t` or its subtypes + + + +Some examples of using json data-types in matcher are : + +```sql +create or replace package test_expectations_json is + + --%suite(json expectations) + + --%test(Gives success for identical data) + procedure success_on_same_data; +end; +/ + +create or replace package body test_expectations_json is + + procedure success_on_same_data is + l_expected json_element_t; + l_actual json_element_t; + begin + -- Arrange + l_expected := json_element_t.parse(' +{ + "Actors":[ + { + "name":"Tom Cruise", + "age":56, + "Born At":"Syracuse, NY", + "Birthdate":"July 3, 1962", + "photo":"https://jsonformatter.org/img/tom-cruise.jpg", + "wife":null, + "weight":67.5, + "hasChildren":true, + "hasGreyHair":false, + "children":[ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name":"Robert Downey Jr.", + "age":53, + "Born At":"New York City, NY", + "Birthdate":"April 4, 1965", + "photo":"https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife":"Susan Downey", + "weight":77.1, + "hasChildren":true, + "hasGreyHair":false, + "children":[ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + ] +}'); + + l_actual := json_element_t.parse(' +{ + "Actors":[ + { + "name":"Tom Cruise", + "age":56, + "Born At":"Syracuse, NY", + "Birthdate":"July 3, 1962", + "photo":"https://jsonformatter.org/img/tom-cruise.jpg", + "wife":null, + "weight":67.5, + "hasChildren":true, + "hasGreyHair":false, + "children":[ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name":"Robert Downey Jr.", + "age":53, + "Born At":"New York City, NY", + "Birthdate":"April 4, 1965", + "photo":"https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife":"Susan Downey", + "weight":77.1, + "hasChildren":true, + "hasGreyHair":false, + "children":[ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + ] +}'); + + ut3.ut.expect( l_actual ).to_equal( l_actual ); + + end; +end; +/ +``` + +It is possible to use a PL/SQL to extract a piece of JSON and compare it as follow + +```sql +create or replace package test_expectations_json is + + --%suite(json expectations) + + --%test(Gives success for identical pieces of two different jsons) + procedure to_diff_json_extract_same; + +end; +/ + +create or replace package body test_expectations_json is + + procedure to_diff_json_extract_same as + l_expected json_object_t; + l_actual json_object_t; + l_array_actual json_array_t; + l_array_expected json_array_t; + begin + -- Arrange + l_expected := json_object_t.parse(' { + "Actors": [ + { + "name": "Tom Cruise", + "age": 56, + "Born At": "Syracuse, NY", + "Birthdate": "July 3, 1962", + "photo": "https://jsonformatter.org/img/tom-cruise.jpg", + "wife": null, + "weight": 67.5, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name": "Robert Downey Jr.", + "age": 53, + "Born At": "New York City, NY", + "Birthdate": "April 4, 1965", + "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife": "Susan Downey", + "weight": 77.1, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + ] + }' + ); + + l_actual := json_object_t.parse(' { + "Actors": + { + "name": "Krzystof Jarzyna", + "age": 53, + "Born At": "Szczecin", + "Birthdate": "April 4, 1965", + "photo": "niewidzialny", + "wife": "Susan Downey", + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + }' + ); + + l_array_actual := json_array_t(json_query(l_actual.stringify,'$.Actors.children')); + l_array_expected := json_array_t(json_query(l_expected.stringify,'$.Actors[1].children')); + --Act + ut3.ut.expect(l_array_actual).to_equal(l_array_expected); + + end; +end; +/ +``` + + + + + + + # Negating a matcher + Expectations provide a very convenient way to perform a check on a negated matcher. Syntax to check for matcher evaluating to true: @@ -1209,21 +1422,21 @@ Since NULL is neither *true* nor *false*, both expectations will report failure. The matrix below illustrates the data types supported by different matchers. -| Matcher | blob | boolean | clob | date | number | timestamp | timestamp
with
timezone | timestamp
with
local
timezone | varchar2 | interval
year
to
month | interval
day
to
second | cursor | nested
table
/ varray | object | -| :---------------------- | :--: | :-----: | :--: | :--: | :----: | :-------: | :---------------------------: | :------------------------------------: | :------: | :-----------------------------: | :-----------------------------: | :----: | :-------------------------: | :----: | -| **be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -| **be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -| **be_false** | | X | | | | | | | | | | | | | -| **be_true** | | X | | | | | | | | | | | | | -| **be_greater_than** | | | | X | X | X | X | X | | X | X | | | | -| **be_greater_or_equal** | | | | X | X | X | X | X | | X | X | | | | -| **be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | | -| **be_less_than** | | | | X | X | X | X | X | | X | X | | | | -| **be_between** | | | | X | X | X | X | X | X | X | X | | | | -| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | -| **contain** | | | | | | | | | | | | X | X | X | -| **match** | | | X | | | | | | X | | | | | | -| **be_like** | | | X | | | | | | X | | | | | | -| **be_empty** | X | | X | | | | | | | | | X | X | | -| **have_count** | | | | | | | | | | | | X | X | | +| Matcher | blob | boolean | clob | date | number | timestamp | timestamp
with
timezone | timestamp
with
local
timezone | varchar2 | interval
year
to
month | interval
day
to
second | cursor | nested
table
/ varray | object | json | +| :---------------------: | :--: | :-----: | :--: | :--: | :----: | :-------: | :---------------------------: | :------------------------------------: | :------: | :-----------------------------: | :-----------------------------: | :----: | :-------------------------: | :----: | :--: | +| **be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | +| **be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | +| **be_false** | | X | | | | | | | | | | | | | | +| **be_true** | | X | | | | | | | | | | | | | | +| **be_greater_than** | | | | X | X | X | X | X | | X | X | | | | | +| **be_greater_or_equal** | | | | X | X | X | X | X | | X | X | | | | | +| **be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | | | +| **be_less_than** | | | | X | X | X | X | X | | X | X | | | | | +| **be_between** | | | | X | X | X | X | X | X | X | X | | | | | +| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | +| **contain** | | | | | | | | | | | | X | X | X | | +| **match** | | | X | | | | | | X | | | | | | | +| **be_like** | | | X | | | | | | X | | | | | | | +| **be_empty** | X | | X | | | | | | | | | X | X | | X | +| **have_count** | | | | | | | | | | | | X | X | | X | diff --git a/docs/userguide/getting-started.md b/docs/userguide/getting-started.md index 6f59dc759..42e4cea4b 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.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Getting started with TDD and utPLSQL diff --git a/docs/userguide/install.md b/docs/userguide/install.md index 0a47fcfd1..bf4558ca9 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Downloading latest version of utPLSQL @@ -9,7 +9,7 @@ To download latest version of utPLSQL from github on both Unix/Linux as well as ```bash #!/bin/bash # Get the url to latest release "zip" file -UTPLSQL_DOWNLOAD_URL=$(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') +UTPLSQL_DOWNLOAD_URL=$(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip\"" | sed 's/"//g') # Download the latest release "zip" file curl -Lk "${UTPLSQL_DOWNLOAD_URL}" -o utPLSQL.zip # Extract downloaded "zip" file @@ -19,7 +19,7 @@ unzip -q utPLSQL.zip You may download with a one-liner if that is more convenient. ```bash #!/bin/bash -curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') +curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip\"" | sed 's/"//g') ``` ## Windows @@ -72,16 +72,44 @@ The utPLSQL may be installed on any supported version of Oracle Database [see](h * 12c * 12c R2 * 18c +* 19c # Headless installation -To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql` as SYSDBA. +utPLSQL can be installed with DDL trigger, to enable tracking of DDL changes to your unit test packages. +This is the recommended installation approach, when you want to compile and run unit test packages in a schema containing huge amount of database packages (for example Oracle EBS installation schema). +The reason for having DDL trigger is to enable in-time annotation parsing for utPLSQL. +Without DDL trigger, utPLSQL needs to investigate your schema objects last_ddl_timestamp each time tests are executed to check if any of DB packages were changed in given schema and if they need scanning for annotation changes. +This process can be time-consuming if DB schema is large. -The script accepts three optional parameters that define: +The headless scripts accept three optional parameters that define: - username to create as owner of utPLSQL (default `ut3`) - password for owner of utPLSQL (default `XNtxj8eEgA6X6b6f`) - tablespace to use for storage of profiler data (default `users`) +The scripts need to be executed by `SYSDBA`, in order to grant access to `DBMS_LOCK` and `DBMS_CRYPTO` system packages. + +**Note:** +> Grant on `DBMS_LOCK` is required only for installation on Oracle versions below 18c. For versions 18c and above, utPLSQL uses `DBMS_SESSION.SLEEP` so access to `DBMS_LOCK` package is no longer needed. + +**Note:** +> The user performing the installation must have the `ADMINISTER DATABASE TRIGGER` privilege. This is required for installation of trigger that is responsible for parsing annotations at at compile-time of a package. + +**Note:** +> When installing with DDL trigger, utPLSQL will not be registering unit tests for any of oracle-maintained schemas. +For Oracle 11g following users are excluded: +> ANONYMOUS, APPQOSSYS, AUDSYS, DBSFWUSER, DBSNMP, DIP, GGSYS, GSMADMIN_INTERNAL, GSMCATUSER, GSMUSER, ORACLE_OCM, OUTLN, REMOTE_SCHEDULER_AGENT, SYS, SYS$UMF, SYSBACKUP, SYSDG, SYSKM, SYSRAC, SYSTEM, WMSYS, XDB, XS$NULL +> +> For Oracle 12c and above the users returned by below query are excluded by utPLSQL: +> +>```sql +> select username from all_users where oracle_maintained='Y'; +>``` + +## Installation without DDL trigger + +To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql` as SYSDBA. + Example invocation of the script from command line: ```bash cd source @@ -94,16 +122,34 @@ cd source sqlplus sys/sys_pass@db as sysdba @install_headless.sql utp3 my_verySecret_password utp3_tablespace ``` -The script needs to be executed by `SYSDBA`, in order to grant access to `DBMS_LOCK` and `DBMS_CRYPTO` system packages. +## Installation with DDL trigger + +To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless_with_trigger.sql` as SYSDBA. + +Example invocation of the script from command line: +```bash +cd source +sqlplus sys/sys_pass@db as sysdba @install_headless_with_trigger.sql +``` -*Note:* Grant on `DBMS_LOCK` is required on Oracle versions below 18c +Invoking script with parameters: +```bash +cd source +sqlplus sys/sys_pass@db as sysdba @install_headless_with_trigger.sql utp3 my_verySecret_password utp3_tablespace +``` +**Note:** +>When installing utPLSQL into database with existing unit test packages, utPLSQL will not be able to already-existing unit test packages. When utPSLQL was installed with DDL trigger, you have to do one of: +>- Recompile existing Unit Test packages to make utPLSQL aware of their existence +>- Invoke `exec ut_runner.rebuild_annotation_cache(a_schema_name=> ... );` for every schema containing unit tests in your database +> +> Steps above are required to assure annotation cache is populated properly from existing objects. Rebuilding annotation cache might be faster than code recompilation. # Recommended Schema It is highly recommended to install utPLSQL in it's own schema. You are free to choose any name for this schema. Installing uPLSQL into shared schema is really not recommended as you loose isolation of framework. -If the installation and utPLSQL owner user is one and the same, the user must have the following Oracle system permissions before you can proceed with the installation. +If the installing user and utPLSQL owner is one and the same, the user must have the following Oracle system permissions before you can proceed with the installation. - CREATE SESSION - CREATE PROCEDURE @@ -113,6 +159,7 @@ If the installation and utPLSQL owner user is one and the same, the user must ha - CREATE VIEW - CREATE SYNONYM - ALTER SESSION + - CREATE TRIGGER In addition the user must be granted the execute privilege on `DBMS_LOCK` and `DBMS_CRYPTO` packages. @@ -123,7 +170,7 @@ It is up to DBA to maintain the storage of the profiler tables. # Manual installation procedure -### Creating schema for utPLSQL +## Creating schema for utPLSQL To create the utPLSQL schema and grant all the required privileges execute script `create_utplsql_owner.sql` from the `source` directory with parameters: - `user name` - the name of the user that will own of utPLSQL object @@ -136,8 +183,8 @@ cd source sqlplus sys/sys_password@database as sysdba @create_utPLSQL_owner.sql ut3 ut3 users ``` -### Installing utPLSQL -To install the utPLSQL framework into your database run the `/source/install.sql` script and provide `schema_name` where utPLSQL is to be installed. +## Installing utPLSQL +To install the utPLSQL framework into your database, go to `source` directory, run the `install.sql` providing the `schema_name` for utPLSQL as parameter. Schema must be created prior to calling the `install` script. You may install utPLSQL from any account that has sufficient privileges to create objects in other users schema. @@ -147,7 +194,26 @@ cd source sqlplus admin/admins_password@database @install.sql ut3 ``` -### Allowing other users to access the utPLSQL framework +## Installing DDL trigger +To minimize startup time of utPLSQL framework (especially on a database with large schema) it is recommended to install utPLSQL DDL trigger to enable utPLSQL annotation to be updated at compile-time. + +It's recommended to install DDL trigger when connected as `SYSDBA` user. Trigger is created in utPLSQL schema. +If using the owner schema of utPLSQL to install trigger, the owner needs to have `ADMINISTER DATABASE TRIGGER` and `CREATE TRIGGER` system privileges. +If using different user to install trigger, the user needs to have `ADMINISTER DATABASE TRIGGER` and `CREATE ANY TRIGGER` system privileges. + +To install DDL trigger go to `source` directory, run the `install_ddl_trigger.sql` providing the `schema_name` for utPLSQL as parameter. + +Example invocation: +```bash +cd source +sqlplus admin/admins_password@database @install_ddl_trigger.sql ut3 +``` + +**Note:** +>Trigger can be installed ant any point in time. + + +## Allowing other users to access the utPLSQL framework In order to allow other users to access utPLSQL, synonyms must be created and privileges granted. You have two options: diff --git a/docs/userguide/querying_suites.md b/docs/userguide/querying_suites.md index 50aa661f5..868f69556 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.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Qyerying for test suites @@ -22,21 +22,22 @@ Querying the data from function provides the follwing details: - `item_line_no` - line_number where annotation identifying the item exists - `path` - suitepath of the item - `disabled_flag` - (0/1) indicator if item is disabled by --%disabled annotation - +- `tags` - tags associated with suites + To get list of all test suites in current schema ```sql select * from table(ut_runner.get_suites_info()) where item_type = 'UT_SUITE'; -``` +``` To get list of all tests for test suite `TEST_STUFF` in current user schema ```sql select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; -``` +``` To get a full information about suite `TEST_STUFF` including suite description, all contexts and tests in a suite ```sql select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; -``` +``` ## Checking if schema contains tests diff --git a/docs/userguide/reporters.md b/docs/userguide/reporters.md index 104795ded..e583bcbda 100644 --- a/docs/userguide/reporters.md +++ b/docs/userguide/reporters.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-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 3703fa4d8..79f7569b9 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.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Running tests @@ -47,6 +47,7 @@ The examples below illustrate different ways and options to invoke `ut.run` proc ```sql alter session set current_schema=hr; +set serveroutput on begin ut.run(); end; @@ -55,6 +56,7 @@ Executes all tests in current schema (_HR_). ```sql +set serveroutput on begin ut.run('HR'); end; @@ -63,6 +65,7 @@ Executes all tests in specified schema (_HR_). ```sql +set serveroutput on begin ut.run('hr:com.my_org.my_project'); end; @@ -73,6 +76,7 @@ Check the [annotations documentation](annotations.md) to find out about suitepat ```sql +set serveroutput on begin ut.run('hr.test_apply_bonus'); end; @@ -81,6 +85,7 @@ Executes all tests from package _hr.test_apply_bonus_. ```sql +set serveroutput on begin ut.run('hr.test_apply_bonus.bonus_cannot_be_negative'); end; @@ -89,6 +94,7 @@ Executes single test procedure _hr.test_apply_bonus.bonus_cannot_be_negative_. ```sql +set serveroutput on begin ut.run(ut_varchar2_list('hr.test_apply_bonus','cust')); end; @@ -96,6 +102,7 @@ end; Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. ```sql +set serveroutput on begin ut.run(ut_varchar2_list('hr.test_apply_bonus,cust)'); end; @@ -104,6 +111,7 @@ end; Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_. ```sql +set serveroutput on begin ut.run('hr.test_apply_bonus,cust'); end; @@ -124,6 +132,7 @@ The `ut.run` procedures and functions accept `a_reporter` attribute that defines You can execute any set of tests with any of the predefined reporters. ```sql +set serveroutput on begin ut.run('hr.test_apply_bonus', ut_junit_reporter()); end; @@ -133,26 +142,6 @@ Executes all tests from package _HR.TEST_APPLY_BONUS_ and provide outputs to DBM For details on build-in reporters look at [reporters documentation](reporters.md). -## Keeping uncommited data after test-run - -utPLSQL by default runs tests in autonomous transaction and performs automatic rollback to assure that tests do not impact one-another and do not have impact on the current session in your IDE. - -If you would like to keep your uncommited data persisted after running tests, you can do so by using `a_force_manual_rollback` flag. -Setting this flag to true has following side-effects: - -- test execution is done in current transaction - if while running tests commit or rollback is issued your current session data will get commited too. -- automatic rollback is forced to be disabled in test-run even if it was explicitly enabled by using annotation `--%rollback(manual) - -Example invocation: -```sql -begin - ut.run('hr.test_apply_bonus', a_force_manual_rollback => true); -end; -``` - - -This option is not anvailable when running tests using `ut.run` as a table function. - ## ut.run functions The `ut.run` functions provide exactly the same functionality as the `ut.run` procedures. @@ -160,6 +149,10 @@ You may use the same sets of parameters with both functions and procedures. The only difference is the output of the results. Functions provide output as a pipelined stream and therefore need to be executed as select statements. +**Note:** +>When running tests with `ut.run` functions, whole test run is executed as autonomous transaction. +At the end of the run, the transaction is automatically rolled-back and all uncommitted changes are reverted. + Example. ```sql select * from table(ut.run('hr.test_apply_bonus', ut_junit_reporter())); @@ -180,7 +173,83 @@ The concept is pretty simple. - as a separate thread, start `ut_runner.run` and pass reporters with previously defined output_ids. - for each reporter start a separate thread and read outputs from the `ut_output_buffer.get_lines` table function by providing the output_id defined in the main thread. -# Reports characterset encoding +# Order of test execution + +## Default order + +When unit tests are executed without random order, they are ordered by: +- schema name +- suite path or test package name if `--%suitepath` was not specified for that package +- `--%test` line number in package + +## Random order + +You can force a test run to execute tests in random order by providing one of options to `ut.run`: +- `a_random_test_order` - true/false for procedures and 1/0 for functions +- `a_random_test_order_seed` - positive number in range of 1 .. 1 000 000 000 + +When tests are executed with random order, randomization is applied to single level of suitepath hierarchy tree. +This is needed to maintain visibility and accessibility of common setup/cleanup `beforeall`/`afterall` in tests. + +Example: +```sql +set serveroutput on +begin + ut.run('hr.test_apply_bonus', a_random_test_order => true); +end; +``` + +```sql +select * from table(ut.run('hr.test_apply_bonus', a_random_test_order => 1)); +``` + +When running with random order, the default report (`ut_documentation_reporter`) will include information about the random test run seed. +Example output: +``` +... +Finished in .12982 seconds +35 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) +Tests were executed with random order seed '302980531'. +``` + +If you want to re-run tests using previously generated seed, you may do so by running them with parameter `a_random_test_order_seed` +Example: +```sql +set serveroutput on +begin + ut.run('hr.test_apply_bonus', a_random_test_order_seed => 302980531); +end; +``` + +```sql +select * from table(ut.run('hr.test_apply_bonus', a_random_test_order_seed => 302980531)); +``` + +**Note** +>Random order seed must be a positive number within range of 1 .. 1 000 000 000. + +# Keeping uncommitted data after test-run + +utPLSQL by default runs tests in autonomous transaction and performs automatic rollback to assure that tests do not impact one-another and do not have impact on the current session in your IDE. + +If you would like to keep your uncommitted data persisted after running tests, you can do so by using `a_force_manual_rollback` flag. +Setting this flag to true has following side-effects: + +- test execution is done in current transaction - if while running tests commit or rollback is issued your current session data will get commited too. +- automatic rollback is forced to be disabled in test-run even if it was explicitly enabled by using annotation `--%rollback(manual) + +Example invocation: +```sql +set serveroutput on +begin + ut.run('hr.test_apply_bonus', a_force_manual_rollback => true); +end; +``` + +**Note:** +>This option is not available when running tests using `ut.run` as a table function. + +# Reports character-set encoding To get properly encoded reports, when running utPLSQL with HTML/XML reports on data containing national characters you need to provide your client character set when calling `ut.run` functions and procedures. diff --git a/docs/userguide/upgrade.md b/docs/userguide/upgrade.md index b803a671a..2c93c439f 100644 --- a/docs/userguide/upgrade.md +++ b/docs/userguide/upgrade.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.1.6.2729-blue.svg) +![version](https://img.shields.io/badge/version-v3.1.7.3085-blue.svg) # Upgrading from version 2 diff --git a/readme.md b/readme.md index 5fc53ed08..315124db6 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -![utPLSQL v3 | Powerful PL/SQL Unit Testing Framework](docs/images/utPLSQL-testing-framework-transparent_120.png) +![utPLSQL v3 | Testing Framework for PL/SQL](docs/images/utPLSQL-testing-framework-transparent_120.png) ---------- @@ -248,4 +248,4 @@ The utPLSQL project is community-driven and is not commercially motivated. Nonet utPLSQL has been supported by Redgate in the form of sponsored stickers and t-shirts. Thank you for helping us spreading the word! - \ No newline at end of file + diff --git a/sonar-project.properties b/sonar-project.properties index c137871ee..2b1270d6e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.projectKey=utPLSQL # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=utPLSQL -sonar.projectVersion=v3.1.6 +sonar.projectVersion=v3.1.7 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. @@ -10,6 +10,7 @@ sonar.projectVersion=v3.1.6 # the sonar-project.properties file. sonar.sources=./source sonar.coverageReportPaths=coverage.xml +sonar.coverage.exclusions=**/*.sql,**/*.pks sonar.tests=./test sonar.testExecutionReportPaths=./test_results.xml sonar.links.issue=https://github.com/utPLSQL/utPLSQL/issues @@ -20,7 +21,7 @@ sonar.plsql.file.suffixes=sql,tab,pkb,tpb sonar.language=plsql -sonar.exclusions=create_synonyms_and_grants_for_public.sql, create_user_grants.sql, create_user_synonyms.sql, create_utplsql_owner.sql, define_ut3_owner_param.sql, install.sql, install_above_12_1.sql, install_component.sql, install_headless.sql, uninstall.sql, uninstall_all.sql, uninstall_coverage_tables.sql +sonar.exclusions=**/*.sql sonar.pullrequest.provider=github sonar.pullrequest.github.endpoint=https://api.github.com/ diff --git a/source/api/ut.pkb b/source/api/ut.pkb index eb4a06bc3..3b94a2bf7 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -2,7 +2,7 @@ create or replace package body ut is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -93,6 +93,11 @@ create or replace package body ut is return ut_expectation(ut_data_value_dsinterval(a_actual), a_message); end; + function expect(a_actual in json_element_t , a_message varchar2 := null) return ut_expectation_json is + begin + return ut_expectation_json(ut_data_value_json(a_actual), a_message); + end; + procedure fail(a_message in varchar2) is begin ut_expectation_processor.report_failure(a_message); @@ -113,12 +118,15 @@ create or replace package body ut is a_paths ut_varchar2_list, a_reporter in out nocopy ut_reporter_base, a_color_console integer, - a_coverage_schemes ut_varchar2_list := null, + a_coverage_schemes ut_varchar2_list, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings, a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list, - a_client_character_set varchar2 := null + a_client_character_set varchar2, + a_random_test_order integer, + a_random_test_order_seed positive, + a_tags varchar2 := null ) is pragma autonomous_transaction; begin @@ -133,7 +141,11 @@ create or replace package body ut is a_include_objects, a_exclude_objects, gc_fail_on_errors, - a_client_character_set + a_client_character_set, + false, + ut_utils.int_to_boolean(a_random_test_order), + a_random_test_order_seed, + a_tags ); rollback; end; @@ -142,12 +154,15 @@ create or replace package body ut is a_paths ut_varchar2_list, a_reporter in out nocopy ut_reporter_base, a_color_console integer, - a_coverage_schemes ut_varchar2_list := null, + a_coverage_schemes ut_varchar2_list, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list, - a_client_character_set varchar2 := null + a_client_character_set varchar2, + a_random_test_order integer, + a_random_test_order_seed positive, + a_tags varchar2 := null ) is pragma autonomous_transaction; begin @@ -162,7 +177,11 @@ create or replace package body ut is a_include_objects, a_exclude_objects, gc_fail_on_errors, - a_client_character_set + a_client_character_set, + false, + ut_utils.int_to_boolean(a_random_test_order), + a_random_test_order_seed, + a_tags ); rollback; end; @@ -200,7 +219,10 @@ create or replace package body ut is a_test_file_mappings ut_file_mappings := null, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -214,7 +236,10 @@ create or replace package body ut is a_test_file_mappings, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + a_random_test_order, + a_random_test_order_seed, + a_tags ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -233,7 +258,10 @@ create or replace package body ut is a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -247,7 +275,10 @@ create or replace package body ut is a_test_files, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + a_random_test_order, + a_random_test_order_seed, + a_tags ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -267,7 +298,10 @@ create or replace package body ut is a_test_file_mappings ut_file_mappings := null, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -281,7 +315,10 @@ create or replace package body ut is a_test_file_mappings, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + a_random_test_order, + a_random_test_order_seed, + a_tags ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -301,7 +338,10 @@ create or replace package body ut is a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -315,7 +355,10 @@ create or replace package body ut is a_test_files, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + a_random_test_order, + a_random_test_order_seed, + a_tags ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -335,7 +378,10 @@ create or replace package body ut is a_test_file_mappings ut_file_mappings := null, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -349,7 +395,10 @@ create or replace package body ut is a_test_file_mappings, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + a_random_test_order, + a_random_test_order_seed, + a_tags ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -369,7 +418,10 @@ create or replace package body ut is a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -383,7 +435,10 @@ create or replace package body ut is a_test_files, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + a_random_test_order, + a_random_test_order_seed, + a_tags ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -404,7 +459,10 @@ create or replace package body ut is a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is l_reporter ut_reporter_base := a_reporter; begin @@ -421,7 +479,10 @@ create or replace package body ut is a_exclude_objects, gc_fail_on_errors, a_client_character_set, - a_force_manual_rollback + a_force_manual_rollback, + a_random_test_order, + a_random_test_order_seed, + a_tags ); else run_autonomous( @@ -433,7 +494,10 @@ create or replace package body ut is a_test_file_mappings, a_include_objects, a_exclude_objects, - a_client_character_set + a_client_character_set, + ut_utils.boolean_to_int(a_random_test_order), + a_random_test_order_seed, + a_tags ); end if; if l_reporter is of (ut_output_reporter_base) then @@ -452,7 +516,10 @@ create or replace package body ut is a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is l_reporter ut_reporter_base := a_reporter; begin @@ -466,7 +533,10 @@ create or replace package body ut is a_include_objects, a_exclude_objects, a_client_character_set, - a_force_manual_rollback + a_force_manual_rollback, + a_random_test_order, + a_random_test_order_seed, + a_tags ); end; @@ -479,7 +549,10 @@ create or replace package body ut is a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is begin ut.run( @@ -492,7 +565,10 @@ create or replace package body ut is a_include_objects, a_exclude_objects, a_client_character_set, - a_force_manual_rollback + a_force_manual_rollback, + a_random_test_order, + a_random_test_order_seed, + a_tags ); end; @@ -505,7 +581,10 @@ create or replace package body ut is a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is begin ut.run( @@ -518,7 +597,10 @@ create or replace package body ut is a_include_objects, a_exclude_objects, a_client_character_set, - a_force_manual_rollback + a_force_manual_rollback, + a_random_test_order, + a_random_test_order_seed, + a_tags ); end; @@ -532,7 +614,10 @@ create or replace package body ut is a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is begin ut.run( @@ -545,7 +630,10 @@ create or replace package body ut is a_include_objects, a_exclude_objects, a_client_character_set, - a_force_manual_rollback + a_force_manual_rollback, + a_random_test_order, + a_random_test_order_seed, + a_tags ); end; @@ -559,7 +647,10 @@ create or replace package body ut is a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is begin ut.run( @@ -572,10 +663,14 @@ create or replace package body ut is a_include_objects, a_exclude_objects, a_client_character_set, - a_force_manual_rollback + a_force_manual_rollback, + a_random_test_order, + a_random_test_order_seed, + a_tags ); end; + procedure set_nls is begin if g_nls_date_format is null then diff --git a/source/api/ut.pks b/source/api/ut.pks index 25c9e6493..ff75179b0 100644 --- a/source/api/ut.pks +++ b/source/api/ut.pks @@ -2,7 +2,7 @@ create or replace package ut authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -45,6 +45,8 @@ create or replace package ut authid current_user as function expect(a_actual in dsinterval_unconstrained, a_message varchar2 := null) return ut_expectation; + function expect(a_actual in json_element_t , a_message varchar2 := null) return ut_expectation_json; + procedure fail(a_message in varchar2); function run( @@ -55,7 +57,10 @@ create or replace package ut authid current_user as a_test_file_mappings ut_file_mappings := null, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined; function run( @@ -66,7 +71,10 @@ create or replace package ut authid current_user as a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined; function run( @@ -78,7 +86,10 @@ create or replace package ut authid current_user as a_test_file_mappings ut_file_mappings := null, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined; function run( @@ -90,7 +101,10 @@ create or replace package ut authid current_user as a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined; function run( @@ -102,7 +116,10 @@ create or replace package ut authid current_user as a_test_file_mappings ut_file_mappings := null, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined; function run( @@ -114,7 +131,10 @@ create or replace package ut authid current_user as a_test_files ut_varchar2_list, a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, - a_client_character_set varchar2 := null + a_client_character_set varchar2 := null, + a_random_test_order integer := 0, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) return ut_varchar2_rows pipelined; procedure run( @@ -126,7 +146,10 @@ create or replace package ut authid current_user as a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); procedure run( @@ -138,7 +161,10 @@ create or replace package ut authid current_user as a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); procedure run( @@ -151,7 +177,10 @@ create or replace package ut authid current_user as a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); procedure run( @@ -164,7 +193,10 @@ create or replace package ut authid current_user as a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); procedure run( @@ -177,7 +209,10 @@ create or replace package ut authid current_user as a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); procedure run( @@ -190,7 +225,10 @@ create or replace package ut authid current_user as a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); /** diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index 10485c346..2b8a10c92 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -2,7 +2,7 @@ create or replace package body ut_runner is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -88,13 +88,18 @@ create or replace package body ut_runner is a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean := false, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ) is - l_run ut_run; - l_coverage_schema_names ut_varchar2_rows; - l_exclude_object_names ut_object_names := ut_object_names(); - l_include_object_names ut_object_names; - l_paths ut_varchar2_list := ut_varchar2_list(); + l_run ut_run; + l_coverage_schema_names ut_varchar2_rows; + l_exclude_object_names ut_object_names := ut_object_names(); + l_include_object_names ut_object_names; + l_paths ut_varchar2_list := ut_varchar2_list(); + l_random_test_order_seed positive; + l_tags ut_varchar2_rows := ut_varchar2_rows(); begin ut_event_manager.initialize(); if a_reporters is not empty then @@ -107,7 +112,12 @@ create or replace package body ut_runner is ut_event_manager.trigger_event(ut_event_manager.gc_initialize); ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_run_info()); - + if a_random_test_order_seed is not null then + l_random_test_order_seed := a_random_test_order_seed; + elsif a_random_test_order then + dbms_random.seed( to_char(systimestamp,'yyyyddmmhh24missffff') ); + l_random_test_order_seed := trunc(dbms_random.value(1, 1000000000)); + end if; if a_paths is null or a_paths is empty or a_paths.count = 1 and a_paths(1) is null then l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema')); else @@ -121,7 +131,6 @@ create or replace package body ut_runner is ut_utils.save_dbms_output_to_cache(); ut_console_reporter_base.set_color_enabled(a_color_console); - if a_coverage_schemes is not empty then l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes); else @@ -131,7 +140,12 @@ create or replace package body ut_runner is if a_exclude_objects is not empty then l_exclude_object_names := to_ut_object_list(a_exclude_objects, l_coverage_schema_names); end if; - + + if a_tags is not null then + l_tags := l_tags multiset union distinct ut_utils.convert_collection( + ut_utils.trim_list_elements(ut_utils.filter_list(ut_utils.string_to_table(a_tags,','),ut_utils.gc_word_no_space)) + ); + end if; l_exclude_object_names := l_exclude_object_names multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names); l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names); @@ -144,10 +158,12 @@ create or replace package body ut_runner is l_include_object_names, set(a_source_file_mappings), set(a_test_file_mappings), - a_client_character_set + a_client_character_set, + l_random_test_order_seed, + l_tags ); - ut_suite_manager.configure_execution_by_path(l_paths, l_run.items); + ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, l_tags); if a_force_manual_rollback then l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true ); end if; diff --git a/source/api/ut_runner.pks b/source/api/ut_runner.pks index e111933b5..a6ba28556 100644 --- a/source/api/ut_runner.pks +++ b/source/api/ut_runner.pks @@ -2,7 +2,7 @@ create or replace package ut_runner authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -68,7 +68,10 @@ create or replace package ut_runner authid current_user is a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean := false, a_client_character_set varchar2 := null, - a_force_manual_rollback boolean := false + a_force_manual_rollback boolean := false, + a_random_test_order boolean := false, + a_random_test_order_seed positive := null, + a_tags varchar2 := null ); /** diff --git a/source/api/ut_suite_item_info.tpb b/source/api/ut_suite_item_info.tpb new file mode 100644 index 000000000..9b142acb0 --- /dev/null +++ b/source/api/ut_suite_item_info.tpb @@ -0,0 +1,38 @@ +create or replace type body ut_suite_item_info is + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2, + a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer, + a_tags ut_varchar2_rows) return self as result is + begin + self.object_owner := a_object_owner; + self.object_name := a_object_name; + self.item_name := a_item_name; + self.item_description := a_item_description; + self.item_type := a_item_type; + self.item_line_no := a_item_line_no; + self.path := a_path; + self.disabled_flag := a_disabled_flag; + self.tags := case + when a_tags is null then null + when a_tags.count = 0 then null + else ut_utils.to_string(ut_utils.table_to_clob(a_tags,',') ,a_quote_char => null) + end; + return; + end; +end; +/ diff --git a/source/api/ut_suite_item_info.tps b/source/api/ut_suite_item_info.tps index bf6fd6ecf..d37e89b59 100644 --- a/source/api/ut_suite_item_info.tps +++ b/source/api/ut_suite_item_info.tps @@ -1,7 +1,7 @@ create or replace type ut_suite_item_info as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -22,6 +22,10 @@ create or replace type ut_suite_item_info as object ( item_type varchar2( 250 ), -- the type of item (UT_SUITE/UT_SUITE_CONTEXT/UT_TEST) item_line_no integer, -- line_number where annotation identifying the item exists path varchar2( 4000 ),-- suitepath of the item - disabled_flag integer -- 0 (zero) if item is not disabled, 1 if item is disabled by --%disabled annotation + disabled_flag integer, -- 0 (zero) if item is not disabled, 1 if item is disabled by --%disabled annotation + tags varchar2(4000), + constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2, + a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer, + a_tags ut_varchar2_rows) return self as result ) / diff --git a/source/api/ut_suite_items_info.tps b/source/api/ut_suite_items_info.tps index d84ed9092..7c9ac33c3 100644 --- a/source/api/ut_suite_items_info.tps +++ b/source/api/ut_suite_items_info.tps @@ -1,7 +1,7 @@ create or replace type ut_suite_items_info as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/check_sys_grants.sql b/source/check_sys_grants.sql index e16869e54..a31e9a9e1 100644 --- a/source/check_sys_grants.sql +++ b/source/check_sys_grants.sql @@ -1,15 +1,15 @@ +define expected_grants = "&1" declare - c_expected_grants constant dbmsoutput_linesarray - := dbmsoutput_linesarray( - 'CREATE TYPE','CREATE VIEW','CREATE SYNONYM','CREATE SEQUENCE','CREATE PROCEDURE','CREATE TABLE' - ); + c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray( &expected_grants ); l_expected_grants dbmsoutput_linesarray := c_expected_grants; l_missing_grants varchar2(4000); begin if user != SYS_CONTEXT('userenv','current_schema') then for i in 1 .. l_expected_grants.count loop - l_expected_grants(i) := replace(l_expected_grants(i),' ',' ANY '); + if l_expected_grants(i) != 'ADMINISTER DATABASE TRIGGER' then + l_expected_grants(i) := replace(l_expected_grants(i),' ',' ANY '); + end if; end loop; end if; select listagg(' - '||privilege,CHR(10)) within group(order by privilege) diff --git a/source/core/annotations/ut_annotated_object.tps b/source/core/annotations/ut_annotated_object.tps index 1bfefed69..06a0f4a36 100644 --- a/source/core/annotations/ut_annotated_object.tps +++ b/source/core/annotations/ut_annotated_object.tps @@ -1,7 +1,7 @@ create type ut_annotated_object as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/annotations/ut_annotated_objects.tps b/source/core/annotations/ut_annotated_objects.tps index b7c01fe7a..c7b142a32 100644 --- a/source/core/annotations/ut_annotated_objects.tps +++ b/source/core/annotations/ut_annotated_objects.tps @@ -1,7 +1,7 @@ create type ut_annotated_objects as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/annotations/ut_annotation.tps b/source/core/annotations/ut_annotation.tps index 35af758c7..982c0348c 100644 --- a/source/core/annotations/ut_annotation.tps +++ b/source/core/annotations/ut_annotation.tps @@ -1,7 +1,7 @@ create type ut_annotation as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/annotations/ut_annotation_cache.sql b/source/core/annotations/ut_annotation_cache.sql index f9c9295cb..8baa6e75c 100644 --- a/source/core/annotations/ut_annotation_cache.sql +++ b/source/core/annotations/ut_annotation_cache.sql @@ -1,7 +1,7 @@ create table ut_annotation_cache ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/annotations/ut_annotation_cache_info.sql b/source/core/annotations/ut_annotation_cache_info.sql index fa7eabeec..e8dc2bfdb 100644 --- a/source/core/annotations/ut_annotation_cache_info.sql +++ b/source/core/annotations/ut_annotation_cache_info.sql @@ -1,7 +1,7 @@ create table ut_annotation_cache_info ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -18,6 +18,6 @@ create table ut_annotation_cache_info ( object_type varchar2(250) not null, parse_time timestamp not null, constraint ut_annotation_cache_info_pk primary key(cache_id), - constraint ut_annotation_cache_info_uk unique (object_owner, object_name, object_type) + constraint ut_annotation_cache_info_uk unique (object_owner, object_type, object_name) ) organization index; diff --git a/source/core/annotations/ut_annotation_cache_manager.pkb b/source/core/annotations/ut_annotation_cache_manager.pkb index 5c40be5b7..21151de8b 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pkb +++ b/source/core/annotations/ut_annotation_cache_manager.pkb @@ -1,7 +1,7 @@ create or replace package body ut_annotation_cache_manager as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -18,22 +18,40 @@ create or replace package body ut_annotation_cache_manager as procedure update_cache(a_object ut_annotated_object) is l_cache_id integer; + l_new_objects_count integer := 0; pragma autonomous_transaction; begin - update ut_annotation_cache_info i - set i.parse_time = systimestamp - where (i.object_owner, i.object_name, i.object_type) - in ((a_object.object_owner, a_object.object_name, a_object.object_type)) - returning cache_id into l_cache_id; - if sql%rowcount = 0 then - insert into ut_annotation_cache_info - (cache_id, object_owner, object_name, object_type, parse_time) - values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, systimestamp) + -- if not in trigger, or object has annotations + if ora_sysevent is null or a_object.annotations is not null and a_object.annotations.count > 0 then + + update ut_annotation_cache_info i + set i.parse_time = systimestamp + where (i.object_owner, i.object_name, i.object_type) + in ((a_object.object_owner, a_object.object_name, a_object.object_type)) returning cache_id into l_cache_id; + + if sql%rowcount = 0 then + + insert into ut_annotation_cache_info + (cache_id, object_owner, object_name, object_type, parse_time) + values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, systimestamp) + returning cache_id into l_cache_id; + l_new_objects_count := 1; + end if; + end if; - delete from ut_annotation_cache c - where cache_id = l_cache_id; + update ut_annotation_cache_schema s + set s.object_count = s.object_count + l_new_objects_count, s.max_parse_time = systimestamp + where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner; + + if sql%rowcount = 0 then + insert into ut_annotation_cache_schema s + (object_owner, object_type, object_count, max_parse_time) + values (a_object.object_owner, a_object.object_type, l_new_objects_count, systimestamp); + end if; + + delete from ut_annotation_cache c where cache_id = l_cache_id; if a_object.annotations is not null and a_object.annotations.count > 0 then insert into ut_annotation_cache @@ -73,17 +91,32 @@ create or replace package body ut_annotation_cache_manager as commit; end; + function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info is + l_result t_cache_schema_info; + begin + begin + select * + into l_result + from ut_annotation_cache_schema s + where s.object_type = a_object_type and s.object_owner = a_object_owner; + exception + when no_data_found then + null; + end; + return l_result; + end; + procedure remove_from_cache(a_objects ut_annotation_objs_cache_info) is pragma autonomous_transaction; begin delete from ut_annotation_cache_info i - where exists ( - select 1 from table (a_objects) o - where o.object_name = i.object_name - and o.object_type = i.object_type - and o.object_owner = i.object_owner - ); + where exists ( + select 1 from table (a_objects) o + where o.object_name = i.object_name + and o.object_type = i.object_type + and o.object_owner = i.object_owner + ); commit; end; @@ -139,6 +172,12 @@ create or replace package body ut_annotation_cache_manager as delete from ut_annotation_cache_info i where ' || l_filter using a_object_owner, a_object_type; + + execute immediate ' + delete from ut_annotation_cache_schema s + where ' || l_filter + using a_object_owner, a_object_type; + commit; end; diff --git a/source/core/annotations/ut_annotation_cache_manager.pks b/source/core/annotations/ut_annotation_cache_manager.pks index 1279c8cc3..4366cd536 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pks +++ b/source/core/annotations/ut_annotation_cache_manager.pks @@ -1,7 +1,7 @@ create or replace package ut_annotation_cache_manager authid definer as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ create or replace package ut_annotation_cache_manager authid definer as See the License for the specific language governing permissions and limitations under the License. */ - + subtype t_cache_schema_info is ut_annotation_cache_schema%rowtype; /** * Populates cache with information about object and it's annotations * Cache information for individual object is modified by this code @@ -34,6 +34,8 @@ create or replace package ut_annotation_cache_manager authid definer as */ function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_time timestamp) return sys_refcursor; + function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info; + /** * Removes cached information about annotations for objects on the list and updates parse_time in cache info table. * diff --git a/source/core/annotations/ut_annotation_cache_schema.sql b/source/core/annotations/ut_annotation_cache_schema.sql new file mode 100644 index 000000000..abab7385e --- /dev/null +++ b/source/core/annotations/ut_annotation_cache_schema.sql @@ -0,0 +1,21 @@ +create table ut_annotation_cache_schema ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + object_owner varchar2(250) not null, + object_type varchar2(250) not null, + object_count integer not null, + max_parse_time date not null, + constraint ut_annotation_cache_schema_pk primary key(object_owner, object_type) +) organization index; + diff --git a/source/core/annotations/ut_annotation_cache_seq.sql b/source/core/annotations/ut_annotation_cache_seq.sql index 1cc97086e..0a898e98e 100644 --- a/source/core/annotations/ut_annotation_cache_seq.sql +++ b/source/core/annotations/ut_annotation_cache_seq.sql @@ -1,7 +1,7 @@ create sequence ut_annotation_cache_seq /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb index 6dbe1d3ec..5b505d63e 100644 --- a/source/core/annotations/ut_annotation_manager.pkb +++ b/source/core/annotations/ut_annotation_manager.pkb @@ -1,7 +1,7 @@ create or replace package body ut_annotation_manager as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -51,36 +51,67 @@ create or replace package body ut_annotation_manager as return l_result; end; - function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotation_objs_cache_info is - l_rows sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_cursor_text varchar2(32767); - l_result ut_annotation_objs_cache_info; + function get_annotation_objs_info( + a_object_owner varchar2, + a_object_type varchar2, + a_parse_date timestamp := null, + a_full_scan boolean := true + ) return ut_annotation_objs_cache_info is + l_rows sys_refcursor; + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); + l_cursor_text varchar2(32767); + l_result ut_annotation_objs_cache_info; + l_object_owner varchar2(250); + l_object_type varchar2(250); begin - l_cursor_text := - q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info( - object_owner => o.owner, - object_name => o.object_name, - object_type => o.object_type, - needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end - ) - from ]'||l_objects_view||q'[ o - left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i - on o.owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = i.object_type - where o.owner = ']'||a_object_owner||q'[' - and o.object_type = ']'||a_object_type||q'[' - and ]' - || case - when a_parse_date is null - then ':a_parse_date is null' - else 'o.last_ddl_time >= cast(:a_parse_date as date)' - end; - open l_rows for l_cursor_text using a_parse_date; - fetch l_rows bulk collect into l_result limit 1000000; + ut_event_manager.trigger_event( + 'get_annotation_objs_info - start ( a_full_scan = ' || ut_utils.to_string(a_full_scan) || ' )' + ); + if not a_full_scan then + l_cursor_text := + q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info( + object_owner => i.object_owner, + object_name => i.object_name, + object_type => i.object_type, + needs_refresh => 'N' + ) + from ]'||l_ut_owner||q'[.ut_annotation_cache_info i + where i.object_owner = :a_object_owner + and i.object_type = :a_object_type]'; + open l_rows for l_cursor_text using a_object_owner, a_object_type; + else + if a_object_owner is not null then + l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner); + end if; + if a_object_type is not null then + l_object_type := sys.dbms_assert.qualified_sql_name(a_object_type); + end if; + l_cursor_text := + q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info( + object_owner => o.owner, + object_name => o.object_name, + object_type => o.object_type, + needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end + ) + from ]'||l_objects_view||q'[ o + left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i + on o.owner = i.object_owner + and o.object_name = i.object_name + and o.object_type = i.object_type + where o.owner = ']'||l_object_owner||q'[' + and o.object_type = ']'||l_object_type||q'[' + and ]' + || case + when a_parse_date is null + then ':a_parse_date is null' + else 'o.last_ddl_time >= cast(:a_parse_date as date)' + end; + open l_rows for l_cursor_text using a_parse_date; + end if; + fetch l_rows bulk collect into l_result limit 10000000; close l_rows; + ut_event_manager.trigger_event('get_annotation_objs_info - end (count='||l_result.count||')'); return l_result; end; @@ -143,7 +174,7 @@ create or replace package body ut_annotation_manager as a_sources_cursor sys_refcursor ) is l_annotations ut_annotations; - c_lines_fetch_limit constant integer := 1000; + c_lines_fetch_limit constant integer := 10000; l_lines dbms_preprocessor.source_lines_t; l_names dbms_preprocessor.source_lines_t; l_name varchar2(250); @@ -155,7 +186,7 @@ create or replace package body ut_annotation_manager as fetch a_sources_cursor bulk collect into l_names, l_lines limit c_lines_fetch_limit; for i in 1 .. l_names.count loop if l_names(i) != l_name then - l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines); + l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type); ut_annotation_cache_manager.update_cache( ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations) ); @@ -169,7 +200,7 @@ create or replace package body ut_annotation_manager as end loop; if a_sources_cursor%rowcount > 0 then - l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines); + l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type); ut_annotation_cache_manager.update_cache( ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations) ); @@ -180,16 +211,18 @@ create or replace package body ut_annotation_manager as end; - procedure rebuild_annotation_cache( + procedure refresh_annotation_cache( a_object_owner varchar2, a_object_type varchar2, a_info_rows ut_annotation_objs_cache_info ) is l_objects_to_parse ut_annotation_objs_cache_info; begin - select value(x)bulk collect into l_objects_to_parse + select value(x) + bulk collect into l_objects_to_parse from table(a_info_rows) x where x.needs_refresh = 'Y'; + ut_event_manager.trigger_event('rebuild_annotation_cache - start (l_objects_to_parse.count = '||l_objects_to_parse.count||')'); ut_annotation_cache_manager.cleanup_cache(l_objects_to_parse); if sys_context('userenv','current_schema') = a_object_owner @@ -208,32 +241,109 @@ create or replace package body ut_annotation_manager as get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_parse) ); end if; + ut_event_manager.trigger_event('rebuild_annotation_cache - end'); end; ------------------------------------------------------------ --public definitions ------------------------------------------------------------ procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is + l_annotation_objs_info ut_annotation_objs_cache_info; begin - rebuild_annotation_cache( - a_object_owner, - a_object_type, - get_annotation_objs_info(a_object_owner, a_object_type, null) - ); + l_annotation_objs_info := get_annotation_objs_info(a_object_owner, a_object_type, null, true); + refresh_annotation_cache( a_object_owner, a_object_type, l_annotation_objs_info ); + end; + + procedure trigger_obj_annotation_rebuild is + l_sql_text ora_name_list_t; + l_parts binary_integer; + l_object_to_parse ut_annotation_obj_cache_info; + l_restricted_users ora_name_list_t; + + function get_source_from_sql_text(a_object_name varchar2, a_sql_text ora_name_list_t, a_parts binary_integer) return sys_refcursor is + l_sql_clob clob; + l_sql_lines ut_varchar2_rows := ut_varchar2_rows(); + l_result sys_refcursor; + begin + if a_parts > 0 then + for i in 1..a_parts loop + ut_utils.append_to_clob(l_sql_clob, a_sql_text(i)); + end loop; + l_sql_clob := ut_utils.replace_multiline_comments(l_sql_clob); + -- replace comment lines that contain "-- create or replace" + l_sql_clob := regexp_replace(l_sql_clob, '^.*[-]{2,}\s*create(\s+or\s+replace).*$', modifier => 'mi'); + -- remove the "create [or replace] [[non]editionable] " so that we have only "type|package" for parsing + -- needed for dbms_preprocessor + l_sql_clob := regexp_replace(l_sql_clob, '^(.*?\s*create(\s+or\s+replace)?(\s+(editionable|noneditionable))?\s+?)((package|type).*)', '\5', 1, 1, 'ni'); + l_sql_lines := ut_utils.convert_collection( ut_utils.clob_to_table(l_sql_clob) ); + end if; + open l_result for + select a_object_name as name, column_value||chr(10) as text from table(l_sql_lines); + return l_result; + end; + + function get_source_for_object(a_object_owner varchar2, a_object_name varchar2, a_object_type varchar2) return sys_refcursor is + l_result sys_refcursor; + l_sources_view varchar2(200) := ut_metadata.get_source_view_name(); + begin + open l_result for + q'[select :a_object_name, s.text + from ]'||l_sources_view||q'[ s + where s.type = :a_object_type + and s.owner = :a_object_owner + and s.name = :a_object_name + order by s.line]' + using a_object_name, a_object_type, a_object_owner, a_object_name; + return l_result; + end; + + begin + if ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then + $if dbms_db_version.version < 12 $then + l_restricted_users := ora_name_list_t( + 'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL', + 'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF', + 'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL'); + $else + select username bulk collect into l_restricted_users + from all_users where oracle_maintained = 'Y'; + $end + if ora_dict_obj_owner member of l_restricted_users then + return; + end if; + + l_object_to_parse := ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y'); + + if ora_sysevent = 'CREATE' then + l_parts := ORA_SQL_TXT(l_sql_text); + build_annot_cache_for_sources( + ora_dict_obj_owner, ora_dict_obj_type, + get_source_from_sql_text(ora_dict_obj_name, l_sql_text, l_parts) + ); + elsif ora_sysevent = 'ALTER' then + build_annot_cache_for_sources( + ora_dict_obj_owner, ora_dict_obj_type, + get_source_for_object(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type) + ); + elsif ora_sysevent = 'DROP' then + ut_annotation_cache_manager.remove_from_cache(ut_annotation_objs_cache_info(l_object_to_parse)); + end if; + end if; end; function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined is - l_info_rows ut_annotation_objs_cache_info; + l_annotation_objs_info ut_annotation_objs_cache_info; l_cursor sys_refcursor; l_results ut_annotated_objects; - c_object_fetch_limit constant integer := 10; + c_object_fetch_limit constant integer := 10; + l_full_scan_needed boolean := not ut_trigger_check.is_alive(); begin - - l_info_rows := get_annotation_objs_info(a_object_owner, a_object_type, a_parse_date); - rebuild_annotation_cache(a_object_owner, a_object_type, l_info_rows); + ut_event_manager.trigger_event('get_annotated_objects - start'); + l_annotation_objs_info := get_annotation_objs_info(a_object_owner, a_object_type, a_parse_date, l_full_scan_needed); + refresh_annotation_cache(a_object_owner, a_object_type, l_annotation_objs_info); --pipe annotations from cache - l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_info_rows, a_parse_date); + l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_annotation_objs_info, a_parse_date); loop fetch l_cursor bulk collect into l_results limit c_object_fetch_limit; for i in 1 .. l_results.count loop @@ -242,6 +352,7 @@ create or replace package body ut_annotation_manager as exit when l_cursor%notfound; end loop; close l_cursor; + ut_event_manager.trigger_event('get_annotated_objects - end'); end; procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is @@ -249,5 +360,39 @@ create or replace package body ut_annotation_manager as ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type); end; + function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is + l_start_pos pls_integer := 1; + l_end_pos pls_integer := 1; + l_result varchar2(4000); + l_item varchar2(4000); + l_at_end boolean := false; + begin + if a_random_seed is null then + l_result := a_path; + end if; + if a_path is not null then + loop + l_end_pos := instr(a_path,'.',l_start_pos); + if l_end_pos = 0 then + l_end_pos := length(a_path)+1; + l_at_end := true; + end if; + l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos); + if l_item is not null then + l_result := + l_result || + dbms_crypto.hash( + to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ), + dbms_crypto.hash_sh1 + ); + end if; + exit when l_at_end; + l_result := l_result || chr(0); + l_start_pos := l_end_pos + 1; + end loop; + end if; + return l_result; + end; + end ut_annotation_manager; / diff --git a/source/core/annotations/ut_annotation_manager.pks b/source/core/annotations/ut_annotation_manager.pks index 829142bd5..c2527fcd2 100644 --- a/source/core/annotations/ut_annotation_manager.pks +++ b/source/core/annotations/ut_annotation_manager.pks @@ -1,7 +1,7 @@ create or replace package ut_annotation_manager authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -43,6 +43,11 @@ create or replace package ut_annotation_manager authid current_user as */ procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2); + /** + * Rebuilds annotation cache for a specified object. + */ + procedure trigger_obj_annotation_rebuild; + /** * Removes cached information about annotations for objects of specified type and specified owner * @@ -51,5 +56,11 @@ create or replace package ut_annotation_manager authid current_user as */ procedure purge_cache(a_object_owner varchar2, a_object_type varchar2); + + /* + * Returns a hash value of suitepath based on input path and random seed + */ + function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2; + end ut_annotation_manager; / diff --git a/source/core/annotations/ut_annotation_obj_cache_info.tps b/source/core/annotations/ut_annotation_obj_cache_info.tps index 2be2ac184..fd0ec51e7 100644 --- a/source/core/annotations/ut_annotation_obj_cache_info.tps +++ b/source/core/annotations/ut_annotation_obj_cache_info.tps @@ -1,7 +1,7 @@ create type ut_annotation_obj_cache_info as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/annotations/ut_annotation_objs_cache_info.tps b/source/core/annotations/ut_annotation_objs_cache_info.tps index 9773a045e..bab33a9d3 100644 --- a/source/core/annotations/ut_annotation_objs_cache_info.tps +++ b/source/core/annotations/ut_annotation_objs_cache_info.tps @@ -1,7 +1,7 @@ create type ut_annotation_objs_cache_info as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/annotations/ut_annotation_parser.pkb b/source/core/annotations/ut_annotation_parser.pkb index 8d3cee3ad..bbe58a667 100644 --- a/source/core/annotations/ut_annotation_parser.pkb +++ b/source/core/annotations/ut_annotation_parser.pkb @@ -1,7 +1,7 @@ create or replace package body ut_annotation_parser as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -223,7 +223,7 @@ create or replace package body ut_annotation_parser as return l_result; end parse_object_annotations; - function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t) return ut_annotations is + function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations is l_processed_lines dbms_preprocessor.source_lines_t; l_source clob; l_annotations ut_annotations := ut_annotations(); @@ -235,7 +235,11 @@ create or replace package body ut_annotation_parser as --convert to post-processed source clob begin --get post-processed source - l_processed_lines := sys.dbms_preprocessor.get_post_processed_source(a_source_lines); + if a_object_type = 'TYPE' then + l_processed_lines := a_source_lines; + else + l_processed_lines := sys.dbms_preprocessor.get_post_processed_source(a_source_lines); + end if; --convert to clob for i in 1..l_processed_lines.count loop ut_utils.append_to_clob(l_source, replace(l_processed_lines(i), chr(13)||chr(10), chr(10))); diff --git a/source/core/annotations/ut_annotation_parser.pks b/source/core/annotations/ut_annotation_parser.pks index a396e877e..b0a61e576 100644 --- a/source/core/annotations/ut_annotation_parser.pks +++ b/source/core/annotations/ut_annotation_parser.pks @@ -1,7 +1,7 @@ create or replace package ut_annotation_parser authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ create or replace package ut_annotation_parser authid current_user as * @param a_source_lines ordered lines of source code to be parsed * @return array containing annotations */ - function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t) return ut_annotations; + function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations; /** diff --git a/source/core/annotations/ut_annotations.tps b/source/core/annotations/ut_annotations.tps index 4238f9512..85be05e72 100644 --- a/source/core/annotations/ut_annotations.tps +++ b/source/core/annotations/ut_annotations.tps @@ -1,7 +1,7 @@ create type ut_annotations /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/annotations/ut_trigger_annotation_parsing.trg b/source/core/annotations/ut_trigger_annotation_parsing.trg new file mode 100644 index 000000000..437b7742d --- /dev/null +++ b/source/core/annotations/ut_trigger_annotation_parsing.trg @@ -0,0 +1,18 @@ +create or replace trigger ut_trigger_annotation_parsing + after create or alter or drop +on database +begin + if (ora_dict_obj_owner = UPPER('&&UT3_OWNER') + and ora_dict_obj_name = 'UT3_TRIGGER_ALIVE' + and ora_dict_obj_type = 'SYNONYM') + then + execute immediate 'begin ut_trigger_check.is_alive(); end;'; + elsif ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') + and not (ora_dict_obj_type = 'TYPE' and ora_dict_obj_name like 'SYS\_PLSQL\_%' escape '\') + then + execute immediate 'begin ut_annotation_manager.trigger_obj_annotation_rebuild; end;'; + end if; +exception + when others then null; +end; +/ diff --git a/source/core/annotations/ut_trigger_check.pkb b/source/core/annotations/ut_trigger_check.pkb new file mode 100644 index 000000000..e07acd3b2 --- /dev/null +++ b/source/core/annotations/ut_trigger_check.pkb @@ -0,0 +1,41 @@ +create or replace package body ut_trigger_check is + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE'; + g_is_trigger_live boolean := false; + + function is_alive return boolean is + pragma autonomous_transaction; + begin + if not g_is_trigger_live then + execute immediate 'create or replace synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object'; + end if; + return g_is_trigger_live; + end; + + procedure is_alive is + begin + if ora_dict_obj_owner is not null and ora_dict_obj_name is not null and ora_dict_obj_type is not null then + g_is_trigger_live := true; + else + g_is_trigger_live := false; + end if; + end; + +end; +/ diff --git a/source/core/annotations/ut_trigger_check.pks b/source/core/annotations/ut_trigger_check.pks new file mode 100644 index 000000000..c4c27c596 --- /dev/null +++ b/source/core/annotations/ut_trigger_check.pks @@ -0,0 +1,31 @@ +create or replace package ut_trigger_check authid definer is + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /** + * checks if the trigger &&UT3_OWNER._PARSE is enabled and operational. + */ + function is_alive return boolean; + + /** + * If called from a DDL trigger sets alive flag to true. + * If called outside of DDL trigger, sets alive flag to false. + */ + procedure is_alive; + +end; +/ diff --git a/source/core/coverage/ut_coverage.pkb b/source/core/coverage/ut_coverage.pkb index 93b6204d1..2fc5c4aec 100644 --- a/source/core/coverage/ut_coverage.pkb +++ b/source/core/coverage/ut_coverage.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -107,12 +107,18 @@ create or replace package body ut_coverage is l_cursor sys_refcursor; l_skip_objects ut_object_names; l_sql varchar2(32767); + l_valid_pattern varchar2(250) := '^\s*select.+$'; begin if not is_develop_mode() then --skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage. l_skip_objects := ut_utils.get_utplsql_objects_list() multiset union all coalesce(a_coverage_options.exclude_objects, ut_object_names()); end if; - l_sql := a_sql; + if regexp_like(a_sql, l_valid_pattern, 'mi') then + -- pseudo assert for PL/SQL Cop + l_sql := sys.dbms_assert.noop(a_sql); + else + raise_application_error(-20542, 'Possible SQL injection detected. a_sql parameter does not match valid pattern "' || l_valid_pattern || '".'); + end if; if a_coverage_options.file_mappings is not empty then open l_cursor for l_sql using a_coverage_options.file_mappings, l_skip_objects; elsif a_coverage_options.include_objects is not empty then diff --git a/source/core/coverage/ut_coverage.pks b/source/core/coverage/ut_coverage.pks index b291f4b26..9254e6d37 100644 --- a/source/core/coverage/ut_coverage.pks +++ b/source/core/coverage/ut_coverage.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_block.pkb b/source/core/coverage/ut_coverage_block.pkb index 8e7688c91..c6d0f409d 100644 --- a/source/core/coverage/ut_coverage_block.pkb +++ b/source/core/coverage/ut_coverage_block.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage_block is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_block.pks b/source/core/coverage/ut_coverage_block.pks index fdce622a5..26c79317e 100644 --- a/source/core/coverage/ut_coverage_block.pks +++ b/source/core/coverage/ut_coverage_block.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage_block authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_helper.pkb b/source/core/coverage/ut_coverage_helper.pkb index cfa3e413c..1c83606d8 100644 --- a/source/core/coverage/ut_coverage_helper.pkb +++ b/source/core/coverage/ut_coverage_helper.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ create or replace package body ut_coverage_helper is pragma autonomous_transaction; begin null; - execute immediate 'truncate table ut_coverage_sources_tmp$'; + execute immediate 'truncate table ut_coverage_sources_tmp'; commit; end; diff --git a/source/core/coverage/ut_coverage_helper.pks b/source/core/coverage/ut_coverage_helper.pks index 014e7b471..85a54a7ca 100644 --- a/source/core/coverage/ut_coverage_helper.pks +++ b/source/core/coverage/ut_coverage_helper.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage_helper authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_helper_block.pkb b/source/core/coverage/ut_coverage_helper_block.pkb index c5c30d12c..e8342a105 100644 --- a/source/core/coverage/ut_coverage_helper_block.pkb +++ b/source/core/coverage/ut_coverage_helper_block.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage_helper_block is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_helper_block.pks b/source/core/coverage/ut_coverage_helper_block.pks index 0b71b7067..0afa3ab15 100644 --- a/source/core/coverage/ut_coverage_helper_block.pks +++ b/source/core/coverage/ut_coverage_helper_block.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage_helper_block authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_helper_profiler.pkb b/source/core/coverage/ut_coverage_helper_profiler.pkb index 340a28ca3..6b685ede0 100644 --- a/source/core/coverage/ut_coverage_helper_profiler.pkb +++ b/source/core/coverage/ut_coverage_helper_profiler.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage_helper_profiler is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_helper_profiler.pks b/source/core/coverage/ut_coverage_helper_profiler.pks index db91326eb..9345f4b88 100644 --- a/source/core/coverage/ut_coverage_helper_profiler.pks +++ b/source/core/coverage/ut_coverage_helper_profiler.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage_helper_profiler authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_profiler.pkb b/source/core/coverage/ut_coverage_profiler.pkb index e4c9ab0af..160e2dd41 100644 --- a/source/core/coverage/ut_coverage_profiler.pkb +++ b/source/core/coverage/ut_coverage_profiler.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage_profiler is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_profiler.pks b/source/core/coverage/ut_coverage_profiler.pks index 4e4b8d9c0..8e671f899 100644 --- a/source/core/coverage/ut_coverage_profiler.pks +++ b/source/core/coverage/ut_coverage_profiler.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage_profiler authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_reporter_base.tpb b/source/core/coverage/ut_coverage_reporter_base.tpb index 9e339347f..5067f9221 100644 --- a/source/core/coverage/ut_coverage_reporter_base.tpb +++ b/source/core/coverage/ut_coverage_reporter_base.tpb @@ -1,7 +1,7 @@ create or replace type body ut_coverage_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_reporter_base.tps b/source/core/coverage/ut_coverage_reporter_base.tps index 76206dd95..2b9d1c625 100644 --- a/source/core/coverage/ut_coverage_reporter_base.tps +++ b/source/core/coverage/ut_coverage_reporter_base.tps @@ -1,7 +1,7 @@ create or replace type ut_coverage_reporter_base under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/coverage/ut_coverage_sources_tmp.sql b/source/core/coverage/ut_coverage_sources_tmp.sql index bcc661a22..f53283dcd 100644 --- a/source/core/coverage/ut_coverage_sources_tmp.sql +++ b/source/core/coverage/ut_coverage_sources_tmp.sql @@ -1,7 +1,7 @@ -create global temporary table ut_coverage_sources_tmp$( +create global temporary table ut_coverage_sources_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -21,46 +21,5 @@ create global temporary table ut_coverage_sources_tmp$( constraint ut_coverage_sources_tmp_pk primary key (owner,name,line) ) on commit preserve rows; -create unique index ut_coverage_sources_tmp_uk on ut_coverage_sources_tmp$ (owner,name,to_be_skipped, line); - -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_coverage_sources_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_coverage_sources_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select full_name - ,owner - ,name - ,line - ,to_be_skipped - ,text - from ut_coverage_sources_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ +--is this needed? +--create unique index ut_coverage_sources_tmp_uk on ut_coverage_sources_tmp$ (owner,name,to_be_skipped, line); diff --git a/source/core/events/ut_event_item.tps b/source/core/events/ut_event_item.tps index d1f52cba6..efec940f5 100644 --- a/source/core/events/ut_event_item.tps +++ b/source/core/events/ut_event_item.tps @@ -1,7 +1,7 @@ create or replace type ut_event_item authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/events/ut_event_listener.tps b/source/core/events/ut_event_listener.tps index fd6ae0486..71ee16a0f 100644 --- a/source/core/events/ut_event_listener.tps +++ b/source/core/events/ut_event_listener.tps @@ -1,7 +1,7 @@ create or replace type ut_event_listener authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/events/ut_event_manager.pkb b/source/core/events/ut_event_manager.pkb index 0dfc6c925..039eb43a0 100644 --- a/source/core/events/ut_event_manager.pkb +++ b/source/core/events/ut_event_manager.pkb @@ -1,7 +1,7 @@ create or replace package body ut_event_manager as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/events/ut_event_manager.pks b/source/core/events/ut_event_manager.pks index 948a9550c..f67bd0f4d 100644 --- a/source/core/events/ut_event_manager.pks +++ b/source/core/events/ut_event_manager.pks @@ -1,7 +1,7 @@ create or replace package ut_event_manager authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/output_buffers/ut_message_id_seq.sql b/source/core/output_buffers/ut_message_id_seq.sql deleted file mode 100644 index 3f0cd25c4..000000000 --- a/source/core/output_buffers/ut_message_id_seq.sql +++ /dev/null @@ -1 +0,0 @@ -create sequence ut_message_id_seq nocycle cache 100; diff --git a/source/core/output_buffers/ut_output_buffer_base.tpb b/source/core/output_buffers/ut_output_buffer_base.tpb new file mode 100644 index 000000000..018250e4b --- /dev/null +++ b/source/core/output_buffers/ut_output_buffer_base.tpb @@ -0,0 +1,76 @@ +create or replace type body ut_output_buffer_base is + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null) is + pragma autonomous_transaction; + l_exists int; + begin + cleanup_buffer(); + self.self_type := coalesce(a_self_type,self.self_type); + self.output_id := coalesce(a_output_id, self.output_id, sys_guid()); + self.start_date := coalesce(self.start_date, sysdate); + self.last_message_id := 0; + select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; + if ( l_exists > 0 ) then + update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; + else + insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); + end if; + commit; + self.is_closed := 0; + end; + + member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is + l_lines sys_refcursor; + begin + open l_lines for + select text, item_type + from table(self.get_lines(a_initial_timeout, a_timeout_sec)); + return l_lines; + end; + + member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) is + l_data sys_refcursor; + l_clob clob; + l_item_type varchar2(32767); + l_lines ut_varchar2_list; + begin + l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); + loop + fetch l_data into l_clob, l_item_type; + exit when l_data%notfound; + l_lines := ut_utils.clob_to_table(l_clob); + for i in 1 .. l_lines.count loop + dbms_output.put_line(l_lines(i)); + end loop; + end loop; + close l_data; + end; + + member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null) is + gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours + l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24); + l_max_retention_date date := sysdate - l_retention_days; + pragma autonomous_transaction; + begin + delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date; + commit; + end; + +end; +/ \ No newline at end of file diff --git a/source/core/output_buffers/ut_output_buffer_base.tps b/source/core/output_buffers/ut_output_buffer_base.tps index 42c4a0d72..745692f38 100644 --- a/source/core/output_buffers/ut_output_buffer_base.tps +++ b/source/core/output_buffers/ut_output_buffer_base.tps @@ -1,7 +1,7 @@ -create or replace type ut_output_buffer_base authid definer as object( +create or replace type ut_output_buffer_base force authid definer as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -17,13 +17,18 @@ create or replace type ut_output_buffer_base authid definer as object( */ output_id raw(32), - member procedure init(self in out nocopy ut_output_buffer_base), - not instantiable member procedure close(self in ut_output_buffer_base), - not instantiable member procedure send_line(self in ut_output_buffer_base, a_text varchar2, a_item_type varchar2 := null), - not instantiable member procedure send_lines(self in ut_output_buffer_base, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), - not instantiable member procedure send_clob(self in ut_output_buffer_base, a_text clob, a_item_type varchar2 := null), - not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined, - not instantiable member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - not instantiable member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) + is_closed number(1,0), + start_date date, + last_message_id number(38,0), + self_type varchar2(250 byte), + member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null), + member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, + member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null), + member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null), + not instantiable member procedure close(self in out nocopy ut_output_buffer_base), + not instantiable member procedure send_line(self in out nocopy ut_output_buffer_base, a_text varchar2, a_item_type varchar2 := null), + not instantiable member procedure send_lines(self in out nocopy ut_output_buffer_base, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), + not instantiable member procedure send_clob(self in out nocopy ut_output_buffer_base, a_text clob, a_item_type varchar2 := null), + not instantiable member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined ) not final not instantiable / diff --git a/source/core/output_buffers/ut_output_buffer_info_tmp.sql b/source/core/output_buffers/ut_output_buffer_info_tmp.sql index 5880022f5..ec09619d2 100644 --- a/source/core/output_buffers/ut_output_buffer_info_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_info_tmp.sql @@ -1,7 +1,7 @@ -create table ut_output_buffer_info_tmp$( +create table ut_output_buffer_info_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -23,41 +23,3 @@ create table ut_output_buffer_info_tmp$( ) organization index nologging initrans 10 ; --- This is needed to be EBR ready as editioning view can only be created by edition enabled user -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_output_buffer_info_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_output_buffer_info_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select output_id - ,start_date - from ut_output_buffer_info_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ diff --git a/source/core/output_buffers/ut_output_buffer_tmp.sql b/source/core/output_buffers/ut_output_buffer_tmp.sql index e7cb49817..49fefa24d 100644 --- a/source/core/output_buffers/ut_output_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_tmp.sql @@ -1,12 +1,7 @@ -declare - v_table_sql varchar2(32767); - e_non_assm exception; - pragma exception_init(e_non_assm, -43853); -begin - v_table_sql := 'create table ut_output_buffer_tmp$( +create table ut_output_buffer_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -24,65 +19,14 @@ begin */ output_id raw(32) not null, message_id number(38,0) not null, - text clob, + text varchar2(4000), item_type varchar2(1000), is_finished number(1,0) default 0 not null, constraint ut_output_buffer_tmp_pk primary key(output_id, message_id), constraint ut_output_buffer_tmp_ck check( is_finished = 0 and (text is not null or item_type is not null ) or is_finished = 1 and text is null and item_type is null ), - constraint ut_output_buffer_fk1 foreign key (output_id) references ut_output_buffer_info_tmp$(output_id) -) organization index overflow nologging initrans 100 '; - begin - execute immediate - v_table_sql || 'lob(text) store as securefile ut_output_text(retention none)'; - exception - when e_non_assm then - execute immediate - v_table_sql || 'lob(text) store as basicfile ut_output_text(pctversion 0)'; + constraint ut_output_buffer_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade +) organization index nologging initrans 100 + overflow nologging initrans 100; - end; -end; -/ - --- This is needed to be EBR ready as editioning view can only be created by edition enabled user -declare - ex_nonedition_user exception; - ex_view_doesnt_exist exception; - pragma exception_init(ex_nonedition_user,-42314); - pragma exception_init(ex_view_doesnt_exist,-942); - v_view_source varchar2(32767); -begin - begin - execute immediate 'drop view ut_output_buffer_tmp'; - exception - when ex_view_doesnt_exist then - null; - end; - v_view_source := ' ut_output_buffer_tmp as -/* -utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project -Licensed under the Apache License, Version 2.0 (the "License"): -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -select output_id - ,message_id - ,text - ,item_type - ,is_finished - from ut_output_buffer_tmp$'; - - execute immediate 'create or replace editioning view '||v_view_source; -exception - when ex_nonedition_user then - execute immediate 'create or replace view '||v_view_source; -end; -/ diff --git a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql new file mode 100644 index 000000000..48cfe6fde --- /dev/null +++ b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql @@ -0,0 +1,47 @@ +declare + v_table_sql varchar2(32767); + e_non_assm exception; + pragma exception_init(e_non_assm, -43853); +begin + v_table_sql := 'create table ut_output_clob_buffer_tmp( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + /* + * This table is not a global temporary table as it needs to allow cross-session data exchange + * It is used however as a temporary table with multiple writers. + * This is why it has very high initrans and has nologging + */ + output_id raw(32) not null, + message_id number(38,0) not null, + text clob, + item_type varchar2(1000), + is_finished number(1,0) default 0 not null, + constraint ut_output_clob_buffer_tmp_pk primary key(output_id, message_id), + constraint ut_output_clob_buffer_tmp_ck check( + is_finished = 0 and (text is not null or item_type is not null ) + or is_finished = 1 and text is null and item_type is null ), + constraint ut_output_clob_buffer_tmp_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade +) nologging initrans 100 +'; + begin + execute immediate + v_table_sql || 'lob(text) store as securefile ut_output_text(retention none enable storage in row)'; + exception + when e_non_assm then + execute immediate + v_table_sql || 'lob(text) store as basicfile ut_output_text(pctversion 0 enable storage in row)'; + + end; +end; +/ diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tpb b/source/core/output_buffers/ut_output_clob_table_buffer.tpb new file mode 100644 index 000000000..8c2825151 --- /dev/null +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tpb @@ -0,0 +1,157 @@ +create or replace type body ut_output_clob_table_buffer is + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_output_clob_table_buffer(self in out nocopy ut_output_clob_table_buffer, a_output_id raw := null) return self as result is + begin + self.init(a_output_id, $$plsql_unit); + return; + end; + + overriding member procedure close(self in out nocopy ut_output_clob_table_buffer) is + pragma autonomous_transaction; + begin + self.last_message_id := self.last_message_id + 1; + insert into ut_output_clob_buffer_tmp(output_id, message_id, is_finished) + values (self.output_id, self.last_message_id, 1); + commit; + self.is_closed := 1; + end; + + overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null) is + pragma autonomous_transaction; + begin + if a_text is not null or a_item_type is not null then + self.last_message_id := self.last_message_id + 1; + insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, self.last_message_id, a_text, a_item_type); + end if; + commit; + end; + + overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is + pragma autonomous_transaction; + begin + insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) + select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type + from table(a_text_list) t + where t.column_value is not null or a_item_type is not null; + self.last_message_id := self.last_message_id + SQL%rowcount; + commit; + end; + + overriding member procedure send_clob(self in out nocopy ut_output_clob_table_buffer, a_text clob, a_item_type varchar2 := null) is + pragma autonomous_transaction; + begin + if a_text is not null and a_text != empty_clob() or a_item_type is not null then + self.last_message_id := self.last_message_id + 1; + insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, self.last_message_id, a_text, a_item_type); + end if; + commit; + end; + + overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is + type t_rowid_tab is table of urowid; + l_message_rowids t_rowid_tab; + l_buffer_data ut_output_data_rows; + l_finished_flags ut_integer_list; + l_already_waited_for number(10,2) := 0; + l_finished boolean := false; + lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute + lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours + l_wait_for integer := lc_init_wait_sec; + lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks + lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long + lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec + l_sleep_time number(2,1) := lc_short_sleep_time; + lc_bulk_limit constant integer := 5000; + l_max_message_id integer := lc_bulk_limit; + + procedure remove_read_data(a_message_rowids t_rowid_tab) is + pragma autonomous_transaction; + begin + forall i in 1 .. a_message_rowids.count + delete from ut_output_clob_buffer_tmp a + where rowid = a_message_rowids(i); + commit; + end; + + procedure remove_buffer_info is + pragma autonomous_transaction; + begin + delete from ut_output_buffer_info_tmp a + where a.output_id = self.output_id; + commit; + end; + + begin + while not l_finished loop + with ordered_buffer as ( + select /*+ index(a) */ a.rowid, ut_output_data_row(a.text, a.item_type), is_finished + from ut_output_clob_buffer_tmp a + where a.output_id = self.output_id + and a.message_id <= l_max_message_id + order by a.message_id + ) + select b.* + bulk collect into l_message_rowids, l_buffer_data, l_finished_flags + from ordered_buffer b; + + --nothing fetched from output, wait and try again + if l_buffer_data.count = 0 then + $if dbms_db_version.version >= 18 $then + dbms_session.sleep(l_sleep_time); + $else + dbms_lock.sleep(l_sleep_time); + $end + l_already_waited_for := l_already_waited_for + l_sleep_time; + if l_already_waited_for > lc_long_wait_time then + l_sleep_time := lc_long_sleep_time; + end if; + else + --reset wait time + -- we wait lc_max_wait_sec for new message + l_wait_for := lc_max_wait_sec; + l_already_waited_for := 0; + l_sleep_time := lc_short_sleep_time; + for i in 1 .. l_buffer_data.count loop + if l_buffer_data(i).text is not null then + pipe row(l_buffer_data(i)); + elsif l_finished_flags(i) = 1 then + l_finished := true; + exit; + end if; + end loop; + remove_read_data(l_message_rowids); + l_max_message_id := l_max_message_id + lc_bulk_limit; + end if; + if l_finished or l_already_waited_for >= l_wait_for then + remove_buffer_info(); + if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then + raise_application_error( + ut_utils.gc_out_buffer_timeout, + 'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.' + ); + end if; + end if; + end loop; + return; + end; + +end; +/ diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tps b/source/core/output_buffers/ut_output_clob_table_buffer.tps new file mode 100644 index 000000000..2eb3640b0 --- /dev/null +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tps @@ -0,0 +1,26 @@ +create or replace type ut_output_clob_table_buffer under ut_output_buffer_base ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_output_clob_table_buffer(self in out nocopy ut_output_clob_table_buffer, a_output_id raw := null) return self as result, + overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null), + overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), + overriding member procedure send_clob(self in out nocopy ut_output_clob_table_buffer, a_text clob, a_item_type varchar2 := null), + overriding member procedure close(self in out nocopy ut_output_clob_table_buffer), + overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined +) not final +/ diff --git a/source/core/output_buffers/ut_output_data_row.tps b/source/core/output_buffers/ut_output_data_row.tps index ddcb65710..b0f5efe91 100644 --- a/source/core/output_buffers/ut_output_data_row.tps +++ b/source/core/output_buffers/ut_output_data_row.tps @@ -1,7 +1,7 @@ create or replace type ut_output_data_row as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/output_buffers/ut_output_data_rows.tps b/source/core/output_buffers/ut_output_data_rows.tps index 9575231ba..1918f0c81 100644 --- a/source/core/output_buffers/ut_output_data_rows.tps +++ b/source/core/output_buffers/ut_output_data_rows.tps @@ -1,7 +1,7 @@ create or replace type ut_output_data_rows as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/output_buffers/ut_output_table_buffer.tpb b/source/core/output_buffers/ut_output_table_buffer.tpb index 5fc71570c..e3f869b22 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_table_buffer.tpb @@ -1,7 +1,7 @@ create or replace type body ut_output_table_buffer is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -18,68 +18,74 @@ create or replace type body ut_output_table_buffer is constructor function ut_output_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result is begin - self.output_id := coalesce(a_output_id, sys_guid()); - self.start_date := sysdate; - self.init(); - self.cleanup_buffer(); + self.init(a_output_id, $$plsql_unit); return; end; - overriding member procedure init(self in out nocopy ut_output_table_buffer) is - pragma autonomous_transaction; - l_exists int; - begin - select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; - if ( l_exists > 0 ) then - update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; - else - insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); - end if; - commit; - end; - - overriding member procedure close(self in ut_output_table_buffer) is + overriding member procedure close(self in out nocopy ut_output_table_buffer) is pragma autonomous_transaction; begin + self.last_message_id := self.last_message_id + 1; insert into ut_output_buffer_tmp(output_id, message_id, is_finished) - values (self.output_id, ut_message_id_seq.nextval, 1); + values (self.output_id, self.last_message_id, 1); commit; + self.is_closed := 1; end; - overriding member procedure send_line(self in ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null) is + overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null) is pragma autonomous_transaction; begin if a_text is not null or a_item_type is not null then - insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_message_id_seq.nextval, a_text, a_item_type); + if length(a_text) > ut_utils.gc_max_storage_varchar2_len then + self.send_lines( + ut_utils.convert_collection( + ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len) + ), + a_item_type + ); + else + self.last_message_id := self.last_message_id + 1; + insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, self.last_message_id, a_text, a_item_type); + end if; + commit; end if; - commit; end; - overriding member procedure send_lines(self in ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is + overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is pragma autonomous_transaction; begin insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) - select self.output_id, ut_message_id_seq.nextval, t.column_value, a_item_type + select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type from table(a_text_list) t where t.column_value is not null or a_item_type is not null; - + self.last_message_id := self.last_message_id + SQL%rowcount; commit; end; - overriding member procedure send_clob(self in ut_output_table_buffer, a_text clob, a_item_type varchar2 := null) is + overriding member procedure send_clob(self in out nocopy ut_output_table_buffer, a_text clob, a_item_type varchar2 := null) is pragma autonomous_transaction; begin if a_text is not null and a_text != empty_clob() or a_item_type is not null then - insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_message_id_seq.nextval, a_text, a_item_type); + if length(a_text) > ut_utils.gc_max_storage_varchar2_len then + self.send_lines( + ut_utils.convert_collection( + ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len) + ), + a_item_type + ); + else + self.last_message_id := self.last_message_id + 1; + insert into ut_output_buffer_tmp(output_id, message_id, text, item_type) + values (self.output_id, self.last_message_id, a_text, a_item_type); + end if; + commit; end if; - commit; end; overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is - l_buffer_data ut_output_data_rows; - l_message_ids ut_integer_list; + l_buffer_data ut_varchar2_rows; + l_item_types ut_varchar2_rows; l_finished_flags ut_integer_list; l_already_waited_for number(10,2) := 0; l_finished boolean := false; @@ -90,15 +96,28 @@ create or replace type body ut_output_table_buffer is lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec l_sleep_time number(2,1) := lc_short_sleep_time; - lc_bulk_limit constant integer := 100; - - procedure remove_read_data(a_message_ids ut_integer_list) is + lc_bulk_limit constant integer := 5000; + l_max_message_id integer := lc_bulk_limit; + + procedure get_data_from_buffer( + a_max_message_id integer, + a_buffer_data out nocopy ut_varchar2_rows, + a_item_types out nocopy ut_varchar2_rows, + a_finished_flags out nocopy ut_integer_list + ) is pragma autonomous_transaction; begin - delete from ut_output_buffer_tmp a - where a.output_id = self.output_id - and a.message_id in (select column_value from table(a_message_ids)); + delete from ( + select * + from ut_output_buffer_tmp o + where o.output_id = self.output_id + and o.message_id <= a_max_message_id + order by o.message_id + ) d + returning d.text, d.item_type, d.is_finished + bulk collect into a_buffer_data, a_item_types, a_finished_flags; commit; + end; procedure remove_buffer_info is @@ -111,17 +130,7 @@ create or replace type body ut_output_table_buffer is begin while not l_finished loop - with ordered_buffer as ( - select a.message_id, ut_output_data_row(a.text, a.item_type), is_finished - from ut_output_buffer_tmp a - where a.output_id = self.output_id - order by a.message_id - ) - select b.* - bulk collect into l_message_ids, l_buffer_data, l_finished_flags - from ordered_buffer b - where rownum <= lc_bulk_limit; - + get_data_from_buffer( l_max_message_id, l_buffer_data, l_item_types, l_finished_flags); --nothing fetched from output, wait and try again if l_buffer_data.count = 0 then $if dbms_db_version.version >= 18 $then @@ -140,14 +149,14 @@ create or replace type body ut_output_table_buffer is l_already_waited_for := 0; l_sleep_time := lc_short_sleep_time; for i in 1 .. l_buffer_data.count loop - if l_buffer_data(i).text is not null then - pipe row(l_buffer_data(i)); + if l_buffer_data(i) is not null then + pipe row(ut_output_data_row(l_buffer_data(i),l_item_types(i))); elsif l_finished_flags(i) = 1 then l_finished := true; exit; end if; end loop; - remove_read_data(l_message_ids); + l_max_message_id := l_max_message_id + lc_bulk_limit; end if; if l_finished or l_already_waited_for >= l_wait_for then remove_buffer_info(); @@ -162,46 +171,5 @@ create or replace type body ut_output_table_buffer is return; end; - overriding member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is - l_lines sys_refcursor; - begin - open l_lines for - select text, item_type - from table(self.get_lines(a_initial_timeout, a_timeout_sec)); - return l_lines; - end; - - overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout natural := null, a_timeout_sec natural := null) is - l_data sys_refcursor; - l_clob clob; - l_item_type varchar2(32767); - l_lines ut_varchar2_list; - begin - l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); - loop - fetch l_data into l_clob, l_item_type; - exit when l_data%notfound; - l_lines := ut_utils.clob_to_table(l_clob); - for i in 1 .. l_lines.count loop - dbms_output.put_line(l_lines(i)); - end loop; - end loop; - close l_data; - end; - - member procedure cleanup_buffer(self in ut_output_table_buffer, a_retention_time_sec natural := null) is - gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours - l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24); - l_max_retention_date date := sysdate - l_retention_days; - pragma autonomous_transaction; - begin - delete from ut_output_buffer_tmp t - where t.output_id - in (select i.output_id from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date); - - delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date; - commit; - end; - end; / diff --git a/source/core/output_buffers/ut_output_table_buffer.tps b/source/core/output_buffers/ut_output_table_buffer.tps index 1c9acbd1d..3e395304a 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tps +++ b/source/core/output_buffers/ut_output_table_buffer.tps @@ -1,7 +1,7 @@ create or replace type ut_output_table_buffer under ut_output_buffer_base ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -16,16 +16,11 @@ create or replace type ut_output_table_buffer under ut_output_buffer_base ( limitations under the License. */ - start_date date, constructor function ut_output_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result, - overriding member procedure init(self in out nocopy ut_output_table_buffer), - overriding member procedure send_line(self in ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null), - overriding member procedure send_lines(self in ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), - overriding member procedure send_clob(self in ut_output_table_buffer, a_text clob, a_item_type varchar2 := null), - overriding member procedure close(self in ut_output_table_buffer), - overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined, - overriding member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout natural := null, a_timeout_sec natural := null), - member procedure cleanup_buffer(self in ut_output_table_buffer, a_retention_time_sec natural := null) + overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null), + overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), + overriding member procedure send_clob(self in out nocopy ut_output_table_buffer, a_text clob, a_item_type varchar2 := null), + overriding member procedure close(self in out nocopy ut_output_table_buffer), + overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined ) not final / diff --git a/source/core/types/ut_console_reporter_base.tpb b/source/core/types/ut_console_reporter_base.tpb index 0245edde3..df256e832 100644 --- a/source/core/types/ut_console_reporter_base.tpb +++ b/source/core/types/ut_console_reporter_base.tpb @@ -1,7 +1,7 @@ create or replace type body ut_console_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_console_reporter_base.tps b/source/core/types/ut_console_reporter_base.tps index 3736e4d33..6c0a08502 100644 --- a/source/core/types/ut_console_reporter_base.tps +++ b/source/core/types/ut_console_reporter_base.tps @@ -1,7 +1,7 @@ create or replace type ut_console_reporter_base under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_coverage_options.tps b/source/core/types/ut_coverage_options.tps index 737ea1abb..bcdbc0b32 100644 --- a/source/core/types/ut_coverage_options.tps +++ b/source/core/types/ut_coverage_options.tps @@ -1,7 +1,7 @@ create or replace type ut_coverage_options force as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index b41e75388..060f416aa 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -1,7 +1,7 @@ create or replace type body ut_executable is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -29,9 +29,13 @@ create or replace type body ut_executable is return; end; - member function form_name return varchar2 is + member function form_name(a_skip_current_user_schema boolean := false) return varchar2 is + l_owner_name varchar2(250) := owner_name; begin - return ut_metadata.form_name(owner_name, object_name, procedure_name); + if a_skip_current_user_schema and sys_context('userenv', 'current_schema') = owner_name then + l_owner_name := null; + end if; + return ut_metadata.form_name(l_owner_name, object_name, procedure_name); end; member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) is @@ -71,10 +75,9 @@ create or replace type body ut_executable is begin if not ut_metadata.package_valid(self.owner_name, self.object_name) then - self.error_stack := l_message_part || 'package does not exist or is invalid: ' ||upper(self.owner_name||'.'||self.object_name); + self.error_stack := l_message_part || 'package '||upper(self.owner_name||'.'||self.object_name)||' does not exist or is invalid.'; elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then - self.error_stack := l_message_part || 'procedure does not exist ' - || upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name); + self.error_stack := l_message_part || 'procedure '||upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name)||' does not exist.'; else l_result := false; end if; @@ -115,7 +118,7 @@ create or replace type body ut_executable is ' l_error_backtrace varchar2(32767);' || chr(10) || 'begin' || chr(10) || ' begin' || chr(10) || - ' ' || self.form_name() || ';' || chr(10) || + ' ' || self.form_name( a_skip_current_user_schema => true ) || ';' || chr(10) || ' exception' || chr(10) || ' when others then ' || chr(10) || ' l_error_stack := dbms_utility.format_error_stack;' || chr(10) || diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 8186e4bae..786d926ad 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -1,7 +1,7 @@ create or replace type ut_executable under ut_event_item( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ create or replace type ut_executable under ut_event_item( */ seq_no integer, constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, a_procedure_name varchar2, a_executable_type varchar2) return self as result, - member function form_name return varchar2, + member function form_name(a_skip_current_user_schema boolean := false) return varchar2, member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item), /** * executes the defines executable diff --git a/source/core/types/ut_executable_test.tps b/source/core/types/ut_executable_test.tps index b11676c0c..2772720de 100644 --- a/source/core/types/ut_executable_test.tps +++ b/source/core/types/ut_executable_test.tps @@ -1,7 +1,7 @@ create or replace type ut_executable_test authid current_user under ut_executable ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_executables.tps b/source/core/types/ut_executables.tps index a06e6c067..f5732d5a1 100644 --- a/source/core/types/ut_executables.tps +++ b/source/core/types/ut_executables.tps @@ -1,7 +1,7 @@ create or replace type ut_executables as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_expectation_result.tpb b/source/core/types/ut_expectation_result.tpb index 6b1bbd4ef..097c900f4 100644 --- a/source/core/types/ut_expectation_result.tpb +++ b/source/core/types/ut_expectation_result.tpb @@ -1,7 +1,7 @@ create or replace type body ut_expectation_result is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_expectation_result.tps b/source/core/types/ut_expectation_result.tps index f5d7fd23e..815d90820 100644 --- a/source/core/types/ut_expectation_result.tps +++ b/source/core/types/ut_expectation_result.tps @@ -1,7 +1,7 @@ create or replace type ut_expectation_result under ut_event_item( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_expectation_results.tps b/source/core/types/ut_expectation_results.tps index 942f9b398..963c726f8 100644 --- a/source/core/types/ut_expectation_results.tps +++ b/source/core/types/ut_expectation_results.tps @@ -1,7 +1,7 @@ create or replace type ut_expectation_results as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_file_mapping.tpb b/source/core/types/ut_file_mapping.tpb index c5a82c09d..247aa5ac8 100644 --- a/source/core/types/ut_file_mapping.tpb +++ b/source/core/types/ut_file_mapping.tpb @@ -1,7 +1,7 @@ create or replace type body ut_file_mapping as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_file_mapping.tps b/source/core/types/ut_file_mapping.tps index e046808d4..c032e0b77 100644 --- a/source/core/types/ut_file_mapping.tps +++ b/source/core/types/ut_file_mapping.tps @@ -1,7 +1,7 @@ create or replace type ut_file_mapping as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_file_mappings.tps b/source/core/types/ut_file_mappings.tps index 6ff2604b3..a48c3e872 100644 --- a/source/core/types/ut_file_mappings.tps +++ b/source/core/types/ut_file_mappings.tps @@ -1,7 +1,7 @@ create or replace type ut_file_mappings as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_integer_list.tps b/source/core/types/ut_integer_list.tps index c1fc4de91..25f1679b2 100644 --- a/source/core/types/ut_integer_list.tps +++ b/source/core/types/ut_integer_list.tps @@ -1,7 +1,7 @@ create or replace type ut_integer_list as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_key_value_pair.tps b/source/core/types/ut_key_value_pair.tps index ae1b9aba7..873a354fd 100644 --- a/source/core/types/ut_key_value_pair.tps +++ b/source/core/types/ut_key_value_pair.tps @@ -1,7 +1,7 @@ create or replace type ut_key_value_pair force as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_key_value_pairs.tps b/source/core/types/ut_key_value_pairs.tps index c9bab9ec2..28fa87cf0 100644 --- a/source/core/types/ut_key_value_pairs.tps +++ b/source/core/types/ut_key_value_pairs.tps @@ -1,7 +1,7 @@ create or replace type ut_key_value_pairs as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_logical_suite.tpb b/source/core/types/ut_logical_suite.tpb index 4dca71b3e..74c7ff81c 100644 --- a/source/core/types/ut_logical_suite.tpb +++ b/source/core/types/ut_logical_suite.tpb @@ -1,7 +1,7 @@ create or replace type body ut_logical_suite as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_logical_suite.tps b/source/core/types/ut_logical_suite.tps index 270558faa..71cfdb23d 100644 --- a/source/core/types/ut_logical_suite.tps +++ b/source/core/types/ut_logical_suite.tps @@ -1,7 +1,7 @@ create or replace type ut_logical_suite under ut_suite_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_object_name.tpb b/source/core/types/ut_object_name.tpb index 299b6e269..cf1ab2a78 100644 --- a/source/core/types/ut_object_name.tpb +++ b/source/core/types/ut_object_name.tpb @@ -1,7 +1,7 @@ create or replace type body ut_object_name as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_object_name.tps b/source/core/types/ut_object_name.tps index 12afa69dd..28e41958f 100644 --- a/source/core/types/ut_object_name.tps +++ b/source/core/types/ut_object_name.tps @@ -1,7 +1,7 @@ create or replace type ut_object_name as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_object_names.tps b/source/core/types/ut_object_names.tps index f46580172..2f7e5ea16 100644 --- a/source/core/types/ut_object_names.tps +++ b/source/core/types/ut_object_names.tps @@ -1,7 +1,7 @@ create or replace type ut_object_names as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_output_reporter_base.tpb b/source/core/types/ut_output_reporter_base.tpb index 1f682070b..d20f454a8 100644 --- a/source/core/types/ut_output_reporter_base.tpb +++ b/source/core/types/ut_output_reporter_base.tpb @@ -1,7 +1,7 @@ create or replace type body ut_output_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_output_reporter_base.tps b/source/core/types/ut_output_reporter_base.tps index ba550fb0f..95ee9c1f8 100644 --- a/source/core/types/ut_output_reporter_base.tps +++ b/source/core/types/ut_output_reporter_base.tps @@ -1,7 +1,7 @@ create or replace type ut_output_reporter_base under ut_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_reporter_base.tpb b/source/core/types/ut_reporter_base.tpb index 741d024e0..94d518af4 100644 --- a/source/core/types/ut_reporter_base.tpb +++ b/source/core/types/ut_reporter_base.tpb @@ -1,7 +1,7 @@ create or replace type body ut_reporter_base is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_reporter_base.tps b/source/core/types/ut_reporter_base.tps index 4f8216294..36af70776 100644 --- a/source/core/types/ut_reporter_base.tps +++ b/source/core/types/ut_reporter_base.tps @@ -1,7 +1,7 @@ create or replace type ut_reporter_base under ut_event_listener ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_reporter_info.tps b/source/core/types/ut_reporter_info.tps index 7426498d5..a4028974f 100644 --- a/source/core/types/ut_reporter_info.tps +++ b/source/core/types/ut_reporter_info.tps @@ -1,7 +1,7 @@ create or replace type ut_reporter_info as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_reporters.tps b/source/core/types/ut_reporters.tps index 7df85c2f3..b16e74653 100644 --- a/source/core/types/ut_reporters.tps +++ b/source/core/types/ut_reporters.tps @@ -1,7 +1,7 @@ create or replace type ut_reporters as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_reporters_info.tps b/source/core/types/ut_reporters_info.tps index fa9484641..6e9a866ef 100644 --- a/source/core/types/ut_reporters_info.tps +++ b/source/core/types/ut_reporters_info.tps @@ -1,7 +1,7 @@ create or replace type ut_reporters_info as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_results_counter.tpb b/source/core/types/ut_results_counter.tpb index 2378bf640..0007acd9b 100644 --- a/source/core/types/ut_results_counter.tpb +++ b/source/core/types/ut_results_counter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_results_counter as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_results_counter.tps b/source/core/types/ut_results_counter.tps index c3ed97d71..1b26b673a 100644 --- a/source/core/types/ut_results_counter.tps +++ b/source/core/types/ut_results_counter.tps @@ -1,7 +1,7 @@ create or replace type ut_results_counter as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index 21a5ef36e..bff16dc69 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -1,7 +1,7 @@ create or replace type body ut_run as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -18,23 +18,24 @@ create or replace type body ut_run as constructor function ut_run( self in out nocopy ut_run, - a_items ut_suite_items, - a_run_paths ut_varchar2_list := null, - a_schema_names ut_varchar2_rows := null, - a_exclude_objects ut_object_names := null, - a_include_objects ut_object_names := null, - a_project_file_mappings ut_file_mappings := null, - a_test_file_mappings ut_file_mappings := null, - a_client_character_set varchar2 := null + a_items ut_suite_items, + a_run_paths ut_varchar2_list := null, + a_schema_names ut_varchar2_rows := null, + a_exclude_objects ut_object_names := null, + a_include_objects ut_object_names := null, + a_project_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_client_character_set varchar2 := null, + a_random_test_order_seed positive := null, + a_run_tags ut_varchar2_rows := null ) return self as result is - l_coverage_schema_names ut_varchar2_rows; - l_coverage_options ut_coverage_options; - l_exclude_objects ut_object_names; - begin + begin self.run_paths := a_run_paths; + self.run_tags := a_run_tags; self.self_type := $$plsql_unit; self.items := a_items; self.client_character_set := lower(a_client_character_set); + self.random_test_order_seed := a_random_test_order_seed; self.results_count := ut_results_counter(); self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings()); self.coverage_options := ut_coverage_options( diff --git a/source/core/types/ut_run.tps b/source/core/types/ut_run.tps index e4309e126..2a4e11656 100644 --- a/source/core/types/ut_run.tps +++ b/source/core/types/ut_run.tps @@ -1,7 +1,7 @@ create or replace type ut_run under ut_suite_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -21,19 +21,23 @@ create or replace type ut_run under ut_suite_item ( project_name varchar2(4000), items ut_suite_items, run_paths ut_varchar2_list, + run_tags ut_varchar2_rows, coverage_options ut_coverage_options, test_file_mappings ut_file_mappings, client_character_set varchar2(100), + random_test_order_seed number(38,0), constructor function ut_run( self in out nocopy ut_run, - a_items ut_suite_items, - a_run_paths ut_varchar2_list := null, - a_schema_names ut_varchar2_rows := null, - a_exclude_objects ut_object_names := null, - a_include_objects ut_object_names := null, - a_project_file_mappings ut_file_mappings := null, - a_test_file_mappings ut_file_mappings := null, - a_client_character_set varchar2 := null + a_items ut_suite_items, + a_run_paths ut_varchar2_list := null, + a_schema_names ut_varchar2_rows := null, + a_exclude_objects ut_object_names := null, + a_include_objects ut_object_names := null, + a_project_file_mappings ut_file_mappings := null, + a_test_file_mappings ut_file_mappings := null, + a_client_character_set varchar2 := null, + a_random_test_order_seed positive := null, + a_run_tags ut_varchar2_rows := null ) return self as result, overriding member procedure mark_as_skipped(self in out nocopy ut_run), overriding member function do_execute(self in out nocopy ut_run) return boolean, diff --git a/source/core/types/ut_run_info.tpb b/source/core/types/ut_run_info.tpb index f5a117f95..8e06d6137 100644 --- a/source/core/types/ut_run_info.tpb +++ b/source/core/types/ut_run_info.tpb @@ -1,7 +1,7 @@ create or replace type body ut_run_info as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_run_info.tps b/source/core/types/ut_run_info.tps index 6781e8a99..f59c22c05 100644 --- a/source/core/types/ut_run_info.tps +++ b/source/core/types/ut_run_info.tps @@ -1,7 +1,7 @@ create or replace type ut_run_info under ut_event_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_suite.tpb b/source/core/types/ut_suite.tpb index 14a457623..ccf004a4b 100644 --- a/source/core/types/ut_suite.tpb +++ b/source/core/types/ut_suite.tpb @@ -1,7 +1,7 @@ create or replace type body ut_suite as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -17,7 +17,8 @@ create or replace type body ut_suite as */ constructor function ut_suite ( - self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer + self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer, + a_tags ut_varchar2_rows := null ) return self as result is begin self.self_type := $$plsql_unit; @@ -25,6 +26,7 @@ create or replace type body ut_suite as self.items := ut_suite_items(); before_all_list := ut_executables(); after_all_list := ut_executables(); + self.tags := coalesce(a_tags,ut_varchar2_rows()); return; end; diff --git a/source/core/types/ut_suite.tps b/source/core/types/ut_suite.tps index 7057e4911..ffe2d2d42 100644 --- a/source/core/types/ut_suite.tps +++ b/source/core/types/ut_suite.tps @@ -1,7 +1,7 @@ create or replace type ut_suite under ut_logical_suite ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -27,7 +27,8 @@ create or replace type ut_suite under ut_logical_suite ( */ after_all_list ut_executables, constructor function ut_suite ( - self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer + self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer, + a_tags ut_varchar2_rows := null ) return self as result, overriding member function do_execute(self in out nocopy ut_suite) return boolean, overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list, diff --git a/source/core/types/ut_suite_context.tpb b/source/core/types/ut_suite_context.tpb index c8255f374..3669d3d7e 100644 --- a/source/core/types/ut_suite_context.tpb +++ b/source/core/types/ut_suite_context.tpb @@ -1,7 +1,7 @@ create or replace type body ut_suite_context as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_suite_context.tps b/source/core/types/ut_suite_context.tps index ce4510c39..a328e7657 100644 --- a/source/core/types/ut_suite_context.tps +++ b/source/core/types/ut_suite_context.tps @@ -1,7 +1,7 @@ create or replace type ut_suite_context under ut_suite ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_suite_item.tpb b/source/core/types/ut_suite_item.tpb index ef71975e5..6478d5c82 100644 --- a/source/core/types/ut_suite_item.tpb +++ b/source/core/types/ut_suite_item.tpb @@ -1,7 +1,7 @@ create or replace type body ut_suite_item as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -63,9 +63,11 @@ create or replace type body ut_suite_item as ex_savepoint_not_exists exception; l_transaction_invalidators clob; pragma exception_init(ex_savepoint_not_exists, -1086); + l_savepoint varchar2(250); begin if get_rollback_type() = ut_utils.gc_rollback_auto and a_savepoint is not null then - execute immediate 'rollback to ' || a_savepoint; + l_savepoint := sys.dbms_assert.qualified_sql_name(a_savepoint); + execute immediate 'rollback to ' || l_savepoint; end if; exception when ex_savepoint_not_exists then diff --git a/source/core/types/ut_suite_item.tps b/source/core/types/ut_suite_item.tps index 6b3b9c686..53c59a2ea 100644 --- a/source/core/types/ut_suite_item.tps +++ b/source/core/types/ut_suite_item.tps @@ -1,7 +1,7 @@ create or replace type ut_suite_item force under ut_event_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -60,6 +60,10 @@ create or replace type ut_suite_item force under ut_event_item ( warnings ut_varchar2_rows, results_count ut_results_counter, transaction_invalidators ut_varchar2_list, + /** + * Hold list of tags assign to test + */ + tags ut_varchar2_rows, member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer), member function get_disabled_flag return boolean, not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item), diff --git a/source/core/types/ut_suite_items.tps b/source/core/types/ut_suite_items.tps index ff5709ca8..e80bcc7b4 100644 --- a/source/core/types/ut_suite_items.tps +++ b/source/core/types/ut_suite_items.tps @@ -1,7 +1,7 @@ create or replace type ut_suite_items as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_test.tpb b/source/core/types/ut_test.tpb index 14620b24b..7b2c495de 100644 --- a/source/core/types/ut_test.tpb +++ b/source/core/types/ut_test.tpb @@ -1,7 +1,7 @@ create or replace type body ut_test as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ create or replace type body ut_test as constructor function ut_test( self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, - a_line_no integer, a_expected_error_codes ut_integer_list := null + a_line_no integer, a_expected_error_codes ut_integer_list := null, a_tags ut_varchar2_rows := null ) return self as result is begin self.self_type := $$plsql_unit; @@ -31,6 +31,7 @@ create or replace type body ut_test as self.all_expectations := ut_expectation_results(); self.failed_expectations := ut_expectation_results(); self.expected_error_codes := a_expected_error_codes; + self.tags := coalesce(a_tags,ut_varchar2_rows()); return; end; @@ -162,5 +163,15 @@ create or replace type body ut_test as end loop; return l_outputs; end; + + member function get_failed_expectation_lines return ut_varchar2_rows is + l_results ut_varchar2_rows; + begin + for i in 1 .. failed_expectations.count loop + ut_utils.append_to_list( l_results, ut_utils.convert_collection( failed_expectations(i).get_result_lines() ) ); + ut_utils.append_to_list( l_results, failed_expectations(i).caller_info ); + end loop; + return l_results; + end; end; / diff --git a/source/core/types/ut_test.tps b/source/core/types/ut_test.tps index 752ef3ef7..fcf565671 100644 --- a/source/core/types/ut_test.tps +++ b/source/core/types/ut_test.tps @@ -1,7 +1,7 @@ -create or replace type ut_test under ut_suite_item ( +create or replace type ut_test force under ut_suite_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -57,13 +57,14 @@ create or replace type ut_test under ut_suite_item ( expected_error_codes ut_integer_list, constructor function ut_test( self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, - a_line_no integer, a_expected_error_codes ut_integer_list := null + a_line_no integer, a_expected_error_codes ut_integer_list := null, a_tags ut_varchar2_rows := null ) return self as result, overriding member procedure mark_as_skipped(self in out nocopy ut_test), overriding member function do_execute(self in out nocopy ut_test) return boolean, overriding member procedure calc_execution_result(self in out nocopy ut_test), overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2), overriding member function get_error_stack_traces(self ut_test) return ut_varchar2_list, - overriding member function get_serveroutputs return clob + overriding member function get_serveroutputs return clob, + member function get_failed_expectation_lines return ut_varchar2_rows ) / diff --git a/source/core/types/ut_varchar2_list.tps b/source/core/types/ut_varchar2_list.tps index f324a2842..dd15f0d8f 100644 --- a/source/core/types/ut_varchar2_list.tps +++ b/source/core/types/ut_varchar2_list.tps @@ -1,7 +1,7 @@ create or replace type ut_varchar2_list as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/types/ut_varchar2_rows.tps b/source/core/types/ut_varchar2_rows.tps index ba8962378..d56eeee46 100644 --- a/source/core/types/ut_varchar2_rows.tps +++ b/source/core/types/ut_varchar2_rows.tps @@ -1,7 +1,7 @@ create or replace type ut_varchar2_rows as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/ut_dbms_output_cache.sql b/source/core/ut_dbms_output_cache.sql index 2102ab4ee..1fe4251c7 100644 --- a/source/core/ut_dbms_output_cache.sql +++ b/source/core/ut_dbms_output_cache.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 -Copyright 2016 - 2018 utPLSQL Project +Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb index 8767d8d8b..96ab022e4 100644 --- a/source/core/ut_expectation_processor.pkb +++ b/source/core/ut_expectation_processor.pkb @@ -1,7 +1,7 @@ create or replace package body ut_expectation_processor as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -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..cfcae8b42 100644 --- a/source/core/ut_expectation_processor.pks +++ b/source/core/ut_expectation_processor.pks @@ -1,7 +1,7 @@ create or replace package ut_expectation_processor authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -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_file_mapper.pkb b/source/core/ut_file_mapper.pkb index 35233b57b..adecb7dc8 100644 --- a/source/core/ut_file_mapper.pkb +++ b/source/core/ut_file_mapper.pkb @@ -1,7 +1,7 @@ create or replace package body ut_file_mapper is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/ut_file_mapper.pks b/source/core/ut_file_mapper.pks index 5402ef6e8..4ed670ee5 100644 --- a/source/core/ut_file_mapper.pks +++ b/source/core/ut_file_mapper.pks @@ -1,7 +1,7 @@ create or replace package ut_file_mapper authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/ut_metadata.pkb b/source/core/ut_metadata.pkb index a254529f8..a33dfc1eb 100644 --- a/source/core/ut_metadata.pkb +++ b/source/core/ut_metadata.pkb @@ -1,7 +1,7 @@ create or replace package body ut_metadata as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -21,31 +21,6 @@ create or replace package body ut_metadata as g_cached_object varchar2(500); ------------------------------ --public definitions - - procedure do_resolve(a_owner in out nocopy varchar2, a_object in out nocopy varchar2, a_procedure_name in out nocopy varchar2) is - l_name varchar2(200); - l_context integer := 1; --plsql - begin - l_name := form_name(a_owner, a_object, a_procedure_name); - do_resolve(l_name,l_context,a_owner,a_object, a_procedure_name); - end do_resolve; - - procedure do_resolve(a_fully_qualified_name in varchar2,a_context in integer,a_owner out nocopy varchar2, a_object out nocopy varchar2, - a_procedure_name out nocopy varchar2) is - l_dblink varchar2(200); - l_part1_type number; - l_object_number number; - begin - dbms_utility.name_resolve(name => a_fully_qualified_name - ,context => a_context - ,schema => a_owner - ,part1 => a_object - ,part2 => a_procedure_name - ,dblink => l_dblink - ,part1_type => l_part1_type - ,object_number => l_object_number); - end; - function form_name(a_owner_name varchar2, a_object varchar2, a_subprogram varchar2 default null) return varchar2 is l_name varchar2(200); begin @@ -61,25 +36,16 @@ create or replace package body ut_metadata as function package_valid(a_owner_name varchar2, a_package_name in varchar2) return boolean as l_cnt number; - l_schema varchar2(200); - l_package_name varchar2(200); - l_procedure_name varchar2(200); l_view_name varchar2(200) := get_objects_view_name; begin - l_schema := a_owner_name; - l_package_name := a_package_name; - - do_resolve(l_schema, l_package_name, l_procedure_name); - - execute immediate q'[select count(decode(status, 'VALID', 1, null)) / count(*) + execute immediate q'[select count(*) from ]'||l_view_name||q'[ - where owner = :l_schema - and object_name = :l_package_name - and object_type in ('PACKAGE')]' - into l_cnt using l_schema, l_package_name; - - -- expect both package and body to be valid + where owner = :a_owner_name + and object_name = :a_package_name + and object_type = 'PACKAGE' + and status = 'VALID']' + into l_cnt using upper(a_owner_name), upper(a_package_name); return l_cnt = 1; exception when others then @@ -89,22 +55,12 @@ create or replace package body ut_metadata as function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2) return boolean as l_cnt number; - l_schema varchar2(200); - l_package_name varchar2(200); - l_procedure_name varchar2(200); l_view_name varchar2(200) := get_dba_view('dba_procedures'); begin - - l_schema := a_owner_name; - l_package_name := a_package_name; - l_procedure_name := a_procedure_name; - - do_resolve(l_schema, l_package_name, l_procedure_name); - execute immediate 'select count(*) from '||l_view_name - ||' where owner = :l_schema and object_name = :l_package_name and procedure_name = :l_procedure_name' - into l_cnt using l_schema, l_package_name, l_procedure_name; + ||' where owner = :l_schema and object_name = :l_package_name and procedure_name = :l_procedure_name and rownum = 1' + into l_cnt using a_owner_name, a_package_name, a_procedure_name; --expect one method only for the package with that name. return l_cnt = 1; @@ -306,15 +262,17 @@ create or replace package body ut_metadata as function is_anytype_null(a_value in anydata, a_compound_type in varchar2) return number is l_result integer := 0; l_anydata_sql varchar2(4000); + l_compound_type varchar2(250); begin - if a_value is not null then - l_anydata_sql := ' + if a_value is not null then + l_compound_type := sys.dbms_assert.qualified_sql_name(a_compound_type); + l_anydata_sql := ' declare l_data '||get_anydata_typename(a_value)||'; l_value anydata := :a_value; l_status integer; begin - l_status := l_value.get'||a_compound_type||'(l_data); + l_status := l_value.get'||l_compound_type||'(l_data); :l_data_is_null := case when l_data is null then 1 else 0 end; end;'; execute immediate l_anydata_sql using in a_value, out l_result; @@ -325,12 +283,16 @@ create or replace package body ut_metadata as end; function get_object_name(a_full_object_name in varchar2) return varchar2 is - l_schema varchar2(250); - l_object varchar2(250); - l_procedure_name varchar2(250); + l_result varchar2(250); begin - ut_metadata.do_resolve(a_full_object_name,7,l_schema,l_object, l_procedure_name); - return l_object; + l_result := regexp_substr( + a_full_object_name, + '^([A-Za-z0-9$#_]+|".*?")\.([A-Za-z0-9$#_]+|".*?")', subexpression => 2 + ); + if not l_result like '"%"' then + l_result := upper(l_result); + end if; + return sys.dbms_assert.qualified_sql_name(l_result); end; function get_anydata_compound_type(a_data_value anydata) return varchar2 is diff --git a/source/core/ut_metadata.pks b/source/core/ut_metadata.pks index 184943f2a..bf62c4e52 100644 --- a/source/core/ut_metadata.pks +++ b/source/core/ut_metadata.pks @@ -1,7 +1,7 @@ create or replace package ut_metadata authid current_user as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -64,18 +64,6 @@ create or replace package ut_metadata authid current_user as function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2) return boolean; - /** - * Resolves [owner.]object[.procedure] using dbms_utility.name_resolve and returns resolved parts - * - */ - procedure do_resolve(a_owner in out nocopy varchar2, a_object in out nocopy varchar2, a_procedure_name in out nocopy varchar2); - - /** - * Resolves single string [owner.]object[.procedure] using dbms_utility.name_resolve and returns parts [owner] [object] [procedure] - */ - procedure do_resolve(a_fully_qualified_name in varchar2,a_context in integer,a_owner out nocopy varchar2, - a_object out nocopy varchar2, a_procedure_name out nocopy varchar2); - /** * Return the text of the source line for a given object (body). It excludes package spec and type spec */ diff --git a/source/core/ut_savepoint_seq.sql b/source/core/ut_savepoint_seq.sql index 6ccfc182a..e1d80f452 100644 --- a/source/core/ut_savepoint_seq.sql +++ b/source/core/ut_savepoint_seq.sql @@ -1,7 +1,7 @@ create sequence ut_savepoint_seq /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index b9e5b1b22..d3de777db 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -1,7 +1,7 @@ create or replace package body ut_suite_builder is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ create or replace package body ut_suite_builder is See the License for the specific language governing permissions and limitations under the License. */ - + subtype t_annotation_text is varchar2(4000); subtype t_annotation_name is varchar2(4000); subtype t_object_name is varchar2(500); @@ -23,6 +23,7 @@ create or replace package body ut_suite_builder is gc_suite constant t_annotation_name := 'suite'; gc_suitepath constant t_annotation_name := 'suitepath'; + gc_tags constant t_annotation_name := 'tags'; gc_test constant t_annotation_name := ut_utils.gc_test_execute; gc_disabled constant t_annotation_name := 'disabled'; gc_displayname constant t_annotation_name := 'displayname'; @@ -43,6 +44,7 @@ create or replace package body ut_suite_builder is := tt_annotations( gc_suite, gc_suitepath, + gc_tags, gc_test, gc_disabled, gc_displayname, @@ -304,7 +306,34 @@ create or replace package body ut_suite_builder is l_annotation_pos := a_throws_ann_text.next(l_annotation_pos); end loop; end; - + + procedure add_tags_to_suite_item( + a_suite in out nocopy ut_suite, + a_tags_ann_text tt_annotation_texts, + a_list in out nocopy ut_varchar2_rows, + a_procedure_name t_object_name := null + ) is + l_annotation_pos binary_integer; + l_tag_list ut_varchar2_list := ut_varchar2_list(); + begin + l_annotation_pos := a_tags_ann_text.first; + while l_annotation_pos is not null loop + if a_tags_ann_text(l_annotation_pos) is null then + a_suite.put_warning( + '"--%tags" annotation requires a tag value populated. Annotation ignored.' + || chr( 10 ) || 'at "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || l_annotation_pos + ); + else + l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements( + ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',') + ); + end if; + l_annotation_pos := a_tags_ann_text.next(l_annotation_pos); + end loop; + --remove empty strings from table list e.g. tag1,,tag2 and conver to rows + a_list := ut_utils.convert_collection( ut_utils.filter_list(l_tag_list,ut_utils.gc_word_no_space) ); + end; + procedure set_seq_no( a_list in out nocopy ut_executables ) is @@ -483,13 +512,19 @@ create or replace package body ut_suite_builder is ); set_seq_no(l_test.after_test_list); end if; + + if l_proc_annotations.exists( gc_tags) then + add_tags_to_suite_item(a_suite, l_proc_annotations( gc_tags), l_test.tags, a_procedure_name); + end if; + if l_proc_annotations.exists( gc_throws) then add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, l_proc_annotations( gc_throws)); end if; l_test.disabled_flag := ut_utils.boolean_to_int( l_proc_annotations.exists( gc_disabled)); - + a_suite_items.extend; a_suite_items( a_suite_items.last ) := l_test; + end; procedure propagate_before_after_each( @@ -631,7 +666,10 @@ create or replace package body ut_suite_builder is if a_annotations.by_name.exists(gc_aftereach) then l_after_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_aftereach), gc_aftereach ); end if; - + + if a_annotations.by_name.exists(gc_tags) then + add_tags_to_suite_item(a_suite, a_annotations.by_name(gc_tags),a_suite.tags); + end if; a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled)); --process procedure annotations for suite diff --git a/source/core/ut_suite_builder.pks b/source/core/ut_suite_builder.pks index 5e2624a30..e982fdbc1 100644 --- a/source/core/ut_suite_builder.pks +++ b/source/core/ut_suite_builder.pks @@ -1,7 +1,7 @@ create or replace package ut_suite_builder authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/ut_suite_cache.sql b/source/core/ut_suite_cache.sql index adbdf1734..e4bf52439 100644 --- a/source/core/ut_suite_cache.sql +++ b/source/core/ut_suite_cache.sql @@ -6,7 +6,7 @@ create or replace type ut_tests as table of ut_test create table ut_suite_cache ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -36,6 +36,7 @@ create table ut_suite_cache ( after_each_list, after_test_list, expected_error_codes, + tags, item ) nested table warnings store as ut_suite_cache_warnings @@ -45,7 +46,8 @@ create table ut_suite_cache ( nested table after_each_list store as ut_suite_cache_after_each nested table before_test_list store as ut_suite_cache_before_test nested table after_test_list store as ut_suite_cache_after_test - nested table expected_error_codes store as ut_suite_cache_trhows + nested table expected_error_codes store as ut_suite_cache_throws + nested table tags store as ut_suite_cache_tags return as locator as select cast(null as number(22)) id, @@ -67,6 +69,7 @@ create table ut_suite_cache ( t.after_each_list, t.after_test_list, t.expected_error_codes, + t.tags, t.item from table(ut_suite_contexts(ut_suite_context(user,'package_name','ctx_name',1))) c cross join table(ut_tests(ut_test(user,'package_name','test_name',1))) t diff --git a/source/core/ut_suite_cache_manager.pkb b/source/core/ut_suite_cache_manager.pkb index ce7f018e0..b8b548a4b 100644 --- a/source/core/ut_suite_cache_manager.pkb +++ b/source/core/ut_suite_cache_manager.pkb @@ -1,7 +1,7 @@ create or replace package body ut_suite_cache_manager is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -90,7 +90,8 @@ create or replace package body ut_suite_cache_manager is before_all_list, after_all_list, before_each_list, after_each_list, before_test_list, after_test_list, - expected_error_codes, item + expected_error_codes, tags, + item ) with suites as ( select treat(value(x) as ut_suite) i @@ -103,7 +104,8 @@ create or replace package body ut_suite_cache_manager is s.i.before_all_list as before_all_list, s.i.after_all_list as after_all_list, null before_each_list, null after_each_list, null before_test_list, null after_test_list, - null expected_error_codes, null item + null expected_error_codes, s.i.tags tags, + null item from suites s; insert into ut_suite_cache t @@ -114,7 +116,8 @@ create or replace package body ut_suite_cache_manager is before_all_list, after_all_list, before_each_list, after_each_list, before_test_list, after_test_list, - expected_error_codes, item + expected_error_codes, tags, + item ) with tests as ( select treat(value(x) as ut_test) t @@ -127,9 +130,10 @@ create or replace package body ut_suite_cache_manager is null before_all_list, null after_all_list, s.t.before_each_list as before_each_list, s.t.after_each_list as after_each_list, s.t.before_test_list as before_test_list, s.t.after_test_list as after_test_list, - s.t.expected_error_codes as expected_error_codes, s.t.item as item + s.t.expected_error_codes as expected_error_codes, s.t.tags as test_tags, + s.t.item as item from tests s; - + end if; end if; commit; diff --git a/source/core/ut_suite_cache_manager.pks b/source/core/ut_suite_cache_manager.pks index 02c47988e..03816ee70 100644 --- a/source/core/ut_suite_cache_manager.pks +++ b/source/core/ut_suite_cache_manager.pks @@ -1,7 +1,7 @@ create or replace package ut_suite_cache_manager authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/core/ut_suite_cache_package.sql b/source/core/ut_suite_cache_package.sql index 46f49e915..06f786949 100644 --- a/source/core/ut_suite_cache_package.sql +++ b/source/core/ut_suite_cache_package.sql @@ -1,7 +1,7 @@ create table ut_suite_cache_package ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/ut_suite_cache_schema.sql b/source/core/ut_suite_cache_schema.sql index ba257dafd..46c7b0ef3 100644 --- a/source/core/ut_suite_cache_schema.sql +++ b/source/core/ut_suite_cache_schema.sql @@ -1,7 +1,7 @@ create table ut_suite_cache_schema ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/ut_suite_cache_seq.sql b/source/core/ut_suite_cache_seq.sql index 0c9c835b8..36de28809 100644 --- a/source/core/ut_suite_cache_seq.sql +++ b/source/core/ut_suite_cache_seq.sql @@ -1,7 +1,7 @@ create sequence ut_suite_cache_seq /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index e2098caf9..1ffd5ea49 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -1,7 +1,7 @@ create or replace package body ut_suite_manager is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -18,6 +18,70 @@ create or replace package body ut_suite_manager is gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: '; + gc_get_cache_suite_sql constant varchar2(32767) := + q'[with + suite_items as ( + select /*+ cardinality(c 100) */ c.* + from {:owner:}.ut_suite_cache c + where 1 = 1 {:object_list:} + and c.object_owner = '{:object_owner:}' + and ( {:path:} + and {:object_name:} + and {:procedure_name:} + ) + ) + ), + {:tags:}, + suitepaths as ( + select distinct substr(path,1,instr(path,'.',-1)-1) as suitepath, + path, + object_owner + from {:suite_item_name:} + where self_type = 'UT_SUITE' + ), + gen as ( + select rownum as pos + from xmltable('1 to 20') + ), + suitepath_part AS ( + select distinct + substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, + object_owner + from suitepaths b + join gen g + on g.pos <= regexp_count(b.suitepath, '\w+') + ), + logical_suite_data as ( + select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner, + upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name, + cast(null as {:owner:}.ut_executables) as x, + cast(null as {:owner:}.ut_integer_list) as y, + cast(null as {:owner:}.ut_executable_test) as z + from suitepath_part p + where p.path + not in (select s.path from suitepaths s) + ), + logical_suites as ( + select to_number(null) as id, s.self_type, s.path, s.object_owner, s.object_name, + s.object_name as name, null as line_no, null as parse_time, + null as description, null as rollback_type, 0 as disabled_flag, + {:owner:}.ut_varchar2_rows() as warnings, + s.x as before_all_list, s.x as after_all_list, + s.x as before_each_list, s.x as before_test_list, + s.x as after_each_list, s.x as after_test_list, + s.y as expected_error_codes, null as test_tags, + s.z as item + from logical_suite_data s + ), + items as ( + select * from {:suite_item_name:} + union all + select * from logical_suites + ) + select c.* + from items c + order by c.object_owner,{:random_seed:}]'; + type t_path_item is record ( object_name varchar2(250), procedure_name varchar2(250), @@ -100,6 +164,7 @@ create or replace package body ut_suite_manager is l_schema_names.extend; l_schema_names(l_schema_names.last) := l_schema; end loop; + return l_schema_names; end; @@ -192,7 +257,7 @@ create or replace package body ut_suite_manager is results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), items => a_items_at_level(a_prev_level), before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list) + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags ) else ut_suite( @@ -205,7 +270,7 @@ create or replace package body ut_suite_manager is results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), items => ut_suite_items(), before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list) + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags ) end; when 'UT_SUITE_CONTEXT' then @@ -221,7 +286,7 @@ create or replace package body ut_suite_manager is results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), items => a_items_at_level(a_prev_level), before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list) + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags ) else ut_suite_context( @@ -234,7 +299,7 @@ create or replace package body ut_suite_manager is results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), items => ut_suite_items(), before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list) + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags ) end; when 'UT_LOGICAL_SUITE' then @@ -248,7 +313,7 @@ create or replace package body ut_suite_manager is line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level) + items => a_items_at_level(a_prev_level), tags => null ) else ut_logical_suite( @@ -259,7 +324,7 @@ create or replace package body ut_suite_manager is line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items() + items => ut_suite_items(), tags => null ) end; when 'UT_TEST' then @@ -276,7 +341,8 @@ create or replace package body ut_suite_manager is item => a_rows(a_idx).item, after_test_list => sort_by_seq_no(a_rows(a_idx).after_test_list), after_each_list => sort_by_seq_no(a_rows(a_idx).after_each_list), all_expectations => ut_expectation_results(), failed_expectations => ut_expectation_results(), - parent_error_stack_trace => null, expected_error_codes => a_rows(a_idx).expected_error_codes + parent_error_stack_trace => null, expected_error_codes => a_rows(a_idx).expected_error_codes, + tags => a_rows(a_idx).tags ); end case; l_result.results_count.warnings_count := l_result.warnings.count; @@ -332,136 +398,161 @@ create or replace package body ut_suite_manager is function get_missing_objects(a_object_owner varchar2) return ut_varchar2_rows is l_rows sys_refcursor; l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); l_cursor_text varchar2(32767); l_result ut_varchar2_rows; + l_object_owner varchar2(250); begin + l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner); l_cursor_text := q'[select i.object_name from ]'||l_ut_owner||q'[.ut_suite_cache_package i where not exists ( - select 1 from ]'||l_objects_view||q'[ o - where o.owner = i.object_owner + select 1 from ]'||l_ut_owner||q'[.ut_annotation_cache_info o + where o.object_owner = i.object_owner and o.object_name = i.object_name and o.object_type = 'PACKAGE' - and o.owner = ']'||a_object_owner||q'[' ) - and i.object_owner = ']'||a_object_owner||q'[']'; + and i.object_owner = ']'||l_object_owner||q'[']'; open l_rows for l_cursor_text; fetch l_rows bulk collect into l_result limit 1000000; close l_rows; return l_result; end; - function get_cached_suite_data( - a_object_owner varchar2, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false - ) return t_cached_suites_cursor is - l_path varchar2( 4000 ); - l_result sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; + function get_object_names_sql(a_skip_all_objects boolean ) return varchar2 is begin - if a_path is null and a_object_name is not null then - execute immediate 'select min(path) - from '||l_ut_owner||q'[.ut_suite_cache - where object_owner = :a_object_owner - and object_name = :a_object_name - and name = nvl(:a_procedure_name, name)]' - into l_path using upper(a_object_owner), upper(a_object_name), upper(a_procedure_name); - else - l_path := lower( a_path ); - end if; - - open l_result for - q'[with - suite_items as ( - select /*+ cardinality(c 100) */ c.* - from ]'||l_ut_owner||q'[.ut_suite_cache c - where 1 = 1 ]'||case when not a_skip_all_objects then q'[ + return case when not a_skip_all_objects then q'[ and exists ( select 1 from all_objects a where a.object_name = c.object_name - and a.owner = ']'||upper(a_object_owner)||q'[' + and a.owner = '{:object_owner:}' and a.owner = c.object_owner and a.object_type = 'PACKAGE' - )]' end ||q'[ - and c.object_owner = ']'||upper(a_object_owner)||q'[' - and ( ]' || case when l_path is not null then q'[ + )]' else null end; + end; + + function get_path_sql(a_path in varchar2) return varchar2 is + begin + return case when a_path is not null then q'[ :l_path||'.' like c.path || '.%' /*all children and self*/ or ( c.path||'.' like :l_path || '.%' --all parents ]' - else ' :l_path is null and ( :l_path is null ' end - || case when a_object_name is not null - then 'and c.object_name = :a_object_name ' - else 'and :a_object_name is null' end ||' - '|| case when a_procedure_name is not null - then 'and c.name = :a_procedure_name' - else 'and :a_procedure_name is null' end ||q'[ - ) - ) - ), - suitepaths as ( - select distinct substr(path,1,instr(path,'.',-1)-1) as suitepath, - path, - object_owner - from suite_items - where self_type = 'UT_SUITE' - ), - gen as ( - select rownum as pos - from xmltable('1 to 20') - ), - suitepath_part AS ( - select distinct - substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, - object_owner - from suitepaths b - join gen g - on g.pos <= regexp_count(b.suitepath, '\w+') - ), - logical_suite_data as ( - select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner, - upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name, - cast(null as ]'||l_ut_owner||q'[.ut_executables) as x, - cast(null as ]'||l_ut_owner||q'[.ut_integer_list) as y, - cast(null as ]'||l_ut_owner||q'[.ut_executable_test) as z - from suitepath_part p - where p.path - not in (select s.path from suitepaths s) - ), - logical_suites as ( - select to_number(null) as id, s.self_type, s.path, s.object_owner, s.object_name, - s.object_name as name, null as line_no, null as parse_time, - null as description, null as rollback_type, 0 as disabled_flag, - ]'||l_ut_owner||q'[.ut_varchar2_rows() as warnings, - s.x as before_all_list, s.x as after_all_list, - s.x as before_each_list, s.x as before_test_list, - s.x as after_each_list, s.x as after_test_list, - s.y as expected_error_codes, s.z as item - from logical_suite_data s + else ' :l_path is null and ( :l_path is null ' end; + end; + + function get_object_name_sql(a_object_name in varchar2) return varchar2 is + begin + return case when a_object_name is not null + then ' c.object_name = :a_object_name ' + else ' :a_object_name is null' end; + end; + + function get_procedure_name_sql(a_procedure_name in varchar2) return varchar2 is + begin + return case when a_procedure_name is not null + then ' c.name = :a_procedure_name' + else ' :a_procedure_name is null' end; + end; + + function get_tags_sql(a_tags_count in integer) return varchar2 is + begin + return case when a_tags_count > 0 then + q'[filter_tags as ( + select c.* + from suite_items c + where c.tags multiset intersect :a_tag_list is not empty ), - items as ( - select * from suite_items - union all - select * from logical_suites - ) - select c.* - from items c - order by c.object_owner, - replace(case - when c.self_type in ( 'UT_TEST' ) - then substr(c.path, 1, instr(c.path, '.', -1) ) - else c.path - end, '.', chr(0)) desc nulls last, + suite_items_tags as ( + select c.* from suite_items c + where exists (select 1 from filter_tags t where + t.path||'.' like c.path || '.%' /*all children and self*/ + or c.path||'.' like t.path || '.%' --all parents + ) + )]' + else + q'[dummy as (select 'x' from dual where :a_tag_list is null )]' + end; + end; + + function get_random_seed_sql(a_random_seed positive) return varchar2 is + begin + return case + when a_random_seed is null then q'[ + replace( + case + when c.self_type in ( 'UT_TEST' ) + then substr(c.path, 1, instr(c.path, '.', -1) ) + else c.path + end, '.', chr(0) + ) desc nulls last, c.object_name desc, - c.line_no]' - using l_path, l_path, upper(a_object_name), upper(a_procedure_name); + c.line_no, + :a_random_seed]' + else + ' {:owner:}.ut_annotation_manager.hash_suite_path( + c.path, :a_random_seed + ) desc nulls last' + end; + end; + function get_cached_suite_data( + a_object_owner varchar2, + a_path varchar2 := null, + a_object_name varchar2 := null, + a_procedure_name varchar2 := null, + a_skip_all_objects boolean := false, + a_random_seed positive, + a_tags ut_varchar2_rows := null + ) return t_cached_suites_cursor is + l_path varchar2(4000); + l_result sys_refcursor; + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_sql varchar2(32767); + l_suite_item_name varchar2(20); + l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows()); + l_object_owner varchar2(250); + l_object_name varchar2(250); + l_procedure_name varchar2(250); + begin + if a_object_owner is not null then + l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner); + end if; + if a_object_name is not null then + l_object_name := sys.dbms_assert.qualified_sql_name(a_object_name); + end if; + if a_procedure_name is not null then + l_procedure_name := sys.dbms_assert.qualified_sql_name(a_procedure_name); + end if; + if a_path is null and a_object_name is not null then + execute immediate 'select min(path) + from '||l_ut_owner||q'[.ut_suite_cache + where object_owner = :a_object_owner + and object_name = :a_object_name + and name = nvl(:a_procedure_name, name)]' + into l_path using upper(l_object_owner), upper(l_object_name), upper(a_procedure_name); + else + if a_path is not null then + l_path := lower(sys.dbms_assert.qualified_sql_name(a_path)); + end if; + end if; + l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end; + + l_sql := gc_get_cache_suite_sql; + l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name); + l_sql := replace(l_sql,'{:object_list:}',get_object_names_sql(a_skip_all_objects)); + l_sql := replace(l_sql,'{:object_owner:}',upper(l_object_owner)); + l_sql := replace(l_sql,'{:path:}',get_path_sql(l_path)); + l_sql := replace(l_sql,'{:object_name:}',get_object_name_sql(l_object_name)); + l_sql := replace(l_sql,'{:procedure_name:}',get_procedure_name_sql(l_procedure_name)); + l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count)); + l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed)); + l_sql := replace(l_sql,'{:owner:}',l_ut_owner); + + ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) ); + + open l_result for l_sql using l_path, l_path, upper(a_object_name), upper(a_procedure_name), l_tags, a_random_seed; return l_result; end; @@ -469,7 +560,7 @@ create or replace package body ut_suite_manager is a_owner_name varchar2 ) return boolean is begin - return sys_context( 'userenv', 'current_schema' ) = a_owner_name or ut_metadata.user_has_execute_any_proc(); + return sys_context( 'userenv', 'current_schema' ) = a_owner_name or ut_metadata.user_has_execute_any_proc() or ut_trigger_check.is_alive(); end; procedure build_and_cache_suites( @@ -483,6 +574,7 @@ create or replace package body ut_suite_manager is ex_string_too_small exception; pragma exception_init (ex_string_too_small,-06502); begin + ut_event_manager.trigger_event('build_and_cache_suites - start'); loop fetch a_annotated_objects bulk collect into l_annotated_objects limit 10; @@ -511,28 +603,25 @@ create or replace package body ut_suite_manager is ut_utils.to_string(gc_suitpath_error_message||ut_utils.table_to_clob(l_bad_suitepath_obj,',')) ); end if; + ut_event_manager.trigger_event('build_and_cache_suites - end'); end; procedure refresh_cache( - a_owner_name varchar2, - a_annotations_cursor sys_refcursor := null + a_owner_name varchar2 ) is l_annotations_cursor sys_refcursor; l_suite_cache_time timestamp; begin + ut_event_manager.trigger_event('refresh_cache - start'); l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(a_owner_name); - if a_annotations_cursor is not null then - l_annotations_cursor := a_annotations_cursor; - else - open l_annotations_cursor for - q'[select value(x) - from table( - ]' || ut_utils.ut_owner || q'[.ut_annotation_manager.get_annotated_objects( - :a_owner_name, 'PACKAGE', :a_suite_cache_parse_time - ) - )x ]' - using a_owner_name, l_suite_cache_time; - end if; + open l_annotations_cursor for + q'[select value(x) + from table( + ]' || ut_utils.ut_owner || q'[.ut_annotation_manager.get_annotated_objects( + :a_owner_name, 'PACKAGE', :a_suite_cache_parse_time + ) + )x ]' + using a_owner_name, l_suite_cache_time; build_and_cache_suites(a_owner_name, l_annotations_cursor); @@ -540,6 +629,7 @@ create or replace package body ut_suite_manager is ut_suite_cache_manager.remove_from_cache( a_owner_name, get_missing_objects(a_owner_name) ); end if; + ut_event_manager.trigger_event('refresh_cache - end'); end; procedure add_suites_for_path( @@ -547,7 +637,9 @@ create or replace package body ut_suite_manager is a_path varchar2 := null, a_object_name varchar2 := null, a_procedure_name varchar2 := null, - a_suites in out nocopy ut_suite_items + a_suites in out nocopy ut_suite_items, + a_random_seed positive, + a_tags ut_varchar2_rows := null ) is begin refresh_cache(a_owner_name); @@ -559,7 +651,9 @@ create or replace package body ut_suite_manager is a_path, a_object_name, a_procedure_name, - can_skip_all_objects_scan(a_owner_name) + can_skip_all_objects_scan(a_owner_name), + a_random_seed, + a_tags ) ); @@ -588,7 +682,9 @@ create or replace package body ut_suite_manager is a_path, a_object_name, a_procedure_name, - a_skip_all_objects + a_skip_all_objects, + null, + null ) ); return l_suites; @@ -639,14 +735,19 @@ create or replace package body ut_suite_manager is return resolve_schema_names(l_paths); end; - function configure_execution_by_path(a_paths in ut_varchar2_list) return ut_suite_items is + function configure_execution_by_path(a_paths ut_varchar2_list, a_random_seed positive := null) return ut_suite_items is l_suites ut_suite_items := ut_suite_items(); begin configure_execution_by_path(a_paths, l_suites ); return l_suites; end; - procedure configure_execution_by_path(a_paths in ut_varchar2_list, a_suites out nocopy ut_suite_items) is + procedure configure_execution_by_path( + a_paths ut_varchar2_list, + a_suites out nocopy ut_suite_items, + a_random_seed positive := null, + a_tags ut_varchar2_rows := ut_varchar2_rows() + ) is l_paths ut_varchar2_list := a_paths; l_path_items t_path_items; l_path_item t_path_item; @@ -655,6 +756,7 @@ create or replace package body ut_suite_manager is l_index varchar2(4000 char); l_schema_paths t_schema_paths; begin + ut_event_manager.trigger_event('configure_execution_by_path - start'); a_suites := ut_suite_items(); --resolve schema names from paths and group paths by schema name resolve_schema_names(l_paths); @@ -671,7 +773,9 @@ create or replace package body ut_suite_manager is l_path_item.suite_path, l_path_item.object_name, l_path_item.procedure_name, - a_suites + a_suites, + a_random_seed, + a_tags ); if a_suites.count = l_suites_count then if l_path_item.suite_path is not null then @@ -693,35 +797,44 @@ create or replace package body ut_suite_manager is a_suites(i).set_rollback_type( a_suites(i).get_rollback_type() ); end loop; + ut_event_manager.trigger_event('configure_execution_by_path - start'); end configure_execution_by_path; function get_suites_info( a_owner_name varchar2, a_package_name varchar2 := null ) return sys_refcursor is - l_result sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_result sys_refcursor; + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_owner_name varchar2(250); + l_package_name varchar2(250); begin + if a_owner_name is not null then + l_owner_name := sys.dbms_assert.qualified_sql_name(a_owner_name); + end if; + if a_package_name is not null then + l_package_name := sys.dbms_assert.qualified_sql_name(a_package_name); + end if; - refresh_cache(a_owner_name); + refresh_cache(l_owner_name); open l_result for q'[with suite_items as ( select /*+ cardinality(c 100) */ c.* from ]'||l_ut_owner||q'[.ut_suite_cache c - where 1 = 1 ]'||case when can_skip_all_objects_scan(a_owner_name) then q'[ + where 1 = 1 ]'||case when can_skip_all_objects_scan(l_owner_name) then q'[ and exists ( select 1 from all_objects a where a.object_name = c.object_name - and a.owner = ']'||upper(a_owner_name)||q'[' + and a.owner = ']'||upper(l_owner_name)||q'[' and a.owner = c.object_owner and a.object_type = 'PACKAGE' )]' end ||q'[ - and c.object_owner = ']'||upper(a_owner_name) ||q'[' + and c.object_owner = ']'||upper(l_owner_name)||q'[' and ]' - || case when a_package_name is not null + || case when l_package_name is not null then 'c.object_name = :a_package_name' else ':a_package_name is null' end || q'[ @@ -757,19 +870,19 @@ create or replace package body ut_suite_manager is items as ( select object_owner, object_name, name as item_name, description as item_description, self_type as item_type, line_no as item_line_no, - path, disabled_flag + path, disabled_flag,tags from suite_items union all select object_owner, object_name, object_name as item_name, null as item_description, item_type, null as item_line_no, - s.path, 0 as disabled_flag + s.path, 0 as disabled_flag, ]'||l_ut_owner||q'[.ut_varchar2_rows() as tags from logical_suites s ) select ]'||l_ut_owner||q'[.ut_suite_item_info( object_owner, object_name, item_name, item_description, - item_type, item_line_no, path, disabled_flag + item_type, item_line_no, path, disabled_flag, tags ) - from items c]' using upper(a_package_name); + from items c]' using upper(l_package_name); return l_result; end; @@ -780,17 +893,30 @@ create or replace package body ut_suite_manager is a_procedure_name varchar2 := null, a_item_type varchar2 := null ) return boolean is - l_result integer; - l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_result integer; + l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_owner_name varchar2(250); + l_package_name varchar2(250); + l_procedure_name varchar2(250); begin - refresh_cache(a_owner_name); + if a_owner_name is not null then + l_owner_name := sys.dbms_assert.qualified_sql_name(a_owner_name); + end if; + if a_package_name is not null then + l_package_name := sys.dbms_assert.qualified_sql_name(a_package_name); + end if; + if a_procedure_name is not null then + l_procedure_name := sys.dbms_assert.qualified_sql_name(a_procedure_name); + end if; + + refresh_cache(l_owner_name); execute immediate q'[ select count(1) from dual where exists ( select 1 from ]'||l_ut_owner||q'[.ut_suite_cache c - where 1 = 1 ]'||case when can_skip_all_objects_scan(a_owner_name) then q'[ + where 1 = 1 ]'||case when not can_skip_all_objects_scan(l_owner_name) then q'[ and exists ( select 1 from all_objects a @@ -802,20 +928,20 @@ create or replace package body ut_suite_manager is and :a_owner_name is not null ]' end ||q'[ and c.object_owner = :a_owner_name and ]' - || case when a_package_name is not null + || case when l_package_name is not null then 'c.object_name = :a_package_name' else ':a_package_name is null' end || q'[ and ]' - || case when a_procedure_name is not null + || case when l_procedure_name is not null then 'c.name = :a_procedure_name' else ':a_procedure_name is null' end || q'[ )]' into l_result using - upper(a_owner_name), upper(a_owner_name), - upper(a_package_name), upper(a_procedure_name); + upper(l_owner_name), upper(l_owner_name), + upper(l_package_name), upper(l_procedure_name); return l_result > 0; end; diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks index 5fd82f9be..fe492b049 100644 --- a/source/core/ut_suite_manager.pks +++ b/source/core/ut_suite_manager.pks @@ -1,7 +1,7 @@ create or replace package ut_suite_manager authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ create or replace package ut_suite_manager authid current_user is * @return array containing root suites-ready to be executed * */ - function configure_execution_by_path(a_paths in ut_varchar2_list) return ut_suite_items; + function configure_execution_by_path(a_paths ut_varchar2_list, a_random_seed positive := null) return ut_suite_items; /** * Builds a hierarchical suites based on given suite-paths @@ -46,7 +46,12 @@ create or replace package ut_suite_manager authid current_user is * @param a_suites returned array containing root suites-ready to be executed * */ - procedure configure_execution_by_path(a_paths in ut_varchar2_list, a_suites out nocopy ut_suite_items); + procedure configure_execution_by_path( + a_paths in ut_varchar2_list, + a_suites out nocopy ut_suite_items, + a_random_seed in positive := null, + a_tags ut_varchar2_rows := ut_varchar2_rows() + ); /** * Cleanup paths by removing leading/trailing whitespace and making paths lowercase diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index b29e7fa60..d56df250c 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -1,7 +1,7 @@ create or replace package body ut_utils is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -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; @@ -234,7 +241,9 @@ create or replace package body ut_utils is begin while l_offset <= l_length loop l_amount := a_max_amount - coalesce( length(l_last_line), 0 ); - dbms_lob.read(a_clob, l_amount, l_offset, l_buffer); +-- dbms_lob.read(a_clob, l_amount, l_offset, l_buffer); + l_buffer := substr(a_clob, l_offset, l_amount); + l_amount := length(l_buffer); l_offset := l_offset + l_amount; l_string_results := string_to_table( l_last_line || l_buffer, a_delimiter, l_skip_leading_delimiter ); @@ -278,6 +287,20 @@ create or replace package body ut_utils is return l_result; end; + function table_to_clob(a_text_table ut_varchar2_rows, a_delimiter varchar2:= chr(10)) return clob is + l_result clob; + l_table_rows integer := coalesce(cardinality(a_text_table),0); + begin + for i in 1 .. l_table_rows loop + if i < l_table_rows then + append_to_clob(l_result, a_text_table(i)||a_delimiter); + else + append_to_clob(l_result, a_text_table(i)); + end if; + end loop; + return l_result; + end; + function table_to_clob(a_integer_table ut_integer_list, a_delimiter varchar2:= chr(10)) return clob is l_result clob; l_table_rows integer := coalesce(cardinality(a_integer_table),0); @@ -469,6 +492,7 @@ create or replace package body ut_utils is begin execute immediate 'delete from ut_compound_data_tmp'; execute immediate 'delete from ut_compound_data_diff_tmp'; + execute immediate 'delete from ut_json_data_diff_tmp'; end; function to_version(a_version_no varchar2) return t_version is @@ -545,7 +569,7 @@ create or replace package body ut_utils is function scale_cardinality(a_cardinality natural) return natural is begin - return nvl(trunc(power(10,(floor(log(10,a_cardinality))+1))/3),0); + return case when a_cardinality > 0 then trunc(power(10,(floor(log(10,a_cardinality))+1))/3) else 1 end; end; function build_depreciation_warning(a_old_syntax varchar2, a_new_syntax varchar2) return varchar2 is @@ -596,7 +620,6 @@ create or replace package body ut_utils is if a_list is not null then l_filtered_list := ut_varchar2_list(); l_index := a_list.first; - while (l_index is not null) loop if regexp_like(a_list(l_index), a_regexp_filter) then l_filtered_list.extend; @@ -737,5 +760,110 @@ 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.3085 + */ + 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; + + function to_cdata(a_lines ut_varchar2_rows) return ut_varchar2_rows is + l_results ut_varchar2_rows; + begin + if a_lines is not empty then + ut_utils.append_to_list( l_results, gc_cdata_start_tag); + for i in 1 .. a_lines.count loop + ut_utils.append_to_list( l_results, replace( a_lines(i), gc_cdata_end_tag, gc_cdata_end_tag_wrap ) ); + end loop; + ut_utils.append_to_list( l_results, gc_cdata_end_tag); + else + l_results := a_lines; + end if; + return l_results; + end; + + function to_cdata(a_clob clob) return clob is + l_result clob; + begin + if a_clob is not null and a_clob != empty_clob() then + l_result := replace( a_clob, gc_cdata_end_tag, gc_cdata_end_tag_wrap ); + else + l_result := a_clob; + end if; + return l_result; + end; + + function add_prefix(a_list ut_varchar2_list, a_prefix varchar2, a_connector varchar2 := '/') return ut_varchar2_list is + l_result ut_varchar2_list := ut_varchar2_list(); + l_idx binary_integer; + begin + if a_prefix is not null then + l_idx := a_list.first; + while l_idx is not null loop + l_result.extend; + l_result(l_idx) := add_prefix(a_list(l_idx), a_prefix, a_connector); + l_idx := a_list.next(l_idx); + end loop; + end if; + return l_result; + end; + + function add_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2 is + begin + return a_prefix||a_connector||trim(leading a_connector from a_item); + end; + + function strip_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2 is + begin + return regexp_replace(a_item,a_prefix||a_connector); + end; + end ut_utils; / diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index a9ecf9ac6..43dfdb1bb 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -1,7 +1,7 @@ create or replace package ut_utils authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.1.6.2729'; - + gc_version constant varchar2(50) := 'v3.1.7.3085'; + subtype t_executable_type is varchar2(30); gc_before_all constant t_executable_type := 'beforeall'; gc_before_each constant t_executable_type := 'beforeeach'; @@ -44,6 +44,11 @@ create or replace package ut_utils authid definer is gc_failure_char constant varchar2(7) := 'Failure'; -- one or more expectations failed gc_error_char constant varchar2(5) := 'Error'; -- exception was raised + gc_cdata_start_tag constant varchar2(10) := ''; + gc_cdata_end_tag_wrap constant varchar2(30) := ']]'||gc_cdata_end_tag||gc_cdata_start_tag||'>'; + + /* Constants: Rollback type for ut_test_object */ @@ -109,6 +114,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) := '[...]'; @@ -123,6 +136,11 @@ create or replace package ut_utils authid definer is gc_bc_fetch_limit constant integer := 1000; gc_diff_max_rows constant integer := 20; + /** + * Regexp to validate tag + */ + gc_word_no_space constant varchar2(50) := '^(\w|\S)+$'; + type t_version is record( major natural, minor natural, @@ -226,7 +244,9 @@ create or replace package ut_utils authid definer is function clob_to_table(a_clob clob, a_max_amount integer := 8191, a_delimiter varchar2:= chr(10)) return ut_varchar2_list; function table_to_clob(a_text_table ut_varchar2_list, a_delimiter varchar2:= chr(10)) return clob; - + + function table_to_clob(a_text_table ut_varchar2_rows, a_delimiter varchar2:= chr(10)) return clob; + function table_to_clob(a_integer_table ut_integer_list, a_delimiter varchar2:= chr(10)) return clob; /** @@ -368,6 +388,37 @@ 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; + + /** + * Converts input list into a list surrounded by CDATA tags + * All CDATA end tags get escaped using recommended method from https://en.wikipedia.org/wiki/CDATA#Nesting + */ + function to_cdata(a_lines ut_varchar2_rows) return ut_varchar2_rows; + + /** + * Converts input CLOB into a CLOB surrounded by CDATA tags + * All CDATA end tags get escaped using recommended method from https://en.wikipedia.org/wiki/CDATA#Nesting + */ + function to_cdata(a_clob clob) return clob; + + /** + * Add prefix word to elements of list + */ + function add_prefix(a_list ut_varchar2_list, a_prefix varchar2, a_connector varchar2 := '/') return ut_varchar2_list; + + function add_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2; + + function strip_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2; -end ut_utils; + end ut_utils; / diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index dcc940737..30b79cffb 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ alter session set current_schema = &&ut3_owner; grant execute on &&ut3_owner..ut_expectation to public; grant execute on &&ut3_owner..ut_expectation_compound to public; +grant execute on &&ut3_owner..ut_expectation_json to public; grant execute on &&ut3_owner..ut_be_between to public; grant execute on &&ut3_owner..ut_be_empty to public; grant execute on &&ut3_owner..ut_be_false to public; @@ -74,6 +75,7 @@ grant execute on &&ut3_owner..ut_coverage_options to public; grant execute on &&ut3_owner..ut_coverage_helper to public; grant execute on &&ut3_owner..ut_output_buffer_base to public; grant execute on &&ut3_owner..ut_output_table_buffer to public; +grant execute on &&ut3_owner..ut_output_clob_table_buffer to public; grant execute on &&ut3_owner..ut_file_mappings to public; grant execute on &&ut3_owner..ut_file_mapping to public; grant execute on &&ut3_owner..ut_file_mapper to public; @@ -112,6 +114,7 @@ prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC create public synonym ut_expectation for &&ut3_owner..ut_expectation; create public synonym ut_expectation_compound for &&ut3_owner..ut_expectation_compound; +create public synonym ut_expectation_json for &&ut3_owner..ut_expectation_json; create public synonym be_between for &&ut3_owner..be_between; create public synonym be_empty for &&ut3_owner..be_empty; @@ -154,6 +157,7 @@ create public synonym ut_coverage_options for &&ut3_owner..ut_coverage_options; create public synonym ut_coverage_helper for &&ut3_owner..ut_coverage_helper; create public synonym ut_output_buffer_base for &&ut3_owner..ut_output_buffer_base; create public synonym ut_output_table_buffer for &&ut3_owner..ut_output_table_buffer; +create public synonym ut_output_clob_table_buffer for &&ut3_owner..ut_output_clob_table_buffer; create public synonym ut_file_mappings for &&ut3_owner..ut_file_mappings; create public synonym ut_file_mapping for &&ut3_owner..ut_file_mapping; create public synonym ut_file_mapper for &&ut3_owner..ut_file_mapper; diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql index feab90933..911c1074f 100644 --- a/source/create_user_grants.sql +++ b/source/create_user_grants.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ alter session set current_schema = &&ut3_owner; grant execute on &&ut3_owner..ut_expectation to &ut3_user; grant execute on &&ut3_owner..ut_expectation_compound to &ut3_user; +grant execute on &&ut3_owner..ut_expectation_json to &ut3_user; grant execute on &&ut3_owner..ut_be_between to &ut3_user; grant execute on &&ut3_owner..ut_be_empty to &ut3_user; @@ -95,6 +96,7 @@ grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user; grant execute on &&ut3_owner..ut_output_data_row to &ut3_user; grant execute on &&ut3_owner..ut_output_data_rows to &ut3_user; grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user; +grant execute on &&ut3_owner..ut_output_clob_table_buffer to &ut3_user; grant execute on &&ut3_owner..ut_file_mappings to &ut3_user; grant execute on &&ut3_owner..ut_file_mapping to &ut3_user; grant execute on &&ut3_owner..ut_file_mapper to &ut3_user; diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql index b08cb7b0e..b564dc6c4 100644 --- a/source/create_user_synonyms.sql +++ b/source/create_user_synonyms.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3 create or replace synonym &ut3_user..ut_expectation for &&ut3_owner..ut_expectation; create or replace synonym &ut3_user..ut_expectation_compound for &&ut3_owner..ut_expectation_compound; +create or replace synonym &ut3_user..ut_expectation_json for &&ut3_owner..ut_expectation_json; create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between; create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty; @@ -97,6 +98,7 @@ create or replace synonym &ut3_user..ut_coverage_options for &&ut3_owner..ut_cov create or replace synonym &ut3_user..ut_coverage_helper for &&ut3_owner..ut_coverage_helper; create or replace synonym &ut3_user..ut_output_buffer_base for &&ut3_owner..ut_output_buffer_base; create or replace synonym &ut3_user..ut_output_table_buffer for &&ut3_owner..ut_output_table_buffer; +create or replace synonym &ut3_user..ut_output_clob_table_buffer for &&ut3_owner..ut_output_clob_table_buffer; create or replace synonym &ut3_user..ut_file_mappings for &&ut3_owner..ut_file_mappings; create or replace synonym &ut3_user..ut_file_mapping for &&ut3_owner..ut_file_mapping; create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_mapper; diff --git a/source/create_utplsql_owner.sql b/source/create_utplsql_owner.sql index a74ee6c44..9d163d802 100644 --- a/source/create_utplsql_owner.sql +++ b/source/create_utplsql_owner.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ prompt Creating utPLSQL user &&ut3_user create user &ut3_user identified by "&ut3_password" default tablespace &ut3_tablespace quota unlimited on &ut3_tablespace; -grant create session, create sequence, create procedure, create type, create table, create view, create synonym to &ut3_user; +grant create session, create sequence, create procedure, create type, create table, create view, create synonym, administer database trigger to &ut3_user; begin $if dbms_db_version.version < 18 $then diff --git a/source/define_ut3_owner_param.sql b/source/define_ut3_owner_param.sql index a889ead05..1b183b581 100644 --- a/source/define_ut3_owner_param.sql +++ b/source/define_ut3_owner_param.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 242d6c2fc..19f2a6bb2 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -1,7 +1,7 @@ create global temporary table ut_compound_data_diff_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index abb07ee80..755c5154d 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -1,7 +1,7 @@ create or replace package body ut_compound_data_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -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 @@ -174,7 +176,7 @@ create or replace package body ut_compound_data_helper is function generate_equal_sql(a_col_name in varchar2) return varchar2 is begin - return ' a.'||a_col_name||q'[ = ]'||' e.'||a_col_name; + return ' decode(a.'||a_col_name||','||' e.'||a_col_name||',1,0) = 1 '; end; function generate_partition_stmt( @@ -231,7 +233,13 @@ 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)||')'; + elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('NUMBER') then + --We cannot use a precision and scale as dbms_sql.describe_columns3 return precision 0 for dual table + -- there is also no need for that as we not process data but only read and compare as they are stored l_col_type := a_data_info.column_type; else l_col_type := a_data_info.column_type @@ -327,6 +335,7 @@ create or replace package body ut_compound_data_helper is l_not_equal_stmt clob; l_where_stmt clob; l_ut_owner varchar2(250) := ut_utils.ut_owner; + l_join_by_list ut_varchar2_list; function get_join_type(a_inclusion_compare in boolean,a_negated in boolean) return varchar2 is begin @@ -348,12 +357,22 @@ create or replace package body ut_compound_data_helper is end; begin + /** + * We already estabilished cursor equality so now we add anydata root if we compare anydata + * to join by. + */ + l_join_by_list := + case + when a_other is of (ut_data_value_anydata) then ut_utils.add_prefix(a_join_by_list, a_other.cursor_details.get_root) + else a_join_by_list + end; + dbms_lob.createtemporary(l_compare_sql, true); --Initiate a SQL template with placeholders ut_utils.append_to_clob(l_compare_sql, g_compare_sql_template); --Generate a pieceso of dynamic SQL that will substitute placeholders gen_sql_pieces_out_of_cursor( - a_other.cursor_details.cursor_columns_info, a_join_by_list, a_unordered, + a_other.cursor_details.cursor_columns_info, l_join_by_list, a_unordered, l_xmltable_stmt, l_select_stmt, l_partition_stmt, l_join_on_stmt, l_not_equal_stmt ); @@ -366,7 +385,7 @@ create or replace package body ut_compound_data_helper is l_compare_sql := replace(l_compare_sql,'{:join_type:}',get_join_type(a_inclusion_type,a_is_negated)); l_compare_sql := replace(l_compare_sql,'{:join_condition:}',l_join_on_stmt); - if l_not_equal_stmt is not null and ((a_join_by_list.count > 0 and not a_is_negated) or (not a_unordered)) then + if l_not_equal_stmt is not null and ((l_join_by_list.count > 0 and not a_is_negated) or (not a_unordered)) then ut_utils.append_to_clob(l_where_stmt,' ( '||l_not_equal_stmt||' ) or '); end if; --If its inclusion we expect a actual set to fully match and have no extra elements over expected @@ -569,6 +588,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 @@ -595,6 +616,137 @@ 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; + + function compare_json_data(a_act_json_data ut_json_leaf_tab,a_exp_json_data ut_json_leaf_tab) return tt_json_diff_tab is + l_result_diff tt_json_diff_tab := tt_json_diff_tab(); + begin + + with + differences as ( + select case + when (a.element_name is null or e.element_name is null) then gc_json_missing + when a.json_type != e.json_type then gc_json_type + when (decode(a.element_value,e.element_value,1,0) = 0) then gc_json_notequal + else gc_json_unknown + end as difference_type, + case + when (a.element_name is null or e.element_name is null) then 1 + when a.json_type != e.json_type then 2 + when (decode(a.element_value,e.element_value,1,0) = 0) then 3 + else 4 + end as order_by_type, + a.element_name as act_element_name, + a.element_value as act_element_value, + a.hierarchy_level as act_hierarchy_level, + a.index_position as act_index_position, + a.json_type as act_json_type, + a.access_path as act_access_path, + a.parent_name as act_par_name, + a.parent_path as act_parent_path, + e.element_name as exp_element_name, + e.element_value as exp_element_value, + e.hierarchy_level as exp_hierarchy_level, + e.index_position as exp_index_position, + e.json_type as exp_json_type, + e.access_path as exp_access_path, + e.parent_name as exp_par_name, + e.parent_path as exp_parent_path + from table(a_act_json_data) a + full outer join table(a_exp_json_data) e + on decode(a.parent_name,e.parent_name,1,0)= 1 + and decode(a.parent_path,e.parent_path,1,0)= 1 + and ( + case when a.parent_type = 'object' or e.parent_type = 'object' then + decode(a.element_name,e.element_name,1,0) + else 1 end = 1 + ) + and ( + case when a.parent_type = 'array' or e.parent_type = 'array' then + decode(a.index_position,e.index_position,1,0) + else 1 end = 1 + ) + and a.hierarchy_level = e.hierarchy_level + where (a.element_name is null or e.element_name is null) + or (a.json_type != e.json_type) + or (decode(a.element_value,e.element_value,1,0) = 0) + ) + select difference_type, + act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path, + exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path + bulk collect into l_result_diff + from differences a + where not exists ( + select 1 from differences b + where (a.act_par_name = b.act_element_name and a.act_hierarchy_level - 1 = b.act_hierarchy_level) + or (a.exp_par_name = b.exp_element_name and a.exp_hierarchy_level - 1 = b.exp_hierarchy_level) + and a.difference_type = gc_json_missing and b.difference_type = gc_json_missing + ) + order by order_by_type, + nvl(act_hierarchy_level,exp_hierarchy_level), + nvl(act_index_position,exp_index_position) nulls first, + nvl(act_element_name,exp_element_name) ; + return l_result_diff; + end; + + function insert_json_diffs(a_diff_id raw, a_act_json_data ut_json_leaf_tab, a_exp_json_data ut_json_leaf_tab) return integer is + l_diffs tt_json_diff_tab := compare_json_data(a_act_json_data,a_exp_json_data); + begin + forall i in 1..l_diffs.count + insert into ut_json_data_diff_tmp ( + diff_id, difference_type, + act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path, + exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path + ) + values ( + a_diff_id,l_diffs(i).difference_type, + l_diffs(i).act_element_name,l_diffs(i).act_element_value,l_diffs(i).act_json_type, l_diffs(i).act_access_path, l_diffs(i).act_parent_path, + l_diffs(i).exp_element_name,l_diffs(i).exp_element_value,l_diffs(i).exp_json_type,l_diffs(i).exp_access_path, l_diffs(i).exp_parent_path + ); + + return l_diffs.count; + end; + + function get_json_diffs_type(a_diffs_all tt_json_diff_tab) return tt_json_diff_type_tab is + l_diffs_summary tt_json_diff_type_tab := tt_json_diff_type_tab(); + begin + select d.difference_type,count(1) + bulk collect into l_diffs_summary + from table(a_diffs_all) d + group by d.difference_type; + + return l_diffs_summary; + end; + + function get_json_diffs_tmp(a_diff_id raw) return tt_json_diff_tab is + l_diffs tt_json_diff_tab; + begin + select difference_type, + act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path, + exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path + bulk collect into l_diffs + from ut_json_data_diff_tmp + where diff_id = a_diff_id; + + return l_diffs; + end; begin g_anytype_name_map(dbms_types.typecode_date) := 'DATE'; @@ -641,6 +793,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..56745be76 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -1,7 +1,7 @@ create or replace package ut_compound_data_helper authid definer is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -19,6 +19,11 @@ create or replace package ut_compound_data_helper authid definer is gc_compare_unordered constant varchar2(10):='unordered'; gc_compare_normal constant varchar2(10):='normal'; + gc_json_missing constant varchar2(30) := 'missing properties'; + gc_json_type constant varchar2(30) := 'incorrect types'; + gc_json_notequal constant varchar2(30) := 'unequal values'; + gc_json_unknown constant varchar2(30) := 'unknown'; + type t_column_diffs is record( diff_type varchar2(1), expected_name varchar2(250), @@ -50,7 +55,30 @@ create or replace package ut_compound_data_helper authid definer is ); type t_diff_tab is table of t_diff_rec; - + + type t_json_diff_rec is record ( + difference_type varchar2(50), + act_element_name varchar2(4000), + act_element_value varchar2(4000), + act_json_type varchar2(4000), + act_access_path varchar2(4000), + act_parent_path varchar2(4000), + exp_element_name varchar2(4000), + exp_element_value varchar2(4000), + exp_json_type varchar2(4000), + exp_access_path varchar2(4000), + exp_parent_path varchar2(4000) + ); + + type tt_json_diff_tab is table of t_json_diff_rec; + + type t_json_diff_type_rec is record ( + difference_type varchar2(50), + no_of_occurence integer + ); + + type tt_json_diff_type_tab is table of t_json_diff_type_rec; + function get_columns_diff( a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab,a_order_enforced boolean := false ) return tt_column_diffs; @@ -92,5 +120,21 @@ 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; + + function compare_json_data(a_act_json_data ut_json_leaf_tab,a_exp_json_data ut_json_leaf_tab) return tt_json_diff_tab; + + function insert_json_diffs(a_diff_id raw, a_act_json_data ut_json_leaf_tab,a_exp_json_data ut_json_leaf_tab) return integer; + + function get_json_diffs_tmp(a_diff_id raw) return tt_json_diff_tab; + + + function get_json_diffs_type(a_diffs_all tt_json_diff_tab) return tt_json_diff_type_tab; + end; / diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index 0fb5f9544..10a88269e 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -1,7 +1,7 @@ create global temporary table ut_compound_data_tmp( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 4aecdb81f..3dbf9431a 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -1,7 +1,7 @@ create or replace type body ut_compound_data_value as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps index 8e42765f5..a9b78f944 100644 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ b/source/expectations/data_values/ut_compound_data_value.tps @@ -1,7 +1,7 @@ create or replace type ut_compound_data_value force under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_cursor_column.tpb b/source/expectations/data_values/ut_cursor_column.tpb index 5f6f18c56..13b1b3158 100644 --- a/source/expectations/data_values/ut_cursor_column.tpb +++ b/source/expectations/data_values/ut_cursor_column.tpb @@ -4,26 +4,37 @@ create or replace type body ut_cursor_column as self in out nocopy ut_cursor_column, a_col_name varchar2, a_col_schema_name varchar2, a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1, - a_col_position integer, a_col_type varchar2, a_collection integer,a_access_path in varchar2 + a_col_position integer, a_col_type varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer, + a_col_scale integer ) is begin self.parent_name := a_parent_name; --Name of the parent if its nested self.hierarchy_level := a_hierarchy_level; --Hierarchy level self.column_position := a_col_position; --Position of the column in cursor/ type self.column_len := a_col_max_len; --length of column + self.column_precision := a_col_precision; + self.column_scale := a_col_scale; 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 XMLTABLE query + self.filter_path := '/'||self.access_path; --Filter path will differ from access path in anydata type + 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 @@ -42,10 +53,12 @@ create or replace type body ut_cursor_column as constructor function ut_cursor_column( self in out nocopy ut_cursor_column, a_col_name varchar2, a_col_schema_name varchar2, a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1, - a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2 + a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer, + a_col_scale integer ) return self as result is begin - init(a_col_name, a_col_schema_name, a_col_type_name, a_col_max_len, a_parent_name,a_hierarchy_level, a_col_position, a_col_type, a_collection,a_access_path); + init(a_col_name, a_col_schema_name, a_col_type_name, a_col_max_len, a_parent_name,a_hierarchy_level, a_col_position, + a_col_type, a_collection,a_access_path,a_col_precision,a_col_scale); return; end; diff --git a/source/expectations/data_values/ut_cursor_column.tps b/source/expectations/data_values/ut_cursor_column.tps index 4b436051a..c865ea64b 100644 --- a/source/expectations/data_values/ut_cursor_column.tps +++ b/source/expectations/data_values/ut_cursor_column.tps @@ -1,7 +1,7 @@ -create or replace type ut_cursor_column force authid current_user as object ( +create or replace type ut_cursor_column authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -17,28 +17,34 @@ create or replace type ut_cursor_column force authid current_user as object ( */ parent_name varchar2(4000), access_path varchar2(4000), + filter_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), column_len integer, + column_precision integer, + column_scale integer, is_sql_diffable number(1, 0), is_collection number(1, 0), member procedure init(self in out nocopy ut_cursor_column, a_col_name varchar2, a_col_schema_name varchar2, a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1, - a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2), + a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer, + a_col_scale integer), constructor function ut_cursor_column( self in out nocopy ut_cursor_column, a_col_name varchar2, a_col_schema_name varchar2, a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1, - a_col_position integer, a_col_type in varchar2, a_collection integer, a_access_path in varchar2) + a_col_position integer, a_col_type in varchar2, a_collection integer, a_access_path in varchar2, a_col_precision in integer, + a_col_scale integer) return self as result, constructor function ut_cursor_column( self in out nocopy ut_cursor_column) return self as result diff --git a/source/expectations/data_values/ut_cursor_column_tab.tps b/source/expectations/data_values/ut_cursor_column_tab.tps index 1b7a1698f..b1b33f7fe 100644 --- a/source/expectations/data_values/ut_cursor_column_tab.tps +++ b/source/expectations/data_values/ut_cursor_column_tab.tps @@ -1,7 +1,7 @@ create or replace type ut_cursor_column_tab as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_cursor_details.tpb b/source/expectations/data_values/ut_cursor_details.tpb index c1d229e6a..20313ed96 100644 --- a/source/expectations/data_values/ut_cursor_details.tpb +++ b/source/expectations/data_values/ut_cursor_details.tpb @@ -39,7 +39,9 @@ create or replace type body ut_cursor_details as l_idx, ut_compound_data_helper.get_column_type_desc(l_elements_info.type_code,false), ut_utils.boolean_to_int(l_is_collection), - a_access_path + a_access_path, + l_elements_info.precision, + l_elements_info.scale ); if l_element_info.attr_elt_type is not null then desc_compound_data( @@ -63,7 +65,9 @@ create or replace type body ut_cursor_details as l_idx, ut_compound_data_helper.get_column_type_desc(l_element_info.type_code,false), ut_utils.boolean_to_int(l_is_collection), - a_access_path + a_access_path, + l_elements_info.precision, + l_elements_info.scale ); if l_element_info.attr_elt_type is not null then desc_compound_data( @@ -92,6 +96,7 @@ create or replace type body ut_cursor_details as l_hierarchy_level integer := 1; begin self.cursor_columns_info := ut_cursor_column_tab(); + self.is_anydata := 0; dbms_sql.describe_columns3(a_cursor_number, l_columns_count, l_columns_desc); /** @@ -114,7 +119,9 @@ create or replace type body ut_cursor_details as pos, ut_compound_data_helper.get_column_type_desc(l_columns_desc(pos).col_type,true), ut_utils.boolean_to_int(l_is_collection), - null + null, + l_columns_desc(pos).col_precision, + l_columns_desc(pos).col_scale ); if l_columns_desc(pos).col_type = dbms_sql.user_defined_type or l_is_collection then @@ -141,12 +148,13 @@ create or replace type body ut_cursor_details as member function get_missing_join_by_columns( a_expected_columns ut_varchar2_list ) return ut_varchar2_list is l_result ut_varchar2_list; begin + --regexp_replace(c.access_path,'^\/?([^\/]+\/){1}') select fl.column_value bulk collect into l_result from table(a_expected_columns) fl where not exists ( select 1 from table(self.cursor_columns_info) c - where regexp_like(c.access_path, '^'||fl.column_value||'($|/.*)') + where regexp_like(c.filter_path,'^/?'||fl.column_value||'($|/.*)' ) ) order by fl.column_value; return l_result; @@ -154,6 +162,8 @@ create or replace type body ut_cursor_details as member procedure filter_columns(self in out nocopy ut_cursor_details, a_match_options ut_matcher_options) is l_result ut_cursor_details := self; + l_column_tab ut_cursor_column_tab := ut_cursor_column_tab(); + l_column ut_cursor_column; c_xpath_extract_reg constant varchar2(50) := '^((/ROW/)|^(//)|^(/\*/))?(.*)'; begin if l_result.cursor_columns_info is not null then @@ -173,8 +183,9 @@ create or replace type body ut_cursor_details as bulk collect into l_result.cursor_columns_info from table(self.cursor_columns_info) x where exists( - select 1 from included_columns f where regexp_like( x.access_path, '^/?'||f.col_names||'($|/.*)' ) - ); + select 1 from included_columns f where regexp_like(x.filter_path,'^/?'||f.col_names||'($|/.*)' ) + ) + or x.hierarchy_level = case when self.is_anydata = 1 then 1 else 0 end ; end if; elsif a_match_options.exclude.items.count > 0 then with excluded_columns as ( @@ -185,9 +196,27 @@ create or replace type body ut_cursor_details as bulk collect into l_result.cursor_columns_info from table(self.cursor_columns_info) x where not exists( - select 1 from excluded_columns f where regexp_like( '/'||x.access_path, '^/?'||f.col_names||'($|/.*)' ) + select 1 from excluded_columns f where regexp_like(x.filter_path,'^/?'||f.col_names||'($|/.*)' ) ); end if; + + --Rewrite column order after columns been excluded + for i in ( + select parent_name, access_path, display_path, has_nested_col, + transformed_name, hierarchy_level, + rownum as new_position, xml_valid_name, + column_name, column_type, column_type_name, column_schema, + column_len, column_precision ,column_scale ,is_sql_diffable, is_collection,value(x) col_info + from table(l_result.cursor_columns_info) x + order by x.column_position asc + ) loop + l_column := i.col_info; + l_column.column_position := i.new_position; + l_column_tab.extend; + l_column_tab(l_column_tab.last) := l_column; + end loop; + + l_result.cursor_columns_info := l_column_tab; self := l_result; end if; end; @@ -200,8 +229,28 @@ create or replace type body ut_cursor_details as from table(self.cursor_columns_info) t where (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null) having count(*) > 0; - return l_result; end; + + member function get_root return varchar2 is + l_root varchar2(250); + begin + if self.cursor_columns_info.count > 0 then + select x.access_path into l_root from table(self.cursor_columns_info) x + where x.hierarchy_level = 1; + else + l_root := null; + end if; + return l_root; + end; + + member procedure strip_root_from_anydata(self in out nocopy ut_cursor_details) is + l_root varchar2(250) := get_root(); + begin + self.is_anydata := 1; + for i in 1..cursor_columns_info.count loop + self.cursor_columns_info(i).filter_path := '/'||ut_utils.strip_prefix(self.cursor_columns_info(i).access_path,l_root); + end loop; + end; end; / diff --git a/source/expectations/data_values/ut_cursor_details.tps b/source/expectations/data_values/ut_cursor_details.tps index c2aa98066..7092e834f 100644 --- a/source/expectations/data_values/ut_cursor_details.tps +++ b/source/expectations/data_values/ut_cursor_details.tps @@ -1,7 +1,7 @@ -create or replace type ut_cursor_details force authid current_user as object ( +create or replace type ut_cursor_details authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ create or replace type ut_cursor_details force authid current_user as object ( */ cursor_columns_info ut_cursor_column_tab, + /*if type is anydata we need to skip level 1 on joinby / inlude / exclude as its artificial cursor*/ + is_anydata number(1,0), constructor function ut_cursor_details(self in out nocopy ut_cursor_details) return self as result, constructor function ut_cursor_details( self in out nocopy ut_cursor_details,a_cursor_number in number @@ -29,9 +31,11 @@ create or replace type ut_cursor_details force authid current_user as object ( a_level in integer, a_access_path in varchar2 ), - member function contains_collection return boolean, - member function get_missing_join_by_columns( a_expected_columns ut_varchar2_list ) return ut_varchar2_list, + member function contains_collection return boolean, + member function get_missing_join_by_columns( a_expected_columns ut_varchar2_list ) return ut_varchar2_list, member procedure filter_columns(self in out nocopy ut_cursor_details, a_match_options ut_matcher_options), - member function get_xml_children(a_parent_name varchar2 := null) return xmltype + member function get_xml_children(a_parent_name varchar2 := null) return xmltype, + member function get_root return varchar2, + member procedure strip_root_from_anydata(self in out nocopy ut_cursor_details) ) / diff --git a/source/expectations/data_values/ut_data_value.tpb b/source/expectations/data_values/ut_data_value.tpb index 8c8e677fb..d8feb1a62 100644 --- a/source/expectations/data_values/ut_data_value.tpb +++ b/source/expectations/data_values/ut_data_value.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps index 425fbeb54..ca7e18308 100644 --- a/source/expectations/data_values/ut_data_value.tps +++ b/source/expectations/data_values/ut_data_value.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value force authid current_user as object ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_anydata.tpb b/source/expectations/data_values/ut_data_value_anydata.tpb index 19917633a..0b5447758 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tpb +++ b/source/expectations/data_values/ut_data_value_anydata.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_anydata as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -61,8 +61,6 @@ create or replace type body ut_data_value_anydata as member procedure init(self in out nocopy ut_data_value_anydata, a_value anydata) is l_refcursor sys_refcursor; - l_ctx number; - l_ut_owner varchar2(250) := ut_utils.ut_owner; cursor_not_open exception; l_cursor_number number; l_anydata_sql varchar2(32767); @@ -84,6 +82,7 @@ create or replace type body ut_data_value_anydata as self.extract_cursor(l_refcursor); l_cursor_number := dbms_sql.to_cursor_number(l_refcursor); self.cursor_details := ut_cursor_details(l_cursor_number); + self.cursor_details.strip_root_from_anydata; dbms_sql.close_cursor(l_cursor_number); elsif not l_refcursor%isopen then raise cursor_not_open; diff --git a/source/expectations/data_values/ut_data_value_anydata.tps b/source/expectations/data_values/ut_data_value_anydata.tps index c0ee6137b..5ed0406ca 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tps +++ b/source/expectations/data_values/ut_data_value_anydata.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_anydata under ut_data_value_refcursor( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_blob.tpb b/source/expectations/data_values/ut_data_value_blob.tpb index c597af023..11af6d2f7 100644 --- a/source/expectations/data_values/ut_data_value_blob.tpb +++ b/source/expectations/data_values/ut_data_value_blob.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_blob as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_blob.tps b/source/expectations/data_values/ut_data_value_blob.tps index ed6aa2afe..f557ffbce 100644 --- a/source/expectations/data_values/ut_data_value_blob.tps +++ b/source/expectations/data_values/ut_data_value_blob.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_blob under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_boolean.tpb b/source/expectations/data_values/ut_data_value_boolean.tpb index bc8c1e2f9..0645d3269 100644 --- a/source/expectations/data_values/ut_data_value_boolean.tpb +++ b/source/expectations/data_values/ut_data_value_boolean.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_boolean as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_boolean.tps b/source/expectations/data_values/ut_data_value_boolean.tps index 62b413e10..a254e05c0 100644 --- a/source/expectations/data_values/ut_data_value_boolean.tps +++ b/source/expectations/data_values/ut_data_value_boolean.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_boolean under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_clob.tpb b/source/expectations/data_values/ut_data_value_clob.tpb index 7b7c7ffd8..dacb390b6 100644 --- a/source/expectations/data_values/ut_data_value_clob.tpb +++ b/source/expectations/data_values/ut_data_value_clob.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_clob as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_clob.tps b/source/expectations/data_values/ut_data_value_clob.tps index 4212efb3c..1ff5d5623 100644 --- a/source/expectations/data_values/ut_data_value_clob.tps +++ b/source/expectations/data_values/ut_data_value_clob.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_clob under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_date.tpb b/source/expectations/data_values/ut_data_value_date.tpb index 727f624d4..dd87156bc 100644 --- a/source/expectations/data_values/ut_data_value_date.tpb +++ b/source/expectations/data_values/ut_data_value_date.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_date as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_date.tps b/source/expectations/data_values/ut_data_value_date.tps index e1c358789..4435a3512 100644 --- a/source/expectations/data_values/ut_data_value_date.tps +++ b/source/expectations/data_values/ut_data_value_date.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_date under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tpb b/source/expectations/data_values/ut_data_value_dsinterval.tpb index 6b49a5d1c..ff9d5fe1e 100644 --- a/source/expectations/data_values/ut_data_value_dsinterval.tpb +++ b/source/expectations/data_values/ut_data_value_dsinterval.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_dsinterval as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tps b/source/expectations/data_values/ut_data_value_dsinterval.tps index 2d3ad48f0..114619bf2 100644 --- a/source/expectations/data_values/ut_data_value_dsinterval.tps +++ b/source/expectations/data_values/ut_data_value_dsinterval.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_dsinterval under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_json.tpb b/source/expectations/data_values/ut_data_value_json.tpb new file mode 100644 index 000000000..e4b556ef9 --- /dev/null +++ b/source/expectations/data_values/ut_data_value_json.tpb @@ -0,0 +1,166 @@ +create or replace type body ut_data_value_json as + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + member procedure init (self in out nocopy ut_data_value_json, a_value json_element_t) is + begin + self.is_data_null := case when a_value is null then 1 else 0 end; + self.data_value := case when a_value is null then null else a_value.to_clob end; + self.self_type := $$plsql_unit; + self.data_type := 'json'; + self.json_tree := ut_json_tree_details(a_value); + self.data_id := sys_guid(); + end; + + constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json_element_t) return self as result is + begin + init(a_value); + return; + end; + + overriding member function is_null return boolean is + begin + return (ut_utils.int_to_boolean(self.is_data_null)); + end; + + overriding member function is_empty return boolean is + begin + return self.data_value = '{}'; + end; + + overriding member function to_string return varchar2 is + begin + return ut_utils.to_string(self.data_value); + end; + + overriding member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2 is + l_result clob; + l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab(); + l_result_string varchar2(32767); + l_other ut_data_value_json; + l_self ut_data_value_json := self; + l_diff_id ut_compound_data_helper.t_hash; + c_max_rows integer := ut_utils.gc_diff_max_rows; + l_diffs ut_compound_data_helper.tt_json_diff_tab; + l_message varchar2(32767); + + function get_diff_by_type(a_diff ut_compound_data_helper.tt_json_diff_tab) return clob is + l_diff_summary ut_compound_data_helper.tt_json_diff_type_tab := ut_compound_data_helper.get_json_diffs_type(a_diff); + l_message_list ut_varchar2_list := ut_varchar2_list(); + begin + for i in 1..l_diff_summary.count loop + l_message_list.extend; + l_message_list(l_message_list.last) := l_diff_summary(i).no_of_occurence||' '||l_diff_summary(i).difference_type; + end loop; + return ut_utils.table_to_clob(l_message_list,', '); + end; + + function get_json_diff_text (a_json_diff ut_compound_data_helper.t_json_diff_rec) return clob is + begin + return + case + when a_json_diff.difference_type = ut_compound_data_helper.gc_json_missing + then + case + when a_json_diff.act_element_name is not null then q'[ Missing property: ]'||a_json_diff.act_element_name + when a_json_diff.exp_element_name is not null then q'[ Extra property: ]'||a_json_diff.exp_element_name + end || ' on path: '||nvl(a_json_diff.act_parent_path,a_json_diff.exp_parent_path) + else + case + when a_json_diff.difference_type = ut_compound_data_helper.gc_json_type + then q'[ Actual type: ']'||a_json_diff.act_json_type||q'[' was expected to be: ']'||a_json_diff.exp_json_type||q'[']' + when a_json_diff.difference_type = ut_compound_data_helper.gc_json_notequal + then q'[ Actual value: ]'||a_json_diff.act_element_value||q'[ was expected to be: ]'||a_json_diff.exp_element_value + end || ' on path: '||nvl(a_json_diff.act_access_path,a_json_diff.exp_access_path) + end; + end; + + begin + if not a_other is of (ut_data_value_json) then + raise value_error; + end if; + dbms_lob.createtemporary(l_result, true); + l_other := treat(a_other as ut_data_value_json); + l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); + + if not l_self.is_null and not l_other.is_null then + l_diffs := ut_compound_data_helper.get_json_diffs_tmp(l_diff_id); + + l_message := ' '||l_diffs.count|| ' differences found' || + case when l_diffs.count > c_max_rows then ', showing first '|| c_max_rows else null end||chr(10); + ut_utils.append_to_clob( l_result, l_message ); + l_message := get_diff_by_type(l_diffs)||chr(10); + ut_utils.append_to_clob( l_result, l_message ); + + for i in 1 .. least( c_max_rows, l_diffs.count ) loop + l_results.extend; + l_results(l_results.last) := get_json_diff_text(l_diffs(i)); + end loop; + ut_utils.append_to_clob(l_result, l_results); + + end if; + + + l_result_string := ut_utils.to_string(l_result,null); + dbms_lob.freetemporary(l_result); + return l_result_string; + end; + + overriding member function compare_implementation(a_other ut_data_value) return integer is + l_self ut_data_value_json := self; + l_other ut_data_value := a_other; + begin + return l_self.compare_implementation( l_other, null ); + end; + + member function compare_implementation(a_other in ut_data_value,a_match_options ut_matcher_options) return + integer is + l_result integer; + l_other ut_data_value_json; + l_diff_id ut_compound_data_helper.t_hash; + begin + if a_other is of (ut_data_value_json) then + l_other := treat(a_other as ut_data_value_json); + l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); + l_result := + case + when ut_compound_data_helper.insert_json_diffs( + l_diff_id, self.json_tree.json_tree_info, l_other.json_tree.json_tree_info + ) > 0 then 1 + else 0 + end; + end if; + return l_result; + end; + + member function get_elements_count return integer is + begin + return json_element_t.parse(self.data_value).get_size; + end; + + member function get_json_count_info return varchar2 is + begin + return self.data_type||' [ count = '||self.get_elements_count||' ]'; + end; + + overriding member function get_object_info return varchar2 is + begin + return self.data_type; + end; + +end; +/ diff --git a/source/expectations/data_values/ut_data_value_json.tps b/source/expectations/data_values/ut_data_value_json.tps new file mode 100644 index 000000000..bfaccb2e2 --- /dev/null +++ b/source/expectations/data_values/ut_data_value_json.tps @@ -0,0 +1,32 @@ +create or replace type ut_data_value_json under ut_compound_data_value( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + data_value clob, + json_tree ut_json_tree_details, + member procedure init (self in out nocopy ut_data_value_json, a_value json_element_t), + constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json_element_t) return self as result, + overriding member function is_null return boolean, + overriding member function is_empty return boolean, + overriding member function to_string return varchar2, + overriding member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2, + overriding member function compare_implementation(a_other ut_data_value) return integer, + member function compare_implementation(a_other ut_data_value,a_match_options ut_matcher_options) return integer, + member function get_elements_count return integer, + member function get_json_count_info return varchar2, + overriding member function get_object_info return varchar2 +) +/ diff --git a/source/expectations/data_values/ut_data_value_number.tpb b/source/expectations/data_values/ut_data_value_number.tpb index cbd524f42..b8a28a124 100644 --- a/source/expectations/data_values/ut_data_value_number.tpb +++ b/source/expectations/data_values/ut_data_value_number.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_number as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_number.tps b/source/expectations/data_values/ut_data_value_number.tps index 674dd89fe..872ab405e 100644 --- a/source/expectations/data_values/ut_data_value_number.tps +++ b/source/expectations/data_values/ut_data_value_number.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_number under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 83bd1502f..eda5b2cd9 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_refcursor as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -49,15 +49,22 @@ create or replace type body ut_data_value_refcursor as dbms_xmlgen.setNullHandling(l_ctx, dbms_xmlgen.empty_tag); dbms_xmlgen.setMaxRows(l_ctx, c_bulk_rows); loop - l_xml := dbms_xmlgen.getxmltype(l_ctx); + l_xml := dbms_xmlgen.getxmltype(l_ctx); exit when dbms_xmlgen.getNumRowsProcessed(l_ctx) = 0; + --Bug in oracle 12.2+ where XML binary storage trimming insignificant whitespaces. + $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then + l_xml := xmltype( replace(l_xml.getClobVal(),' 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); @@ -235,8 +250,14 @@ create or replace type body ut_data_value_refcursor as if l_diff_row_count > 0 then l_row_diffs := ut_compound_data_helper.get_rows_diff_by_sql( l_self_cols, l_other_cols, l_self.data_id, l_other.data_id, - l_diff_id, a_match_options.join_by.items, a_match_options.unordered, - a_match_options.ordered_columns(), self.extract_path + l_diff_id, + case + when + l_self.cursor_details.is_anydata = 1 then ut_utils.add_prefix(a_match_options.join_by.items, l_self.cursor_details.get_root) + else + a_match_options.join_by.items + end, + a_match_options.unordered,a_match_options.ordered_columns(), self.extract_path ); l_message := chr(10) ||'Rows: [ ' || l_diff_row_count ||' differences' @@ -309,8 +330,7 @@ create or replace type body ut_data_value_refcursor as l_cursor := ut_compound_data_helper.get_compare_cursor(a_diff_cursor_text, a_self.data_id, a_other.data_id); --fetch and save rows for display of diff - fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_diff_max_rows; - + fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_diff_max_rows; exception when others then if l_cursor%isopen then close l_cursor; diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps index 7556ec3de..4de253b8f 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ b/source/expectations/data_values/ut_data_value_refcursor.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_timestamp.tpb b/source/expectations/data_values/ut_data_value_timestamp.tpb index 7b9d15e41..adb18e360 100644 --- a/source/expectations/data_values/ut_data_value_timestamp.tpb +++ b/source/expectations/data_values/ut_data_value_timestamp.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_timestamp as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_timestamp.tps b/source/expectations/data_values/ut_data_value_timestamp.tps index e32f855a6..ebd00762c 100644 --- a/source/expectations/data_values/ut_data_value_timestamp.tps +++ b/source/expectations/data_values/ut_data_value_timestamp.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_timestamp under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb b/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb index 8abbfce12..0f41e16b1 100644 --- a/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb +++ b/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_timestamp_ltz as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_timestamp_ltz.tps b/source/expectations/data_values/ut_data_value_timestamp_ltz.tps index 869197c98..3608ebd37 100644 --- a/source/expectations/data_values/ut_data_value_timestamp_ltz.tps +++ b/source/expectations/data_values/ut_data_value_timestamp_ltz.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_timestamp_ltz under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_timestamp_tz.tpb b/source/expectations/data_values/ut_data_value_timestamp_tz.tpb index a61d60e33..710a313a7 100644 --- a/source/expectations/data_values/ut_data_value_timestamp_tz.tpb +++ b/source/expectations/data_values/ut_data_value_timestamp_tz.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_timestamp_tz as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_timestamp_tz.tps b/source/expectations/data_values/ut_data_value_timestamp_tz.tps index 55aa3a803..ca0bfc5cb 100644 --- a/source/expectations/data_values/ut_data_value_timestamp_tz.tps +++ b/source/expectations/data_values/ut_data_value_timestamp_tz.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_timestamp_tz under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_varchar2.tpb b/source/expectations/data_values/ut_data_value_varchar2.tpb index 4f80ee161..da4276d51 100644 --- a/source/expectations/data_values/ut_data_value_varchar2.tpb +++ b/source/expectations/data_values/ut_data_value_varchar2.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_varchar2 as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_varchar2.tps b/source/expectations/data_values/ut_data_value_varchar2.tps index ce5954a09..27bb720ce 100644 --- a/source/expectations/data_values/ut_data_value_varchar2.tps +++ b/source/expectations/data_values/ut_data_value_varchar2.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_varchar2 under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_xmltype.tpb b/source/expectations/data_values/ut_data_value_xmltype.tpb index ecefb664d..3b10aadce 100644 --- a/source/expectations/data_values/ut_data_value_xmltype.tpb +++ b/source/expectations/data_values/ut_data_value_xmltype.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_xmltype as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_xmltype.tps b/source/expectations/data_values/ut_data_value_xmltype.tps index 42c54ae05..476097de3 100644 --- a/source/expectations/data_values/ut_data_value_xmltype.tps +++ b/source/expectations/data_values/ut_data_value_xmltype.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_xmltype under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_yminterval.tpb b/source/expectations/data_values/ut_data_value_yminterval.tpb index 38f3cf857..6d6a05b4a 100644 --- a/source/expectations/data_values/ut_data_value_yminterval.tpb +++ b/source/expectations/data_values/ut_data_value_yminterval.tpb @@ -1,7 +1,7 @@ create or replace type body ut_data_value_yminterval as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_data_value_yminterval.tps b/source/expectations/data_values/ut_data_value_yminterval.tps index efc9e0e48..d20dfcad7 100644 --- a/source/expectations/data_values/ut_data_value_yminterval.tps +++ b/source/expectations/data_values/ut_data_value_yminterval.tps @@ -1,7 +1,7 @@ create or replace type ut_data_value_yminterval under ut_data_value( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_json_data_diff_tmp.sql b/source/expectations/data_values/ut_json_data_diff_tmp.sql new file mode 100644 index 000000000..3d77dca8b --- /dev/null +++ b/source/expectations/data_values/ut_json_data_diff_tmp.sql @@ -0,0 +1,27 @@ +create global temporary table ut_json_data_diff_tmp( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + diff_id raw(128), + difference_type varchar2(250), + act_element_name varchar2(2000), + act_element_value varchar2(4000), + act_json_type varchar2(100), + act_access_path varchar2(4000), + act_parent_path varchar2(4000), + exp_element_name varchar2(2000), + exp_element_value varchar2(4000), + exp_json_type varchar2(2000), + exp_access_path varchar2(4000), + exp_parent_path varchar2(4000) +) on commit preserve rows; diff --git a/source/expectations/data_values/ut_json_leaf.tpb b/source/expectations/data_values/ut_json_leaf.tpb new file mode 100644 index 000000000..83f1009ef --- /dev/null +++ b/source/expectations/data_values/ut_json_leaf.tpb @@ -0,0 +1,32 @@ +create or replace type body ut_json_leaf as + + member procedure init( self in out nocopy ut_json_leaf, + a_element_name varchar2, a_element_value varchar2,a_parent_name varchar2, + a_access_path varchar2, a_hierarchy_level integer, a_index_position integer, a_json_type in varchar2, + a_parent_type varchar2, a_array_element integer:=0, a_parent_path varchar2) is + begin + self.element_name := a_element_name; + self.element_value := a_element_value; + self.parent_name := a_parent_name; + self.hierarchy_level := a_hierarchy_level; + self.access_path := a_access_path; + self.index_position := a_index_position; + self.json_type := a_json_type; + self.is_array_element := a_array_element; + self.parent_type := a_parent_type; + self.parent_path := a_parent_path; + end; + + constructor function ut_json_leaf( self in out nocopy ut_json_leaf, + a_element_name varchar2, a_element_value varchar2,a_parent_name varchar2, + a_access_path varchar2, a_hierarchy_level integer, a_index_position integer, a_json_type in varchar2, + a_parent_type varchar2, a_array_element integer:=0, a_parent_path varchar2) + return self as result is + begin + init(a_element_name,a_element_value,a_parent_name, a_access_path, a_hierarchy_level, a_index_position, + a_json_type,a_parent_type,a_array_element, a_parent_path); + return; + end; + +end; +/ diff --git a/source/expectations/data_values/ut_json_leaf.tps b/source/expectations/data_values/ut_json_leaf.tps new file mode 100644 index 000000000..c38c3b238 --- /dev/null +++ b/source/expectations/data_values/ut_json_leaf.tps @@ -0,0 +1,42 @@ +create or replace type ut_json_leaf authid current_user as object ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + element_name varchar2(4000), + element_value varchar2(4000), + parent_name varchar2(4000), + access_path varchar2(4000), + tlength integer, + display_path varchar2(4000), + hierarchy_level integer, + index_position integer, + json_type varchar2(2000), + is_array_element integer, + parent_type varchar2(2000), + parent_path varchar2(4000), + + member procedure init(self in out nocopy ut_json_leaf, + a_element_name varchar2, a_element_value varchar2,a_parent_name varchar2, + a_access_path varchar2, a_hierarchy_level integer, a_index_position integer, a_json_type in varchar2, + a_parent_type varchar2, a_array_element integer:=0, a_parent_path varchar2), + + constructor function ut_json_leaf( self in out nocopy ut_json_leaf, + a_element_name varchar2, a_element_value varchar2,a_parent_name varchar2, + a_access_path varchar2, a_hierarchy_level integer, a_index_position integer, a_json_type in varchar2, + a_parent_type varchar2, a_array_element integer:=0, a_parent_path varchar2) + return self as result +) +/ diff --git a/source/expectations/data_values/ut_json_leaf_tab.tps b/source/expectations/data_values/ut_json_leaf_tab.tps new file mode 100644 index 000000000..0c7a40b9f --- /dev/null +++ b/source/expectations/data_values/ut_json_leaf_tab.tps @@ -0,0 +1,19 @@ +create or replace type ut_json_leaf_tab as + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +table of ut_json_leaf +/ \ No newline at end of file diff --git a/source/expectations/data_values/ut_json_tree_details.tpb b/source/expectations/data_values/ut_json_tree_details.tpb new file mode 100644 index 000000000..a333ea71c --- /dev/null +++ b/source/expectations/data_values/ut_json_tree_details.tpb @@ -0,0 +1,207 @@ +create or replace type body ut_json_tree_details as + + member function get_json_type(a_json_piece json_element_t) return varchar2 is + begin + return + case + when a_json_piece.is_object then 'object' + when a_json_piece.is_array then 'array' + when a_json_piece.is_string then 'string' + when a_json_piece.is_number then 'number' + when a_json_piece.is_boolean then 'boolean' + when a_json_piece.is_true then 'true' + when a_json_piece.is_false then 'false' + when a_json_piece.is_null then 'null' + when a_json_piece.is_date then 'date' + when a_json_piece.is_timestamp then 'timestamp' + when a_json_piece.is_scalar then 'scalar' + else null + end; + end; + + member function get_json_value(a_json_piece json_element_t, a_key varchar2) return varchar2 is + l_json_el json_element_t; + l_val varchar2(4000); + begin + l_json_el := treat(a_json_piece as json_object_t).get(a_key); + case + when l_json_el.is_string then l_val := ut_utils.to_string(l_json_el.to_string(),null); + when l_json_el.is_number then l_val := ut_utils.to_string(l_json_el.to_number()); + when l_json_el.is_boolean then l_val := ut_utils.to_string(l_json_el.to_boolean()); +-- when l_json_el.is_true then l_val := ut_utils.to_string(l_json_el.to_boolean()); +-- when l_json_el.is_false then l_val := ut_utils.to_string(l_json_el.to_boolean()); + when l_json_el.is_date then l_val := ut_utils.to_string(l_json_el.to_date()); + when l_json_el.is_timestamp then l_val := ut_utils.to_string(l_json_el.to_date()); + else null; + end case; + return l_val; + end; + + member function get_json_value(a_json_piece json_element_t, a_key integer) return varchar2 is + l_json_el json_element_t; + l_val varchar2(4000); + begin + l_json_el := treat(a_json_piece as json_array_t).get(a_key); + case + when l_json_el.is_string then l_val := ut_utils.to_string(l_json_el.to_string(),null); + when l_json_el.is_number then l_val := ut_utils.to_string(l_json_el.to_number()); + when l_json_el.is_boolean then l_val := ut_utils.to_string(l_json_el.to_boolean()); +-- when l_json_el.is_true then l_val := ut_utils.to_string(l_json_el.to_boolean()); +-- when l_json_el.is_false then l_val := ut_utils.to_string(l_json_el.to_boolean()); + when l_json_el.is_date then l_val := ut_utils.to_string(l_json_el.to_date()); + when l_json_el.is_timestamp then l_val := ut_utils.to_string(l_json_el.to_date()); + else null; + end case; + return l_val; + end; + + member procedure add_json_leaf( + self in out nocopy ut_json_tree_details, + a_element_name varchar2, + a_element_value varchar2, + a_parent_name varchar2, + a_access_path varchar2, + a_hierarchy_level integer, + a_index_position integer, + a_json_type varchar2, + a_parent_type varchar2, + a_array_element integer := 0, + a_parent_path varchar2 + ) is + begin + self.json_tree_info.extend; + self.json_tree_info(self.json_tree_info.last) := + ut_json_leaf( + a_element_name, a_element_value, a_parent_name, a_access_path, + a_hierarchy_level, a_index_position,a_json_type, a_parent_type, + a_array_element, a_parent_path + ); + end; + + member procedure traverse_object( + self in out nocopy ut_json_tree_details, + a_json_piece json_element_t, + a_parent_name varchar2 := null, + a_hierarchy_level integer := 1, + a_access_path varchar2 := '$' + ) as + l_keys json_key_list; + l_object json_object_t := treat(a_json_piece as json_object_t); + l_path varchar2(32767); + l_type varchar2(50); + l_name varchar2(4000); + begin + l_keys := coalesce(l_object.get_keys,json_key_list()); + + for i in 1 .. l_keys.count loop + l_type := get_json_type(l_object.get(l_keys(i))); + l_name := '"'||l_keys(i)||'"'; + l_path := a_access_path||'.'||l_name; + + add_json_leaf( + l_name, + get_json_value(l_object,l_keys(i)), + a_parent_name, + l_path, + a_hierarchy_level, + i, + l_type, + 'object', + 0, + a_access_path + ); + case l_type + when 'array' then + traverse_array ( + treat (l_object.get (l_keys(i)) as json_array_t), + l_name, + a_hierarchy_level + 1, + l_path + ); + when 'object' then + traverse_object( + treat (l_object.get (l_keys(i)) as json_object_t), + l_name, + a_hierarchy_level+1, + l_path + ); + else + null; + end case; + end loop; + end traverse_object; + + member procedure traverse_array( + self in out nocopy ut_json_tree_details, + a_json_piece json_element_t, + a_parent_name varchar2 := null, + a_hierarchy_level integer := 1, + a_access_path varchar2 := '$' + ) as + l_array json_array_t; + l_type varchar2(50); + l_name varchar2(4000); + l_path varchar2(32767); + begin + l_array := treat(a_json_piece as json_array_t); + + for i in 0 .. l_array.get_size - 1 loop + l_type := get_json_type(l_array.get(i)); + l_name := case when l_type = 'object' then l_type else l_array.get(i).stringify end; + l_path := a_access_path||'['||i||']'; + + add_json_leaf( + l_name, + get_json_value(a_json_piece,i), + a_parent_name, + l_path, + a_hierarchy_level, + i, + l_type, + 'array', + 1, + l_path + ); + case l_type + when 'array' then + traverse_array ( + treat (l_array.get (i) as json_array_t), + l_name, + a_hierarchy_level + 1, + l_path + ); + when 'object' then + traverse_object( + treat (l_array.get (i) as json_object_t), + l_name, + a_hierarchy_level + 1, + l_path + ); + else + null; + end case; + end loop; + end traverse_array; + + member procedure init(self in out nocopy ut_json_tree_details,a_json_doc in json_element_t, a_level_in integer := 0) is + begin + if a_json_doc.is_object then + traverse_object(treat (a_json_doc as json_object_t)); + elsif a_json_doc.is_array then + traverse_array(treat (a_json_doc as json_array_t)); + end if; + end; + + constructor function ut_json_tree_details( + self in out nocopy ut_json_tree_details, a_json_doc in json_element_t, a_level_in integer := 0 + ) return self as result is + begin + self.json_tree_info := ut_json_leaf_tab(); + if a_json_doc is not null then + init(a_json_doc,a_level_in); + end if; + return; + end; + +end; +/ diff --git a/source/expectations/data_values/ut_json_tree_details.tps b/source/expectations/data_values/ut_json_tree_details.tps new file mode 100644 index 000000000..0684ecafe --- /dev/null +++ b/source/expectations/data_values/ut_json_tree_details.tps @@ -0,0 +1,54 @@ +create or replace type ut_json_tree_details force as object ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + json_tree_info ut_json_leaf_tab, + member function get_json_type(a_json_piece json_element_t) return varchar2, + member function get_json_value(a_json_piece json_element_t,a_key varchar2) return varchar2, + member function get_json_value(a_json_piece json_element_t,a_key integer) return varchar2, + member procedure add_json_leaf( + self in out nocopy ut_json_tree_details, + a_element_name varchar2, + a_element_value varchar2, + a_parent_name varchar2, + a_access_path varchar2, + a_hierarchy_level integer, + a_index_position integer, + a_json_type in varchar2, + a_parent_type in varchar2, + a_array_element integer := 0, + a_parent_path varchar2 + ), + member procedure traverse_object( + self in out nocopy ut_json_tree_details, + a_json_piece json_element_t, + a_parent_name varchar2 := null, + a_hierarchy_level integer := 1, + a_access_path varchar2 := '$' + ), + member procedure traverse_array( + self in out nocopy ut_json_tree_details, + a_json_piece json_element_t, + a_parent_name varchar2 := null, + a_hierarchy_level integer := 1, + a_access_path varchar2 := '$' + ), + member procedure init(self in out nocopy ut_json_tree_details,a_json_doc in json_element_t, a_level_in integer := 0), + constructor function ut_json_tree_details( + self in out nocopy ut_json_tree_details, a_json_doc in json_element_t, a_level_in integer := 0 + ) return self as result +) +/ diff --git a/source/expectations/data_values/ut_key_anyval_pair.tps b/source/expectations/data_values/ut_key_anyval_pair.tps index e0701ef28..4903282e9 100644 --- a/source/expectations/data_values/ut_key_anyval_pair.tps +++ b/source/expectations/data_values/ut_key_anyval_pair.tps @@ -1,7 +1,7 @@ create or replace type ut_key_anyval_pair force as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_key_anyval_pairs.tps b/source/expectations/data_values/ut_key_anyval_pairs.tps index 40748c5a5..94bd5df54 100644 --- a/source/expectations/data_values/ut_key_anyval_pairs.tps +++ b/source/expectations/data_values/ut_key_anyval_pairs.tps @@ -1,7 +1,7 @@ create or replace type ut_key_anyval_pairs as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_key_anyvalues.tpb b/source/expectations/data_values/ut_key_anyvalues.tpb index 07413f77b..93bf1eb53 100644 --- a/source/expectations/data_values/ut_key_anyvalues.tpb +++ b/source/expectations/data_values/ut_key_anyvalues.tpb @@ -1,7 +1,7 @@ create or replace type body ut_key_anyvalues as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/data_values/ut_key_anyvalues.tps b/source/expectations/data_values/ut_key_anyvalues.tps index c871d1466..6dd32a76d 100644 --- a/source/expectations/data_values/ut_key_anyvalues.tps +++ b/source/expectations/data_values/ut_key_anyvalues.tps @@ -1,7 +1,7 @@ create or replace type ut_key_anyvalues under ut_event_item ( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/json_objects_specs.sql b/source/expectations/json_objects_specs.sql new file mode 100644 index 000000000..c0d42e8fb --- /dev/null +++ b/source/expectations/json_objects_specs.sql @@ -0,0 +1,70 @@ +BEGIN + + $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then + dbms_output.put_line('Object exists , dont install'); + $else + dbms_output.put_line('Installing json structures specs.'); + execute immediate q'[create or replace TYPE JSON_Element_T FORCE AUTHID CURRENT_USER AS OBJECT( + dummyobjt NUMBER, + STATIC FUNCTION parse(jsn VARCHAR2) RETURN JSON_Element_T, + STATIC FUNCTION parse(jsn CLOB) RETURN JSON_Element_T, + STATIC FUNCTION parse(jsn BLOB) RETURN JSON_Element_T, + MEMBER FUNCTION to_Clob RETURN CLOB, + MEMBER FUNCTION stringify RETURN VARCHAR2, + MEMBER FUNCTION is_Object RETURN BOOLEAN, + MEMBER FUNCTION is_Array RETURN BOOLEAN, + MEMBER FUNCTION is_Scalar RETURN BOOLEAN, + MEMBER FUNCTION is_String RETURN BOOLEAN, + MEMBER FUNCTION is_Number RETURN BOOLEAN, + MEMBER FUNCTION is_Boolean RETURN BOOLEAN, + MEMBER FUNCTION is_True RETURN BOOLEAN, + MEMBER FUNCTION is_False RETURN BOOLEAN, + MEMBER FUNCTION is_Null RETURN BOOLEAN, + MEMBER FUNCTION is_Date RETURN BOOLEAN, + MEMBER FUNCTION is_Timestamp RETURN BOOLEAN, + MEMBER FUNCTION to_string RETURN VARCHAR2, + MEMBER FUNCTION to_number RETURN NUMBER, + MEMBER FUNCTION to_boolean RETURN BOOLEAN, + MEMBER FUNCTION to_date RETURN VARCHAR2, + + MEMBER FUNCTION get_Size(self IN JSON_ELEMENT_T) RETURN NUMBER +) NOT FINAL NOT INSTANTIABLE;]'; + + execute immediate q'[create or replace TYPE JSON_KEY_LIST FORCE AS VARRAY(32767) OF VARCHAR2(4000);]'; + + execute immediate q'[create or replace TYPE JSON_Array_T FORCE AUTHID CURRENT_USER UNDER JSON_Element_T( + CONSTRUCTOR FUNCTION JSON_Array_T RETURN SELF AS RESULT, + MEMBER FUNCTION get(pos NUMBER) RETURN JSON_Element_T, + MEMBER FUNCTION get_String(pos NUMBER) RETURN VARCHAR2, + MEMBER FUNCTION get_Number(pos NUMBER) RETURN NUMBER, + MEMBER FUNCTION get_Boolean(pos NUMBER) RETURN BOOLEAN, + MEMBER FUNCTION get_Date(pos NUMBER) RETURN DATE, + MEMBER FUNCTION get_Timestamp(pos NUMBER) RETURN TIMESTAMP, + MEMBER FUNCTION get_Clob(pos NUMBER) RETURN CLOB, + MEMBER PROCEDURE get_Clob(pos NUMBER, c IN OUT NOCOPY CLOB), + MEMBER FUNCTION get_Blob(pos NUMBER) RETURN BLOB, + MEMBER PROCEDURE get_Blob(pos NUMBER, b IN OUT NOCOPY BLOB), + MEMBER FUNCTION get_Type(pos NUMBER) RETURN VARCHAR2 +) FINAL;]'; + + execute immediate q'[create or replace TYPE JSON_Object_T AUTHID CURRENT_USER UNDER JSON_Element_T( + CONSTRUCTOR FUNCTION JSON_Object_T RETURN SELF AS RESULT, + MEMBER FUNCTION get(key VARCHAR2) RETURN JSON_Element_T, + MEMBER FUNCTION get_Object(key VARCHAR2) RETURN JSON_OBJECT_T, + MEMBER FUNCTION get_Array(key VARCHAR2) RETURN JSON_ARRAY_T, + MEMBER FUNCTION get_String(key VARCHAR2) RETURN VARCHAR2, + MEMBER FUNCTION get_Number(key VARCHAR2) RETURN NUMBER, + MEMBER FUNCTION get_Boolean(key VARCHAR2) RETURN BOOLEAN, + MEMBER FUNCTION get_Date(key VARCHAR2) RETURN DATE, + MEMBER FUNCTION get_Timestamp(key VARCHAR2) RETURN TIMESTAMP, + MEMBER FUNCTION get_Clob(key VARCHAR2) RETURN CLOB, + MEMBER PROCEDURE get_Clob(key VARCHAR2, c IN OUT NOCOPY CLOB), + MEMBER FUNCTION get_Blob(key VARCHAR2) RETURN BLOB, + MEMBER PROCEDURE get_Blob(key VARCHAR2, b IN OUT NOCOPY BLOB), + MEMBER FUNCTION get_Type(key VARCHAR2) RETURN VARCHAR2, + MEMBER FUNCTION get_Keys RETURN JSON_KEY_LIST +) FINAL;]'; + $end + +END; +/ \ No newline at end of file diff --git a/source/expectations/matchers/ut_be_between.tpb b/source/expectations/matchers/ut_be_between.tpb index f4bf24aab..7368ad5a7 100644 --- a/source/expectations/matchers/ut_be_between.tpb +++ b/source/expectations/matchers/ut_be_between.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_between is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_between.tps b/source/expectations/matchers/ut_be_between.tps index 79c4ec2fe..7e254719e 100644 --- a/source/expectations/matchers/ut_be_between.tps +++ b/source/expectations/matchers/ut_be_between.tps @@ -1,7 +1,7 @@ create or replace type ut_be_between under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_empty.tpb b/source/expectations/matchers/ut_be_empty.tpb index 82ad95d5a..08523fb02 100644 --- a/source/expectations/matchers/ut_be_empty.tpb +++ b/source/expectations/matchers/ut_be_empty.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_empty as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_empty.tps b/source/expectations/matchers/ut_be_empty.tps index 0acb80e55..76af402fe 100644 --- a/source/expectations/matchers/ut_be_empty.tps +++ b/source/expectations/matchers/ut_be_empty.tps @@ -1,7 +1,7 @@ create or replace type ut_be_empty under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_false.tpb b/source/expectations/matchers/ut_be_false.tpb index 6e2f3ba1f..671f43cbe 100644 --- a/source/expectations/matchers/ut_be_false.tpb +++ b/source/expectations/matchers/ut_be_false.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_false as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_false.tps b/source/expectations/matchers/ut_be_false.tps index 06bb290d4..3d4e8dda9 100644 --- a/source/expectations/matchers/ut_be_false.tps +++ b/source/expectations/matchers/ut_be_false.tps @@ -1,7 +1,7 @@ create or replace type ut_be_false under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_greater_or_equal.tpb b/source/expectations/matchers/ut_be_greater_or_equal.tpb index 978d821e1..6877eb32c 100644 --- a/source/expectations/matchers/ut_be_greater_or_equal.tpb +++ b/source/expectations/matchers/ut_be_greater_or_equal.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_greater_or_equal AS /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_greater_or_equal.tps b/source/expectations/matchers/ut_be_greater_or_equal.tps index b97589bb0..facd33b3d 100644 --- a/source/expectations/matchers/ut_be_greater_or_equal.tps +++ b/source/expectations/matchers/ut_be_greater_or_equal.tps @@ -1,7 +1,7 @@ create or replace type ut_be_greater_or_equal under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_greater_than.tpb b/source/expectations/matchers/ut_be_greater_than.tpb index b7b52af9a..da46347af 100644 --- a/source/expectations/matchers/ut_be_greater_than.tpb +++ b/source/expectations/matchers/ut_be_greater_than.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_greater_than AS /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_greater_than.tps b/source/expectations/matchers/ut_be_greater_than.tps index 9963a6277..fa19a9bd4 100644 --- a/source/expectations/matchers/ut_be_greater_than.tps +++ b/source/expectations/matchers/ut_be_greater_than.tps @@ -1,7 +1,7 @@ create or replace type ut_be_greater_than under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_less_or_equal.tpb b/source/expectations/matchers/ut_be_less_or_equal.tpb index 6f6b7febd..98c4238eb 100644 --- a/source/expectations/matchers/ut_be_less_or_equal.tpb +++ b/source/expectations/matchers/ut_be_less_or_equal.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_less_or_equal AS /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_less_or_equal.tps b/source/expectations/matchers/ut_be_less_or_equal.tps index a9fe9492b..225c99b72 100644 --- a/source/expectations/matchers/ut_be_less_or_equal.tps +++ b/source/expectations/matchers/ut_be_less_or_equal.tps @@ -1,7 +1,7 @@ create or replace type ut_be_less_or_equal under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_less_than.tpb b/source/expectations/matchers/ut_be_less_than.tpb index 7d3e06d62..e1c5c84b1 100644 --- a/source/expectations/matchers/ut_be_less_than.tpb +++ b/source/expectations/matchers/ut_be_less_than.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_less_than as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_less_than.tps b/source/expectations/matchers/ut_be_less_than.tps index f6ae1f0e4..8482f0327 100644 --- a/source/expectations/matchers/ut_be_less_than.tps +++ b/source/expectations/matchers/ut_be_less_than.tps @@ -1,7 +1,7 @@ create or replace type ut_be_less_than under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_like.tpb b/source/expectations/matchers/ut_be_like.tpb index 315f43d6c..dbcd1c798 100644 --- a/source/expectations/matchers/ut_be_like.tpb +++ b/source/expectations/matchers/ut_be_like.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_like as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_like.tps b/source/expectations/matchers/ut_be_like.tps index 1e8430e32..0c1609a98 100644 --- a/source/expectations/matchers/ut_be_like.tps +++ b/source/expectations/matchers/ut_be_like.tps @@ -1,7 +1,7 @@ create or replace type ut_be_like under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_not_null.tpb b/source/expectations/matchers/ut_be_not_null.tpb index 595a94b75..94ee0ce0a 100644 --- a/source/expectations/matchers/ut_be_not_null.tpb +++ b/source/expectations/matchers/ut_be_not_null.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_not_null as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_not_null.tps b/source/expectations/matchers/ut_be_not_null.tps index 42e899701..34cc2bfd0 100644 --- a/source/expectations/matchers/ut_be_not_null.tps +++ b/source/expectations/matchers/ut_be_not_null.tps @@ -1,7 +1,7 @@ create or replace type ut_be_not_null under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_null.tpb b/source/expectations/matchers/ut_be_null.tpb index 82a4391d6..3194f092f 100644 --- a/source/expectations/matchers/ut_be_null.tpb +++ b/source/expectations/matchers/ut_be_null.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_null as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_null.tps b/source/expectations/matchers/ut_be_null.tps index ef30feea1..486e11f28 100644 --- a/source/expectations/matchers/ut_be_null.tps +++ b/source/expectations/matchers/ut_be_null.tps @@ -1,7 +1,7 @@ create or replace type ut_be_null under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_true.tpb b/source/expectations/matchers/ut_be_true.tpb index 3c83002e0..565ab590b 100644 --- a/source/expectations/matchers/ut_be_true.tpb +++ b/source/expectations/matchers/ut_be_true.tpb @@ -1,7 +1,7 @@ create or replace type body ut_be_true as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_be_true.tps b/source/expectations/matchers/ut_be_true.tps index f73c7700b..b994913f5 100644 --- a/source/expectations/matchers/ut_be_true.tps +++ b/source/expectations/matchers/ut_be_true.tps @@ -1,7 +1,7 @@ create or replace type ut_be_true under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_comparison_matcher.tpb b/source/expectations/matchers/ut_comparison_matcher.tpb index 6eec4c11a..50f8d6050 100644 --- a/source/expectations/matchers/ut_comparison_matcher.tpb +++ b/source/expectations/matchers/ut_comparison_matcher.tpb @@ -1,7 +1,7 @@ create or replace type body ut_comparison_matcher as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_comparison_matcher.tps b/source/expectations/matchers/ut_comparison_matcher.tps index d66ad8b56..76520a296 100644 --- a/source/expectations/matchers/ut_comparison_matcher.tps +++ b/source/expectations/matchers/ut_comparison_matcher.tps @@ -1,7 +1,7 @@ create or replace type ut_comparison_matcher under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_contain.tpb b/source/expectations/matchers/ut_contain.tpb index bb6e78d50..cf6653f63 100644 --- a/source/expectations/matchers/ut_contain.tpb +++ b/source/expectations/matchers/ut_contain.tpb @@ -1,7 +1,7 @@ create or replace type body ut_contain as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_contain.tps b/source/expectations/matchers/ut_contain.tps index bb4e1b40a..518352573 100644 --- a/source/expectations/matchers/ut_contain.tps +++ b/source/expectations/matchers/ut_contain.tps @@ -1,7 +1,7 @@ create or replace type ut_contain under ut_equal( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_equal.tpb b/source/expectations/matchers/ut_equal.tpb index a666caaa3..2e774d396 100644 --- a/source/expectations/matchers/ut_equal.tpb +++ b/source/expectations/matchers/ut_equal.tpb @@ -1,7 +1,7 @@ create or replace type body ut_equal as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -152,6 +152,12 @@ create or replace type body ut_equal as return; end; + constructor function ut_equal(self in out nocopy ut_equal, a_expected json_element_t, a_nulls_are_equal boolean := null) return self as result is + begin + init(ut_data_value_json(a_expected), a_nulls_are_equal); + return; + end; + member function include(a_items varchar2) return ut_equal is l_result ut_equal := self; begin @@ -237,17 +243,17 @@ create or replace type body ut_equal as l_result varchar2(32767); begin if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then - if self.expected is of (ut_data_value_refcursor) then l_result := 'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info() - || chr(10) || 'Diff:' || - treat(expected as ut_data_value_refcursor).diff( a_actual, options ); + || chr(10) || 'Diff:' || + case + when self.expected is of (ut_data_value_refcursor) then + treat(expected as ut_data_value_refcursor).diff( a_actual, options ) + when self.expected is of (ut_data_value_json) then + treat(expected as ut_data_value_json).diff( a_actual, options ) else - l_result := - 'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info() - || chr(10) || 'Diff:' || - expected.diff( a_actual, options ); - end if; + expected.diff( a_actual, options ) + end; else l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report(); end if; diff --git a/source/expectations/matchers/ut_equal.tps b/source/expectations/matchers/ut_equal.tps index 68997fbcc..1f42324d7 100644 --- a/source/expectations/matchers/ut_equal.tps +++ b/source/expectations/matchers/ut_equal.tps @@ -1,7 +1,7 @@ create or replace type ut_equal force under ut_comparison_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ create or replace type ut_equal force under ut_comparison_matcher( constructor function ut_equal(self in out nocopy ut_equal, a_expected varchar2, a_nulls_are_equal boolean := null) return self as result, constructor function ut_equal(self in out nocopy ut_equal, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) return self as result, constructor function ut_equal(self in out nocopy ut_equal, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) return self as result, + constructor function ut_equal(self in out nocopy ut_equal, a_expected json_element_t, a_nulls_are_equal boolean := null) return self as result, member function include(a_items varchar2) return ut_equal, member function include(a_items ut_varchar2_list) return ut_equal, member function exclude(a_items varchar2) return ut_equal, diff --git a/source/expectations/matchers/ut_have_count.tpb b/source/expectations/matchers/ut_have_count.tpb index 135a948d5..b0f4e06d4 100644 --- a/source/expectations/matchers/ut_have_count.tpb +++ b/source/expectations/matchers/ut_have_count.tpb @@ -1,7 +1,7 @@ create or replace type body ut_have_count as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -28,6 +28,8 @@ create or replace type body ut_have_count as begin if a_actual is of(ut_data_value_refcursor) and ( treat (a_actual as ut_data_value_refcursor).compound_type != 'object') then l_result := ( self.expected = treat(a_actual as ut_data_value_refcursor).elements_count ); + elsif a_actual is of(ut_data_value_json) then + l_result := ( self.expected = treat(a_actual as ut_data_value_json).get_elements_count ); else l_result := (self as ut_matcher).run_matcher(a_actual); end if; @@ -36,12 +38,16 @@ create or replace type body ut_have_count as overriding member function failure_message(a_actual ut_data_value) return varchar2 is begin - return 'Actual: (' || a_actual.get_object_info()||') was expected to have [ count = '||ut_utils.to_string(self.expected)||' ]'; + return 'Actual: (' || case when a_actual is of (ut_data_value_json) then + treat(a_actual as ut_data_value_json).get_json_count_info() else a_actual.get_object_info() end|| + ') was expected to have [ count = '||ut_utils.to_string(self.expected)||' ]'; end; overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is begin - return 'Actual: ' || a_actual.get_object_info()||' was expected not to have [ count = '||ut_utils.to_string(self.expected)||' ]'; + return 'Actual: ' || case when a_actual is of (ut_data_value_json) then + treat(a_actual as ut_data_value_json).get_json_count_info() else a_actual.get_object_info() end|| + ' was expected not to have [ count = '||ut_utils.to_string(self.expected)||' ]'; end; end; diff --git a/source/expectations/matchers/ut_have_count.tps b/source/expectations/matchers/ut_have_count.tps index dc4511d72..fb0fc76fc 100644 --- a/source/expectations/matchers/ut_have_count.tps +++ b/source/expectations/matchers/ut_have_count.tps @@ -1,7 +1,7 @@ create or replace type ut_have_count under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_match.tpb b/source/expectations/matchers/ut_match.tpb index f85af4aac..57fabbaec 100644 --- a/source/expectations/matchers/ut_match.tpb +++ b/source/expectations/matchers/ut_match.tpb @@ -1,7 +1,7 @@ create or replace type body ut_match as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_match.tps b/source/expectations/matchers/ut_match.tps index ca9fcd34c..8d6b0f73a 100644 --- a/source/expectations/matchers/ut_match.tps +++ b/source/expectations/matchers/ut_match.tps @@ -1,7 +1,7 @@ create or replace type ut_match under ut_matcher( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_matcher.tpb b/source/expectations/matchers/ut_matcher.tpb index 4f3b324b4..228f2caad 100644 --- a/source/expectations/matchers/ut_matcher.tpb +++ b/source/expectations/matchers/ut_matcher.tpb @@ -1,7 +1,7 @@ create or replace type body ut_matcher as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_matcher.tps b/source/expectations/matchers/ut_matcher.tps index f4c082af0..34e1742df 100644 --- a/source/expectations/matchers/ut_matcher.tps +++ b/source/expectations/matchers/ut_matcher.tps @@ -1,7 +1,7 @@ create or replace type ut_matcher authid current_user as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_matcher_options.tpb b/source/expectations/matchers/ut_matcher_options.tpb index 7741747d5..6fec3dee6 100644 --- a/source/expectations/matchers/ut_matcher_options.tpb +++ b/source/expectations/matchers/ut_matcher_options.tpb @@ -1,7 +1,7 @@ create or replace type body ut_matcher_options as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_matcher_options.tps b/source/expectations/matchers/ut_matcher_options.tps index cae062bf1..dbdf985f0 100644 --- a/source/expectations/matchers/ut_matcher_options.tps +++ b/source/expectations/matchers/ut_matcher_options.tps @@ -1,7 +1,7 @@ create or replace type ut_matcher_options authid current_user as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_matcher_options_items.tpb b/source/expectations/matchers/ut_matcher_options_items.tpb index 575537417..2c3f51d34 100644 --- a/source/expectations/matchers/ut_matcher_options_items.tpb +++ b/source/expectations/matchers/ut_matcher_options_items.tpb @@ -1,7 +1,7 @@ create or replace type body ut_matcher_options_items is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/matchers/ut_matcher_options_items.tps b/source/expectations/matchers/ut_matcher_options_items.tps index 81ee17897..cc74650f3 100644 --- a/source/expectations/matchers/ut_matcher_options_items.tps +++ b/source/expectations/matchers/ut_matcher_options_items.tps @@ -1,7 +1,7 @@ create or replace type ut_matcher_options_items authid current_user as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/ut_expectation.tpb b/source/expectations/ut_expectation.tpb index 54de82b47..b50efef6a 100644 --- a/source/expectations/ut_expectation.tpb +++ b/source/expectations/ut_expectation.tpb @@ -1,7 +1,7 @@ create or replace type body ut_expectation as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -186,6 +186,10 @@ create or replace type body ut_expectation as self.to_( ut_equal(a_expected, a_nulls_are_equal) ); end; + member procedure to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null) is + begin + self.to_( ut_equal(a_expected, a_nulls_are_equal) ); + end; member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is begin @@ -288,6 +292,10 @@ create or replace type body ut_expectation as self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); end; + member procedure not_to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null) is + begin + self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); + end; member procedure to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 := null) is begin @@ -700,6 +708,6 @@ create or replace type body ut_expectation as begin self.not_to( ut_contain(a_expected).negated() ); end; - + end; / diff --git a/source/expectations/ut_expectation.tps b/source/expectations/ut_expectation.tps index eae74202e..5b3370c43 100644 --- a/source/expectations/ut_expectation.tps +++ b/source/expectations/ut_expectation.tps @@ -1,7 +1,7 @@ create or replace type ut_expectation authid current_user as object( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ create or replace type ut_expectation authid current_user as object( member procedure to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null), member procedure to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null), member procedure to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null), + member procedure to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null), member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null), member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null), @@ -69,6 +70,7 @@ create or replace type ut_expectation authid current_user as object( member procedure not_to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null), member procedure not_to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null), member procedure not_to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null), + member procedure not_to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null), member procedure to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 := null), diff --git a/source/expectations/ut_expectation_compound.tpb b/source/expectations/ut_expectation_compound.tpb index 603513e78..aaab7cb34 100644 --- a/source/expectations/ut_expectation_compound.tpb +++ b/source/expectations/ut_expectation_compound.tpb @@ -1,7 +1,7 @@ create or replace type body ut_expectation_compound as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/ut_expectation_compound.tps b/source/expectations/ut_expectation_compound.tps index a0f935c5c..bd17eb8b1 100644 --- a/source/expectations/ut_expectation_compound.tps +++ b/source/expectations/ut_expectation_compound.tps @@ -1,7 +1,7 @@ create or replace type ut_expectation_compound force under ut_expectation( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/expectations/ut_expectation_json.tpb b/source/expectations/ut_expectation_json.tpb new file mode 100644 index 000000000..954daf4e7 --- /dev/null +++ b/source/expectations/ut_expectation_json.tpb @@ -0,0 +1,61 @@ +create or replace type body ut_expectation_json as + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_expectation_json(self in out nocopy ut_expectation_json, a_actual_data ut_data_value, a_description varchar2) return self as result is + begin + self.actual_data := a_actual_data; + self.description := a_description; + return; + end; + + member procedure to_be_empty(self in ut_expectation_json) is + begin + self.to_( ut_be_empty() ); + end; + + member procedure not_to_be_empty(self in ut_expectation_json) is + begin + self.not_to( ut_be_empty() ); + end; + + member function to_equal(a_expected json_element_t, a_nulls_are_equal boolean := null) return ut_expectation_json is + l_result ut_expectation_json := self; + begin + l_result.matcher := ut_equal(a_expected, a_nulls_are_equal); + return l_result; + end; + + member function not_to_equal(a_expected json_element_t, a_nulls_are_equal boolean := null) return ut_expectation_json is + l_result ut_expectation_json := self; + begin + l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated(); + return l_result; + end; + + member procedure to_have_count(self in ut_expectation_json, a_expected integer) is + begin + self.to_( ut_have_count(a_expected) ); + end; + + member procedure not_to_have_count(self in ut_expectation_json, a_expected integer) is + begin + self.not_to( ut_have_count(a_expected) ); + end; + +end; +/ diff --git a/source/expectations/ut_expectation_json.tps b/source/expectations/ut_expectation_json.tps new file mode 100644 index 000000000..9cc9aecb8 --- /dev/null +++ b/source/expectations/ut_expectation_json.tps @@ -0,0 +1,29 @@ +create or replace type ut_expectation_json under ut_expectation( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + matcher ut_matcher, + + constructor function ut_expectation_json(self in out nocopy ut_expectation_json, a_actual_data ut_data_value, a_description varchar2) return self as result, + + member procedure to_be_empty(self in ut_expectation_json), + member procedure not_to_be_empty(self in ut_expectation_json), + member function to_equal(a_expected json_element_t , a_nulls_are_equal boolean := null) return ut_expectation_json, + member function not_to_equal(a_expected json_element_t , a_nulls_are_equal boolean := null) return ut_expectation_json, + member procedure to_have_count(self in ut_expectation_json, a_expected integer), + member procedure not_to_have_count(self in ut_expectation_json, a_expected integer) +) +/ diff --git a/source/install.sql b/source/install.sql index e34aa57af..c8eab658c 100644 --- a/source/install.sql +++ b/source/install.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -31,9 +31,10 @@ prompt &&line_separator alter session set current_schema = &&ut3_owner; @@check_object_grants.sql -@@check_sys_grants.sql +@@check_sys_grants.sql "'CREATE TYPE','CREATE VIEW','CREATE SYNONYM','CREATE SEQUENCE','CREATE PROCEDURE','CREATE TABLE'" --set define off + --dbms_output buffer cache table @@install_component.sql 'core/ut_dbms_output_cache.sql' @@ -84,6 +85,8 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'core/types/ut_reporter_base.tps' @@install_component.sql 'core/types/ut_reporters.tps' + +@@install_component.sql 'expectations/json_objects_specs.sql' @@install_component.sql 'expectations/matchers/ut_matcher_options_items.tps' @@install_component.sql 'expectations/matchers/ut_matcher_options.tps' @@install_component.sql 'expectations/data_values/ut_data_value.tps' @@ -92,21 +95,26 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'expectations/data_values/ut_key_anyvalues.tps' +--output buffer table +@@install_component.sql 'core/output_buffers/ut_output_buffer_info_tmp.sql' +@@install_component.sql 'core/output_buffers/ut_output_buffer_tmp.sql' +@@install_component.sql 'core/output_buffers/ut_output_clob_buffer_tmp.sql' --output buffer base api @@install_component.sql 'core/output_buffers/ut_output_data_row.tps' @@install_component.sql 'core/output_buffers/ut_output_data_rows.tps' @@install_component.sql 'core/output_buffers/ut_output_buffer_base.tps' ---output buffer table -@@install_component.sql 'core/output_buffers/ut_output_buffer_info_tmp.sql' -@@install_component.sql 'core/output_buffers/ut_output_buffer_tmp.sql' -@@install_component.sql 'core/output_buffers/ut_message_id_seq.sql' +@@install_component.sql 'core/output_buffers/ut_output_buffer_base.tpb' --output buffer table api @@install_component.sql 'core/output_buffers/ut_output_table_buffer.tps' @@install_component.sql 'core/output_buffers/ut_output_table_buffer.tpb' +@@install_component.sql 'core/output_buffers/ut_output_clob_table_buffer.tps' +@@install_component.sql 'core/output_buffers/ut_output_clob_table_buffer.tpb' @@install_component.sql 'core/types/ut_output_reporter_base.tps' --annotations +@@install_component.sql 'core/annotations/ut_trigger_check.pks' +@@install_component.sql 'core/annotations/ut_trigger_check.pkb' @@install_component.sql 'core/annotations/ut_annotation.tps' @@install_component.sql 'core/annotations/ut_annotations.tps' @@install_component.sql 'core/annotations/ut_annotated_object.tps' @@ -114,6 +122,7 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'core/annotations/ut_annotation_obj_cache_info.tps' @@install_component.sql 'core/annotations/ut_annotation_objs_cache_info.tps' @@install_component.sql 'core/annotations/ut_annotation_cache_seq.sql' +@@install_component.sql 'core/annotations/ut_annotation_cache_schema.sql' @@install_component.sql 'core/annotations/ut_annotation_cache_info.sql' @@install_component.sql 'core/annotations/ut_annotation_cache.sql' @@install_component.sql 'core/annotations/ut_annotation_cache_manager.pks' @@ -190,11 +199,14 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema --expectations and matchers @@install_component.sql 'expectations/data_values/ut_compound_data_tmp.sql' @@install_component.sql 'expectations/data_values/ut_compound_data_diff_tmp.sql' +@@install_component.sql 'expectations/data_values/ut_json_data_diff_tmp.sql' @@install_component.sql 'expectations/data_values/ut_compound_data_value.tps' +@@install_component.sql 'expectations/data_values/ut_json_leaf.tps' +@@install_component.sql 'expectations/data_values/ut_json_leaf_tab.tps' +@@install_component.sql 'expectations/data_values/ut_json_tree_details.tps' @@install_component.sql 'expectations/data_values/ut_cursor_column.tps' @@install_component.sql 'expectations/data_values/ut_cursor_column_tab.tps' @@install_component.sql 'expectations/data_values/ut_cursor_details.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_anydata.tps' @@install_component.sql 'expectations/data_values/ut_data_value_blob.tps' @@install_component.sql 'expectations/data_values/ut_data_value_boolean.tps' @@install_component.sql 'expectations/data_values/ut_data_value_clob.tps' @@ -210,6 +222,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tps' @@install_component.sql 'expectations/data_values/ut_data_value_xmltype.tps' @@install_component.sql 'expectations/data_values/ut_compound_data_helper.pks' +@@install_component.sql 'expectations/data_values/ut_data_value_json.tps' @@install_component.sql 'expectations/matchers/ut_matcher.tps' @@install_component.sql 'expectations/matchers/ut_comparison_matcher.tps' @@install_component.sql 'expectations/matchers/ut_be_false.tps' @@ -228,9 +241,12 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/matchers/ut_be_empty.tps' @@install_component.sql 'expectations/matchers/ut_match.tps' @@install_component.sql 'expectations/ut_expectation.tps' +@@install_component.sql 'expectations/data_values/ut_json_leaf.tpb' +@@install_component.sql 'expectations/data_values/ut_json_tree_details.tpb' @@install_component.sql 'expectations/data_values/ut_cursor_column.tpb' @@install_component.sql 'expectations/data_values/ut_cursor_details.tpb' @@install_component.sql 'expectations/ut_expectation_compound.tps' +@@install_component.sql 'expectations/ut_expectation_json.tps' @@install_component.sql 'expectations/matchers/ut_matcher_options_items.tpb' @@install_component.sql 'expectations/matchers/ut_matcher_options.tpb' @@ -251,6 +267,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tpb' @@install_component.sql 'expectations/data_values/ut_data_value_yminterval.tpb' @@install_component.sql 'expectations/data_values/ut_data_value_xmltype.tpb' +@@install_component.sql 'expectations/data_values/ut_data_value_json.tpb' @@install_component.sql 'expectations/matchers/ut_matcher.tpb' @@install_component.sql 'expectations/matchers/ut_comparison_matcher.tpb' @@install_component.sql 'expectations/matchers/ut_be_false.tpb' @@ -270,6 +287,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'expectations/matchers/ut_match.tpb' @@install_component.sql 'expectations/ut_expectation.tpb' @@install_component.sql 'expectations/ut_expectation_compound.tpb' +@@install_component.sql 'expectations/ut_expectation_json.tpb' @@install_component.sql 'expectations/data_values/ut_key_anyvalues.tpb' --core reporter @@ -278,6 +296,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema --plugin interface API for running utPLSQL @@install_component.sql 'api/ut_suite_item_info.tps' +@@install_component.sql 'api/ut_suite_item_info.tpb' @@install_component.sql 'api/ut_suite_items_info.tps' @@install_component.sql 'api/ut_runner.pks' @@install_component.sql 'api/ut_runner.pkb' diff --git a/source/install_component.sql b/source/install_component.sql index 16c4cd8a0..857c1771c 100644 --- a/source/install_component.sql +++ b/source/install_component.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/install_ddl_trigger.sql b/source/install_ddl_trigger.sql new file mode 100644 index 000000000..1395cc50c --- /dev/null +++ b/source/install_ddl_trigger.sql @@ -0,0 +1,22 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +@@define_ut3_owner_param.sql + +@@check_sys_grants.sql "'ADMINISTER DATABASE TRIGGER','CREATE TRIGGER'" +@@install_component.sql 'core/annotations/ut_trigger_annotation_parsing.trg' + diff --git a/source/install_headless.sql b/source/install_headless.sql index 8acc080fa..e8cf00705 100644 --- a/source/install_headless.sql +++ b/source/install_headless.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -14,25 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -set echo off -set verify off -column 1 new_value 1 noprint -column 2 new_value 2 noprint -column 3 new_value 3 noprint -select null as "1", null as "2" , null as "3" from dual where 1=0; -column sep new_value sep noprint -select '--------------------------------------------------------------' as sep from dual; - -spool params.sql.tmp - -column ut3_owner new_value ut3_owner noprint -column ut3_password new_value ut3_password noprint -column ut3_tablespace new_value ut3_tablespace noprint - -select coalesce('&&1','UT3') ut3_owner, - coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password, - coalesce('&&3','users') ut3_tablespace from dual; +@@set_install_params.sql @@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace @@install.sql &&ut3_owner diff --git a/source/install_headless_with_trigger.sql b/source/install_headless_with_trigger.sql new file mode 100644 index 000000000..0e13d7a59 --- /dev/null +++ b/source/install_headless_with_trigger.sql @@ -0,0 +1,26 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +@@set_install_params.sql + +@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace +@@install.sql &&ut3_owner +@@create_synonyms_and_grants_for_public.sql &&ut3_owner + +@@install_ddl_trigger.sql + +exit diff --git a/source/reporters/ut_ansiconsole_helper.pkb b/source/reporters/ut_ansiconsole_helper.pkb index 07d9ee9a7..b015e50be 100644 --- a/source/reporters/ut_ansiconsole_helper.pkb +++ b/source/reporters/ut_ansiconsole_helper.pkb @@ -1,7 +1,7 @@ create or replace package body ut_ansiconsole_helper as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_ansiconsole_helper.pks b/source/reporters/ut_ansiconsole_helper.pks index f34ff12bd..7c83ca73b 100644 --- a/source/reporters/ut_ansiconsole_helper.pks +++ b/source/reporters/ut_ansiconsole_helper.pks @@ -1,7 +1,7 @@ create or replace package ut_ansiconsole_helper as /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_cobertura_reporter.tpb b/source/reporters/ut_coverage_cobertura_reporter.tpb index 18221e3d9..eed8e8e73 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tpb +++ b/source/reporters/ut_coverage_cobertura_reporter.tpb @@ -1,160 +1,160 @@ -create or replace type body ut_coverage_cobertura_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project - - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - constructor function ut_coverage_cobertura_reporter( - self in out nocopy ut_coverage_cobertura_reporter - ) return self as result is - begin - self.init($$plsql_unit); - return; - end; - - - overriding member procedure after_calling_run(self in out nocopy ut_coverage_cobertura_reporter, a_run in ut_run) as - l_report_lines ut_varchar2_list; - l_coverage_data ut_coverage.t_coverage; - - function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return clob is - l_file_part varchar2(32767); - l_result clob; - l_line_no binary_integer; - l_pct integer; - begin - dbms_lob.createtemporary(l_result, true); - l_line_no := a_unit_coverage.lines.first; - if l_line_no is null then - for i in 1 .. a_unit_coverage.total_lines loop - ut_utils.append_to_clob(l_result, ''); - end loop; - else - while l_line_no is not null loop - if a_unit_coverage.lines(l_line_no).executions = 0 then - l_file_part := ''||chr(10); - else - l_file_part := ''||chr(10); - end if; - ut_utils.append_to_clob(l_result, l_file_part); - l_line_no := a_unit_coverage.lines.next(l_line_no); - end loop; - end if; - return l_result; - end; - - function get_coverage_xml( - a_coverage_data ut_coverage.t_coverage, - a_run ut_run - ) return ut_varchar2_rows is - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_full_name; - l_obj_name ut_coverage.t_object_name; - c_coverage_def constant varchar2(200) := ''; - c_file_footer constant varchar2(30) := ''; - c_coverage_footer constant varchar2(30) := ''; - c_sources_footer constant varchar2(30) := ''; - c_packages_footer constant varchar2(30) := ''; - c_package_footer constant varchar2(30) := ''; - c_class_footer constant varchar2(30) := ''; - c_lines_footer constant varchar2(30) := ''; - l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60; - begin - - ut_utils.append_to_list( l_result, ut_utils.get_xml_header(a_run.client_character_set) ); - ut_utils.append_to_list( l_result, c_coverage_def ); - - --write header - ut_utils.append_to_list( - l_result, - '' - ); - - - --Write sources - l_unit := a_coverage_data.objects.first; - ut_utils.append_to_list( l_result, '' ); - - while l_unit is not null loop - ut_utils.append_to_list(l_result, ''||dbms_xmlgen.convert(l_unit)||''); - l_unit := a_coverage_data.objects.next(l_unit); - end loop; - ut_utils.append_to_list(l_result, c_sources_footer); - - --write packages - l_unit := a_coverage_data.objects.first; - ut_utils.append_to_list(l_result, ''); - - while l_unit is not null loop - l_obj_name := a_coverage_data.objects(l_unit).name; - ut_utils.append_to_list( - l_result, - '' - ); - - ut_utils.append_to_list( - l_result, - '' - ); - - ut_utils.append_to_list(l_result, ''); - - ut_utils.append_to_list( l_result, get_lines_xml(a_coverage_data.objects(l_unit)) ); - - ut_utils.append_to_list(l_result, c_lines_footer); - ut_utils.append_to_list(l_result, c_class_footer); - ut_utils.append_to_list(l_result, c_package_footer); - - l_unit := a_coverage_data.objects.next(l_unit); - end loop; - - ut_utils.append_to_list(l_result, c_packages_footer); - ut_utils.append_to_list(l_result, c_coverage_footer); - return l_result; - end; - begin - ut_coverage.coverage_stop(); - - l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options); - - self.print_text_lines( get_coverage_xml( l_coverage_data, a_run ) ); - - (self as ut_reporter_base).after_calling_run(a_run); - end; - - overriding member function get_description return varchar2 as - begin - return 'Generates a Cobertura coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for Jenkins and TFS to report coverage. ' || chr(10) || - 'Cobertura Document Type Definition can be found: http://cobertura.sourceforge.net/xml/coverage-04.dtd.'|| chr(10) || - 'Sample file: https://github.com/leobalter/testing-examples/blob/master/solutions/3/report/cobertura-coverage.xml.'; - end; - -end; -/ +create or replace type body ut_coverage_cobertura_reporter is + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + constructor function ut_coverage_cobertura_reporter( + self in out nocopy ut_coverage_cobertura_reporter + ) return self as result is + begin + self.init($$plsql_unit); + return; + end; + + + overriding member procedure after_calling_run(self in out nocopy ut_coverage_cobertura_reporter, a_run in ut_run) as + l_report_lines ut_varchar2_list; + l_coverage_data ut_coverage.t_coverage; + + function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return clob is + l_file_part varchar2(32767); + l_result clob; + l_line_no binary_integer; + l_pct integer; + begin + dbms_lob.createtemporary(l_result, true); + l_line_no := a_unit_coverage.lines.first; + if l_line_no is null then + for i in 1 .. a_unit_coverage.total_lines loop + ut_utils.append_to_clob(l_result, ''||chr(10)); + end loop; + else + while l_line_no is not null loop + if a_unit_coverage.lines(l_line_no).executions = 0 then + l_file_part := ''||chr(10); + else + l_file_part := ''||chr(10); + end if; + ut_utils.append_to_clob(l_result, l_file_part); + l_line_no := a_unit_coverage.lines.next(l_line_no); + end loop; + end if; + return l_result; + end; + + function get_coverage_xml( + a_coverage_data ut_coverage.t_coverage, + a_run ut_run + ) return ut_varchar2_rows is + l_file_part varchar2(32767); + l_result ut_varchar2_rows := ut_varchar2_rows(); + l_unit ut_coverage.t_full_name; + l_obj_name ut_coverage.t_object_name; + c_coverage_def constant varchar2(200) := ''; + c_file_footer constant varchar2(30) := ''; + c_coverage_footer constant varchar2(30) := ''; + c_sources_footer constant varchar2(30) := ''; + c_packages_footer constant varchar2(30) := ''; + c_package_footer constant varchar2(30) := ''; + c_class_footer constant varchar2(30) := ''; + c_lines_footer constant varchar2(30) := ''; + l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60; + begin + + ut_utils.append_to_list( l_result, ut_utils.get_xml_header(a_run.client_character_set) ); + ut_utils.append_to_list( l_result, c_coverage_def ); + + --write header + ut_utils.append_to_list( + l_result, + '' + ); + + + --Write sources + l_unit := a_coverage_data.objects.first; + ut_utils.append_to_list( l_result, '' ); + + while l_unit is not null loop + ut_utils.append_to_list(l_result, ''||dbms_xmlgen.convert(l_unit)||''); + l_unit := a_coverage_data.objects.next(l_unit); + end loop; + ut_utils.append_to_list(l_result, c_sources_footer); + + --write packages + l_unit := a_coverage_data.objects.first; + ut_utils.append_to_list(l_result, ''); + + while l_unit is not null loop + l_obj_name := a_coverage_data.objects(l_unit).name; + ut_utils.append_to_list( + l_result, + '' + ); + + ut_utils.append_to_list( + l_result, + '' + ); + + ut_utils.append_to_list(l_result, ''); + + ut_utils.append_to_list( l_result, get_lines_xml(a_coverage_data.objects(l_unit)) ); + + ut_utils.append_to_list(l_result, c_lines_footer); + ut_utils.append_to_list(l_result, c_class_footer); + ut_utils.append_to_list(l_result, c_package_footer); + + l_unit := a_coverage_data.objects.next(l_unit); + end loop; + + ut_utils.append_to_list(l_result, c_packages_footer); + ut_utils.append_to_list(l_result, c_coverage_footer); + return l_result; + end; + begin + ut_coverage.coverage_stop(); + + l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options); + + self.print_text_lines( get_coverage_xml( l_coverage_data, a_run ) ); + + (self as ut_reporter_base).after_calling_run(a_run); + end; + + overriding member function get_description return varchar2 as + begin + return 'Generates a Cobertura coverage report providing information on code coverage with line numbers.' || chr(10) || + 'Designed for Jenkins and TFS to report coverage. ' || chr(10) || + 'Cobertura Document Type Definition can be found: http://cobertura.sourceforge.net/xml/coverage-04.dtd.'|| chr(10) || + 'Sample file: https://github.com/leobalter/testing-examples/blob/master/solutions/3/report/cobertura-coverage.xml.'; + end; + +end; +/ diff --git a/source/reporters/ut_coverage_cobertura_reporter.tps b/source/reporters/ut_coverage_cobertura_reporter.tps index 6bfd60892..ec5cef2cb 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tps +++ b/source/reporters/ut_coverage_cobertura_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_coverage_cobertura_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_html_reporter.tpb b/source/reporters/ut_coverage_html_reporter.tpb index 77d4b46ff..9e51b5cc2 100644 --- a/source/reporters/ut_coverage_html_reporter.tpb +++ b/source/reporters/ut_coverage_html_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_coverage_html_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_html_reporter.tps b/source/reporters/ut_coverage_html_reporter.tps index 11984ac58..f6bdcc249 100644 --- a/source/reporters/ut_coverage_html_reporter.tps +++ b/source/reporters/ut_coverage_html_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_coverage_html_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index 3ab0b1fb6..00a53c4c6 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -1,7 +1,7 @@ create or replace package body ut_coverage_report_html_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_report_html_helper.pks b/source/reporters/ut_coverage_report_html_helper.pks index bc4d025f3..48dd76acf 100644 --- a/source/reporters/ut_coverage_report_html_helper.pks +++ b/source/reporters/ut_coverage_report_html_helper.pks @@ -1,7 +1,7 @@ create or replace package ut_coverage_report_html_helper authid current_user is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_sonar_reporter.tpb b/source/reporters/ut_coverage_sonar_reporter.tpb index fcc213665..bfe0d890b 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tpb +++ b/source/reporters/ut_coverage_sonar_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_coverage_sonar_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coverage_sonar_reporter.tps b/source/reporters/ut_coverage_sonar_reporter.tps index af52f1675..aa21cafe3 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tps +++ b/source/reporters/ut_coverage_sonar_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_coverage_sonar_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coveralls_reporter.tpb b/source/reporters/ut_coveralls_reporter.tpb index 46c0947d0..1ca317c69 100644 --- a/source/reporters/ut_coveralls_reporter.tpb +++ b/source/reporters/ut_coveralls_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_coveralls_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_coveralls_reporter.tps b/source/reporters/ut_coveralls_reporter.tps index b5c1e1f28..53e86338e 100644 --- a/source/reporters/ut_coveralls_reporter.tps +++ b/source/reporters/ut_coveralls_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_coveralls_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_debug_reporter.tpb b/source/reporters/ut_debug_reporter.tpb index 186290296..365f77755 100644 --- a/source/reporters/ut_debug_reporter.tpb +++ b/source/reporters/ut_debug_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_debug_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ create or replace type body ut_debug_reporter is constructor function ut_debug_reporter(self in out nocopy ut_debug_reporter) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_clob_table_buffer()); self.start_time := current_timestamp(); self.event_time := current_timestamp(); return; diff --git a/source/reporters/ut_debug_reporter.tps b/source/reporters/ut_debug_reporter.tps index 91e90e28c..5fbab61fb 100644 --- a/source/reporters/ut_debug_reporter.tps +++ b/source/reporters/ut_debug_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_debug_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_documentation_reporter.tpb b/source/reporters/ut_documentation_reporter.tpb index df6c25ab0..7210e1cb6 100644 --- a/source/reporters/ut_documentation_reporter.tpb +++ b/source/reporters/ut_documentation_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_documentation_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -209,6 +209,9 @@ create or replace type body ut_documentation_reporter is else self.print_green_text(l_summary_text); end if; + if a_run.random_test_order_seed is not null then + self.print_text('Tests were executed with random order seed '''||a_run.random_test_order_seed||'''.'); + end if; self.print_text(' '); (self as ut_reporter_base).after_calling_run(a_run); end; diff --git a/source/reporters/ut_documentation_reporter.tps b/source/reporters/ut_documentation_reporter.tps index 275408a35..08097e7d4 100644 --- a/source/reporters/ut_documentation_reporter.tps +++ b/source/reporters/ut_documentation_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_documentation_reporter under ut_console_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index bc88aa8af..aa6786f6f 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_junit_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -23,8 +23,6 @@ create or replace type body ut_junit_reporter is end; overriding member procedure after_calling_run(self in out nocopy ut_junit_reporter, a_run in ut_run) is - c_cddata_tag_start constant varchar2(30) := ''; l_suite_id integer := 0; l_tests_count integer := a_run.results_count.disabled_count + a_run.results_count.success_count + a_run.results_count.failure_count + a_run.results_count.errored_count; @@ -36,8 +34,7 @@ create or replace type body ut_junit_reporter is procedure print_test_elements(a_test ut_test) is l_results ut_varchar2_rows := ut_varchar2_rows(); - l_lines ut_varchar2_list; - l_output clob; + l_output clob; begin ut_utils.append_to_list( l_results, @@ -51,30 +48,18 @@ create or replace type body ut_junit_reporter is end if; if a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, c_cddata_tag_start); - ut_utils.append_to_list( l_results, ut_utils.convert_collection(a_test.get_error_stack_traces()) ); - ut_utils.append_to_list( l_results, c_cddata_tag_end); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); ut_utils.append_to_list( l_results, ''); elsif a_test.result > ut_utils.gc_success then ut_utils.append_to_list( l_results, ''); - for i in 1 .. a_test.failed_expectations.count loop - - l_lines := a_test.failed_expectations(i).get_result_lines(); - - for j in 1 .. l_lines.count loop - ut_utils.append_to_list( l_results, dbms_xmlgen.convert(l_lines(j)) ); - end loop; - ut_utils.append_to_list( l_results, dbms_xmlgen.convert(a_test.failed_expectations(i).caller_info) ); - end loop; + ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) ); ut_utils.append_to_list( l_results, ''); end if; - -- TODO - decide if we need/want to use the tag too + l_output := a_test.get_serveroutputs(); if l_output is not null then ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, c_cddata_tag_start); - ut_utils.append_to_list( l_results, l_output); - ut_utils.append_to_list( l_results, c_cddata_tag_end ); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_serveroutputs() ) ); ut_utils.append_to_list( l_results, '' ); else ut_utils.append_to_list( l_results, ''); @@ -86,7 +71,7 @@ create or replace type body ut_junit_reporter is end; procedure print_suite_elements(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is - l_tests_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count + + l_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count + a_suite.results_count.failure_count + a_suite.results_count.errored_count; l_suite ut_suite; l_tests ut_suite_items := ut_suite_items(); @@ -95,7 +80,7 @@ create or replace type body ut_junit_reporter is l_errors ut_varchar2_list; begin a_suite_id := a_suite_id + 1; - self.print_text(''); -- Becasue testsuites have to appear before test we capture test and leave it for later. @@ -117,11 +102,9 @@ create or replace type body ut_junit_reporter is l_suite := treat(a_suite as ut_suite); l_data := l_suite.get_serveroutputs(); - if l_data is not null and l_data != empty_clob() then + if l_data is not null then ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, c_cddata_tag_start); - ut_utils.append_to_list( l_results, l_data); - ut_utils.append_to_list( l_results, c_cddata_tag_end); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( l_data ) ); ut_utils.append_to_list( l_results, ''); else ut_utils.append_to_list( l_results, ''); @@ -130,9 +113,7 @@ create or replace type body ut_junit_reporter is l_errors := l_suite.get_error_stack_traces(); if l_errors is not empty then ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, c_cddata_tag_start); - ut_utils.append_to_list( l_results, ut_utils.table_to_clob(l_errors)); - ut_utils.append_to_list( l_results, c_cddata_tag_end); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( l_errors ) ) ); ut_utils.append_to_list( l_results, ''); else ut_utils.append_to_list( l_results, ''); diff --git a/source/reporters/ut_junit_reporter.tps b/source/reporters/ut_junit_reporter.tps index 051358c59..ca6cf505b 100644 --- a/source/reporters/ut_junit_reporter.tps +++ b/source/reporters/ut_junit_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_junit_reporter force under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_realtime_reporter.tpb b/source/reporters/ut_realtime_reporter.tpb index e712c8f85..7a3176ee6 100644 --- a/source/reporters/ut_realtime_reporter.tpb +++ b/source/reporters/ut_realtime_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_realtime_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ create or replace type body ut_realtime_reporter is self in out nocopy ut_realtime_reporter ) return self as result is begin - self.init($$plsql_unit); + self.init($$plsql_unit,ut_output_clob_table_buffer()); total_number_of_tests := 0; current_test_number := 0; current_indent := 0; @@ -141,6 +141,7 @@ create or replace type body ut_realtime_reporter is self.print_end_node('counter'); self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_suite.get_error_stack_traces())); self.print_cdata_node('serverOutput', a_suite.get_serveroutputs()); + self.print_cdata_node('warnings', ut_utils.table_to_clob(a_suite.warnings)); self.print_end_node('suite'); self.print_end_node('event'); self.flush_print_buffer('post-suite'); @@ -196,6 +197,7 @@ create or replace type body ut_realtime_reporter is end loop expectations; self.print_end_node('failedExpectations'); end if; + self.print_cdata_node('warnings', ut_utils.table_to_clob(a_test.warnings)); self.print_end_node('test'); self.print_end_node('event'); self.flush_print_buffer('post-test'); diff --git a/source/reporters/ut_realtime_reporter.tps b/source/reporters/ut_realtime_reporter.tps index 096ebe8ee..99efed387 100644 --- a/source/reporters/ut_realtime_reporter.tps +++ b/source/reporters/ut_realtime_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_realtime_reporter force under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index 1da349d83..6d76b5d41 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_sonar_test_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -43,26 +43,18 @@ create or replace type body ut_sonar_test_reporter is end; procedure print_test_results(a_test ut_test) is - l_results ut_varchar2_rows := ut_varchar2_rows(); - l_lines ut_varchar2_list; + l_results ut_varchar2_rows := ut_varchar2_rows(); begin ut_utils.append_to_list( l_results, ''); if a_test.result = ut_utils.gc_disabled then ut_utils.append_to_list( l_results, ''); elsif a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); ut_utils.append_to_list( l_results, ''); elsif a_test.result > ut_utils.gc_success then ut_utils.append_to_list( l_results, ''); - for i in 1 .. a_test.failed_expectations.count loop - l_lines := a_test.failed_expectations(i).get_result_lines(); - for i in 1 .. l_lines.count loop - ut_utils.append_to_list( l_results, dbms_xmlgen.convert(l_lines(i))); - end loop; - end loop; + ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) ); ut_utils.append_to_list( l_results, ''); end if; ut_utils.append_to_list( l_results, ''); diff --git a/source/reporters/ut_sonar_test_reporter.tps b/source/reporters/ut_sonar_test_reporter.tps index 353edbf0d..8bdb067df 100644 --- a/source/reporters/ut_sonar_test_reporter.tps +++ b/source/reporters/ut_sonar_test_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_sonar_test_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_teamcity_reporter.tpb b/source/reporters/ut_teamcity_reporter.tpb index d01e85153..ee0a53098 100644 --- a/source/reporters/ut_teamcity_reporter.tpb +++ b/source/reporters/ut_teamcity_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_teamcity_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_teamcity_reporter.tps b/source/reporters/ut_teamcity_reporter.tps index 7f61e2b6e..2738ec00e 100644 --- a/source/reporters/ut_teamcity_reporter.tps +++ b/source/reporters/ut_teamcity_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_teamcity_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_teamcity_reporter_helper.pkb b/source/reporters/ut_teamcity_reporter_helper.pkb index f5167fbb8..2d165d7a3 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pkb +++ b/source/reporters/ut_teamcity_reporter_helper.pkb @@ -1,7 +1,7 @@ create or replace package body ut_teamcity_reporter_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_teamcity_reporter_helper.pks b/source/reporters/ut_teamcity_reporter_helper.pks index 6bab87367..7258999e1 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pks +++ b/source/reporters/ut_teamcity_reporter_helper.pks @@ -1,7 +1,7 @@ create or replace package ut_teamcity_reporter_helper is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index 5f3770b23..5262ac687 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_tfs_junit_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. @@ -29,9 +29,7 @@ create or replace type body ut_tfs_junit_reporter is member procedure junit_version_one(self in out nocopy ut_tfs_junit_reporter,a_run in ut_run) is l_suite_id integer := 0; - l_tests_count integer := a_run.results_count.disabled_count + a_run.results_count.success_count + - a_run.results_count.failure_count + a_run.results_count.errored_count; - + function get_common_suite_attributes(a_item ut_suite_item) return varchar2 is begin return ' errors="' ||a_item.results_count.errored_count || '"' || @@ -55,7 +53,6 @@ create or replace type body ut_tfs_junit_reporter is procedure print_test_results(a_test ut_test) is l_results ut_varchar2_rows := ut_varchar2_rows(); - l_lines ut_varchar2_list; begin self.print_text(''); @@ -69,20 +66,12 @@ create or replace type body ut_tfs_junit_reporter is if a_test.result = ut_utils.gc_error then ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) ); ut_utils.append_to_list( l_results, ''); -- Do not count error as failure elsif a_test.result = ut_utils.gc_failure then ut_utils.append_to_list( l_results, ''); - for i in 1 .. a_test.failed_expectations.count loop - l_lines := a_test.failed_expectations(i).get_result_lines(); - for j in 1 .. l_lines.count loop - ut_utils.append_to_list( l_results, dbms_xmlgen.convert(l_lines(j))); - end loop; - ut_utils.append_to_list( l_results, dbms_xmlgen.convert(a_test.failed_expectations(i).caller_info)); - end loop; + ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) ); ut_utils.append_to_list( l_results, ''); end if; @@ -106,43 +95,39 @@ create or replace type body ut_tfs_junit_reporter is end if; end loop; - if a_suite is of(ut_suite) then - a_suite_id := a_suite_id + 1; - self.print_text(''); - self.print_text(''); - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_test) then - print_test_results(treat(a_suite.items(i) as ut_test)); - end if; - end loop; - l_suite := treat(a_suite as ut_suite); - l_outputs := l_suite.get_serveroutputs(); - if l_outputs is not null and l_outputs != empty_clob() then - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); - else - ut_utils.append_to_list( l_results, ''); - end if; + if a_suite is of(ut_suite) then + a_suite_id := a_suite_id + 1; + self.print_text(''); + self.print_text(''); + for i in 1 .. a_suite.items.count loop + if a_suite.items(i) is of(ut_test) then + print_test_results(treat(a_suite.items(i) as ut_test)); + end if; + end loop; + l_suite := treat(a_suite as ut_suite); + l_outputs := l_suite.get_serveroutputs(); + if l_outputs is not null and l_outputs != empty_clob() then + ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( l_suite.get_serveroutputs() ) ); + ut_utils.append_to_list( l_results, ''); + else + ut_utils.append_to_list( l_results, ''); + end if; - l_errors := l_suite.get_error_stack_traces(); - if l_errors is not empty then - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); - else - ut_utils.append_to_list( l_results, ''); - end if; - ut_utils.append_to_list( l_results, ''); + l_errors := l_suite.get_error_stack_traces(); + if l_errors is not empty then + ut_utils.append_to_list( l_results, ''); + ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( l_errors ) ) ); + ut_utils.append_to_list( l_results, ''); + else + ut_utils.append_to_list( l_results, ''); + end if; + ut_utils.append_to_list( l_results, ''); - self.print_text_lines(l_results); + self.print_text_lines(l_results); end if; - end; + end; begin l_suite_id := 0; diff --git a/source/reporters/ut_tfs_junit_reporter.tps b/source/reporters/ut_tfs_junit_reporter.tps index 9e7a90e0a..ecf422bd3 100644 --- a/source/reporters/ut_tfs_junit_reporter.tps +++ b/source/reporters/ut_tfs_junit_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_tfs_junit_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_xunit_reporter.tpb b/source/reporters/ut_xunit_reporter.tpb index e2deb22ce..b06c20810 100644 --- a/source/reporters/ut_xunit_reporter.tpb +++ b/source/reporters/ut_xunit_reporter.tpb @@ -1,7 +1,7 @@ create or replace type body ut_xunit_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/reporters/ut_xunit_reporter.tps b/source/reporters/ut_xunit_reporter.tps index 81fa19e5b..b09205171 100644 --- a/source/reporters/ut_xunit_reporter.tps +++ b/source/reporters/ut_xunit_reporter.tps @@ -1,7 +1,7 @@ create or replace type ut_xunit_reporter under ut_junit_reporter( /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/set_install_params.sql b/source/set_install_params.sql new file mode 100644 index 000000000..4dc33c367 --- /dev/null +++ b/source/set_install_params.sql @@ -0,0 +1,34 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +set echo off +set verify off +column 1 new_value 1 noprint; +column 2 new_value 2 noprint; +column 3 new_value 3 noprint; +select null as "1", null as "2" , null as "3" from dual where 1=0; +column sep new_value sep noprint +select '--------------------------------------------------------------' as sep from dual; + +column ut3_owner new_value ut3_owner noprint +column ut3_password new_value ut3_password noprint +column ut3_tablespace new_value ut3_tablespace noprint + +select coalesce('&&1','UT3') ut3_owner, + coalesce('&&2','XNtxj8eEgA6X6b6f') ut3_password, + coalesce('&&3','users') ut3_tablespace + from dual; diff --git a/source/uninstall.sql b/source/uninstall.sql index 7b927e91d..760bf89b7 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/uninstall_all.sql b/source/uninstall_all.sql index 8d2bf0222..32180d762 100644 --- a/source/uninstall_all.sql +++ b/source/uninstall_all.sql @@ -1,6 +1,6 @@ /* utPLSQL - Version 3 - Copyright 2016 - 2018 utPLSQL Project + Copyright 2016 - 2019 utPLSQL Project Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index 62d14cb58..a7e6b947e 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -1,4 +1,9 @@ set echo on + +drop trigger ut_trigger_annotation_parsing; + +drop synonym ut3_trigger_alive; + drop synonym be_between; drop synonym have_count; @@ -47,9 +52,7 @@ drop package ut_coverage; drop package ut_coverage_helper; -drop view ut_coverage_sources_tmp; - -drop table ut_coverage_sources_tmp$; +drop table ut_coverage_sources_tmp purge; drop package ut_teamcity_reporter_helper; @@ -63,20 +66,24 @@ drop package ut_suite_manager; drop package ut_suite_builder; -drop table ut_suite_cache; +drop package ut_suite_cache_manager; + +drop table ut_suite_cache purge; drop sequence ut_suite_cache_seq; -drop table ut_suite_cache_package; +drop table ut_suite_cache_package purge; -drop table ut_suite_cache_schema; +drop table ut_suite_cache_schema purge; drop package ut; -drop table ut_dbms_output_cache; +drop table ut_dbms_output_cache purge; drop type ut_expectation_compound force; +drop type ut_expectation_json force; + drop type ut_expectation force; drop package ut_expectation_processor; @@ -127,6 +134,8 @@ drop type ut_data_value_number force; drop type ut_data_value_refcursor force; +drop type ut_data_value_json force; + drop type ut_data_value_dsinterval force; drop type ut_data_value_date force; @@ -137,10 +146,6 @@ drop type ut_data_value_boolean force; drop type ut_data_value_blob force; -drop type ut_data_value_object force; - -drop type ut_data_value_collection force; - drop type ut_data_value_anydata force; drop type ut_data_value_xmltype force; @@ -151,15 +156,25 @@ drop type ut_matcher_options force; drop type ut_matcher_options_items force; +drop type ut_json_tree_details force; + +drop type ut_json_leaf_tab force; + +drop type ut_json_leaf; + drop type ut_cursor_details force; drop type ut_cursor_column_tab force; drop type ut_cursor_column force; -drop table ut_compound_data_tmp; +drop table ut_compound_data_tmp purge; -drop table ut_compound_data_diff_tmp; +drop table ut_compound_data_diff_tmp purge; + +drop table ut_json_data_diff_tmp; + +drop trigger ut_trigger_annotation_parsing; drop package ut_annotation_manager; @@ -167,9 +182,11 @@ drop package ut_annotation_parser; drop package ut_annotation_cache_manager; -drop table ut_annotation_cache cascade constraints; +drop table ut_annotation_cache cascade constraints purge; + +drop table ut_annotation_cache_info cascade constraints purge; -drop table ut_annotation_cache_info cascade constraints; +drop table ut_annotation_cache_schema cascade constraints purge; drop sequence ut_annotation_cache_seq; @@ -185,12 +202,23 @@ drop type ut_annotations force; drop type ut_annotation force; +drop package ut_trigger_check; + drop package ut_file_mapper; drop package ut_metadata; drop package ut_ansiconsole_helper; +begin + $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then + execute immediate 'drop type json_element_t force'; + $else + dbms_output.put_line('Nothing to drop'); + $end +end; +/ + drop package ut_utils; drop sequence ut_savepoint_seq; @@ -247,17 +275,15 @@ drop type ut_suite_item force; drop type ut_output_table_buffer force; -drop type ut_output_buffer_base force; - -drop view ut_output_buffer_tmp; +drop type ut_output_clob_table_buffer force; -drop table ut_output_buffer_tmp$ purge; +drop type ut_output_buffer_base force; -drop view ut_output_buffer_info_tmp; +drop table ut_output_buffer_tmp purge; -drop table ut_output_buffer_info_tmp$; +drop table ut_output_clob_buffer_tmp purge; -drop sequence ut_message_id_seq; +drop table ut_output_buffer_info_tmp purge; drop type ut_output_data_rows force; @@ -287,6 +313,8 @@ drop type ut_key_value_pairs force; drop type ut_key_value_pair force; +drop type ut_key_anyvalues force; + drop type ut_object_names force; drop type ut_object_name force; diff --git a/test/api/test_ut_run.pkb b/test/api/test_ut_run.pkb deleted file mode 100644 index 9e9fce0f7..000000000 --- a/test/api/test_ut_run.pkb +++ /dev/null @@ -1,1016 +0,0 @@ -create or replace package body test_ut_run is - - --%test(ut.version() returns version of the framework) - procedure ut_version is - begin - ut.expect(ut3.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); - end; - - --%test(ut.fail() marks test as failed) - procedure ut_fail is - begin - --Act - ut3.ut.fail('Testing failure message'); - --Assert - ut.expect( - xmltype(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).getClobVal() - ).to_be_like('%2%Testing failure message%'); - --Cleanup - ut3.ut_expectation_processor.clear_expectations(); - end; - - procedure create_ut3$user#_tests is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut3$user#.test_package_1 is - --%suite - --%suitepath(tests) - - --%test(Test1 from test package 1) - procedure test1; - - --%test(Test2 from test package 1) - procedure test2; - - procedure run(a_reporter ut3.ut_reporter_base := null); - procedure run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base); - procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null); - procedure run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base); - procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null); - procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base); - function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; - function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; - function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; - function run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; - function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; - function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; - - end test_package_1; - ]'; - execute immediate q'[create or replace package body ut3$user#.test_package_1 is - procedure test1 is - begin - dbms_output.put_line('test_package_1.test1 executed'); - end; - procedure test2 is - begin - dbms_output.put_line('test_package_1.test2 executed'); - end; - - procedure run(a_reporter ut3.ut_reporter_base := null) is - begin - ut3.ut.run(a_reporter); - end; - procedure run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is - begin - ut3.ut.run( - a_reporter, a_source_files => ut3.ut_varchar2_list(), - a_test_files => a_test_files - ); - end; - procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) is - begin - ut3.ut.run(a_path, a_reporter); - end; - procedure run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is - begin - ut3.ut.run( - a_path, - a_reporter, a_source_files => ut3.ut_varchar2_list(), - a_test_files => a_test_files - ); - end; - procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) is - begin - ut3.ut.run(a_paths, a_reporter); - end; - procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is - begin - ut3.ut.run( - a_paths, - a_reporter, a_source_files => ut3.ut_varchar2_list(), - a_test_files => a_test_files - ); - end; - - function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3.ut.run(a_reporter)); - return l_results; - end; - function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; - begin - select * bulk collect into l_results from table ( - ut3.ut.run( - a_reporter, a_source_files => ut3.ut_varchar2_list(), - a_test_files => a_test_files - )); - return l_results; - end; - function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3.ut.run(a_path, a_reporter)); - return l_results; - end; - function run(a_path varchar2, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; - begin - select * bulk collect into l_results from table ( - ut3.ut.run( - a_path, - a_reporter, a_source_files => ut3.ut_varchar2_list(), - a_test_files => a_test_files - )); - return l_results; - end; - function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3.ut.run(a_paths, a_reporter)); - return l_results; - end; - function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is - l_results ut3.ut_varchar2_list; - begin - select * bulk collect into l_results from table ( - ut3.ut.run( - a_paths, - a_reporter, a_source_files => ut3.ut_varchar2_list(), - a_test_files => a_test_files - )); - return l_results; - end; - end test_package_1; - ]'; - - execute immediate q'[create or replace package ut3$user#.test_package_2 is - --%suite - --%suitepath(tests.test_package_1) - - --%test - procedure test1; - - --%test - procedure test2; - - end test_package_2; - ]'; - execute immediate q'[create or replace package body ut3$user#.test_package_2 is - procedure test1 is - begin - dbms_output.put_line('test_package_2.test1 executed'); - end; - procedure test2 is - begin - dbms_output.put_line('test_package_2.test2 executed'); - end; - end test_package_2; - ]'; - - execute immediate q'[create or replace package ut3$user#.test_package_3 is - --%suite - --%suitepath(tests2) - - --%test - procedure test1; - - --%test - procedure test2; - - end test_package_3; - ]'; - execute immediate q'[create or replace package body ut3$user#.test_package_3 is - procedure test1 is - begin - dbms_output.put_line('test_package_3.test1 executed'); - end; - procedure test2 is - begin - dbms_output.put_line('test_package_3.test2 executed'); - end; - end test_package_3; - ]'; - end; - - procedure drop_ut3$user#_tests is - pragma autonomous_transaction; - begin - execute immediate q'[drop package ut3$user#.test_package_1]'; - execute immediate q'[drop package ut3$user#.test_package_2]'; - execute immediate q'[drop package ut3$user#.test_package_3]'; - end; - - procedure run_proc_no_params is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_package_1.run(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_proc_specific_reporter is - l_results clob; - begin - --Act - execute immediate 'begin ut3$user#.test_package_1.run(:a_reporter); end;' - using in ut3.ut_documentation_reporter(); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_proc_cov_file_list is - l_results clob; - begin - --Act - execute immediate 'begin ut3$user#.test_package_1.run(a_test_files=>:a_test_files, a_reporter=>:a_reporter); end;' - using - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in ut3.ut_sonar_test_reporter(); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%tests/ut3$user#.test_package_1.pkb%tests/ut3$user#.test_package_3.pkb%' ); - end; - - procedure run_proc_pkg_name is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_package_1.run(:a_path); end;' - using in 'test_package_1'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%' ); - ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); - ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); - end; - - procedure run_proc_pkg_name_file_list is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_package_1.run(:a_path, :a_test_files, :a_reporter); end;' - using - in 'test_package_3', - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in ut3.ut_sonar_test_reporter(); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); - ut.expect( l_results ).not_to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); - ut.expect( l_results ).not_to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); - end; - - procedure run_proc_path_list is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_package_1.run(:a_paths); end;' - using in ut3.ut_varchar2_list(':tests.test_package_1',':tests'); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%' ); - ut.expect( l_results ).to_be_like( '%test_package_2%' ); - ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); - end; - - procedure run_proc_path_list_file_list is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_package_1.run(:a_paths, :a_test_files, :a_reporter); end;' - using - in ut3.ut_varchar2_list(':tests.test_package_1',':tests'), - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in ut3.ut_sonar_test_reporter(); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); - ut.expect( l_results ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); - ut.expect( l_results ).not_to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); - end; - - procedure run_proc_null_reporter is - l_results clob; - begin - --Act - execute immediate 'begin ut3$user#.test_package_1.run(:a_reporter); end;' - using in cast(null as ut3.ut_reporter_base); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); - end; - - procedure run_proc_null_path is - l_results clob; - begin - --Act - execute immediate 'begin ut3$user#.test_package_1.run(:a_path); end;' - using in cast(null as varchar2); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_proc_null_path_list is - l_results clob; - l_paths ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin ut3$user#.test_package_1.run(:a_paths); end;' - using in l_paths; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_proc_empty_path_list is - l_results clob; - begin - --Act - execute immediate 'begin ut3$user#.test_package_1.run(:a_paths); end;' - using in ut3.ut_varchar2_list(); - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure create_suite_with_commit is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package test_commit_warning is - --%suite - --%suitepath(ut.run.transaction) - - --%test - procedure does_commit; - end;'; - execute immediate 'create or replace package body test_commit_warning is - procedure does_commit is - begin - ut3.ut.expect(1).to_equal(1); - commit; - end; - end;'; - end; - - procedure drop_suite_with_commit is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_commit_warning'; - end; - - procedure run_proc_warn_on_commit is - l_results clob; - begin - ut3.ut.run('test_commit_warning'); - l_results := core.get_dbms_output_as_clob(); - ut.expect(l_results).to_be_like( - '%Unable to perform automatic rollback after test%'|| - 'An implicit or explicit commit/rollback occurred in procedures:%' || - 'does_commit%' || - 'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.%' - ); - end; - - procedure create_failing_beforeall_suite is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package parent_suite is - --%suite - --%suitepath(ut.run.failing_setup) - - --%beforeall - procedure failing_setup; - end;'; - execute immediate 'create or replace package body parent_suite is - procedure failing_setup is - begin - raise no_data_found; - end; - end;'; - execute immediate 'create or replace package child_suite is - --%suite - --%suitepath(ut.run.failing_setup.parent_suite.some_sub_suite) - - --%test - procedure does_stuff; - end;'; - execute immediate 'create or replace package body child_suite is - procedure does_stuff is - begin - ut3.ut.expect(1).to_equal(1); - end; - end;'; - end; - - procedure drop_failing_beforeall_suite is - pragma autonomous_transaction; - begin - execute immediate 'drop package parent_suite'; - execute immediate 'drop package child_suite'; - end; - - procedure run_proc_fail_child_suites is - l_results clob; - begin - ut3.ut.run('child_suite'); - l_results := core.get_dbms_output_as_clob(); - ut.expect(l_results).to_be_like( - '%1) does_stuff%' || - 'ORA-01403: no data found%' || - 'ORA-06512: at "UT3_TESTER.PARENT_SUITE%' - ); - end; - - procedure transaction_setup is - pragma autonomous_transaction; - begin - execute immediate 'create table transaction_test_table(message varchar2(100))'; - execute immediate 'create or replace package test_transaction is - --%suite - - --%test - procedure insert_row; - - --%test - procedure insert_and_raise; - end; - '; - execute immediate 'create or replace package body test_transaction is - procedure insert_row is - begin - insert into transaction_test_table values (''2 - inside the test_transaction.insert_row test''); - end; - procedure insert_and_raise is - begin - insert into transaction_test_table values (''2 - inside the test_transaction.insert_row test''); - raise no_data_found; - end; - end; - '; - - end; - - procedure transaction_cleanup is - pragma autonomous_transaction; - begin - begin - execute immediate 'drop table transaction_test_table'; - exception - when others then null; - end; - begin - execute immediate 'drop package test_transaction'; - exception - when others then null; - end; - end; - - procedure run_proc_keep_test_data is - l_expected sys_refcursor; - l_actual sys_refcursor; - l_results clob; - begin - --Arrange - execute immediate ' - insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; - - --Act - ut3.ut.run('test_transaction.insert_row', a_force_manual_rollback => true); - l_results := core.get_dbms_output_as_clob(); - - --Assert - open l_expected for - select '1 - inside the test_ut_run.run_proc_keep_test_changes test' as message from dual - union all - select '2 - inside the test_transaction.insert_row test' from dual - order by 1; - - open l_actual for 'select * from transaction_test_table order by 1'; - - ut.expect( l_actual ).to_equal(l_expected); - end; - - procedure run_proc_keep_test_data_raise is - l_expected sys_refcursor; - l_actual sys_refcursor; - l_results clob; - begin - --Arrange - execute immediate ' - insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; - - --Act - ut3.ut.run('test_transaction.insert_and_raise', a_force_manual_rollback => true); - l_results := core.get_dbms_output_as_clob(); - - --Assert - open l_expected for - select '1 - inside the test_ut_run.run_proc_keep_test_changes test' as message from dual - union all - select '2 - inside the test_transaction.insert_row test' from dual - order by 1; - - open l_actual for 'select * from transaction_test_table order by 1'; - - ut.expect( l_actual ).to_equal(l_expected); - end; - - procedure run_proc_discard_test_data is - l_expected sys_refcursor; - l_actual sys_refcursor; - l_results clob; - begin - --Arrange - execute immediate ' - insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; - - --Act - ut3.ut.run('test_transaction.insert_row'); - l_results := core.get_dbms_output_as_clob(); - - --Assert - open l_expected for - select '1 - inside the test_ut_run.run_proc_keep_test_changes test' as message from dual; - - open l_actual for 'select * from transaction_test_table order by 1'; - - ut.expect( l_actual ).to_equal(l_expected); - end; - - procedure run_func_no_params is - l_results ut3.ut_varchar2_list; - begin - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(); end;' using out l_results; - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_func_specific_reporter is - l_results ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_reporter); end;' - using out l_results, in ut3.ut_documentation_reporter(); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_func_cov_file_list is - l_results ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(a_test_files=>:a_test_files, a_reporter=>:a_reporter); end;' - using out l_results, - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in ut3.ut_sonar_test_reporter(); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%tests/ut3$user#.test_package_1.pkb%tests/ut3$user#.test_package_3.pkb%' ); - end; - - procedure run_func_pkg_name is - l_results ut3.ut_varchar2_list; - begin - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_path); end;' - using out l_results, in 'test_package_1'; - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); - end; - - procedure run_func_pkg_name_file_list is - l_results ut3.ut_varchar2_list; - begin - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_path, :a_test_files, :a_reporter); end;' - using out l_results, - in 'test_package_3', - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in ut3.ut_sonar_test_reporter(); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); - end; - - procedure run_func_path_list is - l_results ut3.ut_varchar2_list; - begin - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths); end;' - using out l_results, in ut3.ut_varchar2_list(':tests.test_package_1',':tests'); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); - end; - - procedure run_func_path_list_file_list is - l_results ut3.ut_varchar2_list; - begin - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths, :a_test_files, :a_reporter); end;' - using out l_results, - in ut3.ut_varchar2_list(':tests.test_package_1',':tests'), - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in ut3.ut_sonar_test_reporter(); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_1.pkb%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests/ut3$user#.test_package_2.pkb%' ); - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3$user#.test_package_3.pkb%' ); - end; - - procedure run_func_null_reporter is - l_results ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_reporter); end;' - using out l_results, in cast(null as ut3.ut_reporter_base); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); - end; - - procedure run_func_null_path is - l_results ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_path); end;' - using out l_results, in cast(null as varchar2); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_func_null_path_list is - l_results ut3.ut_varchar2_list; - l_paths ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths); end;' - using out l_results, in l_paths; - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_func_empty_path_list is - l_results ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(:a_paths); end;' - using out l_results, in ut3.ut_varchar2_list(); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_func_cov_file_lst_null_rep is - l_results ut3.ut_varchar2_list; - begin - --Act - execute immediate 'begin :l_results := ut3$user#.test_package_1.run(a_test_files=>:a_test_files, a_reporter=>:a_reporter); end;' - using out l_results, - in ut3.ut_varchar2_list('tests/ut3$user#.test_package_1.pkb','tests/ut3$user#.test_package_2.pkb','tests/ut3$user#.test_package_3.pkb'), - in cast(null as ut3.ut_reporter_base); - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); - end; - - procedure run_func_empty_suite is - l_results ut3.ut_varchar2_list; - l_expected varchar2(32767); - pragma autonomous_transaction; - begin - --Arrange - execute immediate q'[create or replace package empty_suite as - -- %suite - - procedure not_a_test; - end;]'; - execute immediate q'[create or replace package body empty_suite as - procedure not_a_test is begin null; end; - end;]'; - l_expected := '%empty_suite%0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'; - --Act - select * bulk collect into l_results from table(ut3.ut.run('empty_suite')); - - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( l_expected ); - - --Cleanup - execute immediate q'[drop package empty_suite]'; - end; - - procedure create_db_link is - l_service_name varchar2(100); - pragma autonomous_transaction; - begin - select global_name into l_service_name from global_name; - execute immediate - 'create public database link db_loopback connect to ut3_tester identified by ut3 - using ''(DESCRIPTION= - (ADDRESS=(PROTOCOL=TCP) - (HOST='||sys_context('userenv','SERVER_HOST')||') - (PORT=1521) - ) - (CONNECT_DATA=(SERVICE_NAME='||l_service_name||')))'''; - end; - - procedure drop_db_link is - begin - execute immediate 'drop public database link db_loopback'; - exception - when others then - null; - end; - - procedure create_test_suite is - pragma autonomous_transaction; - begin - create_db_link; - execute immediate q'[ - create or replace package stateful_package as - function get_state return varchar2; - end; - ]'; - execute immediate q'[ - create or replace package body stateful_package as - g_state varchar2(1) := 'A'; - function get_state return varchar2 is begin return g_state; end; - end; - ]'; - execute immediate q'[ - create or replace package test_stateful as - --%suite - --%suitepath(test_state) - - --%test - --%beforetest(acquire_state_via_db_link,rebuild_stateful_package) - procedure failing_stateful_test; - - procedure rebuild_stateful_package; - procedure acquire_state_via_db_link; - - end; - ]'; - execute immediate q'{ - create or replace package body test_stateful as - - procedure failing_stateful_test is - begin - ut3.ut.expect(stateful_package.get_state@db_loopback).to_equal('abc'); - end; - - procedure rebuild_stateful_package is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package body stateful_package as - g_state varchar2(3) := 'abc'; - function get_state return varchar2 is begin return g_state; end; - end; - ]'; - end; - - procedure acquire_state_via_db_link is - begin - dbms_output.put_line('stateful_package.get_state@db_loopback='||stateful_package.get_state@db_loopback); - end; - end; - }'; - - end; - - procedure raise_in_invalid_state is - l_results ut3.ut_varchar2_list; - l_expected varchar2(32767); - begin - --Arrange - l_expected := 'test_state - test_stateful - failing_stateful_test [% sec] (FAILED - 1)% -Failures:% - 1) failing_stateful_test - ORA-04068: existing state of packages (DB_LOOPBACK%) has been discarded - ORA-04061: existing state of package body "UT3_TESTER.STATEFUL_PACKAGE" has been invalidated - ORA-04065: not executed, altered or dropped package body "UT3_TESTER.STATEFUL_PACKAGE"% - ORA-06512: at line 6% -1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)%'; - - --Act - select * bulk collect into l_results from table(ut3.ut.run('test_stateful')); - - --Assert - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( l_expected ); - ut.fail('Expected exception but nothing was raised'); - exception - when others then - ut.expect( ut3.ut_utils.table_to_clob(l_results) ).to_be_like( l_expected ); - ut.expect(sqlcode).to_equal(-4068); - end; - - procedure drop_test_suite is - pragma autonomous_transaction; - begin - drop_db_link; - execute immediate 'drop package stateful_package'; - execute immediate 'drop package test_stateful'; - end; - - procedure run_in_invalid_state is - l_results ut3.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767); - begin - select * bulk collect into l_results from table(ut3.ut.run('failing_invalid_spec')); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like('%Call params for % are not valid: package does not exist or is invalid: %FAILING_INVALID_SPEC%'); - - end; - - procedure compile_invalid_package is - ex_compilation_error exception; - pragma exception_init(ex_compilation_error,-24344); - pragma autonomous_transaction; - begin - begin - execute immediate q'[ - create or replace package failing_invalid_spec as - --%suite - gv_glob_val non_existing_table.id%type := 0; - - --%test - procedure test1; - end;]'; - exception when ex_compilation_error then null; - end; - begin - execute immediate q'[ - create or replace package body failing_invalid_spec as - procedure test1 is begin ut.expect(1).to_equal(1); end; - end;]'; - exception when ex_compilation_error then null; - end; - end; - procedure drop_invalid_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package failing_invalid_spec'; - end; - - procedure run_and_revalidate_specs is - l_results ut3.ut_varchar2_list; - l_actual clob; - l_is_invalid number; - begin - execute immediate q'[select count(1) from all_objects o where o.owner = :object_owner and o.object_type = 'PACKAGE' - and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid - using user,'INVALID_PCKAG_THAT_REVALIDATES'; - - select * bulk collect into l_results from table(ut3.ut.run('invalid_pckag_that_revalidates')); - - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(1).to_equal(l_is_invalid); - ut.expect(l_actual).to_be_like('%invalid_pckag_that_revalidates%invalidspecs [% sec]% -%Finished in % seconds% -%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - - end; - - procedure generate_invalid_spec is - ex_compilation_error exception; - pragma exception_init(ex_compilation_error,-24344); - pragma autonomous_transaction; - begin - - execute immediate q'[ - create or replace package parent_specs as - c_test constant varchar2(1) := 'Y'; - end;]'; - - execute immediate q'[ - create or replace package invalid_pckag_that_revalidates as - --%suite - g_var varchar2(1) := parent_specs.c_test; - - --%test(invalidspecs) - procedure test1; - end;]'; - - execute immediate q'[ - create or replace package body invalid_pckag_that_revalidates as - procedure test1 is begin ut.expect('Y').to_equal(g_var); end; - end;]'; - - -- That should invalidate test package and we can then revers - execute immediate q'[ - create or replace package parent_specs as - c_test_error constant varchar2(1) := 'Y'; - end;]'; - - execute immediate q'[ - create or replace package parent_specs as - c_test constant varchar2(1) := 'Y'; - end;]'; - - end; - procedure drop_invalid_spec is - pragma autonomous_transaction; - begin - execute immediate 'drop package invalid_pckag_that_revalidates'; - execute immediate 'drop package parent_specs'; - end; - - procedure run_and_report_warnings is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - - select * bulk collect into l_results from table(ut3.ut.run('bad_annotations')); - l_actual := ut3.ut_utils.table_to_clob(l_results); - - ut.expect(l_actual).to_be_like('%Invalid annotation "--%context". Cannot find following "--%endcontext". Annotation ignored.% -%1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s)%'); - - end; - - procedure create_bad_annot is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package bad_annotations as - --%suite - - --%context - - --%test(invalidspecs) - procedure test1; - - end;]'; - - execute immediate q'[ - create or replace package body bad_annotations as - procedure test1 is begin ut.expect(1).to_equal(1); end; - end;]'; - - end; - - procedure drop_bad_annot is - pragma autonomous_transaction; - begin - execute immediate 'drop package bad_annotations'; - end; - - procedure savepoints_on_db_links is - l_results clob; - begin - ut3.ut.run('test_distributed_savepoint'); - l_results := core.get_dbms_output_as_clob(); - ut.expect(l_results).to_be_like('%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure create_suite_with_link is - pragma autonomous_transaction; - begin - create_db_link; - execute immediate 'create table tst(id number(18,0))'; - execute immediate q'[ - create or replace package test_distributed_savepoint is - --%suite - --%suitepath(alltests) - - --%beforeall - procedure setup; - - --%test - procedure test; - end;]'; - - execute immediate q'[ - create or replace package body test_distributed_savepoint is - - g_expected constant integer := 1; - - procedure setup is - begin - insert into tst@db_loopback values(g_expected); - end; - - procedure test is - l_actual integer := 0; - begin - select id into l_actual from tst@db_loopback; - - ut.expect(l_actual).to_equal(g_expected); - end; - - end;]'; - end; - - procedure drop_suite_with_link is - pragma autonomous_transaction; - begin - drop_db_link; - execute immediate 'drop table tst'; - execute immediate 'drop package test_distributed_savepoint'; - end; - -end; -/ diff --git a/test/common_helper/utplsql.pkb b/test/common_helper/utplsql.pkb new file mode 100644 index 000000000..c752caa41 --- /dev/null +++ b/test/common_helper/utplsql.pkb @@ -0,0 +1,11 @@ +create or replace package body utplsql is + + procedure global_setup is + begin + --we need to have dbms_output enable for our tests + --TODO - move this to utPLSQL-cli once cli has support for it. + dbms_output.enable(null); + end; + +end; +/ diff --git a/test/common_helper/utplsql.pks b/test/common_helper/utplsql.pks new file mode 100644 index 000000000..51adbb117 --- /dev/null +++ b/test/common_helper/utplsql.pks @@ -0,0 +1,9 @@ +create or replace package utplsql is + + --%suite + + --%beforeall + procedure global_setup; + +end; +/ diff --git a/test/core.pkb b/test/core.pkb deleted file mode 100644 index 60baa0190..000000000 --- a/test/core.pkb +++ /dev/null @@ -1,92 +0,0 @@ -create or replace package body core is - - function get_dbms_output_as_clob return clob is - l_status number; - l_line varchar2(32767); - l_result clob; - begin - - dbms_output.get_line(line => l_line, status => l_status); - if l_status != 1 then - dbms_lob.createtemporary(l_result, true, dur => dbms_lob.session); - end if; - while l_status != 1 loop - if l_line is not null then - ut3.ut_utils.append_to_clob(l_result, l_line||chr(10)); - end if; - dbms_output.get_line(line => l_line, status => l_status); - end loop; - return l_result; - end; - - procedure global_setup is - begin - ut3.ut_coverage.set_develop_mode(true); - --improve performance of test execution by disabling all compiler optimizations - execute_autonomous('ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0'); - - execute_autonomous( - q'[create or replace package ut_transaction_control as - function count_rows(a_val varchar2) return number; - procedure setup; - procedure test; - procedure test_failure; - end;]' - ); - execute_autonomous( - q'[create or replace package body ut_transaction_control - as - - function count_rows(a_val varchar2) return number is - l_cnt number; - begin - select count(*) into l_cnt from ut$test_table t where t.val = a_val; - return l_cnt; - end; - procedure setup is begin - insert into ut$test_table values ('s'); - end; - procedure test is - begin - insert into ut$test_table values ('t'); - end; - procedure test_failure is - begin - insert into ut$test_table values ('t'); - --raise no_data_found; - raise_application_error(-20001,'Error'); - end; - end;]' - ); - end; - - procedure global_cleanup is - begin - execute_autonomous('drop package ut_transaction_control'); - end; - - procedure execute_autonomous(a_sql varchar2) is - pragma autonomous_transaction; - begin - if a_sql is not null then - execute immediate a_sql; - end if; - commit; - end; - - function run_test(a_path varchar2) return clob is - l_lines ut3.ut_varchar2_list; - begin - select * bulk collect into l_lines from table(ut3.ut.run(a_path)); - return ut3.ut_utils.table_to_clob(l_lines); - end; - - function get_value(a_variable varchar2) return integer is - l_glob_val integer; - begin - execute immediate 'begin :l_glob_val := '||a_variable||'; end;' using out l_glob_val; - return l_glob_val; - end; - -end; -/ diff --git a/test/core.pks b/test/core.pks deleted file mode 100644 index d23ab6be0..000000000 --- a/test/core.pks +++ /dev/null @@ -1,21 +0,0 @@ -create or replace package core is - - --%suite - --%suitepath(utplsql) - - --%beforeall - procedure global_setup; - - --%afterall - procedure global_cleanup; - - procedure execute_autonomous(a_sql varchar2); - - function run_test(a_path varchar2) return clob; - - function get_value(a_variable varchar2) return integer; - - function get_dbms_output_as_clob return clob; - -end; -/ diff --git a/test/core/annotations/test_annotation_manager.pkb b/test/core/annotations/test_annotation_manager.pkb deleted file mode 100644 index 804980a39..000000000 --- a/test/core/annotations/test_annotation_manager.pkb +++ /dev/null @@ -1,306 +0,0 @@ -create or replace package body test_annotation_manager is - - procedure create_dummy_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package dummy_package as - procedure some_dummy_procedure; - end;]'; - end; - - procedure drop_dummy_package is - pragma autonomous_transaction; - begin - execute immediate q'[drop package dummy_package]'; - end; - - procedure recompile_dummy_package is - pragma autonomous_transaction; - begin - execute immediate q'[alter package dummy_package compile]'; - end; - - procedure create_dummy_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package dummy_test_package as - --%suite(dummy_test_suite) - --%rollback(manual) - - --%test(dummy_test) - --%beforetest(some_procedure) - procedure some_dummy_test_procedure; - end;]'; - execute immediate q'[grant execute on dummy_test_package to public]'; - end; - - procedure modify_dummy_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package dummy_test_package as - --%suite(dummy_test_suite) - - --%test(dummy_test) - procedure some_dummy_test_procedure; - end;]'; - end; - - procedure drop_dummy_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[drop package dummy_test_package]'; - end; - - procedure recompile_dummy_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[alter package dummy_test_package compile]'; - end; - - procedure create_parse_proc_as_ut3$user# is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace procedure ut3$user#.parse_annotations is - begin - ut3.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER','PACKAGE'); - end;]'; - end; - - procedure parse_dummy_test_as_ut3$user# is - pragma autonomous_transaction; - begin - execute immediate 'begin ut3$user#.parse_annotations; end;'; - end; - - procedure drop_parse_proc_as_ut3$user# is - pragma autonomous_transaction; - begin - execute immediate 'drop procedure ut3$user#.parse_annotations'; - end; - - procedure cleanup_annotation_cache is - pragma autonomous_transaction; - begin - delete from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name in ('DUMMY_PACKAGE','DUMMY_TEST_PACKAGE'); - commit; - end; - - - procedure add_new_package is - l_actual_cache_id integer; - l_actual integer; - l_start_date date; - begin - --Act - l_start_date := sysdate; - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE' - and parse_time >= l_start_date; - - ut.expect(l_actual_cache_id).to_be_not_null; - - select count(1) - into l_actual - from ut3.ut_annotation_cache - where cache_id = l_actual_cache_id; - - ut.expect(l_actual).to_equal(0); - - end; - - procedure update_modified_package is - l_actual_cache_id integer; - l_actual integer; - l_start_date date; - begin - --Arrange - l_start_date := sysdate; - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - recompile_dummy_package(); - l_start_date := sysdate; - $if dbms_db_version.version >= 18 $then - dbms_session.sleep(1); - $else - dbms_lock.sleep(1); - $end - --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE' - and parse_time >= l_start_date; - - ut.expect(l_actual_cache_id).to_be_not_null; - - select count(1) - into l_actual - from ut3.ut_annotation_cache - where cache_id = l_actual_cache_id; - - ut.expect(l_actual).to_equal(0); - end; - - - procedure add_new_test_package is - l_actual_cache_id integer; - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; - begin - --Arrange - l_start_date := sysdate; - --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' - and parse_time >= l_start_date; - - ut.expect(l_actual_cache_id).to_be_not_null; - - open l_actual for - select annotation_position, annotation_name, annotation_text, subobject_name - from ut3.ut_annotation_cache where cache_id = l_actual_cache_id - order by annotation_position; - - open l_expected for - select 2 as annotation_position, 'suite' as annotation_name, - 'dummy_test_suite' as annotation_text, '' as subobject_name - from dual union all - select 3, 'rollback' , 'manual', '' as subobject_name - from dual union all - select 5, 'test' , 'dummy_test', 'some_dummy_test_procedure' as subobject_name - from dual union all - select 6, 'beforetest' , 'some_procedure', 'some_dummy_test_procedure' as subobject_name - from dual; - - ut.expect(l_actual).to_equal(l_expected); - end; - - - procedure update_modified_test_package is - l_actual_cache_id integer; - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; - begin - --Arrange - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - l_start_date := sysdate; - modify_dummy_test_package(); - --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' - and parse_time >= l_start_date; - - ut.expect(l_actual_cache_id).to_be_not_null; - - open l_actual for - select annotation_position, annotation_name, annotation_text, subobject_name - from ut3.ut_annotation_cache where cache_id = l_actual_cache_id - order by annotation_position; - - open l_expected for - select 2 as annotation_position, 'suite' as annotation_name, - 'dummy_test_suite' as annotation_text, to_char(null) as subobject_name - from dual union all - select 4, 'test' , 'dummy_test', 'some_dummy_test_procedure' as subobject_name - from dual; - - ut.expect(l_actual).to_equal(l_expected); - end; - - - procedure keep_dropped_data_in_cache is - l_actual_cache_id integer; - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; - begin - parse_dummy_test_as_ut3$user#(); - l_start_date := sysdate; - drop_dummy_test_package(); - --Act - parse_dummy_test_as_ut3$user#(); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' - and parse_time >= l_start_date; - - ut.expect(l_actual_cache_id).not_to_be_null(); - - open l_actual for - select annotation_position, annotation_name, annotation_text, subobject_name - from ut3.ut_annotation_cache where cache_id = l_actual_cache_id - order by annotation_position; - - open l_expected for - select 2 as annotation_position, 'suite' as annotation_name, - 'dummy_test_suite' as annotation_text, '' as subobject_name - from dual union all - select 3, 'rollback' , 'manual', '' as subobject_name - from dual union all - select 5, 'test' , 'dummy_test', 'some_dummy_test_procedure' as subobject_name - from dual union all - select 6, 'beforetest' , 'some_procedure', 'some_dummy_test_procedure' as subobject_name - from dual; - - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure no_data_for_dropped_object is - l_actual sys_refcursor; - begin - --Arrange - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - drop_dummy_test_package(); - --Act - open l_actual for - select * from table(ut3.ut_annotation_manager.get_annotated_objects(user,'PACKAGE')) - where object_name = 'DUMMY_TEST_PACKAGE'; - --Assert - ut.expect(l_actual).to_be_empty(); - end; - - procedure cleanup_dropped_data_in_cache is - l_cache_count integer; - l_actual sys_refcursor; - l_expected sys_refcursor; - l_start_date date; - begin - --Arrange - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - l_start_date := sysdate; - drop_dummy_test_package(); - --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - --Assert - select count(1) - into l_cache_count - from ut3.ut_annotation_cache_info - where object_owner = user - and object_type = 'PACKAGE' - and object_name = 'DUMMY_TEST_PACKAGE'; - - ut.expect(l_cache_count).to_equal(0); - - end; - -end test_annotation_manager; -/ diff --git a/test/core/annotations/test_annotation_manager.pks b/test/core/annotations/test_annotation_manager.pks deleted file mode 100644 index 0726c8256..000000000 --- a/test/core/annotations/test_annotation_manager.pks +++ /dev/null @@ -1,55 +0,0 @@ -create or replace package test_annotation_manager is - - --%suite(ut_annotation_manager) - --%suitepath(utplsql.core.annotations) - - --%aftereach - procedure cleanup_annotation_cache; - - procedure create_dummy_package; - - procedure drop_dummy_package; - - procedure create_dummy_test_package; - - procedure create_parse_proc_as_ut3$user#; - - procedure drop_parse_proc_as_ut3$user#; - - procedure drop_dummy_test_package; - - --%test(Adds new package to annotation cache info) - --%beforetest(create_dummy_package) - --%aftertest(drop_dummy_package) - procedure add_new_package; - - --%test(Updates annotation cache info for modified package) - --%beforetest(create_dummy_package) - --%aftertest(drop_dummy_package) - procedure update_modified_package; - - --%test(Adds annotations to cache for unit test package) - --%beforetest(create_dummy_test_package) - --%aftertest(drop_dummy_test_package) - procedure add_new_test_package; - - --%test(Updates annotations in cache for modified test package) - --%beforetest(create_dummy_test_package) - --%aftertest(drop_dummy_test_package) - procedure update_modified_test_package; - - --%test(Keeps annotations in cache when object was removed but user can't see whole schema) - --%beforetest(create_dummy_test_package,create_parse_proc_as_ut3$user#) - --%aftertest(drop_parse_proc_as_ut3$user#) - procedure keep_dropped_data_in_cache; - - --%test(Does not return data for dropped object) - --%beforetest(create_dummy_test_package) - procedure no_data_for_dropped_object; - - --%test(Remove object from cache when object dropped and user can see whole schema) - --%beforetest(create_dummy_test_package) - procedure cleanup_dropped_data_in_cache; - -end test_annotation_manager; -/ diff --git a/test/core/expectations/test_expectation_anydata.pkb b/test/core/expectations/test_expectation_anydata.pkb deleted file mode 100644 index 0b3a93261..000000000 --- a/test/core/expectations/test_expectation_anydata.pkb +++ /dev/null @@ -1,974 +0,0 @@ -create or replace package body test_expectation_anydata is - - g_test_expected anydata; - g_test_actual anydata; - - procedure cleanup_expectations is - begin - expectations.cleanup_expectations( ); - end; - - procedure cleanup is - begin - g_test_expected := null; - g_test_actual := null; - cleanup_expectations(); - end; - - procedure fail_on_different_type_null is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( cast(null as test_dummy_object) ); - g_test_actual := anydata.convertObject( cast(null as other_dummy_object) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual (ut3_tester.other_dummy_object) cannot be compared to Expected (ut3_tester.test_dummy_object) using matcher 'equal'.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure fail_on_different_type is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( other_dummy_object(1, 'A', '0') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual (ut3_tester.other_dummy_object) cannot be compared to Expected (ut3_tester.test_dummy_object) using matcher 'equal'.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure fail_on_different_object_data is - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( test_dummy_object(1, null, '0') ); - --Act - ut3.ut.expect( g_test_actual ).not_to_equal( g_test_expected ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure fail_on_one_object_null is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( cast(null as test_dummy_object) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object was expected to equal: ut3_tester.test_dummy_object -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Missing: 1A0]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - - end; - - procedure fail_on_collection_vs_object is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertCollection( test_dummy_object_list(test_dummy_object(1, 'A', '0')) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual (ut3_tester.test_dummy_object_list) cannot be compared to Expected (ut3_tester.test_dummy_object) using matcher 'equal'.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure fail_on_null_vs_empty_coll is - l_null_list test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list() ); - g_test_actual := anydata.convertCollection( l_null_list ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 0 ] -%Diff: -%Rows: [ all different ] -%All rows are different as the columns position is not matching.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - - end; - - procedure fail_on_one_collection_null is - l_null_list test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list(test_dummy_object(1, 'A', '0')) ); - g_test_actual := anydata.convertCollection( l_null_list ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Missing: 1A0]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure fail_on_one_collection_empty is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list(test_dummy_object(1, 'A', '0')) ); - g_test_actual := anydata.convertCollection( test_dummy_object_list() ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = 0 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Missing: 1A0]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - - end; - - procedure fail_on_different_coll_data is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_obj test_dummy_object := test_dummy_object(1, 'A', '0'); - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list(l_obj) ); - g_test_actual := anydata.convertCollection( test_dummy_object_list(l_obj, l_obj) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 2 - Extra: 1A0]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - --%test(Gives success when both anydata are NULL) - procedure success_on_both_anydata_null is - --Arrange - l_null_anydata anydata; - begin - --Act - ut3.ut.expect( l_null_anydata ).to_equal( l_null_anydata ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure success_on_both_object_null is - --Arrange - l_null_object test_dummy_object; - l_anydata anydata := anydata.convertObject(l_null_object); - begin - --Act - ut3.ut.expect( l_anydata ).to_equal( l_anydata ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure success_on_both_coll_null is - --Arrange - l_null_collection test_dummy_object_list; - l_anydata anydata := anydata.convertCollection(l_null_collection); - begin - --Act - ut3.ut.expect( l_anydata ).to_equal( l_anydata ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure success_on_same_coll_data is - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list(test_dummy_object(1, 'A', '0')) ); - g_test_actual := anydata.convertCollection( test_dummy_object_list(test_dummy_object(1, 'A', '0')) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure fail_on_coll_different_order is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_first_obj test_dummy_object := test_dummy_object(1, 'A', '0'); - l_second_obj test_dummy_object := test_dummy_object(2, 'b', '1'); - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list(l_first_obj, l_second_obj) ); - g_test_actual := anydata.convertCollection( test_dummy_object_list(l_second_obj, l_first_obj) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - procedure success_on_same_object_data is - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure exclude_attributes_as_list is - l_list ut3.ut_varchar2_list; - begin - --Arrange - l_list := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/Value','/TEST_DUMMY_OBJECT/ID'); - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>3, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure exclude_attributes_as_csv is - l_list varchar2(100); - begin - --Arrange - l_list := 'TEST_DUMMY_OBJECT/Value,TEST_DUMMY_OBJECT/ID'; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>2, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure exclude_attributes_xpath is - l_xpath varchar2(100); - begin - --Arrange - l_xpath := '//TEST_DUMMY_OBJECT/Value|//TEST_DUMMY_OBJECT/ID'; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>2, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_xpath ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure exclude_ignores_invalid_attrib is - l_exclude varchar2(100); - begin - --Arrange - l_exclude := 'BadAttributeName'; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_exclude ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure include_attributes_as_list is - l_list ut3.ut_varchar2_list; - begin - --Arrange - l_list := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/Value','TEST_DUMMY_OBJECT/ID'); - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'b',"Value"=>'0') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_list ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure include_attributes_as_csv is - l_xpath varchar2(100); - begin - --Arrange - l_xpath := 'TEST_DUMMY_OBJECT/key,TEST_DUMMY_OBJECT/ID'; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure include_attributes_xpath is - l_xpath varchar2(100); - begin - --Arrange - l_xpath := '//TEST_DUMMY_OBJECT/key|//TEST_DUMMY_OBJECT/ID'; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure include_ignores_invalid_attrib is - l_include varchar2(100); - begin - --Arrange - l_include := ' BadAttributeName, TEST_DUMMY_OBJECT/ID '; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_include ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure include_exclude_attributes_csv is - l_exclude varchar2(100); - l_include varchar2(100); - begin - --Arrange - l_include := 'TEST_DUMMY_OBJECT/key,TEST_DUMMY_OBJECT/ID,TEST_DUMMY_OBJECT/Value'; - l_exclude := '//TEST_DUMMY_OBJECT/key|//TEST_DUMMY_OBJECT/Value'; - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure include_exclude_attrib_list is - l_exclude ut3.ut_varchar2_list; - l_include ut3.ut_varchar2_list; - l_expected varchar2(32767); - l_actual varchar2(32767); - begin - --Arrange - l_include := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/key','TEST_DUMMY_OBJECT/ID','TEST_DUMMY_OBJECT/Value'); - l_exclude := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/key','TEST_DUMMY_OBJECT/Value'); - g_test_expected := anydata.convertObject( test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); - g_test_actual := anydata.convertObject( test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure reports_diff_attribute is - l_expected varchar2(32767); - l_actual varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( test_dummy_object(1, NULL, '0') ); - l_expected := q'[Actual: ut3_tester.test_dummy_object was expected to equal: ut3_tester.test_dummy_object -Diff: -Rows: [ 1 differences ] - Row No. 1 - Actual: - Row No. 1 - Expected: A]'; - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_actual := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - ut.expect(l_actual).to_be_like(l_expected); - end; - - - procedure reports_diff_structure is - l_obj test_dummy_object := test_dummy_object(1, 'A', '0'); - l_expected varchar2(32767); - l_actual varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertCollection( test_dummy_object_list(l_obj) ); - g_test_actual := anydata.convertCollection( test_dummy_object_list(l_obj, l_obj) ); - l_expected := q'[Actual: ut3_tester.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 1 ] -Diff: -Rows: [ 1 differences ] - Row No. 2 - Extra: 1A0]'; - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_actual := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - ut.expect(l_actual).to_be_like(l_expected); - end; - - function get_anydata return anydata is - begin - return anydata.convertObject( test_dummy_object(1, 'B', '0') ); - end; - - procedure deprec_to_equal_excl_varch is - begin - --Act - ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); - --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); - end; - - procedure deprec_to_equal_excl_list is - begin - --Act - ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); - --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); - end; - - procedure deprec_not_to_equal_excl_varch is - begin - --Act - ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); - --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); - end; - - procedure deprec_not_to_equal_excl_list is - begin - --Act - ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); - --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); - end; - - procedure deprec_equal_excl_varch is - begin - --Act - ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col')); - --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); - end; - - procedure deprec_equal_excl_list is - begin - --Act - ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'))); - --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); - end; - - procedure data_diff_on_atr_data_mismatch is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2 - order by rownum desc; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - l_expected_message := q'[Actual: ut3_tester.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 2 ] -Diff: -Rows: [ 2 differences ] - Row No. 1 - Actual: 1Something 11 - Row No. 1 - Expected: 2Something 22 - Row No. 2 - Actual: 2Something 22 - Row No. 2 - Expected: 1Something 11]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure data_diff_on_20_rows_only is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - select test_dummy_object( rn, 'Something '||rn, rn1) - bulk collect into l_actual - from (select rownum * case when mod(rownum,2) = 0 then -1 else 1 end rn, - rownum * case when mod(rownum,4) = 0 then -1 else 1 end rn1 - from dual connect by level <=100); - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=110; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - l_expected_message := q'[Actual: ut3_tester.test_dummy_object_list [ count = 100 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 110 ] -Diff: -Rows: [ 60 differences, showing first 20 ] - Row No. 2 - Actual: -2Something -2 - Row No. 2 - Expected: 2Something 2 - Row No. 4 - Actual: -4Something -4-4 - Row No. 4 - Expected: 4Something 44 - % - Row No. 38 - Actual: -38Something -38 - Row No. 38 - Expected: 38Something 38 - Row No. 40 - Actual: -40Something -40-40 - Row No. 40 - Expected: 40Something 4040]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure collection_include_list is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_list ut3.ut_varchar2_list; - begin - l_list := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/Value','TEST_DUMMY_OBJECT/ID'); - --Arrange - select test_dummy_object( rownum, 'SomethingsDifferent '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); - - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure collection_exclude_list is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_list ut3.ut_varchar2_list; - begin - l_list := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/Value','TEST_DUMMY_OBJECT/ID'); - --Arrange - select test_dummy_object( rownum*2, 'Something '||rownum, rownum*2) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).exclude( l_list ); - - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure collection_include_list_fail is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_list ut3.ut_varchar2_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - l_list := ut3.ut_varchar2_list('TEST_DUMMY_OBJECT/name'); - --Arrange - select test_dummy_object( rownum, 'SomethingsDifferent '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); - - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 2 ] -%Diff: -%Rows: [ 2 differences ] -%All rows are different as the columns are not matching.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure array_same_data is - begin - --Arrange - g_test_expected := anydata.convertCollection( t_tab_varchar('A') ); - g_test_actual := anydata.convertCollection( t_tab_varchar('A') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure array_diff_data is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertCollection( t_tab_varchar('A') ); - g_test_actual := anydata.convertCollection( t_tab_varchar('B') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester.t_tab_varchar [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: B -%Row No. 1 - Expected: A]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure array_is_null is - l_is_null t_tab_varchar ; - begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure array_null_equal_array_null is - l_is_null t_tab_varchar ; - l_is_null_bis t_tab_varchar ; - begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure array_null_equal_array_notnull is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_is_null t_tab_varchar ; - begin - --Arrange - g_test_expected := anydata.convertCollection( l_is_null ); - g_test_actual := anydata.convertCollection( t_tab_varchar('A') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester.t_tab_varchar [ count = ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Extra: A]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure empty_array_have_zero_elem is - begin - ut3.ut.expect( anydata.convertCollection(t_tab_varchar())).to_have_count(0); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure array_empty_equal_array_empty is - begin - --Arrange - g_test_expected := anydata.convertCollection(t_tab_varchar()); - g_test_actual := anydata.convertCollection(t_tab_varchar()); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure arr_empty_equal_arr_notempty is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_is_null t_tab_varchar ; - begin - --Arrange - g_test_expected := anydata.convertCollection( t_tab_varchar() ); - g_test_actual := anydata.convertCollection( t_tab_varchar('A') ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester.t_tab_varchar [ count = 0 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Extra: A]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure collection_is_null is - l_null_list test_dummy_object_list; - begin - --Arrange - g_test_actual := anydata.convertCollection( l_null_list ); - --Act - ut3.ut.expect( g_test_actual ).to_be_null; - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure collection_is_empty is - begin - --Arrange - g_test_actual := anydata.convertCollection( test_dummy_object_list() ); - --Act - ut3.ut.expect( g_test_actual ).to_have_count(0); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - - end; - - procedure varray_same_data is - begin - --Arrange - g_test_expected := anydata.convertCollection( t_varray(1) ); - g_test_actual := anydata.convertCollection( t_varray(1) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure varray_diff_data is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertCollection( t_varray(1) ); - g_test_actual := anydata.convertCollection( t_varray(2) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester.t_varray [ count = 1 ] was expected to equal: ut3_tester.t_varray [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: 2 -%Row No. 1 - Expected: 1]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure varray_is_null is - l_is_null t_varray ; - begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure varray_null_equal_varray_null is - l_is_null t_varray ; - l_is_null_bis t_varray ; - begin - ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure varr_null_equal_varr_notnull is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_is_null t_varray ; - begin - --Arrange - g_test_expected := anydata.convertCollection( l_is_null ); - g_test_actual := anydata.convertCollection( t_varray(1) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester.t_varray [ count = 1 ] was expected to equal: ut3_tester.t_varray [ count = ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Extra: 1]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure empty_varray_have_zero_elem is - begin - ut3.ut.expect( anydata.convertCollection(t_varray())).to_have_count(0); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure varr_empty_equal_varr_empty is - begin - --Arrange - g_test_expected := anydata.convertCollection(t_varray()); - g_test_actual := anydata.convertCollection(t_varray()); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure varr_empty_equal_varr_notempty is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_is_null t_varray ; - begin - --Arrange - g_test_expected := anydata.convertCollection( t_varray() ); - g_test_actual := anydata.convertCollection( t_varray(1) ); - --Act - ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester.t_varray [ count = 1 ] was expected to equal: ut3_tester.t_varray [ count = 0 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Extra: 1]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure collection_join_by is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2 - order by rownum desc; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('TEST_DUMMY_OBJECT/ID'); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure collection_join_by_fail is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum * 2, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2 - order by rownum desc; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('TEST_DUMMY_OBJECT/ID'); - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 2 ] -%Diff: -%Rows: [ 3 differences ] -%PK 2 - Actual: Something 2 -%PK 2 - Actual: 2 -%PK 2 - Expected: Something 1 -%PK 2 - Expected: 1 -%PK 1 - Extra: 1Something 11 -%PK 4 - Missing: 4Something 22]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure collection_unordered is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - begin - --Arrange - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=3; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=3 - order by rownum desc; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure collection_unordered_fail is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2; - select test_dummy_object( rownum * 2, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2 - order by rownum desc; - - l_expected_message := q'[%Actual: ut3_tester.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester.test_dummy_object_list [ count = 2 ] -%Diff: -%Rows: [ 4 differences ] -%Extra: 1Something 11 -%Extra: 2Something 22 -%Missing: 4Something 22 -%Missing: 2Something 11]'; - - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure object_join_by is - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - - --Act - ut3.ut.expect(g_test_actual).to_equal(g_test_expected).join_by('TEST_DUMMY_OBJECT/ID'); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure object_unordered is - begin - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - - --Act - ut3.ut.expect(g_test_actual).to_equal(g_test_expected).unordered; - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure collection_to_contain is - l_actual test_dummy_object_list; - l_expected test_dummy_object_list; - begin - --Arrange - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=4; - select test_dummy_object( rownum, 'Something '||rownum, rownum) - bulk collect into l_expected - from dual connect by level <=2 - order by rownum desc; - --Act - ut3.ut.expect(anydata.convertCollection(l_actual)).to_contain(anydata.convertCollection(l_expected)); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure object_to_contain is - begin - --Arrange - g_test_expected := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - g_test_actual := anydata.convertObject( test_dummy_object(1, 'A', '0') ); - - --Act - ut3.ut.expect(g_test_actual).to_contain(g_test_expected); - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - -end; -/ \ No newline at end of file diff --git a/test/core/expectations/unary/test_expect_not_to_be_null.pkb b/test/core/expectations/unary/test_expect_not_to_be_null.pkb deleted file mode 100644 index 45ce4f697..000000000 --- a/test/core/expectations/unary/test_expect_not_to_be_null.pkb +++ /dev/null @@ -1,265 +0,0 @@ -create or replace package body test_expect_not_to_be_null -is - gc_object_name constant varchar2(30) := 't_not_to_be_null_test'; - gc_nested_table_name constant varchar2(30) := 'tt_not_to_be_null_test'; - gc_varray_name constant varchar2(30) := 'tv_not_to_be_null_test'; - - procedure cleanup_expectations is - begin - expectations.cleanup_expectations( ); - end; - - procedure create_types is - pragma autonomous_transaction; - begin - execute immediate 'create type ' || gc_object_name || ' is object (dummy number)'; - execute immediate 'create type ' || gc_nested_table_name || ' is table of number'; - execute immediate 'create type ' || gc_varray_name || ' is varray(1) of number'; - end; - - procedure drop_types is - pragma autonomous_transaction; - begin - execute immediate 'drop type ' || gc_object_name; - execute immediate 'drop type ' || gc_nested_table_name; - execute immediate 'drop type ' || gc_varray_name; - end; - - procedure blob_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'blob', 'to_blob(''abc'')' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure blob_0_length is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'blob', 'empty_blob()' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure boolean_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'boolean', 'true' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure clob_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'clob', 'to_clob(''abc'')' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - - procedure clob_0_length is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'clob', 'empty_clob()' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure date_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'date', 'sysdate' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure number_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'number', '1234' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure timestamp_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'timestamp', 'systimestamp' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure timestamp_with_ltz_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( - 'not_to_be_null', 'timestamp with local time zone', 'systimestamp' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure timestamp_with_tz_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'timestamp with time zone', - 'systimestamp' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure varchar2_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'varchar2(4000)', '''abc''' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure initialized_object is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'not_to_be_null', gc_object_name, gc_object_name || '(1)', 'object' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure initialized_nested_table is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'not_to_be_null', gc_nested_table_name, gc_nested_table_name || '()', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure initialized_varray is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'not_to_be_null', gc_varray_name, gc_varray_name || '()', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_blob is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'blob', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_boolean is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'boolean', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_clob is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'clob', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_date is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'date', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_number is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'number', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_timestamp is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'timestamp', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_timestamp_with_ltz is - begin - --Act - execute immediate expectations.unary_expectation_block( - 'not_to_be_null', 'timestamp with local time zone', 'null' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_timestamp_with_tz is - begin - --Act - execute immediate expectations.unary_expectation_block( - 'not_to_be_null', 'timestamp with time zone', 'null' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_varchar2 is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'varchar2(4000)', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure null_anydata is - begin - --Act - execute immediate expectations.unary_expectation_block( 'not_to_be_null', 'anydata', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure uninit_object_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'not_to_be_null', gc_object_name, 'null', 'object' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure uninit_nested_table_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'not_to_be_null', gc_nested_table_name, 'null', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure uninit_varray_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'not_to_be_null', gc_varray_name, 'null', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - -end test_expect_not_to_be_null; -/ diff --git a/test/core/expectations/unary/test_expect_to_be_not_null.pkb b/test/core/expectations/unary/test_expect_to_be_not_null.pkb deleted file mode 100644 index be6b3f2f8..000000000 --- a/test/core/expectations/unary/test_expect_to_be_not_null.pkb +++ /dev/null @@ -1,264 +0,0 @@ -create or replace package body test_expect_to_be_not_null -is - gc_object_name constant varchar2(30) := 't_to_be_not_null_test'; - gc_nested_table_name constant varchar2(30) := 'tt_to_be_not_null_test'; - gc_varray_name constant varchar2(30) := 'tv_to_be_not_null_test'; - - procedure cleanup_expectations is - begin - expectations.cleanup_expectations(); - end; - - procedure create_types is - pragma autonomous_transaction; - begin - execute immediate 'create type '||gc_object_name||' is object (dummy number)'; - execute immediate 'create type '||gc_nested_table_name||' is table of number'; - execute immediate 'create type '||gc_varray_name||' is varray(1) of number'; - end; - - procedure drop_types is - pragma autonomous_transaction; - begin - execute immediate 'drop type '||gc_object_name; - execute immediate 'drop type '||gc_nested_table_name; - execute immediate 'drop type '||gc_varray_name; - end; - - procedure blob_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'blob', 'to_blob(''abc'')'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure empty_blob is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'blob', 'empty_blob()'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure boolean_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'boolean', 'true'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure clob_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'clob', 'to_clob(''abc'')'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure empty_clob is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'clob', 'empty_clob()'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure date_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'date', 'sysdate'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure number_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'number', '1234'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure timestamp_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'timestamp', 'systimestamp'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure timestamp_with_ltz_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'timestamp with local time zone', 'systimestamp'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure timestamp_with_tz_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'timestamp with time zone', 'systimestamp'); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure varchar2_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'varchar2(4000)', '''abc'''); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure initialized_object is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_not_null', gc_object_name, gc_object_name||'(1)', 'object' - ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure initialized_nested_table is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_not_null', gc_nested_table_name, gc_nested_table_name||'()', 'collection' - ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure initialized_varray is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_not_null', gc_varray_name, gc_varray_name||'()', 'collection' - ); - --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); - end; - - procedure null_blob is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'blob', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - procedure null_boolean is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'boolean', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_clob is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'clob', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_date is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'date', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_number is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'number', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_timestamp is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'timestamp', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_timestamp_with_ltz is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'timestamp with local time zone', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_timestamp_with_tz is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'timestamp with time zone', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - - procedure null_varchar2 is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'varchar2(4000)', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - procedure null_anydata is - begin - --Act - execute immediate expectations.unary_expectation_block('to_be_not_null', 'anydata', 'null'); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - procedure uninit_object_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_not_null', gc_object_name, 'null', 'object' - ); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - procedure uninit_nested_table_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_not_null', gc_nested_table_name, 'null', 'collection' - ); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - - procedure uninit_varray_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_not_null', gc_varray_name, 'null', 'collection' - ); - --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); - end; - -end test_expect_to_be_not_null; -/ diff --git a/test/core/expectations/unary/test_expect_to_be_null.pkb b/test/core/expectations/unary/test_expect_to_be_null.pkb deleted file mode 100644 index 4179bfbe6..000000000 --- a/test/core/expectations/unary/test_expect_to_be_null.pkb +++ /dev/null @@ -1,260 +0,0 @@ -create or replace package body test_expect_to_be_null -is - gc_object_name constant varchar2(30) := 't_to_be_null_test'; - gc_nested_table_name constant varchar2(30) := 'tt_to_be_null_test'; - gc_varray_name constant varchar2(30) := 'tv_to_be_null_test'; - - procedure cleanup_expectations is - begin - expectations.cleanup_expectations( ); - end; - - procedure create_types is - pragma autonomous_transaction; - begin - execute immediate 'create type ' || gc_object_name || ' is object (dummy number)'; - execute immediate 'create type ' || gc_nested_table_name || ' is table of number'; - execute immediate 'create type ' || gc_varray_name || ' is varray(1) of number'; - end; - - procedure drop_types is - pragma autonomous_transaction; - begin - execute immediate 'drop type ' || gc_object_name; - execute immediate 'drop type ' || gc_nested_table_name; - execute immediate 'drop type ' || gc_varray_name; - end; - - procedure null_blob is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'blob', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_boolean is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'boolean', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_clob is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'clob', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_date is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'date', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_number is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'number', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_timestamp is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'timestamp', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_timestamp_with_ltz is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'timestamp with local time zone', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_timestamp_with_tz is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'timestamp with time zone', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_varchar2 is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'varchar2(4000)', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure null_anydata is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'anydata', 'null' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure uninit_object_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_null', gc_object_name, 'null', 'object' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure uninit_nested_table_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_null', gc_nested_table_name, 'null', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure uninit_varray_in_anydata is - begin - --Act - execute immediate expectations.unary_expectation_object_block( 'to_be_null', gc_varray_name, - 'null', 'collection' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); - end; - - procedure blob_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'blob', 'to_blob(''abc'')' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure empty_blob is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'blob', 'empty_blob()' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure boolean_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'boolean', 'true' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure clob_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'clob', 'to_clob(''abc'')' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure empty_clob is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'clob', 'empty_clob()' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure date_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'date', 'sysdate' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure number_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'number', '1234' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure timestamp_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'timestamp', 'systimestamp' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure timestamp_with_ltz_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( - 'to_be_null', 'timestamp with local time zone', 'systimestamp' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure timestamp_with_tz_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( - 'to_be_null', 'timestamp with time zone', 'systimestamp' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure varchar2_not_null is - begin - --Act - execute immediate expectations.unary_expectation_block( 'to_be_null', 'varchar2(4000)', '''abc''' ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure initialized_object is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_null', gc_object_name, gc_object_name || '(1)', 'object' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure initialized_nested_table is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_null', gc_nested_table_name, gc_nested_table_name || '()', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - - procedure initialized_varray is - begin - --Act - execute immediate expectations.unary_expectation_object_block( - 'to_be_null', gc_varray_name, gc_varray_name || '()', 'collection' - ); - --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); - end; - -end test_expect_to_be_null; -/ diff --git a/test/core/min_grant_user/test_min_grant_user.pkb b/test/core/min_grant_user/test_min_grant_user.pkb deleted file mode 100644 index 233cca67f..000000000 --- a/test/core/min_grant_user/test_min_grant_user.pkb +++ /dev/null @@ -1,71 +0,0 @@ -create or replace package body test_min_grant_user is - - procedure test_join_by_cursor is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_cursor_grants.run_test_join_by_cursor(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%execute join by test [% sec]' || - '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - - procedure test_equal_cursor is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_cursor_grants.run_test_equal_cursor(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%execute equal test [% sec]' || - '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - - procedure test_not_empty_cursor is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_cursor_grants.run_test_not_empty_cursor(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%execute not_empty test [% sec]' || - '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - - - procedure test_have_count_cursor is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_cursor_grants.run_test_have_count_cursor(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%execute have_count test [% sec]' || - '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - - procedure test_empty_cursor is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_cursor_grants.run_test_empty_cursor(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%execute empty test [% sec]' || - '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - - procedure test_equal_non_diff_sql is - l_results clob; - begin - execute immediate 'begin ut3$user#.test_cursor_grants.run_test_equal_non_diff_sql(); end;'; - l_results := core.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%execute test with non diff datatype [% sec]' || - '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - -end; -/ diff --git a/test/core/min_grant_user/test_min_grant_user.pks b/test/core/min_grant_user/test_min_grant_user.pks deleted file mode 100644 index daf34b35d..000000000 --- a/test/core/min_grant_user/test_min_grant_user.pks +++ /dev/null @@ -1,25 +0,0 @@ -create or replace package test_min_grant_user is - - --%suite(minimum grant user tests) - --%suitepath(utplsql.core) - - --%test(execute join by test) - procedure test_join_by_cursor; - - --%test(execute equal test) - procedure test_equal_cursor; - - --%test(execute not_empty test) - procedure test_not_empty_cursor; - - --%test(execute have_count test) - procedure test_have_count_cursor; - - --%test(execute empty test) - procedure test_empty_cursor; - - --%test(execute test with non diff datatype) - procedure test_equal_non_diff_sql; - -end; -/ diff --git a/test/core/reporters/test_coverage.pkb b/test/core/reporters/test_coverage.pkb deleted file mode 100644 index 2c67dc8c9..000000000 --- a/test/core/reporters/test_coverage.pkb +++ /dev/null @@ -1,262 +0,0 @@ -create or replace package body test_coverage is - - function get_mock_run_id return integer is - v_result integer; - begin - select nvl(min(runid),0) - 1 into v_result - from ut3.plsql_profiler_runs; - return v_result; - end; - - procedure create_dummy_coverage_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package UT3.DUMMY_COVERAGE is - procedure do_stuff; - end;]'; - execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE is - procedure do_stuff is - begin - if 1 = 2 then - dbms_output.put_line('should not get here'); - else - dbms_output.put_line('should get here'); - end if; - end; - end;]'; - end; - - procedure create_dummy_coverage_test is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE is - --%suite(dummy coverage test) - --%suitepath(coverage_testing) - - --%test - procedure test_do_stuff; - end;]'; - execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE is - procedure test_do_stuff is - begin - dummy_coverage.do_stuff; - end; - end;]'; - end; - - procedure create_dummy_coverage_test_1 is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package UT3.DUMMY_COVERAGE_1 is - procedure do_stuff; - end;]'; - execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE_1 is - procedure do_stuff is - begin - if 1 = 2 then - dbms_output.put_line('should not get here'); - else - dbms_output.put_line('should get here'); - end if; - end; - end;]'; - execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE_1 is - --%suite(dummy coverage test 1) - --%suitepath(coverage_testing) - - --%test - procedure test_do_stuff; - end;]'; - execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE_1 is - procedure test_do_stuff is - begin - dummy_coverage_1.do_stuff; - end; - end;]'; - end; - - procedure drop_dummy_coverage_test_1 is - pragma autonomous_transaction; - begin - execute immediate q'[drop package UT3.DUMMY_COVERAGE_1]'; - execute immediate q'[drop package UT3.TEST_DUMMY_COVERAGE_1]'; - end; - - - procedure mock_coverage_data(a_run_id integer) is - c_unit_id constant integer := 1; - begin - insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) - values(a_run_id, user, sysdate, 'unit testing utPLSQL'); - - insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) - values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE'); - - insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) - select a_run_id, c_unit_id, 4, 1, 1 from dual union all - select a_run_id, c_unit_id, 5, 0, 0 from dual union all - select a_run_id, c_unit_id, 7, 1, 1 from dual; - end; - - procedure create_dummy_coverage_pkg is - pragma autonomous_transaction; - begin - create_dummy_coverage_package(); - create_dummy_coverage_test(); - end; - - procedure setup_dummy_coverage is - pragma autonomous_transaction; - begin - g_run_id := get_mock_run_id(); - ut3.ut_coverage.mock_coverage_id(g_run_id, ut3.ut_coverage.gc_proftab_coverage); - mock_coverage_data(g_run_id); - commit; - end; - - procedure drop_dummy_coverage_pkg is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3.test_dummy_coverage]'; exception when others then null; end; - begin execute immediate q'[drop package ut3.dummy_coverage]'; exception when others then null; end; - end; - - procedure cleanup_dummy_coverage is - pragma autonomous_transaction; - begin - delete from ut3.plsql_profiler_data where runid = g_run_id; - delete from ut3.plsql_profiler_units where runid = g_run_id; - delete from ut3.plsql_profiler_runs where runid = g_run_id; - commit; - end; - - procedure coverage_for_object is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - begin - --Arrange - l_expected := '%%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_object_no_owner is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - begin - --Arrange - l_expected := '%%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_include_objects => ut3.ut_varchar2_list( 'dummy_coverage' ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_schema is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - begin - --Arrange - l_expected := ''; - l_expected := '%'||l_expected||'%'||l_expected||'%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_coverage_schemes => ut3.ut_varchar2_list( 'ut3' ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_file is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - l_file_path varchar2(100); - begin - --Arrange - l_file_path := lower('test/ut3.dummy_coverage.pkb'); - l_expected := '%%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_source_files => ut3.ut_varchar2_list( l_file_path ), - a_test_files => ut3.ut_varchar2_list( ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_tmp_data_refresh is - l_actual clob; - l_results ut3.ut_varchar2_list; - begin - --Arrange - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3:coverage_testing', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) - ) - ); - cleanup_dummy_coverage(); - drop_dummy_coverage_pkg(); - create_dummy_coverage_test_1; - - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3:coverage_testing', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) - ) - ); - - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_equal(to_clob(' - -')); - end; - -end; -/ diff --git a/test/core/reporters/test_coverage/test_cov_cobertura_reporter.pkb b/test/core/reporters/test_coverage/test_cov_cobertura_reporter.pkb deleted file mode 100644 index cabf64e90..000000000 --- a/test/core/reporters/test_coverage/test_cov_cobertura_reporter.pkb +++ /dev/null @@ -1,45 +0,0 @@ -create or replace package body test_cov_cobertura_reporter is - - procedure report_on_file is - l_results ut3.ut_varchar2_list; - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := - q'[ - - - -test/ut3.dummy_coverage.pkb - - - - - - - - - - - - -]'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_cobertura_reporter( ), - a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), - a_test_files => ut3.ut_varchar2_list( ) - ) - ); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - -end; -/ diff --git a/test/core/reporters/test_extended_coverage.pkb b/test/core/reporters/test_extended_coverage.pkb deleted file mode 100644 index a3719e503..000000000 --- a/test/core/reporters/test_extended_coverage.pkb +++ /dev/null @@ -1,188 +0,0 @@ -create or replace package body test_extended_coverage is - - g_run_id ut3.ut_coverage.tt_coverage_id_arr; - - function get_mock_block_run_id return integer is - v_result integer; - begin - select nvl(min(run_id),0) - 1 into v_result - from dbmspcc_runs; - return v_result; - end; - - function get_mock_proftab_run_id return integer is - v_result integer; - begin - select nvl(min(runid),0) - 1 into v_result - from ut3.plsql_profiler_runs; - return v_result; - end; - - procedure create_dummy_coverage_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG is - procedure do_stuff(i_input in number); - end;]'; - execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG is - procedure do_stuff(i_input in number) is - begin - if i_input = 2 then - dbms_output.put_line('should not get here'); - else - dbms_output.put_line('should get here'); - end if; - end; - end;]'; - end; - - procedure create_dummy_coverage_test is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE is - --%suite(dummy coverage test) - --%suitepath(coverage_testing) - - --%test - procedure test_do_stuff; - end;]'; - execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE is - procedure test_do_stuff is - begin - dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long.do_stuff(1); - ut.expect(1).to_equal(1); - end; - end;]'; - end; - - procedure mock_block_coverage_data(a_run_id integer) is - c_unit_id constant integer := 1; - begin - insert into dbmspcc_runs ( run_id, run_owner, run_timestamp, run_comment) - values(a_run_id, user, sysdate, 'unit testing utPLSQL'); - - insert into dbmspcc_units ( run_id, object_id, type, owner, name,last_ddl_time) - values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG',sysdate); - - insert into dbmspcc_blocks ( run_id, object_id, line,block,col,covered,not_feasible) - select a_run_id, c_unit_id,4,1,1,1,0 from dual union all - select a_run_id, c_unit_id,4,2,2,0,0 from dual union all - select a_run_id, c_unit_id,5,3,0,1,0 from dual union all - select a_run_id, c_unit_id,7,4,1,1,0 from dual; - end; - - procedure mock_profiler_coverage_data(a_run_id integer) is - c_unit_id constant integer := 1; - begin - insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) - values(a_run_id, user, sysdate, 'unit testing utPLSQL'); - - insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) - values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG'); - - insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) - select a_run_id, c_unit_id, 4, 1, 1 from dual union all - select a_run_id, c_unit_id, 5, 0, 0 from dual union all - select a_run_id, c_unit_id, 6, 1, 0 from dual union all - select a_run_id, c_unit_id, 7, 1, 1 from dual; - end; - - procedure setup_dummy_coverage is - pragma autonomous_transaction; - begin - create_dummy_coverage_package(); - create_dummy_coverage_test(); - g_run_id(ut3.ut_coverage.gc_block_coverage) := get_mock_block_run_id(); - g_run_id(ut3.ut_coverage.gc_proftab_coverage) := get_mock_proftab_run_id(); - ut3.ut_coverage.mock_coverage_id(g_run_id); - mock_block_coverage_data(g_run_id(ut3.ut_coverage.gc_block_coverage)); - mock_profiler_coverage_data(g_run_id(ut3.ut_coverage.gc_proftab_coverage)); - commit; - end; - - procedure cleanup_dummy_coverage is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3.test_dummy_coverage]'; exception when others then null; end; - begin execute immediate q'[drop package ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long]'; exception when others then null; end; - delete from dbmspcc_blocks where run_id = g_run_id(ut3.ut_coverage.gc_block_coverage); - delete from dbmspcc_units where run_id = g_run_id(ut3.ut_coverage.gc_block_coverage); - delete from dbmspcc_runs where run_id = g_run_id(ut3.ut_coverage.gc_block_coverage); - delete from ut3.plsql_profiler_data where runid = g_run_id(ut3.ut_coverage.gc_proftab_coverage); - delete from ut3.plsql_profiler_units where runid = g_run_id(ut3.ut_coverage.gc_proftab_coverage); - delete from ut3.plsql_profiler_runs where runid = g_run_id(ut3.ut_coverage.gc_proftab_coverage); - commit; - end; - - procedure coverage_for_object is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - begin - --Arrange - l_expected := '%%%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long' ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_schema is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - begin - --Arrange - l_expected := '%%%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_coverage_schemes => ut3.ut_varchar2_list( 'ut3' ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).to_be_like('%%%'); - end; - - procedure coverage_for_file is - l_expected clob; - l_actual clob; - l_results ut3.ut_varchar2_list; - l_file_path varchar2(250); - begin - --Arrange - l_file_path := lower('test/ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long.pkb'); - l_expected := '%%%'; - --Act - select * - bulk collect into l_results - from table( - ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', - a_reporter=> ut3.ut_coverage_sonar_reporter( ), - a_source_files => ut3.ut_varchar2_list( l_file_path ), - a_test_files => ut3.ut_varchar2_list( ) - ) - ); - --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - -end; -/ diff --git a/test/grant_ut3_owner_to_ut3_tester.sql b/test/grant_ut3_owner_to_ut3_tester.sql new file mode 100644 index 000000000..19424be1a --- /dev/null +++ b/test/grant_ut3_owner_to_ut3_tester.sql @@ -0,0 +1,35 @@ +set define off +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set plsql_optimize_level=0; + +set linesize 200 +set define on +set verify off + +prompt Empowering UT3_TESTER to UT3_OWNER objects + +begin + for i in ( select object_name from all_objects t + where t.object_type in ('PACKAGE','TYPE') + and owner = 'UT3' + and generated = 'N' + and lower(object_name) not like 'sys%') + loop + execute immediate 'grant execute on ut3."'||i.object_name||'" to UT3_TESTER'; + end loop; +end; +/ + +prompt Empowering UT3_TESTER to UT3_OWNER tables + +begin + for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_TYPE is NULL) + loop + execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER'; + end loop; +end; +/ + +exit; diff --git a/test/helpers/ut3user#.test_cursor_grants.pkb b/test/helpers/ut3user#.test_cursor_grants.pkb deleted file mode 100644 index 112d9559e..000000000 --- a/test/helpers/ut3user#.test_cursor_grants.pkb +++ /dev/null @@ -1,114 +0,0 @@ -create or replace package body ut3$user#.test_cursor_grants is - - procedure run_test_join_by_cursor is - begin - ut3.ut.run('test_cursor_grants.test_join_by_cursor'); - end; - - procedure run_test_equal_cursor is - begin - ut3.ut.run('test_cursor_grants.test_equal_cursor'); - end; - - procedure run_test_not_empty_cursor is - begin - ut3.ut.run('test_cursor_grants.test_not_empty_cursor'); - end; - - procedure run_test_have_count_cursor is - begin - ut3.ut.run('test_cursor_grants.test_have_count_cursor'); - end; - - procedure run_test_empty_cursor is - begin - ut3.ut.run('test_cursor_grants.test_empty_cursor'); - end; - - procedure run_test_equal_non_diff_sql is - begin - ut3.ut.run('test_cursor_grants.test_equal_non_diff_sql'); - end; - - procedure test_join_by_cursor is - l_actual SYS_REFCURSOR; - l_expected SYS_REFCURSOR; - begin - --Arrange - open l_actual for select owner, object_name,object_type from all_objects where owner = user - order by 1,2,3 asc; - open l_expected for select owner, object_name,object_type from all_objects where owner = user - order by 1,2,3 desc; - - --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_NAME,OBJECT_TYPE'); - - end; - - procedure test_equal_cursor is - l_actual SYS_REFCURSOR; - l_expected SYS_REFCURSOR; - l_list ut3_tester.test_dummy_object_list; - begin - --Arrange - open l_actual for select value(x) as item from table(l_list) x; - open l_expected for select value(x) as item from table(l_list) x; - - --Act - ut3.ut.expect(l_actual).to_equal(l_expected); - - end; - - procedure test_not_empty_cursor is - l_details_cur SYS_REFCURSOR; - l_expected ut3_tester.test_dummy_object_list; - begin - select ut3_tester.test_dummy_object( rn, 'Something '||rn, rn1) - bulk collect into l_expected - from (select rownum * case when mod(rownum,2) = 0 then -1 else 1 end rn, - rownum * case when mod(rownum,4) = 0 then -1 else 1 end rn1 - from dual connect by level <=10); - - --Arrange - open l_details_cur for - select value(x) as item from table(l_expected) x; - - --Act - ut3.ut.expect(l_details_cur).not_to_be_empty(); - end; - - procedure test_have_count_cursor is - l_expected SYS_REFCURSOR; - begin - --Arrange - open l_expected for - select value(x) as item from table(ut3_tester.test_dummy_object_list()) x; - - --Act - ut3.ut.expect(l_expected).to_have_count(0); - end; - - procedure test_empty_cursor is - l_expected SYS_REFCURSOR; - begin - open l_expected for - select value(x) as item from table(ut3_tester.test_dummy_object_list()) x; - --Act - ut3.ut.expect(l_expected).to_be_empty(); - end; - - procedure test_equal_non_diff_sql is - l_actual SYS_REFCURSOR; - l_expected SYS_REFCURSOR; - begin - open l_actual for - select to_clob('test1') as item from dual; - - open l_expected for - select to_clob('test1') as item from dual; - - ut3.ut.expect(l_actual).to_equal(l_expected); - end; - -end; -/ diff --git a/test/helpers/ut3user#.test_cursor_grants.pks b/test/helpers/ut3user#.test_cursor_grants.pks deleted file mode 100644 index cf829c09f..000000000 --- a/test/helpers/ut3user#.test_cursor_grants.pks +++ /dev/null @@ -1,30 +0,0 @@ -create or replace package ut3$user#.test_cursor_grants is - --%suite() - - procedure run_test_join_by_cursor; - procedure run_test_equal_cursor; - procedure run_test_not_empty_cursor; - procedure run_test_have_count_cursor; - procedure run_test_empty_cursor; - procedure run_test_equal_non_diff_sql; - - --%test(execute join by test) - procedure test_join_by_cursor; - - --%test(execute equal test) - procedure test_equal_cursor; - - --%test(execute not empty test) - procedure test_not_empty_cursor; - - --%test(execute have_count test) - procedure test_have_count_cursor; - - --%test(execute empty test) - procedure test_empty_cursor; - - --%test(execute test with non diff datatype) - procedure test_equal_non_diff_sql; - -end; -/ diff --git a/test/helpers/ut_example_tests.pkb b/test/helpers/ut_example_tests.pkb deleted file mode 100644 index d8afd592a..000000000 --- a/test/helpers/ut_example_tests.pkb +++ /dev/null @@ -1,24 +0,0 @@ -create or replace package body ut_example_tests -as - - procedure set_g_number_0 as - begin - g_number := 0; - end; - - procedure add_1_to_g_number as - begin - g_number := g_number + 1; - end; - - procedure failing_procedure as - begin - g_number := 1 / 0; - end; - - procedure ut_commit_test is - begin - commit; - end; -end; -/ diff --git a/test/helpers/ut_with_invalid_body.pkb b/test/helpers/ut_with_invalid_body.pkb deleted file mode 100644 index e265bf8de..000000000 --- a/test/helpers/ut_with_invalid_body.pkb +++ /dev/null @@ -1,4 +0,0 @@ -create or replace package body ut_with_invalid_body as - procedure test1; -end; -/ \ No newline at end of file diff --git a/test/helpers/ut_with_invalid_body.pks b/test/helpers/ut_with_invalid_body.pks deleted file mode 100644 index 702affb59..000000000 --- a/test/helpers/ut_with_invalid_body.pks +++ /dev/null @@ -1,4 +0,0 @@ -create or replace package ut_with_invalid_body as - procedure test1; -end; -/ \ No newline at end of file diff --git a/test/helpers/ut_without_body.pks b/test/helpers/ut_without_body.pks deleted file mode 100644 index 45a3c50d4..000000000 --- a/test/helpers/ut_without_body.pks +++ /dev/null @@ -1,4 +0,0 @@ -create or replace package ut_without_body as - procedure test1; -end; -/ \ No newline at end of file diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index 385cb46a4..01bd378fb 100755 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -6,19 +6,25 @@ git rev-parse && cd "$(git rev-parse --show-cdup)" cd test -time "$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_tests.sql +time "$SQLCLI" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA @grant_ut3_owner_to_ut3_tester.sql -cd .. +time "$SQLCLI" ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_helper.sql + +time "$SQLCLI" ${UT3_USER}/${UT3_USER_PASSWORD}@//${CONNECTION_STR} @install_ut3_user_tests.sql +time "$SQLCLI" ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@//${CONNECTION_STR} @install_ut3_tester_tests.sql + +cd .. -time utPLSQL-cli/bin/utplsql run ${UT3_TESTER}/${UT3_TESTER_PASSWORD}@${CONNECTION_STR} \ +time utPLSQL-cli/bin/utplsql run ${UT3_TESTER_HELPER}/${UT3_TESTER_HELPER_PASSWORD}@${CONNECTION_STR} \ -source_path=source -owner=ut3 \ +-p='ut3_tester,ut3$user#' \ -test_path=test -c \ --f=ut_coverage_sonar_reporter -o=coverage.xml \ --f=ut_coverage_html_reporter -o=coverage.html \ --f=ut_coveralls_reporter -o=coverage.json \ --f=ut_sonar_test_reporter -o=test_results.xml \ --f=ut_junit_reporter -o=junit_test_results.xml \ --f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ --f=ut_documentation_reporter -o=test_results.log -s \ --scc +-f=ut_coverage_sonar_reporter -o=coverage.xml \ +-f=ut_coverage_cobertura_reporter -o=cobertura.xml \ +-f=ut_coverage_html_reporter -o=coverage.html \ +-f=ut_coveralls_reporter -o=coverage.json \ +-f=ut_sonar_test_reporter -o=test_results.xml \ +-f=ut_junit_reporter -o=junit_test_results.xml \ +-f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ +-f=ut_documentation_reporter -o=test_results.log -s diff --git a/test/install_ut3_tester_helper.sql b/test/install_ut3_tester_helper.sql new file mode 100644 index 000000000..c6244fd39 --- /dev/null +++ b/test/install_ut3_tester_helper.sql @@ -0,0 +1,63 @@ +set define off +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set plsql_optimize_level=0; +--Install ut3_tester_helper +@@ut3_tester_helper/test_dummy_object.tps +@@ut3_tester_helper/other_dummy_object.tps +@@ut3_tester_helper/test_dummy_object_list.tps +@@ut3_tester_helper/test_tab_varchar2.tps +@@ut3_tester_helper/test_tab_varray.tps +@@ut3_tester_helper/test_dummy_number.tps +@@ut3_tester_helper/ut_test_table.sql +@@ut3_tester_helper/test_event_object.tps +@@ut3_tester_helper/test_event_list.tps + +@@ut3_tester_helper/main_helper.pks +@@ut3_tester_helper/run_helper.pks +@@ut3_tester_helper/coverage_helper.pks +@@ut3_tester_helper/expectations_helper.pks +@@ut3_tester_helper/ut_example_tests.pks + +@@ut3_tester_helper/main_helper.pkb +@@ut3_tester_helper/run_helper.pkb +@@ut3_tester_helper/coverage_helper.pkb +@@ut3_tester_helper/expectations_helper.pkb +@@ut3_tester_helper/ut_example_tests.pkb + +set linesize 200 +set define on +set verify off +column text format a100 +column error_count noprint new_value error_count + +prompt Validating installation + +set heading on +select type, name, sequence, line, position, text, count(1) over() error_count + from all_errors + where owner = USER + and name not like 'BIN$%' --not recycled + and name != 'UT_WITH_INVALID_BODY' + -- errors only. ignore warnings + and attribute = 'ERROR' + order by name, type, sequence +/ + +begin + if to_number('&&error_count') > 0 then + raise_application_error(-20000, 'Not all sources were successfully installed.'); + else + dbms_output.put_line('Installation completed successfully'); + end if; + + for i in ( select object_name from user_objects t where t.object_type in ('PACKAGE','TYPE')) + loop + execute immediate 'grant execute on '||i.object_name||' to PUBLIC'; + end loop; + +end; +/ + +exit; diff --git a/test/install_ut3_tester_tests.sql b/test/install_ut3_tester_tests.sql new file mode 100644 index 000000000..6b3a5356c --- /dev/null +++ b/test/install_ut3_tester_tests.sql @@ -0,0 +1,72 @@ +set define off +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set plsql_optimize_level=0; + +@@common_helper/utplsql.pks +@@common_helper/utplsql.pkb + +--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/test_ut_utils.pks +@@ut3_tester/core/test_ut_test.pks +@@ut3_tester/core/test_ut_suite.pks +@@ut3_tester/core/test_ut_executable.pks +@@ut3_tester/core/test_suite_manager.pks +@@ut3_tester/core/test_file_mapper.pks +@@ut3_tester/core/test_output_buffer.pks +@@ut3_tester/core/test_suite_builder.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 +@@ut3_tester/core/test_ut_utils.pkb +@@ut3_tester/core/test_ut_test.pkb +@@ut3_tester/core/test_ut_suite.pkb +@@ut3_tester/core/test_ut_executable.pkb +@@ut3_tester/core/test_suite_manager.pkb +@@ut3_tester/core/test_file_mapper.pkb +@@ut3_tester/core/test_output_buffer.pkb +@@ut3_tester/core/test_suite_builder.pkb + + + +set linesize 200 +set define on +set verify off +column text format a100 +column error_count noprint new_value error_count + +prompt Validating installation + +set heading on +select type, name, sequence, line, position, text, count(1) over() error_count + from all_errors + where owner = USER + and name not like 'BIN$%' --not recycled + and name != 'UT_WITH_INVALID_BODY' + -- errors only. ignore warnings + and attribute = 'ERROR' + order by name, type, sequence +/ + +begin + if to_number('&&error_count') > 0 then + raise_application_error(-20000, 'Not all sources were successfully installed.'); + else + dbms_output.put_line('Installation completed successfully'); + end if; +end; +/ + +exit; diff --git a/test/install_ut3_user_tests.sql b/test/install_ut3_user_tests.sql new file mode 100644 index 000000000..b7361e4aa --- /dev/null +++ b/test/install_ut3_user_tests.sql @@ -0,0 +1,128 @@ +set define off +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set plsql_optimize_level=0; + +@@common_helper/utplsql.pks +@@common_helper/utplsql.pkb + +prompt Install user tests +@@ut3_user/test_user.pks +@@ut3_user/expectations/unary/test_expect_not_to_be_null.pks +@@ut3_user/expectations/unary/test_expect_to_be_null.pks +@@ut3_user/expectations/unary/test_expect_to_be_empty.pks +@@ut3_user/expectations/unary/test_expect_to_have_count.pks +@@ut3_user/expectations/unary/test_expect_to_be_true_false.pks +@@ut3_user/expectations/unary/test_expect_to_be_not_null.pks +@@ut3_user/expectations/binary/test_equal.pks +@@ut3_user/expectations/binary/test_expect_to_be_less_than.pks +@@ut3_user/expectations/binary/test_be_less_or_equal.pks +@@ut3_user/expectations/binary/test_be_greater_or_equal.pks +@@ut3_user/expectations/binary/test_be_greater_than.pks +@@ut3_user/expectations/test_matchers.pks +@@ut3_user/expectations/test_expectation_anydata.pks +@@ut3_user/expectations/test_expectations_cursor.pks +set define on +@@install_above_12_1.sql 'ut3_user/expectations/test_expectations_json.pks' +set define off +@@ut3_user/api/test_ut_runner.pks +@@ut3_user/api/test_ut_run.pks +@@ut3_user/reporters.pks +@@ut3_user/reporters/test_tfs_junit_reporter.pks +@@ut3_user/reporters/test_teamcity_reporter.pks +@@ut3_user/reporters/test_sonar_test_reporter.pks +@@ut3_user/reporters/test_junit_reporter.pks +@@ut3_user/reporters/test_documentation_reporter.pks +@@ut3_user/reporters/test_debug_reporter.pks +@@ut3_user/reporters/test_realtime_reporter.pks +@@ut3_user/reporters/test_coverage.pks +set define on +@@install_above_12_1.sql 'ut3_user/reporters/test_extended_coverage.pks' +@@install_above_12_1.sql 'ut3_user/reporters/test_coverage/test_html_extended_reporter.pks' +set define off +@@ut3_user/reporters/test_coverage/test_coveralls_reporter.pks +@@ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks +@@ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks +set define on +@@install_below_12_2.sql 'ut3_user/reporters/test_proftab_coverage.pks' +@@install_below_12_2.sql 'ut3_user/reporters/test_coverage/test_html_proftab_reporter.pks' +set define off + +@@ut3_user/test_user.pkb +@@ut3_user/expectations/unary/test_expect_not_to_be_null.pkb +@@ut3_user/expectations/unary/test_expect_to_be_null.pkb +@@ut3_user/expectations/unary/test_expect_to_be_empty.pkb +@@ut3_user/expectations/unary/test_expect_to_have_count.pkb +@@ut3_user/expectations/unary/test_expect_to_be_true_false.pkb +@@ut3_user/expectations/unary/test_expect_to_be_not_null.pkb +@@ut3_user/expectations/binary/test_equal.pkb +@@ut3_user/expectations/binary/test_expect_to_be_less_than.pkb +@@ut3_user/expectations/binary/test_be_less_or_equal.pkb +@@ut3_user/expectations/binary/test_be_greater_or_equal.pkb +@@ut3_user/expectations/binary/test_be_greater_than.pkb +@@ut3_user/expectations/test_matchers.pkb +@@ut3_user/expectations/test_expectation_anydata.pkb +@@ut3_user/expectations/test_expectations_cursor.pkb +set define on +@@install_above_12_1.sql 'ut3_user/expectations/test_expectations_json.pkb' +set define off +@@ut3_user/api/test_ut_runner.pkb +@@ut3_user/api/test_ut_run.pkb +@@ut3_user/reporters.pkb +@@ut3_user/reporters/test_tfs_junit_reporter.pkb +@@ut3_user/reporters/test_teamcity_reporter.pkb +@@ut3_user/reporters/test_sonar_test_reporter.pkb +@@ut3_user/reporters/test_junit_reporter.pkb +@@ut3_user/reporters/test_documentation_reporter.pkb +@@ut3_user/reporters/test_debug_reporter.pkb +@@ut3_user/reporters/test_realtime_reporter.pkb +@@ut3_user/reporters/test_coverage.pkb +set define on +@@install_above_12_1.sql 'ut3_user/reporters/test_extended_coverage.pkb' +@@install_above_12_1.sql 'ut3_user/reporters/test_coverage/test_html_extended_reporter.pkb' +set define off +@@ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb +@@ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb +@@ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb +set define on +@@install_below_12_2.sql 'ut3_user/reporters/test_proftab_coverage.pkb' +@@install_below_12_2.sql 'ut3_user/reporters/test_coverage/test_html_proftab_reporter.pkb' +set define off + + +set linesize 200 +set define on +set verify off +column text format a100 +column error_count noprint new_value error_count + +prompt Validating installation + +set heading on +select type, name, sequence, line, position, text, count(1) over() error_count + from all_errors + where owner = USER + and name not like 'BIN$%' --not recycled + and name != 'UT_WITH_INVALID_BODY' + -- errors only. ignore warnings + and attribute = 'ERROR' + order by name, type, sequence +/ + +begin + if to_number('&&error_count') > 0 then + raise_application_error(-20000, 'Not all sources were successfully installed.'); + else + dbms_output.put_line('Installation completed successfully'); + end if; + + for i in ( select object_name from user_objects t where t.object_type = 'PACKAGE') + loop + execute immediate 'grant execute on '||i.object_name||' to UT3_TESTER'; + end loop; + +end; +/ + +exit; diff --git a/test/ut3_tester/core.pkb b/test/ut3_tester/core.pkb new file mode 100644 index 000000000..505388a8f --- /dev/null +++ b/test/ut3_tester/core.pkb @@ -0,0 +1,11 @@ +create or replace package body core is + + procedure global_setup is + begin + ut3.ut_coverage.set_develop_mode(true); + --improve performance of test execution by disabling all compiler optimizations + ut3_tester_helper.main_helper.execute_autonomous('ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0'); + end; + +end; +/ diff --git a/test/ut3_tester/core.pks b/test/ut3_tester/core.pks new file mode 100644 index 000000000..4565c47f3 --- /dev/null +++ b/test/ut3_tester/core.pks @@ -0,0 +1,10 @@ +create or replace package core is + + --%suite + --%suitepath(utplsql.ut3_tester) + + --%beforeall + procedure global_setup; + +end; +/ diff --git a/test/core/annotations/test_annot_throws_exception.pkb b/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb similarity index 100% rename from test/core/annotations/test_annot_throws_exception.pkb rename to test/ut3_tester/core/annotations/test_annot_throws_exception.pkb diff --git a/test/core/annotations/test_annot_throws_exception.pks b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks similarity index 98% rename from test/core/annotations/test_annot_throws_exception.pks rename to test/ut3_tester/core/annotations/test_annot_throws_exception.pks index 54e814b55..ce2e6ba7a 100644 --- a/test/core/annotations/test_annot_throws_exception.pks +++ b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks @@ -1,7 +1,7 @@ create or replace package test_annot_throws_exception is --%suite(annotations - throws) - --%suitepath(utplsql.core.annotations) + --%suitepath(utplsql.ut3_tester.core.annotations) --%beforeall procedure recollect_tests_results; diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pkb b/test/ut3_tester/core/annotations/test_annotation_manager.pkb new file mode 100644 index 000000000..e64adc861 --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annotation_manager.pkb @@ -0,0 +1,413 @@ +create or replace package body test_annotation_manager is + + procedure disable_ddl_trigger is + pragma autonomous_transaction; + begin + execute immediate 'alter trigger ut3.ut_trigger_annotation_parsing disable'; + execute immediate 'begin ut3.ut_trigger_check.is_alive(); end;'; + end; + + procedure enable_ddl_trigger is + pragma autonomous_transaction; + begin + execute immediate 'alter trigger ut3.ut_trigger_annotation_parsing enable'; + end; + + procedure create_dummy_package is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package dummy_package as + procedure some_dummy_procedure; + end;]'; + end; + + procedure drop_dummy_package is + pragma autonomous_transaction; + begin + execute immediate q'[drop package dummy_package]'; + exception + when others then + null; + end; + + procedure recompile_dummy_package is + pragma autonomous_transaction; + begin + execute immediate q'[alter package dummy_package compile]'; + end; + + procedure create_dummy_test_package is + pragma autonomous_transaction; + begin + execute immediate q'[ + /* + * Some multiline comments before package spec + create or replace package dummy_test_package dummy comment to prove that we pick the right piece of code + */ + -- create or replace package dummy_test_package dummy comment to prove that we pick the right piece of code + --Some single-line comment before package spec + create or replace package dummy_test_package as + --%suite(dummy_test_suite) + --%rollback(manual) + + --create or replace package dummy_test_package dummy comment to prove that we pick the right piece of code + + --%test(dummy_test) + --%beforetest(some_procedure) + procedure some_dummy_test_procedure; + end;]'; + execute immediate q'[grant execute on dummy_test_package to public]'; + end; + + procedure modify_dummy_test_package is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package dummy_test_package as + --%suite(dummy_test_suite) + + --%test(dummy_test) + procedure some_dummy_test_procedure; + end;]'; + end; + + procedure drop_dummy_test_package is + pragma autonomous_transaction; + begin + execute immediate q'[drop package dummy_test_package]'; + exception + when others then + null; + end; + + procedure recompile_dummy_test_package is + pragma autonomous_transaction; + begin + execute immediate q'[alter package dummy_test_package compile]'; + end; + + procedure create_parse_proc_as_ut3$user# is + begin + ut3_tester_helper.main_helper.create_parse_proc_as_ut3$user#(); + end; + + procedure parse_dummy_test_as_ut3$user# is + begin + ut3_tester_helper.main_helper.parse_dummy_test_as_ut3$user#(); + end; + + procedure drop_parse_proc_as_ut3$user# is + begin + ut3_tester_helper.main_helper.drop_parse_proc_as_ut3$user#(); + exception + when others then + null; + end; + + procedure cleanup_annotation_cache is + begin + ut3_tester_helper.main_helper.cleanup_annotation_cache(); + end; + + procedure assert_dummy_package(a_start_date date) is + l_actual_cache_id integer; + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + select max(cache_id) + into l_actual_cache_id + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE' + and parse_time >= a_start_date; + ut.expect(l_actual_cache_id).to_be_not_null; + + open l_actual for + select annotation_position, annotation_name, annotation_text, subobject_name + from ut3.ut_annotation_cache where cache_id = l_actual_cache_id + order by annotation_position; + + ut.expect(l_actual).to_be_empty(); + end; + + procedure assert_dummy_test_package(a_start_date date) is + l_actual_cache_id integer; + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + select max(cache_id) + into l_actual_cache_id + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' + and parse_time >= a_start_date; + ut.expect(l_actual_cache_id).to_be_not_null; + + open l_actual for + select annotation_position, annotation_name, annotation_text, subobject_name + from ut3.ut_annotation_cache where cache_id = l_actual_cache_id + order by annotation_position; + + open l_expected for + select 2 as annotation_position, 'suite' as annotation_name, + 'dummy_test_suite' as annotation_text, '' as subobject_name + from dual union all + select 3, 'rollback' , 'manual', '' as subobject_name + from dual union all + select 7, 'test' , 'dummy_test', 'some_dummy_test_procedure' as subobject_name + from dual union all + select 8, 'beforetest' , 'some_procedure', 'some_dummy_test_procedure' as subobject_name + from dual; + + ut.expect(l_actual).to_equal(l_expected); + end; + + + procedure trg_skip_existing_package is + l_actual_cache_id integer; + begin + --Arrange + disable_ddl_trigger(); + create_dummy_test_package(); + --Act + enable_ddl_trigger(); + --Assert + select max(cache_id) + into l_actual_cache_id + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; + + ut.expect(l_actual_cache_id).to_be_null; + end; + + --%test(Adds existing package to cache when package recompiled) + procedure trg_add_existing_on_compile is + l_start_date date; + begin + --Arrange + disable_ddl_trigger(); + create_dummy_test_package(); + --Act + enable_ddl_trigger(); + l_start_date := sysdate; + recompile_dummy_test_package(); + --Assert + assert_dummy_test_package(l_start_date); + end; + + --%test(Adds existing package to cache when schema cache refreshed) + procedure trg_add_existing_on_refresh is + l_start_date date; + begin + --Arrange + disable_ddl_trigger(); + create_dummy_test_package(); + create_dummy_package(); + --Act + enable_ddl_trigger(); + l_start_date := sysdate; + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + --Assert + assert_dummy_test_package(l_start_date); + assert_dummy_package(l_start_date); + end; + + procedure trg_not_add_new_package is + l_actual sys_refcursor; + begin + --Act + create_dummy_package(); + --Assert + open l_actual for + select * + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE'; + + ut.expect(l_actual).to_be_empty(); + end; + + procedure trg_add_new_test_package is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_start_date date; + begin + --Arrange + l_start_date := sysdate; + --Act + create_dummy_test_package(); + --Assert + assert_dummy_test_package(l_start_date); + end; + + --%test(Removes annotations from cache when object was removed and user can't see whole schema) + procedure trg_no_data_for_dropped_object is + l_actual sys_refcursor; + begin + drop_dummy_test_package(); + --Assert + open l_actual for + select * + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') + and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; + + ut.expect(l_actual).to_be_empty(); + + end; + + --%test(Updates annotation cache when package recompiled) + procedure trg_update_modified_package is + begin + null; + end; + + procedure add_new_package is + l_actual_cache_id integer; + l_actual sys_refcursor; + l_start_date date; + begin + --Act + l_start_date := sysdate; + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + --Assert + select max(cache_id) + into l_actual_cache_id + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE' + and parse_time >= l_start_date; + + ut.expect(l_actual_cache_id).to_be_not_null; + + open l_actual for + select * + from ut3.ut_annotation_cache + where cache_id = l_actual_cache_id; + + ut.expect(l_actual).to_be_empty(); + + end; + + procedure update_modified_package is + l_actual integer; + l_start_date date; + begin + --Arrange + l_start_date := sysdate; + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + recompile_dummy_package(); + l_start_date := sysdate; + $if dbms_db_version.version >= 18 $then + dbms_session.sleep(1); + $else + dbms_lock.sleep(1); + $end + + --Act + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + --Assert + assert_dummy_package(l_start_date); + end; + + + procedure add_new_test_package is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_start_date date; + begin + --Arrange + l_start_date := sysdate; + --Act + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + --Assert + assert_dummy_test_package(l_start_date); + end; + + + procedure update_modified_test_package is + l_actual_cache_id integer; + l_actual sys_refcursor; + l_expected sys_refcursor; + l_start_date date; + begin + --Arrange + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + l_start_date := sysdate; + modify_dummy_test_package(); + --Act + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + --Assert + select max(cache_id) + into l_actual_cache_id + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE' + and parse_time >= l_start_date; + + ut.expect(l_actual_cache_id).to_be_not_null; + + open l_actual for + select annotation_position, annotation_name, annotation_text, subobject_name + from ut3.ut_annotation_cache where cache_id = l_actual_cache_id + order by annotation_position; + + open l_expected for + select 2 as annotation_position, 'suite' as annotation_name, + 'dummy_test_suite' as annotation_text, to_char(null) as subobject_name + from dual union all + select 4, 'test' , 'dummy_test', 'some_dummy_test_procedure' as subobject_name + from dual; + + ut.expect(l_actual).to_equal(l_expected); + end; + + + procedure keep_dropped_data_in_cache is + l_actual sys_refcursor; + l_expected sys_refcursor; + l_start_date date; + begin + parse_dummy_test_as_ut3$user#(); + l_start_date := sysdate; + drop_dummy_test_package(); + --Act + parse_dummy_test_as_ut3$user#(); + --Assert + assert_dummy_test_package(l_start_date); + end; + + procedure no_data_for_dropped_object is + l_actual sys_refcursor; + begin + --Arrange + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + drop_dummy_test_package(); + --Act + open l_actual for + select * from table(ut3.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE')) + where object_name = 'DUMMY_TEST_PACKAGE'; + --Assert + ut.expect(l_actual).to_be_empty(); + end; + + procedure cleanup_dropped_data_in_cache is + l_cache_count integer; + l_actual sys_refcursor; + l_expected sys_refcursor; + l_start_date date; + begin + --Arrange + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + l_start_date := sysdate; + drop_dummy_test_package(); + --Act + ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + --Assert + select count(1) + into l_cache_count + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') + and object_type = 'PACKAGE' + and object_name = 'DUMMY_TEST_PACKAGE'; + + ut.expect(l_cache_count).to_equal(0); + + end; + +end test_annotation_manager; +/ diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pks b/test/ut3_tester/core/annotations/test_annotation_manager.pks new file mode 100644 index 000000000..fd5bc3410 --- /dev/null +++ b/test/ut3_tester/core/annotations/test_annotation_manager.pks @@ -0,0 +1,90 @@ +create or replace package test_annotation_manager is + + --%suite(ut_annotation_manager) + --%suitepath(utplsql.ut3_tester.core.annotations) + + --%aftereach + procedure cleanup_annotation_cache; + + procedure disable_ddl_trigger; + + procedure enable_ddl_trigger; + + procedure create_dummy_package; + + procedure drop_dummy_package; + + procedure create_dummy_test_package; + + procedure create_parse_proc_as_ut3$user#; + + procedure drop_parse_proc_as_ut3$user#; + + procedure drop_dummy_test_package; + + --%context(With DDL trigger enabled) + + --%aftereach(drop_dummy_test_package,drop_dummy_package) + + --%test(Does not detect unit test packages created before enabling trigger) + procedure trg_skip_existing_package; + + --%test(Adds existing package to cache when package recompiled) + procedure trg_add_existing_on_compile; + + --%test(Adds existing package to cache when schema cache refreshed) + procedure trg_add_existing_on_refresh; + + --%test(Doesn't add package to annotation cache info when it is not unit test package) + procedure trg_not_add_new_package; + + --%test(Populates annotation cache when package created) + procedure trg_add_new_test_package; + + --%test(Removes annotations from cache when object was removed and user can't see whole schema) + --%beforetest(create_dummy_test_package) + procedure trg_no_data_for_dropped_object; + + --%test(Updates annotation cache when package recompiled) + procedure trg_update_modified_package; + + --%endcontext + + --%context(Without DDL trigger enabled) + + --%beforeall(disable_ddl_trigger) + + --%afterall(enable_ddl_trigger) + + --%beforeeach(create_dummy_package) + --%aftereach(drop_dummy_package) + + --%test(Adds new package to annotation cache info when it is not unit test package) + procedure add_new_package; + + --%test(Updates annotation cache info for modified package) + procedure update_modified_package; + + --%test(Adds annotations to cache for unit test package) + --%beforetest(create_dummy_test_package) + --%aftertest(drop_dummy_test_package) + procedure add_new_test_package; + + --%test(Updates annotations in cache for modified test package) + procedure update_modified_test_package; + + --%test(Keeps annotations in cache when object was removed but user can't see whole schema) + --%beforetest(create_dummy_test_package,create_parse_proc_as_ut3$user#) + --%aftertest(drop_parse_proc_as_ut3$user#) + procedure keep_dropped_data_in_cache; + + --%test(Does not return data for dropped object) + procedure no_data_for_dropped_object; + + --%test(Remove object from cache when object dropped and user can see whole schema) + procedure cleanup_dropped_data_in_cache; + + --%endcontext + +end test_annotation_manager; +/ diff --git a/test/core/annotations/test_annotation_parser.pkb b/test/ut3_tester/core/annotations/test_annotation_parser.pkb similarity index 99% rename from test/core/annotations/test_annotation_parser.pkb rename to test/ut3_tester/core/annotations/test_annotation_parser.pkb index 5345e3a50..c4c90c046 100644 --- a/test/core/annotations/test_annotation_parser.pkb +++ b/test/ut3_tester/core/annotations/test_annotation_parser.pkb @@ -305,7 +305,7 @@ v58yvbLAXLi9gYHwoIvAgccti+Cmpg0DKLY= -- %some_annotation_like_text '; --Act - l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source); + l_actual := ut3.ut_annotation_parser.parse_object_annotations(l_source,'PACKAGE'); --Assert ut.expect(anydata.convertCollection(l_actual)).to_be_empty(); end; diff --git a/test/core/annotations/test_annotation_parser.pks b/test/ut3_tester/core/annotations/test_annotation_parser.pks similarity index 96% rename from test/core/annotations/test_annotation_parser.pks rename to test/ut3_tester/core/annotations/test_annotation_parser.pks index 19b98ae63..a4fe3ed70 100644 --- a/test/core/annotations/test_annotation_parser.pks +++ b/test/ut3_tester/core/annotations/test_annotation_parser.pks @@ -1,7 +1,7 @@ create or replace package test_annotation_parser is --%suite(ut_annotation_parser) - --%suitepath(utplsql.core.annotations) + --%suitepath(utplsql.ut3_tester.core.annotations) --%test(Treats procedure level annotations as package level, if mixed with comments) procedure test_proc_comments; diff --git a/test/core/annotations/test_before_after_annotations.pkb b/test/ut3_tester/core/annotations/test_before_after_annotations.pkb similarity index 97% rename from test/core/annotations/test_before_after_annotations.pkb rename to test/ut3_tester/core/annotations/test_before_after_annotations.pkb index 0aa9f5c39..e2f34e847 100644 --- a/test/core/annotations/test_before_after_annotations.pkb +++ b/test/ut3_tester/core/annotations/test_before_after_annotations.pkb @@ -200,12 +200,12 @@ create or replace package body test_before_after_annotations is execute immediate l_test_package_body; --Execute the tests and collect the results - select * bulk collect into l_test_results from table(ut3.ut.run(('dummy_before_after_test'))); + select * bulk collect into l_test_results from table(ut3.ut.run(('ut3_tester.dummy_before_after_test'))); execute immediate 'drop package dummy_before_after_test'; execute immediate 'drop package shared_test_package'; - g_tests_results := ut3.ut_utils.table_to_clob(l_test_results); + g_tests_results := ut3_tester_helper.main_helper.table_to_clob(l_test_results); end; procedure beforetest_local_procedure is @@ -282,8 +282,7 @@ create or replace package body test_before_after_annotations is ); ut.expect(g_tests_results).to_match( '1\) beforetest_missing_procedure\s+' || - 'Call params for beforetest are not valid: procedure does not exist ' || - 'UT3_TESTER.DUMMY_BEFORE_AFTER_TEST.NON_EXISTENT_PROCEDURE' + 'Call params for beforetest are not valid: procedure UT3_TESTER\.DUMMY_BEFORE_AFTER_TEST\.NON_EXISTENT_PROCEDURE does not exist\.' ,'m' ); end; diff --git a/test/core/annotations/test_before_after_annotations.pks b/test/ut3_tester/core/annotations/test_before_after_annotations.pks similarity index 96% rename from test/core/annotations/test_before_after_annotations.pks rename to test/ut3_tester/core/annotations/test_before_after_annotations.pks index a4ce52727..062efff48 100644 --- a/test/core/annotations/test_before_after_annotations.pks +++ b/test/ut3_tester/core/annotations/test_before_after_annotations.pks @@ -1,7 +1,7 @@ create or replace package test_before_after_annotations is --%suite(annotations - beforetest and aftertest) - --%suitepath(utplsql.core.annotations) + --%suitepath(utplsql.ut3_tester.core.annotations) subtype t_procedure_name is varchar2(250) not null; type t_procedures is table of t_procedure_name; diff --git a/test/core/expectations/test_expectation_processor.pkb b/test/ut3_tester/core/expectations/test_expectation_processor.pkb similarity index 100% rename from test/core/expectations/test_expectation_processor.pkb rename to test/ut3_tester/core/expectations/test_expectation_processor.pkb diff --git a/test/core/expectations/test_expectation_processor.pks b/test/ut3_tester/core/expectations/test_expectation_processor.pks similarity index 88% rename from test/core/expectations/test_expectation_processor.pks rename to test/ut3_tester/core/expectations/test_expectation_processor.pks index ecde48153..5b63c8938 100644 --- a/test/core/expectations/test_expectation_processor.pks +++ b/test/ut3_tester/core/expectations/test_expectation_processor.pks @@ -1,7 +1,7 @@ create or replace package test_expectation_processor is --%suite(expectation_processor) - --%suitepath(utplsql.core.expectations) + --%suitepath(utplsql.ut3_tester.core.expectations) --%context(who_called_expectation) diff --git a/test/core/test_file_mapper.pkb b/test/ut3_tester/core/test_file_mapper.pkb similarity index 83% rename from test/core/test_file_mapper.pkb rename to test/ut3_tester/core/test_file_mapper.pkb index 34b38f108..3813c9450 100644 --- a/test/core/test_file_mapper.pkb +++ b/test/ut3_tester/core/test_file_mapper.pkb @@ -6,8 +6,8 @@ create or replace package body test_file_mapper is begin --Arrange l_expected := ut3.ut_file_mappings( - ut3.ut_file_mapping('C:\tests\helpers\core.pkb',USER,'CORE','PACKAGE BODY'), - ut3.ut_file_mapping('tests/helpers/test_file_mapper.pkb',USER,'TEST_FILE_MAPPER','PACKAGE BODY') + ut3.ut_file_mapping('C:\tests\helpers\core.pkb',sys_context('USERENV', 'CURRENT_USER'),'CORE','PACKAGE BODY'), + ut3.ut_file_mapping('tests/helpers/test_file_mapper.pkb',sys_context('USERENV', 'CURRENT_USER'),'TEST_FILE_MAPPER','PACKAGE BODY') ); --Act l_actual := ut3.ut_file_mapper.build_file_mappings( diff --git a/test/core/test_file_mapper.pks b/test/ut3_tester/core/test_file_mapper.pks similarity index 88% rename from test/core/test_file_mapper.pks rename to test/ut3_tester/core/test_file_mapper.pks index f64343637..b2443766c 100644 --- a/test/core/test_file_mapper.pks +++ b/test/ut3_tester/core/test_file_mapper.pks @@ -1,7 +1,7 @@ create or replace package test_file_mapper is --%suite(file_mapper) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) --%test(Maps file paths into database objects using default mappings) procedure default_mappings; diff --git a/test/core/test_output_buffer.pkb b/test/ut3_tester/core/test_output_buffer.pkb similarity index 53% rename from test/core/test_output_buffer.pkb rename to test/ut3_tester/core/test_output_buffer.pkb index 848824ea8..7aab6f389 100644 --- a/test/core/test_output_buffer.pkb +++ b/test/ut3_tester/core/test_output_buffer.pkb @@ -9,7 +9,7 @@ create or replace package body test_output_buffer is l_buffer ut3.ut_output_buffer_base; begin --Arrange - l_buffer := ut3.ut_output_table_buffer(); + l_buffer := ut3.ut_output_clob_table_buffer(); l_expected_text := to_clob(lpad('a text', 31000, ',a text')) || chr(10) || to_clob(lpad('a text', 31000, ',a text')) || chr(13) || to_clob(lpad('a text', 31000, ',a text')) @@ -27,7 +27,8 @@ create or replace package body test_output_buffer is ut.expect(l_actual_text).to_equal(l_expected_text); ut.expect(l_actual_item_type).to_equal(l_expected_item_type); - select count(1) into l_remaining from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id; + select count(1) into l_remaining from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp) + where output_id = l_buffer.output_id; ut.expect(l_remaining).to_equal(0); end; @@ -37,14 +38,32 @@ create or replace package body test_output_buffer is l_result integer; l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer(); begin - delete from ut3.ut_output_buffer_tmp; + ut3_tester_helper.run_helper.delete_buffer(); --Act l_buffer.send_line(null); - open l_cur for select * from ut3.ut_output_buffer_tmp; + open l_cur for select * from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); ut.expect(l_cur).to_be_empty; end; + + procedure test_doesnt_send_on_null_elem is + l_cur sys_refcursor; + l_result integer; + l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer(); + l_message_id varchar2(255); + l_text varchar2(4000); + begin + ut3_tester_helper.run_helper.delete_buffer(); + --Act + l_buffer.send_lines(ut3.ut_varchar2_rows(null)); + l_buffer.send_lines(ut3.ut_varchar2_rows('test')); + + select message_id, text into l_message_id, l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); + ut.expect(l_message_id).to_equal('1'); + ut.expect(l_text).to_equal('test'); + end; + procedure test_send_line is l_result varchar2(4000); c_expected constant varchar2(4000) := lpad('a text',4000,',a text'); @@ -52,7 +71,7 @@ create or replace package body test_output_buffer is begin l_buffer.send_line(c_expected); - select text into l_result from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id; + select text into l_result from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp) where output_id = l_buffer.output_id; ut.expect(l_result).to_equal(c_expected); end; @@ -85,11 +104,47 @@ create or replace package body test_output_buffer is ut.expect(l_duration).to_be_greater_than(interval '0.99' second); end; - select count(1) into l_remaining from ut3.ut_output_buffer_tmp where output_id = l_buffer.output_id; + select count(1) into l_remaining from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp) where output_id = l_buffer.output_id; --Data got removed from output buffer ut.expect(l_remaining).to_equal(0); end; - + + procedure test_purge(a_buffer ut3.ut_output_buffer_base ) is + l_stale_buffer ut3.ut_output_buffer_base := a_buffer; + l_fresh_buffer ut3.ut_output_buffer_base; + l_buffer ut3.ut_output_buffer_base; + begin + --Arrange + l_stale_buffer.start_date := sysdate - 2; + --initialize with new start date + l_stale_buffer.init(); + l_stale_buffer.send_line('some text'); + l_stale_buffer.close(); + + l_fresh_buffer := ut3.ut_output_table_buffer(); + l_fresh_buffer.send_line('some text'); + l_fresh_buffer.close(); + + --Act - purge is performed on new buffer create + l_buffer := ut3.ut_output_table_buffer(); + + --Assert + -- Data in "fresh" buffer remains + ut.expect( l_fresh_buffer.get_lines_cursor(0,0), l_buffer.self_type ).to_have_count(1); + -- Data in "slate" buffer is purged and so the call to get_lines_cursor throws ORA-20218 + ut.expect( l_stale_buffer.get_lines_cursor(0,0), l_buffer.self_type ).to_be_empty(); + end; + + procedure test_purge_text_buffer is + begin + test_purge(ut3.ut_output_table_buffer()); + end; + + procedure test_purge_clob_buffer is + begin + test_purge(ut3.ut_output_clob_table_buffer()); + end; + end test_output_buffer; / diff --git a/test/core/test_output_buffer.pks b/test/ut3_tester/core/test_output_buffer.pks similarity index 52% rename from test/core/test_output_buffer.pks rename to test/ut3_tester/core/test_output_buffer.pks index 417b1ce09..24c2c01eb 100644 --- a/test/core/test_output_buffer.pks +++ b/test/ut3_tester/core/test_output_buffer.pks @@ -1,7 +1,7 @@ create or replace package test_output_buffer is --%suite(output_buffer) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) --%test(Receives a line from buffer table and deletes) procedure test_receive; @@ -9,11 +9,22 @@ create or replace package test_output_buffer is --%test(Does not send line if null text given) procedure test_doesnt_send_on_null_text; + --%test(Does not send line if null text given for multiline case) + procedure test_doesnt_send_on_null_elem; + --%test(Sends a line into buffer table) procedure test_send_line; --%test(Waits For The Data To Appear For Specified Time) procedure test_waiting_for_data; + --%test(Purges text buffer data older than one day and leaves the rest) + --%throws(-20218) + procedure test_purge_text_buffer; + + --%test(Purges clob buffer data older than one day and leaves the rest) + --%throws(-20218) + procedure test_purge_clob_buffer; + end test_output_buffer; / diff --git a/test/core/test_suite_builder.pkb b/test/ut3_tester/core/test_suite_builder.pkb similarity index 79% rename from test/core/test_suite_builder.pkb rename to test/ut3_tester/core/test_suite_builder.pkb index bd76e88d8..523d31a3d 100644 --- a/test/core/test_suite_builder.pkb +++ b/test/ut3_tester/core/test_suite_builder.pkb @@ -7,6 +7,8 @@ create or replace package body test_suite_builder is l_suites ut3.ut_suite_items; l_suite ut3.ut_logical_suite; l_cursor sys_refcursor; + l_type_cursor sys_refcursor; + l_ctx dbms_xmlgen.ctxhandle; l_xml xmltype; begin open l_cursor for select value(x) from table( @@ -22,9 +24,14 @@ create or replace package body test_suite_builder is a_skip_all_objects => true ); l_suite := treat( l_suites(l_suites.first) as ut3.ut_logical_suite); - + + open l_type_cursor for select l_suite as "UT_LOGICAL_SUITE" from dual; + l_ctx := dbms_xmlgen.newcontext(l_type_cursor); + dbms_xmlgen.setNullHandling(l_ctx, dbms_xmlgen.empty_tag); + l_xml := dbms_xmlgen.getxmltype(l_ctx); + select deletexml( - xmltype(l_suite), + l_xml, '//RESULTS_COUNT|//START_TIME|//END_TIME|//RESULT|//ASSOCIATED_EVENT_NAME' || '|//TRANSACTION_INVALIDATORS|//ERROR_BACKTRACE|//ERROR_STACK|//SERVEROUTPUT' ) @@ -608,11 +615,11 @@ create or replace package body test_suite_builder is --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert - ut.expect(l_actual).to_be_like('%%Annotation "--\%beforeall"%line 2%%', '\'); - ut.expect(l_actual).to_be_like('%%Annotation "--\%beforeeach"%line 3%%', '\'); - ut.expect(l_actual).to_be_like('%%Annotation "--\%aftereach"%line 4%%', '\'); - ut.expect(l_actual).to_be_like('%%Annotation "--\%afterall" cannot be used with "--\%test". Annotation ignored.' - ||'%at "UT3_TESTER.SOME_PACKAGE.DO_STUFF", line 5%%', '\'); + ut.expect(l_actual).to_match('(.*)()(.*)(Annotation "--%beforeall")(.*)(line 2)(.*)()(.*)', 'n'); + ut.expect(l_actual).to_match('(.*)()(.*)(Annotation "--%beforeeach")(.*)(line 3)(.*)()(.*)', 'n'); + ut.expect(l_actual).to_match('(.*)()(.*)(Annotation "--%aftereach")(.*)(line 4)(.*)()(.*)', 'n'); + ut.expect(l_actual).to_match('(.*)()(.*)(Annotation "--%afterall" cannot be used with "--%test". Annotation ignored.)' + ||'(.*)(at "UT3_TESTER.SOME_PACKAGE.DO_STUFF", line 5)(.*)()(.*)', 'n'); ut.expect(l_actual).not_to_be_like('%%'); ut.expect(l_actual).not_to_be_like('%%'); ut.expect(l_actual).not_to_be_like('%%'); @@ -638,7 +645,8 @@ create or replace package body test_suite_builder is l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( - '%' || + ''|| + '' || '%' || '%' || '' || @@ -661,7 +669,8 @@ create or replace package body test_suite_builder is '%some_packagesuite_level_beforeall' || '%' || '' || - '' + ''|| + '' ); end; @@ -685,6 +694,7 @@ create or replace package body test_suite_builder is l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( + ''|| '' || '%' || '%' || @@ -705,7 +715,8 @@ create or replace package body test_suite_builder is '%%suite_level_test%' || '%' || '%' || - '%' + '%'|| + '' ); ut.expect(l_actual).not_to_be_like('%%%%%%'); ut.expect(l_actual).not_to_be_like('%%%%%%'); @@ -733,6 +744,7 @@ create or replace package body test_suite_builder is l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert ut.expect(l_actual).to_be_like( + ''|| '' || '%' || '%' || @@ -755,7 +767,8 @@ create or replace package body test_suite_builder is '%' || '%%suite_level_beforeall%' || '%%suite_level_afterall%' || - '%' + '%'|| + '' ); ut.expect(l_actual).not_to_be_like('%%%%%%'); ut.expect(l_actual).not_to_be_like('%%%%%%'); @@ -782,6 +795,7 @@ create or replace package body test_suite_builder is ,'\' ); ut.expect(l_actual).to_be_like( + ''|| '' || '%' || '' || @@ -796,7 +810,8 @@ create or replace package body test_suite_builder is '%some_packagecontext_setup' || '%' || '' || - '' + ''|| + '' ); end; @@ -824,6 +839,7 @@ create or replace package body test_suite_builder is ,'\' ); ut.expect(l_actual).to_be_like( + ''|| '' || '%' || '' || @@ -846,7 +862,8 @@ create or replace package body test_suite_builder is '%some_packagesuite_level_beforeall' || '%' || '' || - '' + ''|| + '' ); end; @@ -879,6 +896,7 @@ create or replace package body test_suite_builder is ,'\' ); ut.expect(l_actual).to_be_like( + ''|| '' || '%' || '' || @@ -901,7 +919,8 @@ create or replace package body test_suite_builder is '%some_packagesuite_level_beforeall' || '%' || '' || - '' + ''|| + '' ); end; @@ -1095,7 +1114,7 @@ create or replace package body test_suite_builder is --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert - ut.expect(l_actual).to_be_like('%Unsupported annotation "--\%bad_procedure_annotation". Annotation ignored.% line 2%', '\'); + ut.expect(l_actual).to_match('(.*)(Unsupported annotation "--%bad_procedure_annotation"\. Annotation ignored\.)(.*)( line 2)(.*)', 'n'); end; procedure test_bad_package_annotation is @@ -1111,8 +1130,308 @@ create or replace package body test_suite_builder is --Act l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); --Assert - ut.expect(l_actual).to_be_like('%Unsupported annotation "--\%bad_package_annotation". Annotation ignored.% line 17%', '\'); + ut.expect(l_actual).to_match('(.*)(Unsupported annotation "--%bad_package_annotation"\. Annotation ignored\.)(.*)( line 17)(.*)', 'n'); + end; + + procedure test_tag_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags','testtag', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%testtag%'|| + '%%' + ); + end; + procedure suite_tag_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags','suitetag', null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%some_packagetestsuitesome_package' || + '%suitetag%'|| + '%%' + ); + + end; + + procedure test_tags_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags','testtag,testtag2,testtag3', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%testtagtesttag2testtag3%'|| + '%%' + ); + + end; + + procedure suite_tags_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag2', null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%some_packagetestsuitesome_package' || + '%suitetagsuitetag1suitetag2%'|| + '%%' + ); + + end; + + procedure test_2line_tags_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags','testtag', 'test_procedure'), + ut3.ut_annotation(10, 'tags','testtag2', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%testtagtesttag2%'|| + '%%' + ); + + end; + + procedure suite_2line_tags_annotation is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags','suitetag', null), + ut3.ut_annotation(4, 'tags','suitetag1', null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%some_packagetestsuitesome_package' || + '%suitetagsuitetag1%'|| + '%%' + ); + + end; + + procedure test_empty_tag is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags',null, 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%%"--%tags" annotation requires a tag value populated. Annotation ignored.%%'|| + '%%' + ); + + end; + + procedure suite_empty_tag is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%"--%tags" annotation requires a tag value populated. Annotation ignored.%%'|| + '%%' + ); + + end; + + procedure test_duplicate_tag is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags','testtag,testtag1,testtag', 'test_procedure'), + ut3.ut_annotation(10, 'tags',' testtag,testtag1,testtag2', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%testtagtesttag1testtag2%'|| + '%%' + ); + + end; + + procedure suite_duplicate_tag is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag', null), + ut3.ut_annotation(4, 'tags',' suitetag1,suitetag2', null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%some_packagetestsuitesome_package' || + '%suitetagsuitetag1suitetag2%'|| + '%%' + ); + + end; + + procedure test_empty_tag_between is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags','testtag,, ,testtag1', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%testtagtesttag1%'|| + '%%' + ); + + end; + + procedure suite_empty_tag_between is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags','suitetag,, ,suitetag1', null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%some_packagetestsuitesome_package' || + '%suitetagsuitetag1%'|| + '%%' + ); + + end; + + procedure test_special_char_tag is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(8, 'test','Some test', 'test_procedure'), + ut3.ut_annotation(9, 'tags','#?$%^&*!|\/@][', 'test_procedure') + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%test_procedureSome testsome_package.test_procedure' || + '%#?$%^&*!|\/@][%'|| + '%%' + ); + + end; + + procedure suite_special_char_tag is + l_actual clob; + l_annotations ut3.ut_annotations; + begin + --Arrange + l_annotations := ut3.ut_annotations( + ut3.ut_annotation(2, 'suite','testsuite', null), + ut3.ut_annotation(3, 'tags','#?$%^&*!|\/@][', null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + '%' || + '%some_packagetestsuitesome_package' || + '%#?$%^&*!|\/@][%'|| + '%%' + ); + + end; + end test_suite_builder; / diff --git a/test/core/test_suite_builder.pks b/test/ut3_tester/core/test_suite_builder.pks similarity index 79% rename from test/core/test_suite_builder.pks rename to test/ut3_tester/core/test_suite_builder.pks index 21ca58206..721db153f 100644 --- a/test/core/test_suite_builder.pks +++ b/test/ut3_tester/core/test_suite_builder.pks @@ -1,6 +1,6 @@ create or replace package test_suite_builder is --%suite(suite_builder) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) --%context(suite) --%displayname(--%suite annotation) @@ -172,5 +172,52 @@ create or replace package test_suite_builder is --%endcontext + --%context(tags_annotation) + --%displayname(--%tag_annotation) + + --%test(Build suite test with tag) + procedure test_tag_annotation; + + --%test(Build suite with tag) + procedure suite_tag_annotation; + + --%test(Build suite test with three tags) + procedure test_tags_annotation; + + --%test(Build suite with three tags) + procedure suite_tags_annotation; + + --%test(Build suite test with two line tag annotation) + procedure test_2line_tags_annotation; + + --%test(Build suite with two line tag annotation) + procedure suite_2line_tags_annotation; + + --%test(Build suite test with empty line tag annotation) + procedure test_empty_tag; + + --%test(Build suite with empty line tag annotation) + procedure suite_empty_tag; + + --%test(Build suite test with duplicate tag annotation) + procedure test_duplicate_tag; + + --%test(Build suite with duplicate tag annotation) + procedure suite_duplicate_tag; + + --%test(Build suite test with empty between tag annotation) + procedure test_empty_tag_between; + + --%test(Build suite with empty between tag annotation) + procedure suite_empty_tag_between; + + --%test(Build suite test with special char tag annotation) + procedure test_special_char_tag; + + --%test(Build suite with special char tag annotation) + procedure suite_special_char_tag; + + --%endcontext + end test_suite_builder; / diff --git a/test/core/test_suite_manager.pkb b/test/ut3_tester/core/test_suite_manager.pkb similarity index 91% rename from test/core/test_suite_manager.pkb rename to test/ut3_tester/core/test_suite_manager.pkb index bd6c97779..6f4237f9c 100644 --- a/test/core/test_suite_manager.pkb +++ b/test/ut3_tester/core/test_suite_manager.pkb @@ -4,32 +4,13 @@ create or replace package body test_suite_manager is pragma exception_init(ex_obj_doesnt_exist, -04043); procedure create_dummy_long_test_package is - pragma autonomous_transaction; begin - execute immediate q'[create or replace package ut3.dummy_long_test_package as - - --%suitepath(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) - --%suite(dummy_test_suite) - - --%test(dummy_test) - procedure some_dummy_test_procedure; - end;]'; - - execute immediate q'[create or replace package ut3.dummy_long_test_package1 as - - --%suitepath(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) - --%suite(dummy_test_suite1) - - --%test(dummy_test) - procedure some_dummy_test_procedure; - end;]'; + ut3_tester_helper.run_helper.create_dummy_long_test_package(); end; procedure drop_dummy_long_test_package is - pragma autonomous_transaction; begin - execute immediate q'[drop package ut3.dummy_long_test_package]'; - execute immediate q'[drop package ut3.dummy_long_test_package1]'; + ut3_tester_helper.run_helper.drop_dummy_long_test_package(); end; procedure compile_dummy_packages is @@ -310,7 +291,7 @@ end test_package_with_ctx;]'; end; procedure test_schema_run is - c_path constant varchar2(100) := USER; + c_path constant varchar2(100) := sys_context('USERENV', 'CURRENT_USER'); l_objects_to_run ut3.ut_suite_items := ut3.ut_suite_items(); l_all_objects_to_run ut3.ut_suite_items; @@ -357,7 +338,7 @@ end test_package_with_ctx;]'; end; procedure test_top2_by_name is - c_path varchar2(100) := USER||'.test_package_2'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -415,7 +396,7 @@ end test_package_with_ctx;]'; end; procedure test_by_path_to_subsuite is - c_path varchar2(100) := USER||':tests.test_package_1.test_package_2'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test_package_2'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -469,7 +450,7 @@ end test_package_with_ctx;]'; end; procedure test_subsute_proc_by_path is - c_path varchar2(100) := USER||':tests.test_package_1.test_package_2.test2'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test_package_2.test2'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -539,7 +520,7 @@ end test_package_with_ctx;]'; end; procedure test_top_pack_by_name is - c_path varchar2(100) := USER||'.test_package_1'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -614,7 +595,7 @@ end test_package_with_ctx;]'; end; procedure test_top_pack_by_path is - c_path varchar2(100) := USER||':tests'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -668,7 +649,7 @@ end test_package_with_ctx;]'; end; procedure test_top_pck_proc_by_path is - c_path varchar2(100) := USER||':tests.test_package_1.test2'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test2'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -728,7 +709,7 @@ end test_package_with_ctx;]'; end; procedure test_top_pkc_proc_by_name is - c_path varchar2(100) := USER||'.test_package_1.test2'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1.test2'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -784,7 +765,7 @@ end test_package_with_ctx;]'; end; procedure test_top_pkc_nosub_by_name is - c_path varchar2(100) := USER||'.test_package_3'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_3'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -848,7 +829,7 @@ end test_package_with_ctx;]'; end; procedure test_top_subpck_by_path is - c_path varchar2(100) := USER||':tests2.test_package_3'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests2.test_package_3'; l_objects_to_run ut3.ut_suite_items; l_test0_suite ut3.ut_logical_suite; @@ -1035,13 +1016,13 @@ end;'; l_test_report ut3.ut_varchar2_list; begin - select * bulk collect into l_test_report from table(ut3.ut.run(USER||'.tst_package_to_be_dropped')); + select * bulk collect into l_test_report from table(ut3.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.tst_package_to_be_dropped')); -- drop package clean_inv_cache_on_drop; begin - select * bulk collect into l_test_report from table(ut3.ut.run(user || '.tst_package_to_be_dropped')); + select * bulk collect into l_test_report from table(ut3.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.tst_package_to_be_dropped')); ut.fail('Cache not invalidated on package drop'); exception when others then @@ -1078,7 +1059,7 @@ end;'; l_test_report ut3.ut_varchar2_list; begin - select * bulk collect into l_test_report from table(ut3.ut.run(USER||'.test_dependencies')); + select * bulk collect into l_test_report from table(ut3.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_dependencies')); ut.expect(l_test_report(l_test_report.count-1)).to_be_like('1 test_, 0 failed, 0 errored, 0 disabled, 0 warning(s)'); --execute immediate 'select * from table(ut3.ut.run(''UT3.test_dependencies'', ut3.utplsql_test_reporter()))' into l_result; @@ -1396,7 +1377,7 @@ end;]'; end; procedure pck_proc_in_ctx_by_name is - c_path varchar2(100) := USER||'.test_package_with_ctx.test1'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_with_ctx.test1'; l_objects_to_run ut3.ut_suite_items; l_test_suite ut3.ut_logical_suite; @@ -1423,7 +1404,7 @@ end;]'; end; procedure pck_proc_in_ctx_by_path is - c_path varchar2(100) := USER||':test_package_with_ctx.some_context.test1'; + c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':test_package_with_ctx.some_context.test1'; l_objects_to_run ut3.ut_suite_items; l_test_suite ut3.ut_logical_suite; @@ -1456,28 +1437,20 @@ end;]'; l_expected := ut3.ut_object_names( ut3.ut_object_name('UT3','SOME_TEST_PACKAGE') ); - l_actual := ut3.ut_suite_manager.get_schema_ut_packages(ut3.ut_varchar2_rows('UT3')); + l_actual := ut3_tester_helper.run_helper.get_object_name('UT3'); ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; + procedure create_ut3_suite is - pragma autonomous_transaction; begin - execute immediate q'[ - create or replace package ut3.some_test_package - as - --%suite - - --%test - procedure some_test; - - end;]'; + ut3_tester_helper.run_helper.create_ut3_suite(); end; procedure drop_ut3_suite is pragma autonomous_transaction; begin - execute immediate q'[drop package ut3.some_test_package]'; + ut3_tester_helper.run_helper.drop_ut3_suite(); end; procedure add_new_long_test_package is @@ -1485,7 +1458,7 @@ end;]'; l_expected_message varchar2(500); begin l_expected_message := q'[ORA-20217: 'Suitepath exceeds 1000 CHAR on: UT3.DUMMY_LONG_TEST_PACKAGE,UT3.DUMMY_LONG_TEST_PACKAGE1'%]'; - l_actual := ut3.ut_suite_manager.get_schema_ut_packages(ut3.ut_varchar2_rows('UT3')); + l_actual := ut3_tester_helper.run_helper.get_object_name('UT3'); ut.fail('Expected exception for suitpaths over 1k for two packages'); exception when others then diff --git a/test/core/test_suite_manager.pks b/test/ut3_tester/core/test_suite_manager.pks similarity index 99% rename from test/core/test_suite_manager.pks rename to test/ut3_tester/core/test_suite_manager.pks index aad29fad0..ed318b890 100644 --- a/test/core/test_suite_manager.pks +++ b/test/ut3_tester/core/test_suite_manager.pks @@ -1,7 +1,7 @@ create or replace package test_suite_manager is --%suite(suite_manager) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) procedure create_dummy_long_test_package; diff --git a/test/core/test_ut_executable.pkb b/test/ut3_tester/core/test_ut_executable.pkb similarity index 80% rename from test/core/test_ut_executable.pkb rename to test/ut3_tester/core/test_ut_executable.pkb index 1d2e74ff3..92420de47 100644 --- a/test/core/test_ut_executable.pkb +++ b/test/ut3_tester/core/test_ut_executable.pkb @@ -24,8 +24,9 @@ create or replace package body test_ut_executable is l_result boolean; begin --Arrange - l_test := ut3.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); - l_executable := ut3.ut_executable_test( user, 'test_ut_executable', 'output_proc', ut3.ut_utils.gc_test_execute ); + l_test := ut3.ut_test(a_object_owner => 'ut3_tester', a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); + l_executable := ut3.ut_executable_test( a_owner => 'ut3_tester', a_package => 'test_ut_executable', + a_procedure_name => 'output_proc', a_executable_type => ut3.ut_utils.gc_test_execute ); --Act l_result := l_executable.do_execute(l_test); --Assert @@ -40,8 +41,8 @@ create or replace package body test_ut_executable is l_result boolean; begin --Arrange - l_test := ut3.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); - l_executable := ut3.ut_executable_test( user, 'test_ut_executable', 'throwing_proc', ut3.ut_utils.gc_test_execute ); + l_test := ut3.ut_test(a_object_owner => 'ut3_tester', a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); + l_executable := ut3.ut_executable_test( 'ut3_tester', 'test_ut_executable', 'throwing_proc', ut3.ut_utils.gc_test_execute ); --Act l_result := l_executable.do_execute(l_test); --Assert @@ -76,9 +77,7 @@ create or replace package body test_ut_executable is dbms_lock.sleep(0.4); $end while l_cnt > 0 loop - select count(1) into l_cnt - from dba_scheduler_running_jobs srj - where srj.job_name = l_job_name; + l_cnt:=ut3_tester_helper.main_helper.get_job_count(l_job_name); end loop; end; @@ -97,7 +96,7 @@ create or replace package body test_ut_executable is procedure output_proc is begin - dbms_output.put_line(g_dbms_output_text); + dbms_output.put_line('Some output from procedure'); end; procedure throwing_proc is diff --git a/test/core/test_ut_executable.pks b/test/ut3_tester/core/test_ut_executable.pks similarity index 94% rename from test/core/test_ut_executable.pks rename to test/ut3_tester/core/test_ut_executable.pks index 4c11e5142..882f0f209 100644 --- a/test/core/test_ut_executable.pks +++ b/test/ut3_tester/core/test_ut_executable.pks @@ -1,7 +1,7 @@ create or replace package test_ut_executable is --%suite(ut_executable) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) --%context(do_execute) diff --git a/test/core/test_ut_suite.pkb b/test/ut3_tester/core/test_ut_suite.pkb similarity index 67% rename from test/core/test_ut_suite.pkb rename to test/ut3_tester/core/test_ut_suite.pkb index 04d75277a..3ea323a6d 100644 --- a/test/core/test_ut_suite.pkb +++ b/test/ut3_tester/core/test_ut_suite.pkb @@ -2,26 +2,36 @@ create or replace package body test_ut_suite is procedure cleanup_package_state is begin - ut_example_tests.g_number := null; + ut3_tester_helper.ut_example_tests.g_number := null; end; - + + procedure create_trans_control is + begin + ut3_tester_helper.run_helper.create_trans_control; + end; + + procedure drop_trans_control is + begin + ut3_tester_helper.run_helper.drop_trans_control; + end; + procedure disabled_suite is l_suite ut3.ut_suite; begin --Arrange l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.path := 'ut_example_tests'; + l_suite.path := 'ut3_tester_helper.ut_example_tests'; l_suite.disabled_flag := ut3.ut_utils.boolean_to_int(true); l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); l_suite.after_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_be_null; + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_disabled); ut.expect(l_suite.results_count.disabled_count).to_equal(2); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -35,14 +45,14 @@ create or replace package body test_ut_suite is begin --Arrange l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.path := 'ut_example_tests'; + l_suite.path := 'ut3_tester_helper.ut_example_tests'; l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_be_null; + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -56,17 +66,17 @@ create or replace package body test_ut_suite is begin --Arrange l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.path := 'ut_example_tests'; + l_suite.path := 'ut3_tester_helper.ut_example_tests'; l_suite.after_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_after_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'set_g_number_0', a_line_no=> 1); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_equal(1); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_success); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(1); @@ -101,44 +111,39 @@ create or replace package body test_ut_suite is ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); end; - procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut3_latest_release.ut_matcher) is + procedure rollback_auto is l_suite ut3.ut_suite; begin --Arrange - execute immediate 'delete from ut$test_table'; + execute immediate 'delete from ut3_tester_helper.ut$test_table'; l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); - l_suite.path := 'ut_transaction_control'; + l_suite.path := 'ut3_tester_helper.ut_transaction_control'; l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_TRANSACTION_CONTROL', 'setup', ut3.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER, a_object_name => 'ut_transaction_control',a_name => a_procedure_name, a_line_no=> 1); - l_suite.set_rollback_type(a_rollback_type); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER, a_object_name => 'ut_transaction_control',a_name => 'test', a_line_no=> 1); + l_suite.set_rollback_type(ut3.ut_utils.gc_rollback_auto); --Act l_suite.do_execute(); --Assert - ut.expect(core.get_value(q'[ut_transaction_control.count_rows('t')]')).to_( a_expectation ); - ut.expect(core.get_value(q'[ut_transaction_control.count_rows('s')]')).to_( a_expectation ); - end; - - procedure rollback_auto is - begin - test_rollback_type('test', ut3.ut_utils.gc_rollback_auto, equal(0) ); + ut.expect(ut3_tester_helper.main_helper.get_value(q'[ut3_tester_helper.ut_transaction_control.count_rows('t')]')).to_equal(0); + ut.expect(ut3_tester_helper.main_helper.get_value(q'[ut3_tester_helper.ut_transaction_control.count_rows('s')]')).to_equal(0); end; procedure rollback_auto_on_failure is begin - test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_auto, equal(0) ); + ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_auto, equal(0) ); end; procedure rollback_manual is begin - test_rollback_type('test', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) ); + ut3_tester_helper.run_helper.test_rollback_type('test', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) ); end; procedure rollback_manual_on_failure is begin - test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) ); + ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3.ut_utils.gc_rollback_manual, be_greater_than(0) ); end; procedure trim_transaction_invalidators is diff --git a/test/core/test_ut_suite.pks b/test/ut3_tester/core/test_ut_suite.pks similarity index 78% rename from test/core/test_ut_suite.pks rename to test/ut3_tester/core/test_ut_suite.pks index cc4de8528..385d00fc7 100644 --- a/test/core/test_ut_suite.pks +++ b/test/ut3_tester/core/test_ut_suite.pks @@ -1,7 +1,7 @@ create or replace package test_ut_suite is --%suite(ut_suite) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) --%beforeeach procedure cleanup_package_state; @@ -15,12 +15,21 @@ create or replace package test_ut_suite is --%test(Reports warnings for each test if afterall raises exception) procedure aftereall_errors; + --%beforetest(ut3_tester_helper.run_helper.package_no_body) + --%aftertest(ut3_tester_helper.run_helper.drop_package_no_body) --%test(Fails all tests in package when package has no body) procedure package_without_body; --%test(Fails all tests in package when package body is invalid) procedure package_with_invalid_body; + --%context( rollback_test ) + + --%beforeall + procedure create_trans_control; + --%afterall + procedure drop_trans_control; + --%test(Performs automatic rollback after a suite) procedure rollback_auto; @@ -32,7 +41,9 @@ create or replace package test_ut_suite is --%test(rollback(manual) - disables automatic rollback after a suite even if test fails) procedure rollback_manual_on_failure; - + + --%endcontext + --%test(Transaction invalidators list is trimmed in warnings when too long) procedure trim_transaction_invalidators; diff --git a/test/core/test_ut_test.pkb b/test/ut3_tester/core/test_ut_test.pkb similarity index 78% rename from test/core/test_ut_test.pkb rename to test/ut3_tester/core/test_ut_test.pkb index b521d6841..2a85a323f 100644 --- a/test/core/test_ut_test.pkb +++ b/test/ut3_tester/core/test_ut_test.pkb @@ -2,7 +2,7 @@ create or replace package body test_ut_test is procedure cleanup_package_state is begin - ut_example_tests.g_number := null; + ut3_tester_helper.ut_example_tests.g_number := null; end; procedure disabled_test is @@ -10,19 +10,19 @@ create or replace package body test_ut_test is l_test ut3.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.path := 'ut_example_tests'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_suite := ut3.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.path := 'ut3_tester_helper.ut_example_tests'; + l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 2); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 2); l_suite.items(l_suite.items.last).disabled_flag := ut3.ut_utils.boolean_to_int(true); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_equal(1); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_success); ut.expect(l_suite.results_count.disabled_count).to_equal(1); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -36,21 +36,21 @@ create or replace package body test_ut_test is l_test ut3.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.path := 'ut_example_tests'; - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_suite := ut3.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.path := 'ut3_tester_helper.ut_example_tests'; + l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3.ut_utils.gc_before_test)); - l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_after_test)); + l_test := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_before_test)); + l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_after_test)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_equal(3); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(3); ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -64,19 +64,19 @@ create or replace package body test_ut_test is l_test ut3.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3.ut_utils.gc_before_each)); - l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_after_each)); + l_suite := ut3.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_test := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_before_each)); + l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_after_each)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => 'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_equal(3); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(3); ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -90,19 +90,19 @@ create or replace package body test_ut_test is l_test ut3.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_before_test)); - l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3.ut_utils.gc_after_test)); + l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_test := ut3.ut_test(a_object_owner =>'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_before_test)); + l_test.after_test_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_after_test)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner =>'ut3_tester_helper',a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_equal(2); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(2); ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -116,19 +116,19 @@ create or replace package body test_ut_test is l_test ut3.ut_test; begin --Arrange - l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3.ut_utils.gc_before_all)); - l_test := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); - l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3.ut_utils.gc_before_each)); - l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3.ut_utils.gc_after_each)); + l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'ut_example_tests', a_line_no=> 1); + l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'set_g_number_0', ut3.ut_utils.gc_before_all)); + l_test := ut3.ut_test(a_object_owner => USER,a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_test.before_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'failing_procedure', ut3.ut_utils.gc_before_each)); + l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(USER, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_after_each)); l_suite.items.extend; l_suite.items(l_suite.items.last) := l_test; l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_name => 'UT_EXAMPLE_TESTS',a_name => 'add_1_to_g_number', a_line_no=> 1); + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER,a_object_name => 'ut_example_tests',a_name => 'add_1_to_g_number', a_line_no=> 1); --Act l_suite.do_execute(); --Assert - ut.expect(ut_example_tests.g_number).to_equal(2); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(2); ut.expect(l_suite.result).to_equal(ut3.ut_utils.gc_error); ut.expect(l_suite.results_count.disabled_count).to_equal(0); ut.expect(l_suite.results_count.warnings_count).to_equal(0); @@ -140,22 +140,31 @@ create or replace package body test_ut_test is procedure after_each_executed is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null ); begin - l_test.after_each_list := ut3.ut_executables(ut3.ut_executable(user, 'ut_example_tests', 'add_1_to_g_number', ut3.ut_utils.gc_after_each)); + l_test.after_each_list := ut3.ut_executables( + ut3.ut_executable( + user, + 'UT_EXAMPLE_TESTS', + 'add_1_to_g_number', + ut3.ut_utils.gc_after_each + ) + ); --Act l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); - ut.expect(ut_example_tests.g_number).to_equal(1); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure after_each_proc_name_invalid is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -168,12 +177,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_equal(0); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; procedure after_each_procedure_name_null is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -186,7 +196,7 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_equal(0); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; procedure create_app_info_package is @@ -309,6 +319,7 @@ create or replace package body test_ut_test is procedure before_each_executed is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'add_1_to_g_number', a_line_no => null @@ -319,13 +330,14 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); - ut.expect(ut_example_tests.g_number).to_equal(1); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure before_each_proc_name_invalid is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -338,12 +350,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_be_null; + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure before_each_proc_name_null is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -356,14 +369,15 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_be_null; + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure ignore_savepoint_exception is pragma autonomous_transaction; --Arrange l_test ut3.ut_test := ut3.ut_test( - a_object_name => 'ut_example_tests', + a_object_owner => 'ut3_tester_helper', + a_object_name => 'ut_example_tests', a_name => 'ut_commit_test', a_line_no => null ); @@ -390,10 +404,19 @@ create or replace package body test_ut_test is ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); end; + procedure create_synonym is + begin + ut3_tester_helper.ut_example_tests.create_synonym; + end; + + procedure drop_synonym is + begin + ut3_tester_helper.ut_example_tests.drop_synonym; + end; + procedure owner_name_null is --Arrange l_test ut3.ut_test := ut3.ut_test( - a_object_owner => null, a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -403,10 +426,9 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); - ut.expect(ut_example_tests.g_number).to_equal(0); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; - procedure create_invalid_package is pragma autonomous_transaction; begin @@ -471,6 +493,7 @@ create or replace package body test_ut_test is procedure procedure_name_invalid is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'invalid procedure name', a_line_no => null @@ -485,6 +508,7 @@ create or replace package body test_ut_test is procedure procedure_name_null is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => null, a_line_no => null @@ -499,6 +523,7 @@ create or replace package body test_ut_test is procedure before_test_executed is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'add_1_to_g_number', a_line_no => null @@ -509,12 +534,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); - ut.expect(ut_example_tests.g_number).to_equal(1); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure before_test_proc_name_invalid is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -527,12 +553,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_be_null; + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure before_test_proc_name_null is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -545,12 +572,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_be_null; + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; end; procedure after_test_executed is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -561,12 +589,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_success); - ut.expect(ut_example_tests.g_number).to_equal(1); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); end; procedure after_test_proce_name_invalid is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -579,12 +608,13 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_equal(0); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; procedure after_test_proc_name_null is --Arrange l_test ut3.ut_test := ut3.ut_test( + a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_name => 'set_g_number_0', a_line_no => null @@ -597,7 +627,7 @@ create or replace package body test_ut_test is l_test.do_execute(); --Assert ut.expect(l_test.result).to_equal(ut3.ut_utils.gc_error); - ut.expect(ut_example_tests.g_number).to_equal(0); + ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); end; procedure create_output_package is diff --git a/test/core/test_ut_test.pks b/test/ut3_tester/core/test_ut_test.pks similarity index 94% rename from test/core/test_ut_test.pks rename to test/ut3_tester/core/test_ut_test.pks index ee888ecd3..18ea6613f 100644 --- a/test/core/test_ut_test.pks +++ b/test/ut3_tester/core/test_ut_test.pks @@ -1,8 +1,8 @@ create or replace package test_ut_test is --%suite(ut_test) - --%suitepath(utplsql.core) - + --%suitepath(utplsql.ut3_tester.core) + --%beforeeach procedure cleanup_package_state; @@ -49,7 +49,14 @@ create or replace package test_ut_test is procedure ignore_savepoint_exception; --%test(Fails when owner name invalid) procedure owner_name_invalid; + + + procedure create_synonym; + procedure drop_synonym; + --%test(Runs test as current schema when owner name null) + --%beforetest(create_synonym) + --%aftertest(drop_synonym) procedure owner_name_null; procedure create_invalid_package; diff --git a/test/core/test_ut_utils.pkb b/test/ut3_tester/core/test_ut_utils.pkb similarity index 99% rename from test/core/test_ut_utils.pkb rename to test/ut3_tester/core/test_ut_utils.pkb index 326f5a49b..31e1520d2 100644 --- a/test/core/test_ut_utils.pkb +++ b/test/ut3_tester/core/test_ut_utils.pkb @@ -252,7 +252,7 @@ end;]' using p_expected_list; begin l_lines := sys.dbms_preprocessor.get_post_processed_source( object_type => 'PACKAGE', - schema_name => user, + schema_name => sys_context('USERENV', 'CURRENT_USER'), object_name => 'TST_CHARS' ); diff --git a/test/core/test_ut_utils.pks b/test/ut3_tester/core/test_ut_utils.pks similarity index 98% rename from test/core/test_ut_utils.pks rename to test/ut3_tester/core/test_ut_utils.pks index 8452f84c3..d8fca3b60 100644 --- a/test/core/test_ut_utils.pks +++ b/test/ut3_tester/core/test_ut_utils.pks @@ -1,7 +1,7 @@ create or replace package test_ut_utils is --%suite(ut_utils) - --%suitepath(utplsql.core) + --%suitepath(utplsql.ut3_tester.core) function get_numeric_delimiter return varchar2; diff --git a/test/ut3_tester_helper/coverage_helper.pkb b/test/ut3_tester_helper/coverage_helper.pkb new file mode 100644 index 000000000..feac8000d --- /dev/null +++ b/test/ut3_tester_helper/coverage_helper.pkb @@ -0,0 +1,275 @@ +create or replace package body coverage_helper is + + function get_mock_run_id return integer is + v_result integer; + begin + select nvl(min(runid),0) - 1 into v_result + from ut3.plsql_profiler_runs; + return v_result; + end; + + function get_mock_block_run_id return integer is + v_result integer; + begin + select nvl(min(run_id),0) - 1 into v_result + from dbmspcc_runs; + return v_result; + end; + + procedure mock_coverage_data(a_run_id integer,a_user in varchar2) is + c_unit_id constant integer := 1; + begin + insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) + values(a_run_id, a_user, sysdate, 'unit testing utPLSQL'); + + insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) + values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE'); + + insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) + select a_run_id, c_unit_id, 4, 1, 1 from dual union all + select a_run_id, c_unit_id, 5, 0, 0 from dual union all + select a_run_id, c_unit_id, 7, 1, 1 from dual; + end; + + procedure cleanup_dummy_coverage(a_run_id in integer) is + pragma autonomous_transaction; + begin + delete from ut3.plsql_profiler_data where runid = a_run_id; + delete from ut3.plsql_profiler_units where runid = a_run_id; + delete from ut3.plsql_profiler_runs where runid = a_run_id; + commit; + end; + + procedure create_dummy_coverage_package is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package UT3.DUMMY_COVERAGE is + procedure do_stuff; + + procedure grant_myself; + end;]'; + execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE is + procedure do_stuff is + begin + if 1 = 2 then + dbms_output.put_line('should not get here'); + else + dbms_output.put_line('should get here'); + end if; + end; + + procedure grant_myself is + begin + execute immediate 'grant debug,execute on UT3.DUMMY_COVERAGE to ut3$user#'; + end; + end;]'; + + end; + + procedure create_dummy_coverage_test is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE is + --%suite(dummy coverage test) + --%suitepath(coverage_testing) + + --%test + procedure test_do_stuff; + + procedure grant_myself; + end;]'; + execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE is + procedure test_do_stuff is + begin + dummy_coverage.do_stuff; + end; + + procedure grant_myself is + begin + execute immediate 'grant debug,execute on UT3.TEST_DUMMY_COVERAGE to ut3$user#'; + end; + end;]'; + + end; + + procedure grant_exec_on_cov is + pragma autonomous_transaction; + begin + execute immediate 'begin UT3.DUMMY_COVERAGE.grant_myself(); end;'; + execute immediate 'begin UT3.TEST_DUMMY_COVERAGE.grant_myself(); end;'; + end; + + procedure drop_dummy_coverage_pkg is + pragma autonomous_transaction; + begin + begin execute immediate q'[drop package ut3.test_dummy_coverage]'; exception when others then null; end; + begin execute immediate q'[drop package ut3.dummy_coverage]'; exception when others then null; end; + end; + + + procedure create_dummy_coverage_test_1 is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package UT3.DUMMY_COVERAGE_1 is + procedure do_stuff; + procedure grant_myself; + end;]'; + execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE_1 is + procedure do_stuff is + begin + if 1 = 2 then + dbms_output.put_line('should not get here'); + else + dbms_output.put_line('should get here'); + end if; + end; + + procedure grant_myself is + begin + execute immediate 'grant debug,execute on UT3.DUMMY_COVERAGE_1 to ut3$user#'; + end; + + end;]'; + execute immediate q'[create or replace package UT3.TEST_DUMMY_COVERAGE_1 is + --%suite(dummy coverage test 1) + --%suitepath(coverage_testing) + + --%test + procedure test_do_stuff; + + procedure grant_myself; + end;]'; + execute immediate q'[create or replace package body UT3.TEST_DUMMY_COVERAGE_1 is + procedure test_do_stuff is + begin + dummy_coverage_1.do_stuff; + end; + + procedure grant_myself is + begin + execute immediate 'grant debug,execute on UT3.TEST_DUMMY_COVERAGE_1 to ut3$user#'; + end; + + end;]'; + end; + + procedure drop_dummy_coverage_test_1 is + pragma autonomous_transaction; + begin + execute immediate q'[drop package UT3.DUMMY_COVERAGE_1]'; + execute immediate q'[drop package UT3.TEST_DUMMY_COVERAGE_1]'; + end; + + procedure grant_exec_on_cov_1 is + pragma autonomous_transaction; + begin + execute immediate 'begin UT3.DUMMY_COVERAGE_1.grant_myself(); end;'; + execute immediate 'begin UT3.TEST_DUMMY_COVERAGE_1.grant_myself(); end;'; + end; + + --12.2 Setup + procedure create_dummy_12_2_cov_pck is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG is + procedure do_stuff(i_input in number); + + procedure grant_myself; + end;]'; + execute immediate q'[create or replace package body UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG is + procedure do_stuff(i_input in number) is + begin + if i_input = 2 then + dbms_output.put_line('should not get here'); + else + dbms_output.put_line('should get here'); + end if; + end; + + procedure grant_myself is + begin + execute immediate 'grant debug,execute on UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG to ut3$user#'; + end; + + end;]'; + end; + + procedure create_dummy_12_2_cov_test is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package UT3.TEST_BLOCK_DUMMY_COVERAGE is + --%suite(dummy coverage test) + --%suitepath(coverage_testing) + + --%test + procedure test_do_stuff; + + procedure grant_myself; + + end;]'; + execute immediate q'[create or replace package body UT3.TEST_BLOCK_DUMMY_COVERAGE is + procedure test_do_stuff is + begin + dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long.do_stuff(1); + ut.expect(1).to_equal(1); + end; + + procedure grant_myself is + begin + execute immediate 'grant debug,execute on UT3.TEST_BLOCK_DUMMY_COVERAGE to ut3$user#'; + end; + end;]'; + end; + + procedure mock_block_coverage_data(a_run_id integer,a_user in varchar2) is + c_unit_id constant integer := 1; + begin + insert into dbmspcc_runs ( run_id, run_owner, run_timestamp, run_comment) + values(a_run_id, a_user, sysdate, 'unit testing utPLSQL'); + + insert into dbmspcc_units ( run_id, object_id, type, owner, name,last_ddl_time) + values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG',sysdate); + + insert into dbmspcc_blocks ( run_id, object_id, line,block,col,covered,not_feasible) + select a_run_id, c_unit_id,4,1,1,1,0 from dual union all + select a_run_id, c_unit_id,4,2,2,0,0 from dual union all + select a_run_id, c_unit_id,5,3,0,1,0 from dual union all + select a_run_id, c_unit_id,7,4,1,1,0 from dual; + end; + + procedure mock_profiler_coverage_data(a_run_id integer,a_user in varchar2) is + c_unit_id constant integer := 1; + begin + insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) + values(a_run_id, a_user, sysdate, 'unit testing utPLSQL'); + + insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) + values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG'); + + insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) + select a_run_id, c_unit_id, 4, 1, 1 from dual union all + select a_run_id, c_unit_id, 5, 0, 0 from dual union all + select a_run_id, c_unit_id, 6, 1, 0 from dual union all + select a_run_id, c_unit_id, 7, 1, 1 from dual; + end; + + procedure cleanup_dummy_coverage(a_block_id in integer, a_prof_id in integer) is + pragma autonomous_transaction; + begin + begin execute immediate q'[drop package ut3.test_block_dummy_coverage]'; exception when others then null; end; + begin execute immediate q'[drop package ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long]'; exception when others then null; end; + delete from dbmspcc_blocks where run_id = a_block_id; + delete from dbmspcc_units where run_id = a_block_id; + delete from dbmspcc_runs where run_id = a_block_id; + cleanup_dummy_coverage(a_prof_id); + commit; + end; + + procedure grant_exec_on_12_2_cov is + pragma autonomous_transaction; + begin + execute immediate 'begin UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG.grant_myself(); end;'; + execute immediate 'begin UT3.TEST_BLOCK_DUMMY_COVERAGE.grant_myself(); end;'; + end; +end; +/ diff --git a/test/ut3_tester_helper/coverage_helper.pks b/test/ut3_tester_helper/coverage_helper.pks new file mode 100644 index 000000000..73ff7b448 --- /dev/null +++ b/test/ut3_tester_helper/coverage_helper.pks @@ -0,0 +1,30 @@ +create or replace package coverage_helper is + + g_run_id integer; + + type prof_runs_tab is table of ut3.plsql_profiler_runs%rowtype; + + function get_mock_run_id return integer; + function get_mock_block_run_id return integer; + procedure cleanup_dummy_coverage(a_run_id in integer); + procedure mock_coverage_data(a_run_id integer,a_user in varchar2); + + --Profiler coveage + procedure create_dummy_coverage_package; + procedure create_dummy_coverage_test; + procedure grant_exec_on_cov; + procedure mock_profiler_coverage_data(a_run_id integer,a_user in varchar2); + procedure drop_dummy_coverage_pkg; + procedure create_dummy_coverage_test_1; + procedure drop_dummy_coverage_test_1; + procedure grant_exec_on_cov_1; + + --Block coverage + procedure create_dummy_12_2_cov_pck; + procedure create_dummy_12_2_cov_test; + procedure mock_block_coverage_data(a_run_id integer,a_user in varchar2); + procedure cleanup_dummy_coverage(a_block_id in integer, a_prof_id in integer); + procedure grant_exec_on_12_2_cov; + +end; +/ diff --git a/test/core/expectations.pkb b/test/ut3_tester_helper/expectations_helper.pkb similarity index 81% rename from test/core/expectations.pkb rename to test/ut3_tester_helper/expectations_helper.pkb index cc2bae436..cc86f18a6 100644 --- a/test/core/expectations.pkb +++ b/test/ut3_tester_helper/expectations_helper.pkb @@ -1,4 +1,4 @@ -create or replace package body expectations is +create or replace package body expectations_helper is function unary_expectation_block( a_matcher_name varchar2, @@ -52,16 +52,6 @@ create or replace package body expectations is end;'; return l_execute; end; - - function failed_expectations_data return anydata is - begin - return anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations()); - end; - - procedure cleanup_expectations is - begin - ut3.ut_expectation_processor.clear_expectations(); - end; - -end expectations; + +end; / diff --git a/test/core/expectations.pks b/test/ut3_tester_helper/expectations_helper.pks similarity index 78% rename from test/core/expectations.pks rename to test/ut3_tester_helper/expectations_helper.pks index 9abc29400..9c1d54333 100644 --- a/test/core/expectations.pks +++ b/test/ut3_tester_helper/expectations_helper.pks @@ -1,4 +1,4 @@ -create or replace package expectations is +create or replace package expectations_helper is function unary_expectation_block( a_matcher_name varchar2, @@ -20,10 +20,6 @@ create or replace package expectations is a_expected_data_type varchar2, a_expected_data varchar2 ) return varchar2; - - function failed_expectations_data return anydata; - - procedure cleanup_expectations; - -end expectations; + +end; / diff --git a/test/ut3_tester_helper/main_helper.pkb b/test/ut3_tester_helper/main_helper.pkb new file mode 100644 index 000000000..ffccc3185 --- /dev/null +++ b/test/ut3_tester_helper/main_helper.pkb @@ -0,0 +1,158 @@ +create or replace package body main_helper is + + function get_dbms_output_as_clob return clob is + l_status number; + l_line varchar2(32767); + l_result clob; + begin + + dbms_output.get_line(line => l_line, status => l_status); + if l_status != 1 then + dbms_lob.createtemporary(l_result, true, dur => dbms_lob.session); + end if; + while l_status != 1 loop + if l_line is not null then + ut3.ut_utils.append_to_clob(l_result, l_line||chr(10)); + end if; + dbms_output.get_line(line => l_line, status => l_status); + end loop; + return l_result; + end; + + procedure execute_autonomous(a_sql varchar2) is + pragma autonomous_transaction; + begin + if a_sql is not null then + execute immediate a_sql; + end if; + commit; + end; + + function run_test(a_path varchar2) return clob is + l_lines ut3.ut_varchar2_list; + begin + select * bulk collect into l_lines from table(ut3.ut.run(a_path)); + return ut3.ut_utils.table_to_clob(l_lines); + end; + + function get_value(a_variable varchar2) return integer is + l_glob_val integer; + begin + execute immediate 'begin :l_glob_val := '||a_variable||'; end;' using out l_glob_val; + return l_glob_val; + end; + + function get_failed_expectations return ut3.ut_varchar2_list is + l_expectations_result ut3.ut_expectation_results := ut3.ut_expectation_processor.get_failed_expectations(); + l_result ut3.ut_varchar2_list := ut3.ut_varchar2_list(); + begin + for i in 1..l_expectations_result.count loop + l_result := l_result multiset union l_expectations_result(i).get_result_lines(); + end loop; + return l_result; + end; + + function get_failed_expectations(a_pos in number) return varchar2 is + l_result varchar2(32767) := ut3.ut_expectation_processor.get_failed_expectations()(a_pos).message; + begin + return l_result; + end; + + function failed_expectations_data return anydata is + begin + return anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations()); + end; + + function get_failed_expectations_num return number is + l_num_failed number; + l_results ut3.ut_expectation_results := ut3.ut_expectation_processor.get_failed_expectations(); + begin + l_num_failed := l_results.count; + return l_num_failed; + end; + + procedure clear_expectations is + begin + ut3.ut_expectation_processor.clear_expectations(); + end; + + function table_to_clob(a_results in ut3.ut_varchar2_list) return clob is + begin + return ut3.ut_utils.table_to_clob(a_results); + end; + + function get_warnings return ut3.ut_varchar2_rows is + begin + return ut3.ut_expectation_processor.get_warnings(); + end; + + procedure reset_nulls_equal is + begin + ut3.ut_expectation_processor.nulls_Are_equal(ut3.ut_expectation_processor.gc_default_nulls_are_equal); + end; + + procedure nulls_are_equal(a_nulls_equal boolean := true) is + begin + ut3.ut_expectation_processor.nulls_Are_equal(a_nulls_equal); + end; + + procedure cleanup_annotation_cache is + pragma autonomous_transaction; + begin + delete from ut3.ut_annotation_cache_info + where object_owner = user and object_type = 'PACKAGE' and object_name in ('DUMMY_PACKAGE','DUMMY_TEST_PACKAGE'); + commit; + end; + + procedure create_parse_proc_as_ut3$user# is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace procedure ut3$user#.parse_annotations is + begin + ut3.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER','PACKAGE'); + end;]'; + end; + + procedure drop_parse_proc_as_ut3$user# is + pragma autonomous_transaction; + begin + execute immediate 'drop procedure ut3$user#.parse_annotations'; + end; + + procedure parse_dummy_test_as_ut3$user# is + pragma autonomous_transaction; + begin + execute immediate 'begin ut3$user#.parse_annotations; end;'; + end; + + function get_job_count(a_job_name varchar2) return number is + l_cnt number; + begin + select count(1) into l_cnt + from dba_scheduler_running_jobs srj + where srj.job_name = a_job_name; + end; + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_list, a_item varchar2) is + begin + ut3.ut_utils.append_to_list(a_list,a_item); + end; + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item varchar2) is + begin + ut3.ut_utils.append_to_list(a_list,a_item); + end; + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item clob) is + begin + ut3.ut_utils.append_to_list(a_list,a_item); + end; + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_items ut3.ut_varchar2_rows) is + begin + ut3.ut_utils.append_to_list(a_list,a_items); + end; + +end; +/ diff --git a/test/ut3_tester_helper/main_helper.pks b/test/ut3_tester_helper/main_helper.pks new file mode 100644 index 000000000..7d349151c --- /dev/null +++ b/test/ut3_tester_helper/main_helper.pks @@ -0,0 +1,49 @@ +create or replace package main_helper is + + gc_success number := ut3.ut_utils.gc_success; + gc_failure number := ut3.ut_utils.gc_failure; + + procedure execute_autonomous(a_sql varchar2); + + function run_test(a_path varchar2) return clob; + + function get_value(a_variable varchar2) return integer; + + function get_dbms_output_as_clob return clob; + + function get_failed_expectations return ut3.ut_varchar2_list; + + function get_failed_expectations(a_pos in number) return varchar2; + + function get_failed_expectations_num return number; + + procedure clear_expectations; + + function table_to_clob(a_results in ut3.ut_varchar2_list) return clob; + + function get_warnings return ut3.ut_varchar2_rows; + + procedure reset_nulls_equal; + + procedure nulls_are_equal(a_nulls_equal boolean := true); + + procedure cleanup_annotation_cache; + + procedure create_parse_proc_as_ut3$user#; + + procedure drop_parse_proc_as_ut3$user#; + + procedure parse_dummy_test_as_ut3$user#; + + function get_job_count(a_job_name varchar2) return number; + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_list, a_item varchar2); + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item varchar2); + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_item clob); + + procedure append_to_list(a_list in out nocopy ut3.ut_varchar2_rows, a_items ut3.ut_varchar2_rows); + +end; +/ diff --git a/test/helpers/other_dummy_object.tps b/test/ut3_tester_helper/other_dummy_object.tps similarity index 99% rename from test/helpers/other_dummy_object.tps rename to test/ut3_tester_helper/other_dummy_object.tps index c1019c415..7453d5dcf 100644 --- a/test/helpers/other_dummy_object.tps +++ b/test/ut3_tester_helper/other_dummy_object.tps @@ -13,4 +13,4 @@ create or replace type other_dummy_object as object ( "name" varchar2(30), "Value" varchar2(30) ) -/ \ No newline at end of file +/ diff --git a/test/ut3_tester_helper/run_helper.pkb b/test/ut3_tester_helper/run_helper.pkb new file mode 100644 index 000000000..9bc2b7f79 --- /dev/null +++ b/test/ut3_tester_helper/run_helper.pkb @@ -0,0 +1,632 @@ +create or replace package body run_helper is + + procedure setup_cache_objects is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut3$user#.dummy_test_package as + --%suite(dummy_test_suite) + --%rollback(manual) + + --%test(dummy_test) + --%beforetest(some_procedure) + procedure some_dummy_test_procedure; + end;]'; + execute immediate q'[create or replace procedure ut3$user#.dummy_test_procedure as + --%some_annotation(some_text) + --%rollback(manual) + begin + null; + end;]'; + execute immediate q'[create or replace procedure ut3_tester_helper.dummy_test_procedure as + --%some_annotation(some_text) + --%rollback(manual) + begin + null; + end;]'; + + execute immediate q'[grant execute on ut3_tester_helper.dummy_test_procedure to public]'; + end; + + procedure setup_cache_objectstag is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut3$user#.dummy_test_package as + --%suite(dummy_test_suite) + --%tags(dummy) + --%rollback(manual) + + --%test(dummy_test) + --%tags(testtag) + --%beforetest(some_procedure) + procedure some_dummy_test_procedure; + end;]'; + execute immediate q'[create or replace procedure ut3$user#.dummy_test_procedure as + --%some_annotation(some_text) + --%rollback(manual) + begin + null; + end;]'; + execute immediate q'[create or replace procedure ut3_tester_helper.dummy_test_procedure as + --%some_annotation(some_text) + --%rollback(manual) + begin + null; + end;]'; + + execute immediate q'[grant execute on ut3_tester_helper.dummy_test_procedure to public]'; + end; + + procedure setup_cache_twotags is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut3$user#.dummy_test_package as + --%suite(dummy_test_suite) + --%tags(suitetag1,suitetag2) + --%rollback(manual) + + --%test(dummy_test) + --%tags(testtag1,testtag2) + --%beforetest(some_procedure) + procedure some_dummy_test_procedure; + end;]'; + execute immediate q'[create or replace procedure ut3$user#.dummy_test_procedure as + --%some_annotation(some_text) + --%rollback(manual) + begin + null; + end;]'; + execute immediate q'[create or replace procedure ut3_tester_helper.dummy_test_procedure as + --%some_annotation(some_text) + --%rollback(manual) + begin + null; + end;]'; + + execute immediate q'[grant execute on ut3_tester_helper.dummy_test_procedure to public]'; + end; + + procedure create_trans_control is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut_transaction_control as + function count_rows(a_val varchar2) return number; + procedure setup; + procedure test; + procedure test_failure; + end;]'; + + execute immediate + q'[create or replace package body ut_transaction_control + as + + function count_rows(a_val varchar2) return number is + l_cnt number; + begin + select count(*) into l_cnt from ut$test_table t where t.val = a_val; + return l_cnt; + end; + procedure setup is begin + insert into ut$test_table values ('s'); + end; + procedure test is + begin + insert into ut$test_table values ('t'); + end; + procedure test_failure is + begin + insert into ut$test_table values ('t'); + --raise no_data_found; + raise_application_error(-20001,'Error'); + end; + end;]'; + + execute immediate 'grant execute on ut_transaction_control to public'; + end; + + procedure drop_trans_control is + pragma autonomous_transaction; + begin + execute immediate 'drop package ut_transaction_control'; + end; + + procedure setup_cache is + pragma autonomous_transaction; + begin + setup_cache_objects(); + ut3.ut_annotation_manager.rebuild_annotation_cache('UT3$USER#','PACKAGE'); + ut3.ut_annotation_manager.rebuild_annotation_cache('UT3$USER#','PROCEDURE'); + ut3.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER_HELPER','PROCEDURE'); + end; + + procedure cleanup_cache is + pragma autonomous_transaction; + begin + delete from ut3.ut_annotation_cache_info + where object_type = 'PROCEDURE' and object_owner in ('UT3$USER#','UT3_TESTER_HELPER') + or object_type = 'PACKAGE' and object_owner = user and object_name = 'DUMMY_TEST_PACKAGE'; + execute immediate q'[drop package ut3$user#.dummy_test_package]'; + execute immediate q'[drop procedure ut3$user#.dummy_test_procedure]'; + execute immediate q'[drop procedure ut3_tester_helper.dummy_test_procedure]'; + end; + + procedure create_db_link is + l_service_name varchar2(100); + pragma autonomous_transaction; + begin + select global_name into l_service_name from global_name; + execute immediate + 'create public database link db_loopback connect to ut3_tester_helper identified by ut3 + using ''(DESCRIPTION= + (ADDRESS=(PROTOCOL=TCP) + (HOST='||sys_context('userenv','SERVER_HOST')||') + (PORT=1521) + ) + (CONNECT_DATA=(SERVICE_NAME='||l_service_name||')))'''; + end; + + procedure drop_db_link is + begin + execute immediate 'drop public database link db_loopback'; + exception + when others then + null; + end; + + procedure db_link_setup is + l_service_name varchar2(100); + begin + create_db_link; + execute immediate q'[ + create or replace package ut3$user#.test_db_link is + --%suite + + --%test + procedure runs_with_db_link; + end;]'; + + execute immediate q'[ + create or replace package body ut3$user#.test_db_link is + procedure runs_with_db_link is + a_value integer; + begin + select 1 into a_value + from dual@db_loopback; + ut3.ut.expect(a_value).to_be_null(); + end; + end;]'; + + end; + + procedure db_link_cleanup is + begin + drop_db_link; + begin execute immediate 'drop package ut3$user#.test_db_link'; exception when others then null; end; + end; + + procedure create_suite_with_link is + pragma autonomous_transaction; + begin + create_db_link; + execute immediate 'create table tst(id number(18,0))'; + execute immediate q'[ + create or replace package test_distributed_savepoint is + --%suite + --%suitepath(alltests) + + --%beforeall + procedure setup; + + --%test + procedure test; + end;]'; + + execute immediate q'[ + create or replace package body test_distributed_savepoint is + + g_expected constant integer := 1; + + procedure setup is + begin + insert into tst@db_loopback values(g_expected); + end; + + procedure test is + l_actual integer := 0; + begin + select id into l_actual from tst@db_loopback; + + ut.expect(l_actual).to_equal(g_expected); + end; + + end;]'; + execute immediate 'grant execute on test_distributed_savepoint to public'; + end; + + procedure drop_suite_with_link is + pragma autonomous_transaction; + begin + drop_db_link; + execute immediate 'drop table tst'; + execute immediate 'drop package test_distributed_savepoint'; + end; + + procedure create_ut3$user#_tests is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_package_1 is + --%suite + --%tags(suite1,helper) + --%suitepath(tests) + --%rollback(manual) + + --%test(Test1 from test package 1) + --%tags(test1,suite1test1,subtest1) + procedure test1; + + --%test(Test2 from test package 1) + --%tags(test1,suite1test2) + procedure test2; + + end test_package_1; + ]'; + execute immediate q'[create or replace package body test_package_1 is + procedure test1 is + begin + dbms_output.put_line('test_package_1.test1 executed'); + raise_application_error(-20111,'test'); + end; + procedure test2 is + begin + dbms_output.put_line('test_package_1.test2 executed'); + end; + end test_package_1; + ]'; + + execute immediate q'[create or replace package test_package_2 is + --%suite + --%tags(suite2,helper) + --%suitepath(tests.test_package_1) + + --%test + --%tags(test2,suite2test1,subtest2) + procedure test1; + + --%test + --%tags(suite2test2) + procedure test2; + + end test_package_2; + ]'; + execute immediate q'[create or replace package body test_package_2 is + procedure test1 is + begin + dbms_output.put_line('test_package_2.test1 executed'); + end; + procedure test2 is + begin + dbms_output.put_line('test_package_2.test2 executed'); + end; + end test_package_2; + ]'; + + execute immediate q'[create or replace package test_package_3 is + --%suite + --%tags(suite3,helper) + --%suitepath(tests2) + + --%test + --%tags(test1suite3) + procedure test1; + + --%test + --%tags(test2suite3) + procedure test2; + + end test_package_3; + ]'; + execute immediate q'[create or replace package body test_package_3 is + procedure test1 is + begin + dbms_output.put_line('test_package_3.test1 executed'); + end; + procedure test2 is + begin + dbms_output.put_line('test_package_3.test2 executed'); + end; + end test_package_3; + ]'; + execute immediate q'[grant execute on test_package_1 to public]'; + execute immediate q'[grant execute on test_package_2 to public]'; + execute immediate q'[grant execute on test_package_3 to public]'; + end; + + procedure drop_ut3$user#_tests is + pragma autonomous_transaction; + begin + execute immediate q'[drop package test_package_1]'; + execute immediate q'[drop package test_package_2]'; + execute immediate q'[drop package test_package_3]'; + end; + + procedure create_test_suite is + pragma autonomous_transaction; + begin + ut3_tester_helper.run_helper.create_db_link; + execute immediate q'[ + create or replace package stateful_package as + function get_state return varchar2; + end; + ]'; + execute immediate q'[ + create or replace package body stateful_package as + g_state varchar2(1) := 'A'; + function get_state return varchar2 is begin return g_state; end; + end; + ]'; + execute immediate q'[ + create or replace package test_stateful as + --%suite + --%suitepath(test_state) + + --%test + --%beforetest(acquire_state_via_db_link,rebuild_stateful_package) + procedure failing_stateful_test; + + procedure rebuild_stateful_package; + procedure acquire_state_via_db_link; + + end; + ]'; + execute immediate q'{ + create or replace package body test_stateful as + + procedure failing_stateful_test is + begin + ut3.ut.expect(stateful_package.get_state@db_loopback).to_equal('abc'); + end; + + procedure rebuild_stateful_package is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace package body stateful_package as + g_state varchar2(3) := 'abc'; + function get_state return varchar2 is begin return g_state; end; + end; + ]'; + end; + + procedure acquire_state_via_db_link is + begin + dbms_output.put_line('stateful_package.get_state@db_loopback='||stateful_package.get_state@db_loopback); + end; + end; + }'; + execute immediate 'grant execute on test_stateful to public'; + end; + + procedure drop_test_suite is + pragma autonomous_transaction; + begin + drop_db_link; + execute immediate 'drop package stateful_package'; + execute immediate 'drop package test_stateful'; + end; + + procedure package_no_body is + pragma autonomous_transaction; + begin + execute immediate 'create or replace package ut_without_body as + procedure test1; + end;'; + end; + + procedure drop_package_no_body is + pragma autonomous_transaction; + begin + execute immediate 'drop package ut_without_body'; + end; + + procedure run(a_reporter ut3.ut_reporter_base := null) is + begin + ut3.ut.run(a_reporter); + end; + + procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) is + begin + ut3.ut.run(a_path, a_reporter); + end; + + procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) is + begin + ut3.ut.run(a_paths, a_reporter); + end; + + procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) is + begin + ut3.ut.run( + a_paths, + a_reporter, + a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + ); + end; + + function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_reporter)); + return l_results; + end; + + function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table ( + ut3.ut.run( + a_paths, + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + )); + return l_results; + end; + + function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) + return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_path, a_reporter)); + return l_results; + end; + + function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) + return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_paths, a_reporter)); + return l_results; + end; + + function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) + return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table ( + ut3.ut.run( + a_reporter, a_source_files => ut3.ut_varchar2_list(), + a_test_files => a_test_files + )); + return l_results; + end; + + procedure run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2) is + begin + ut3.ut.run(a_reporter,a_tags => a_tags); + end; + + procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null,a_tags varchar2) is + begin + ut3.ut.run(a_path, a_reporter,a_tags => a_tags); + end; + + procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) is + begin + ut3.ut.run(a_paths, a_reporter,a_tags => a_tags); + end; + + function run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2) return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_reporter, a_tags => a_tags)); + return l_results; + end; + + function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) + return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_path, a_reporter,a_tags => a_tags)); + return l_results; + end; + + function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) + return ut3.ut_varchar2_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run(a_paths, a_reporter, a_tags => a_tags)); + return l_results; + end; + + procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut3_latest_release.ut_matcher) is + l_suite ut3.ut_suite; + begin + --Arrange + execute immediate 'delete from ut$test_table'; + l_suite := ut3.ut_suite(a_object_owner => USER, a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); + l_suite.path := 'ut_transaction_control'; + l_suite.before_all_list := ut3.ut_executables(ut3.ut_executable(USER, 'UT_TRANSACTION_CONTROL', 'setup', ut3.ut_utils.gc_before_all)); + l_suite.items.extend; + l_suite.items(l_suite.items.last) := ut3.ut_test(a_object_owner => USER, a_object_name => 'ut_transaction_control',a_name => a_procedure_name, a_line_no=> 1); + l_suite.set_rollback_type(a_rollback_type); + + --Act + l_suite.do_execute(); + + --Assert + ut.expect(main_helper.get_value(q'[ut_transaction_control.count_rows('t')]')).to_( a_expectation ); + ut.expect(main_helper.get_value(q'[ut_transaction_control.count_rows('s')]')).to_( a_expectation ); + end; + + procedure create_dummy_long_test_package is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package ut3.dummy_long_test_package as + + --%suitepath(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) + --%suite(dummy_test_suite) + + --%test(dummy_test) + procedure some_dummy_test_procedure; + end;]'; + + execute immediate q'[create or replace package ut3.dummy_long_test_package1 as + + --%suitepath(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) + --%suite(dummy_test_suite1) + + --%test(dummy_test) + procedure some_dummy_test_procedure; + end;]'; + end; + + procedure drop_dummy_long_test_package is + pragma autonomous_transaction; + begin + execute immediate q'[drop package ut3.dummy_long_test_package]'; + execute immediate q'[drop package ut3.dummy_long_test_package1]'; + end; + + procedure create_ut3_suite is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace package ut3.some_test_package + as + --%suite + + --%test + procedure some_test; + + end;]'; + end; + + procedure drop_ut3_suite is + pragma autonomous_transaction; + begin + execute immediate q'[drop package ut3.some_test_package]'; + end; + + function get_object_name(a_owner in varchar2) return ut3.ut_object_names is + begin + return ut3.ut_suite_manager.get_schema_ut_packages(ut3.ut_varchar2_rows(a_owner)); + end; + + function ut_output_buffer_tmp return t_out_buff_tab pipelined is + l_buffer_tab t_out_buff_tab; + cursor get_buffer is + select * from ut3.ut_output_buffer_tmp; + begin + open get_buffer; + fetch get_buffer bulk collect into l_buffer_tab; + for idx in 1..l_buffer_tab.count loop + pipe row(l_buffer_tab(idx)); + end loop; + end; + + procedure delete_buffer is + begin + delete from ut3.ut_output_buffer_tmp; + end; + +end; +/ diff --git a/test/ut3_tester_helper/run_helper.pks b/test/ut3_tester_helper/run_helper.pks new file mode 100644 index 000000000..e06401eae --- /dev/null +++ b/test/ut3_tester_helper/run_helper.pks @@ -0,0 +1,68 @@ +create or replace package run_helper is + + g_run_id integer; + + type t_out_buff_tab is table of ut3.ut_output_buffer_tmp%rowtype; + type prof_runs_tab is table of ut3.plsql_profiler_runs%rowtype; + + procedure setup_cache_objects; + procedure setup_cache_objectstag; + procedure setup_cache_twotags; + procedure setup_cache; + procedure cleanup_cache; + procedure create_db_link; + procedure drop_db_link; + procedure db_link_setup; + procedure db_link_cleanup; + + procedure create_suite_with_link; + procedure drop_suite_with_link; + + procedure create_ut3$user#_tests; + procedure drop_ut3$user#_tests; + + procedure create_test_suite; + procedure drop_test_suite; + procedure package_no_body; + procedure drop_package_no_body; + + procedure create_trans_control; + procedure drop_trans_control; + + procedure run(a_reporter ut3.ut_reporter_base := null); + procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null); + procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null); + procedure run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, + a_reporter ut3.ut_reporter_base); + function run(a_reporter ut3.ut_reporter_base := null) return ut3.ut_varchar2_list; + function run(a_paths ut3.ut_varchar2_list, a_test_files ut3.ut_varchar2_list, + a_reporter ut3.ut_reporter_base) return ut3.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null) + return ut3.ut_varchar2_list; + function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null) + return ut3.ut_varchar2_list; + function run(a_test_files ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base) + return ut3.ut_varchar2_list; + + procedure run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2); + procedure run(a_path varchar2, a_reporter ut3.ut_reporter_base := null,a_tags varchar2); + procedure run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2); + function run(a_reporter ut3.ut_reporter_base := null,a_tags varchar2) return ut3.ut_varchar2_list; + function run(a_path varchar2, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) + return ut3.ut_varchar2_list; + function run(a_paths ut3.ut_varchar2_list, a_reporter ut3.ut_reporter_base := null, a_tags varchar2) + return ut3.ut_varchar2_list; + + procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut3_latest_release.ut_matcher); + + procedure create_dummy_long_test_package; + procedure drop_dummy_long_test_package; + procedure create_ut3_suite; + procedure drop_ut3_suite; + function get_object_name(a_owner in varchar2) return ut3.ut_object_names; + + function ut_output_buffer_tmp return t_out_buff_tab pipelined; + procedure delete_buffer; + +end; +/ diff --git a/test/ut3_tester_helper/test_dummy_number.tps b/test/ut3_tester_helper/test_dummy_number.tps new file mode 100644 index 000000000..b6283c93b --- /dev/null +++ b/test/ut3_tester_helper/test_dummy_number.tps @@ -0,0 +1,14 @@ +declare + l_exists integer; +begin + select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_NUMBER'; + if l_exists > 0 then + execute immediate 'drop type test_dummy_number force'; + end if; +end; +/ + +create or replace type test_dummy_number as object ( + id number +) +/ diff --git a/test/helpers/test_dummy_object.tps b/test/ut3_tester_helper/test_dummy_object.tps similarity index 87% rename from test/helpers/test_dummy_object.tps rename to test/ut3_tester_helper/test_dummy_object.tps index 79eed3e6e..7f095fc0a 100644 --- a/test/helpers/test_dummy_object.tps +++ b/test/ut3_tester_helper/test_dummy_object.tps @@ -14,6 +14,3 @@ create or replace type test_dummy_object as object ( "Value" varchar2(30) ) / - - -grant execute on test_dummy_object to ut3$user#; \ No newline at end of file diff --git a/test/helpers/test_dummy_object_list.tps b/test/ut3_tester_helper/test_dummy_object_list.tps similarity index 59% rename from test/helpers/test_dummy_object_list.tps rename to test/ut3_tester_helper/test_dummy_object_list.tps index e1dde66ed..67bba558e 100644 --- a/test/helpers/test_dummy_object_list.tps +++ b/test/ut3_tester_helper/test_dummy_object_list.tps @@ -1,4 +1,2 @@ create or replace type test_dummy_object_list as table of test_dummy_object / - -grant execute on test_dummy_object_list to ut3$user#; \ No newline at end of file diff --git a/test/helpers/test_event_list.tps b/test/ut3_tester_helper/test_event_list.tps similarity index 100% rename from test/helpers/test_event_list.tps rename to test/ut3_tester_helper/test_event_list.tps diff --git a/test/helpers/test_event_object.tps b/test/ut3_tester_helper/test_event_object.tps similarity index 100% rename from test/helpers/test_event_object.tps rename to test/ut3_tester_helper/test_event_object.tps diff --git a/test/helpers/test_tab_varchar2.tps b/test/ut3_tester_helper/test_tab_varchar2.tps similarity index 100% rename from test/helpers/test_tab_varchar2.tps rename to test/ut3_tester_helper/test_tab_varchar2.tps diff --git a/test/helpers/test_tab_varray.tps b/test/ut3_tester_helper/test_tab_varray.tps similarity index 100% rename from test/helpers/test_tab_varray.tps rename to test/ut3_tester_helper/test_tab_varray.tps diff --git a/test/ut3_tester_helper/ut_example_tests.pkb b/test/ut3_tester_helper/ut_example_tests.pkb new file mode 100644 index 000000000..7e795d184 --- /dev/null +++ b/test/ut3_tester_helper/ut_example_tests.pkb @@ -0,0 +1,36 @@ +create or replace package body ut_example_tests +as + procedure create_synonym is + pragma autonomous_transaction; + begin + execute immediate 'create or replace synonym ut3_tester.ut_example_tests for ut3_tester_helper.ut_example_tests'; + end; + + procedure drop_synonym is + pragma autonomous_transaction; + begin + execute immediate 'drop synonym ut3_tester.ut_example_tests'; + end; + + procedure set_g_number_0 as + begin + g_number := 0; + end; + + procedure add_1_to_g_number as + begin + g_number := g_number + 1; + end; + + procedure failing_procedure as + begin + g_number := 1 / 0; + end; + + procedure ut_commit_test is + begin + commit; + end; + +end; +/ diff --git a/test/helpers/ut_example_tests.pks b/test/ut3_tester_helper/ut_example_tests.pks similarity index 57% rename from test/helpers/ut_example_tests.pks rename to test/ut3_tester_helper/ut_example_tests.pks index 428d55743..a62c02332 100644 --- a/test/helpers/ut_example_tests.pks +++ b/test/ut3_tester_helper/ut_example_tests.pks @@ -1,5 +1,9 @@ -create or replace package ut_example_tests as +create or replace package ut_example_tests is g_number number; + + procedure create_synonym; + procedure drop_synonym; + procedure set_g_number_0; procedure add_1_to_g_number; procedure failing_procedure; diff --git a/test/helpers/ut_test_table.sql b/test/ut3_tester_helper/ut_test_table.sql similarity index 80% rename from test/helpers/ut_test_table.sql rename to test/ut3_tester_helper/ut_test_table.sql index bccd07bc4..c4832a10f 100644 --- a/test/helpers/ut_test_table.sql +++ b/test/ut3_tester_helper/ut_test_table.sql @@ -9,3 +9,4 @@ end; / create table ut$test_table (val varchar2(1)); +grant select,insert,update,delete on ut$test_table to public; diff --git a/test/ut3_user/api/test_ut_run.pkb b/test/ut3_user/api/test_ut_run.pkb new file mode 100644 index 000000000..3fb2fbfec --- /dev/null +++ b/test/ut3_user/api/test_ut_run.pkb @@ -0,0 +1,1020 @@ +create or replace package body test_ut_run is + + g_owner varchar2(250) := sys_context('userenv', 'current_schema'); + + procedure clear_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations(); + end; + + procedure create_ut3$user#_tests is + begin + ut3_tester_helper.run_helper.create_ut3$user#_tests(); + end; + + procedure drop_ut3$user#_tests is + begin + ut3_tester_helper.run_helper.drop_ut3$user#_tests(); + end; + + procedure ut_version is + begin + ut.expect(ut3.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); + end; + + procedure ut_fail is + begin + --Act + ut3.ut.fail('Testing failure message'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations(1)) + .to_be_like('%Testing failure message%'); + end; + + procedure run_proc_no_params is + l_results clob; + begin + ut3_tester_helper.run_helper.run(); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_specific_reporter is + l_results clob; + begin + --Act + ut3.ut.run('ut3_tester_helper',a_reporter => ut3.ut_documentation_reporter() ); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_cov_file_list is + l_results clob; + begin + --Act + ut3.ut.run( + 'ut3_tester_helper', + a_reporter => ut3.ut_sonar_test_reporter(), + a_source_files => ut3.ut_varchar2_list(), + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + ); + + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb'|| + '%tests/ut3_tester_helper.test_package_1.pkb'|| + '%tests/ut3_tester_helper.test_package_3.pkb%' ); + end; + + procedure run_proc_pkg_name is + l_results clob; + begin + ut3.ut.run('ut3_tester_helper.test_package_1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_proc_pkg_name_file_list is + l_results clob; + begin + ut3.ut.run( + 'ut3_tester_helper.test_package_3', + ut3.ut_sonar_test_reporter(), a_source_files => ut3.ut_varchar2_list(), + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + ); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3_tester_helper.test_package_3.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3_tester_helper.test_package_1.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb%' ); + end; + + procedure run_proc_path_list is + l_results clob; + begin + ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list(':tests.test_package_1',':tests')); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_proc_path_list_file_list is + l_results clob; + begin + ut3_tester_helper.run_helper.run( + a_paths => ut3.ut_varchar2_list(':tests.test_package_1',':tests'), + a_reporter => ut3.ut_sonar_test_reporter(), + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + ); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3_tester_helper.test_package_1.pkb%' ); + ut.expect( l_results ).to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3_tester_helper.test_package_3.pkb%' ); + end; + + procedure run_proc_null_reporter is + l_results clob; + begin + --Act + ut3.ut.run('ut3_tester_helper', cast(null as ut3.ut_reporter_base)); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); + end; + + procedure run_proc_null_path is + l_results clob; + begin + --Act + ut3_tester_helper.run_helper.run(cast(null as varchar2)); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_null_path_list is + l_results clob; + l_paths ut3.ut_varchar2_list; + begin + --Act + ut3_tester_helper.run_helper.run(l_paths); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_proc_empty_path_list is + l_results clob; + begin + --Act + ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list()); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure create_suite_with_commit is + pragma autonomous_transaction; + begin + execute immediate 'create or replace package test_commit_warning is + --%suite + --%suitepath(ut.run.transaction) + + --%test + procedure does_commit; + end;'; + execute immediate 'create or replace package body test_commit_warning is + procedure does_commit is + begin + ut3.ut.expect(1).to_equal(1); + commit; + end; + end;'; + end; + + procedure drop_suite_with_commit is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_commit_warning'; + end; + + procedure run_proc_warn_on_commit is + l_results clob; + begin + ut3.ut.run('test_commit_warning'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + ut.expect(l_results).to_be_like( + '%Unable to perform automatic rollback after test%'|| + 'An implicit or explicit commit/rollback occurred in procedures:%' || + 'does_commit%' || + 'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.%' + ); + end; + + procedure create_failing_beforeall_suite is + pragma autonomous_transaction; + begin + execute immediate 'create or replace package parent_suite is + --%suite + --%suitepath(ut.run.failing_setup) + + --%beforeall + procedure failing_setup; + end;'; + execute immediate 'create or replace package body parent_suite is + procedure failing_setup is + begin + raise no_data_found; + end; + end;'; + execute immediate 'create or replace package child_suite is + --%suite + --%suitepath(ut.run.failing_setup.parent_suite.some_sub_suite) + + --%test + procedure does_stuff; + end;'; + execute immediate 'create or replace package body child_suite is + procedure does_stuff is + begin + ut3.ut.expect(1).to_equal(1); + end; + end;'; + end; + + procedure drop_failing_beforeall_suite is + pragma autonomous_transaction; + begin + execute immediate 'drop package parent_suite'; + execute immediate 'drop package child_suite'; + end; + + procedure run_proc_fail_child_suites is + l_results clob; + begin + ut3.ut.run('child_suite'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + ut.expect(l_results).to_be_like( + '%1) does_stuff%' || + 'ORA-01403: no data found%' || + 'ORA-06512: at "UT3$USER#.PARENT_SUITE%' + ); + end; + + procedure transaction_setup is + pragma autonomous_transaction; + begin + execute immediate 'create table transaction_test_table(message varchar2(100))'; + execute immediate 'create or replace package test_transaction is + --%suite + + --%test + procedure insert_row; + + --%test + procedure insert_and_raise; + end; + '; + execute immediate 'create or replace package body test_transaction is + procedure insert_row is + begin + insert into transaction_test_table values (''2 - inside the test_transaction.insert_row test''); + end; + procedure insert_and_raise is + begin + insert into transaction_test_table values (''2 - inside the test_transaction.insert_row test''); + raise no_data_found; + end; + end; + '; + + end; + + procedure transaction_cleanup is + pragma autonomous_transaction; + begin + begin + execute immediate 'drop table transaction_test_table'; + exception + when others then null; + end; + begin + execute immediate 'drop package test_transaction'; + exception + when others then null; + end; + end; + + procedure run_proc_keep_test_data is + l_expected sys_refcursor; + l_actual sys_refcursor; + l_results clob; + begin + --Arrange + execute immediate ' + insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; + + --Act + ut3.ut.run('test_transaction.insert_row', a_force_manual_rollback => true); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + + --Assert + open l_expected for + select '1 - inside the test_ut_run.run_proc_keep_test_changes test' as message from dual + union all + select '2 - inside the test_transaction.insert_row test' from dual + order by 1; + + open l_actual for 'select * from transaction_test_table order by 1'; + + ut.expect( l_actual ).to_equal(l_expected); + end; + + procedure run_proc_keep_test_data_raise is + l_expected sys_refcursor; + l_actual sys_refcursor; + l_results clob; + begin + --Arrange + execute immediate ' + insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; + + --Act + ut3.ut.run('test_transaction.insert_and_raise', a_force_manual_rollback => true); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + + --Assert + open l_expected for + select '1 - inside the test_ut_run.run_proc_keep_test_changes test' as message from dual + union all + select '2 - inside the test_transaction.insert_row test' from dual + order by 1; + + open l_actual for 'select * from transaction_test_table order by 1'; + + ut.expect( l_actual ).to_equal(l_expected); + end; + + procedure run_proc_discard_test_data is + l_expected sys_refcursor; + l_actual sys_refcursor; + l_results clob; + begin + --Arrange + execute immediate ' + insert into transaction_test_table values (''1 - inside the test_ut_run.run_proc_keep_test_changes test'')'; + + --Act + ut3.ut.run('test_transaction.insert_row'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + + --Assert + open l_expected for + select '1 - inside the test_ut_run.run_proc_keep_test_changes test' as message from dual; + + open l_actual for 'select * from transaction_test_table order by 1'; + + ut.expect( l_actual ).to_equal(l_expected); + end; + + procedure run_func_no_params is + l_results ut3.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_specific_reporter is + l_results ut3.ut_varchar2_list; + begin + --Act + l_results := ut3_tester_helper.run_helper.run(ut3.ut_documentation_reporter()); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_cov_file_list is + l_results ut3.ut_varchar2_list; + begin + --Act + select * bulk collect into l_results from table ( + ut3.ut.run('ut3_tester_helper', + ut3.ut_sonar_test_reporter(), + a_source_files => ut3.ut_varchar2_list(), + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + )); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb%tests/ut3_tester_helper.test_package_1.pkb%tests/ut3_tester_helper.test_package_3.pkb%' ); + end; + + procedure run_func_pkg_name is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run('ut3_tester_helper.test_package_1')); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_func_pkg_name_file_list is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table ( + ut3.ut.run('ut3_tester_helper.test_package_3', + ut3.ut_sonar_test_reporter(), + a_source_files => ut3.ut_varchar2_list(), + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + )); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%tests/ut3_tester_helper.test_package_3.pkb%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3_tester_helper.test_package_1.pkb%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb%' ); + end; + + procedure run_func_path_list is + l_results ut3.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list(':tests.test_package_1',':tests')); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_func_path_list_file_list is + l_results ut3.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run( + a_paths => ut3.ut_varchar2_list(':tests.test_package_1',':tests'), + a_reporter => ut3.ut_sonar_test_reporter(), + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + ); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%tests/ut3_tester_helper.test_package_1.pkb%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%tests/ut3_tester_helper.test_package_3.pkb%' ); + end; + + procedure run_func_null_reporter is + l_results ut3.ut_varchar2_list; + begin + --Act + select * bulk collect into l_results from table (ut3.ut.run('ut3_tester_helper',cast(null as ut3.ut_reporter_base))); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%tests%test_package_1%test_package_2%tests2%test_package_3%' ); + end; + + procedure run_func_null_path is + l_results ut3.ut_varchar2_list; + begin + --Act + l_results := ut3_tester_helper.run_helper.run(cast(null as varchar2)); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_null_path_list is + l_results ut3.ut_varchar2_list; + l_paths ut3.ut_varchar2_list; + begin + --Act + l_results := ut3_tester_helper.run_helper.run(l_paths); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_empty_path_list is + l_results ut3.ut_varchar2_list; + begin + --Act + l_results := ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list()); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_cov_file_lst_null_rep is + l_results ut3.ut_varchar2_list; + begin + --Act + l_results := ut3_tester_helper.run_helper.run( + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb'), + a_reporter => cast(null as ut3.ut_reporter_base)); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure run_func_empty_suite is + l_results ut3.ut_varchar2_list; + l_expected varchar2(32767); + pragma autonomous_transaction; + begin + --Arrange + execute immediate q'[create or replace package empty_suite as + -- %suite + + procedure not_a_test; + end;]'; + execute immediate q'[create or replace package body empty_suite as + procedure not_a_test is begin null; end; + end;]'; + l_expected := '%empty_suite%0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'; + --Act + select * bulk collect into l_results from table(ut3.ut.run('empty_suite')); + + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); + + --Cleanup + execute immediate q'[drop package empty_suite]'; + end; + + procedure raise_in_invalid_state is + l_results ut3.ut_varchar2_list; + l_expected varchar2(32767); + begin + --Arrange + l_expected := 'test_state + test_stateful + failing_stateful_test [% sec] (FAILED - 1)% +Failures:% + 1) failing_stateful_test + ORA-04068: existing state of packages (DB_LOOPBACK%) has been discarded + ORA-04061: existing state of package body "%.STATEFUL_PACKAGE" has been invalidated + ORA-04065: not executed, altered or dropped package body "%.STATEFUL_PACKAGE"% + ORA-06512: at line 6% +1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)%'; + + --Act + select * bulk collect into l_results from table(ut3.ut.run('ut3_tester_helper.test_stateful')); + + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); + ut.fail('Expected exception but nothing was raised'); + exception + when others then + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); + ut.expect(sqlcode).to_equal(-4068); + end; + + procedure create_test_suite is + begin + ut3_tester_helper.run_helper.create_test_suite; + end; + + procedure drop_test_suite is + begin + ut3_tester_helper.run_helper.drop_test_suite; + end; + + procedure run_in_invalid_state is + l_results ut3.ut_varchar2_list; + l_actual clob; + l_expected varchar2(32767); + begin + select * bulk collect into l_results from table(ut3.ut.run('failing_invalid_spec')); + + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like('%Call params for % are not valid: package %FAILING_INVALID_SPEC% does not exist or is invalid.%'); + + end; + + procedure compile_invalid_package is + ex_compilation_error exception; + pragma exception_init(ex_compilation_error,-24344); + pragma autonomous_transaction; + begin + begin + execute immediate q'[ + create or replace package failing_invalid_spec as + --%suite + gv_glob_val non_existing_table.id%type := 0; + + --%test + procedure test1; + end;]'; + exception when ex_compilation_error then null; + end; + begin + execute immediate q'[ + create or replace package body failing_invalid_spec as + procedure test1 is begin ut.expect(1).to_equal(1); end; + end;]'; + exception when ex_compilation_error then null; + end; + end; + procedure drop_invalid_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package failing_invalid_spec'; + end; + + procedure run_and_revalidate_specs is + l_results ut3.ut_varchar2_list; + l_actual clob; + l_is_invalid number; + begin + execute immediate q'[select count(1) from all_objects o where o.owner = :object_owner and o.object_type = 'PACKAGE' + and o.status = 'INVALID' and o.object_name= :object_name]' into l_is_invalid + using 'UT3$USER#','INVALID_PCKAG_THAT_REVALIDATES'; + + select * bulk collect into l_results from table(ut3.ut.run('invalid_pckag_that_revalidates')); + + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(1).to_equal(l_is_invalid); + ut.expect(l_actual).to_be_like('%invalid_pckag_that_revalidates%invalidspecs [% sec]% +%Finished in % seconds% +%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + + end; + + procedure generate_invalid_spec is + ex_compilation_error exception; + pragma exception_init(ex_compilation_error,-24344); + pragma autonomous_transaction; + begin + + execute immediate q'[ + create or replace package parent_specs as + c_test constant varchar2(1) := 'Y'; + end;]'; + + execute immediate q'[ + create or replace package invalid_pckag_that_revalidates as + --%suite + g_var varchar2(1) := parent_specs.c_test; + + --%test(invalidspecs) + procedure test1; + end;]'; + + execute immediate q'[ + create or replace package body invalid_pckag_that_revalidates as + procedure test1 is begin ut.expect('Y').to_equal(g_var); end; + end;]'; + + -- That should invalidate test package and we can then revers + execute immediate q'[ + create or replace package parent_specs as + c_test_error constant varchar2(1) := 'Y'; + end;]'; + + execute immediate q'[ + create or replace package parent_specs as + c_test constant varchar2(1) := 'Y'; + end;]'; + + end; + procedure drop_invalid_spec is + pragma autonomous_transaction; + begin + execute immediate 'drop package invalid_pckag_that_revalidates'; + execute immediate 'drop package parent_specs'; + end; + + procedure run_and_report_warnings is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + + select * bulk collect into l_results from table(ut3.ut.run('bad_annotations')); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + + ut.expect(l_actual).to_be_like('%Invalid annotation "--%context". Cannot find following "--%endcontext". Annotation ignored.% +%1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s)%'); + + end; + + procedure create_bad_annot is + pragma autonomous_transaction; + begin + execute immediate q'[ + create or replace package bad_annotations as + --%suite + + --%context + + --%test(invalidspecs) + procedure test1; + + end;]'; + + execute immediate q'[ + create or replace package body bad_annotations as + procedure test1 is begin ut.expect(1).to_equal(1); end; + end;]'; + + end; + + procedure drop_bad_annot is + pragma autonomous_transaction; + begin + execute immediate 'drop package bad_annotations'; + end; + + procedure create_suite_with_link is + begin + ut3_tester_helper.run_helper.create_suite_with_link; + end; + + procedure drop_suite_with_link is + begin + ut3_tester_helper.run_helper.drop_suite_with_link; + end; + + procedure savepoints_on_db_links is + l_results clob; + begin + ut3.ut.run('ut3_tester_helper.test_distributed_savepoint'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + ut.expect(l_results).to_be_like('%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); + end; + + procedure remove_time_from_results(a_results in out nocopy ut3.ut_varchar2_list) is + begin + for i in 1 .. a_results.count loop + a_results(i) := regexp_replace(a_results(i),'\[[0-9]*[\.,][0-9]+ sec\]',''); + a_results(i) := regexp_replace(a_results(i),'Finished in [0-9]*[\.,][0-9]+ seconds',''); + end loop; + end; + + procedure run_schema_name_test is + l_results ut3.ut_varchar2_list; + l_expected clob; + begin + select * bulk collect into l_results + from table ( ut3.ut.run( g_owner||'.'||g_owner ) ); + l_expected := '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'; + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); + end; + + procedure create_schema_name_package is + pragma autonomous_transaction; + begin + execute immediate ' + create or replace package '||g_owner||'.'||g_owner||' as + --%suite + + --%test + procedure sample_test; + end;'; + + execute immediate ' + create or replace package body '||g_owner||'.'||g_owner||' as + procedure sample_test is begin ut.expect(1).to_equal(1); end; + end;'; + + end; + + procedure drop_schema_name_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package '||g_owner||'.'||g_owner; + end; + + procedure run_with_random_order is + l_random_results ut3.ut_varchar2_list; + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_random_results + from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ) + where trim(column_value) is not null and column_value not like 'Finished in %' + and column_value not like '%Tests were executed with random order %'; + + select * bulk collect into l_results + from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1' ) ) + --TODO this condition should be removed once issues with unordered compare and 'blank text rows' are resolved. + where trim(column_value) is not null and column_value not like 'Finished in %'; + + remove_time_from_results(l_results); + remove_time_from_results(l_random_results); + + ut.expect(anydata.convertCollection(l_random_results)).to_equal(anydata.convertCollection(l_results)).unordered(); + ut.expect(anydata.convertCollection(l_random_results)).not_to_equal(anydata.convertCollection(l_results)); + end; + + procedure run_and_report_random_ord_seed is + l_actual ut3.ut_varchar2_list; + begin + select * bulk collect into l_actual + from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 123456789 ) ); + + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_actual) ).to_be_like( q'[%Tests were executed with random order seed '123456789'.%]' ); + end; + + procedure run_with_random_order_seed is + l_expected ut3.ut_varchar2_list; + l_actual ut3.ut_varchar2_list; + begin + + select * bulk collect into l_expected + from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); + select * bulk collect into l_actual + from table ( ut3.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); + + remove_time_from_results(l_actual); + remove_time_from_results(l_expected); + l_actual.delete(l_actual.count); + l_expected.delete(l_expected.count); + + ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + end; + + procedure test_run_by_one_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'suite1test1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure suite_run_by_one_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'suite2'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).not_to_be_like( '%test_package_1.%executed%' ); + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).to_be_like( '%test_package_2.%executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3.%executed%' ); + end; + + procedure two_test_run_by_one_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'test2'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).not_to_be_like( '%test_package_1.%executed%' ); + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).to_be_like( '%test_package_2.%executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3.%executed%' ); + end; + + procedure all_suites_run_by_one_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'helper'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).to_be_like( '%test_package_3%' ); + end; + + procedure two_test_run_by_two_tags is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'subtest1,subtest2'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_1.test2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2.test2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure suite_with_children_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'suite1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure suite_with_tag_parent is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'suite2'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure test_nonexists_tag is + l_results clob; + l_exp_message varchar2(4000); + begin + ut3_tester_helper.run_helper.run(a_tags => 'nonexisting'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + ut.expect( l_results ).not_to_be_like( '%test_package_1%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure test_duplicate_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'suite1test1,suite1test1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure suite_duplicate_tag is + l_results clob; + begin + ut3_tester_helper.run_helper.run(a_tags => 'suite1,suite1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_proc_pkg_name_tag is + l_results clob; + begin + ut3.ut.run('ut3_tester_helper.test_package_1',a_tags => 'suite1test1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_1.test2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_pkg_name_file_list_tag is + l_results clob; + begin + ut3.ut.run('ut3_tester_helper.test_package_1',a_tags => 'suite1test1'); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%test_package_1%' ); + ut.expect( l_results ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_1.test2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_package_3%' ); + end; + + procedure run_proc_path_list_tag is + l_results clob; + begin + ut3.ut.run( + 'ut3_tester_helper.test_package_1', + ut3.ut_sonar_test_reporter(), a_source_files => ut3.ut_varchar2_list(),a_tags => 'suite1', + a_test_files => ut3.ut_varchar2_list('tests/ut3_tester_helper.test_package_1.pkb', + 'tests/ut3_tester_helper.test_package_2.pkb', + 'tests/ut3_tester_helper.test_package_3.pkb') + ); + l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + --Assert + ut.expect( l_results ).to_be_like( '%tests/ut3_tester_helper.test_package_1.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3_tester_helper.test_package_2.pkb%' ); + ut.expect( l_results ).not_to_be_like( '%tests/ut3_tester_helper.test_package_3.pkb%' ); + end; + + procedure tag_run_func_no_params is + l_results ut3.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(a_tags => 'helper'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%test_package_2%test_package_3%' ); + end; + + procedure tag_run_func_pkg_name is + l_results ut3.ut_varchar2_list; + begin + select * bulk collect into l_results from table (ut3.ut.run('ut3_tester_helper.test_package_1', a_tags => 'suite1test1')); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + + procedure tag_run_func_path_list is + l_results ut3.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run(ut3.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => 'suite1test1,suite2test1'); + --Assert + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_1.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test1%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test2%executed%' ); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3%' ); + end; + +end; +/ diff --git a/test/api/test_ut_run.pks b/test/ut3_user/api/test_ut_run.pks similarity index 68% rename from test/api/test_ut_run.pks rename to test/ut3_user/api/test_ut_run.pks index 55d19e866..406c70b09 100644 --- a/test/api/test_ut_run.pks +++ b/test/ut3_user/api/test_ut_run.pks @@ -1,17 +1,19 @@ create or replace package test_ut_run is --%suite(ut.run) - --%suitepath(utplsql.api) - + --%suitepath(utplsql.test_user.api) + procedure clear_expectations; + + procedure create_ut3$user#_tests; + procedure drop_ut3$user#_tests; + --%test(ut.version() returns version of the framework) procedure ut_version; --%test(ut.fail() marks test as failed) + --%aftertest(clear_expectations) procedure ut_fail; - procedure create_ut3$user#_tests; - procedure drop_ut3$user#_tests; - --%context(ut_run_procedure) --%displayname(ut.run() procedure options) --%beforeall(create_ut3$user#_tests) @@ -56,12 +58,13 @@ create or replace package test_ut_run is --%aftertest(drop_failing_beforeall_suite) procedure run_proc_fail_child_suites; + procedure create_suite_with_link; + procedure drop_suite_with_link; + --%test(Savepoints are working properly on distributed transactions - Issue #839) --%beforetest(create_suite_with_link) --%aftertest(drop_suite_with_link) procedure savepoints_on_db_links; - procedure create_suite_with_link; - procedure drop_suite_with_link; --%endcontext @@ -82,6 +85,7 @@ create or replace package test_ut_run is --%context(ut_run_function) + --%displayname(ut.run() function options) --%beforeall(create_ut3$user#_tests) --%afterall(drop_ut3$user#_tests) @@ -142,7 +146,89 @@ create or replace package test_ut_run is procedure run_and_report_warnings; procedure create_bad_annot; procedure drop_bad_annot; + + --%test(Can run test package that is named the same as schema name) + --%beforetest(create_schema_name_package) + --%aftertest(drop_schema_name_package) + procedure run_schema_name_test; + procedure create_schema_name_package; + procedure drop_schema_name_package; + + --%endcontext + + --%context(random_order) + + --%displayname(Random test execution order) + --%beforeall(create_ut3$user#_tests) + --%afterall(drop_ut3$user#_tests) + + --%test(Runs tests in random order) + procedure run_with_random_order; + + --%test(Reports test random_test_order_seed) + procedure run_and_report_random_ord_seed; + + --%test(Runs tests in the same random order with provided seed) + procedure run_with_random_order_seed; + --%endcontext + --%context(run with tags) + + --%displayname(Call ut.run with #tags) + --%beforeall(create_ut3$user#_tests) + --%afterall(drop_ut3$user#_tests) + + --%test(Execute test by tag ut_run) + procedure test_run_by_one_tag; + + --%test( Execute suite by one tag) + procedure suite_run_by_one_tag; + + --%test(Execute two tests by one tag) + procedure two_test_run_by_one_tag; + + --%test(Execute all suites tests with tag) + procedure all_suites_run_by_one_tag; + + --%test(Execute tests by passing two tags) + procedure two_test_run_by_two_tags; + + --%test(Execute suite and all of its children) + procedure suite_with_children_tag; + + --%test(Execute suite and parents) + procedure suite_with_tag_parent; + + --%test(Execute test for non existing tag) + procedure test_nonexists_tag; + + --%test(Execute test for duplicate list tags) + procedure test_duplicate_tag; + + --%test(Execute suite test for duplicate list tags) + procedure suite_duplicate_tag; + + --%test(Runs given package only with package name given as path and filter by tag) + procedure run_proc_pkg_name_tag; + + --%test(Runs all from given package with package name given as path and coverage file list with tag) + procedure run_pkg_name_file_list_tag; + + --%test(Runs tests from given paths with paths list and tag) + procedure run_proc_path_list_tag; + + --%test(Runs all tests in current schema with default reporter when only tag is given) + procedure tag_run_func_no_params; + + --%test(Runs given package only with package name given as path and filter by tag) + procedure tag_run_func_pkg_name; + + --%test(Runs tests from given paths with paths list and a tag) + procedure tag_run_func_path_list; + + --%endcontext + end; / + diff --git a/test/api/test_ut_runner.pkb b/test/ut3_user/api/test_ut_runner.pkb similarity index 73% rename from test/api/test_ut_runner.pkb rename to test/ut3_user/api/test_ut_runner.pkb index 79c78d911..2baf4cbeb 100644 --- a/test/api/test_ut_runner.pkb +++ b/test/ut3_user/api/test_ut_runner.pkb @@ -1,48 +1,28 @@ create or replace package body test_ut_runner is procedure setup_cache_objects is - pragma autonomous_transaction; begin - execute immediate q'[create or replace package dummy_test_package as - --%suite(dummy_test_suite) - --%rollback(manual) - - --%test(dummy_test) - --%beforetest(some_procedure) - procedure some_dummy_test_procedure; - end;]'; - execute immediate q'[create or replace procedure dummy_test_procedure as - --%some_annotation(some_text) - --%rollback(manual) - begin - null; - end;]'; - execute immediate q'[create or replace procedure ut3.dummy_test_procedure as - --%some_annotation(some_text) - --%rollback(manual) - begin - null; - end;]'; + ut3_tester_helper.run_helper.setup_cache_objects(); + end; + + procedure setup_cache_objectstag is + begin + ut3_tester_helper.run_helper.setup_cache_objectstag(); + end; + + procedure setup_cache_twotags is + begin + ut3_tester_helper.run_helper.setup_cache_twotags(); end; procedure setup_cache is - pragma autonomous_transaction; begin - setup_cache_objects(); - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PROCEDURE'); - ut3.ut_annotation_manager.rebuild_annotation_cache('UT3','PROCEDURE'); + ut3_tester_helper.run_helper.setup_cache(); end; procedure cleanup_cache is - pragma autonomous_transaction; begin - delete from ut3.ut_annotation_cache_info - where object_type = 'PROCEDURE' and object_owner in ('UT3',user) - or object_type = 'PACKAGE' and object_owner = user and object_name = 'DUMMY_TEST_PACKAGE'; - execute immediate q'[drop package dummy_test_package]'; - execute immediate q'[drop procedure dummy_test_procedure]'; - execute immediate q'[drop procedure ut3.dummy_test_procedure]'; + ut3_tester_helper.run_helper.cleanup_cache(); end; procedure create_test_spec @@ -99,6 +79,7 @@ end;'; procedure close_newly_opened_transaction is l_output_data dbms_output.chararr; l_num_lines integer := 100000; + pragma autonomous_transaction; begin --Arrange create_test_spec(); @@ -171,7 +152,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run('test_cache')); --Assert - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); l_expected := '%ut3.ut.expect(1).to_be_null;%'; ut.expect(l_actual).to_be_like(l_expected); drop_test_package(); @@ -220,26 +201,26 @@ end;'; open l_actual for select * from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PROCEDURE'; + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PROCEDURE'; ut.expect(l_actual).not_to_be_empty(); --Act - ut3.ut_runner.purge_cache(user,'PROCEDURE'); + ut3.ut_runner.purge_cache(sys_context('USERENV', 'CURRENT_USER'),'PROCEDURE'); --Assert open l_actual for select * from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PROCEDURE'; + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PROCEDURE'; --Cache purged for object owner/type ut.expect(l_actual).to_be_empty(); open l_actual for select * from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE'; + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE'; --Cache not purged for other types ut.expect(l_actual).not_to_be_empty(); open l_actual for select * from ut3.ut_annotation_cache_info - where object_owner = 'UT3' and object_type = 'PROCEDURE'; + where object_owner = 'UT3_TESTER_HELPER' and object_type = 'PROCEDURE'; --Cache not purged for other owners ut.expect(l_actual).not_to_be_empty(); @@ -249,42 +230,86 @@ end;'; l_actual integer; begin --Act - ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE'); + ut3.ut_runner.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); --Assert select count(1) into l_actual from ut3.ut_annotation_cache_info i join ut3.ut_annotation_cache c on c.cache_id = i.cache_id - where object_owner = user and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; - --Rebuild cache for user/packages + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; + --Rebuild cache for sys_context('USERENV', 'CURRENT_USER')/packages ut.expect(l_actual).to_equal(4); select count(1) into l_actual from ut3.ut_annotation_cache_info i join ut3.ut_annotation_cache c on c.cache_id = i.cache_id - where object_owner = 'UT3' and object_type = 'PROCEDURE'; + where object_owner = 'UT3_TESTER_HELPER' and object_type = 'PROCEDURE'; --Did not rebuild cache for ut3/procedures ut.expect(l_actual).to_equal(0); end; - procedure test_get_suites_info is + procedure test_get_suites_info_notag is l_expected sys_refcursor; l_actual sys_refcursor; begin --Arrange open l_expected for select - 'UT3_TESTER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, - 'dummy_test_package' path, 0 disabled_flag + 'dummy_test_package' path, 0 disabled_flag,null tags from dual union all select - 'UT3_TESTER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, 'dummy_test' item_description, 'UT_TEST' item_type, 5 item_line_no, - 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag + 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,null tags + from dual; + --Act + open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure test_get_suites_info_tag is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'dummy_test_package' path, 0 disabled_flag,'dummy' tags + from dual union all + select + 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, + 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,'testtag' tags from dual; --Act - open l_actual for select * from table(ut3.ut_runner.get_suites_info(NULL,'DUMMY_TEST_PACKAGE')); + open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure test_get_suites_info_twotag is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'dummy_test_package' path, 0 disabled_flag,'suitetag1,suitetag2' tags + from dual union all + select + 'UT3$USER#' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, + 'dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag,'testtag1,testtag2' tags + from dual; + --Act + open l_actual for select * from table(ut3.ut_runner.get_suites_info('UT3$USER#','DUMMY_TEST_PACKAGE')); --Assert ut.expect(l_actual).to_equal(l_expected); end; @@ -315,47 +340,21 @@ end;'; end; procedure db_link_cleanup is - begin - begin execute immediate 'drop public database link db_loopback'; exception when others then null; end; - begin execute immediate 'drop package test_db_link'; exception when others then null; end; - end; + pragma autonomous_transaction; + begin + ut3_tester_helper.run_helper.db_link_cleanup(); + end; procedure db_link_setup is - l_service_name varchar2(100); - begin - select global_name into l_service_name from global_name; - execute immediate - 'create public database link db_loopback connect to ut3_tester identified by ut3 - using ''(DESCRIPTION= - (ADDRESS=(PROTOCOL=TCP) - (HOST='||sys_context('userenv','SERVER_HOST')||') - (PORT=1521) - ) - (CONNECT_DATA=(SERVICE_NAME='||l_service_name||')))'''; - execute immediate q'[ - create or replace package test_db_link is - --%suite - - --%test - procedure runs_with_db_link; - end;]'; - - execute immediate q'[ - create or replace package body test_db_link is - procedure runs_with_db_link is - a_value integer; - begin - select 1 into a_value - from dual@db_loopback; - ut3.ut.expect(a_value).to_be_null(); - end; - end;]'; - - end; + pragma autonomous_transaction; + begin + ut3_tester_helper.run_helper.db_link_setup(); + end; procedure raises_20213_on_fail_link is l_reporter ut3.ut_documentation_reporter := ut3.ut_documentation_reporter(); l_lines ut3.ut_varchar2_list; + pragma autonomous_transaction; begin --Arrange --Act @@ -448,7 +447,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1','test_csl_names2'))); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -461,7 +460,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run('test_csl_names1')); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -474,7 +473,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run('test_csl_names1,test_csl_names2')); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %4 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -487,7 +486,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -500,7 +499,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -520,7 +519,7 @@ end;'; ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -533,7 +532,7 @@ end;'; bulk collect into l_results from table(ut3.ut.run(ut3.ut_varchar2_list('test_csl_names1.one_is_one,test_csl_names2.one_is_one'))); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like('%Finished in % seconds %2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%'); end; @@ -542,19 +541,19 @@ end;'; begin ut.expect( ut3.ut_runner.is_test( - a_owner => 'UT3_TESTER', + a_owner => 'UT3$USER#', a_package_name => 'DUMMY_TEST_PACKAGE', a_procedure_name => 'SOME_DUMMY_TEST_PROCEDURE' ) ).to_be_true(); - ut.expect( ut3.ut_runner.is_test( 'ut3_tester','dummy_test_package','some_dummy_test_procedure' ) ).to_be_true(); + ut.expect( ut3.ut_runner.is_test( 'ut3$user#','dummy_test_package','some_dummy_test_procedure' ) ).to_be_true(); end; procedure is_test_false is begin - ut.expect( ut3.ut_runner.is_test( 'UT3_TESTER','DUMMY_TEST_PACKAGE', 'BAD' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_test( 'UT3_TESTER','DUMMY_TEST_PACKAGE', null ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_test( 'UT3_TESTER',null,'some_dummy_test_procedure' ) ).to_be_false(); + ut.expect( ut3.ut_runner.is_test( 'UT3$USER#','DUMMY_TEST_PACKAGE', 'BAD' ) ).to_be_false(); + ut.expect( ut3.ut_runner.is_test( 'UT3$USER#','DUMMY_TEST_PACKAGE', null ) ).to_be_false(); + ut.expect( ut3.ut_runner.is_test( 'UT3$USER#',null,'some_dummy_test_procedure' ) ).to_be_false(); ut.expect( ut3.ut_runner.is_test( null,'DUMMY_TEST_PACKAGE','some_dummy_test_procedure' ) ).to_be_false(); end; @@ -562,26 +561,26 @@ end;'; begin ut.expect( ut3.ut_runner.is_suite( - a_owner => 'UT3_TESTER', + a_owner => 'UT3$USER#', a_package_name => 'DUMMY_TEST_PACKAGE' ) ).to_be_true(); - ut.expect( ut3.ut_runner.is_suite( 'ut3_tester','dummy_test_package' ) ).to_be_true(); + ut.expect( ut3.ut_runner.is_suite( 'ut3$user#','dummy_test_package' ) ).to_be_true(); end; procedure is_suite_false is begin - ut.expect( ut3.ut_runner.is_suite( 'UT3_TESTER','BAD' ) ).to_be_false(); - ut.expect( ut3.ut_runner.is_suite( 'UT3_TESTER', null ) ).to_be_false(); + ut.expect( ut3.ut_runner.is_suite( 'UT3$USER#','BAD' ) ).to_be_false(); + ut.expect( ut3.ut_runner.is_suite( 'UT3$USER#', null ) ).to_be_false(); ut.expect( ut3.ut_runner.is_suite( null,'DUMMY_TEST_PACKAGE' ) ).to_be_false(); end; procedure has_suites_true is begin - ut.expect( ut3.ut_runner.has_suites( a_owner => 'UT3_TESTER' ) ).to_be_true(); + ut.expect( ut3.ut_runner.has_suites( a_owner => 'UT3$USER#' ) ).to_be_true(); - ut.expect( ut3.ut_runner.has_suites( 'ut3_tester' ) ).to_be_true(); + ut.expect( ut3.ut_runner.has_suites( 'ut3$user#' ) ).to_be_true(); end; procedure has_suites_false is diff --git a/test/api/test_ut_runner.pks b/test/ut3_user/api/test_ut_runner.pks similarity index 85% rename from test/api/test_ut_runner.pks rename to test/ut3_user/api/test_ut_runner.pks index d67ee45fc..08282e997 100644 --- a/test/api/test_ut_runner.pks +++ b/test/ut3_user/api/test_ut_runner.pks @@ -1,7 +1,7 @@ create or replace package test_ut_runner is --%suite(ut_runner) - --%suitepath(utplsql.api) + --%suitepath(utplsql.test_user.api) --%rollback(manual) --%test(transaction stays open after the run if it was opened before the run) @@ -41,16 +41,29 @@ create or replace package test_ut_runner is procedure test_purge_cache_schema_type; procedure setup_cache_objects; + procedure setup_cache_objectstag; + procedure setup_cache_twotags; --%test(Rebuilds cache for a given schema and object type) --%beforetest(setup_cache_objects) --%aftertest(cleanup_cache) + --%DISABLED(TODO -disable trigger for this test to pass) procedure test_rebuild_cache_schema_type; --%test(get_suites_info returns a cursor containing records for a newly created test) --%beforetest(setup_cache_objects) --%aftertest(cleanup_cache) - procedure test_get_suites_info; + procedure test_get_suites_info_notag; + + --%test(get_suites_info returns a cursor containing records for a newly created test with tag) + --%beforetest(setup_cache_objectstag) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_tag; + + --%test(get_suites_info returns a cursor containing records for a newly created test with two tags) + --%beforetest(setup_cache_twotags) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_twotag; --%test(get_reporters_list returns a cursor containing all built-in reporters and information about output-reporter) --%beforetest(setup_cache_objects) diff --git a/test/core/expectations/binary/test_be_greater_or_equal.pkb b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb similarity index 69% rename from test/core/expectations/binary/test_be_greater_or_equal.pkb rename to test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb index f41878643..5d99d07b6 100644 --- a/test/core/expectations/binary/test_be_greater_or_equal.pkb +++ b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb @@ -2,7 +2,7 @@ create or replace package body test_be_greater_or_equal is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; function to_greater_equal_block( @@ -11,7 +11,7 @@ create or replace package body test_be_greater_or_equal is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'to_be_greater_or_equal', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -22,7 +22,7 @@ create or replace package body test_be_greater_or_equal is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'not_to_be_greater_or_equal', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -32,7 +32,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_number_greater is @@ -40,7 +40,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ym_greater is @@ -48,7 +48,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ds_greater is @@ -56,7 +56,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_greater is @@ -64,7 +64,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_tz_greater is @@ -72,7 +72,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_ltz_greater is @@ -80,7 +80,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_date_equal is @@ -88,7 +88,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('date', 'sysdate', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_number_equal is @@ -96,7 +96,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('number', '2.0', '2.00'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ym_equal is @@ -104,7 +104,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('interval year to month', '''2-1''', '''2-1'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ds_equal is @@ -112,7 +112,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_equal is @@ -120,7 +120,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_tz_equal is @@ -128,7 +128,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_ltz_equal is @@ -136,7 +136,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_date_less is @@ -144,7 +144,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('date', 'sysdate-1', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_number_less is @@ -152,7 +152,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('number', '1.0', '1.01'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ym_less is @@ -160,7 +160,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('interval year to month', '''2-1''', '''2-2'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ds_less is @@ -168,7 +168,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_less is @@ -176,7 +176,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_tz_less is @@ -184,7 +184,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_ltz_less is @@ -192,7 +192,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate to_greater_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_date_greater is @@ -200,7 +200,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_number_greater is @@ -208,7 +208,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_interval_ym_greater is @@ -216,7 +216,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_interval_ds_greater is @@ -224,7 +224,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_timestamp_greater is @@ -232,7 +232,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_timestamp_tz_gretr is @@ -240,7 +240,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_timestamp_ltz_gretr is @@ -248,7 +248,7 @@ create or replace package body test_be_greater_or_equal is --Act execute immediate not_to_greater_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_clob is @@ -256,7 +256,7 @@ create or replace package body test_be_greater_or_equal is --Act ut3.ut.expect(to_clob('3')).to_( ut3.be_greater_or_equal(3) ); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/core/expectations/binary/test_be_greater_or_equal.pks b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pks similarity index 98% rename from test/core/expectations/binary/test_be_greater_or_equal.pks rename to test/ut3_user/expectations/binary/test_be_greater_or_equal.pks index 077dff59c..3f51e8e3f 100644 --- a/test/core/expectations/binary/test_be_greater_or_equal.pks +++ b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pks @@ -1,7 +1,7 @@ create or replace package test_be_greater_or_equal is --%suite((not)to_be_greater_or_equal) - --%suitepath(utplsql.core.expectations.binary) + --%suitepath(utplsql.test_user.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/binary/test_be_greater_than.pkb b/test/ut3_user/expectations/binary/test_be_greater_than.pkb similarity index 68% rename from test/core/expectations/binary/test_be_greater_than.pkb rename to test/ut3_user/expectations/binary/test_be_greater_than.pkb index 5863b11b1..37e15f633 100644 --- a/test/core/expectations/binary/test_be_greater_than.pkb +++ b/test/ut3_user/expectations/binary/test_be_greater_than.pkb @@ -2,7 +2,7 @@ create or replace package body test_be_greater_than is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; function to_greater_than_block( @@ -11,7 +11,7 @@ create or replace package body test_be_greater_than is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'to_be_greater_than', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -22,7 +22,7 @@ create or replace package body test_be_greater_than is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'not_to_be_greater_than', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -32,7 +32,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_number_greater is @@ -40,7 +40,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ym_greater is @@ -48,7 +48,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ds_greater is @@ -56,7 +56,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_greater is @@ -64,7 +64,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_tz_greater is @@ -72,7 +72,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_ltz_greater is @@ -80,7 +80,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_date_equal is @@ -88,7 +88,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('date', 'sysdate', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_number_equal is @@ -96,7 +96,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('number', '2.0', '2.00'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ym_equal is @@ -104,7 +104,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('interval year to month', '''2-1''', '''2-1'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ds_equal is @@ -112,7 +112,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_equal is @@ -120,7 +120,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_tz_equal is @@ -128,7 +128,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_ltz_equal is @@ -136,7 +136,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_date_less is @@ -144,7 +144,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('date', 'sysdate-1', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_number_less is @@ -152,7 +152,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('number', '1.0', '1.01'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ym_less is @@ -160,7 +160,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('interval year to month', '''2-1''', '''2-2'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ds_less is @@ -168,7 +168,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_less is @@ -176,7 +176,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_tz_less is @@ -184,7 +184,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_ltz_less is @@ -192,7 +192,7 @@ create or replace package body test_be_greater_than is --Act execute immediate to_greater_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_date_greater is @@ -200,7 +200,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_number_greater is @@ -208,7 +208,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_interval_ym_greater is @@ -216,7 +216,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_interval_ds_greater is @@ -224,7 +224,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_timestamp_greater is @@ -232,7 +232,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_timestamp_tz_gretr is @@ -240,7 +240,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_actual_timestamp_ltz_gretr is @@ -248,7 +248,7 @@ create or replace package body test_be_greater_than is --Act execute immediate not_to_greater_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_clob is @@ -256,7 +256,7 @@ create or replace package body test_be_greater_than is --Act ut3.ut.expect(to_clob('3')).to_( ut3.be_greater_than(2) ); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/core/expectations/binary/test_be_greater_than.pks b/test/ut3_user/expectations/binary/test_be_greater_than.pks similarity index 98% rename from test/core/expectations/binary/test_be_greater_than.pks rename to test/ut3_user/expectations/binary/test_be_greater_than.pks index 6a1dfcc3e..fb158dddb 100644 --- a/test/core/expectations/binary/test_be_greater_than.pks +++ b/test/ut3_user/expectations/binary/test_be_greater_than.pks @@ -1,7 +1,7 @@ create or replace package test_be_greater_than is --%suite((not)to_be_greater_than) - --%suitepath(utplsql.core.expectations.binary) + --%suitepath(utplsql.test_user.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/binary/test_be_less_or_equal.pkb b/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb similarity index 69% rename from test/core/expectations/binary/test_be_less_or_equal.pkb rename to test/ut3_user/expectations/binary/test_be_less_or_equal.pkb index c72e0039b..bf7632cc4 100644 --- a/test/core/expectations/binary/test_be_less_or_equal.pkb +++ b/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb @@ -2,7 +2,7 @@ create or replace package body test_be_less_or_equal is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; function to_less_or_equal_block( @@ -11,7 +11,7 @@ create or replace package body test_be_less_or_equal is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'to_be_less_or_equal', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -22,7 +22,7 @@ create or replace package body test_be_less_or_equal is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'not_to_be_less_or_equal', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -32,7 +32,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_number_greater is @@ -40,7 +40,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ym_greater is @@ -48,7 +48,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ds_greater is @@ -56,7 +56,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_greater is @@ -64,7 +64,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_tz_greater is @@ -72,7 +72,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_ltz_greater is @@ -80,7 +80,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_date_equal is @@ -88,7 +88,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('date', 'sysdate', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_number_equal is @@ -96,7 +96,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('number', '2.0', '2.00'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ym_equal is @@ -104,7 +104,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('interval year to month', '''2-1''', '''2-1'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ds_equal is @@ -112,7 +112,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_equal is @@ -120,7 +120,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_tz_equal is @@ -128,7 +128,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_ltz_equal is @@ -136,7 +136,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_date_less is @@ -144,7 +144,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('date', 'sysdate-1', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_number_less is @@ -152,7 +152,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('number', '1.0', '1.01'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ym_less is @@ -160,7 +160,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('interval year to month', '''2-1''', '''2-2'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ds_less is @@ -168,7 +168,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_less is @@ -176,7 +176,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_tz_less is @@ -184,7 +184,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_ltz_less is @@ -192,7 +192,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate to_less_or_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_date_greater is @@ -200,7 +200,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_number_greater is @@ -208,7 +208,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_interval_ym_greater is @@ -216,7 +216,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_interval_ds_greater is @@ -224,7 +224,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_timestamp_greater is @@ -232,7 +232,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_timestamp_tz_gretr is @@ -240,7 +240,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_timestamp_ltz_gretr is @@ -248,7 +248,7 @@ create or replace package body test_be_less_or_equal is --Act execute immediate not_to_less_or_equal_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_clob is @@ -256,7 +256,7 @@ create or replace package body test_be_less_or_equal is --Act ut3.ut.expect(to_clob('3')).to_( ut3.be_less_or_equal(3) ); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/core/expectations/binary/test_be_less_or_equal.pks b/test/ut3_user/expectations/binary/test_be_less_or_equal.pks similarity index 98% rename from test/core/expectations/binary/test_be_less_or_equal.pks rename to test/ut3_user/expectations/binary/test_be_less_or_equal.pks index a6ab01664..d6baf037e 100644 --- a/test/core/expectations/binary/test_be_less_or_equal.pks +++ b/test/ut3_user/expectations/binary/test_be_less_or_equal.pks @@ -1,7 +1,7 @@ create or replace package test_be_less_or_equal is --%suite((not)to_be_less_or_equal) - --%suitepath(utplsql.core.expectations.binary) + --%suitepath(utplsql.test_user.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/binary/test_equal.pkb b/test/ut3_user/expectations/binary/test_equal.pkb similarity index 95% rename from test/core/expectations/binary/test_equal.pkb rename to test/ut3_user/expectations/binary/test_equal.pkb index dd7dd7a82..95fd594c7 100644 --- a/test/core/expectations/binary/test_equal.pkb +++ b/test/ut3_user/expectations/binary/test_equal.pkb @@ -2,12 +2,12 @@ create or replace package body test_equal is procedure reset_nulls_equal is begin - ut3.ut_expectation_processor.nulls_Are_equal(ut3.ut_expectation_processor.gc_default_nulls_are_equal); + ut3_tester_helper.main_helper.reset_nulls_equal; end; procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; function to_equal_block( @@ -40,7 +40,7 @@ create or replace package body test_equal is begin execute immediate to_equal_block( 'to_equal', a_actual_type, a_expected_type, a_actual, a_expected, a_nulls_equal ); - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); cleanup_expectations; end; @@ -65,7 +65,7 @@ create or replace package body test_equal is begin execute immediate to_equal_block( 'to_equal', a_actual_type, a_expected_type, a_actual, a_expected, a_nulls_equal ); - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); cleanup_expectations; end; @@ -79,7 +79,7 @@ create or replace package body test_equal is begin execute immediate to_equal_block( 'not_to_equal', a_actual_type, a_expected_type, a_actual, a_expected, a_nulls_equal ); - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); cleanup_expectations; end; @@ -200,7 +200,7 @@ create or replace package body test_equal is procedure failure_on_both_null_with_conf is begin - ut3.ut_expectation_processor.nulls_Are_equal(false); + ut3_tester_helper.main_helper.nulls_are_equal(false); test_to_equal_fail('blob', 'NULL', 'NULL'); test_to_equal_fail('boolean', 'NULL', 'NULL'); test_to_equal_fail('clob', 'NULL', 'NULL'); @@ -246,7 +246,7 @@ create or replace package body test_equal is procedure success_on_both_null_with_parm is begin - ut3.ut_expectation_processor.nulls_Are_equal(false); + ut3_tester_helper.main_helper.nulls_are_equal(false); test_to_equal_success('blob', 'NULL', 'NULL', true); test_to_equal_success('boolean', 'NULL', 'NULL', true); test_to_equal_success('clob', 'NULL', 'NULL', true); diff --git a/test/core/expectations/binary/test_equal.pks b/test/ut3_user/expectations/binary/test_equal.pks similarity index 95% rename from test/core/expectations/binary/test_equal.pks rename to test/ut3_user/expectations/binary/test_equal.pks index c0280c288..923d43a31 100644 --- a/test/core/expectations/binary/test_equal.pks +++ b/test/ut3_user/expectations/binary/test_equal.pks @@ -1,7 +1,7 @@ create or replace package test_equal is --%suite((not)to_be_equal) - --%suitepath(utplsql.core.expectations.binary) + --%suitepath(utplsql.test_user.expectations.binary) procedure reset_nulls_equal; diff --git a/test/core/expectations/binary/test_expect_to_be_less_than.pkb b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb similarity index 69% rename from test/core/expectations/binary/test_expect_to_be_less_than.pkb rename to test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb index 8f1278db4..d7bf5533b 100644 --- a/test/core/expectations/binary/test_expect_to_be_less_than.pkb +++ b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb @@ -2,7 +2,7 @@ create or replace package body test_expect_to_be_less_than is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; function to_be_less_than_block( @@ -11,7 +11,7 @@ create or replace package body test_expect_to_be_less_than is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'to_be_less_than', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -22,7 +22,7 @@ create or replace package body test_expect_to_be_less_than is a_expected varchar2 ) return varchar2 is begin - return expectations.binary_expectation_block( + return ut3_tester_helper.expectations_helper.binary_expectation_block( 'not_to_be_less_than', a_data_type, a_actual, a_data_type, a_expected ); end; @@ -32,7 +32,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_number_greater is @@ -40,7 +40,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ym_greater is @@ -48,7 +48,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ds_greater is @@ -56,7 +56,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_greater is @@ -64,7 +64,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_tz_greater is @@ -72,7 +72,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_ltz_greater is @@ -80,7 +80,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_date_equal is @@ -88,7 +88,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('date', 'sysdate', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_number_equal is @@ -96,7 +96,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('number', '2.0', '2.00'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ym_equal is @@ -104,7 +104,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('interval year to month', '''2-1''', '''2-1'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_interval_ds_equal is @@ -112,7 +112,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_equal is @@ -120,7 +120,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_tz_equal is @@ -128,7 +128,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_timestamp_ltz_equal is @@ -136,7 +136,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure actual_date_less is @@ -144,7 +144,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('date', 'sysdate-1', 'sysdate'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_number_less is @@ -152,7 +152,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('number', '1.0', '1.01'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ym_less is @@ -160,7 +160,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('interval year to month', '''2-1''', '''2-2'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_interval_ds_less is @@ -168,7 +168,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_less is @@ -176,7 +176,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_tz_less is @@ -184,7 +184,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_timestamp_ltz_less is @@ -192,7 +192,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate to_be_less_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +03:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_date_greater is @@ -200,7 +200,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('date', 'sysdate', 'sysdate-1'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_number_greater is @@ -208,7 +208,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('number', '2.0', '1.99'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_interval_ym_greater is @@ -216,7 +216,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('interval year to month', '''2-1''', '''2-0'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_interval_ds_greater is @@ -224,7 +224,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_timestamp_greater is @@ -232,7 +232,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_timestamp_tz_gretr is @@ -240,7 +240,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('timestamp with time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_actual_timestamp_ltz_gretr is @@ -248,7 +248,7 @@ create or replace package body test_expect_to_be_less_than is --Act execute immediate not_to_be_less_than_block('timestamp with local time zone', 'to_timestamp_tz(''1997 12 +01:00'',''YYYY FF TZR'')', 'to_timestamp_tz(''1997 12 +02:00'',''YYYY FF TZR'')'); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure actual_clob is @@ -256,7 +256,7 @@ create or replace package body test_expect_to_be_less_than is --Act ut3.ut.expect(to_clob('3')).to_( ut3.be_less_than(4) ); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/core/expectations/binary/test_expect_to_be_less_than.pks b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pks similarity index 98% rename from test/core/expectations/binary/test_expect_to_be_less_than.pks rename to test/ut3_user/expectations/binary/test_expect_to_be_less_than.pks index 67e6b8776..c03f0d28e 100644 --- a/test/core/expectations/binary/test_expect_to_be_less_than.pks +++ b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_less_than is --%suite((not)to_be_less_than) - --%suitepath(utplsql.core.expectations.binary) + --%suitepath(utplsql.test_user.expectations.binary) --%aftereach procedure cleanup_expectations; diff --git a/test/ut3_user/expectations/test_expectation_anydata.pkb b/test/ut3_user/expectations/test_expectation_anydata.pkb new file mode 100644 index 000000000..4838aabff --- /dev/null +++ b/test/ut3_user/expectations/test_expectation_anydata.pkb @@ -0,0 +1,1001 @@ +create or replace package body test_expectation_anydata is + + g_test_expected anydata; + g_test_actual anydata; + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + procedure cleanup is + begin + g_test_expected := null; + g_test_actual := null; + cleanup_expectations(); + end; + + procedure fail_on_different_type_null is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( cast(null as ut3_tester_helper.test_dummy_object) ); + g_test_actual := anydata.convertObject( cast(null as ut3_tester_helper.other_dummy_object) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual (ut3_tester_helper.other_dummy_object) cannot be compared to Expected (ut3_tester_helper.test_dummy_object) using matcher 'equal'.]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_on_different_type is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.other_dummy_object(1, 'A', '0') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual (ut3_tester_helper.other_dummy_object) cannot be compared to Expected (ut3_tester_helper.test_dummy_object) using matcher 'equal'.]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_on_different_object_data is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, null, '0') ); + --Act + ut3.ut.expect( g_test_actual ).not_to_equal( g_test_expected ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_on_one_object_null is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( cast(null as ut3_tester_helper.test_dummy_object) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object was expected to equal: ut3_tester_helper.test_dummy_object +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Missing: 1A0]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure fail_on_collection_vs_object is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual (ut3_tester_helper.test_dummy_object_list) cannot be compared to Expected (ut3_tester_helper.test_dummy_object) using matcher 'equal'.]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_on_null_vs_empty_coll is + l_null_list ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list() ); + g_test_actual := anydata.convertCollection( l_null_list ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 0 ] +%Diff: +%Rows: [ all different ] +%All rows are different as the columns position is not matching.]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure fail_on_one_collection_null is + l_null_list ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); + g_test_actual := anydata.convertCollection( l_null_list ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Missing: 1A0]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_on_one_collection_empty is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list() ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 0 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Missing: 1A0]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure fail_on_different_coll_data is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_obj ut3_tester_helper.test_dummy_object := ut3_tester_helper.test_dummy_object(1, 'A', '0'); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_obj) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_obj, l_obj) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 2 - Extra: 1A0]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + --%test(Gives success when both anydata are NULL) + procedure success_on_both_anydata_null is + --Arrange + l_null_anydata anydata; + begin + --Act + ut3.ut.expect( l_null_anydata ).to_equal( l_null_anydata ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure success_on_both_object_null is + --Arrange + l_null_object ut3_tester_helper.test_dummy_object; + l_anydata anydata := anydata.convertObject(l_null_object); + begin + --Act + ut3.ut.expect( l_anydata ).to_equal( l_anydata ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure success_on_both_coll_null is + --Arrange + l_null_collection ut3_tester_helper.test_dummy_object_list; + l_anydata anydata := anydata.convertCollection(l_null_collection); + begin + --Act + ut3.ut.expect( l_anydata ).to_equal( l_anydata ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure success_on_same_coll_data is + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(ut3_tester_helper.test_dummy_object(1, 'A', '0')) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_on_coll_different_order is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_first_obj ut3_tester_helper.test_dummy_object := ut3_tester_helper.test_dummy_object(1, 'A', '0'); + l_second_obj ut3_tester_helper.test_dummy_object := ut3_tester_helper.test_dummy_object(2, 'b', '1'); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_first_obj, l_second_obj) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_second_obj, l_first_obj) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure success_on_same_object_data is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure exclude_attributes_as_list is + l_list ut3.ut_varchar2_list; + begin + --Arrange + l_list := ut3.ut_varchar2_list('Value','/ID'); + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>3, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure exclude_attributes_as_csv is + l_list varchar2(100); + begin + --Arrange + l_list := 'Value,ID'; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>2, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_list ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure exclude_attributes_xpath is + l_xpath varchar2(100); + begin + --Arrange + l_xpath := '//Value|//ID'; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>2, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_xpath ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure exclude_ignores_invalid_attrib is + l_exclude varchar2(100); + begin + --Arrange + l_exclude := 'BadAttributeName'; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected, a_exclude=> l_exclude ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure include_attributes_as_list is + l_list ut3.ut_varchar2_list; + begin + --Arrange + l_list := ut3.ut_varchar2_list('Value','ID'); + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'b',"Value"=>'0') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_list ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure include_attributes_as_csv is + l_xpath varchar2(100); + begin + --Arrange + l_xpath := 'key,ID'; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure include_attributes_xpath is + l_xpath varchar2(100); + begin + --Arrange + l_xpath := '//key|//ID'; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_xpath ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure include_ignores_invalid_attrib is + l_include varchar2(100); + begin + --Arrange + l_include := ' BadAttributeName, ID '; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).include( l_include ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure include_exclude_attributes_csv is + l_exclude varchar2(100); + l_include varchar2(100); + begin + --Arrange + l_include := 'key,ID,Value'; + l_exclude := '//key|//Value'; + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure include_exclude_attrib_list is + l_exclude ut3.ut_varchar2_list; + l_include ut3.ut_varchar2_list; + l_expected varchar2(32767); + l_actual varchar2(32767); + begin + --Arrange + l_include := ut3.ut_varchar2_list('key','ID','Value'); + l_exclude := ut3.ut_varchar2_list('key','Value'); + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'B',"Value"=>'0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(id=>1, "name"=>'A',"Value"=>'1') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).exclude( l_exclude ).include( l_include ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure reports_diff_attribute is + l_expected varchar2(32767); + l_actual varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, NULL, '0') ); + l_expected := q'[Actual: ut3_tester_helper.test_dummy_object was expected to equal: ut3_tester_helper.test_dummy_object +Diff: +Rows: [ 1 differences ] + Row No. 1 - Actual: + Row No. 1 - Expected: A]'; + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_actual := ut3_tester_helper.main_helper.get_failed_expectations(1); + ut.expect(l_actual).to_be_like(l_expected); + end; + + + procedure reports_diff_structure is + l_obj ut3_tester_helper.test_dummy_object := ut3_tester_helper.test_dummy_object(1, 'A', '0'); + l_expected varchar2(32767); + l_actual varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_obj) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list(l_obj, l_obj) ); + l_expected := q'[Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 1 ] +Diff: +Rows: [ 1 differences ] + Row No. 2 - Extra: 1A0]'; + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + --Assert + l_actual := ut3_tester_helper.main_helper.get_failed_expectations(1); + ut.expect(l_actual).to_be_like(l_expected); + end; + + function get_anydata return anydata is + begin + return anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'B', '0') ); + end; + + procedure deprec_to_equal_excl_varch is + begin + --Act + ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); + --Assert + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + end; + + procedure deprec_to_equal_excl_list is + begin + --Act + ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + --Assert + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + end; + + procedure deprec_not_to_equal_excl_varch is + begin + --Act + ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'); + --Assert + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + end; + + procedure deprec_not_to_equal_excl_list is + begin + --Act + ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); + --Assert + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + end; + + procedure deprec_equal_excl_varch is + begin + --Act + ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col')); + --Assert + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + end; + + procedure deprec_equal_excl_list is + begin + --Act + ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'))); + --Assert + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + end; + + procedure data_diff_on_atr_data_mismatch is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + + l_expected_message := q'[Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] +Diff: +Rows: [ 2 differences ] + Row No. 1 - Actual: 1Something 11 + Row No. 1 - Expected: 2Something 22 + Row No. 2 - Actual: 2Something 22 + Row No. 2 - Expected: 1Something 11]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure data_diff_on_20_rows_only is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rn, 'Something '||rn, rn1) + bulk collect into l_actual + from (select rownum * case when mod(rownum,2) = 0 then -1 else 1 end rn, + rownum * case when mod(rownum,4) = 0 then -1 else 1 end rn1 + from dual connect by level <=100); + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=110; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); + + l_expected_message := q'[Actual: ut3_tester_helper.test_dummy_object_list [ count = 100 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 110 ] +Diff: +Rows: [ 60 differences, showing first 20 ] + Row No. 2 - Actual: -2Something -2 + Row No. 2 - Expected: 2Something 2 + Row No. 4 - Actual: -4Something -4-4 + Row No. 4 - Expected: 4Something 44 + % + Row No. 38 - Actual: -38Something -38 + Row No. 38 - Expected: 38Something 38 + Row No. 40 - Actual: -40Something -40-40 + Row No. 40 - Expected: 40Something 4040]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure collection_include_list is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_list ut3.ut_varchar2_list; + begin + l_list := ut3.ut_varchar2_list('Value','ID'); + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'SomethingsDifferent '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); + + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure collection_exclude_list is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_list ut3.ut_varchar2_list; + begin + l_list := ut3.ut_varchar2_list('Value','ID'); + --Arrange + select ut3_tester_helper.test_dummy_object( rownum*2, 'Something '||rownum, rownum*2) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).exclude( l_list ); + + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure collection_include_list_fail is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_list ut3.ut_varchar2_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + l_list := ut3.ut_varchar2_list('name'); + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'SomethingsDifferent '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include( l_list ); + + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] +%Diff: +%Rows: [ 2 differences ] +%Row No. 1 - Actual: SomethingsDifferent 1 +%Row No. 1 - Expected: Something 1 +%Row No. 2 - Actual: SomethingsDifferent 2 +%Row No. 2 - Expected: Something 2]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure array_same_data is + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure array_diff_data is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('B') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester_helper.t_tab_varchar [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: B +%Row No. 1 - Expected: A]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure array_is_null is + l_is_null ut3_tester_helper.t_tab_varchar ; + begin + ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure array_null_equal_array_null is + l_is_null ut3_tester_helper.t_tab_varchar ; + l_is_null_bis ut3_tester_helper.t_tab_varchar ; + begin + ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure array_null_equal_array_notnull is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_is_null ut3_tester_helper.t_tab_varchar ; + begin + --Arrange + g_test_expected := anydata.convertCollection( l_is_null ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester_helper.t_tab_varchar [ count = ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Extra: A]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure empty_array_have_zero_elem is + begin + ut3.ut.expect( anydata.convertCollection(ut3_tester_helper.t_tab_varchar())).to_have_count(0); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure array_empty_equal_array_empty is + begin + --Arrange + g_test_expected := anydata.convertCollection(ut3_tester_helper.t_tab_varchar()); + g_test_actual := anydata.convertCollection(ut3_tester_helper.t_tab_varchar()); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure arr_empty_equal_arr_notempty is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_is_null ut3_tester_helper.t_tab_varchar ; + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.t_tab_varchar() ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_tab_varchar('A') ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.t_tab_varchar [ count = 1 ] was expected to equal: ut3_tester_helper.t_tab_varchar [ count = 0 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Extra: A]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure collection_is_null is + l_null_list ut3_tester_helper.test_dummy_object_list; + begin + --Arrange + g_test_actual := anydata.convertCollection( l_null_list ); + --Act + ut3.ut.expect( g_test_actual ).to_be_null; + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure collection_is_empty is + begin + --Arrange + g_test_actual := anydata.convertCollection( ut3_tester_helper.test_dummy_object_list() ); + --Act + ut3.ut.expect( g_test_actual ).to_have_count(0); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure varray_same_data is + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varray_diff_data is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(2) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.t_varray [ count = 1 ] was expected to equal: ut3_tester_helper.t_varray [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: 2 +%Row No. 1 - Expected: 1]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure varray_is_null is + l_is_null ut3_tester_helper.t_varray ; + begin + ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_be_null; + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varray_null_equal_varray_null is + l_is_null ut3_tester_helper.t_varray ; + l_is_null_bis ut3_tester_helper.t_varray ; + begin + ut3.ut.expect( anydata.convertCollection( l_is_null ) ).to_equal(anydata.convertCollection( l_is_null_bis )); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varr_null_equal_varr_notnull is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_is_null ut3_tester_helper.t_varray ; + begin + --Arrange + g_test_expected := anydata.convertCollection( l_is_null ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.t_varray [ count = 1 ] was expected to equal: ut3_tester_helper.t_varray [ count = ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Extra: 1]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure empty_varray_have_zero_elem is + begin + ut3.ut.expect( anydata.convertCollection(ut3_tester_helper.t_varray())).to_have_count(0); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varr_empty_equal_varr_empty is + begin + --Arrange + g_test_expected := anydata.convertCollection(ut3_tester_helper.t_varray()); + g_test_actual := anydata.convertCollection(ut3_tester_helper.t_varray()); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varr_empty_equal_varr_notempty is + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + l_is_null ut3_tester_helper.t_varray ; + begin + --Arrange + g_test_expected := anydata.convertCollection( ut3_tester_helper.t_varray() ); + g_test_actual := anydata.convertCollection( ut3_tester_helper.t_varray(1) ); + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ); + l_expected_message := q'[%Actual: ut3_tester_helper.t_varray [ count = 1 ] was expected to equal: ut3_tester_helper.t_varray [ count = 0 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Extra: 1]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure collection_join_by is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('ID'); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure collection_join_by_fail is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum * 2, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).join_by('ID'); + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] +%Diff: +%Rows: [ 3 differences ] +%PK 2 - Actual: Something 2 +%PK 2 - Actual: 2 +%PK 2 - Expected: Something 1 +%PK 2 - Expected: 1 +%PK 1 - Extra: 1Something 11 +%PK 4 - Missing: 4Something 22]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure collection_unordered is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=3; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=3 + order by rownum desc; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure collection_unordered_fail is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=2; + select ut3_tester_helper.test_dummy_object( rownum * 2, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + + l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ count = 2 ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 2 ] +%Diff: +%Rows: [ 4 differences ] +%Extra: 1Something 11 +%Extra: 2Something 22 +%Missing: 4Something 22 +%Missing: 2Something 11]'; + + ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).unordered; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure object_join_by is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + + --Act + ut3.ut.expect(g_test_actual).to_equal(g_test_expected).join_by('ID'); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure object_unordered is + begin + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + + --Act + ut3.ut.expect(g_test_actual).to_equal(g_test_expected).unordered; + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure collection_to_contain is + l_actual ut3_tester_helper.test_dummy_object_list; + l_expected ut3_tester_helper.test_dummy_object_list; + begin + --Arrange + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_actual + from dual connect by level <=4; + select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) + bulk collect into l_expected + from dual connect by level <=2 + order by rownum desc; + --Act + ut3.ut.expect(anydata.convertCollection(l_actual)).to_contain(anydata.convertCollection(l_expected)); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure object_to_contain is + begin + --Arrange + g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_object(1, 'A', '0') ); + + --Act + ut3.ut.expect(g_test_actual).to_contain(g_test_expected); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure arr_empty_eq_arr_empty_unord is + begin + --Arrange + g_test_expected := anydata.convertCollection(ut3_tester_helper.t_tab_varchar(null)); + g_test_actual := anydata.convertCollection(ut3_tester_helper.t_tab_varchar(null)); + + --Act + ut3.ut.expect( g_test_actual ).to_equal( g_test_expected ).unordered(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure arr_empty_nqua_arr_e_unord is + begin + --Arrange + g_test_expected := anydata.convertCollection(ut3_tester_helper.t_tab_varchar('t')); + g_test_actual := anydata.convertCollection(ut3_tester_helper.t_tab_varchar(' ')); + + --Act + ut3.ut.expect( g_test_actual ).not_to_equal( g_test_expected ).unordered(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + +end; +/ \ No newline at end of file diff --git a/test/core/expectations/test_expectation_anydata.pks b/test/ut3_user/expectations/test_expectation_anydata.pks similarity index 96% rename from test/core/expectations/test_expectation_anydata.pks rename to test/ut3_user/expectations/test_expectation_anydata.pks index b9fbda93b..a6eeb25fb 100644 --- a/test/core/expectations/test_expectation_anydata.pks +++ b/test/ut3_user/expectations/test_expectation_anydata.pks @@ -1,7 +1,7 @@ create or replace package test_expectation_anydata is --%suite(equal on anydata) - --%suitepath(utplsql.core.expectations) + --%suitepath(utplsql.test_user.expectations) --%aftereach procedure cleanup; @@ -198,5 +198,10 @@ create or replace package test_expectation_anydata is --%test( Success when anydata object contains data from another anydata) procedure object_to_contain; + --%test ( Empty Array equal empty array ) + procedure arr_empty_eq_arr_empty_unord; + + --%test ( Empty Array not equal array with space ) + procedure arr_empty_nqua_arr_e_unord; end; / diff --git a/test/core/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb similarity index 78% rename from test/core/expectations/test_expectations_cursor.pkb rename to test/ut3_user/expectations/test_expectations_cursor.pkb index 1b155353d..daa3389bc 100644 --- a/test/core/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -13,7 +13,7 @@ create or replace package body test_expectations_cursor is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; procedure setup_temp_table_test @@ -50,7 +50,7 @@ create or replace package body test_expectations_cursor is --Act - execute the expectation on cursor opened on GTT ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); --Cleanup rollback; end; @@ -78,7 +78,29 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + 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; @@ -93,7 +115,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_on_both_null @@ -104,7 +126,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_to_be_null @@ -114,7 +136,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_be_null(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_not_to_be_not_null @@ -124,7 +146,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).not_to_be_not_null(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_not_to_be_null @@ -136,7 +158,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_be_not_null(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_to_be_not_null @@ -148,7 +170,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_be_not_null(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_is_empty @@ -160,7 +182,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure success_is_not_empty @@ -172,7 +194,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure failure_is_null @@ -184,7 +206,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_be_null(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure failure_is_not_null @@ -194,7 +216,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).not_to_be_null(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure failure_is_empty @@ -206,7 +228,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure failure_is_not_empty @@ -218,7 +240,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_null_vs_empty @@ -231,7 +253,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).not_to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_on_difference @@ -245,7 +267,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_on_expected_missing @@ -259,7 +281,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_on_actual_missing @@ -273,7 +295,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_on_different_column_name @@ -287,7 +309,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -302,7 +324,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure pass_on_different_column_order @@ -316,7 +338,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure pass_on_diff_column_ord_uc @@ -330,7 +352,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ).uc; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_on_multi_diff_col_order @@ -351,7 +373,7 @@ create or replace package body test_expectations_cursor is %Rows: [ 1 differences ] %Row No. 1 - Actual: 4030 %Row No. 1 - Expected: 34]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -374,7 +396,7 @@ create or replace package body test_expectations_cursor is %Rows: [ 1 differences ] %Row No. 1 - Actual: 4030 %Row No. 1 - Expected: 34]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -390,7 +412,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure include_time_in_date_with_nls @@ -407,7 +429,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect( l_actual ).to_equal( l_expected ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); ut3.ut.reset_nls; end; @@ -422,7 +444,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_columns_as_list @@ -436,7 +458,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_columns_as_csv @@ -450,7 +472,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,Some_Col'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_columns_as_mixed_list is @@ -463,7 +485,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3.ut_varchar2_list('A_COLUMN','/ROW/Some_Col')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_columns_as_mix_csv_lst is @@ -476,7 +498,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,/ROW/Some_Col'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_columns_xpath_invalid @@ -501,7 +523,7 @@ create or replace package body test_expectations_cursor is %Row No. 2 - Expected: c %Row No. 3 - Actual: d %Row No. 3 - Expected: c]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -517,7 +539,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN|/ROW/Some_Col'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure exclude_ignores_invalid_column @@ -531,7 +553,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3.ut_varchar2_list('A_COLUMN','non_existing_column')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_columns_as_list @@ -545,7 +567,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_columns_as_csv @@ -559,7 +581,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected).include('RN,//A_Column, SOME_COL'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_columns_xpath @@ -573,7 +595,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected).include('/ROW/RN|//A_Column|//SOME_COL'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_ignores_invalid_column @@ -587,7 +609,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list(' RN ',' non_existing_column ')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_exclude_col_csv_xpath @@ -601,7 +623,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected).exclude('Some_Col').include('/ROW/RN|//Some_Col'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure include_exclude_columns_list @@ -615,7 +637,7 @@ create or replace package body test_expectations_cursor is --Act ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN')).include(ut3.ut_varchar2_list('RN','A_Column','A_COLUMN')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure data_diff_on_rows_mismatch @@ -637,7 +659,7 @@ Rows: [ 2 differences ] Row No. 2 - Actual: 6 Row No. 2 - Expected: 2 Row No. 3 - Missing: 3]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -659,7 +681,7 @@ Columns: Column [position: 2, data-type: NUMBER] is not expected in results. Rows: [ 1 differences ] All rows are different as the columns are not matching.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -682,7 +704,7 @@ Columns: Column data-type is invalid. Expected: NUMBER, actual: VARCHAR2. Rows: [ all different ] All rows are different as the columns position is not matching.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -704,7 +726,7 @@ Diff: Columns:% Column [data-type: NUMBER] is missing. Expected column position: 2.% Column [position: 2, data-type: NUMBER] is not expected in results.%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -729,7 +751,7 @@ Columns: Column is misplaced. Expected position: 4, actual position: 3. Rows: [ all different ] All rows are different as the columns position is not matching.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -746,7 +768,7 @@ Rows: [ all different ] --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered_columns; - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; --%test(Reports only mismatched columns on column data mismatch) @@ -769,7 +791,7 @@ Rows: [ 2 differences ] Row No. 1 - Expected: 1 Row No. 2 - Actual: -2 Row No. 2 - Expected: 2]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -806,7 +828,7 @@ Rows: [ 60 differences, showing first 20 ] Row No. 38 - Expected: 38 Row No. 40 - Actual: -40 Row No. 40 - Expected: 40]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -843,7 +865,7 @@ Rows: [ 4 differences ] Row No. 3 - Actual: JESSICAJONES42345 Row No. 3 - Expected: 3TONYSTARK100000 Row No. 4 - Extra: MLUKESKYWALKER21000]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -879,7 +901,7 @@ Rows: [ 4 differences ] Row No. 3 - Actual: JESSICAJONES42345 Row No. 3 - Expected: 3TONYSTARK100000 Row No. 4 - Extra: MLUKESKYWALKER21000]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -937,7 +959,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_expected).to_equal(l_actual); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure closes_cursor_after_use @@ -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 @@ -1008,13 +1028,13 @@ Rows: [ 4 differences ] l_expected sys_refcursor; begin --Arrange - open l_actual for select object_name from all_objects where rownum <=1100 order by object_id; - open l_expected for select object_name from all_objects where rownum <=1100 order by object_id; + open l_actual for select rownum object_name from dual connect by level <=1100; + open l_expected for select rownum object_name from dual connect by level <=1100; --Act ut3.ut.expect(l_actual).to_equal(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; function get_cursor return sys_refcursor is @@ -1029,8 +1049,8 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col'); --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); end; procedure deprec_to_equal_excl_list is @@ -1038,8 +1058,8 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); end; procedure deprec_not_to_equal_excl_varch is @@ -1047,8 +1067,8 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col'); --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); end; procedure deprec_not_to_equal_excl_list is @@ -1056,8 +1076,8 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')); --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); end; procedure deprec_equal_excl_varch is @@ -1065,8 +1085,8 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(get_cursor()).to_(ut3.equal(get_cursor(), a_exclude => 'A_COLUMN,Some_Col')); --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); end; procedure deprec_equal_excl_list is @@ -1074,8 +1094,8 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(get_cursor()).to_(ut3.equal(get_cursor(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'))); --Assert - ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1); - ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); + ut.expect(cardinality(ut3_tester_helper.main_helper.get_warnings())).to_equal(1); + ut.expect(ut3_tester_helper.main_helper.get_warnings()(1)).to_be_like('The syntax: "%" is deprecated.%'); end; procedure col_diff_on_col_name_implicit is @@ -1099,7 +1119,7 @@ Rows: [ 4 differences ] %Column <2> [position: 2, data-type: CHAR] is not expected in results. %Rows: [ all different ] %All rows are different as the columns position is not matching.]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1116,7 +1136,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_actual).to_equal(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_unorderd_compr_success is @@ -1129,7 +1149,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_unord_compr_success_uc is @@ -1142,7 +1162,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered().uc(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_unordered_compare_fail is @@ -1168,7 +1188,7 @@ Rows: [ 4 differences ] %Rows: [ 2 differences ]% %Extra: test-666% %Missing: test-667%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1184,7 +1204,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID').uc(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_joinby_compare is @@ -1198,7 +1218,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_joinby_col_not_ord @@ -1221,7 +1241,7 @@ Rows: [ 4 differences ] %PK 1 - Expected: 3 %PK 1 - Actual: 40 %PK 1 - Expected: 4]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1237,7 +1257,7 @@ Rows: [ 4 differences ] --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OBJECT_ID,OBJECT_NAME')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_joinby_compare_nokey is @@ -1258,7 +1278,7 @@ Diff:% %Unable to join sets:% %Join key OWNER does not exists in expected% %Join key OWNER does not exists in actual%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1283,7 +1303,7 @@ Diff:% %Join key USER_ID does not exists in expected% %Join key OWNER does not exists in actual% %Join key USER_ID does not exists in actual%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1306,7 +1326,7 @@ Diff:% %Unable to join sets:% %Join key SOME_COL does not exists in expected% %Join key SOME_COL does not exists in actual%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1329,7 +1349,7 @@ Diff:% %Unable to join sets:% %Join key RN does not exists in expected% %Join key RN does not exists in actual%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1351,7 +1371,7 @@ Diff:% Diff:% %Unable to join sets:% %Join key RNI does not exists in expected%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1373,7 +1393,7 @@ Diff:% Diff:% %Unable to join sets:% %Join key RNI does not exists in actual%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1388,7 +1408,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_unorder_compare_1000 is @@ -1401,7 +1421,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_joinby_compare_fail is @@ -1425,7 +1445,7 @@ Diff:% %Rows: [ 1 differences ]% %PK TEST - Actual:%-610% %PK TEST - Expected:%-600%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1451,7 +1471,7 @@ Diff:% %Rows: [ 2 differences ]% %PK TEST-610 - Extra: TEST-610% %PK TEST-600 - Missing: TEST-600%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1477,7 +1497,7 @@ Diff:% %Rows: [ 1 differences ]% %PK TESTY - Actual:%-610% %PK TESTY - Expected:%-600%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1493,7 +1513,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).unordered; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure joinby_incl_cols_as_list @@ -1507,7 +1527,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure joinby_excl_cols_as_list @@ -1521,7 +1541,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure unord_excl_cols_as_list @@ -1535,7 +1555,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col')).unordered; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure excl_dif_cols_as_list @@ -1549,7 +1569,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure inlc_dif_cols_as_list @@ -1563,7 +1583,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure inlc_exc_dif_cols_as_list @@ -1577,7 +1597,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).include(ut3.ut_varchar2_list('RN')).exclude(ut3.ut_varchar2_list('A_COLUMN')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure compare_obj_typ_col_un is @@ -1585,16 +1605,16 @@ Diff:% l_expected sys_refcursor; begin --Arrange - open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_actual for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum asc; - open l_expected for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_expected for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum desc; --Act ut3.ut.expect(l_actual).to_equal(l_expected).unordered; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure compare_obj_typ_col_jb is @@ -1602,16 +1622,16 @@ Diff:% l_expected sys_refcursor; begin --Arrange - open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_actual for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum asc; - open l_expected for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_expected for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum desc; --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure comp_obj_typ_col_un_fail is @@ -1621,10 +1641,10 @@ Diff:% l_actual_message varchar2(32767); begin --Arrange - open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_actual for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum asc; - open l_expected for select test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval + open l_expected for select ut3_tester_helper.test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval from dual connect by level <=3 order by rownum desc; --Act @@ -1637,7 +1657,7 @@ Rows: [ 5 differences% %Missing: 3Somethings 33% %Missing: 2Somethings 22% %Missing: 1Somethings 11%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1647,16 +1667,16 @@ Rows: [ 5 differences% l_expected sys_refcursor; begin --Arrange - open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_actual for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum asc; - open l_expected for select test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval + open l_expected for select ut3_tester_helper.test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval from dual connect by level <=2 order by rownum desc; --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_not_null(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure comp_obj_typ_col_jb_multi is @@ -1664,16 +1684,16 @@ Rows: [ 5 differences% l_expected sys_refcursor; begin --Arrange - open l_actual for select rownum as rn,test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_actual for select rownum as rn,ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum asc; - open l_expected for select rownum as rn,test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_expected for select rownum as rn,ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum desc; --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('RN,COLVAL/ID')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure comp_obj_typ_col_jb_nokey is @@ -1683,10 +1703,10 @@ Rows: [ 5 differences% l_actual_message varchar2(32767); begin --Arrange - open l_actual for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_actual for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum asc; - open l_expected for select test_dummy_object( rownum, 'Something '||rownum, rownum) as colval + open l_expected for select ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval from dual connect by level <=2 order by rownum desc; --Act @@ -1697,7 +1717,7 @@ Diff:% %Unable to join sets:% %Join key COLVAL/IDS does not exists in expected% %Join key COLVAL/IDS does not exists in actual%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1729,7 +1749,7 @@ Diff:% ut3.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure compare_nest_tab_col_jb_fail is @@ -1764,7 +1784,7 @@ Diff:% %PK % - Expected: %% %PK % - Actual: %% %PK % - Expected: %%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1796,7 +1816,7 @@ Diff:% ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('KEY,VALUE')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure compare_nest_tab_cols_jb_fail is @@ -1831,7 +1851,7 @@ Diff:% %PK %% - Extra% %PK %% - Missing% %PK %% - Missing%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -1870,7 +1890,7 @@ Diff:% %PK %%%%%%%%%%%%%Extra%%% %PK %%%%%%%%%%%%%Missing%%% %PK %%%%%%%%%%%%%Missing%%%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1902,7 +1922,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -1940,7 +1960,7 @@ Diff:% %Extra: 21Apples 12Apples 2 %Missing: 11Peaches 12Peaches 2 %Missing: 21Peaches 12Peaches 2%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -1974,7 +1994,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2006,7 +2026,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2038,7 +2058,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ANNOTATIONS'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; @@ -2081,10 +2101,10 @@ Diff:% %Rows: [ 1 differences ] %PK TEST - Actual: TESTTESTTEST%1testtesttest2testtesttest% %PK TEST - Expected: TESTTESTTEST%11testtesttest2testtesttest%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); - --ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + --ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure compare_rec_coll_as_join is @@ -2122,7 +2142,7 @@ Diff:% %Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in expected% %Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in actual% %Please make sure that your join clause is not refferring to collection element%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -2154,7 +2174,7 @@ Diff:% %Diff: %Rows: [ 1 differences ] %Missing: Table%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -2171,9 +2191,9 @@ Diff:% and rownum < 20; --Act - ut3.ut.expect(l_actual).to_( ut3.contain(l_expected) ); + ut3.ut.expect(l_actual).to_contain(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_to_contain_uc is @@ -2187,9 +2207,9 @@ Diff:% and rownum < 20; --Act - ut3.ut.expect(l_actual).to_( ut3.contain(l_expected).uc() ); + ut3.ut.expect(l_actual).to_contain(l_expected).uc(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_to_contain_unordered is @@ -2198,15 +2218,15 @@ Diff:% begin --Arrange open l_actual for - select owner, object_name,object_type from all_objects where owner = user + select rownum owner, rownum||'name' object_name,'PACKAGE' object_type from dual connect by level < 20 order by 1,2,3 asc; open l_expected for - select owner, object_name,object_type from all_objects where owner = user and rownum < 20; + select rownum owner, rownum||'name' object_name,'PACKAGE' object_type from dual connect by level < 10; --Act - ut3.ut.expect(l_actual).to_( ut3.contain(l_expected).unordered() ); + ut3.ut.expect(l_actual).to_contain(l_expected).unordered(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_to_contain_fail is @@ -2216,10 +2236,8 @@ Diff:% l_actual_message varchar2(32767); begin --Arrange - open l_actual for select owner, object_name,object_type from all_objects where owner = user - and rownum < 5; - open l_expected for select owner, object_name,object_type from all_objects where owner = user - and rownum < 10; + open l_actual for select rownum owner,rownum object_name, 'PACKAGE' object_type from dual connect by level < 5; + open l_expected for select rownum owner,rownum object_name, 'PACKAGE' object_type from dual connect by level < 10; --Act ut3.ut.expect(l_actual).to_contain(l_expected); @@ -2232,7 +2250,7 @@ Diff:% %Missing: %%%% %Missing: %%%% %Missing: %%%%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -2248,7 +2266,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_contain_joinby_fail is @@ -2275,7 +2293,7 @@ Diff:% %Rows: [ 1 differences ] %PK TEST - Actual: -600 %PK TEST - Expected: -601%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -2292,7 +2310,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure to_cont_join_incl_cols_as_lst @@ -2306,7 +2324,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure contain_join_excl_cols_as_lst @@ -2320,7 +2338,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_contain(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure contain_excl_cols_as_list @@ -2334,7 +2352,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_contain(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col')); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_not_to_contain @@ -2351,7 +2369,7 @@ Diff:% --Act ut3.ut.expect(l_actual).not_to_contain(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure cursor_not_to_contain_fail is @@ -2379,7 +2397,7 @@ Diff:% %CHARNUMBER% %Data:% %TEST-600%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -2395,7 +2413,7 @@ Diff:% --Act ut3.ut.expect(l_actual).not_to_contain(l_expected).join_by('USER_ID'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_cont_join_incl_cols_as_lst is @@ -2408,7 +2426,7 @@ Diff:% --Act ut3.ut.expect(l_actual).not_to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_cont_join_excl_cols_as_lst is @@ -2421,7 +2439,7 @@ Diff:% --Act ut3.ut.expect(l_actual).not_to_contain(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure to_contain_duplicates is @@ -2437,7 +2455,7 @@ Diff:% --Act ut3.ut.expect(l_actual).to_contain(l_expected); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure to_contain_duplicates_fail is @@ -2460,7 +2478,7 @@ Diff:% %Missing: % %Missing: % %Missing: %]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -2492,7 +2510,7 @@ Diff:% %Rows: [ 2 differences ] %Missing: 1Something 1 %Missing: 2Something 2%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -2520,10 +2538,310 @@ Diff:% %1Something 12Something 2 %was expected to be empty%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + 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; + begin + open l_expected for + select column_value t1 from table(ut_varchar2_list('')); + + open l_actual for + select column_value t1 from table(ut_varchar2_list(' ')); + --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; + + procedure insginificant_whitespace2 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for + select ' t ' t1 from dual; + + open l_actual for + select 't' t1 from dual; + --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; + + procedure insginificant_whitespace3 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for + select 't ' t1 from dual; + + open l_actual for + select 't' t1 from dual; + --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; + + procedure insginificant_whitespace4 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for + select ' t' t1 from dual; + + open l_actual for + select 't' t1 from dual; + --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; + + procedure insginificant_whitespace5 is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for + select ' ' t1 from dual; + + open l_actual for + select '' t1 from dual; --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; + + procedure nulltowhitespace is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for + select cast(null as varchar2(2)) t1 from dual; + + open l_actual for + select ' ' t1 from dual; + --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; + + procedure number_from_dual is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + open l_expected for select + 12345 as n1, + cast(7456123.89 as number(7,-2)) as n2, + cast(7456123.89 as number(9,1)) as n3, + cast(7456123.89 as number(9,2)) as n4, + cast(7456123.89 as number(9)) as n5, + cast(7456123.89 as number(*,1)) as n6, + 7456123.89 as n7 + from dual; + + open l_actual for select + 12345 as n1, + 7456100 as n2, + 7456123.9 as n3, + 7456123.89 as n4, + 7456124 as n5, + 7456123.9 as n6, + 7456123.89 as n7 + from dual; + ut3.ut.expect(l_actual).to_equal(l_expected); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure compare_number_pckg_type + as + l_expected sys_refcursor; + l_actual sys_refcursor; + l_expected_data t_num_tab; + l_actual_message varchar2(32767); + l_expected_message varchar2(32767); + begin + + l_expected_data(1).col1 := 2135; + l_expected_data(1).col4 := 2016; + l_expected_data(1).col5 := -1; + + --Select on package level nested table types supported only since Oracle 12 + $if dbms_db_version.version >= 12 $then + open l_expected for + select * + from table (l_expected_data); + + open l_actual for + select + 1 as col1 + ,2 as col2 + ,3 as col3 + ,2016 as col4 + ,-1 as col5 + from dual; + + ut3.ut.expect(l_actual).to_equal(a_expected => l_expected); + + l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] +%Diff: +%Rows: [ 1 differences ] +%Row No. 1 - Actual: 123 +%Row No. 1 - Expected: 2135%]'; + + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + ut.expect(l_actual_message).to_be_like(l_expected_message); + $end end; + procedure uc_columns_exclude is + v_actual SYS_REFCURSOR; + v_expected SYS_REFCURSOR; + begin + open v_expected for + select to_Char(null) id, 'ok' name from dual; + open v_actual for + select 'ok' name, to_number(null) id from dual; + + ut3.ut.expect(v_actual).to_equal(v_expected).exclude('ID'); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; end; / diff --git a/test/core/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks similarity index 87% rename from test/core/expectations/test_expectations_cursor.pks rename to test/ut3_user/expectations/test_expectations_cursor.pks index e8f492674..483968301 100644 --- a/test/core/expectations/test_expectations_cursor.pks +++ b/test/ut3_user/expectations/test_expectations_cursor.pks @@ -1,7 +1,7 @@ create or replace package test_expectations_cursor is --%suite(cursor expectations) - --%suitepath(utplsql.core.expectations) + --%suitepath(utplsql.test_user.expectations) --%aftereach procedure cleanup_expectations; @@ -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,11 +393,74 @@ 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 ) + --%disabled + procedure insginificant_whitespace1; + + --%test ( Compare insiginificant whitespaces scenario 2 ) + procedure insginificant_whitespace2; + + --%test ( Compare insiginificant whitespaces scenario 3 ) + procedure insginificant_whitespace3; + + --%test ( Compare insiginificant whitespaces scenario 4 ) + procedure insginificant_whitespace4; + + /*Oracle Bug not readin properly in xmltable */ + --%test ( Compare insiginificant whitespaces scenario 5 ) + --%disabled + procedure insginificant_whitespace5; + + /*Oracle Bug not readin properly in xmltable */ + --%test ( Compare null to whitespace ) + --%disabled + procedure nulltowhitespace; + + --%test(Check precision of number from dual #907) + procedure number_from_dual; + + --%test( Comparing number types with different precisions works with package-type nested tables ) + procedure compare_number_pckg_type; + + type t_num_rec is record ( + col1 number(15,0), + col2 number(1,0), + col3 number(4,0), + col4 number(4,0), + col5 number(38,0)); + + + type t_num_tab is table of t_num_rec index by binary_integer; + + --%test( Mixed column order exclusion ) + procedure uc_columns_exclude; + end; / diff --git a/test/ut3_user/expectations/test_expectations_json.pkb b/test/ut3_user/expectations/test_expectations_json.pkb new file mode 100644 index 000000000..6214d2237 --- /dev/null +++ b/test/ut3_user/expectations/test_expectations_json.pkb @@ -0,0 +1,1609 @@ +create or replace package body test_expectations_json is + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + procedure success_on_same_data + as + l_expected json_element_t; + l_actual json_element_t; + begin + -- Arrange + l_actual := json_element_t.parse(' { + "Actors": [ + { + "name": "Tom Cruise", + "age": 56, + "Born At": "Syracuse, NY", + "Birthdate": "July 3, 1962", + "photo": "https://jsonformatter.org/img/tom-cruise.jpg", + "wife": null, + "weight": 67.5, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name": "Robert Downey Jr.", + "age": 53, + "Born At": "New York City, NY", + "Birthdate": "April 4, 1965", + "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife": "Susan Downey", + "weight": 77.1, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + ] + }'); + + --Act + ut3.ut.expect( l_actual ).to_equal( l_actual ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_on_diff_data + as + l_expected json_element_t; + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thron\"es","The Wire"],"string": "some string","int": 2,"aboolean": true, "boolean": true,"object": {"foo": "bar","object1": {"new prop1": "new prop value"},"object2": {"new prop1": "new prop value"},"object3": {"new prop1": "new prop value"},"object4": {"new prop1": "new prop value"}}},"Amy Ryan": {"one": "In Treatment","two": "The Wire"},"Annie Fitzgerald": ["Big Love","True Blood"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsgard": ["Generation Kill","True Blood"], "Clarke Peters": null}'); + + --Act + ut3.ut.expect( l_actual ).to_equal( l_expected ); + --Assert + l_expected_message := q'[%Diff: 20 differences found +%3 incorrect types, 4 unequal values, 13 missing properties +%Missing property: "Alexander Skarsg?rd" on path: $ +%Extra property: "Alexander Skarsgard" on path: $ +%Missing property: "Alice Farmer" on path: $ +%Extra property: "Clarke Peters" on path: $ +%Extra property: "one" on path: $."Amy Ryan" +%Missing property: "The Sopranos" on path: $."Annie Fitzgerald"[2] +%Extra property: "two" on path: $."Amy Ryan" +%Missing property: "Oz" on path: $."Annie Fitzgerald"[3] +%Missing property: "otherint" on path: $."Aidan Gillen" +%Extra property: "object1" on path: $."Aidan Gillen"."object" +%Extra property: "object2" on path: $."Aidan Gillen"."object" +%Extra property: "object3" on path: $."Aidan Gillen"."object" +%Extra property: "object4" on path: $."Aidan Gillen"."object" +%Actual type: 'array' was expected to be: 'object' on path: $."Amy Ryan" +%Actual type: 'string' was expected to be: 'number' on path: $."Aidan Gillen"."int" +%Actual type: 'string' was expected to be: 'boolean' on path: $."Aidan Gillen"."aboolean" +%Actual value: "True Blood" was expected to be: "Big Love" on path: $."Annie Fitzgerald"[0] +%Actual value: "Big Love" was expected to be: "True Blood" on path: $."Annie Fitzgerald"[1] +%Actual value: FALSE was expected to be: TRUE on path: $."Aidan Gillen"."boolean" +%Actual value: "Game of Thrones" was expected to be: "Game of Thron\"es" on path: $."Aidan Gillen"."array"[0]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure null_json_variable + as + l_expected json_object_t ; + begin + -- Arrange + l_expected := cast (null as json_object_t ); + + --Act + ut3.ut.expect( l_expected ).to_be_null; + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure not_null_json_variable + as + l_expected json_object_t ; + begin + -- Arrange + l_expected := json_object_t(); + + --Act + ut3.ut.expect( l_expected ).not_to_be_null; + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_null_json_var + as + l_expected json_object_t ; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := json_object_t('{ "t" : "1" }'); + + --Act + ut3.ut.expect( l_expected ).to_be_null; + --Assert + l_expected_message := q'[%Actual: (json) +%'{"t":"1"}' +%was expected to be null%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_not_null_json_var + as + l_expected json_object_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := cast (null as json_object_t ); + + --Act + ut3.ut.expect( l_expected ).not_to_be_null; + --Assert + l_expected_message := q'[%Actual: NULL (json) was expected not to be null%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure empty_json + as + l_expected json_object_t; + begin + -- Arrange + l_expected := json_object_t(); + + --Act + ut3.ut.expect( l_expected ).to_be_empty; + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure not_empty_json + as + l_expected json_object_t; + begin + -- Arrange + l_expected := json_object_t.parse('{ "name" : "test" }'); + + --Act + ut3.ut.expect( l_expected ).not_to_be_empty; + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_empty_json + as + l_expected json_object_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := json_object_t.parse('{ "name" : "test" }'); + + --Act + ut3.ut.expect( l_expected ).to_be_empty; + --Assert + l_expected_message := q'[%Actual: (json) +%'{"name":"test"}' +%was expected to be empty%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure fail_not_empty_json + as + l_expected json_object_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := json_object_t(); + + --Act + ut3.ut.expect( l_expected ).not_to_be_empty; + --Assert + l_expected_message := q'[%Actual: (json) +%'{}' +%was expected not to be empty%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure to_have_count as + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3.ut.expect( l_actual ).to_have_count( 6 ); + + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + end; + + procedure fail_to_have_count + as + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3.ut.expect( l_actual ).to_have_count( 2 ); + --Assert + l_expected_message := q'[%Actual: (json [ count = 6 ]) was expected to have [ count = 2 ]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + + end; + + procedure not_to_have_count + as + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3.ut.expect( l_actual ).not_to_have_count( 7 ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure fail_not_to_have_count + as + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json_element_t.parse('{"Aidan Gillen": {"array": ["Game of Thrones","The Wire"],"string": "some string","int": "2","otherint": 4, "aboolean": "true", "boolean": false,"object": {"foo": "bar"}},"Amy Ryan": ["In Treatment","The Wire"],"Annie Fitzgerald": ["True Blood","Big Love","The Sopranos","Oz"],"Anwan Glover": ["Treme","The Wire"],"Alexander Skarsg?rd": ["Generation Kill","True Blood"],"Alice Farmer": ["The Corner","Oz","The Wire"]}'); + + --Act + ut3.ut.expect( l_actual ).not_to_have_count( 6 ); + --Assert + l_expected_message := q'[%Actual: json [ count = 6 ] was expected not to have [ count = 6 ]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure to_have_count_array + as + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_actual := json_element_t.parse('["Game of Thrones","The Wire"]'); + + --Act + ut3.ut.expect( l_actual ).to_have_count( 2 ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure to_diff_json_extract_same + as + l_expected json_object_t; + l_actual json_object_t; + BEGIN + -- Arrange + l_expected := json_object_t.parse(' { + "Actors": [ + { + "name": "Tom Cruise", + "age": 56, + "Born At": "Syracuse, NY", + "Birthdate": "July 3, 1962", + "photo": "https://jsonformatter.org/img/tom-cruise.jpg", + "wife": null, + "weight": 67.5, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name": "Robert Downey Jr.", + "age": 53, + "Born At": "New York City, NY", + "Birthdate": "April 4, 1965", + "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife": "Susan Downey", + "weight": 77.1, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + ] + }' + ); + l_actual := json_object_t.parse(' { + "Actors": + { + "name": "Krzystof Jarzyna", + "age": 53, + "Born At": "Szczecin", + "Birthdate": "April 4, 1965", + "photo": "niewidzialny", + "wife": "Susan Downey", + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + }' + ); + + + --Act + ut3.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors.children'))).to_equal(json_array_t(json_query(l_expected + .stringify,'$.Actors[1].children'))); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure to_diff_json_extract_diff + as + l_expected json_object_t; + l_actual json_object_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := json_object_t.parse(' { + "Actors": [ + { + "name": "Tom Cruise", + "age": 56, + "Born At": "Syracuse, NY", + "Birthdate": "July 3, 1962", + "photo": "https://jsonformatter.org/img/tom-cruise.jpg", + "wife": null, + "weight": 67.5, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Suri", + "Isabella Jane", + "Connor" + ] + }, + { + "name": "Robert Downey Jr.", + "age": 53, + "Born At": "New York City, NY", + "Birthdate": "April 4, 1965", + "photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg", + "wife": "Susan Downey", + "weight": 77.1, + "hasChildren": true, + "hasGreyHair": false, + "children": [ + "Noemi", + "Avri Roel", + "Exton Elias" + ] + } + ] + }' + ); + l_actual := json_object_t.parse(' { + "Actors": + { + "name": "Krzystof Jarzyna", + "age": 53, + "Born At": "Szczecin", + "Birthdate": "April 4, 1965", + "photo": "niewidzialny", + "wife": "Susan Downey", + "children": [ + "Indio Falconer", + "Avri Roel", + "Exton Elias" + ] + } + }' + ); + + + --Act + ut3.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors.children'))).to_equal(json_array_t(json_query(l_expected + .stringify,'$.Actors[1].children'))); + --Assert + l_expected_message := q'[%Actual: json was expected to equal: json +%Diff: 1 differences found +%1 unequal values +%Actual value: "Noemi" was expected to be: "Indio Falconer" on path: $[0]%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure long_json_test + as + l_actual json_element_t; + begin + l_actual := json_element_t.parse('[ + { + "_id": "5ce6dc0c3a11766d5a26f494", + "index": 0, + "guid": "a86b8b2d-216d-4061-bafa-f3820e41efbe", + "isActive": true, + "balance": "$1,754.93", + "picture": "http://placehold.it/32x32", + "age": 39, + "eyeColor": "green", + "name": "Pearlie Lott", + "gender": "female", + "company": "KOG", + "email": "pearlielott@kog.com", + "phone": "+1 (852) 567-2605", + "address": "357 Eldert Street, Benson, Montana, 5484", + "about": "Est officia consectetur reprehenderit fugiat culpa ea commodo aliqua deserunt enim eu. Exercitation adipisicing laboris nisi irure commodo dolor consectetur tempor minim sunt ullamco Lorem occaecat. Irure quis ut Lorem aliquip aute pariatur magna laboris duis veniam qui velit. Pariatur occaecat eu minim adipisicing est do. Occaecat do ipsum ut in enim quis voluptate et. Sit ea irure nulla culpa in eiusmod.\r\n", + "registered": "2018-08-24T12:46:31 -01:00", + "latitude": -22.323554, + "longitude": 139.071611, + "tags": [ + "id", + "do", + "amet", + "magna", + "est", + "veniam", + "voluptate" + ], + "friends": [ + { + "id": 0, + "name": "Tammi Lowe" + }, + { + "id": 1, + "name": "Simpson Miles" + }, + { + "id": 2, + "name": "Hogan Osborne" + } + ], + "greeting": "Hello, Pearlie Lott! You have 2 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5ce6dc0c2b56a6f3271fc272", + "index": 1, + "guid": "2a24b446-d11a-4a52-b6c8-86acba1dc65f", + "isActive": true, + "balance": "$1,176.58", + "picture": "http://placehold.it/32x32", + "age": 30, + "eyeColor": "brown", + "name": "Bertha Mack", + "gender": "female", + "company": "AQUAFIRE", + "email": "berthamack@aquafire.com", + "phone": "+1 (804) 504-2151", + "address": "636 Bouck Court, Cresaptown, Vermont, 5203", + "about": "Ipsum est exercitation excepteur reprehenderit ipsum. Do velit dolore minim ad. Quis amet dolor dolore exercitation sint Lorem. Exercitation nulla magna ut incididunt enim veniam voluptate Lorem velit adipisicing sunt deserunt sunt aute. Ullamco id anim Lorem dolore do labore excepteur et reprehenderit sit adipisicing sunt esse veniam. Anim laborum labore labore incididunt in labore exercitation ad occaecat amet ea quis veniam ut.\r\n", + "registered": "2017-12-29T06:00:27 -00:00", + "latitude": 75.542572, + "longitude": 147.312705, + "tags": [ + "veniam", + "sunt", + "commodo", + "ad", + "enim", + "officia", + "nisi" + ], + "friends": [ + { + "id": 0, + "name": "Riddle Williams" + }, + { + "id": 1, + "name": "Tracy Wagner" + }, + { + "id": 2, + "name": "Morrow Phillips" + } + ], + "greeting": "Hello, Bertha Mack! You have 8 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5ce6dc0c6d8631fbfdd2afc7", + "index": 2, + "guid": "66ca5411-4c88-4347-9972-e1016f628098", + "isActive": false, + "balance": "$2,732.22", + "picture": "http://placehold.it/32x32", + "age": 33, + "eyeColor": "blue", + "name": "Fox Morgan", + "gender": "male", + "company": "PERKLE", + "email": "foxmorgan@perkle.com", + "phone": "+1 (985) 401-3450", + "address": "801 Whitty Lane, Snyderville, Guam, 5253", + "about": "Ex officia eu Lorem velit ullamco qui cupidatat irure sunt ea ad deserunt. Officia est consequat aute labore occaecat aliquip. Velit commodo cillum incididunt cupidatat ad id veniam aute labore tempor qui culpa voluptate dolor. Occaecat in ea id labore exercitation non tempor occaecat laboris aute irure fugiat dolor mollit. Voluptate non proident officia deserunt ex et ullamco aute eiusmod cupidatat consequat elit id.\r\n", + "registered": "2015-04-02T06:40:53 -01:00", + "latitude": -27.612441, + "longitude": -134.005929, + "tags": [ + "occaecat", + "amet", + "eu", + "dolore", + "ad", + "fugiat", + "quis" + ], + "friends": [ + { + "id": 0, + "name": "Case Preston" + }, + { + "id": 1, + "name": "Pollard Dawson" + }, + { + "id": 2, + "name": "Frye Mann" + } + ], + "greeting": "Hello, Fox Morgan! You have 2 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5ce6dc0c0a7fea91e0a1fdf5", + "index": 3, + "guid": "f895a236-fc0d-4c08-b2f0-9d1638dc256d", + "isActive": true, + "balance": "$2,746.32", + "picture": "http://placehold.it/32x32", + "age": 34, + "eyeColor": "green", + "name": "Deleon Tucker", + "gender": "male", + "company": "ZANILLA", + "email": "deleontucker@zanilla.com", + "phone": "+1 (883) 415-2709", + "address": "540 Vandam Street, Chical, Wyoming, 5181", + "about": "Consectetur consectetur sint Lorem non id. Fugiat reprehenderit nulla dolore nisi culpa esse ea. Ad occaecat qui magna proident ex pariatur aliquip adipisicing do aute aute sunt. Aliqua aliqua et exercitation sunt ut adipisicing.\r\n", + "registered": "2017-10-08T09:05:49 -01:00", + "latitude": 34.893845, + "longitude": 110.699256, + "tags": [ + "culpa", + "sunt", + "sit", + "ut", + "eiusmod", + "laboris", + "ullamco" + ], + "friends": [ + { + "id": 0, + "name": "Bernadine Pennington" + }, + { + "id": 1, + "name": "Latoya Bradshaw" + }, + { + "id": 2, + "name": "Iva Caldwell" + } + ], + "greeting": "Hello, Deleon Tucker! You have 7 unread messages.", + "favoriteFruit": "banana" + }, + { + "_id": "5ce6dc0c18bc92716a12a8e4", + "index": 4, + "guid": "6ed45f42-1a2b-48b2-89ce-5fdb2505343b", + "isActive": true, + "balance": "$1,049.96", + "picture": "http://placehold.it/32x32", + "age": 30, + "eyeColor": "blue", + "name": "Schwartz Norman", + "gender": "male", + "company": "UPDAT", + "email": "schwartznorman@updat.com", + "phone": "+1 (826) 404-3309", + "address": "925 Harman Street, Cornucopia, Georgia, 5748", + "about": "Qui Lorem ullamco veniam irure aliquip amet exercitation. Velit nisi id laboris adipisicing in esse adipisicing commodo cillum do exercitation tempor. Consequat tempor dolor minim consequat minim ad do tempor excepteur.\r\n", + "registered": "2014-08-10T08:34:27 -01:00", + "latitude": 27.35547, + "longitude": -77.343791, + "tags": [ + "reprehenderit", + "nisi", + "duis", + "fugiat", + "id", + "non", + "laboris" + ], + "friends": [ + { + "id": 0, + "name": "Dora Combs" + }, + { + "id": 1, + "name": "Emerson Wade" + }, + { + "id": 2, + "name": "Alma Mccormick" + } + ], + "greeting": "Hello, Schwartz Norman! You have 1 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5ce6dc0cb7ae44eb76c3e5fd", + "index": 5, + "guid": "0516df27-73db-42a8-b2c3-d34bd976e031", + "isActive": false, + "balance": "$3,679.94", + "picture": "http://placehold.it/32x32", + "age": 32, + "eyeColor": "brown", + "name": "Christi Oneal", + "gender": "female", + "company": "SUREPLEX", + "email": "christioneal@sureplex.com", + "phone": "+1 (985) 408-3098", + "address": "640 Fayette Street, Dennard, Washington, 7962", + "about": "Dolore fugiat sit non dolore nostrud mollit enim id sint culpa do reprehenderit ad. Velit occaecat incididunt nostrud aliqua incididunt do cillum occaecat laboris quis duis. Non tempor culpa aliquip est est consectetur ullamco elit. Voluptate et sit do et. Amet sit irure eu ex enim nulla anim deserunt ut. Sit aute ea ut fugiat eu tempor Lorem.\r\n", + "registered": "2015-05-10T09:24:56 -01:00", + "latitude": 43.343805, + "longitude": 79.535043, + "tags": [ + "occaecat", + "laboris", + "nulla", + "nisi", + "dolore", + "cillum", + "dolore" + ], + "friends": [ + { + "id": 0, + "name": "Marquez Wiggins" + }, + { + "id": 1, + "name": "Mai Fischer" + }, + { + "id": 2, + "name": "Newman Davenport" + } + ], + "greeting": "Hello, Christi Oneal! You have 8 unread messages.", + "favoriteFruit": "strawberry" + } +]'); + + --Act + ut3.ut.expect( l_actual ).to_equal( l_actual ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure json_same_diffrent_ord + as + l_expected json_element_t; + l_actual json_element_t; + begin + -- Arrange + l_expected := json_element_t.parse('{ + "records": [ + {"field1": "outer", "field2": "thought"}, + {"field2": "thought", "field1": "outer"} + ] , + "special message": "hello, world!" +}'); + l_actual := json_element_t.parse('{ + "special message": "hello, world!" , + "records": [ + {"field2": "thought" ,"field1": "outer"}, + {"field1": "outer" , "field2": "thought"} + ] +}'); + + --Act + ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure long_json_test2 + as + l_actual json_element_t; + begin + l_actual := json_element_t.parse('[ + { + "_id":"5ce6dc0c3a11766d5a26f494", + "index":0, + "guid":"a86b8b2d-216d-4061-bafa-f3820e41efbe", + "isActive":true, + "balance":"$1,754.93", + "picture":"http://placehold.it/32x32", + "age":39, + "eyeColor":"green", + "name":"Pearlie Lott", + "gender":"female", + "company":"KOG", + "email":"pearlielott@kog.com", + "phone":"+1 (852) 567-2605", + "address":"357 Eldert Street, Benson, Montana, 5484", + "about":"Est officia consectetur reprehenderit fugiat culpa ea commodo aliqua deserunt enim eu. Exercitation adipisicing laboris nisi irure commodo dolor consectetur tempor minim sunt ullamco Lorem occaecat. Irure quis ut Lorem aliquip aute pariatur magna laboris duis veniam qui velit. Pariatur occaecat eu minim adipisicing est do. Occaecat do ipsum ut in enim quis voluptate et. Sit ea irure nulla culpa in eiusmod.\r\n", + "registered":"2018-08-24T12:46:31 -01:00", + "latitude":-22.323554, + "longitude":139.071611, + "tags":[ + "id", + "do", + "amet", + "magna", + "est", + "veniam", + "voluptate" + ], + "friends":[ + { + "id":0, + "name":"Tammi Lowe" + }, + { + "id":1, + "name":"Simpson Miles" + }, + { + "id":2, + "name":"Hogan Osborne" + } + ], + "greeting":"Hello, Pearlie Lott! You have 2 unread messages.", + "favoriteFruit":"banana" + }, + { + "_id":"5ce6dc0c2b56a6f3271fc272", + "index":1, + "guid":"2a24b446-d11a-4a52-b6c8-86acba1dc65f", + "isActive":true, + "balance":"$1,176.58", + "picture":"http://placehold.it/32x32", + "age":30, + "eyeColor":"brown", + "name":"Bertha Mack", + "gender":"female", + "company":"AQUAFIRE", + "email":"berthamack@aquafire.com", + "phone":"+1 (804) 504-2151", + "address":"636 Bouck Court, Cresaptown, Vermont, 5203", + "about":"Ipsum est exercitation excepteur reprehenderit ipsum. Do velit dolore minim ad. Quis amet dolor dolore exercitation sint Lorem. Exercitation nulla magna ut incididunt enim veniam voluptate Lorem velit adipisicing sunt deserunt sunt aute. Ullamco id anim Lorem dolore do labore excepteur et reprehenderit sit adipisicing sunt esse veniam. Anim laborum labore labore incididunt in labore exercitation ad occaecat amet ea quis veniam ut.\r\n", + "registered":"2017-12-29T06:00:27 -00:00", + "latitude":75.542572, + "longitude":147.312705, + "tags":[ + "veniam", + "sunt", + "commodo", + "ad", + "enim", + "officia", + "nisi" + ], + "friends":[ + { + "id":0, + "name":"Riddle Williams" + }, + { + "id":1, + "name":"Tracy Wagner" + }, + { + "id":2, + "name":"Morrow Phillips" + } + ], + "greeting":"Hello, Bertha Mack! You have 8 unread messages.", + "favoriteFruit":"banana" + }, + { + "_id":"5ce6dc0c6d8631fbfdd2afc7", + "index":2, + "guid":"66ca5411-4c88-4347-9972-e1016f628098", + "isActive":false, + "balance":"$2,732.22", + "picture":"http://placehold.it/32x32", + "age":33, + "eyeColor":"blue", + "name":"Fox Morgan", + "gender":"male", + "company":"PERKLE", + "email":"foxmorgan@perkle.com", + "phone":"+1 (985) 401-3450", + "address":"801 Whitty Lane, Snyderville, Guam, 5253", + "about":"Ex officia eu Lorem velit ullamco qui cupidatat irure sunt ea ad deserunt. Officia est consequat aute labore occaecat aliquip. Velit commodo cillum incididunt cupidatat ad id veniam aute labore tempor qui culpa voluptate dolor. Occaecat in ea id labore exercitation non tempor occaecat laboris aute irure fugiat dolor mollit. Voluptate non proident officia deserunt ex et ullamco aute eiusmod cupidatat consequat elit id.\r\n", + "registered":"2015-04-02T06:40:53 -01:00", + "latitude":-27.612441, + "longitude":-134.005929, + "tags":[ + "occaecat", + "amet", + "eu", + "dolore", + "ad", + "fugiat", + "quis" + ], + "friends":[ + { + "id":0, + "name":"Case Preston" + }, + { + "id":1, + "name":"Pollard Dawson" + }, + { + "id":2, + "name":"Frye Mann" + } + ], + "greeting":"Hello, Fox Morgan! You have 2 unread messages.", + "favoriteFruit":"apple" + }, + { + "_id":"5ce6dc0c0a7fea91e0a1fdf5", + "index":3, + "guid":"f895a236-fc0d-4c08-b2f0-9d1638dc256d", + "isActive":true, + "balance":"$2,746.32", + "picture":"http://placehold.it/32x32", + "age":34, + "eyeColor":"green", + "name":"Deleon Tucker", + "gender":"male", + "company":"ZANILLA", + "email":"deleontucker@zanilla.com", + "phone":"+1 (883) 415-2709", + "address":"540 Vandam Street, Chical, Wyoming, 5181", + "about":"Consectetur consectetur sint Lorem non id. Fugiat reprehenderit nulla dolore nisi culpa esse ea. Ad occaecat qui magna proident ex pariatur aliquip adipisicing do aute aute sunt. Aliqua aliqua et exercitation sunt ut adipisicing.\r\n", + "registered":"2017-10-08T09:05:49 -01:00", + "latitude":34.893845, + "longitude":110.699256, + "tags":[ + "culpa", + "sunt", + "sit", + "ut", + "eiusmod", + "laboris", + "ullamco" + ], + "friends":[ + { + "id":0, + "name":"Bernadine Pennington" + }, + { + "id":1, + "name":"Latoya Bradshaw" + }, + { + "id":2, + "name":"Iva Caldwell" + } + ], + "greeting":"Hello, Deleon Tucker! You have 7 unread messages.", + "favoriteFruit":"banana" + }, + { + "_id":"5ce6dc0c18bc92716a12a8e4", + "index":4, + "guid":"6ed45f42-1a2b-48b2-89ce-5fdb2505343b", + "isActive":true, + "balance":"$1,049.96", + "picture":"http://placehold.it/32x32", + "age":30, + "eyeColor":"blue", + "name":"Schwartz Norman", + "gender":"male", + "company":"UPDAT", + "email":"schwartznorman@updat.com", + "phone":"+1 (826) 404-3309", + "address":"925 Harman Street, Cornucopia, Georgia, 5748", + "about":"Qui Lorem ullamco veniam irure aliquip amet exercitation. Velit nisi id laboris adipisicing in esse adipisicing commodo cillum do exercitation tempor. Consequat tempor dolor minim consequat minim ad do tempor excepteur.\r\n", + "registered":"2014-08-10T08:34:27 -01:00", + "latitude":27.35547, + "longitude":-77.343791, + "tags":[ + "reprehenderit", + "nisi", + "duis", + "fugiat", + "id", + "non", + "laboris" + ], + "friends":[ + { + "id":0, + "name":"Dora Combs" + }, + { + "id":1, + "name":"Emerson Wade" + }, + { + "id":2, + "name":"Alma Mccormick" + } + ], + "greeting":"Hello, Schwartz Norman! You have 1 unread messages.", + "favoriteFruit":"apple" + }, + { + "_id":"5ce6dc0cb7ae44eb76c3e5fd", + "index":5, + "guid":"0516df27-73db-42a8-b2c3-d34bd976e031", + "isActive":false, + "balance":"$3,679.94", + "picture":"http://placehold.it/32x32", + "age":32, + "eyeColor":"brown", + "name":"Christi Oneal", + "gender":"female", + "company":"SUREPLEX", + "email":"christioneal@sureplex.com", + "phone":"+1 (985) 408-3098", + "address":"640 Fayette Street, Dennard, Washington, 7962", + "about":"Dolore fugiat sit non dolore nostrud mollit enim id sint culpa do reprehenderit ad. Velit occaecat incididunt nostrud aliqua incididunt do cillum occaecat laboris quis duis. Non tempor culpa aliquip est est consectetur ullamco elit. Voluptate et sit do et. Amet sit irure eu ex enim nulla anim deserunt ut. Sit aute ea ut fugiat eu tempor Lorem.\r\n", + "registered":"2015-05-10T09:24:56 -01:00", + "latitude":43.343805, + "longitude":79.535043, + "tags":[ + "occaecat", + "laboris", + "nulla", + "nisi", + "dolore", + "cillum", + "dolore" + ], + "friends":[ + { + "id":0, + "name":"Marquez Wiggins" + }, + { + "id":1, + "name":"Mai Fischer" + }, + { + "id":2, + "name":"Newman Davenport" + } + ], + "greeting":"Hello, Christi Oneal! You have 8 unread messages.", + "favoriteFruit":"strawberry" + } +]'); + + --Act + ut3.ut.expect( l_actual ).to_equal( l_actual ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure long_json_diff as + l_expected json_element_t; + l_actual json_element_t; + l_expected_message varchar2(32767); + l_actual_message varchar2(32767); + begin + -- Arrange + l_expected := json_element_t.parse('[ + { + "_id": "5ce6ec46cb9977b050f15d97", + "index": 0, + "guid": "1acb2b6b-15b5-4747-a62f-db477e18df61", + "isActive": false, + "balance": "$1,443.80", + "picture": "http://placehold.it/32x32", + "age": 33, + "eyeColor": "brown", + "name": "Carson Conley", + "gender": "male", + "company": "EYEWAX", + "email": "carsonconley@eyewax.com", + "phone": "+1 (873) 520-2117", + "address": "289 Wallabout Street, Cazadero, Nevada, 4802", + "about": "Lorem aliqua veniam eiusmod exercitation anim sunt esse qui tempor officia amet nulla labore enim. Fugiat eiusmod amet exercitation incididunt mollit pariatur amet et quis et ex amet adipisicing. Elit in commodo tempor adipisicing exercitation Lorem amet cillum sint sint aliquip. Officia enim do irure velit qui officia et reprehenderit qui enim.\r\n", + "registered": "2018-08-07T05:03:13 -01:00", + "latitude": -1.973252, + "longitude": 17.835529, + "tags": [ + "dolore", + "occaecat", + "proident", + "laborum", + "nostrud", + "non", + "occaecat" + ], + "friends": [ + { + "id": 0, + "name": "Riggs Cardenas" + }, + { + "id": 1, + "name": "Duncan Schultz" + }, + { + "id": 2, + "name": "Galloway Bond" + } + ], + "greeting": "Hello, Carson Conley! You have 5 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5ce6ec469ba57bef5c421021", + "index": 1, + "guid": "59be5b73-fffe-4a4f-acea-65c5abbdb53c", + "isActive": true, + "balance": "$3,895.35", + "picture": "http://placehold.it/32x32", + "age": 21, + "eyeColor": "brown", + "name": "Melton Carroll", + "gender": "male", + "company": "ISOSPHERE", + "email": "meltoncarroll@isosphere.com", + "phone": "+1 (804) 416-2235", + "address": "114 Windsor Place, Dubois, Oklahoma, 9648", + "about": "Pariatur ea voluptate aute dolor minim laborum cillum ad reprehenderit. Mollit sint voluptate duis et culpa amet irure laborum. Nulla veniam fugiat sint proident aliquip dolore laboris nisi et. Nisi in do aliqua voluptate cupidatat enim dolor minim minim qui tempor. Eu anim ea mollit sunt esse et est cillum cillum pariatur dolor. Ea anim duis sunt eiusmod sit cillum consectetur aliquip ad et elit culpa irure commodo.\r\n", + "registered": "2018-10-20T01:38:32 -01:00", + "latitude": 46.821539, + "longitude": 19.78817, + "tags": [ + "sunt", + "aliquip", + "commodo", + "occaecat", + "mollit", + "minim", + "sint" + ], + "friends": [ + { + "id": 0, + "name": "Tameka Reese" + }, + { + "id": 1, + "name": "Rosemarie Buckley" + }, + { + "id": 2, + "name": "Houston Moran" + } + ], + "greeting": "Hello, Melton Carroll! You have 10 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5ce6ec464e6f8751e75ed29f", + "index": 2, + "guid": "42e07b71-b769-4078-b226-f79048b75bd2", + "isActive": false, + "balance": "$3,366.81", + "picture": "http://placehold.it/32x32", + "age": 23, + "eyeColor": "blue", + "name": "Kathie Cameron", + "gender": "female", + "company": "EVENTIX", + "email": "kathiecameron@eventix.com", + "phone": "+1 (949) 416-3458", + "address": "171 Henderson Walk, Barstow, American Samoa, 3605", + "about": "Lorem est mollit consequat pariatur elit. Enim adipisicing ipsum sit labore exercitation fugiat qui eu enim. Quis irure Lorem exercitation laborum sunt quis Lorem pariatur officia veniam aute officia mollit quis.\r\n", + "registered": "2015-07-15T08:40:18 -01:00", + "latitude": -12.947501, + "longitude": 51.221756, + "tags": [ + "voluptate", + "officia", + "laborum", + "nulla", + "anim", + "mollit", + "adipisicing" + ], + "friends": [ + { + "id": 0, + "name": "Noelle Leonard" + }, + { + "id": 1, + "name": "Sally Barr" + }, + { + "id": 2, + "name": "Rosie Rutledge" + } + ], + "greeting": "Hello, Kathie Cameron! You have 10 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5ce6ec4632328a654d592cb6", + "index": 3, + "guid": "6b9124a9-fbde-4c60-8dac-e296f5daa3c4", + "isActive": true, + "balance": "$2,374.96", + "picture": "http://placehold.it/32x32", + "age": 32, + "eyeColor": "brown", + "name": "Ebony Carver", + "gender": "female", + "company": "EVENTEX", + "email": "ebonycarver@eventex.com", + "phone": "+1 (816) 535-3332", + "address": "452 Lott Street, Iberia, South Carolina, 1635", + "about": "Ea cupidatat occaecat in Lorem adipisicing quis sunt. Occaecat sit Lorem eiusmod et. Velit nostrud cupidatat do exercitation. Officia esse excepteur labore aliqua fugiat dolor duis. Ullamco qui ipsum eu do nostrud et laboris magna dolor cillum. Dolore eiusmod do occaecat dolore.\r\n", + "registered": "2017-04-12T09:20:02 -01:00", + "latitude": 65.70655, + "longitude": 150.667286, + "tags": [ + "do", + "laboris", + "exercitation", + "quis", + "laboris", + "amet", + "sint" + ], + "friends": [ + { + "id": 0, + "name": "Rowena Holloway" + }, + { + "id": 1, + "name": "Lee Chang" + }, + { + "id": 2, + "name": "Delaney Kennedy" + } + ], + "greeting": "Hello, Ebony Carver! You have 10 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5ce6ec46d9dbfbf9b184cee7", + "index": 4, + "guid": "9dece65b-6b48-4960-880b-7795ff63c81c", + "isActive": false, + "balance": "$2,927.54", + "picture": "http://placehold.it/32x32", + "age": 27, + "eyeColor": "green", + "name": "Mae Payne", + "gender": "female", + "company": "ZEPITOPE", + "email": "maepayne@zepitope.com", + "phone": "+1 (904) 531-2930", + "address": "575 Amity Street, Eden, Iowa, 4017", + "about": "Voluptate ex enim aliqua ea et proident ipsum est anim nostrud. Duis aliquip voluptate voluptate non aliquip. Elit commodo Lorem aliqua sit elit consectetur reprehenderit in aute minim. Dolor non incididunt do tempor aliquip esse non magna anim eiusmod ut id id.\r\n", + "registered": "2016-08-29T06:23:00 -01:00", + "latitude": -60.325313, + "longitude": 88.598722, + "tags": [ + "est", + "incididunt", + "officia", + "sunt", + "eu", + "ut", + "deserunt" + ], + "friends": [ + { + "id": 0, + "name": "Taylor Walton" + }, + { + "id": 1, + "name": "Celina Mcdonald" + }, + { + "id": 2, + "name": "Berry Rivers" + } + ], + "greeting": "Hello, Mae Payne! You have 4 unread messages.", + "favoriteFruit": "strawberry" + } +]'); + l_actual := json_element_t.parse('[ + { + "_id": "5ce6ec6660565269b16cf836", + "index": 0, + "guid": "c222eda5-d925-4163-89e3-4b0e50d5e297", + "isActive": false, + "balance": "$3,626.25", + "picture": "http://placehold.it/32x32", + "age": 28, + "eyeColor": "green", + "name": "Leigh Munoz", + "gender": "female", + "company": "OATFARM", + "email": "leighmunoz@oatfarm.com", + "phone": "+1 (969) 545-2708", + "address": "218 Mersereau Court, Homeworth, Connecticut, 4423", + "about": "Eiusmod exercitation incididunt ea incididunt anim voluptate. Duis laboris ut Lorem pariatur tempor voluptate occaecat laboris. Enim duis excepteur cillum ullamco pariatur sint. Dolor labore qui ullamco deserunt do consectetur labore velit occaecat officia incididunt Lorem dolore. Pariatur dolor voluptate ex adipisicing labore quis aliquip aliquip. Culpa tempor proident nisi occaecat aliqua mollit ullamco nisi cillum ipsum exercitation quis excepteur. Consequat officia ex ipsum id consequat deserunt sunt id nostrud magna.\r\n", + "registered": "2018-10-08T10:24:07 -01:00", + "latitude": -42.796797, + "longitude": -14.220273, + "tags": [ + "ex", + "elit", + "consectetur", + "ipsum", + "aute", + "ipsum", + "Lorem" + ], + "friends": [ + { + "id": 0, + "name": "Selena Dunn" + }, + { + "id": 1, + "name": "Wilda Haynes" + }, + { + "id": 2, + "name": "Calderon Long" + } + ], + "greeting": "Hello, Leigh Munoz! You have 6 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5ce6ec66383ddbf3c400e3ed", + "index": 1, + "guid": "2e778803-50d3-411f-b34d-47d0f19d03f7", + "isActive": false, + "balance": "$2,299.28", + "picture": "http://placehold.it/32x32", + "age": 23, + "eyeColor": "blue", + "name": "Velez Drake", + "gender": "male", + "company": "GENMY", + "email": "velezdrake@genmy.com", + "phone": "+1 (870) 564-2219", + "address": "526 Erskine Loop, Websterville, Nebraska, 1970", + "about": "Consectetur Lorem do ex est dolor. Consectetur do tempor amet elit. Amet dolore cupidatat Lorem sunt reprehenderit.\r\n", + "registered": "2017-11-24T04:42:37 -00:00", + "latitude": -45.78579, + "longitude": 142.062878, + "tags": [ + "do", + "esse", + "nisi", + "sunt", + "et", + "nisi", + "nostrud" + ], + "friends": [ + { + "id": 0, + "name": "Bessie Schmidt" + }, + { + "id": 1, + "name": "Harriett Lyons" + }, + { + "id": 2, + "name": "Jerry Gonzales" + } + ], + "greeting": "Hello, Velez Drake! You have 1 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5ce6ec660a8b5f95ed543305", + "index": 2, + "guid": "bb0eaa88-f7fd-4b72-8538-8c0b4595bcec", + "isActive": true, + "balance": "$3,085.28", + "picture": "http://placehold.it/32x32", + "age": 36, + "eyeColor": "green", + "name": "Gallegos Dominguez", + "gender": "male", + "company": "QOT", + "email": "gallegosdominguez@qot.com", + "phone": "+1 (947) 581-3675", + "address": "375 Temple Court, Beaulieu, Minnesota, 3880", + "about": "Qui consequat est aliquip esse minim Lorem qui quis. Enim consequat anim culpa consequat ex incididunt ad incididunt est id excepteur nulla culpa. Aliqua enim enim exercitation anim velit occaecat voluptate qui minim ut ullamco fugiat. Anim voluptate nulla minim labore dolore eu veniam. Exercitation sint eiusmod aute aliqua magna aliqua pariatur Lorem velit pariatur ex duis.\r\n", + "registered": "2019-03-11T12:36:55 -00:00", + "latitude": -1.619328, + "longitude": -160.580052, + "tags": [ + "ipsum", + "reprehenderit", + "id", + "aliqua", + "ad", + "do", + "sunt" + ], + "friends": [ + { + "id": 0, + "name": "Justice Bruce" + }, + { + "id": 1, + "name": "Alta Clements" + }, + { + "id": 2, + "name": "Amy Hobbs" + } + ], + "greeting": "Hello, Gallegos Dominguez! You have 10 unread messages.", + "favoriteFruit": "strawberry" + }, + { + "_id": "5ce6ec6600fb7aaee2d1243e", + "index": 3, + "guid": "4a4363b5-9d65-4b22-9b58-a5c8c1c5bd5d", + "isActive": false, + "balance": "$3,152.70", + "picture": "http://placehold.it/32x32", + "age": 37, + "eyeColor": "green", + "name": "Bobbie Baldwin", + "gender": "female", + "company": "IDEGO", + "email": "bobbiebaldwin@idego.com", + "phone": "+1 (937) 501-3123", + "address": "271 Coles Street, Deltaville, Massachusetts, 349", + "about": "Dolor labore quis Lorem eiusmod duis adipisicing ut. Aute aute aliquip exercitation eiusmod veniam ullamco irure sit est. Ut Lorem incididunt do sint laborum cillum Lorem commodo duis. Dolor nulla ad consectetur non cillum. Est excepteur esse mollit elit laborum ullamco exercitation sit esse. Reprehenderit occaecat ad ad reprehenderit adipisicing non Lorem ipsum fugiat culpa. Do quis non exercitation ea magna elit non.\r\n", + "registered": "2014-06-25T07:44:03 -01:00", + "latitude": -70.045195, + "longitude": 117.328462, + "tags": [ + "anim", + "excepteur", + "aliqua", + "mollit", + "non", + "in", + "adipisicing" + ], + "friends": [ + { + "id": 0, + "name": "Lora Little" + }, + { + "id": 1, + "name": "Stanton Pollard" + }, + { + "id": 2, + "name": "Bernice Knowles" + } + ], + "greeting": "Hello, Bobbie Baldwin! You have 5 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5ce6ec660585cbb589b34fc8", + "index": 4, + "guid": "18547241-6fd0-466d-9f79-21aeb0485294", + "isActive": false, + "balance": "$3,853.86", + "picture": "http://placehold.it/32x32", + "age": 32, + "eyeColor": "blue", + "name": "Erika Benton", + "gender": "female", + "company": "SURETECH", + "email": "erikabenton@suretech.com", + "phone": "+1 (833) 472-2277", + "address": "893 Jamison Lane, Grayhawk, Illinois, 1820", + "about": "Ullamco nisi quis esse fugiat eu proident nisi cupidatat reprehenderit nostrud nulla laborum duis. Duis quis ipsum ad voluptate enim. Et excepteur irure proident adipisicing enim eu veniam aliquip nostrud amet sit est. Non laborum reprehenderit qui ullamco occaecat elit sunt ea nostrud reprehenderit incididunt sunt.\r\n", + "registered": "2018-01-19T11:58:53 -00:00", + "latitude": -44.595301, + "longitude": 100.938225, + "tags": [ + "cupidatat", + "aliqua", + "nostrud", + "nostrud", + "ipsum", + "ipsum", + "commodo" + ], + "friends": [ + { + "id": 0, + "name": "Addie Benjamin" + }, + { + "id": 1, + "name": "Brock Nolan" + }, + { + "id": 2, + "name": "Betty Suarez" + } + ], + "greeting": "Hello, Erika Benton! You have 5 unread messages.", + "favoriteFruit": "apple" + }, + { + "_id": "5ce6ec66ff15753596332021", + "index": 5, + "guid": "f865dabb-4871-4f29-9c56-17361d254f39", + "isActive": true, + "balance": "$3,474.90", + "picture": "http://placehold.it/32x32", + "age": 32, + "eyeColor": "blue", + "name": "Rice Owens", + "gender": "male", + "company": "ACIUM", + "email": "riceowens@acium.com", + "phone": "+1 (975) 576-3718", + "address": "400 Halleck Street, Lafferty, District Of Columbia, 495", + "about": "Cupidatat laborum mollit non eu aute amet consectetur aliqua officia consectetur consequat. Tempor labore pariatur Lorem sint quis laborum est dolore et. Est ipsum incididunt eiusmod enim nostrud laboris duis est enim proident do laborum id culpa.\r\n", + "registered": "2018-05-06T02:43:06 -01:00", + "latitude": 2.843708, + "longitude": -3.301217, + "tags": [ + "laboris", + "velit", + "dolore", + "sunt", + "ad", + "aliqua", + "duis" + ], + "friends": [ + { + "id": 0, + "name": "Ramirez King" + }, + { + "id": 1, + "name": "Jeannie Boyer" + }, + { + "id": 2, + "name": "Deloris Jensen" + } + ], + "greeting": "Hello, Rice Owens! You have 9 unread messages.", + "favoriteFruit": "banana" + } +]'); + + --Act + ut3.ut.expect( l_actual ).to_equal( l_expected ); + --Assert + l_expected_message := q'[%Diff: 133 differences found, showing first 20 +%132 unequal values, 1 missing properties +%Extra property: object on path: $[5] +%Actual value: "5ce6ec46cb9977b050f15d97" was expected to be: "5ce6ec6660565269b16cf836" on path: $[0]."_id" +%Actual value: "5ce6ec469ba57bef5c421021" was expected to be: "5ce6ec66383ddbf3c400e3ed" on path: $[1]."_id" +%Actual value: "5ce6ec4632328a654d592cb6" was expected to be: "5ce6ec6600fb7aaee2d1243e" on path: $[3]."_id" +%Actual value: "5ce6ec464e6f8751e75ed29f" was expected to be: "5ce6ec660a8b5f95ed543305" on path: $[2]."_id" +%Actual value: "5ce6ec46d9dbfbf9b184cee7" was expected to be: "5ce6ec660585cbb589b34fc8" on path: $[4]."_id" +%Actual value: "59be5b73-fffe-4a4f-acea-65c5abbdb53c" was expected to be: "2e778803-50d3-411f-b34d-47d0f19d03f7" on path: $[1]."guid" +%Actual value: "9dece65b-6b48-4960-880b-7795ff63c81c" was expected to be: "18547241-6fd0-466d-9f79-21aeb0485294" on path: $[4]."guid" +%Actual value: "42e07b71-b769-4078-b226-f79048b75bd2" was expected to be: "bb0eaa88-f7fd-4b72-8538-8c0b4595bcec" on path: $[2]."guid" +%Actual value: "6b9124a9-fbde-4c60-8dac-e296f5daa3c4" was expected to be: "4a4363b5-9d65-4b22-9b58-a5c8c1c5bd5d" on path: $[3]."guid" +%Actual value: "1acb2b6b-15b5-4747-a62f-db477e18df61" was expected to be: "c222eda5-d925-4163-89e3-4b0e50d5e297" on path: $[0]."guid" +%Actual value: FALSE was expected to be: TRUE on path: $[2]."isActive" +%Actual value: TRUE was expected to be: FALSE on path: $[3]."isActive" +%Actual value: TRUE was expected to be: FALSE on path: $[1]."isActive" +%Actual value: "$3,895.35" was expected to be: "$2,299.28" on path: $[1]."balance" +%Actual value: "$1,443.80" was expected to be: "$3,626.25" on path: $[0]."balance" +%Actual value: "$3,366.81" was expected to be: "$3,085.28" on path: $[2]."balance" +%Actual value: "$2,927.54" was expected to be: "$3,853.86" on path: $[4]."balance" +%Actual value: "$2,374.96" was expected to be: "$3,152.70" on path: $[3]."balance" +%Actual value: 23 was expected to be: 36 on path: $[2]."age"%]'; + + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); + --Assert + ut.expect(l_actual_message).to_be_like(l_expected_message); + end; + + procedure check_json_objects is + l_expected json_object_t; + l_actual json_object_t; + begin + l_expected := json_object_t('{ "name" : "Bond", "proffesion" : "spy", "drink" : "martini"}'); + l_actual := json_object_t('{ "proffesion" : "spy","name" : "Bond", "drink" : "martini"}'); + ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure check_json_arrays is + l_expected json_array_t; + l_actual json_array_t; + begin + l_expected := json_array_t('[ {"name" : "Bond", "proffesion" : "spy", "drink" : "martini"} , {"name" : "Kloss", "proffesion" : "spy", "drink" : "beer"} ]'); + l_actual := json_array_t('[ {"name" : "Bond", "proffesion" : "spy", "drink" : "martini"} , {"name" : "Kloss", "proffesion" : "spy", "drink" : "beer"} ]'); + ut3.ut.expect( l_actual ).to_equal( l_expected ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + +end; +/ diff --git a/test/ut3_user/expectations/test_expectations_json.pks b/test/ut3_user/expectations/test_expectations_json.pks new file mode 100644 index 000000000..64dff42e8 --- /dev/null +++ b/test/ut3_user/expectations/test_expectations_json.pks @@ -0,0 +1,79 @@ +create or replace package test_expectations_json is + + --%suite(json expectations) + --%suitepath(utplsql.test_user.expectations) + + --%aftereach + procedure cleanup_expectations; + + --%test(Gives success for identical data) + procedure success_on_same_data; + + --%test(Gives failure for different data) + procedure fail_on_diff_data; + + --%test( Json variable is null) + procedure null_json_variable; + + --%test( Json variable is not null) + procedure not_null_json_variable; + + --%test( Fail json variable is null) + procedure fail_null_json_var; + + --%test( Fail json variable is not null) + procedure fail_not_null_json_var; + + --%test(Json string is empty) + procedure empty_json; + + --%test(Json string is not empty) + procedure not_empty_json; + + --%test( Fail json string is empty) + procedure fail_empty_json; + + --%test( Fail json string is not empty) + procedure fail_not_empty_json; + + --%test( Json object to have count ) + procedure to_have_count; + + --%test( Fail Json object to have count) + procedure fail_to_have_count; + + --%test( Json object not to have count) + procedure not_to_have_count; + + --%test( Fail Json object not to have count) + procedure fail_not_to_have_count; + + --%test( Json object to have count on array) + procedure to_have_count_array; + + --%test( Two json use plsql function to extract same pieces and compare) + procedure to_diff_json_extract_same; + + --%test( Two json use plsql function to extract diff pieces and compare) + procedure to_diff_json_extract_diff; + + --%test( Long JSON test same ) + procedure long_json_test; + + --%test( JSON test same semantic content different order ) + procedure json_same_diffrent_ord; + + --%test( Long complex nested JSON test ) + procedure long_json_test2; + + --%test( Long complex json differences ) + procedure long_json_diff; + + --%test( Compare two objects json ) + procedure check_json_objects; + + --%test( Compare two json arrays ) + procedure check_json_arrays; + +end; +/ diff --git a/test/core/expectations/test_matchers.pkb b/test/ut3_user/expectations/test_matchers.pkb similarity index 57% rename from test/core/expectations/test_matchers.pkb rename to test/ut3_user/expectations/test_matchers.pkb index 1a15986b9..88e25e8b1 100644 --- a/test/core/expectations/test_matchers.pkb +++ b/test/ut3_user/expectations/test_matchers.pkb @@ -2,7 +2,7 @@ create or replace package body test_matchers is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; procedure exec_matcher(a_type varchar2, a_actual_value varchar2, a_expected_value varchar2, a_matcher varchar2, a_result integer, a_prefix varchar2 := null) is @@ -16,10 +16,10 @@ create or replace package body test_matchers is ut3.ut.expect( l_actual ).'||a_prefix||'to_'||a_matcher||'( l_expected ); end;'; execute immediate l_statement; - if a_result = ut3.ut_utils.gc_success then - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + if a_result = ut3_tester_helper.main_helper.gc_success then + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); else - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); end if; cleanup_expectations(); end exec_matcher; @@ -36,10 +36,10 @@ create or replace package body test_matchers is ut3.ut.expect(l_actual_value).to_be_between(l_lower, l_higher); end;'; execute immediate l_statement; - if a_result = ut3.ut_utils.gc_success then - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + if a_result = ut3_tester_helper.main_helper.gc_success then + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); else - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); end if; cleanup_expectations(); end exec_be_between; @@ -56,10 +56,10 @@ create or replace package body test_matchers is ut3.ut.expect(l_actual_value).'||a_not_prefix||'to_be_between(l_value1, l_value2); end;'; execute immediate l_statement; - if a_result = ut3.ut_utils.gc_success then - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + if a_result = ut3_tester_helper.main_helper.gc_success then + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); else - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); end if; cleanup_expectations(); end exec_be_between2; @@ -76,13 +76,14 @@ create or replace package body test_matchers is ut3.ut.expect( l_actual ).' || a_prefix ||q'[to_be_like(l_pattern, l_escape_char); end;]' using a_pattern, a_escape; - if a_result = ut3.ut_utils.gc_success then - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + if a_result = ut3_tester_helper.main_helper.gc_success then + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); else - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); end if; cleanup_expectations(); end; + procedure exec_match(a_type varchar2, a_actual_value varchar2, a_pattern varchar2, a_modifiers varchar2, a_result integer, a_not_prefix varchar2 default null) is l_statement varchar2(32767); begin @@ -96,10 +97,10 @@ create or replace package body test_matchers is ut3.ut.expect( l_actual ).'||a_not_prefix||'to_match(l_pattern, l_modifiers); end;'; execute immediate l_statement using a_pattern, a_modifiers; - if a_result = ut3.ut_utils.gc_success then - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + if a_result = ut3_tester_helper.main_helper.gc_success then + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); else - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); end if; cleanup_expectations(); end; @@ -108,135 +109,135 @@ create or replace package body test_matchers is begin --failure when value out of range - exec_be_between2('date', 'sysdate', 'sysdate-2', 'sysdate-1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('number', '2.0', '1.99', '1.999', ut3.ut_utils.gc_failure, ''); - exec_be_between2('varchar2(1)', '''c''', '''a''', '''b''', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp with local time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp with time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_failure, ''); - exec_be_between2('interval year to month', '''2-2''', '''2-0''', '''2-1''', ut3.ut_utils.gc_failure, ''); - exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 00:59:59''', ut3.ut_utils.gc_failure, ''); + exec_be_between2('date', 'sysdate', 'sysdate-2', 'sysdate-1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('number', '2.0', '1.99', '1.999', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('varchar2(1)', '''c''', '''a''', '''b''', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp with local time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp with time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('interval year to month', '''2-2''', '''2-0''', '''2-1''', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 00:59:59''', ut3_tester_helper.main_helper.gc_failure, ''); --success when value in range - exec_be_between2('date', 'sysdate', 'sysdate-1', 'sysdate+1', ut3.ut_utils.gc_success, ''); - exec_be_between2('number', '2.0', '1.99', '2.01', ut3.ut_utils.gc_success, ''); - exec_be_between2('varchar2(1)', '''b''', '''a''', '''c''', ut3.ut_utils.gc_success, ''); - exec_be_between2('timestamp', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_success, ''); - exec_be_between2('timestamp with local time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_success, ''); - exec_be_between2('timestamp with time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_success, ''); - exec_be_between2('interval year to month', '''2-1''', '''2-0''', '''2-2''', ut3.ut_utils.gc_success, ''); - exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 01:00:01''', ut3.ut_utils.gc_success, ''); + exec_be_between2('date', 'sysdate', 'sysdate-1', 'sysdate+1', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('number', '2.0', '1.99', '2.01', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('varchar2(1)', '''b''', '''a''', '''c''', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('timestamp', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('timestamp with local time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('timestamp with time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('interval year to month', '''2-1''', '''2-0''', '''2-2''', ut3_tester_helper.main_helper.gc_success, ''); + exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 01:00:01''', ut3_tester_helper.main_helper.gc_success, ''); --success when value not in range - exec_be_between2('date', 'sysdate', 'sysdate-2', 'sysdate-1', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('number', '2.0', '1.99', '1.999', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('varchar2(1)', '''c''', '''a''', '''b''', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('timestamp', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('timestamp with local time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('timestamp with time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('interval year to month', '''2-2''', '''2-0''', '''2-1''', ut3.ut_utils.gc_success, 'not_'); - exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 00:59:59''', ut3.ut_utils.gc_success, 'not_'); + exec_be_between2('date', 'sysdate', 'sysdate-2', 'sysdate-1', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('number', '2.0', '1.99', '1.999', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('varchar2(1)', '''c''', '''a''', '''b''', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('timestamp', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('timestamp with local time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('timestamp with time zone', 'systimestamp+1', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('interval year to month', '''2-2''', '''2-0''', '''2-1''', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 00:59:59''', ut3_tester_helper.main_helper.gc_success, 'not_'); --failure when value not out of range - exec_be_between2('date', 'sysdate', 'sysdate-1', 'sysdate+1', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('number', '2.0', '1.99', '2.01', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('varchar2(1)', '''b''', '''a''', '''c''', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp with local time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp with time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('interval year to month', '''2-1''', '''2-0''', '''2-2''', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 01:00:01''', ut3.ut_utils.gc_failure, 'not_'); + exec_be_between2('date', 'sysdate', 'sysdate-1', 'sysdate+1', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('number', '2.0', '1.99', '2.01', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('varchar2(1)', '''b''', '''a''', '''c''', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp with local time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp with time zone', 'systimestamp', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('interval year to month', '''2-1''', '''2-0''', '''2-2''', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('interval day to second', '''2 01:00:00''', '''2 00:59:58''', '''2 01:00:01''', ut3_tester_helper.main_helper.gc_failure, 'not_'); --failure when value is null - exec_be_between2('date', 'null', 'sysdate-1', 'sysdate+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('number', 'null', '1.99', '2.01', ut3.ut_utils.gc_failure, ''); - exec_be_between2('varchar2(1)', 'null', '''a''', '''c''', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp', 'null', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp with local time zone', 'null', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp with time zone', 'null', 'systimestamp-1', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('interval year to month', 'null', '''2-0''', '''2-2''', ut3.ut_utils.gc_failure, ''); - exec_be_between2('interval day to second', 'null', '''2 00:59:58''', '''2 01:00:01''', ut3.ut_utils.gc_failure, ''); + exec_be_between2('date', 'null', 'sysdate-1', 'sysdate+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('number', 'null', '1.99', '2.01', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('varchar2(1)', 'null', '''a''', '''c''', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp', 'null', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp with local time zone', 'null', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp with time zone', 'null', 'systimestamp-1', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('interval year to month', 'null', '''2-0''', '''2-2''', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('interval day to second', 'null', '''2 00:59:58''', '''2 01:00:01''', ut3_tester_helper.main_helper.gc_failure, ''); - exec_be_between2('date', 'null', 'sysdate-2', 'sysdate-1', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('number', 'null', '1.99', '1.999', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('varchar2(1)', 'null', '''a''', '''b''', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp', 'null', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp with local time zone', 'null', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp with time zone', 'null', 'systimestamp-1', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('interval year to month', 'null', '''2-0''', '''2-1''', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('interval day to second', 'null', '''2 00:59:58''', '''2 00:59:59''', ut3.ut_utils.gc_failure, 'not_'); + exec_be_between2('date', 'null', 'sysdate-2', 'sysdate-1', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('number', 'null', '1.99', '1.999', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('varchar2(1)', 'null', '''a''', '''b''', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp', 'null', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp with local time zone', 'null', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp with time zone', 'null', 'systimestamp-1', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('interval year to month', 'null', '''2-0''', '''2-1''', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('interval day to second', 'null', '''2 00:59:58''', '''2 00:59:59''', ut3_tester_helper.main_helper.gc_failure, 'not_'); --failure when lower bound is null - exec_be_between2('date', 'sysdate', 'null', 'sysdate+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('number', '2.0', 'null', '2.01', ut3.ut_utils.gc_failure, ''); - exec_be_between2('varchar2(1)', '''b''', 'null', '''c''', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp', 'systimestamp', 'null', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp with local time zone', 'systimestamp', 'null', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('timestamp with time zone', 'systimestamp', 'null', 'systimestamp+1', ut3.ut_utils.gc_failure, ''); - exec_be_between2('interval year to month', '''2-1''', 'null', '''2-2''', ut3.ut_utils.gc_failure, ''); - exec_be_between2('interval day to second', '''2 01:00:00''', 'null', '''2 01:00:01''', ut3.ut_utils.gc_failure, ''); + exec_be_between2('date', 'sysdate', 'null', 'sysdate+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('number', '2.0', 'null', '2.01', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('varchar2(1)', '''b''', 'null', '''c''', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp', 'systimestamp', 'null', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp with local time zone', 'systimestamp', 'null', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('timestamp with time zone', 'systimestamp', 'null', 'systimestamp+1', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('interval year to month', '''2-1''', 'null', '''2-2''', ut3_tester_helper.main_helper.gc_failure, ''); + exec_be_between2('interval day to second', '''2 01:00:00''', 'null', '''2 01:00:01''', ut3_tester_helper.main_helper.gc_failure, ''); - exec_be_between2('date', 'sysdate', 'null', 'sysdate-1', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('number', '2.0', 'null', '1.999', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('varchar2(1)', '''b''', 'null', '''b''', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp', 'systimestamp+1', 'null', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp with local time zone', 'systimestamp+1', 'null', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('timestamp with time zone', 'systimestamp+1', 'null', 'systimestamp', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('interval year to month', '''2-2''', 'null', '''2-1''', ut3.ut_utils.gc_failure, 'not_'); - exec_be_between2('interval day to second', '''2 01:00:00''', 'null', '''2 00:59:59''', ut3.ut_utils.gc_failure, 'not_'); + exec_be_between2('date', 'sysdate', 'null', 'sysdate-1', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('number', '2.0', 'null', '1.999', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('varchar2(1)', '''b''', 'null', '''b''', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp', 'systimestamp+1', 'null', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp with local time zone', 'systimestamp+1', 'null', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('timestamp with time zone', 'systimestamp+1', 'null', 'systimestamp', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('interval year to month', '''2-2''', 'null', '''2-1''', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_between2('interval day to second', '''2 01:00:00''', 'null', '''2 00:59:59''', ut3_tester_helper.main_helper.gc_failure, 'not_'); --Fails for unsupported data-type - exec_be_between2('clob', '''b''', '''a''', '''c''', ut3.ut_utils.gc_failure, ''); + exec_be_between2('clob', '''b''', '''a''', '''c''', ut3_tester_helper.main_helper.gc_failure, ''); end; procedure test_match is begin - exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3.ut_utils.gc_success); - exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3.ut_utils.gc_success); - exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', 'Ste(v|ph)en$', '', ut3.ut_utils.gc_success); - exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', 'Ste(v|ph)en$', 'i', ut3.ut_utils.gc_success); + exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3_tester_helper.main_helper.gc_success); + exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3_tester_helper.main_helper.gc_success); + exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', 'Ste(v|ph)en$', '', ut3_tester_helper.main_helper.gc_success); + exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', 'Ste(v|ph)en$', 'i', ut3_tester_helper.main_helper.gc_success); - exec_match('varchar2(100)', '''Stephen''', '^Steven$', '', ut3.ut_utils.gc_failure); - exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3.ut_utils.gc_failure); - exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3.ut_utils.gc_failure); - exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3.ut_utils.gc_failure); + exec_match('varchar2(100)', '''Stephen''', '^Steven$', '', ut3_tester_helper.main_helper.gc_failure); + exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3_tester_helper.main_helper.gc_failure); + exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3_tester_helper.main_helper.gc_failure); + exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3_tester_helper.main_helper.gc_failure); - exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3.ut_utils.gc_failure, 'not_'); - exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3.ut_utils.gc_failure, 'not_'); - exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', 'Ste(v|ph)en$', '', ut3.ut_utils.gc_failure, 'not_'); - exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', 'Ste(v|ph)en$', 'i', ut3.ut_utils.gc_failure, 'not_'); + exec_match('varchar2(100)', '''Stephen''', '^Ste(v|ph)en$', '', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_match('varchar2(100)', '''sTEPHEN''', '^Ste(v|ph)en$', 'i', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', 'Ste(v|ph)en$', '', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', 'Ste(v|ph)en$', 'i', ut3_tester_helper.main_helper.gc_failure, 'not_'); - exec_match('varchar2(100)', '''Stephen''', '^Steven$', '', ut3.ut_utils.gc_success, 'not_'); - exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3.ut_utils.gc_success, 'not_'); - exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3.ut_utils.gc_success, 'not_'); - exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3.ut_utils.gc_success, 'not_'); + exec_match('varchar2(100)', '''Stephen''', '^Steven$', '', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_match('varchar2(100)', '''sTEPHEN''', '^Steven$', 'i', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_match('clob', 'to_clob(rpad('', '',32767)||''Stephen'')', '^Stephen', '', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_match('clob', 'to_clob(rpad('', '',32767)||''sTEPHEN'')', '^Stephen', 'i', ut3_tester_helper.main_helper.gc_success, 'not_'); --Fails for unsupported data-type - exec_match('number', '12345', '^123.*', 'i', ut3.ut_utils.gc_failure); + exec_match('number', '12345', '^123.*', 'i', ut3_tester_helper.main_helper.gc_failure); end; procedure test_be_like is begin - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3.ut_utils.gc_success); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3.ut_utils.gc_success); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en%', '', ut3.ut_utils.gc_success); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en\_K%', '\', ut3.ut_utils.gc_success); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3_tester_helper.main_helper.gc_success); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3_tester_helper.main_helper.gc_success); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en%', '', ut3_tester_helper.main_helper.gc_success); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en\_K%', '\', ut3_tester_helper.main_helper.gc_success); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste_en%', '', ut3.ut_utils.gc_failure); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3.ut_utils.gc_failure); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste_en%', '', ut3.ut_utils.gc_failure); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Stephe\__%', '\', ut3.ut_utils.gc_failure); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste_en%', '', ut3_tester_helper.main_helper.gc_failure); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3_tester_helper.main_helper.gc_failure); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste_en%', '', ut3_tester_helper.main_helper.gc_failure); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Stephe\__%', '\', ut3_tester_helper.main_helper.gc_failure); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3.ut_utils.gc_failure, 'not_'); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3.ut_utils.gc_failure, 'not_'); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en%', '', ut3.ut_utils.gc_failure, 'not_'); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en\_K%', '\', ut3.ut_utils.gc_failure, 'not_'); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en%', '', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste__en\_K%', '\', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en%', '', ut3_tester_helper.main_helper.gc_failure, 'not_'); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste__en\_K%', '\', ut3_tester_helper.main_helper.gc_failure, 'not_'); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste_en%', '', ut3.ut_utils.gc_success, 'not_'); - exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3.ut_utils.gc_success, 'not_'); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste_en%', '', ut3.ut_utils.gc_success, 'not_'); - exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Stephe\__%', '\', ut3.ut_utils.gc_success, 'not_'); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Ste_en%', '', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_like('varchar2(100)', '''Stephen_King''', 'Stephe\__%', '\', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Ste_en%', '', ut3_tester_helper.main_helper.gc_success, 'not_'); + exec_be_like('clob', 'to_clob(rpad(''a'',32767,''a'')||''Stephen_King'')', 'a%Stephe\__%', '\', ut3_tester_helper.main_helper.gc_success, 'not_'); --Fails for unsupported data-type - exec_be_like('number', '12345', '123%', '', ut3.ut_utils.gc_failure); + exec_be_like('number', '12345', '123%', '', ut3_tester_helper.main_helper.gc_failure); end; procedure test_timestamp_between is diff --git a/test/core/expectations/test_matchers.pks b/test/ut3_user/expectations/test_matchers.pks similarity index 88% rename from test/core/expectations/test_matchers.pks rename to test/ut3_user/expectations/test_matchers.pks index 0fa0953d4..e3e22e0cd 100644 --- a/test/core/expectations/test_matchers.pks +++ b/test/ut3_user/expectations/test_matchers.pks @@ -1,11 +1,11 @@ create or replace package test_matchers is --%suite(matchers) - --%suitepath(utplsql.core.expectations) + --%suitepath(utplsql.test_user.expectations) --%aftereach procedure cleanup_expectations; - + --%test procedure test_be_between2; --%test diff --git a/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pkb b/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pkb new file mode 100644 index 000000000..448addb8c --- /dev/null +++ b/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pkb @@ -0,0 +1,265 @@ +create or replace package body test_expect_not_to_be_null +is + gc_object_name constant varchar2(30) := 't_not_to_be_null_test'; + gc_nested_table_name constant varchar2(30) := 'tt_not_to_be_null_test'; + gc_varray_name constant varchar2(30) := 'tv_not_to_be_null_test'; + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + procedure create_types is + pragma autonomous_transaction; + begin + execute immediate 'create type ' || gc_object_name || ' is object (dummy number)'; + execute immediate 'create type ' || gc_nested_table_name || ' is table of number'; + execute immediate 'create type ' || gc_varray_name || ' is varray(1) of number'; + end; + + procedure drop_types is + pragma autonomous_transaction; + begin + execute immediate 'drop type ' || gc_object_name; + execute immediate 'drop type ' || gc_nested_table_name; + execute immediate 'drop type ' || gc_varray_name; + end; + + procedure blob_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'blob', 'to_blob(''abc'')' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure blob_0_length is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'blob', 'empty_blob()' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure boolean_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'boolean', 'true' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure clob_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'clob', 'to_clob(''abc'')' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + + procedure clob_0_length is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'clob', 'empty_clob()' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure date_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'date', 'sysdate' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure number_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'number', '1234' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure timestamp_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'timestamp', 'systimestamp' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure timestamp_with_ltz_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( + 'not_to_be_null', 'timestamp with local time zone', 'systimestamp' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure timestamp_with_tz_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'timestamp with time zone', + 'systimestamp' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varchar2_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'varchar2(4000)', '''abc''' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure initialized_object is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'not_to_be_null', gc_object_name, gc_object_name || '(1)', 'object' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure initialized_nested_table is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'not_to_be_null', gc_nested_table_name, gc_nested_table_name || '()', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure initialized_varray is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'not_to_be_null', gc_varray_name, gc_varray_name || '()', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_blob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'blob', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_boolean is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'boolean', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_clob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'clob', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_date is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'date', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_number is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'number', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_timestamp is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'timestamp', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_timestamp_with_ltz is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( + 'not_to_be_null', 'timestamp with local time zone', 'null' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_timestamp_with_tz is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( + 'not_to_be_null', 'timestamp with time zone', 'null' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_varchar2 is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'varchar2(4000)', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'not_to_be_null', 'anydata', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure uninit_object_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'not_to_be_null', gc_object_name, 'null', 'object' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure uninit_nested_table_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'not_to_be_null', gc_nested_table_name, 'null', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure uninit_varray_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'not_to_be_null', gc_varray_name, 'null', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + +end test_expect_not_to_be_null; +/ diff --git a/test/core/expectations/unary/test_expect_not_to_be_null.pks b/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pks similarity index 97% rename from test/core/expectations/unary/test_expect_not_to_be_null.pks rename to test/ut3_user/expectations/unary/test_expect_not_to_be_null.pks index fa2d6193f..11648d5d2 100644 --- a/test/core/expectations/unary/test_expect_not_to_be_null.pks +++ b/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pks @@ -1,7 +1,7 @@ create or replace package test_expect_not_to_be_null is --%suite(not_to_be_null) - --%suitepath(utplsql.core.expectations.unary) + --%suitepath(utplsql.test_user.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/unary/test_expect_to_be_empty.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb similarity index 66% rename from test/core/expectations/unary/test_expect_to_be_empty.pkb rename to test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb index 0db499906..3694850fe 100644 --- a/test/core/expectations/unary/test_expect_to_be_empty.pkb +++ b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb @@ -2,10 +2,9 @@ create or replace package body test_expect_to_be_empty is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; - - procedure success_be_empty_cursor is + procedure success_be_empty_cursor is l_cursor sys_refcursor; begin --Arrange @@ -13,7 +12,7 @@ create or replace package body test_expect_to_be_empty is --Act ut3.ut.expect(l_cursor).to_be_empty; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_be_empty_cursor is @@ -24,7 +23,7 @@ create or replace package body test_expect_to_be_empty is --Act ut3.ut.expect(l_cursor).to_be_empty; --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_be_empty_cursor_report is @@ -40,7 +39,7 @@ create or replace package body test_expect_to_be_empty is l_expected_message := q'[Actual: (refcursor [ count = 1 ])% X% was expected to be empty%%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -54,7 +53,7 @@ was expected to be empty%%]'; --Act ut3.ut.expect(l_cursor).not_to_be_empty; --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_not_be_empty_cursor is @@ -65,7 +64,7 @@ was expected to be empty%%]'; --Act ut3.ut.expect(l_cursor).not_to_be_empty; --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_be_empty_collection is @@ -76,7 +75,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect(l_actual).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_be_empty_collection is @@ -87,7 +86,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect(l_actual).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_not_be_empty_coll is @@ -98,7 +97,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect(l_actual).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_not_be_empty_collection is @@ -109,7 +108,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect(l_actual).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_be_empty_null_collection is @@ -121,7 +120,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect(l_actual).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_not_be_empty_null_coll is @@ -133,30 +132,30 @@ was expected to be empty%%]'; -- Act ut3.ut.expect(l_actual).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_be_empty_object is l_actual anydata; begin --Arrange - l_actual := anydata.convertObject(ut3.ut_data_value_number(1)); + l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act ut3.ut.expect(l_actual).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_be_empty_null_object is l_actual anydata; - l_data ut3.ut_data_value_number; + l_data ut3_tester_helper.test_dummy_number; begin --Arrange l_actual := anydata.convertObject(l_data); -- Act ut3.ut.expect(l_actual).to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_be_empty_number is @@ -164,7 +163,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( 1 ).to_( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; /** @@ -175,23 +174,23 @@ was expected to be empty%%]'; l_actual anydata; begin --Arrange - l_actual := anydata.convertObject(ut3.ut_data_value_number(1)); + l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act ut3.ut.expect(l_actual).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_not_be_empty_null_object is l_actual anydata; - l_data ut3.ut_data_value_number; + l_data ut3_tester_helper.test_dummy_number; begin --Arrange l_actual := anydata.convertObject(l_data); -- Act ut3.ut.expect(l_actual).not_to_be_empty(); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_not_be_empty_number is @@ -199,7 +198,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( 1 ).not_to( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_be_empty_clob is @@ -207,7 +206,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( empty_clob() ).to_( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_be_empty_clob is @@ -215,7 +214,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( to_clob(' ') ).to_( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_be_empty_blob is @@ -223,7 +222,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( empty_blob() ).to_( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_be_empty_blob is @@ -231,7 +230,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( to_blob('AA') ).to_( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -240,7 +239,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( empty_clob() ).not_to( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_not_be_empty_clob is @@ -248,7 +247,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( to_clob(' ') ).not_to( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_not_be_empty_blob is @@ -256,7 +255,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( empty_blob() ).not_to( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_not_be_empty_blob is @@ -264,7 +263,7 @@ was expected to be empty%%]'; -- Act ut3.ut.expect( to_blob('AA') ).not_to( ut3.be_empty() ); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; end; diff --git a/test/core/expectations/unary/test_expect_to_be_empty.pks b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pks similarity index 97% rename from test/core/expectations/unary/test_expect_to_be_empty.pks rename to test/ut3_user/expectations/unary/test_expect_to_be_empty.pks index 92a7e0bef..a76787ac5 100644 --- a/test/core/expectations/unary/test_expect_to_be_empty.pks +++ b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_empty is --%suite - --%suitepath(utplsql.core.expectations.unary) + --%suitepath(utplsql.test_user.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pkb new file mode 100644 index 000000000..0e747eb85 --- /dev/null +++ b/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pkb @@ -0,0 +1,264 @@ +create or replace package body test_expect_to_be_not_null +is + gc_object_name constant varchar2(30) := 't_to_be_not_null_test'; + gc_nested_table_name constant varchar2(30) := 'tt_to_be_not_null_test'; + gc_varray_name constant varchar2(30) := 'tv_to_be_not_null_test'; + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + procedure create_types is + pragma autonomous_transaction; + begin + execute immediate 'create type '||gc_object_name||' is object (dummy number)'; + execute immediate 'create type '||gc_nested_table_name||' is table of number'; + execute immediate 'create type '||gc_varray_name||' is varray(1) of number'; + end; + + procedure drop_types is + pragma autonomous_transaction; + begin + execute immediate 'drop type '||gc_object_name; + execute immediate 'drop type '||gc_nested_table_name; + execute immediate 'drop type '||gc_varray_name; + end; + + procedure blob_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'blob', 'to_blob(''abc'')'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure empty_blob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'blob', 'empty_blob()'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure boolean_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'boolean', 'true'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure clob_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'clob', 'to_clob(''abc'')'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure empty_clob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'clob', 'empty_clob()'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure date_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'date', 'sysdate'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure number_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'number', '1234'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure timestamp_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp', 'systimestamp'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure timestamp_with_ltz_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with local time zone', 'systimestamp'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure timestamp_with_tz_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with time zone', 'systimestamp'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure varchar2_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'varchar2(4000)', '''abc'''); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure initialized_object is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_not_null', gc_object_name, gc_object_name||'(1)', 'object' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure initialized_nested_table is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_not_null', gc_nested_table_name, gc_nested_table_name||'()', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure initialized_varray is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_not_null', gc_varray_name, gc_varray_name||'()', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_blob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'blob', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_boolean is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'boolean', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_clob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'clob', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_date is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'date', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_number is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'number', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_timestamp is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_timestamp_with_ltz is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with local time zone', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_timestamp_with_tz is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with time zone', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + + procedure null_varchar2 is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'varchar2(4000)', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure null_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'anydata', 'null'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure uninit_object_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_not_null', gc_object_name, 'null', 'object' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure uninit_nested_table_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_not_null', gc_nested_table_name, 'null', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure uninit_varray_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_not_null', gc_varray_name, 'null', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + +end test_expect_to_be_not_null; +/ diff --git a/test/core/expectations/unary/test_expect_to_be_not_null.pks b/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pks similarity index 97% rename from test/core/expectations/unary/test_expect_to_be_not_null.pks rename to test/ut3_user/expectations/unary/test_expect_to_be_not_null.pks index 351482fee..7cb7cc265 100644 --- a/test/core/expectations/unary/test_expect_to_be_not_null.pks +++ b/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_not_null is --%suite(to_be_not_null) - --%suitepath(utplsql.core.expectations.unary) + --%suitepath(utplsql.test_user.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_null.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_null.pkb new file mode 100644 index 000000000..c0899c08d --- /dev/null +++ b/test/ut3_user/expectations/unary/test_expect_to_be_null.pkb @@ -0,0 +1,260 @@ +create or replace package body test_expect_to_be_null +is + gc_object_name constant varchar2(30) := 't_to_be_null_test'; + gc_nested_table_name constant varchar2(30) := 'tt_to_be_null_test'; + gc_varray_name constant varchar2(30) := 'tv_to_be_null_test'; + + procedure cleanup_expectations is + begin + ut3_tester_helper.main_helper.clear_expectations( ); + end; + + procedure create_types is + pragma autonomous_transaction; + begin + execute immediate 'create type ' || gc_object_name || ' is object (dummy number)'; + execute immediate 'create type ' || gc_nested_table_name || ' is table of number'; + execute immediate 'create type ' || gc_varray_name || ' is varray(1) of number'; + end; + + procedure drop_types is + pragma autonomous_transaction; + begin + execute immediate 'drop type ' || gc_object_name; + execute immediate 'drop type ' || gc_nested_table_name; + execute immediate 'drop type ' || gc_varray_name; + end; + + procedure null_blob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'blob', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_boolean is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'boolean', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_clob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'clob', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_date is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'date', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_number is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'number', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_timestamp is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'timestamp', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_timestamp_with_ltz is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'timestamp with local time zone', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_timestamp_with_tz is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'timestamp with time zone', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_varchar2 is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'varchar2(4000)', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure null_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'anydata', 'null' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure uninit_object_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_null', gc_object_name, 'null', 'object' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure uninit_nested_table_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_null', gc_nested_table_name, 'null', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure uninit_varray_in_anydata is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( 'to_be_null', gc_varray_name, + 'null', 'collection' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure blob_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'blob', 'to_blob(''abc'')' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure empty_blob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'blob', 'empty_blob()' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure boolean_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'boolean', 'true' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure clob_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'clob', 'to_clob(''abc'')' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure empty_clob is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'clob', 'empty_clob()' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure date_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'date', 'sysdate' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure number_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'number', '1234' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure timestamp_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'timestamp', 'systimestamp' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure timestamp_with_ltz_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( + 'to_be_null', 'timestamp with local time zone', 'systimestamp' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure timestamp_with_tz_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( + 'to_be_null', 'timestamp with time zone', 'systimestamp' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure varchar2_not_null is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block( 'to_be_null', 'varchar2(4000)', '''abc''' ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure initialized_object is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_null', gc_object_name, gc_object_name || '(1)', 'object' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure initialized_nested_table is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_null', gc_nested_table_name, gc_nested_table_name || '()', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + + procedure initialized_varray is + begin + --Act + execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block( + 'to_be_null', gc_varray_name, gc_varray_name || '()', 'collection' + ); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + +end test_expect_to_be_null; +/ diff --git a/test/core/expectations/unary/test_expect_to_be_null.pks b/test/ut3_user/expectations/unary/test_expect_to_be_null.pks similarity index 97% rename from test/core/expectations/unary/test_expect_to_be_null.pks rename to test/ut3_user/expectations/unary/test_expect_to_be_null.pks index 8b34e1279..f1758316e 100644 --- a/test/core/expectations/unary/test_expect_to_be_null.pks +++ b/test/ut3_user/expectations/unary/test_expect_to_be_null.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_null is --%suite(to_be_null) - --%suitepath(utplsql.core.expectations.unary) + --%suitepath(utplsql.test_user.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/unary/test_expect_to_be_true_false.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb similarity index 56% rename from test/core/expectations/unary/test_expect_to_be_true_false.pkb rename to test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb index 32ef58a7d..6a621c6b3 100644 --- a/test/core/expectations/unary/test_expect_to_be_true_false.pkb +++ b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb @@ -3,7 +3,7 @@ is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; procedure to_be_true_null_boolean is @@ -11,7 +11,7 @@ is --Act ut3.ut.expect( 1=null ).to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure to_be_true_success is @@ -19,7 +19,7 @@ is --Act ut3.ut.expect( 1=1 ).to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure to_be_true_failure is @@ -27,7 +27,7 @@ is --Act ut3.ut.expect( 1=2 ).to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure to_be_true_bad_type is @@ -35,7 +35,7 @@ is --Act ut3.ut.expect( 1 ).to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_to_be_true_null_boolean is @@ -43,7 +43,7 @@ is --Act ut3.ut.expect( 1=null ).not_to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_to_be_true_success is @@ -51,7 +51,7 @@ is --Act ut3.ut.expect( 1=2 ).not_to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_to_be_true_failure is @@ -59,7 +59,7 @@ is --Act ut3.ut.expect( 1=1 ).not_to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; @@ -68,7 +68,7 @@ is --Act ut3.ut.expect( 1 ).not_to_be_true(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure to_be_false_null_boolean is @@ -76,7 +76,7 @@ is --Act ut3.ut.expect( 1=null ).to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure to_be_false_success is @@ -84,7 +84,7 @@ is --Act ut3.ut.expect( 1=2 ).to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure to_be_false_failure is @@ -92,7 +92,7 @@ is --Act ut3.ut.expect( 1=1 ).to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure to_be_false_bad_type is @@ -100,7 +100,7 @@ is --Act ut3.ut.expect( 1 ).to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_to_be_false_null_boolean is @@ -108,7 +108,7 @@ is --Act ut3.ut.expect( 1=null ).not_to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_to_be_false_success is @@ -116,7 +116,7 @@ is --Act ut3.ut.expect( 1=1 ).not_to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure not_to_be_false_failure is @@ -124,7 +124,7 @@ is --Act ut3.ut.expect( 1=2 ).not_to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure not_to_be_false_bad_type is @@ -132,7 +132,7 @@ is --Act ut3.ut.expect( 1 ).not_to_be_false(); --Assert - ut.expect( expectations.failed_expectations_data( ) ).not_to_be_empty( ); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/core/expectations/unary/test_expect_to_be_true_false.pks b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pks similarity index 97% rename from test/core/expectations/unary/test_expect_to_be_true_false.pks rename to test/ut3_user/expectations/unary/test_expect_to_be_true_false.pks index abdbf44b6..28bbae6f7 100644 --- a/test/core/expectations/unary/test_expect_to_be_true_false.pks +++ b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_be_true_false is --%suite(to_be_true/false) - --%suitepath(utplsql.core.expectations.unary) + --%suitepath(utplsql.test_user.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/expectations/unary/test_expect_to_have_count.pkb b/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb similarity index 69% rename from test/core/expectations/unary/test_expect_to_have_count.pkb rename to test/ut3_user/expectations/unary/test_expect_to_have_count.pkb index a95a6778a..327ced120 100644 --- a/test/core/expectations/unary/test_expect_to_have_count.pkb +++ b/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb @@ -2,7 +2,7 @@ create or replace package body test_expect_to_have_count is procedure cleanup_expectations is begin - expectations.cleanup_expectations( ); + ut3_tester_helper.main_helper.clear_expectations( ); end; procedure success_have_count_cursor is @@ -13,7 +13,7 @@ create or replace package body test_expect_to_have_count is --Act ut3.ut.expect(l_cursor).to_have_count(11); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_have_count_cursor is @@ -24,7 +24,7 @@ create or replace package body test_expect_to_have_count is --Act ut3.ut.expect(l_cursor).to_have_count(1); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_have_count_cursor_report is @@ -38,7 +38,7 @@ create or replace package body test_expect_to_have_count is ut3.ut.expect(l_cursor).to_have_count(2); l_expected_message := q'[Actual: (refcursor [ count = 1 ]) was expected to have [ count = 2 ]%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); @@ -52,7 +52,7 @@ create or replace package body test_expect_to_have_count is --Act ut3.ut.expect(l_cursor).not_to_have_count(2); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_not_have_count_cursor is @@ -63,7 +63,7 @@ create or replace package body test_expect_to_have_count is --Act ut3.ut.expect(l_cursor).not_to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_have_count_collection is @@ -74,7 +74,7 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect(l_actual).to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_have_count_collection is @@ -85,7 +85,7 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect(l_actual).to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure success_not_have_count_coll is @@ -96,7 +96,7 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect(l_actual).not_to_have_count(2); --Assert - ut.expect(expectations.failed_expectations_data()).to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure fail_not_have_count_coll is @@ -107,7 +107,7 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect(l_actual).not_to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_have_count_null_coll is @@ -119,7 +119,7 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect(l_actual).to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_not_have_count_null_coll is @@ -131,30 +131,30 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect(l_actual).not_to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_have_count_object is l_actual anydata; begin --Arrange - l_actual := anydata.convertObject(ut3.ut_data_value_number(1)); + l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act ut3.ut.expect(l_actual).to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_have_count_null_object is l_actual anydata; - l_data ut3.ut_data_value_number; + l_data ut3_tester_helper.test_dummy_number; begin --Arrange l_actual := anydata.convertObject(l_data); -- Act ut3.ut.expect(l_actual).to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_have_count_number is @@ -165,7 +165,7 @@ create or replace package body test_expect_to_have_count is ut3.ut.expect( 1 ).to_( ut3.have_count(0) ); --Assert l_expected_message := q'[%The matcher 'have count' cannot be used with data type (number).%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; @@ -176,26 +176,26 @@ create or replace package body test_expect_to_have_count is l_actual_message varchar2(32767); begin --Arrange - l_actual := anydata.convertObject(ut3.ut_data_value_number(1)); + l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); -- Act ut3.ut.expect(l_actual).not_to_have_count(0); --Assert - l_expected_message := q'[%The matcher 'have count' cannot be used with data type (ut3.ut_data_value_number).%]'; - l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message; + l_expected_message := q'[%The matcher 'have count' cannot be used with data type (ut3_tester_helper.test_dummy_number).%]'; + l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); end; procedure fail_not_have_count_null_obj is l_actual anydata; - l_data ut3.ut_data_value_number; + l_data ut3_tester_helper.test_dummy_number; begin --Arrange l_actual := anydata.convertObject(l_data); -- Act ut3.ut.expect(l_actual).not_to_have_count(0); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure fail_not_have_count_number is @@ -203,7 +203,7 @@ create or replace package body test_expect_to_have_count is -- Act ut3.ut.expect( 1 ).not_to( ut3.have_count(0) ); --Assert - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; diff --git a/test/core/expectations/unary/test_expect_to_have_count.pks b/test/ut3_user/expectations/unary/test_expect_to_have_count.pks similarity index 96% rename from test/core/expectations/unary/test_expect_to_have_count.pks rename to test/ut3_user/expectations/unary/test_expect_to_have_count.pks index 636f98ba4..b944d8800 100644 --- a/test/core/expectations/unary/test_expect_to_have_count.pks +++ b/test/ut3_user/expectations/unary/test_expect_to_have_count.pks @@ -1,7 +1,7 @@ create or replace package test_expect_to_have_count is --%suite((not)to_have_count) - --%suitepath(utplsql.core.expectations.unary) + --%suitepath(utplsql.test_user.expectations.unary) --%aftereach procedure cleanup_expectations; diff --git a/test/core/reporters.pkb b/test/ut3_user/reporters.pkb similarity index 70% rename from test/core/reporters.pkb rename to test/ut3_user/reporters.pkb index abd9e6007..d6a104242 100644 --- a/test/core/reporters.pkb +++ b/test/ut3_user/reporters.pkb @@ -110,8 +110,24 @@ as dbms_output.put_line(''); end; -end;]'; - +end;]'; + + execute immediate q'[create or replace package check_fail_escape is + --%suitepath(core) + --%suite(Check JUNIT XML failure is escaped) + + --%test(Fail Miserably) + procedure fail_miserably; + + end;]'; + + execute immediate q'[create or replace package body check_fail_escape is + procedure fail_miserably is + begin + ut3.ut.expect('test').to_equal(''); + end; + end;]'; + end; procedure reporters_setup is @@ -122,6 +138,7 @@ end;]'; procedure drop_test_helper_package is begin execute immediate 'drop package test_reporters'; + execute immediate 'drop package check_fail_escape'; end; procedure reporters_cleanup is @@ -141,10 +158,29 @@ end;]'; select * bulk collect into l_results from table(ut3.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set)); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%'); end; + procedure check_xml_failure_escaped( + a_reporter ut3.ut_output_reporter_base + ) is + l_results ut3.ut_varchar2_list; + l_actual clob; + begin + --Act + select * + bulk collect into l_results + from table( ut3.ut.run( 'check_fail_escape', a_reporter ) ); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_be_like('%' (varchar2)%]' + ||q'[at "UT3$USER#.CHECK_FAIL_ESCAPE%", line % ut3.ut.expect('test').to_equal('');]' + ||'%]]>%' + ); + end; + end reporters; / diff --git a/test/core/reporters.pks b/test/ut3_user/reporters.pks similarity index 71% rename from test/core/reporters.pks rename to test/ut3_user/reporters.pks index 229e4e9b1..54800fa4a 100644 --- a/test/core/reporters.pks +++ b/test/ut3_user/reporters.pks @@ -1,7 +1,7 @@ create or replace package reporters is --%suite - --%suitepath(utplsql.core) + --%suitepath(utplsql.test_user) --%beforeall procedure reporters_setup; @@ -14,5 +14,9 @@ create or replace package reporters is a_client_character_set varchar2 ); + procedure check_xml_failure_escaped( + a_reporter ut3.ut_output_reporter_base + ); + end reporters; / diff --git a/test/ut3_user/reporters/test_coverage.pkb b/test/ut3_user/reporters/test_coverage.pkb new file mode 100644 index 000000000..6b094f2ae --- /dev/null +++ b/test/ut3_user/reporters/test_coverage.pkb @@ -0,0 +1,36 @@ +create or replace package body test_coverage is + + function get_mock_run_id return integer is + v_result integer; + begin + return ut3_tester_helper.coverage_helper.get_mock_run_id(); + end; + + procedure create_dummy_coverage_pkg is + begin + ut3_tester_helper.coverage_helper.create_dummy_coverage_package(); + ut3_tester_helper.coverage_helper.create_dummy_coverage_test(); + ut3_tester_helper.coverage_helper.grant_exec_on_cov(); + end; + + procedure setup_dummy_coverage is + pragma autonomous_transaction; + begin + g_run_id := get_mock_run_id(); + ut3.ut_coverage.mock_coverage_id(g_run_id, ut3.ut_coverage.gc_proftab_coverage); + ut3_tester_helper.coverage_helper.mock_coverage_data(g_run_id,user); + commit; + end; + + procedure drop_dummy_coverage_pkg is + begin + ut3_tester_helper.coverage_helper.drop_dummy_coverage_pkg(); + end; + + procedure cleanup_dummy_coverage is + begin + ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(g_run_id); + end; + +end; +/ diff --git a/test/ut3_user/reporters/test_coverage.pks b/test/ut3_user/reporters/test_coverage.pks new file mode 100644 index 000000000..d56597d11 --- /dev/null +++ b/test/ut3_user/reporters/test_coverage.pks @@ -0,0 +1,20 @@ +create or replace package test_coverage is + + --%suite + --%suitepath(utplsql.test_user.reporters) + + g_run_id integer; + + --%beforeall + procedure create_dummy_coverage_pkg; + --%beforeall + procedure setup_dummy_coverage; + + + --%afterall + procedure drop_dummy_coverage_pkg; + --%afterall + procedure cleanup_dummy_coverage; + +end; +/ diff --git a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb new file mode 100644 index 000000000..b3c0439b4 --- /dev/null +++ b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb @@ -0,0 +1,101 @@ +create or replace package body test_cov_cobertura_reporter is + + procedure report_on_file is + l_results ut3.ut_varchar2_list; + l_expected clob; + l_actual clob; + begin + --Arrange + l_expected := + q'[ + + + +test/ut3.dummy_coverage.pkb + + + + + + + + + + + + +]'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_dummy_coverage', + a_reporter=> ut3.ut_coverage_cobertura_reporter( ), + a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage.pkb' ), + a_test_files => ut3.ut_varchar2_list( ) + ) + ); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure report_zero_coverage is + l_results ut3.ut_varchar2_list; + l_expected clob; + l_actual clob; + begin + --Arrange + l_expected := + q'[ + + + +ut3.dummy_coverage + + + + + + + + + + + + + + + + + + + + + + + + +]'; + + test_coverage.cleanup_dummy_coverage; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_dummy_coverage', + a_reporter=> ut3.ut_coverage_cobertura_reporter( ), + a_include_objects => ut3.ut_varchar2_list('UT3.DUMMY_COVERAGE') + ) + ); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + --Assert + ut.expect(l_actual).to_be_like(l_expected); + --Cleanup + test_coverage.setup_dummy_coverage; + end; + +end; +/ diff --git a/test/core/reporters/test_coverage/test_cov_cobertura_reporter.pks b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks similarity index 54% rename from test/core/reporters/test_coverage/test_cov_cobertura_reporter.pks rename to test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks index ac347fb9d..0016641d5 100644 --- a/test/core/reporters/test_coverage/test_cov_cobertura_reporter.pks +++ b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks @@ -1,10 +1,13 @@ create or replace package test_cov_cobertura_reporter is --%suite(ut_cov_cobertura_reporter) - --%suitepath(utplsql.core.reporters.test_coverage) + --%suitepath(utplsql.test_user.reporters.test_coverage) --%test(reports on a project file mapped to database object) procedure report_on_file; + --%test(reports zero coverage on each line of non-executed database object - Issue #917) + procedure report_zero_coverage; + end test_cov_cobertura_reporter; / diff --git a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb similarity index 93% rename from test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb rename to test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb index 81b2c12f8..5cd53a093 100644 --- a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb @@ -25,7 +25,7 @@ create or replace package body test_coverage_sonar_reporter is a_test_files => ut3.ut_varchar2_list( ) ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_equal(l_expected); end; diff --git a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks similarity index 83% rename from test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks rename to test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks index 31cb358dd..7a98355cf 100644 --- a/test/core/reporters/test_coverage/test_coverage_sonar_reporter.pks +++ b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_coverage_sonar_reporter is --%suite(ut_coverge_sonar_reporter) - --%suitepath(utplsql.core.reporters.test_coverage) + --%suitepath(utplsql.test_user.reporters.test_coverage) --%test(reports on a project file mapped to database object) procedure report_on_file; diff --git a/test/core/reporters/test_coverage/test_coveralls_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb similarity index 90% rename from test/core/reporters/test_coverage/test_coveralls_reporter.pkb rename to test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb index 774e796a0..0be0e8ce3 100644 --- a/test/core/reporters/test_coverage/test_coveralls_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb @@ -31,7 +31,7 @@ null, a_test_files => ut3.ut_varchar2_list( ) ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_equal(l_expected); end; @@ -55,6 +55,11 @@ null, 0, 0, 0, +0, +0, +0, +0, +0, 0 ] } @@ -73,7 +78,7 @@ null, a_include_objects => ut3.ut_varchar2_list('UT3.DUMMY_COVERAGE') ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_equal(l_expected); diff --git a/test/core/reporters/test_coverage/test_coveralls_reporter.pks b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks similarity index 83% rename from test/core/reporters/test_coverage/test_coveralls_reporter.pks rename to test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks index bf2b861f7..d958b8f12 100644 --- a/test/core/reporters/test_coverage/test_coveralls_reporter.pks +++ b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_coveralls_reporter is --%suite(ut_coveralls_reporter) - --%suitepath(utplsql.core.reporters.test_coverage) + --%suitepath(utplsql.test_user.reporters.test_coverage) --%test(reports on a project file mapped to database object) procedure report_on_file; diff --git a/test/core/reporters/test_coverage/test_html_extended_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_html_extended_reporter.pkb similarity index 90% rename from test/core/reporters/test_coverage/test_html_extended_reporter.pkb rename to test/ut3_user/reporters/test_coverage/test_html_extended_reporter.pkb index 19e1fe807..02b275020 100644 --- a/test/core/reporters/test_coverage/test_html_extended_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_html_extended_reporter.pkb @@ -13,14 +13,14 @@ create or replace package body test_html_extended_reporter is bulk collect into l_results from table( ut3.ut.run( - a_path => 'ut3.test_dummy_coverage', + a_path => 'ut3.test_block_dummy_coverage', a_reporter=> ut3.ut_coverage_html_reporter(), a_source_files => ut3.ut_varchar2_list( 'test/ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long.pkb' ), a_test_files => ut3.ut_varchar2_list( ), a_client_character_set => l_charset ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like(l_expected); end; diff --git a/test/core/reporters/test_coverage/test_html_extended_reporter.pks b/test/ut3_user/reporters/test_coverage/test_html_extended_reporter.pks similarity index 79% rename from test/core/reporters/test_coverage/test_html_extended_reporter.pks rename to test/ut3_user/reporters/test_coverage/test_html_extended_reporter.pks index cefa71d66..dbe31b83d 100644 --- a/test/core/reporters/test_coverage/test_html_extended_reporter.pks +++ b/test/ut3_user/reporters/test_coverage/test_html_extended_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_html_extended_reporter is --%suite(ut_html_extended_reporter) - --%suitepath(utplsql.core.reporters.test_extended_coverage) + --%suitepath(utplsql.test_user.reporters.test_extended_coverage) --%test(reports on a project file mapped to database object in extended profiler coverage) procedure report_on_file; diff --git a/test/core/reporters/test_coverage/test_html_proftab_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_html_proftab_reporter.pkb similarity index 93% rename from test/core/reporters/test_coverage/test_html_proftab_reporter.pkb rename to test/ut3_user/reporters/test_coverage/test_html_proftab_reporter.pkb index c10af2869..8daf36513 100644 --- a/test/core/reporters/test_coverage/test_html_proftab_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_html_proftab_reporter.pkb @@ -20,7 +20,7 @@ create or replace package body test_html_proftab_reporter is a_client_character_set => l_charset ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like(l_expected); end; diff --git a/test/core/reporters/test_coverage/test_html_proftab_reporter.pks b/test/ut3_user/reporters/test_coverage/test_html_proftab_reporter.pks similarity index 75% rename from test/core/reporters/test_coverage/test_html_proftab_reporter.pks rename to test/ut3_user/reporters/test_coverage/test_html_proftab_reporter.pks index d091510c6..02973fbe0 100644 --- a/test/core/reporters/test_coverage/test_html_proftab_reporter.pks +++ b/test/ut3_user/reporters/test_coverage/test_html_proftab_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_html_proftab_reporter is --%suite(ut_html_proftab_reporter) - --%suitepath(utplsql.core.reporters.test_coverage) + --%suitepath(utplsql.test_user.reporters.test_coverage.test_proftab_coverage) --%test(reports on a project file mapped to database object in profiler coverage) procedure report_on_file; diff --git a/test/core/reporters/test_debug_reporter.pkb b/test/ut3_user/reporters/test_debug_reporter.pkb similarity index 94% rename from test/core/reporters/test_debug_reporter.pkb rename to test/ut3_user/reporters/test_debug_reporter.pkb index d82685ac4..f108ec577 100644 --- a/test/core/reporters/test_debug_reporter.pkb +++ b/test/ut3_user/reporters/test_debug_reporter.pkb @@ -13,7 +13,7 @@ create or replace package body test_debug_reporter as ut3.ut_debug_reporter() ) ); - g_actual := ut3.ut_utils.table_to_clob(l_results); + g_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); end; procedure includes_event_info is diff --git a/test/core/reporters/test_debug_reporter.pks b/test/ut3_user/reporters/test_debug_reporter.pks similarity index 86% rename from test/core/reporters/test_debug_reporter.pks rename to test/ut3_user/reporters/test_debug_reporter.pks index d4ba20a62..4d7f7962f 100644 --- a/test/core/reporters/test_debug_reporter.pks +++ b/test/ut3_user/reporters/test_debug_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_debug_reporter as --%suite(ut_debug_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%beforeall procedure run_reporter; diff --git a/test/core/reporters/test_documentation_reporter.pkb b/test/ut3_user/reporters/test_documentation_reporter.pkb similarity index 54% rename from test/core/reporters/test_documentation_reporter.pkb rename to test/ut3_user/reporters/test_documentation_reporter.pkb index 7045aa7ca..a1f895947 100644 --- a/test/core/reporters/test_documentation_reporter.pkb +++ b/test/ut3_user/reporters/test_documentation_reporter.pkb @@ -1 +1 @@ -create or replace package body test_documentation_reporter as procedure report_produces_expected_out is l_results ut3.ut_varchar2_list; l_actual clob; l_expected varchar2(32767):=q'[%org utplsql tests helpers A suite for testing different outcomes from reporters A description of some context passing_test [% sec] a test with failing assertion [% sec] (FAILED - 1) a test raising unhandled exception [% sec] (FAILED - 2) a disabled test [0 sec] (DISABLED) % Failures: % 1) failing_test "Fails as values are different" Actual: 'number [1] ' (varchar2) was expected to equal: 'number [2] ' (varchar2)% at "UT3_TESTER.TEST_REPORTERS%", line 36 ut3.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] '); % % 2) erroring_test ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at "UT3_TESTER.TEST_REPORTERS", line 44% ORA-06512: at line 6 Finished in % seconds 4 tests, 1 failed, 1 errored, 1 disabled, 0 warning(s)%]'; begin select * bulk collect into l_results from table( ut3.ut.run( 'test_reporters', ut3.ut_documentation_reporter() ) ); l_actual := ut3.ut_utils.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; procedure check_encoding_included is begin reporters.check_xml_encoding_included(ut3.ut_sonar_test_reporter(), 'UTF-8'); end; end; / \ No newline at end of file +create or replace package body test_documentation_reporter as procedure report_produces_expected_out is l_results ut3.ut_varchar2_list; l_actual clob; l_expected varchar2(32767):=q'[%org utplsql tests helpers A suite for testing different outcomes from reporters A description of some context passing_test [% sec] a test with failing assertion [% sec] (FAILED - 1) a test raising unhandled exception [% sec] (FAILED - 2) a disabled test [0 sec] (DISABLED) % Failures: % 1) failing_test "Fails as values are different" Actual: 'number [1] ' (varchar2) was expected to equal: 'number [2] ' (varchar2)% at "UT3$USER#.TEST_REPORTERS%", line 36 ut3.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] '); % % 2) erroring_test ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at "UT3$USER#.TEST_REPORTERS", line 44% ORA-06512: at line 6 Finished in % seconds 4 tests, 1 failed, 1 errored, 1 disabled, 0 warning(s)%]'; begin select * bulk collect into l_results from table( ut3.ut.run( 'test_reporters', ut3.ut_documentation_reporter() ) ); l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; end; / \ No newline at end of file diff --git a/test/core/reporters/test_documentation_reporter.pks b/test/ut3_user/reporters/test_documentation_reporter.pks similarity index 81% rename from test/core/reporters/test_documentation_reporter.pks rename to test/ut3_user/reporters/test_documentation_reporter.pks index 09835abdc..ec6894c61 100644 --- a/test/core/reporters/test_documentation_reporter.pks +++ b/test/ut3_user/reporters/test_documentation_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_documentation_reporter as --%suite(ut_documentation_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%test(Report produces expected output) procedure report_produces_expected_out; diff --git a/test/ut3_user/reporters/test_extended_coverage.pkb b/test/ut3_user/reporters/test_extended_coverage.pkb new file mode 100644 index 000000000..bb8bd27a6 --- /dev/null +++ b/test/ut3_user/reporters/test_extended_coverage.pkb @@ -0,0 +1,106 @@ +create or replace package body test_extended_coverage is + + g_run_id ut3.ut_coverage.tt_coverage_id_arr; + + function get_mock_block_run_id return integer is + begin + return ut3_tester_helper.coverage_helper.get_mock_block_run_id(); + end; + + function get_mock_proftab_run_id return integer is + begin + return ut3_tester_helper.coverage_helper.get_mock_run_id(); + end; + + procedure setup_dummy_coverage is + pragma autonomous_transaction; + begin + ut3_tester_helper.coverage_helper.create_dummy_12_2_cov_pck(); + ut3_tester_helper.coverage_helper.create_dummy_12_2_cov_test(); + ut3_tester_helper.coverage_helper.grant_exec_on_12_2_cov(); + g_run_id(ut3.ut_coverage.gc_block_coverage) := get_mock_block_run_id(); + g_run_id(ut3.ut_coverage.gc_proftab_coverage) := get_mock_proftab_run_id(); + ut3.ut_coverage.mock_coverage_id(g_run_id); + ut3_tester_helper.coverage_helper.mock_block_coverage_data(g_run_id(ut3.ut_coverage.gc_block_coverage),user); + ut3_tester_helper.coverage_helper.mock_profiler_coverage_data(g_run_id(ut3.ut_coverage.gc_proftab_coverage),user); + commit; + end; + + procedure cleanup_dummy_coverage is + begin + ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(g_run_id(ut3.ut_coverage.gc_block_coverage) + ,g_run_id(ut3.ut_coverage.gc_proftab_coverage)); + end; + + procedure coverage_for_object is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + begin + --Arrange + l_expected := '%%%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_block_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long' ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_for_schema is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + begin + --Arrange + l_expected := '%%%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_block_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_coverage_schemes => ut3.ut_varchar2_list( 'ut3' ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + ut.expect(l_actual).to_be_like('%%%'); + end; + + procedure coverage_for_file is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + l_file_path varchar2(250); + begin + --Arrange + l_file_path := lower('test/ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long.pkb'); + l_expected := '%%%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_block_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_source_files => ut3.ut_varchar2_list( l_file_path ), + a_test_files => ut3.ut_varchar2_list( ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + +end; +/ diff --git a/test/core/reporters/test_extended_coverage.pks b/test/ut3_user/reporters/test_extended_coverage.pks similarity index 92% rename from test/core/reporters/test_extended_coverage.pks rename to test/ut3_user/reporters/test_extended_coverage.pks index 6d85a4a30..aaef20877 100644 --- a/test/core/reporters/test_extended_coverage.pks +++ b/test/ut3_user/reporters/test_extended_coverage.pks @@ -1,7 +1,7 @@ create or replace package test_extended_coverage is --%suite - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%beforeall procedure setup_dummy_coverage; diff --git a/test/core/reporters/test_junit_reporter.pkb b/test/ut3_user/reporters/test_junit_reporter.pkb similarity index 84% rename from test/core/reporters/test_junit_reporter.pkb rename to test/ut3_user/reporters/test_junit_reporter.pkb index e0a7ea00d..e1b790156 100644 --- a/test/core/reporters/test_junit_reporter.pkb +++ b/test/ut3_user/reporters/test_junit_reporter.pkb @@ -72,23 +72,6 @@ create or replace package body test_junit_reporter as execute immediate q'[create or replace package body Tst_Fix_Case_Sensitive as procedure bUgFiX is begin ut.expect(1).to_equal(1); end; end;]'; - - execute immediate q'[create or replace package check_fail_escape is - --%suitepath(core) - --%suite(checkfailedescape) - --%displayname(Check JUNIT XML failure is escaped) - - --%test(Fail Miserably) - procedure fail_miserably; - - end;]'; - - execute immediate q'[create or replace package body check_fail_escape is - procedure fail_miserably is - begin - ut3.ut.expect('test').to_equal(''); - end; - end;]'; end; @@ -100,7 +83,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).not_to_be_like('%%'); ut.expect(l_actual).to_be_like('%<tag>%'); @@ -114,7 +97,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).not_to_be_like('%Actual: 1 (number) was expected to equal: 1 (number)%'); ut.expect(l_actual).to_be_like('%Actual: 1 (number) was expected to equal: 2 (number)%'); @@ -128,25 +111,12 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_xunit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).not_to_be_like('%Actual: 1 (number) was expected to equal: 1 (number)%'); ut.expect(l_actual).to_be_like('%Actual: 1 (number) was expected to equal: 2 (number)%'); end; - procedure reports_failed_line is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_junit_reporting',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%at "%.CHECK_JUNIT_REPORTING%", line %'); - end; - procedure check_classname_suite is l_results ut3.ut_varchar2_list; l_actual clob; @@ -155,7 +125,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%testcase classname="check_junit_reporting" assertions="%" name="%"%'); end; @@ -174,7 +144,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting', ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_match('time="[0-9]*\.[0-9]{3,6}"'); --Cleanup @@ -189,7 +159,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_rep_suitepath',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%testcase classname="core.check_junit_rep_suitepath" assertions="%" name="%"%'); end; @@ -216,7 +186,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('tst_package_junit_nodesc',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; @@ -238,7 +208,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('tst_package_junit_nosuite',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; @@ -294,7 +264,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('test_reporters',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; @@ -302,13 +272,7 @@ create or replace package body test_junit_reporter as l_results ut3.ut_varchar2_list; l_actual clob; begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_fail_escape',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%Actual: 'test' (varchar2) was expected to equal: '<![CDATA[some stuff]]>' (varchar2)%'); + reporters.check_xml_failure_escaped(ut3.ut_junit_reporter()); end; procedure check_classname_is_populated is @@ -329,7 +293,7 @@ create or replace package body test_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('Tst_Fix_Case_Sensitive',ut3.ut_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; @@ -345,7 +309,6 @@ create or replace package body test_junit_reporter as execute immediate 'drop package check_junit_rep_suitepath'; execute immediate 'drop package tst_package_junit_nodesc'; execute immediate 'drop package tst_package_junit_nosuite'; - execute immediate 'drop package check_fail_escape'; execute immediate 'drop package Tst_Fix_Case_Sensitive'; end; diff --git a/test/core/reporters/test_junit_reporter.pks b/test/ut3_user/reporters/test_junit_reporter.pks similarity index 92% rename from test/core/reporters/test_junit_reporter.pks rename to test/ut3_user/reporters/test_junit_reporter.pks index b39c5ff03..71443c180 100644 --- a/test/core/reporters/test_junit_reporter.pks +++ b/test/ut3_user/reporters/test_junit_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_junit_reporter as --%suite(ut_junit_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%beforeall procedure create_a_test_package; @@ -15,9 +15,6 @@ create or replace package test_junit_reporter as --%test(Xunit Backward Compatibility - Reports only failed expectations and exceptions) procedure reports_xunit_only_fail_or_err; - --%test(Reports failed line of test) - procedure reports_failed_line; - --%test(Check that classname is returned correct suite) procedure check_classname_suite; diff --git a/test/ut3_user/reporters/test_proftab_coverage.pkb b/test/ut3_user/reporters/test_proftab_coverage.pkb new file mode 100644 index 000000000..c5ad8c112 --- /dev/null +++ b/test/ut3_user/reporters/test_proftab_coverage.pkb @@ -0,0 +1,143 @@ +create or replace package body test_proftab_coverage is + + procedure create_dummy_coverage_test_1 is + begin + ut3_tester_helper.coverage_helper.create_dummy_coverage_test_1(); + ut3_tester_helper.coverage_helper.grant_exec_on_cov_1(); + end; + + procedure drop_dummy_coverage_test_1 is + begin + ut3_tester_helper.coverage_helper.drop_dummy_coverage_test_1(); + end; + + procedure coverage_for_object is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + begin + --Arrange + l_expected := '%%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_for_object_no_owner is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + begin + --Arrange + l_expected := '%%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_include_objects => ut3.ut_varchar2_list( 'dummy_coverage' ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_for_schema is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + begin + --Arrange + l_expected := ''; + l_expected := '%'||l_expected||'%'||l_expected||'%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_coverage_schemes => ut3.ut_varchar2_list( 'ut3' ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_for_file is + l_expected clob; + l_actual clob; + l_results ut3.ut_varchar2_list; + l_file_path varchar2(100); + begin + --Arrange + l_file_path := lower('test/ut3.dummy_coverage.pkb'); + l_expected := '%%'; + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3.test_dummy_coverage', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_source_files => ut3.ut_varchar2_list( l_file_path ), + a_test_files => ut3.ut_varchar2_list( ) + ) + ); + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_be_like(l_expected); + end; + + procedure coverage_tmp_data_refresh is + l_actual clob; + l_results ut3.ut_varchar2_list; + begin + --Arrange + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3:coverage_testing', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) + ) + ); + ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(test_coverage.g_run_id); + ut3_tester_helper.coverage_helper.drop_dummy_coverage_pkg(); + create_dummy_coverage_test_1; + + --Act + select * + bulk collect into l_results + from table( + ut3.ut.run( + a_path => 'ut3:coverage_testing', + a_reporter=> ut3.ut_coverage_sonar_reporter( ), + a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) + ) + ); + + --Assert + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); + ut.expect(l_actual).to_equal(to_clob(' + +')); + end; + +end; +/ diff --git a/test/core/reporters/test_coverage.pks b/test/ut3_user/reporters/test_proftab_coverage.pks similarity index 62% rename from test/core/reporters/test_coverage.pks rename to test/ut3_user/reporters/test_proftab_coverage.pks index 51eb175ec..1bb5c10cd 100644 --- a/test/core/reporters/test_coverage.pks +++ b/test/ut3_user/reporters/test_proftab_coverage.pks @@ -1,21 +1,7 @@ -create or replace package test_coverage is +create or replace package test_proftab_coverage is --%suite - --%suitepath(utplsql.core.reporters) - - g_run_id integer; - - --%beforeall - procedure create_dummy_coverage_pkg; - --%beforeall - procedure setup_dummy_coverage; - - - --%afterall - procedure drop_dummy_coverage_pkg; - --%afterall - procedure cleanup_dummy_coverage; - + --%suitepath(utplsql.test_user.reporters.test_coverage) --%test(Coverage is gathered for specified object - default coverage type) procedure coverage_for_object; @@ -30,11 +16,12 @@ create or replace package test_coverage is procedure coverage_for_file; --%test(Coverage data is not cached between runs - issue #562 ) - --%aftertest(create_dummy_coverage_pkg) - --%aftertest(setup_dummy_coverage) + --%aftertest(ut3$user#.test_coverage.create_dummy_coverage_pkg) + --%aftertest(ut3$user#.test_coverage.setup_dummy_coverage) --%aftertest(drop_dummy_coverage_test_1) procedure coverage_tmp_data_refresh; procedure drop_dummy_coverage_test_1; + end; / diff --git a/test/core/reporters/test_realtime_reporter.pkb b/test/ut3_user/reporters/test_realtime_reporter.pkb similarity index 75% rename from test/core/reporters/test_realtime_reporter.pkb rename to test/ut3_user/reporters/test_realtime_reporter.pkb index c4ceb9d5d..28724facf 100644 --- a/test/core/reporters/test_realtime_reporter.pkb +++ b/test/ut3_user/reporters/test_realtime_reporter.pkb @@ -1,6 +1,6 @@ create or replace package body test_realtime_reporter as - g_events test_event_list := test_event_list(); + g_events ut3_tester_helper.test_event_list := ut3_tester_helper.test_event_list(); procedure create_test_suites_and_run is pragma autonomous_transaction; @@ -99,6 +99,23 @@ create or replace package body test_realtime_reporter as raise no_data_found; end; end;]'; + + execute immediate q'[create or replace package check_realtime_reporting4 is + --%suite + --%suitepath(realtime_reporting) + /* tag annotation without parameter will raise a warning */ + --%tags + + --%test + procedure test_8_with_warning; + end;]'; + execute immediate q'[create or replace package body check_realtime_reporting4 is + procedure test_8_with_warning is + begin + commit; -- this will raise a warning + ut3.ut.expect(8).to_equal(8); + end; + end;]'; <> declare @@ -110,9 +127,9 @@ create or replace package body test_realtime_reporter as a_reporters => ut3.ut_reporters(l_reporter) ); -- consume - select test_event_object(item_type, xmltype(text)) + select ut3_tester_helper.test_event_object(item_type, xmltype(text)) bulk collect into g_events - from table(ut3.ut_output_table_buffer(l_reporter.output_buffer.output_id).get_lines()) + from table(l_reporter.get_lines()) where trim(text) is not null and item_type is not null; end run_report_and_cache_result; end create_test_suites_and_run; @@ -128,6 +145,10 @@ create or replace package body test_realtime_reporter as open l_expected for select 'pre-run' as event_type, null as item_id from dual union all select 'pre-suite' as event_type, 'realtime_reporting' as item_id from dual union all + select 'pre-suite' as event_type, 'realtime_reporting.check_realtime_reporting4' as item_id from dual union all + select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting4.test_8_with_warning' as item_id from dual union all + select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting4.test_8_with_warning' as item_id from dual union all + select 'post-suite' as event_type, 'realtime_reporting.check_realtime_reporting4' as item_id from dual union all select 'pre-suite' as event_type, 'realtime_reporting.check_realtime_reporting3' as item_id from dual union all select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting3.test_6_with_runtime_error' as item_id from dual union all select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting3.test_6_with_runtime_error' as item_id from dual union all @@ -179,6 +200,9 @@ create or replace package body test_realtime_reporter as select 'event/items/suite/items/suite' as node_path from dual union all select 'event/items/suite/items/suite/items' as node_path from dual union all select 'event/items/suite/items/suite/items/test' as node_path from dual union all + select 'event/items/suite/items/suite' as node_path from dual union all + select 'event/items/suite/items/suite/items' as node_path from dual union all + select 'event/items/suite/items/suite/items/test' as node_path from dual union all select 'event/items/suite/items/suite/items/test' as node_path from dual union all select 'event/items/suite/items/suite' as node_path from dual union all select 'event/items/suite/items/suite/items' as node_path from dual union all @@ -196,7 +220,7 @@ create or replace package body test_realtime_reporter as procedure total_number_of_tests is l_actual integer; - l_expected integer := 7; + l_expected integer := 8; begin select t.event_doc.extract('/event/totalNumberOfTests/text()').getnumberval() into l_actual @@ -242,9 +266,9 @@ create or replace package body test_realtime_reporter as and t.event_doc.extract('//test/@id').getstringval() is not null; open l_expected for select level as test_number, - 7 as total_number_of_tests + 8 as total_number_of_tests from dual - connect by level <= 7; + connect by level <= 8; ut.expect(l_actual).to_equal(l_expected).unordered; end pre_test_nodes; @@ -270,9 +294,9 @@ create or replace package body test_realtime_reporter as and t.event_doc.extract('//test/counter/warning/text()').getnumberval() is not null; open l_expected for select level as test_number, - 7 as total_number_of_tests + 8 as total_number_of_tests from dual - connect by level <= 7; + connect by level <= 8; ut.expect(l_actual).to_equal(l_expected).unordered; end post_test_nodes; @@ -320,10 +344,10 @@ create or replace package body test_realtime_reporter as from table(g_events) t where t.event_doc.extract('/event[@type="post-test"]/test/@id').getstringval() = 'realtime_reporting.check_realtime_reporting3.test_7_with_serveroutput'; - ut3.ut_utils.append_to_list(l_expected_list, ''); - l_expected := ut3.ut_utils.table_to_clob(l_expected_list); + ut3_tester_helper.main_helper.append_to_list(l_expected_list, ''); + l_expected := ut3_tester_helper.main_helper.table_to_clob(l_expected_list); ut.expect(l_actual).to_equal(l_expected); end serveroutput_of_test; @@ -337,11 +361,11 @@ create or replace package body test_realtime_reporter as from table(g_events) t where t.event_doc.extract('/event[@type="post-suite"]/suite/@id').getstringval() = 'realtime_reporting.check_realtime_reporting3'; - ut3.ut_utils.append_to_list(l_expected_list, ''); - l_expected := ut3.ut_utils.table_to_clob(l_expected_list); + ut3_tester_helper.main_helper.append_to_list(l_expected_list, ''); + l_expected := ut3_tester_helper.main_helper.table_to_clob(l_expected_list); ut.expect(l_actual).to_equal(l_expected); end serveroutput_of_testsuite; @@ -355,10 +379,10 @@ create or replace package body test_realtime_reporter as from table(g_events) t where t.event_doc.extract('/event[@type="post-test"]/test/@id').getstringval() = 'realtime_reporting.check_realtime_reporting3.test_6_with_runtime_error'; - ut3.ut_utils.append_to_list(l_expected_list, ''); - l_expected := ut3.ut_utils.table_to_clob(l_expected_list); + ut3_tester_helper.main_helper.append_to_list(l_expected_list, ''); + l_expected := ut3_tester_helper.main_helper.table_to_clob(l_expected_list); ut.expect(l_actual).to_be_like(l_expected); end error_stack_of_test; @@ -372,13 +396,48 @@ create or replace package body test_realtime_reporter as from table(g_events) t where t.event_doc.extract('/event[@type="post-suite"]/suite/@id').getstringval() = 'realtime_reporting.check_realtime_reporting3'; - ut3.ut_utils.append_to_list(l_expected_list, ''); - l_expected := ut3.ut_utils.table_to_clob(l_expected_list); + ut3_tester_helper.main_helper.append_to_list(l_expected_list, ''); + l_expected := ut3_tester_helper.main_helper.table_to_clob(l_expected_list); ut.expect(l_actual).to_be_like(l_expected); end error_stack_of_testsuite; + procedure warnings_of_test is + l_actual clob; + l_expected_list ut3.ut_varchar2_list; + l_expected clob; + begin + select t.event_doc.extract('//event/test/warnings/text()').getstringval() + into l_actual + from table(g_events) t + where t.event_doc.extract('/event[@type="post-test"]/test/@id').getstringval() + = 'realtime_reporting.check_realtime_reporting4.test_8_with_warning'; + ut3_tester_helper.main_helper.append_to_list(l_expected_list, ''); + l_expected := ut3_tester_helper.main_helper.table_to_clob(l_expected_list); + ut.expect(l_actual).to_be_like(l_expected); + end warnings_of_test; + + procedure warnings_of_testsuite is + l_actual clob; + l_expected_list ut3.ut_varchar2_list; + l_expected clob; + begin + select t.event_doc.extract('//event/suite/warnings/text()').getstringval() + into l_actual + from table(g_events) t + where t.event_doc.extract('/event[@type="post-suite"]/suite/@id').getstringval() + = 'realtime_reporting.check_realtime_reporting4'; + ut3_tester_helper.main_helper.append_to_list(l_expected_list, ''); + l_expected := ut3_tester_helper.main_helper.table_to_clob(l_expected_list); + ut.expect(l_actual).to_be_like(l_expected); + end warnings_of_testsuite; + procedure get_description is l_reporter ut3.ut_realtime_reporter; l_actual varchar2(4000); @@ -395,6 +454,7 @@ create or replace package body test_realtime_reporter as execute immediate 'drop package check_realtime_reporting1'; execute immediate 'drop package check_realtime_reporting2'; execute immediate 'drop package check_realtime_reporting3'; + execute immediate 'drop package check_realtime_reporting4'; end remove_test_suites; end test_realtime_reporter; diff --git a/test/core/reporters/test_realtime_reporter.pks b/test/ut3_user/reporters/test_realtime_reporter.pks similarity index 90% rename from test/core/reporters/test_realtime_reporter.pks rename to test/ut3_user/reporters/test_realtime_reporter.pks index b59313895..e57ccab21 100644 --- a/test/core/reporters/test_realtime_reporter.pks +++ b/test/ut3_user/reporters/test_realtime_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_realtime_reporter as --%suite(ut_realtime_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%beforeall procedure create_test_suites_and_run; @@ -44,7 +44,13 @@ create or replace package test_realtime_reporter as --%test(Provide the error stack of a testsuite) procedure error_stack_of_testsuite; - + + --%test(Provide warnings of a test) + procedure warnings_of_test; + + --%test(Provide warnings of a testsuite) + procedure warnings_of_testsuite; + --%test(Provide a description of the reporter explaining the use for SQL Developer) procedure get_description; diff --git a/test/core/reporters/test_sonar_test_reporter.pkb b/test/ut3_user/reporters/test_sonar_test_reporter.pkb similarity index 78% rename from test/core/reporters/test_sonar_test_reporter.pkb rename to test/ut3_user/reporters/test_sonar_test_reporter.pkb index 9cf38ea91..357eff0a2 100644 --- a/test/core/reporters/test_sonar_test_reporter.pkb +++ b/test/ut3_user/reporters/test_sonar_test_reporter.pkb @@ -20,10 +20,10 @@ create or replace package body test_sonar_test_reporter as ut3.ut.run( 'test_reporters', ut3.ut_sonar_test_reporter(), - a_test_file_mappings => ut3.ut_file_mapper.build_file_mappings( user, ut3.ut_varchar2_list('tests/helpers/test_reporters.pkb')) + a_test_file_mappings => ut3.ut_file_mapper.build_file_mappings( sys_context('USERENV', 'CURRENT_USER'), ut3.ut_varchar2_list('tests/helpers/test_reporters.pkb')) ) ); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual :=ut3_tester_helper.main_helper.table_to_clob(l_results); ut.expect(l_actual).to_be_like(l_expected); end; @@ -32,5 +32,10 @@ create or replace package body test_sonar_test_reporter as reporters.check_xml_encoding_included(ut3.ut_sonar_test_reporter(), 'UTF-8'); end; + procedure check_failure_escaped is + begin + reporters.check_xml_failure_escaped(ut3.ut_sonar_test_reporter()); + end; + end; / diff --git a/test/core/reporters/test_sonar_test_reporter.pks b/test/ut3_user/reporters/test_sonar_test_reporter.pks similarity index 67% rename from test/core/reporters/test_sonar_test_reporter.pks rename to test/ut3_user/reporters/test_sonar_test_reporter.pks index ab4776c38..ade449dba 100644 --- a/test/core/reporters/test_sonar_test_reporter.pks +++ b/test/ut3_user/reporters/test_sonar_test_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_sonar_test_reporter as --%suite(ut_sonar_test_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%test(Report produces expected output) procedure report_produces_expected_out; @@ -9,5 +9,8 @@ create or replace package test_sonar_test_reporter as --%test(Includes XML header with encoding when encoding provided) procedure check_encoding_included; + --%test( Validate that fail with special char are escaped ) + procedure check_failure_escaped; + end; / diff --git a/test/core/reporters/test_teamcity_reporter.pkb b/test/ut3_user/reporters/test_teamcity_reporter.pkb similarity index 78% rename from test/core/reporters/test_teamcity_reporter.pkb rename to test/ut3_user/reporters/test_teamcity_reporter.pkb index 77b850b15..fc2ab169e 100644 --- a/test/core/reporters/test_teamcity_reporter.pkb +++ b/test/ut3_user/reporters/test_teamcity_reporter.pkb @@ -45,29 +45,29 @@ create or replace package body test_teamcity_reporter as %##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.tests.helpers'] %##teamcity[testSuiteStarted timestamp='%' name='A suite for testing different outcomes from reporters'] %##teamcity[testSuiteStarted timestamp='%' name='A description of some context'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.passing_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3$user#.test_reporters.passing_test'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.passing_test'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3$user#.test_reporters.passing_test'] %##teamcity[testSuiteFinished timestamp='%' name='A description of some context'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.failing_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3$user#.test_reporters.failing_test'] -%##teamcity[testFailed timestamp='%' details='Actual: |'number |[1|] |' (varchar2) was expected to equal: |'number |[2|] |' (varchar2) ' message='Fails as values are different' name='ut3_tester.test_reporters.failing_test'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.failing_test'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.erroring_test'] +%##teamcity[testFailed timestamp='%' details='Actual: |'number |[1|] |' (varchar2) was expected to equal: |'number |[2|] |' (varchar2) ' message='Fails as values are different' name='ut3$user#.test_reporters.failing_test'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3$user#.test_reporters.failing_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3$user#.test_reporters.erroring_test'] -%##teamcity[testStdErr timestamp='%' name='ut3_tester.test_reporters.erroring_test' out='Test exception:|nORA-06512: at "UT3_TESTER.TEST_REPORTERS", line %|nORA-06512: at %|n|n'] -%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06512: at "UT3_TESTER.TEST_REPORTERS", line %|nORA-06512: at %|n|n' message='Error occured' name='ut3_tester.test_reporters.erroring_test'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.test_reporters.erroring_test'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.test_reporters.disabled_test'] -%##teamcity[testIgnored timestamp='%' name='ut3_tester.test_reporters.disabled_test'] +%##teamcity[testStdErr timestamp='%' name='ut3$user#.test_reporters.erroring_test' out='Test exception:|nORA-06512: at "UT3$USER#.TEST_REPORTERS", line %|nORA-06512: at %|n|n'] +%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06512: at "UT3$USER#.TEST_REPORTERS", line %|nORA-06512: at %|n|n' message='Error occured' name='ut3$user#.test_reporters.erroring_test'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3$user#.test_reporters.erroring_test'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3$user#.test_reporters.disabled_test'] +%##teamcity[testIgnored timestamp='%' name='ut3$user#.test_reporters.disabled_test'] %##teamcity[testSuiteFinished timestamp='%' name='A suite for testing different outcomes from reporters'] %##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.tests.helpers'] %##teamcity[testSuiteFinished timestamp='%' name='org.utplsql.tests'] @@ -79,7 +79,7 @@ create or replace package body test_teamcity_reporter as from table(ut3.ut.run('test_reporters',ut3.ut_teamcity_reporter())); --assert - ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected); + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); end; procedure escape_special_chars is @@ -88,9 +88,9 @@ create or replace package body test_teamcity_reporter as l_expected varchar2(32767); begin l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='A suite with |'quote|''] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.check_escape_special_chars.test_do_stuff'] -%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |' |[ |r|n |] |'|nwas expected to be null' name='ut3_tester.check_escape_special_chars.test_do_stuff'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.check_escape_special_chars.test_do_stuff'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3$user#.check_escape_special_chars.test_do_stuff'] +%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |' |[ |r|n |] |'|nwas expected to be null' name='ut3$user#.check_escape_special_chars.test_do_stuff'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3$user#.check_escape_special_chars.test_do_stuff'] %##teamcity[testSuiteFinished timestamp='%' name='A suite with |'quote|'']}'; --act select * @@ -98,7 +98,7 @@ create or replace package body test_teamcity_reporter as from table(ut3.ut.run('check_escape_special_chars',ut3.ut_teamcity_reporter())); --assert - ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected); + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); end; procedure trims_long_output is @@ -107,9 +107,9 @@ create or replace package body test_teamcity_reporter as l_expected varchar2(32767); begin l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_trims_long_output'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_tester.check_trims_long_output.long_output'] -%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |'aVarcharaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|[...|]' name='ut3_tester.check_trims_long_output.long_output'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_tester.check_trims_long_output.long_output'] +%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3$user#.check_trims_long_output.long_output'] +%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |'aVarcharaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|[...|]' name='ut3$user#.check_trims_long_output.long_output'] +%##teamcity[testFinished timestamp='%' duration='%' name='ut3$user#.check_trims_long_output.long_output'] %##teamcity[testSuiteFinished timestamp='%' name='check_trims_long_output']}'; --act select * @@ -117,7 +117,7 @@ create or replace package body test_teamcity_reporter as from table(ut3.ut.run('check_trims_long_output',ut3.ut_teamcity_reporter())); --assert - ut.expect(ut3.ut_utils.table_to_clob(l_output_data)).to_be_like(l_expected); + ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); end; procedure remove_test_package is diff --git a/test/core/reporters/test_teamcity_reporter.pks b/test/ut3_user/reporters/test_teamcity_reporter.pks similarity index 90% rename from test/core/reporters/test_teamcity_reporter.pks rename to test/ut3_user/reporters/test_teamcity_reporter.pks index ef474b225..f849751f1 100644 --- a/test/core/reporters/test_teamcity_reporter.pks +++ b/test/ut3_user/reporters/test_teamcity_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_teamcity_reporter as --%suite(ut_teamcity_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%beforeall procedure create_a_test_package; diff --git a/test/core/reporters/test_tfs_junit_reporter.pkb b/test/ut3_user/reporters/test_tfs_junit_reporter.pkb similarity index 74% rename from test/core/reporters/test_tfs_junit_reporter.pkb rename to test/ut3_user/reporters/test_tfs_junit_reporter.pkb index 122c665e3..196a2ec08 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pkb +++ b/test/ut3_user/reporters/test_tfs_junit_reporter.pkb @@ -48,25 +48,7 @@ create or replace package body test_tfs_junit_reporter as null; end; end;]'; - - execute immediate q'[create or replace package check_fail_escape is - --%suitepath(core) - --%suite(checkfailedescape) - --%displayname(Check JUNIT XML failure is escaped) - - --%test(Fail Miserably) - procedure fail_miserably; - - end;]'; - - execute immediate q'[create or replace package body check_fail_escape is - procedure fail_miserably is - begin - ut3.ut.expect('test').to_equal(''); - end; - end;]'; - end; @@ -78,7 +60,7 @@ create or replace package body test_tfs_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).not_to_be_like('%%'); ut.expect(l_actual).to_be_like('%<tag>%'); @@ -92,25 +74,12 @@ create or replace package body test_tfs_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).not_to_be_like('%Actual: 1 (number) was expected to equal: 1 (number)%'); ut.expect(l_actual).to_be_like('%Actual: 1 (number) was expected to equal: 2 (number)%'); end; - procedure reports_failed_line is - l_results ut3.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_junit_reporting',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%at "%.CHECK_JUNIT_REPORTING%", line %'); - end; - procedure check_classname_suite is l_results ut3.ut_varchar2_list; l_actual clob; @@ -119,7 +88,7 @@ create or replace package body test_tfs_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%testcase classname="check_junit_reporting"%'); end; @@ -132,7 +101,7 @@ create or replace package body test_tfs_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_flat_suitepath',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like(' @@ -157,7 +126,7 @@ create or replace package body test_tfs_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_reporting', ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_match('time="[0-9]*\.[0-9]{3,6}"'); --Cleanup @@ -165,16 +134,8 @@ create or replace package body test_tfs_junit_reporter as end; procedure check_failure_escaped is - l_results ut3.ut_varchar2_list; - l_actual clob; begin - --Act - select * - bulk collect into l_results - from table(ut3.ut.run('check_fail_escape',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like('%Actual: 'test' (varchar2) was expected to equal: '<![CDATA[some stuff]]>' (varchar2)%'); + reporters.check_xml_failure_escaped(ut3.ut_tfs_junit_reporter()); end; procedure check_classname_suitepath is @@ -185,7 +146,7 @@ create or replace package body test_tfs_junit_reporter as select * bulk collect into l_results from table(ut3.ut.run('check_junit_rep_suitepath',ut3.ut_tfs_junit_reporter())); - l_actual := ut3.ut_utils.table_to_clob(l_results); + l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); --Assert ut.expect(l_actual).to_be_like('%testcase classname="core.check_junit_rep_suitepath"%'); end; @@ -195,7 +156,6 @@ create or replace package body test_tfs_junit_reporter as execute immediate 'drop package check_junit_reporting'; execute immediate 'drop package check_junit_rep_suitepath'; execute immediate 'drop package check_junit_flat_suitepath'; - execute immediate 'drop package check_fail_escape'; end; procedure check_encoding_included is diff --git a/test/core/reporters/test_tfs_junit_reporter.pks b/test/ut3_user/reporters/test_tfs_junit_reporter.pks similarity index 90% rename from test/core/reporters/test_tfs_junit_reporter.pks rename to test/ut3_user/reporters/test_tfs_junit_reporter.pks index cc589be1b..07acb4d21 100644 --- a/test/core/reporters/test_tfs_junit_reporter.pks +++ b/test/ut3_user/reporters/test_tfs_junit_reporter.pks @@ -1,7 +1,7 @@ create or replace package test_tfs_junit_reporter as --%suite(ut_tfs_junit_reporter) - --%suitepath(utplsql.core.reporters) + --%suitepath(utplsql.test_user.reporters) --%beforeall procedure crate_a_test_package; @@ -12,9 +12,6 @@ create or replace package test_tfs_junit_reporter as --%test(Reports only failed expectations and exceptions) procedure reports_only_failed_or_errored; - --%test(Reports failed line of test) - procedure reports_failed_line; - --%test(Check that classname is returned correct suite) procedure check_classname_suite; diff --git a/test/ut3_user/test_user.pkb b/test/ut3_user/test_user.pkb new file mode 100644 index 000000000..ca84a1c69 --- /dev/null +++ b/test/ut3_user/test_user.pkb @@ -0,0 +1,11 @@ +create or replace package body test_user is + + procedure global_setup is + begin + ut3.ut_coverage.set_develop_mode(true); + --improve performance of test execution by disabling all compiler optimizations + ut3_tester_helper.main_helper.execute_autonomous('ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0'); + end; + +end; +/ diff --git a/test/ut3_user/test_user.pks b/test/ut3_user/test_user.pks new file mode 100644 index 000000000..ea0435efd --- /dev/null +++ b/test/ut3_user/test_user.pks @@ -0,0 +1,10 @@ +create or replace package test_user is + + --%suite + --%suitepath(utplsql) + + --%beforeall + procedure global_setup; + +end; +/