diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 2cda5ad55..000000000 --- a/.gitattributes +++ /dev/null @@ -1,18 +0,0 @@ -.github export-ignore -.idea export-ignore -development export-ignore -test export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.gitmodules export-ignore -mkdocs.yml export-ignore -BUILD_NO export-ignore -mkdocs_offline.yml export-ignore -sonar-project.properties export-ignore -^docs/** linguist-documentation -*.pkb linguist-language=PLSQL -*.pks linguist-language=PLSQL -*.sql linguist-language=PLSQL -*.tpb linguist-language=PLSQL -*.tps linguist-language=PLSQL -*.sh text eol=lf diff --git a/.github/DISCUSSION_TEMPLATE/README.md b/.github/DISCUSSION_TEMPLATE/README.md deleted file mode 100644 index f6c0905f4..000000000 --- a/.github/DISCUSSION_TEMPLATE/README.md +++ /dev/null @@ -1,150 +0,0 @@ -# GitHub Discussions β€” setup guide for utPLSQL/utPLSQL - -This folder contains the discussion category form templates that power structured -GitHub Discussions for the utPLSQL project. - ---- - -## File β†’ category mapping - - - -| File | Category name to create in GitHub | Format | Who can post | -|------------------------|-----------------------------------|-----------------------|--------------------------------| -| `announcements.yml` | πŸ“’ Announcements | Announcement | Maintainers only | -| `rfcs-design.yml` | πŸ’‘ RFCs & Design | Open-ended discussion | Everyone | -| `architecture.yml` | πŸ— Architecture | Open-ended discussion | Everyone | -| `release-planning.yml` | πŸ—“ Release Planning | Open-ended discussion | Maintainers only (recommended) | -| `q-a.yml` | ❓ Q&A | Question / Answer | Everyone | -| `show-and-tell.yml` | πŸ”¬ Show & Tell | Open-ended discussion | Everyone | -| `contributors.yml` | 🀝 Contributors | Open-ended discussion | Everyone | -| `general.yml` | πŸ’¬ General | Open-ended discussion | Everyone | - -> **Polls** are a built-in GitHub Discussions type and do not support YAML templates. -> Create a πŸ—³ Polls category manually (type: Poll) β€” no template file needed. - ---- - -## Step-by-step setup - -### 1. Enable Discussions -Go to **Settings β†’ Features** and check **Discussions**. - -### 2. Create the categories -Go to **Discussions β†’ Categories β†’ ✏️ Edit categories** (gear icon). - -Create each category listed in the table above. -**Order matters** β€” drag to set the display order shown below: - -1. πŸ“’ Announcements -2. πŸ’‘ RFCs & Design -3. πŸ— Architecture -4. πŸ—“ Release Planning -5. ❓ Q&A -6. πŸ”¬ Show & Tell -7. 🀝 Contributors -8. πŸ—³ Polls -9. πŸ’¬ General - -### 3. Commit the templates -Copy all `.yml` files from this folder into `.github/DISCUSSION_TEMPLATE/` in -the **default branch** (usually `develop` for utPLSQL). - -``` -.github/ -└── DISCUSSION_TEMPLATE/ - β”œβ”€β”€ announcements.yml - β”œβ”€β”€ rfcs-design.yml - β”œβ”€β”€ architecture.yml - β”œβ”€β”€ release-planning.yml - β”œβ”€β”€ q-a.yml - β”œβ”€β”€ show-and-tell.yml - β”œβ”€β”€ contributors.yml - └── general.yml -``` - -### 4. Configure category permissions - -| Category | Setting | -|------------------|--------------------------------------------------| -| Announcements | Set to **Maintainers only** in category settings | -| Release Planning | Recommended: **Maintainers only** | -| All others | Open to all | - -### 5. Create the welcome pinned post - -Create a first discussion in **Announcements** titled -**"Welcome to utPLSQL Discussions β€” how to use this space"** - -Suggested body: - -```markdown -## Welcome πŸ‘‹ - -This is the place for design discussions, feature proposals, and community -conversation around utPLSQL. - -### Where to post - -| I want to… | Use | -|---|---| -| Propose a new feature or behaviour change | πŸ’‘ RFCs & Design | -| Discuss internal architecture | πŸ— Architecture | -| Ask a usage / how-to question | ❓ Q&A | -| Share a CI pipeline, integration, or tip | πŸ”¬ Show & Tell | -| Ask about contributing / development setup | 🀝 Contributors | -| Vote on priorities | πŸ—³ Polls | -| Anything else | πŸ’¬ General | - -### Discussions vs Issues - -**Discussions** are for ideas that are still open, need input, or require consensus. -**Issues** are for well-scoped work that someone can pick up and implement. - -A maintainer will convert a Discussion to an Issue once scope is agreed. - -### Real-time chat - -For quick questions: [utPLSQL Slack](https://utplsql.slack.com) -For decisions that need a permanent record: post here. -``` - -Pin this post from the discussion's `…` menu β†’ **Pin discussion**. - -### 6. Update the README - -Add a Discussions badge to the project README: - -```markdown -[![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) -``` - -And add a short paragraph in the "Community" or "Contributing" section pointing -to Discussions as the place for design proposals. - ---- - -## Operating guidelines - -### Discussion β†’ Issue conversion rule - -| Category | Convert when… | -|---------------|----------------------------------------------------------------------| -| RFCs & Design | Consensus reached, scope is defined | -| Architecture | Breaking change formally agreed by maintainers | -| Q&A | A confirmed bug surfaces in the thread | -| Contributors | A gap in docs or tooling is identified that can be filed as an issue | - -Use the **"Create issue from discussion"** button (available in the discussion's sidebar). - -### Housekeeping - -- Lock **Announcements** threads after 30 days. -- Close **Polls** after 14 days; post a summary comment with the result before closing. -- Label cross-references: apply the same labels used on issues - (`enhancement`, `breaking-change`, `coverage`, `oracle-version`, etc.) - to discussions for consistent search. diff --git a/.github/DISCUSSION_TEMPLATE/announcements.yml b/.github/DISCUSSION_TEMPLATE/announcements.yml deleted file mode 100644 index 262746e11..000000000 --- a/.github/DISCUSSION_TEMPLATE/announcements.yml +++ /dev/null @@ -1,54 +0,0 @@ -title: "[Announcement] " -labels: ["announcement"] -body: - - type: markdown - attributes: - value: | - > **Maintainers only.** This category is restricted to project maintainers. - > Announcements are pinned and locked after 30 days. - - - type: dropdown - id: announcement_type - attributes: - label: Announcement type - options: - - New release - - Release candidate / pre-release - - Roadmap update - - Deprecation notice - - Security advisory - - Community / governance update - - Other - validations: - required: true - - - type: input - id: version - attributes: - label: Version (if applicable) - placeholder: "e.g. 3.2.0" - validations: - required: false - - - type: textarea - id: body - attributes: - label: Announcement body - description: | - Write the full announcement here. - For releases, include: highlights, breaking changes, upgrade notes, and a link to the full changelog. - validations: - required: true - - - type: textarea - id: links - attributes: - label: Key links - description: Release tag, changelog, migration guide, Docker image, CLI download, etc. - placeholder: | - - Release: https://github.com/utPLSQL/utPLSQL/releases/tag/v… - - Changelog: … - - Docker: … - - CLI: … - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/architecture.yml b/.github/DISCUSSION_TEMPLATE/architecture.yml deleted file mode 100644 index f3df8e29c..000000000 --- a/.github/DISCUSSION_TEMPLATE/architecture.yml +++ /dev/null @@ -1,100 +0,0 @@ -title: "[Architecture] " -labels: ["architecture", "design"] -body: - - type: markdown - attributes: - value: | - ## Architecture discussion - Use this template for internal design decisions: changes to the suite-loading mechanism, - the coverage engine, DDL trigger behaviour, reporter infrastructure, or any - cross-cutting concern that affects the internals of utPLSQL. - - This category is primarily for **contributors and maintainers**. - If you want to propose a user-facing feature, use **RFCs & Design** instead. - - - type: input - id: title_short - attributes: - label: Component / area - description: Which internal component or subsystem does this discussion concern? - placeholder: "e.g. Suite loader, Coverage engine, Annotation parser, Event system" - validations: - required: true - - - type: textarea - id: context - attributes: - label: Context and current design - description: Briefly describe how the relevant part works today. - validations: - required: true - - - type: textarea - id: problem - attributes: - label: Problem or design question - description: What specific decision needs to be made, or what limitation needs to be addressed? - validations: - required: true - - - type: textarea - id: options - attributes: - label: Options under consideration - description: | - List the design options you are weighing. For each option describe: - - How it works - - Pros - - Cons - - Impact on Oracle compatibility - placeholder: | - **Option A β€” …** - How: … - Pros: … - Cons: … - - **Option B β€” …** - How: … - Pros: … - Cons: … - validations: - required: true - - - type: textarea - id: preferred - attributes: - label: Preferred direction (if any) - description: If you already lean toward one option, say so and why. Leave blank if genuinely open. - validations: - required: false - - - type: dropdown - id: breaking - attributes: - label: Does this introduce a breaking change? - options: - - "No" - - "Yes β€” public API change (ut_runner, ut packages, annotations)" - - "Yes β€” output/reporter format change" - - "Yes β€” internal package change (no public API impact)" - - "Unsure" - validations: - required: true - - - type: textarea - id: migration - attributes: - label: Migration / compatibility notes - description: If breaking, describe the migration path for users and downstream integrations. - validations: - required: false - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have reviewed the existing architecture docs and source - required: true - - label: Relevant unit / integration tests have been considered - required: false diff --git a/.github/DISCUSSION_TEMPLATE/contributors.yml b/.github/DISCUSSION_TEMPLATE/contributors.yml deleted file mode 100644 index 6325961de..000000000 --- a/.github/DISCUSSION_TEMPLATE/contributors.yml +++ /dev/null @@ -1,56 +0,0 @@ -title: "[Contributors] " -labels: ["contributors"] -body: - - type: markdown - attributes: - value: | - ## Contributors - Questions about **contributing to utPLSQL** β€” development environment setup, - the test suite, pull request process, coding conventions, or anything else - that helps you get your first (or next) contribution merged. - - **Useful links before posting:** - - [CONTRIBUTING.md](../../blob/develop/CONTRIBUTING.md) - - [Development environment setup](../../blob/develop/docs/development/developer-guide.md) - - [Open issues labelled `good first issue`](../../issues?q=is%3Aopen+label%3A%22good+first+issue%22) - - - type: dropdown - id: topic - attributes: - label: Topic - options: - - Dev environment / Docker setup - - Running the test suite locally - - Understanding the codebase - - PR review process - - Coding conventions / style - - Good first issue β€” looking for guidance - - Release process - - Documentation contribution - - Other - validations: - required: true - - - type: textarea - id: question - attributes: - label: Question or request - description: What do you need help with? - validations: - required: true - - - type: textarea - id: context - attributes: - label: What you have tried - description: Steps already taken, error messages, links to relevant code, etc. - validations: - required: false - - - type: input - id: os - attributes: - label: Host OS / environment - placeholder: "e.g. macOS 14, Windows 11, Ubuntu 22.04, Docker on Linux" - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/general.yml b/.github/DISCUSSION_TEMPLATE/general.yml deleted file mode 100644 index 0e3b8d100..000000000 --- a/.github/DISCUSSION_TEMPLATE/general.yml +++ /dev/null @@ -1,28 +0,0 @@ -title: "" -labels: ["general"] -body: - - type: markdown - attributes: - value: | - ## General discussion - For open-ended conversations that don't fit another category: - project direction, community topics, suggestions, or anything else. - - If your post turns out to be a feature proposal, a maintainer may move it to - **RFCs & Design**. If it is a question about using utPLSQL, consider posting - in **Q&A** instead so a helpful answer can be marked. - - - type: textarea - id: body - attributes: - label: What's on your mind? - validations: - required: true - - - type: textarea - id: context - attributes: - label: Additional context - description: Background, links, related issues or discussions. - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml deleted file mode 100644 index e4ff1d452..000000000 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ /dev/null @@ -1,87 +0,0 @@ -title: "[Q&A] " -labels: ["question"] -body: - - type: markdown - attributes: - value: | - ## Question & Answer - Ask anything about **using** utPLSQL β€” installation, writing tests, CI integration, - reporters, annotations, code coverage, etc. - - **Tips for a fast answer:** - - Include your utPLSQL version and Oracle version. - - Paste a minimal reproducer (test package + expected vs actual output). - - Check the [documentation](https://utplsql.github.io/utPLSQL/) and - [closed Q&A discussions](../../discussions/categories/q-a?discussions_q=is%3Aclosed) first. - - > If this turns out to be a **bug**, a maintainer will convert this discussion into an Issue. - - - type: input - id: utplsql_version - attributes: - label: utPLSQL version - placeholder: "e.g. 3.1.13" - validations: - required: true - - - type: dropdown - id: oracle_version - attributes: - label: Oracle version - options: - - Oracle 11g - - Oracle 12c - - Oracle 18c - - Oracle 19c - - Oracle 21c - - Oracle 23c / 23ai - - Other / unsure - validations: - required: true - - - type: textarea - id: question - attributes: - label: Question - description: Describe what you are trying to do and what you have tried so far. - validations: - required: true - - - type: textarea - id: reproducer - attributes: - label: Minimal reproducer - description: | - Paste a minimal test package and/or the relevant ut_runner call. - Include the full error message or unexpected output if applicable. - render: sql - validations: - required: false - - - type: textarea - id: expected - attributes: - label: Expected behaviour - validations: - required: false - - - type: textarea - id: actual - attributes: - label: Actual behaviour / error - validations: - required: false - - - type: dropdown - id: install_method - attributes: - label: Installation method - options: - - utPLSQL-cli - - SQL*Plus script - - Docker / utPLSQL-docker - - Liquibase / Flyway - - Other - - N/A - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/release-planning.yml b/.github/DISCUSSION_TEMPLATE/release-planning.yml deleted file mode 100644 index 5663d7613..000000000 --- a/.github/DISCUSSION_TEMPLATE/release-planning.yml +++ /dev/null @@ -1,90 +0,0 @@ -title: "[Release] v" -labels: ["release-planning"] -body: - - type: markdown - attributes: - value: | - ## Release planning discussion - Use this template to discuss the scope of an upcoming release: - what goes in, what gets deferred, and what the acceptance criteria are. - - **Maintainers:** pin this discussion and link it from the corresponding GitHub Milestone. - - - type: input - id: version - attributes: - label: Target version - placeholder: "e.g. 3.2.0" - validations: - required: true - - - type: dropdown - id: release_type - attributes: - label: Release type - options: - - Major (breaking changes) - - Minor (new features, backward-compatible) - - Patch (bug fixes only) - validations: - required: true - - - type: textarea - id: goals - attributes: - label: Release goals - description: What are the 2–4 key things this release should achieve? - placeholder: | - 1. - 2. - 3. - validations: - required: true - - - type: textarea - id: scope_in - attributes: - label: In scope (proposed issues / PRs) - description: | - Link the GitHub Issues and PRs targeted for this release. - Use the format: `- [ ] #123 β€” short description` - placeholder: | - - [ ] #123 β€” ... - - [ ] #456 β€” ... - validations: - required: false - - - type: textarea - id: scope_out - attributes: - label: Out of scope / explicitly deferred - description: Issues that were considered but will not be included β€” and why. - validations: - required: false - - - type: input - id: target_date - attributes: - label: Target release date (approximate) - placeholder: "e.g. 2025-Q2" - validations: - required: false - - - type: textarea - id: oracle_matrix - attributes: - label: Oracle version test matrix - description: Which Oracle versions must pass CI before this release ships? - placeholder: | - - [ ] Oracle 19c - - [ ] Oracle 21c - - [ ] Oracle 23ai - validations: - required: false - - - type: textarea - id: notes - attributes: - label: Additional notes - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/rfcs-design.yml b/.github/DISCUSSION_TEMPLATE/rfcs-design.yml deleted file mode 100644 index 32c0a33c7..000000000 --- a/.github/DISCUSSION_TEMPLATE/rfcs-design.yml +++ /dev/null @@ -1,88 +0,0 @@ -title: "[RFC] " -labels: ["rfc", "design"] -body: - - type: markdown - attributes: - value: | - ## Request for Comments β€” design proposal - Use this template to propose a new feature, a change to existing behaviour, or a significant refactoring. - Once there is consensus and a clear scope, a maintainer will convert this discussion into one or more GitHub Issues. - - **Before posting:** search existing RFCs and open issues to avoid duplicates. - - - type: input - id: summary - attributes: - label: Summary - description: One sentence β€” what are you proposing? - placeholder: "Add support for ..." - validations: - required: true - - - type: textarea - id: problem - attributes: - label: Problem / motivation - description: What problem does this solve? Who is affected and how often? - placeholder: | - Currently, when ... it is not possible to ... - This forces users to ... - validations: - required: true - - - type: textarea - id: proposal - attributes: - label: Proposed solution - description: Describe the solution in as much detail as you have. Pseudo-code, SQL, or PL/SQL snippets are welcome. - placeholder: | - ```sql - -- example of the proposed API - ``` - validations: - required: true - - - type: textarea - id: alternatives - attributes: - label: Alternatives considered - description: What other approaches did you look at? Why did you rule them out? - validations: - required: false - - - type: textarea - id: breaking - attributes: - label: Breaking-change impact - description: | - Does this change affect existing annotations, package APIs, or test output formats? - List affected public symbols (ut_runner, ut, annotations, reporters …). - validations: - required: false - - - type: dropdown - id: oracle_versions - attributes: - label: Oracle version relevance - description: Which Oracle versions does this apply to? - multiple: true - options: - - All supported versions - - Oracle 11g - - Oracle 12c - - Oracle 18c - - Oracle 19c - - Oracle 21c - - Oracle 23c / 23ai - validations: - required: true - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have searched existing discussions and issues for duplicates - required: true - - label: I am willing to help implement or review this feature - required: false diff --git a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml deleted file mode 100644 index 4443c5de6..000000000 --- a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml +++ /dev/null @@ -1,79 +0,0 @@ -title: "[Show & Tell] " -labels: ["show-and-tell"] -body: - - type: markdown - attributes: - value: | - ## Show & Tell - Share how you are using utPLSQL in the wild β€” CI pipelines, IDE integrations, - custom reporters, coverage setups, framework wrappers, or anything else the - community might learn from. - - Posts here are a great source of real-world examples for the documentation. - - - type: input - id: title_short - attributes: - label: What are you sharing? - placeholder: "e.g. utPLSQL + GitHub Actions CI pipeline for Oracle 23ai" - validations: - required: true - - - type: dropdown - id: category - attributes: - label: Category - multiple: true - options: - - CI/CD integration - - IDE / SQL client integration - - Custom reporter - - Code coverage setup - - Framework wrapper / helper library - - Docker / containerised testing - - Annotation patterns - - Performance / large test suite - - Other - validations: - required: true - - - type: textarea - id: description - attributes: - label: Description - description: Describe what you built or configured and why it might be useful to others. - validations: - required: true - - - type: textarea - id: snippet - attributes: - label: Code or configuration snippet - description: Paste the most relevant excerpt. Link to a repo or Gist if you have one. - render: yaml - validations: - required: false - - - type: input - id: utplsql_version - attributes: - label: utPLSQL version used - placeholder: "e.g. 3.1.13" - validations: - required: false - - - type: input - id: oracle_version - attributes: - label: Oracle version - placeholder: "e.g. Oracle 19c" - validations: - required: false - - - type: textarea - id: links - attributes: - label: Links - description: Repository, blog post, documentation page, etc. - validations: - required: false diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index b3e52a19a..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**Provide version info** -Information about utPLSQL and Database version, -```sql -set serveroutput on -declare - l_version varchar2(255); - l_compatibility varchar2(255); -begin - dbms_utility.db_version( l_version, l_compatibility ); - dbms_output.put_line( l_version ); - dbms_output.put_line( l_compatibility ); -end; -/ -select substr(ut.version(),1,60) as ut_version from dual; -select * from v$version; -select * from nls_session_parameters; -select substr(dbms_utility.port_string,1,60) as port_string from dual; -``` - -**Information about client software** -What client was used to run utPLSQL tests? Was it from TOAD, SQLDeveloper, SQLPlus, PLSQL Developer etc... - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Example code** -If applicable, add sample code to help explain your problem. -Please avoid putting your company private/protected code in an issue, as it might violate your company's privacy and security policies. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index f0335781e..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. - -**Note** -> Please do not create issues for generic SQL or PL/SQL questions. There are other forums and communities to help you with those. See [ASKTom](https://asktom.oracle.com) for example. - -**Want to discuss** -If you want to discuss a problem, please go to [utPLSQL discussions](https://github.com/utPLSQL/utPLSQL/discussions) diff --git a/.github/scripts/create_test_users.sh b/.github/scripts/create_test_users.sh deleted file mode 100755 index fe43b7467..000000000 --- a/.github/scripts/create_test_users.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/bash - -set -ev -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd ${SCRIPT_DIR}/../../source - -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -set feedback off -whenever sqlerror exit failure rollback - --------------------------------------------------------------------------------- -PROMPT Adding back create-trigger privilege to $UT3_DEVELOP_SCHEMA for testing -grant administer database trigger to $UT3_DEVELOP_SCHEMA; - --------------------------------------------------------------------------------- -PROMPT Creating UT3_TESTER - Power-user for testing internal framework code - -create user UT3_TESTER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; -grant create session, create procedure, create type, create table to UT3_TESTER; - -grant execute on dbms_lock to UT3_TESTER; - -PROMPT Granting $UT3_DEVELOP_SCHEMA code to UT3_TESTER - -begin - for i in ( - select object_name from all_objects t - where t.object_type in ('PACKAGE','TYPE') - and owner = '$UT3_DEVELOP_SCHEMA' - and generated = 'N' - and object_name not like 'SYS%') - loop - execute immediate 'grant execute on $UT3_DEVELOP_SCHEMA."'||i.object_name||'" to UT3_TESTER'; - end loop; -end; -/ - -PROMPT Granting $UT3_DEVELOP_SCHEMA tables to UT3_TESTER - -begin - for i in ( select table_name from all_tables t where owner = '$UT3_DEVELOP_SCHEMA' and nested = 'NO' and iot_name is null) - loop - execute immediate 'grant select on $UT3_DEVELOP_SCHEMA.'||i.table_name||' to UT3_TESTER'; - end loop; -end; -/ - - --------------------------------------------------------------------------------- -PROMPT Creating UT3_USER - minimal privileges user for API testing - -create user UT3_USER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; -grant create session, create procedure, create type, create table to UT3_USER; - -PROMPT Grants for starting a debugging session from UT3_USER -grant debug connect session to UT3_USER; -grant debug any procedure to UT3_USER; -begin - \$if dbms_db_version.version <= 11 \$then - null; -- no addition action necessary - \$else - -- necessary on 12c or higher - dbms_network_acl_admin.append_host_ace ( - host =>'*', - ace => sys.xs\$ace_type( - privilege_list => sys.xs\$name_list('JDWP') , - principal_name => 'UT3_USER', - principal_type => sys.xs_acl.ptype_db - ) - ); - \$end -end; -/ - --------------------------------------------------------------------------------- -PROMPT Creating UT3_TESTER_HELPER - provides functions to allow min grant test user setup tests. - -create user UT3_TESTER_HELPER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; -grant create session, create procedure, create type, create table to UT3_TESTER_HELPER; - -PROMPT Grants for testing distributed transactions -grant create public database link to UT3_TESTER_HELPER; -grant drop public database link to UT3_TESTER_HELPER; - -PROMPT Grants for testing coverage outside of main $UT3_DEVELOP_SCHEMA 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, - grant any object privilege, grant any privilege, create public synonym, drop public synonym, create any trigger - to UT3_TESTER_HELPER; - -grant create job to UT3_TESTER_HELPER; - -PROMPT Additional grants for disabling DDL trigger and testing parser without trigger enabled/present - -grant alter any trigger to UT3_TESTER_HELPER; -grant administer database trigger to UT3_TESTER_HELPER; -grant execute on dbms_lock to UT3_TESTER_HELPER; - -create user ut3_cache_test_owner identified by ut3; -grant create session, create procedure to ut3_cache_test_owner; - -create user ut3_no_extra_priv_user identified by ut3; -grant create session, create procedure to ut3_no_extra_priv_user; - -create user ut3_select_catalog_user identified by ut3; -grant create session, create procedure, select_catalog_role to ut3_select_catalog_user; - -create user ut3_select_any_table_user identified by ut3; -grant create session, create procedure, select any table to ut3_select_any_table_user; - -create user ut3_execute_any_proc_user identified by ut3; -grant create session, create procedure, execute any procedure to ut3_execute_any_proc_user; -exit -SQL diff --git a/.github/scripts/get_project_version.sh b/.github/scripts/get_project_version.sh deleted file mode 100755 index 54a30a562..000000000 --- a/.github/scripts/get_project_version.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -version=`cat VERSION` -#When on develop branch, add "-develop" to the version text -if [[ "${CI_ACTION_REF_NAME}" == "develop" ]]; then - version=`sed -E "s/(v?[0-9]+\.[0-9]+\.[0-9]+).*/\1-develop/" <<< "${version}"` -fi -echo ${version} diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh deleted file mode 100755 index 46750b89c..000000000 --- a/.github/scripts/install.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -ev -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd ${SCRIPT_DIR}/../../source - -INSTALL_FILE="install_headless_with_trigger.sql" -if [[ ! -f "${INSTALL_FILE}" ]]; then - INSTALL_FILE="install_headless.sql" -fi - -#install core of utplsql -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL -whenever sqlerror exit failure rollback -set feedback off -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_FILE} $UT3_DEVELOP_SCHEMA $UT3_DEVELOP_SCHEMA_PASSWORD -SQL diff --git a/.github/scripts/install_utplsql_release.sh b/.github/scripts/install_utplsql_release.sh deleted file mode 100755 index e50718c7b..000000000 --- a/.github/scripts/install_utplsql_release.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -set -ev -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd ${SCRIPT_DIR}/../../${UTPLSQL_DIR}/source - -"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <>index.md - echo "layout: default" >>index.md - echo "---" >>index.md - echo "" >>index.md - echo "# Documentation versions" >>index.md - echo "" >>index.md - echo "" >>index.md #- 7th line - placeholder for latest release doc - echo "" >>index.md #- 8th line - placeholder for develop branch doc - echo "" >>index.md - echo "## Released Version Doc History" >>index.md - echo "" >>index.md -fi -#If build running on a TAG - it's a new release - need to add it to documentation -if [ "${GITHUB_REF_TYPE}" == "tag" ]; then - sed -i '7s@.*@'" - [Latest ${CI_ACTION_REF_NAME} documentation](latest/) - Created $now"'@' index.md - #add entry to the top of version history (line end of file - ## Released Version Doc History - sed -i '12i'" - [${CI_ACTION_REF_NAME} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md -fi -#replace 4th line in log -sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md -#Add and Commit the changes back to pages repo. -git add . -git commit -m "Deploy to gh-pages branch: base commit ${SHA}" -# Now that we're all set up, we can push. -git push --quiet origin HEAD:${GITHUB_IO_BRANCH} - diff --git a/.github/scripts/run_examples.sh b/.github/scripts/run_examples.sh deleted file mode 100755 index bfa4f7e1a..000000000 --- a/.github/scripts/run_examples.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -ev -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd ${SCRIPT_DIR}/../../examples - -"$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR <> $GITHUB_ENV -echo "UTPLSQL_VERSION=${version}" >> $GITHUB_ENV -echo UTPLSQL_BUILD_VERSION=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") >> $GITHUB_ENV - diff --git a/.github/scripts/set_version_numbers_env.sh b/.github/scripts/set_version_numbers_env.sh deleted file mode 100755 index c61639bf9..000000000 --- a/.github/scripts/set_version_numbers_env.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -build_no=$( expr ${GITHUB_RUN_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} ) -version=$(.github/scripts/get_project_version.sh) - -echo "UTPLSQL_BUILD_NO=${build_no}" >> $GITHUB_ENV -echo "UTPLSQL_VERSION=${version}" >> $GITHUB_ENV -echo UTPLSQL_BUILD_VERSION=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") >> $GITHUB_ENV diff --git a/.github/scripts/uninstall_validate_utplsql.sh b/.github/scripts/uninstall_validate_utplsql.sh deleted file mode 100755 index d0a2070a8..000000000 --- a/.github/scripts/uninstall_validate_utplsql.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -ev -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd ${SCRIPT_DIR}/../../source - -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL - set feedback off - set verify off - whenever sqlerror exit failure rollback - - @uninstall_all.sql $UT3_DEVELOP_SCHEMA -SQL -time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL - set feedback off - set verify off - whenever sqlerror exit failure rollback - set serverout on - begin - for i in ( - select o.object_type||' '||o.owner||'.'||o.object_name as obj - from dba_objects o - where owner = '$UT3_DEVELOP_SCHEMA' - union all - select 'SYNONYM '||s.owner||'.'||s.synonym_name||' FOR '||s.table_owner||'.'||s.table_name as obj - from dba_synonyms s - where table_owner = '$UT3_DEVELOP_SCHEMA' - ) loop - dbms_output.put_line(i.obj); - end loop; - end; - / - 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_DEVELOP_SCHEMA' - and 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_DEVELOP_SCHEMA' - and 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); - end if; - end; - / - drop user $UT3_DEVELOP_SCHEMA; -SQL diff --git a/.github/scripts/update_project_version.sh b/.github/scripts/update_project_version.sh deleted file mode 100755 index 66e45125a..000000000 --- a/.github/scripts/update_project_version.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -UTPLSQL_VERSION_PATTERN="v?([0-9]+\.){3}[0-9]+[^']*" - -echo Current branch is "${CI_ACTION_REF_NAME}" - -echo Update version in project source files -find source -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UTPLSQL_BUILD_VERSION}/" {} \; -echo Source files updated with version tag: ${UTPLSQL_BUILD_VERSION} - -echo Update version in documentation files -find docs -type f -name '*.md' -exec sed -i -r "s/(badge\/version-).*(-blue\.svg)/\1${UTPLSQL_BUILD_VERSION/-/--}\2/" {} \; - -echo Update of sonar-project.properties sonar.projectVersion -sed -i -r "s/(sonar\.projectVersion=).*?/\1${UTPLSQL_VERSION}/" sonar-project.properties - -echo Update VERSION file -echo ${UTPLSQL_VERSION} > VERSION -echo ${UTPLSQL_BUILD_NO} > BUILD_NO - diff --git a/.github/scripts/validate_report_files.sh b/.github/scripts/validate_report_files.sh deleted file mode 100755 index 722a9220a..000000000 --- a/.github/scripts/validate_report_files.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" - -GL_VALID=1 -XSD_DIR="${SCRIPT_DIR}/xsd" -XML_JAR_DIR="${SCRIPT_DIR}/lib" -#XML Validator -XML_VALIDATOR="$XML_JAR_DIR/xml_validator.jar" -HTML_VALIDATOR_URL="http://localhost:8888/" - -HTML_FILENAME="coverage.html" -declare -A XML_FILES -XML_FILES["junit_test_results.xml"]="junit4.xsd" -XML_FILES["tfs_test_results.xml"]="junit_windy.xsd" - -function ValidateHtml { - EXCLUSION_REGEX=".*Element\s.?ol.?\snot\sallowed\sas\schild\sof\selement\s.?pre.*" - #HTML Validation API - VALIDATOR_OUT="gnu" - WARNING_REGEX="info warning:" - ERROR_REGEX="error:" - #Validate HTML - HTML_VALIDATION_RESULTS=$(curl -H "Content-Type: text/html; charset=utf-8" --data-binary @$1 "$HTML_VALIDATOR_URL?out=$VALIDATOR_OUT&filterpattern=$EXCLUSION_REGEX") - - ERROR_COUNT=$(echo "$HTML_VALIDATION_RESULTS" | grep -c "$ERROR_REGEX") - WARNING_COUNT=$(echo "$HTML_VALIDATION_RESULTS" | grep -c "$WARNING_REGEX") - - if [ "$ERROR_COUNT" -gt 0 ]; then - GL_VALID=0 - echo "" - echo "******************************" - echo "HTML File is invalid" - echo "There are $ERROR_COUNT errors, $WARNING_COUNT warning in $HTML_FILENAME" - echo "Please see results:" - echo "$HTML_VALIDATION_RESULTS" | grep "$ERROR_REGEX" - fi -} - -function ValidateXML() { - echo "Validate File $2 against schema $1" - VALIDATION_RESULT=$(java -jar $XML_VALIDATOR -s $1 $2 2>&1) - - if [ $? -ne 0 ]; then - GL_VALID=0 - echo "" - echo "******************************" - echo "XML is invalid" - echo "Please see results:" - echo "$VALIDATION_RESULT" - fi -} - -ValidateHtml "$HTML_FILENAME" - -for XMLFILE in "${!XML_FILES[@]}"; do - #echo "$XMLFILE" "${XML_FILES[$XMLFILE]}"; - ValidateXML "$XSD_DIR/${XML_FILES[$XMLFILE]}" "$XMLFILE" -done - -if [ $GL_VALID -ne 1 ]; then - echo "" - echo "******************************" - echo "Validation failed please see results above." - exit 1 -else - exit 0 -fi diff --git a/.github/scripts/xsd/junit4.xsd b/.github/scripts/xsd/junit4.xsd deleted file mode 100644 index 1142fb28d..000000000 --- a/.github/scripts/xsd/junit4.xsd +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.github/scripts/xsd/junit_windy.xsd b/.github/scripts/xsd/junit_windy.xsd deleted file mode 100644 index 320779edd..000000000 --- a/.github/scripts/xsd/junit_windy.xsd +++ /dev/null @@ -1,212 +0,0 @@ - - - - JUnit test result schema for the Apache Ant JUnit and JUnitReport tasks -Copyright Β© 2011, Windy Road Technology Pty. Limited -The Apache Ant JUnit XML Schema is distributed under the terms of the Apache License Version 2.0 http://www.apache.org/licenses/ -Permission to waive conditions of this license may be requested from Windy Road Support (http://windyroad.org/support). - - - - - - - - - - Contains an aggregation of testsuite results - - - - - - - - - - Derived from testsuite/@name in the non-aggregated documents - - - - - Starts at '0' for the first testsuite and is incremented by 1 for each following testsuite - - - - - - - - - - - - Contains the results of exexuting a testsuite - - - - - Properties (e.g., environment settings) set during test execution - - - - - - - - - - - - - - - - - - - - - - - - - Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace - - - - - - - The error message. e.g., if a java exception is thrown, the return value of getMessage() - - - - - The type of error that occured. e.g., if a java execption is thrown the full class name of the exception. - - - - - - - - - Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace - - - - - - - The message specified in the assert - - - - - The type of the assert. - - - - - - - - - - Name of the test method - - - - - Full class name for the class the test method is in. - - - - - Time taken (in seconds) to execute the test - - - - - - - Data that was written to standard out while the test was executed - - - - - - - - - - Data that was written to standard error while the test was executed - - - - - - - - - - - Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents - - - - - - - - - - when the test was executed. Timezone may not be specified. - - - - - Host on which the tests were executed. 'localhost' should be used if the hostname cannot be determined. - - - - - - - - - - The total number of tests in the suite - - - - - The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals - - - - - The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. - - - - - The total number of ignored or skipped tests in the suite. - - - - - Time taken (in seconds) to execute the tests in the suite - - - - - - - - - \ No newline at end of file diff --git a/.github/variables/.env b/.github/variables/.env deleted file mode 100644 index 7bb5003e8..000000000 --- a/.github/variables/.env +++ /dev/null @@ -1,27 +0,0 @@ -#utPLSQL install env -UT3_DEVELOP_SCHEMA=UT3_DEVELOP -UT3_DEVELOP_SCHEMA_PASSWORD=ut3 -UT3_RELEASE_VERSION_SCHEMA=UT3 -UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3 -UT3_TABLESPACE=users - -# Database Env -SQLCLI="sqlplus" -OJDBC_HOME=ojdbc -OJDBC_URL="https://download.oracle.com/otn-pub/otn_software/jdbc/213" -ORACLE_PWD="oracle" -TZ="Europe/London" - -#Build env -UTPLSQL_CLI_VERSION="3.1.8" -UTPLSQL_DIR="utPLSQL_latest_release" -UTPLSQL_BUILD_NO_OFFSET=3563 - -#Git configuration -GIT_AUTHOR_NAME="github-actions[bot]" -GIT_AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com" -GIT_COMMITTER_NAME="github-actions[bot]" -GIT_COMMITTER_EMAIL="github-actions[bot]@users.noreply.github.com" - -#Docker environment for running utPLSQL install commands -DOCKER_ENV="-e SQLCLI=sqlplus -e UT3_DEVELOP_SCHEMA -e UT3_DEVELOP_SCHEMA_PASSWORD -e UT3_RELEASE_VERSION_SCHEMA -e UT3_RELEASE_VERSION_SCHEMA_PASSWORD -e UT3_TABLESPACE -e ORACLE_PWD -e CONNECTION_STR -e UTPLSQL_DIR" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index be6e18ca2..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,292 +0,0 @@ -name: Build, test, deploy documentation -on: - push: - branches-ignore: [ main ] - pull_request: - branches: [ develop ] - - workflow_dispatch: - -concurrency: ${{github.ref}} -defaults: - run: - shell: bash - -jobs: - - build: - name: Build and test on ${{matrix.db_version_name}} DB - runs-on: ubuntu-latest - timeout-minutes: 90 - env: - ORACLE_VERSION: ${{matrix.oracle-version}} - ORACLE_SID: ${{matrix.oracle-sid}} - CONNECTION_STR: ${{ format( '127.0.0.1:1521/{0}', matrix.oracle-sid ) }} - ORACLE_PASSWORD: oracle - DOCKER_VOLUME: ${{matrix.docker-volume}} - strategy: - fail-fast: false - matrix: - include: - - id: 1 - db_version_name: '19se' - oracle-sid: 'ORCLCDB' - oracle-version: "utplsqlv3/oracledb:19c-se2-small" - - id: 2 - db_version_name: '21XE' - oracle-sid: 'XE' - oracle-version: "gvenzl/oracle-xe:21-slim-faststart" - - id: 3 - db_version_name: '23-free' - oracle-sid: 'FREEPDB1' - oracle-version: "gvenzl/oracle-free:23-slim-faststart" - services: - html_checker: - image: ghcr.io/validator/validator:latest - options: >- - -p 8888:8888 - oracle: - image: ${{matrix.oracle-version}} - env: - ORACLE_PASSWORD: oracle - credentials: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} - volumes: - - ${{github.workspace}}:/utPLSQL - ports: - - 1521:1521 - options: >- - --health-interval 10s - --health-timeout 5s - --health-retries 10 - --name oracle - --health-cmd healthcheck.sh - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: c-py/action-dotenv-to-setenv@v5 - with: - env-file: .github/variables/.env - - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action - - - name: Set build version number env variables - id: set-build-version-number-vars - run: .github/scripts/set_version_numbers_env.sh - - - name: Update project version & build number to verify that code is deployable after the update - id: update-project-version - run: .github/scripts/update_project_version.sh - - - name: Download utPLSQL release for testing -# For PR build - test using target branch as framework, for branch build use self as testing framework - run: git clone --depth=1 --branch=${CI_BASE_REF:-$CI_REF_NAME} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR - - - name: Update privileges on sources - run: chmod -R go+w ./{source,test,examples,${UTPLSQL_DIR}/source} - - - name: Cache OJDBC jars - id: cache-ojdbc - uses: actions/cache@v4 - with: - path: ${{ env.OJDBC_HOME }} - key: ${{ runner.os }}-ojdbc-${{ env.OJDBC_URL }}-v1 - - - name: Add OJDBC home - if: steps.cache-ojdbc.outputs.cache-hit != 'true' - id: get-ojdbc - run: mkdir -p ${OJDBC_HOME} && curl -Lk -o ${OJDBC_HOME}/ojdbc8.jar ${OJDBC_URL}/ojdbc8.jar && curl -Lk -o ${OJDBC_HOME}/orai18n.jar ${OJDBC_URL}/orai18n.jar - - - name: Cache utPLSQL-cli - id: cache-utplsql-cli - uses: actions/cache@v4 - with: - path: utPLSQL-cli - key: ${{ runner.os }}-utplsql-cli-v3.1.8 - - - name: Install utPLSQL-cli - if: steps.cache-utplsql-cli.outputs.cache-hit != 'true' - id: install-utplsql-cli - run: curl -Lk -o utPLSQL-cli.zip "https://github.com/utPLSQL/utPLSQL-cli/releases/download/3.1.9/utPLSQL-cli.zip" && unzip utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli - - - name: Install utPLSQL - id: install-utplsql - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh - - - name: Check code style - if: ${{ matrix.id == 1 }} - id: check-coding-style - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle "$SQLCLI" ${UT3_DEVELOP_SCHEMA}/${UT3_DEVELOP_SCHEMA_PASSWORD}@//${CONNECTION_STR} @/utPLSQL/development/utplsql_style_check.sql - - - name: Validate utPLSQL uninstall - if: ${{ matrix.id == 1 }} - id: validate-uninstall - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/uninstall_validate_utplsql.sh - - - name: Reinstall utPLSQL - if: ${{ matrix.id == 1 }} - id: reinstall-utplsql - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh - - - name: Create test users - id: create-test-users - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/create_test_users.sh - - - name: Install utPLSQL release - id: install-utplsql-release - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install_utplsql_release.sh - - - name: Run Examples - id: run-examples - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/run_examples.sh - - - name: Install tests - id: install-tests - run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle test/install_tests.sh - - - name: Run Tests - id: run-tests - run: test/run_tests.sh - -#Start Needed to diagnose occasional failures of DB on test runs - - name: Prepare diagnostic directory - id: preapre-oracle-diag-dir - if: ${{ always() && steps.run-tests.outcome == 'failure' }} - run: | - mkdir database-diag - chmod +777 database-diag - - name: Get ORACLE_BASE/diag data - id: get-oracle-diag-data - if: ${{ always() && steps.run-tests.outcome == 'failure' }} - run: docker exec oracle bash -c "chmod -R +777 ./diag && cp -r ./diag /utPLSQL/database-diag" - - name: Upload ORACLE_BASE/diag data Artifact - id: upload - if: ${{ always() && steps.run-tests.outcome == 'failure' }} - uses: actions/upload-artifact@v4 - with: - name: my-artifact$-${{matrix.db_version_name}} - path: ${{github.workspace}}/database-diag -#End Needed to diagnose occasional failures of DB on test runs - - - name: Validate utPLSQL reports format - id: validate-reports-format - run: bash .github/scripts/validate_report_files.sh - - - name: Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - files: ./cobertura.xml - flags: ${{matrix.db_version_name}} - fail_ci_if_error: true # optional (default = false) - - - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - files: junit_test_results.xml - - - name: SonarCloud Scan - id: sonar - if: ${{ always() && matrix.db_version_name == '23-free' }} - uses: SonarSource/sonarqube-scan-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: > - -Dsonar.buildString=${{ format( '{0}.{1}', env.UTPLSQL_BUILD_VERSION, matrix.id ) }} - -Dsonar.plsql.jdbc.url=${{ format( 'jdbc:oracle:thin:@//localhost:1521/{0}', env.ORACLE_SID ) }} - -Dsonar.plsql.jdbc.driver.path=${{ format( '{0}/ojdbc8.jar', env.OJDBC_HOME ) }} - - publish: - name: Deploy documentation - needs: [ build ] - concurrency: publish - runs-on: ubuntu-latest - timeout-minutes: 30 - env: - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} - if: | - github.repository == 'utPLSQL/utPLSQL' && - github.base_ref == null && github.ref == 'refs/heads/develop' - steps: - - name: πŸ” API_TOKEN_GITHUB - if: env.API_TOKEN_GITHUB == '' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: echo "API_TOKEN_GITHUB=${GITHUB_TOKEN}" >> $GITHUB_ENV - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ env.API_TOKEN_GITHUB }} - - uses: c-py/action-dotenv-to-setenv@v5 - with: - env-file: .github/variables/.env - - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action - - - name: Set buid version number env variables - id: set-build-version-number-vars - run: .github/scripts/set_version_numbers_env.sh - - - name: Update project version & build number in source code and documentation - id: update-project-version - run: .github/scripts/update_project_version.sh - - - name: Push version update to repository - id: push-version-number-update - run: | - git add sonar-project.properties VERSION BUILD_NO source/* docs/* - git commit -m 'Updated project version after build [skip ci]' - git push --quiet origin HEAD:${CI_ACTION_REF_NAME} - - - name: Setup git config - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - - name: Build and publish documentation - run: | - pip install mkdocs - pip install mkdocs-git-revision-date-localized-plugin - pip install mkdocs-material - pip install git+https://github.com/jimporter/mike.git - mike deploy -p develop - - dispatch: - name: Dispatch downstream builds - concurrency: trigger - needs: [ build, publish ] - runs-on: ubuntu-latest - timeout-minutes: 15 - if: | - github.repository == 'utPLSQL/utPLSQL' && github.base_ref == null && - ( startsWith( github.ref, 'refs/heads/release/v' ) || github.ref == 'refs/heads/develop' ) - strategy: - matrix: - repo: [ 'utPLSQL/utPLSQL-demo-project', 'utPLSQL/utPLSQL-java-api' ] -# repo: [ 'utPLSQL/utPLSQL-v2-v3-migration' ] - steps: - - name: Repository Dispatch - uses: peter-evans/repository-dispatch@v4 - with: - token: ${{ secrets.API_TOKEN_GITHUB }} - repository: ${{ matrix.repo }} - event-type: utPLSQL-build - - slack-workflow-status: - if: always() - name: Post Workflow Status To Slack - needs: [ build, publish, dispatch ] - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Slack Workflow Notification - uses: Gamesight/slack-workflow-status@master - with: - repo_token: ${{secrets.GITHUB_TOKEN}} - slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} - name: 'Github Actions[bot]' - icon_url: 'https://octodex.github.com/images/mona-the-rivetertocat.png' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ab043b6eb..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Create and publish release artifacts -on: - release: - types: [ released ] -#See: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-using-multiple-events-with-activity-types-or-configuration - -defaults: - run: - shell: bash - -jobs: - - upload_artifacts: - name: Upload archives - concurrency: upload - runs-on: ubuntu-latest - timeout-minutes: 60 - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: c-py/action-dotenv-to-setenv@v5 - with: - env-file: .github/variables/.env - - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action - - - name: Set build version number env variables - run: .github/scripts/set_release_version_numbers_env.sh - - - name: Update project version & build number in source code and documentation - run: .github/scripts/update_project_version.sh - - - name: Setup git config - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - - name: Build and publish documentation - run: | - pip install mkdocs - pip install mkdocs-git-revision-date-localized-plugin - pip install mkdocs-material - pip install git+https://github.com/jimporter/mike.git - mike deploy -p -u ${UTPLSQL_VERSION} latest - mkdocs build --clean -f mkdocs_offline.yml - rm -rf docs/* - cp -r -v site/* docs - git add . - git commit -m "tmp commit of HTML documentation for building a release archive" - - - name: Build release archives - run: | - git archive --prefix=utPLSQL/ -o utPLSQL.zip --format=zip HEAD - git archive --prefix=utPLSQL/ -o utPLSQL.tar.gz --format=tar.gz HEAD - md5sum utPLSQL.zip --tag > utPLSQL.zip.md5 - md5sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.md5 - - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: | - utPLSQL.zip - utPLSQL.zip.md5 - utPLSQL.tar.gz - utPLSQL.tar.gz.md5 - - slack-workflow-status: - if: always() - name: Post Workflow Status To Slack - needs: [ upload_artifacts ] - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Slack Workflow Notification - uses: Gamesight/slack-workflow-status@master - with: - repo_token: ${{secrets.GITHUB_TOKEN}} - slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} - name: 'Github Actions[bot]' - icon_url: 'https://octodex.github.com/images/mona-the-rivetertocat.png' - diff --git a/.gitignore b/.gitignore index be442d164..c0bc599b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,5 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 -# User-specific stuff: -.idea/ -.vscode/ -.sonar/ -site/ -pages/ -release/ -*.gz -*.zip -node_modules/ -utPLSQL_latest_release/ -utPLSQL-cli/ -development/env.sh -development/*.jar -*.log +documentation/ +!documentation/src -# exclusions based on artifacts created via actions documented in CONTRIBUTING.md -test/dummy.sql -coverage.html_assets/ -coverage.html -coverage.json -coverage.xml -tfs_test_results.xml -junit_test_results.xml -test_results.xml -*debug*.xml -cobertura.xml +build/*.zip +build/release* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29bb..000000000 diff --git a/BUILD_NO b/BUILD_NO deleted file mode 100644 index 2bfcb2370..000000000 --- a/BUILD_NO +++ /dev/null @@ -1 +0,0 @@ -4342 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index b90e5e80e..000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at utplsql@utplsql.org. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3cac5c86f..0159e8c0c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,186 +1,33 @@ -# How to contribute +## How to contribute ## -The following are the guidelines everyone should use to contribute to utPLSQL. -Changes are welcome from all members of the Community. +The following are the guidelines, everyone should use to contribute to utPLSQL. +Changes are welcome from all members of the Community. -# Getting Started +## Getting Started ## 1. Create a [GitHub Account](https://github.com/join). -2. Fork the utPLSQL Repository and setup your local Repository. _See [how to Fork](https://help.github.com/articles/fork-a-repo) article_ - * Each of the steps below are detailed in **Get started with development** section. +2. Fork the utPLSQL Repository and setup your local Repository. + * Each of the steps below are detailed in the [How to Fork](https://help.github.com/articles/fork-a-repo) article! * Clone your Fork to your local machine. - * Configure "upstream" remote to the [utPLSQL repository](https://github.com/utPLSQL/utPLSQL.git). -3. For each change you want to make: - * Make sure your forked repository is up to date with upstream before you start coding. See [syncing your local repository](https://help.github.com/articles/syncing-a-fork) with upstream utPLSQL repository. - * Create a new branch for your change. We use `feature/feature_name` or `bugfix/fixed_issue_name` to identify branch types. - * Make your change in your new branch. - * Make sure your change is covered with unit tests. - * **Verify code compiles and all existing and new unit tests pass.** - * The quickest way to have a Pull Request not approved, is to submit code that does not compile or pass tests. + * Configure "upstream" remote to the [master utPLSQL repository](https://github.com/utPLSQL/utPLSQL.git). +3. For each change you want to make: + * Create a new branch for your change. + * Make your change in your new branch. + * Although changes can be made in the master branch, it easier long term if a new branch is used. + * **Verify code compiles and unit tests still pass.** + * The quickest way to have a Pull Request not be accepted, is to submit code that does not compile or pass tests. * Commit change to your local repository. - * Push change to your remote repository. - * Submit a [Pull Request](https://help.github.com/articles/using-pull-requests) into develop branch. - * Note: local and remote branches can be deleted after pull request has been merged. + * Push change to your remote repository + * Submit a [Pull Request](https://help.github.com/articles/using-pull-requests). + * Note: local and remote branches can be deleted after pull request has been accepted. -# Coding Standards +**Note:** Getting changes from others requires [Syncing your Local repository](https://help.github.com/articles/syncing-a-fork) with Master utPLSQL repository. This can happen at any time. -* We use snake case for all identifiers in PLSQL code. This separates keywords in names with underscores. `execute_test` -* All code is lower case. -* Prefixes: - * Arguments to procedures and functions will start with `a_`, an Example would be procedure `is_valid(a_owner_name varchar2)` - * Object types and packages will start with `ut_` - * Local variables `l_` - * Global variables `g_` - * Global Constants start with `gc_` - * Types in packages, objects start with `t_` - * Nested Tables start with `tt_` -* varchar2 lengths are set in characters not bytes - - -# Configuring local environment - -Your local environment can be of any flavor (Unix/Linux/Windows/Mac). -At minimum, you need to have Oracle database 19c accessible for the project and SYS account access to install and develop utPLSQL. - -We use four different database accounts (users) for development process. -* `ut3` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development. -* `ut3_develop` - holds the version of utPLSQL of your current branch. This is the schema you will be working on. -* `ut3_tester` - holds unit test packages for development of utPLSQL. -* `ut3_user` - used for testing accessibility to schema names with special characters. -* `ut3_tester_helper` - elevated privileges user, used for creating and dropping objects in other schemas during test run. - - - -## Get started with development - -To get started with development, follow the below steps. - -_If you're using Windows, run the shell scripts using `GIT bash` - Windows-based bash command line._ - -**Caution**: If you are using jetBrains DataGrip, don't use the integrated console to run the shell scripts (not even with GIT bash configured). It might disconnect from oracle randomly during script-run. - -### Clone your fork of utPLSQL git repository - -```bash -# clone your fork of utPLSQL -git clone https://github.com/your account/utPLSQL.git utPLSQL - -cd utPLSQL - -# add main project repo as upstream -git remote add upstream https://github.com/utPLSQL/utPLSQL.git - -# fetch all remote repositories -git fetch --all -``` - -### Prepare environment script - -Copy the environment variables template `development/template.env.sh` to `development/env.sh` -```bash -cp development/template.env.sh development/env.sh -chmod u+w development/env.sh -``` - -You might have to adjust the following lines in `development/env.sh`: -```bash -export SQLCLI=sql # For sqlcl client -#export SQLCLI=sqlplus # For sqlplus client -export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string -export ORACLE_PWD=oracle # Adjust your local SYS password -``` - -### Download utPLSQL release sources and utplsq-cli - -The below script is fetching latest release version from utPLSQL repository. Latest release version is used for self-testing. -```bash -./development/refresh_sources.sh -``` - -### Setup local database for utPLSQL development - -```bash -./development/install.sh -``` - -### That's it - -You now have the following: -- sources from `develop` branch of your fork of utPLSQL repository in `utPLSQL/ut3_latest_release` directory -- sources from `main` branch of utPLSQL/utPLSQL repository in `utPLSQL/ut3_latest_release` directory -- binaries of `utplsql-cli` in `utPLSQL/utPLSQL-cli` directory -- database users created -- your current branch of utPLSQL deployed into `ut3` schema -- utPLSQL released version deployed to `ut3_latest_release` - -At any time, if you need to refresh your database, the below scripts might be helpful. - -## Cleanup of utPLSQL installation in local database - -```bash -development/cleanup.sh -``` - -## Reinstalling utPLSQL development in `ut3` schema - -```bash -development/refresh_ut3.sh -``` - -## Refreshing after release - -Whenever a new version of utPLSQL or a new version of utPLSQL-cli is available, use `development/refresh_sources.sh` to refresh files in your local project folders. - -## Running unit tests - -utPLSQL v3 unit tests are located in the `test` directory - -Before you push any changes and create a pull request to the utPLSQL project repository, make sure that all the tests are executing successfully in your local environment. - -Every new functionality needs to be documented by unit tests that cover happy-path scenarios as well as edge-cases and exception paths. - -> **Important notice:** -> We do our best to keep utPLSQL covered with unit tests. -> Lack of sufficient unit testing is a perfect reason for PR to be rejected. - -To run a full suite of unit tests execute: -```bash -. ./development/env.sh -./test/install_and_run_tests.sh -``` - -You can review the results of tests as well as see information about code coverage in `./coverage.html` file. - - -## Modules - -Below diagram gives a high-level overview of utPLSQL v3 modules and their dependencies. -Dependencies to `ut_util` are not shown as most of modules are depending on it. - -![utPLSQL V3 Modules](development/utPSLQLv3-modules.png) - - -## Build Environment - -We are using a combination of private and publicly available docker images to test utPLSQL. The following versions of Oracle Database are used for testing: - -* 19c-Standard Edition (private image) -* 21-free -* 23-free - -The Free varsions are publicly available and you can set up your local development environment to use one of from [here](https://github.com/gvenzl/oci-oracle-free) - -These [private image]((https://github.com/utPLSQL/docker-scripts) is a slimmed version of [the official Oracle database dockerfiles](https://github.com/oracle/docker-images/tree/master/OracleDatabase) . Due to licensing restrictions, the image cannot be public. - -You can build your own and use it locally, or push to a private docker repository. -The build steps are simple if you already have some experience using Docker. You can find detailed information about how to build your own image with a running database in: [example of creating an image with pre-built DB](https://github.com/oracle/docker-images/blob/master/OracleDatabase/samples/prebuiltdb/README.md) - -> If you are new to Docker, you can start by reading the [Getting Started With Docker](https://docs.docker.com/get-started/) docs. - -## New to GIT +## New to GIT ## If you are new to GIT here are some links to help you with understanding how it works. - [GIT Documentation](http://git-scm.com/doc) - [Atlassian Git Tutorial](https://www.atlassian.com/git/tutorial/git-basics) -- [What are other resources for learning Git and GitHub](https://help.github.com/articles/what-are-other-good-resources-for-learning-git-and-github) +- [What are other resources for learning Git and GitHub](https://help.github.com/articles/what-are-other-good-resources-for-learning-git-and-github) + diff --git a/LICENSE b/LICENSE index 640d46628..8f5b408d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,281 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - 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. + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 + Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md new file mode 100644 index 000000000..ea5668dd6 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +## Welcome to utPLSQL, the unit testing framework for PL/SQL ## + +utPLSQL is a Unit Testing framework for Oracle PL/SQL. + +It is not warranted to be free of bugs. + +Use it at your own risk (but, believe me, there's nothing very risky about it). + +### To Install + + 1. Unzip the software into the directory of your choice. It will create three sub-directories: Code, Examples and Doc. + + 2. Open the Doc/index.html file and follow instructions in the Getting Started document for either installing or upgrading utPLSQL. + +### To Use + +Review the on-line documentation. Start with Getting Started, then check out Build Test Packages and dip into the User Guide as needed. + +Any questions? Go to the utPLSQL contributing page where you will find all the various ways to work with members of project development team. + +https://utplsql.github.io/contributing/ + +and let us know about it. + + +Copyright (c) 2000-2005, 2014-2016 Steven Feuerstein and the utPLSQL Project +https://utplsql.github.io/ diff --git a/VERSION b/VERSION deleted file mode 100644 index 5fcdcb942..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -v3.1.14-develop diff --git a/build/build.pl b/build/build.pl new file mode 100644 index 000000000..873e9b208 --- /dev/null +++ b/build/build.pl @@ -0,0 +1,297 @@ +#!/usr/bin/perl -w +# ************************************************************************ +# GNU General Public License for utPLSQL +# +# Copyright (C) 2014 +# Steven Feuerstein and the utPLSQL Project +# (steven@stevenfeuerstein.com) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program (see license.txt); if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# ************************************************************************ +# +# This perl script can do the following +# 1. Call the build_docs.pl to generate the documentation. +# 2. Create ZIP File for Release +# - Creates a "release" directory underneath the current directory. +# - Copies all the files for a release into this new directory. +# - Creates a zip file (the file that gets released) with the correct name. +# 3. Commit/Push the latest documentation to the utPLSQL.github.io repository. +# +# Please see for +# the Release Procedure. +# + +use strict; +use warnings; +use 5.010; + + +use Cwd; +use Cwd 'abs_path'; +use File::Spec; +use File::Copy; +use File::Copy::Recursive qw(dircopy); +use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); +say "---------------------------------------------------------------"; +say " NOTE: Requires GIT SSH Keys to be setup to Update Web Docs."; +say "---------------------------------------------------------------"; +say "Which build option do you require:"; +say " 1) Create release "; +say " - Update Docs, Create Zip"; +say " 2) Create release and update website "; +say " - Update Docs,Create Zip,Update Web Docs"; +say " 3) Build and Update the website documentation without release"; +say " - Update Docs,Update Web Docs"; +say "---------------------------------------------------------------"; +print "Please make selection: "; +my $selection = <>; +chop $selection; + +if ($selection eq 1) { regenerate_docs(); + create_zip_release();} +elsif ($selection eq 2) { regenerate_docs(); + create_zip_release(); + update_website();} +elsif ($selection eq 3) { regenerate_docs(); + update_website(); } +else { die "Invalid selection - exiting \n"; } + +sub version_number { + state $version; + my $confirmed; + + if (!defined $version) { + print "What is the new version number? "; + $version = <>; + chomp $version; + print "Please confirm new version number: [$version] (Y/N)? "; + $confirmed = <>; + + chomp $confirmed; + + if (!($confirmed eq "Y" || $confirmed eq "y")) { + die "Not confirmed - aborting \n"; + } + } + + return $version; +} + + +sub release_dir { + return "release-" . version_number(); +} + + +sub release_code_dir { + return release_dir() . "/code"; +} + + +sub release_doc_dir { + return release_dir() . "/doc"; +} + +sub release_examples_dir { + return release_dir() . "/examples"; +} + + +sub create_release_directories { + make_dir(release_dir()); + make_dir(release_code_dir()); + make_dir(release_doc_dir()); + make_dir(release_examples_dir()); +} + + +sub make_dir { + my($dir) = @_; + unless(mkdir $dir) { + die "Unable to create $dir - aborting \n"; + } +} + + +sub populate_release_directories { + create_release_directories(); + populate_code_directory(); + populate_doc_directory(); + populate_examples_directory(); + copy ("../readme.md", release_dir()); +} + + +sub populate_code_directory { + dircopy ("../source", release_code_dir()); +} + + +sub populate_doc_directory{ + dircopy ("../documentation/output", release_doc_dir()); +} + + +sub populate_examples_directory{ + dircopy ("../examples", release_examples_dir()); +} + + +sub zip_filename { + my $zipname = "utplsql-" . version_number() ; + $zipname =~ s/[\.]/-/g; + $zipname .= ".zip"; +} + + +sub create_zip_release { + populate_release_directories(); + my $zip = Archive::Zip->new(); + + # Add a directory + my $dir_member = $zip->addTree(release_dir()); + + + unless ( $zip->writeToFileNamed(zip_filename()) == AZ_OK ) { + die "Error creating zip file " . zip_filename() . " \n"; + } +} + + +sub upload_release { +#Left here not used, but could be readded if desired later. + my $confirmed; + + print "Please confirm you wish to upload this release: [".version_number()."] (Y/N)? "; + $confirmed = <>; + chomp $confirmed; + + if (!($confirmed eq "Y" || $confirmed eq "y")) { + die "Not confirmed - aborting \n"; + } + + create_zip_release(); +# upload_zip(); + +} + + +sub regenerate_docs { +# Change working directory so that build_docs.pl can find the files. + my $orig_dir = cwd; + chdir '../documentation/src/'; + system 'build_docs.pl'; + chdir $orig_dir; +} + + +sub confirm_update_docs { + my $confirmed; + print "Please confirm you wish to update documentation on web: (Y/N)? "; + $confirmed = <>; + chomp $confirmed; + my $result = 0; + if (($confirmed eq "Y" || $confirmed eq "y")) { + $result = 1; + } + return $result; +} +sub setup_repo { + if (!(-d '.git')) { + system 'git clone git@github.com:utPLSQL/utPLSQL.github.io.git .'; + } + system 'git checkout master'; + system 'git pull'; +} +sub copy_docs{ + my $builddir = $_[0]; + my $repodir = $_[1]; + my @bdirs = File::Spec->splitdir($builddir); + pop @bdirs; + my @rdirs = File::Spec->splitdir($repodir); + my $doc_output = File::Spec->catdir(@bdirs,'documentation','output'); + my $doc_repo = File::Spec->catdir(@rdirs,'docs'); + dircopy ($doc_output, $doc_repo); +} + +sub add_and_commit{ + system 'git add .'; + my $output = qx/git status --porcelain/; + my $result = 0; + if ($output ne '') { + system 'git commit -m "Automated Doc Refresh from utPLSQL repo"'; + $result = 1; + } + return $result; +} + + +sub push_changes{ + system 'git push'; +} + +sub update_website { + + my $website_repo = ask_for_website_repo(); + my $orig_cwd = cwd; + + if (!(-d $website_repo)) { + make_dir $website_repo; + } + my $abs_website = abs_path($website_repo); + + chdir $website_repo; + + setup_repo(); + copy_docs($orig_cwd,$abs_website); + if (add_and_commit($abs_website) == 0){ + say "No Doc changes to commit and push." + } + else { + if (confirm_update_docs() == 1) { + push_changes(); + } + } + cwd $orig_cwd; +} + + +sub username { + state $username; + + if (!defined $username) { + print "Please enter your Sourceforge username: "; + $username = <>; + chomp $username; + } + + return $username; +} + +sub ask_for_website_repo { + my $web_repo_path; + + say 'Please enter local working copy location of utPLSQL.github.io repository '; + say ' Press "Enter" for defaults of "../../utPLSQL.github.io" '; + $web_repo_path = <>; + + chomp $web_repo_path; + + if ($web_repo_path eq "") { + $web_repo_path = "../../utPLSQL.github.io"; + } + + return $web_repo_path; +} diff --git a/development/PLSQL beautifier rules.br b/development/PLSQL beautifier rules.br deleted file mode 100644 index 883a8a257..000000000 --- a/development/PLSQL beautifier rules.br +++ /dev/null @@ -1,54 +0,0 @@ -Version=1 -RightMargin=120 -Indent=2 -UseTabCharacter=FALSE -TabCharacterSize=2 -AlignDeclarationGroups=TRUE -AlignAssignmentGroups=TRUE -KeywordCase=2 -IdentifierCase=2 -UseSpecialCase=TRUE -ItemList.Format=1 -ItemList.Align=TRUE -ItemList.CommaAfter=FALSE -ItemList.AtLeftMargin=FALSE -EmptyLines=1 -ThenOnNewLine=FALSE -LoopOnNewLine=FALSE -DML.LeftAlignKeywords=FALSE -DML.LeftAlignItems=TRUE -DML.OnOneLineIfPossible=TRUE -DML.WhereSplitAndOr=TRUE -DML.WhereAndOrAfterExpression=FALSE -DML.WhereAndOrUnderWhere=TRUE -DML.JoinSplitBeforeOn=TRUE -DML.InsertItemList.Format=1 -DML.InsertItemList.Align=FALSE -DML.InsertItemList.CommaAfter=FALSE -DML.InsertItemList.AtLeftMargin=FALSE -DML.SelectItemList.Format=2 -DML.SelectItemList.Align=TRUE -DML.SelectItemList.CommaAfter=FALSE -DML.SelectItemList.AtLeftMargin=FALSE -DML.UpdateItemList.Format=2 -DML.UpdateItemList.Align=TRUE -DML.UpdateItemList.CommaAfter=FALSE -DML.UpdateItemList.AtLeftMargin=FALSE -ParameterDeclarationList.Format=0 -ParameterDeclarationList.Align=TRUE -ParameterDeclarationList.CommaAfter=FALSE -ParameterDeclarationList.AtLeftMargin=FALSE -RecordFieldList.Format=1 -RecordFieldList.Align=TRUE -RecordFieldList.CommaAfter=FALSE -RecordFieldList.AtLeftMargin=FALSE -SplitAndOr=FALSE -AndOrAfterExpression=FALSE -[SpecialCase] -ADD_MONTHS -CEIL -FLOOR -JSON -JSON_LIST -MONTHS_BETWEEN -ROUND diff --git a/development/cleanup.sh b/development/cleanup.sh deleted file mode 100755 index 65f3ab0c1..000000000 --- a/development/cleanup.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" - -. ./development/env.sh - -"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL -set echo on -begin - for x in ( - select * from dba_objects - where owner in ( upper('${UT3_RELEASE_VERSION_SCHEMA}'), upper('${UT3_DEVELOP_SCHEMA}') ) - and object_name like 'SYS_PLSQL%') - loop - execute immediate 'drop type '||x.owner||'.'||x.object_name||' force'; - end loop; -end; -/ - -drop user ${UT3_DEVELOP_SCHEMA} cascade; -drop user ${UT3_RELEASE_VERSION_SCHEMA} cascade; -drop user ut3_tester cascade; -drop user ut3_tester_helper cascade; -drop user ut3_user cascade; -drop user ut3_cache_test_owner cascade; -drop user ut3_no_extra_priv_user cascade; -drop user ut3_select_catalog_user cascade; -drop user ut3_select_any_table_user cascade; -drop user ut3_execute_any_proc_user cascade; - -begin - for i in ( - select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'"' drop_orphaned_synonym, owner||'.'||synonym_name syn from dba_synonyms a - where not exists (select 1 from dba_objects b where (a.table_name=b.object_name and a.table_owner=b.owner or b.owner='SYS' and a.table_owner=b.object_name) ) - and a.table_owner not in ('SYS','SYSTEM') - ) loop - execute immediate i.drop_orphaned_synonym; - dbms_output.put_line('synonym '||i.syn||' dropped'); - end loop; -end; -/ -exit -SQL diff --git a/development/install.sh b/development/install.sh deleted file mode 100755 index 468bafd38..000000000 --- a/development/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" - -. ./development/env.sh - -header="******************************************************************************************" -if ! development/cleanup.sh; then - echo -e ${header}"\nFailed to cleanup utPLSQL environment\n"${header} - exit 1 -fi -if ! .github/scripts/install.sh; then - echo -e ${header}"\nFailed to install utPLSQL from current branch into ${UT3_DEVELOP_SCHEMA} schema\n"${header} - exit 1 -fi -if ! .github/scripts/create_test_users.sh; then - echo -e ${header}"\nFailed to create test users from current branch\n"${header} - exit 1 -fi -if ! .github/scripts/install_utplsql_release.sh; then - echo -e ${header}"\nFailed to install utPLSQL from branch ${SELFTESTING_BRANCH} into ${UT3_RELEASE_VERSION_SCHEMA}\n"${header} - exit 1 -fi diff --git a/development/mystats/README.md b/development/mystats/README.md deleted file mode 100644 index c012220a6..000000000 --- a/development/mystats/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# MYSTATS - -## 1.0 Introduction -This repository contains two versions of the MyStats utility. This reports on the resource usage between two snapshots in an active database session. It is a combination of Jonathan Lewis's SNAP_MY_STATS package and my own re-factoring of Tom Kyte's runstats utility (also available via www.oracle-developer.net or github.com/oracle-developer/runstats). I've also added some functionality and flexibility around the statistics reporting section. - -## 2.0 Versions -There are two versions provided. - -### 2.1 mystats_pkg.sql -This creates via a single PL/SQL package named MYSTATS_PKG. This uses invoker rights and dynamic SQL to workaround the common issue whereby developers are not given explicit grants on the required V$ views but have V$ access via a role. See the comments in the package header for more details and usage instructions. - -### 2.2 mystats.sql -This version is a standalone SQL*Plus script that runs MyStats from your SQLPATH without the need to create any database objects. This can be used if you are not able to create the PL/SQL package version of MyStats. See the comments in the script header for more details and usage instructions. - -## 3.0 Version History -``` -Version Date Description --------- --------------- ---------------------------------------------- -1.0 June 2007 Original version -1.1 January 2009 Added extended reporting options -2.0 October 2011 Re-design for standalone script version -2.01 November 2011 Bug-fix for numeric overflow -3.0 November 2015 Added extended snapshot and reporting options -``` - -## 4.0 Credits -1. Credit is given to Jonathan Lewis for his original idea of taking two snapshots to identify resource consumption. -2. Thanks to Martin Bach for suggesting (and providing a prototype) for extended snapshot and reporting options. - -## 5.0 Disclaimer -See http://www.oracle-developer.net/disclaimer.php - -Adrian Billington -(c) www.oracle-developer.net diff --git a/development/mystats/mystats.sql b/development/mystats/mystats.sql deleted file mode 100644 index 1d09a0c09..000000000 --- a/development/mystats/mystats.sql +++ /dev/null @@ -1,513 +0,0 @@ - --- ---------------------------------------------------------------------------------------------- --- --- Utility: MyStats --- --- Script: mystats.sql --- --- Version: 3.0 --- --- Author: Adrian Billington --- www.oracle-developer.net --- (c) oracle-developer.net --- --- Description: A free-standing SQL*Plus script to output the resource consumption of a unit or --- units of work as recorded in v$mystat, v$latch and v$sess_time_model. --- Based on Jonathan Lewis's SNAP_MY_STATS package but as a standalone script (i.e. --- no database objects need to be created). --- --- Key Differences --- --------------- --- --- a) This is a SQL*Plus script that requires no objects to be created; --- --- b) This includes latch statistics and makes use of Tom --- Kyte's RUNSTATS method for distinguising between stats --- and latches; --- --- c) This includes advanced reporting options (see Usage and Examples --- sections below for details); --- --- d) This includes a session time model report; --- --- e) This requires at least version 10.1 to run because it --- makes use of collection methods such as MEMBER OF and --- reports on V$SESS_TIME_MODEL statistics. --- --- Configuration: Edit the c_ms_rmcmd variable in the Constants section at the start of this --- script to use the correct file deletion command for your SQL*Plus client --- platform. It is defaulted to a Windows "del" command, so you will need to --- change it if you are using a Linux/Unix SQL*Plus client. --- --- Reason: To make this run in standalone mode, a couple of temporary files --- are written to your current directory. These files are automatically --- removed on completion of this script. --- --- Usage: @mystats start [optional statistics type(s)] --- ---- --- @mystats stop [optional reporting parameter] --- --- Optional statistics types format: --- --- Short Format Long Format Equivalent --- ----------------------- ---------------------- --- s=[csv] stattypes=[csv] --- --- Statistics types values for the csv list are as follows: --- --- Statistics Type Short Format Long Format Equivalent --- --------------- ------------ ---------------------- --- Statistic s statistic --- Latch l latch --- Time Model t time --- All (default) a all --- --- Optional reporting parameter formats: --- --- Short Format Long Format Equivalent --- ----------------------- ---------------------- --- t= threshold= --- l= like= --- n= names= --- r= regexp= --- --- Use double-quotes when the strings contain spaces, --- e.g. "option=value with space" --- --- Examples: 1. Output all statistics --- ------------------------------------------------------------- --- @mystats start --- ---- --- @mystats stop --- --- 2. Output statistics with delta values >= 1,000 --- ------------------------------------------------------------- --- @mystats start --- ---- --- @mystats stop t=1000 --- --- 3. Output statistics for "redo size" and "user commits" only --- ------------------------------------------------------------- --- @mystats start --- ---- --- @mystats stop "n=redo size, user commits" --- --- 4. Output statistics for those containing the word 'memory' --- ------------------------------------------------------------- --- @mystats start --- ---- --- @mystats stop l=memory --- --- 5. Output statistics for those with I/O, IO, i/o or io in the name --- ------------------------------------------------------------------ --- @mystats start --- ---- --- @mystats stop r=I/?O\s --- --- 6. Capture and output statistics and time model only --- ------------------------------------------------------------- --- @mystats start s=s,t --- ---- --- @mystats stop --- --- 7. Output statistics only for those containing 'parallel' --- ------------------------------------------------------------- --- @mystats start s=s --- ---- --- @mystats stop l=parallel --- --- Notes: 1. See http://www.jlcomp.demon.co.uk/snapshot.html for original --- version. --- --- 2. As described in Configuration above, this script writes and removes --- a couple of temporary files during execution. --- --- 3. A PL/SQL package version of MyStats (v3.0) is also available. --- --- 4. Thanks to Martin Bach for the idea to provide a regexp reporting filter --- option and some example code. --- --- Disclaimer: http://www.oracle-developer.net/disclaimer.php --- --- ---------------------------------------------------------------------------------------------- - -set define on autoprint off -set serveroutput on format wrapped - --- Constants... --- ----------------------------------------------------------------------- -define c_ms_version = 3.0 -define c_ms_rmcmd = "del" --Windows ---define c_ms_rmcmd = "rm" --Unix/Linux -define c_ms_init = "_ms_init.sql" -define c_ms_clear = "_ms_teardown.sql" - - --- Initialise default substitution variables 1 and 2... --- ----------------------------------------------------------------------- -set termout off - -col 1 new_value 1 -col 2 new_value 2 - -select null as "1" -, null as "2" -from dual -where 1=2; - - --- Input parameters... --- ----------------------------------------------------------------------- -define p_ms_snap = &1 -define p_ms_option = "&2" - - --- Initialisation section... --- ----------------------------------------------------------------------- -column snap noprint new_value v_ms_snap -column if_start noprint new_value v_ms_if_start -column if_stop noprint new_value v_ms_if_stop - -select snap -, decode(snap, 'start', '', '--') as if_start -, decode(snap, 'stop', '', '--') as if_stop -from ( - select rtrim(lower('&p_ms_snap'),';') as snap - from dual - ); - -spool "&c_ms_init" replace -prompt var bv_ms_&v_ms_snap clob; -prompt var bv_ms_ela_&v_ms_snap number; -prompt var bv_ms_cpu_&v_ms_snap number; -spool off -@"&c_ms_init" -host &c_ms_rmcmd "&c_ms_init" - - --- Parse the options... --- ----------------------------------------------------------------------- -column threshold noprint new_value v_ms_threshold -column namelist noprint new_value v_ms_name_list -column namelike noprint new_value v_ms_name_like -column regexplike noprint new_value v_ms_name_regexp -column stattypes noprint new_value v_ms_stattypes -column ms_option noprint new_value v_ms_option -column start_option noprint new_value v_ms_start_option -column stop_option noprint new_value v_ms_stop_option - -select case - when o in ('threshold','t') - then 1 - when o in ('names','n') - then 2 - when o in ('like','l') - then 3 - when o in ('regex','r') - then 4 - when o in ('stattype','s') - then 5 - else 0 - end as ms_option -, case - when o in ('threshold','t') - then to_number(v) - else 0 - end as threshold -, case - when o in ('names','n') - then '''' || regexp_replace(v, ' *, *', ''',''') || '''' - else 'null' - end as namelist -, case - when o in ('like','l') - then '''%' || v || '%''' - else 'null' - end as namelike -, case - when o in ('regexp','r') - then '''' || v || '''' - else 'null' - end as regexplike -&v_ms_if_start , case -&v_ms_if_start when o in ('stattype','s') -&v_ms_if_start then regexp_replace(v, ' *, *', ',') -&v_ms_if_start when o is null -&v_ms_if_start then 'all' -&v_ms_if_start end as stattypes -&v_ms_if_start , p as start_option -, p as stop_option -from ( - select trim(regexp_substr(lower('&p_ms_option'), '[^=]+')) as o - , trim(regexp_substr('&p_ms_option', '[^=]+', 1, 2)) as v - , '&p_ms_option' as p - from dual - ); - - --- Stattypes include/exclude section... --- ----------------------------------------------------------------------- -column snap noprint -column include_stats noprint new_value v_ms_include_statistics -column include_latches noprint new_value v_ms_include_latches -column include_time noprint new_value v_ms_include_time_model - -select snap -&v_ms_if_start , case when regexp_like('&v_ms_stattypes', '(^|,)(s|statistic|a|all)(,|$)') then 'Y' else 'N' end as include_stats -&v_ms_if_start , case when regexp_like('&v_ms_stattypes', '(^|,)(l|latch|a|all)(,|$)') then 'Y' else 'N' end as include_latches -&v_ms_if_start , case when regexp_like('&v_ms_stattypes', '(^|,)(t|time|a|all)(,|$)') then 'Y' else 'N' end as include_time -from ( - select rtrim(lower('&p_ms_snap'),';') as snap - from dual - ); - - --- The utility... --- ----------------------------------------------------------------------- -set termout on -declare - - -- Run constants... - -- ------------------------------------------------------------------------- - c_snap1 constant pls_integer := 1; - c_snap2 constant pls_integer := 2; - - -- Snapshots... - -- ------------------------------------------------------------------------- - type rt_snaps is record - ( snap1 clob - , snap2 clob ); - - g_snaps rt_snaps; - - -- Elapsed time calculation... - -- ------------------------------------------------------------------------- - type rt_time is record - ( ela integer - , cpu integer ); - - type aat_time is table of rt_time - index by pls_integer; - - g_times aat_time; - - -- Utility info... - -- ------------------------------------------------------------------------- - procedure ms_options is - begin - dbms_output.put_line('- Statistics types : ' || nvl('&v_ms_start_option', 'all')); - dbms_output.put_line('- Reporting filter : ' || nvl('&v_ms_stop_option', 'none')); - end ms_options; - - procedure ms_info is - begin - dbms_output.put_line('- MyStats v&c_ms_version by Adrian Billington (http://www.oracle-developer.net)'); - dbms_output.put_line('- Original version based on the SNAP_MY_STATS utility by Jonathan Lewis'); - dbms_output.new_line(); - end ms_info; - - -- Snapshot procedure... - -- ------------------------------------------------------------------------- - procedure ms_snap( p_stats in out clob ) is - begin - select dbms_xmlgen.getxml( - q'[select 'STAT' as type - , a.name - , b.value - from v$statname a - , v$mystat b - where a.statistic# = b.statistic# - and '&v_ms_include_statistics' = 'Y' - union all - select 'LATCH' - , name - , gets - from v$latch - where '&v_ms_include_latches' = 'Y' - union all - select 'TIME' - , stat_name - , value - from v$sess_time_model - where sid = sys_context('userenv','sid') - and '&v_ms_include_time_model' = 'Y']' - ) into p_stats - from dual; - end ms_snap; - - -- Time snapshot... - -- ------------------------------------------------------------------------- - procedure ms_time( p_times in out nocopy aat_time, - p_snap in pls_integer ) is - begin - p_times(p_snap).ela := dbms_utility.get_time; - p_times(p_snap).cpu := dbms_utility.get_cpu_time; - end ms_time; - - -- Reporting procedure... - -- ------------------------------------------------------------------------- - procedure ms_report( p_times in aat_time, - p_snaps in rt_snaps ) is - - procedure div( p_divider in varchar2 default '-', - p_width in pls_integer default 90 ) is - begin - dbms_output.put_line( rpad(p_divider, p_width, p_divider) ); - end div; - - procedure nl( p_newlines in pls_integer default 1 ) is - begin - for i in 1 .. p_newlines loop - dbms_output.put_line(null); - end loop; - end nl; - - procedure sh ( p_title in varchar2, - p_header in boolean default true ) is - begin - nl(2); - div; - dbms_output.put_line(p_title); - div; - if p_header then - nl; - dbms_output.put_line('Type ' || rpad('Statistic Name',64) || lpad('Value',18)); - dbms_output.put_line(rpad('-',6,'-') || ' ' || rpad('-',64,'-') || ' ' || lpad('-',16,'-')); - end if; - end sh; - - begin - - -- Report header... - -- ---------------- - nl; - div('='); - dbms_output.put_line('MyStats report : ' || to_char(sysdate,'dd-MON-YYYY hh24:mi:ss')); - div('='); - - - -- Summary timings... - -- ------------------ - sh('1. Summary Timings'); - dbms_output.put_line(rpad('TIMER', 8) || rpad('snapshot interval (seconds)', 64) || - lpad(to_char(round((p_times(c_snap2).ela-p_times(c_snap1).ela)/100,2), 'fm999,990.00'),18)); - dbms_output.put_line(rpad('TIMER', 8) || rpad('CPU time used (seconds)', 64) || - lpad(to_char(round((p_times(c_snap2).cpu-p_times(c_snap1).cpu)/100,2), 'fm999,990.00'),18)); - - - -- Output the sorted stats... - -- -------------------------- - sh('2. Statistics Report'); - - for r in ( with ms_start as ( - select extractValue(xs.object_value, '/ROW/TYPE') as type - , extractValue(xs.object_value, '/ROW/NAME') as name - , to_number(extractValue(xs.object_value, '/ROW/VALUE')) as value - from table(xmlsequence(extract(xmltype(p_snaps.snap1), '/ROWSET/ROW'))) xs - ) - , ms_stop as ( - select extractValue(xs.object_value, '/ROW/TYPE') as type - , extractValue(xs.object_value, '/ROW/NAME') as name - , to_number(extractValue(xs.object_value, '/ROW/VALUE')) as value - from table(xmlsequence(extract(xmltype(p_snaps.snap2), '/ROWSET/ROW'))) xs - ) - , ms_diffs as ( - select type - , name - , ms_stop.value - ms_start.value as diff - from ms_start - inner join - ms_stop - using (type, name) - ) - select type, name, diff - from ms_diffs - where (&v_ms_option = 1 and abs(diff) >= &v_ms_threshold) - or (&v_ms_option = 2 and name in (&v_ms_name_list)) - or (&v_ms_option = 3 and name like &v_ms_name_like) - or (&v_ms_option = 4 and regexp_like(name, &v_ms_name_regexp, 'i')) - or &v_ms_option = 0 - order by - abs(diff) ) - loop - dbms_output.put_line(rpad(r.type,8) || rpad(r.name,64) || - lpad(to_char(r.diff,'999,999,999,999'),18)); - end loop; - - -- Options... - -- ---------- - sh('3. Options Used', false); - ms_options; - - -- About... - -- ------- - sh('4. About', false); - ms_info; - - nl; - div('='); - dbms_output.put_line('End of report'); - div('='); - - end ms_report; - -begin - - -- Runtime program... - -- ------------------------------------------------------------------------- - if '&v_ms_snap' = 'start' then - ms_snap(g_snaps.snap1); - :bv_ms_start := g_snaps.snap1; - ms_time(g_times, c_snap1); - :bv_ms_ela_start := g_times(c_snap1).ela; - :bv_ms_cpu_start := g_times(c_snap1).cpu; - elsif '&v_ms_snap' = 'stop' then - ms_time(g_times, c_snap2); - g_snaps.snap1 := :bv_ms_start; - g_times(c_snap1).ela := :bv_ms_ela_start; - g_times(c_snap1).cpu := :bv_ms_cpu_start; - ms_snap(g_snaps.snap2); - ms_report(g_times, g_snaps); - else - raise_application_error( -20000, - 'Incorrect parameter at position 1 '|| - '[used="&v_ms_snap"; valid="start" or "stop"]', - false ); - end if; - -end; -/ - --- Teardown section... --- ----------------------------------------------------------------------- -set termout off -spool "&c_ms_clear" replace -prompt &v_ms_if_stop undefine bv_ms_start -prompt &v_ms_if_stop undefine bv_ms_ela_start -prompt &v_ms_if_stop undefine bv_ms_cpu_start -prompt &v_ms_if_stop undefine v_ms_stattypes -prompt &v_ms_if_stop undefine v_ms_include_statistics -prompt &v_ms_if_stop undefine v_ms_include_latches -prompt &v_ms_if_stop undefine v_ms_include_time_model -prompt &v_ms_if_stop undefine v_ms_start_option -prompt &v_ms_if_stop undefine v_ms_stop_option -spool off -@"&c_ms_clear" -host &c_ms_rmcmd "&c_ms_clear" -undefine 1 -undefine 2 -undefine p_ms_snap -undefine p_ms_option -undefine v_ms_snap -undefine c_ms_rmcmd -undefine c_ms_init -undefine c_ms_clear -undefine v_ms_if_stop -undefine v_ms_if_start -undefine v_ms_threshold -undefine v_ms_name_list -undefine v_ms_name_like -undefine v_ms_name_regexp -undefine v_ms_option -undefine c_ms_version -set termout on diff --git a/development/mystats/mystats_pkg.sql b/development/mystats/mystats_pkg.sql deleted file mode 100644 index c29d6be77..000000000 --- a/development/mystats/mystats_pkg.sql +++ /dev/null @@ -1,545 +0,0 @@ -create or replace package mystats_pkg authid current_user as - - /* - || ---------------------------------------------------------------------------- - || - || Utility: MyStats - || - || Package: MYSTATS_PKG - || - || Script: mystats_pkg.sql - || - || Version: 3.0 - || - || Author: Adrian Billington - || www.oracle-developer.net - || (c) oracle-developer.net - || - || Description: PL/SQL-only version of Jonathan Lewis's SNAP_MY_STATS package. - || This package is used to output the resource usage as recorded - || in V$MYSTAT and V$LATCH. - || - || Key Differences - || --------------- - || - || a) All logic is encapsulated in a single PL/SQL package - || (no stats view); - || - || b) This uses invoker rights and dynamic SQL to workaround - || the sites where developers cannot get explicit grants - || on the required V$ views, but instead have access via - || roles or other privileges; - || - || c) This includes latch statistics and makes use of Tom - || Kyte's RUNSTATS method for distinguising between stats - || and latches; - || - || d) This includes advanced reporting options (see Usage - || section below for details); - || - || e) This includes a session time model report; - || - || f) This requires at least version 10.1 to run because it - || makes use of collection methods such as MEMBER OF and - || also reports on V$SESS_TIME_MODEL statistics. - || - || Usage: exec mystats_pkg.ms_start( [optional statistics include/exclude parameters] ) - || ---- - || exec mystats_pkg.ms_stop( [optional reporting parameters] ) - || - || Optional statistics types are selected during calls to the MS_START procedure - || and are all included by default: - || - || 1. Statistics (V$SESSTAT) - || 2. Latches (V$LATCH) - || 3. Time Model (V$SESS_TIME_MODEL) - || - || Optional reporting parameters are specified during calls to the MS_STOP procedure - || and take one of the following formats: - || - || 1. Threshold (numeric, using P_THRESHOLD parameter (numeric)) - || 2. Statistic names (array of statnames, using P_STATNAMES parameter (collection)) - || 3. Statistic name LIKE pattern (statname pattern, using P_STATNAME_LIKE parameter (string)) - || 4. Statistic name REGEXP pattern (statname pattern, using P_STATNAME_LIKE and P_USE_REGEXP parameters (string and boolean)) - || - || See examples below. - || - || 1. Output all statistics - || ------------------------------------------------------------- - || exec mystats_pkg.ms_start; - || ---- - || exec mystats_pkg.ms_stop; - || - || 2. Output statistics with delta values >= 1,000 - || ------------------------------------------------------------- - || exec mystats_pkg.ms_start; - || ---- - || exec mystats_pkg.ms_stop(p_threshold=>1000); - || - || 3. Output statistics for "redo size" and "user commits" only - || ------------------------------------------------------------- - || exec mystats_pkg.ms_start; - || ---- - || exec mystats_pkg.ms_stop(p_statnames=>mystats_pkg.statname_ntt('redo size', 'user commits')); - || - || 4. Output statistics for those containing the word 'memory' - || ----------------------------------------------------------- - || exec mystats_pkg.ms_start; - || ---- - || exec mystats_pkg.ms_stop(p_statname_like=>'memory'); - || - || 5. Output statistics for those with I/O, IO, i/o or io in the name - || ------------------------------------------------------------------ - || exec mystats_pkg.ms_start; - || ---- - || exec mystats_pkg.ms_stop(p_statname_like=>'I/?O\s', p_use_regexp=>true); - || - || 6. Capture and output statistics and time model only (exclude latches) - || ---------------------------------------------------------------------- - || exec mystats_pkg.ms_start(p_include_latches=>false); - || ---- - || exec mystats_pkg.ms_stop; - || - || 7. Output statistics only for those containing 'parallel' - || ------------------------------------------------------------- - || exec mystats_pkg.ms_start(p_include_latches=>false, p_include_time_model=>false); - || ---- - || exec mystats_pkg.ms_stop(p_statname_like=>'parallel'); - || - || Notes: 1. Serveroutput must be on (and set higher than default); - || - || 2. See http://www.jlcomp.demon.co.uk/snapshot.html for original - || version. - || - || 3. A free-standing, SQL*Plus-script version of MyStats is also - || available. The script version works without creating any - || database objects. - || - || Disclaimer: http://www.oracle-developer.net/disclaimer.php - || - || ---------------------------------------------------------------------------- - */ - - type statname_ntt is table of varchar2(64); - - procedure ms_start( p_include_statistics in boolean default true, - p_include_latches in boolean default true, - p_include_time_model in boolean default true ); - - procedure ms_stop; - - procedure ms_stop( p_threshold in integer ); - - procedure ms_stop( p_statnames in mystats_pkg.statname_ntt ); - - procedure ms_stop( p_statname_like in varchar2, - p_use_regexp in boolean default false ); - -end mystats_pkg; -/ - -create or replace package body mystats_pkg as - - -- A range of (sub)types for capturing statistics information... - -- ------------------------------------------------------------- - subtype st_option_flag is varchar2(1); - subtype st_stattype is varchar2(6); - subtype st_statname is varchar2(64); - subtype st_statvalue is integer; - subtype st_output is varchar2(255); - - type rt_statistic is record - ( type st_stattype - , name st_statname - , value st_statvalue ); - - type aat_statistic is table of rt_statistic - index by st_statname; - - type aat_mystats is table of aat_statistic - index by pls_integer; - - -- This is the "mystats array" to hold two snapshots... - -- ---------------------------------------------------- - ga_mystats aat_mystats; - - -- Array offsets into the main mystats array, used to - -- determine the start and end points of a run... - -- -------------------------------------------------- - c_run1 constant pls_integer := 1; - c_run2 constant pls_integer := 2; - - -- Globals for elapsed time calculation... - -- --------------------------------------- - type rt_time is record - ( ela_time integer - , cpu_time integer ); - - g_start_time rt_time; - g_end_time rt_time; - - -- Globals to capture snapshot options... - g_include_statistics st_option_flag; - g_include_latches st_option_flag; - g_include_time_model st_option_flag; - - ------------------------------------------------------------------------------ - procedure ms_options( p_threshold in pls_integer, - p_statnames in mystats_pkg.statname_ntt, - p_statname_like in varchar2, - p_statname_regexp in varchar2 ) is - v_filter varchar2(4000); - begin - dbms_output.put('- Statistics types : '); - dbms_output.put('statistics=' || g_include_statistics || ', '); - dbms_output.put('latches=' || g_include_latches || ', '); - dbms_output.put_line('time model=' || g_include_time_model); - if p_threshold is not null then - v_filter := 'threshold=' || p_threshold; - elsif p_statname_like is not null then - v_filter := 'statnames like=' || p_statname_like || ', regular expression=N'; - elsif p_statname_regexp is not null then - v_filter := 'statnames like=' || p_statname_regexp || ', regular expression=Y'; - elsif p_statnames is not null and p_statnames is not empty then - v_filter := 'statnames in='; - for i in 1 .. p_statnames.count loop - v_filter := v_filter || p_statnames(i) || ','; - end loop; - v_filter := rtrim(v_filter, ','); - else - v_filter := 'None'; - end if; - dbms_output.put_line('- Reporting filter : ' || v_filter); - end ms_options; - - ------------------------------------------------------------------------------ - procedure ms_info is - begin - dbms_output.put_line('- MyStats v3.0 by Adrian Billington (http://www.oracle-developer.net)'); - dbms_output.put_line('- Based on the SNAP_MY_STATS utility by Jonathan Lewis'); - end ms_info; - - ------------------------------------------------------------------------------ - procedure ms_snap( p_run in pls_integer, - p_mystats in out nocopy aat_mystats, - p_time in out rt_time ) is - - rc_stat sys_refcursor; - type aat_statistic is table of rt_statistic - index by pls_integer; - aa_stats aat_statistic; - - procedure snap_time is - begin - p_time.ela_time := dbms_utility.get_time; - p_time.cpu_time := dbms_utility.get_cpu_time; - end snap_time; - - begin - - if p_run = c_run2 then - snap_time; - end if; - - -- Dynamic SQL (combined with invoker rights in the spec) works around - -- the need to have explicit select granted on the referenced v$ views. - -- Of course, we still need access granted via a role or other privilege - -- but I've always been able to get the latter and rarely the former... - -- --------------------------------------------------------------------- - open rc_stat for q'[select 'STAT' as type - , a.name - , b.value - from v$statname a - , v$mystat b - where a.statistic# = b.statistic# - and :g_include_statistics = 'Y' - union all - select 'LATCH' - , name - , gets - from v$latch - where :g_include_latches = 'Y' - union all - select 'TIME' - , 'elapsed time' - , hsecs - from v$timer - where :g_include_time_model = 'Y' - union all - select 'TIME' - , stat_name - , value - from v$sess_time_model - where sid = sys_context('userenv','sid') - and :g_include_time_model = 'Y']' - using g_include_statistics, g_include_latches, g_include_time_model, g_include_time_model; - fetch rc_stat bulk collect into aa_stats; - close rc_stat; - for i in 1 .. aa_stats.count loop - p_mystats(p_run)(aa_stats(i).name).type := aa_stats(i).type; - p_mystats(p_run)(aa_stats(i).name).value := aa_stats(i).value; - end loop; - - if p_run = c_run1 then - snap_time; - end if; - - end ms_snap; - - ------------------------------------------------------------------------------ - procedure ms_report( p_threshold in pls_integer default null, - p_statnames in mystats_pkg.statname_ntt default null, - p_statname_like in varchar2 default null, - p_statname_regexp in varchar2 default null ) is - - v_name st_statname; --<-- offset for varchar2 associative arrays - v_indx pls_integer; --<-- offset for pls_integer associative arrays - v_type st_stattype; --<-- statistic type - v_value st_statvalue; --<-- snapshot value for a statistic - - -- Downside of using associative arrays is that we have to sort - -- the output. So here's a couple of types and a variable to enable us - -- to do that... - -- ------------------------------------------------------------------- - type aat_mystats_output is table of st_output - index by st_statname; - type aat_mystats_sorted is table of aat_mystats_output - index by pls_integer; - aa_mystats_sorted aat_mystats_sorted; - - -- Procedure to add a statistic to the sorted mystats array... - -- ----------------------------------------------------------- - procedure sort ( p_stattype in st_stattype, - p_statname in st_statname, - p_value in number ) is - v_offset pls_integer; - v_output st_output; - begin - -- Workaround the offset limits of a PLS_INTEGER associative array... - -- ------------------------------------------------------------------ - v_offset := least(abs(p_value),2147483647); - v_output := rpad(p_stattype, 8) || rpad(p_statname, 64) || - lpad(to_char(p_value,'999,999,999,999'),18); - aa_mystats_sorted(v_offset)(p_statname) := v_output; - end sort; - - -- Report formatting procedures... - -- ------------------------------- - procedure div( p_divider in varchar2 default '-', - p_width in pls_integer default 90 ) is - begin - dbms_output.put_line( rpad(p_divider, p_width, p_divider) ); - end div; - - procedure nl( p_newlines in pls_integer default 1 ) is - begin - for i in 1 .. p_newlines loop - dbms_output.put_line(null); - end loop; - end nl; - - procedure sh ( p_title in varchar2, - p_header in boolean default true ) is - begin - nl(2); - div; - dbms_output.put_line(p_title); - div; - if p_header then - nl; - dbms_output.put_line('Type ' || rpad('Statistic Name',64) || lpad('Value',18)); - dbms_output.put_line(rpad('-',6,'-') || ' ' || rpad('-',64,'-') || ' ' || lpad('-',16,'-')); - end if; - end sh; - - begin - - -- Report header... - -- ---------------- - nl; - div('='); - dbms_output.put_line('MyStats report : ' || to_char(sysdate,'dd-MON-YYYY hh24:mi:ss')); - div('='); - - -- Summary timings... - -- ------------------ - sh('1. Summary Timings'); - dbms_output.put_line(rpad('TIMER', 8) || rpad('snapshot interval (seconds)', 64) || - lpad(to_char(round((g_end_time.ela_time-g_start_time.ela_time)/100,2), 'fm999,990.00'),18)); - dbms_output.put_line(rpad('TIMER', 8) || rpad('CPU time used (seconds)', 64) || - lpad(to_char(round((g_end_time.cpu_time-g_start_time.cpu_time)/100,2), 'fm999,990.00'),18)); - - -- Now sort the output according to difference. A fudge is that we have to sort - -- it manually and also work around the offset limits of an associative array... - -- ----------------------------------------------------------------------------- - v_name := ga_mystats(c_run1).first; - while v_name is not null loop - - -- Retrieve stattype... - -- -------------------- - v_type := ga_mystats(c_run1)(v_name).type; - - -- Calculate the value of the current statistic... - -- ----------------------------------------------- - v_value := ga_mystats(c_run2)(v_name).value - ga_mystats(c_run1)(v_name).value; - - -- If it's greater than the threshold or a statistic we are interested in, - -- then output it. The downside of using purely associative arrays is that - -- we don't have any easy way of sorting. So we have to do it ourselves... - -- ----------------------------------------------------------------------- - if (p_threshold is not null and abs(v_value) >= p_threshold) - or (p_statnames is not empty and v_name member of p_statnames) - or (p_statname_like is not null and v_name like '%'||p_statname_like||'%') or (p_statname_regexp is not null and regexp_like(v_name, p_statname_regexp, 'i')) - then - -- Fix for bug 1713403. If redo goes over 2Gb then it is reported as a negative - -- number. Recommended workaround (prior to fix in 10g) is to use redo blocks written - -- but this seems to be 0 in V$MYSTAT or V$SESSTAT. Output a bug message... - -- ---------------------------------------------------------------------------------- - if v_name = 'redo size' and v_value < 0 then - sort('BUG','redo size > 2gb gives -ve value. Use redo blocks written',0); - else - sort(v_type, v_name, v_value); - end if; - end if; - - - -- Next statname please... - -- ----------------------- - v_name := ga_mystats(c_run1).next(v_name); - - end loop; - - -- Now we can output the sorted snapshot... - -- ---------------------------------------- - sh('2. Statistics Report'); - - v_indx := aa_mystats_sorted.first; - while v_indx is not null loop - - v_name := aa_mystats_sorted(v_indx).first; - while v_name is not null loop - dbms_output.put_line( aa_mystats_sorted(v_indx)(v_name) ); - v_name := aa_mystats_sorted(v_indx).next(v_name); - end loop; - - v_indx := aa_mystats_sorted.next(v_indx); - - end loop; - - -- Options... - -- ------- - sh('3. Options', false); - ms_options(p_threshold, p_statnames, p_statname_like, p_statname_regexp); - - -- Info... - -- ------- - sh('4. About', false); - ms_info; - - nl; - div('='); - dbms_output.put_line('End of report'); - div('='); - - end ms_report; - - ------------------------------------------------------------------------------ - procedure ms_set_snap_options( p_include_statistics in boolean, - p_include_latches in boolean, - p_include_time_model in boolean ) is - function ms_set_option( p_option in boolean ) return varchar2 is - begin - return case - when p_option - then 'Y' - else 'N' - end; - end ms_set_option; - begin - g_include_statistics := ms_set_option(p_include_statistics); - g_include_latches := ms_set_option(p_include_latches); - g_include_time_model := ms_set_option(p_include_time_model); - end ms_set_snap_options; - - ------------------------------------------------------------------------------ - procedure ms_reset is - begin - ga_mystats.delete; - g_start_time := null; - g_end_time := null; - g_include_statistics := null; - g_include_latches := null; - g_include_time_model := null; - end ms_reset; - - ------------------------------------------------------------------------------ - procedure ms_start( p_include_statistics in boolean default true, - p_include_latches in boolean default true, - p_include_time_model in boolean default true ) is - begin - ms_reset; - ms_set_snap_options(p_include_statistics, p_include_latches, p_include_time_model); - ms_snap(c_run1, ga_mystats, g_start_time); - end ms_start; - - ------------------------------------------------------------------------------ - procedure ms_stop_internal( p_threshold in integer default null, - p_statnames in mystats_pkg.statname_ntt default null, - p_statname_like in varchar2 default null, - p_statname_regexp in varchar2 default null ) is - begin - if g_start_time.ela_time is not null then - ms_snap(c_run2, ga_mystats, g_end_time); - case - when p_threshold is not null - then ms_report(p_threshold => p_threshold); - when p_statnames is not null - then ms_report(p_statnames => p_statnames); - when p_statname_like is not null - then ms_report(p_statname_like => p_statname_like); - when p_statname_regexp is not null - then ms_report(p_statname_regexp => p_statname_regexp); - else ms_report; - end case; - ms_reset; - else - raise_application_error( - -20001, 'Error: must call ms_start before ms_stop.' - ); - end if; - end ms_stop_internal; - - ------------------------------------------------------------------------------ - procedure ms_stop is - begin - ms_stop_internal(p_threshold => 0); - end ms_stop; - - ------------------------------------------------------------------------------ - procedure ms_stop( p_threshold in integer ) is - begin - ms_stop_internal(p_threshold => p_threshold); - end ms_stop; - - ------------------------------------------------------------------------------ - procedure ms_stop( p_statnames in mystats_pkg.statname_ntt ) is - begin - ms_stop_internal(p_statnames => p_statnames); - end ms_stop; - - ------------------------------------------------------------------------------ - procedure ms_stop( p_statname_like in varchar2, - p_use_regexp in boolean default false ) is - begin - if p_use_regexp then - ms_stop_internal(p_statname_regexp => p_statname_like); - else - ms_stop_internal(p_statname_like => p_statname_like); - end if; - end ms_stop; - -end mystats_pkg; -/ - --- create or replace public synonym mystats_pkg for mystats_pkg; --- grant execute on mystats_pkg to public; diff --git a/development/refresh_sources.sh b/development/refresh_sources.sh deleted file mode 100755 index 83518d7cc..000000000 --- a/development/refresh_sources.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" - -. ./development/env.sh - -# remove sub-direcotry containing main branch shallow copy -rm -rf ${UTPLSQL_DIR:-utPLSQL_latest_release} -# clone utPLSQL main branch from upstream into utPLSQL sub-directory of your project -git clone --depth=1 --branch=${SELFTESTING_BRANCH:-main} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR:-utPLSQL_latest_release} - -rm -rf utPLSQL-cli/* -# download latest release version of utPLSQL-cli -curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip -# unzip utPLSQL-cli and remove the zip file -unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip - diff --git a/development/refresh_ut3.sh b/development/refresh_ut3.sh deleted file mode 100755 index 827af827d..000000000 --- a/development/refresh_ut3.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" - -. development/env.sh - -cd source - -"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL -@uninstall ${UT3_DEVELOP_SCHEMA} -@install ${UT3_DEVELOP_SCHEMA} -exit -SQL diff --git a/development/releasing.md b/development/releasing.md deleted file mode 100644 index ac2091632..000000000 --- a/development/releasing.md +++ /dev/null @@ -1,28 +0,0 @@ -## Release process - -To create a release follow the below steps - -## Release preparation - - Create a **draft** of a Release with a new tag number `vX.Y.X` sourced from the `develop` branch on [github releases page](https://github.com/utPLSQL/utPLSQL/releases) - - Populate release description using the `Generate release notes` button - - Review the auto-generated release notes and update tem if needed - - Optionally, split the default `## What's Changed` list into `## New features`, `## Enhancements`, `## Bug fixes`. See previous release notes for details - -## Performing a release - - Publish [the previously prepared](#release-preparation) release draft. - - Wait for the [Github Actions `Release`](https://github.com/utPLSQL/utPLSQL/actions/workflows/release.yml) process to complete successfully. The process will upload release artifacts (`zip` and `tar.gz` files along with `md5`) - - After Release build was completed successfully, merge the `develop` branch into `main` branch. At this point, main branch and release tag should be at the same commit version and artifacts should be uploaded into Github release. - - Increase the version number in the `VERSION` file on `develop` branch to open start next release version. - - Clone `utplsql.githug.io` project and: - - Add a new announcement about next version being released in `docs/_posts`. Use previous announcements as a template. Make sure to set date, time and post title properly. - - Add the post to list in `mkdocs.yml` file in root directory of that repository. - - Add the link to the post at the beginning of the `docs/index.md` file. - - Send the announcement on Twitter(X) accoiunt abut utPLSQL release. - -The following will happen: - - When a Github release is published, a new tag is added in on the repository and a release build is executed - - With Release action, the documentation for new release is published on `utplsql.github.io` and installation archives are added to the release. - -# Note: -The utPLSQL installation files are uploaded by the release build process as release artifacts (separate `zip` and `tar.gz` files). -The release artifacts include HTML documentation generated from MD files, sources and tests diff --git a/development/template.env.sh b/development/template.env.sh deleted file mode 100755 index fdbed4b6b..000000000 --- a/development/template.env.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -export SQLCLI=sql # For sqlcl client -#export SQLCLI=sqlplus # For sqlplus client -export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string -export ORACLE_PWD=oracle # Adjust your local SYS password -export UTPLSQL_CLI_VERSION="v3.1.8" -export SELFTESTING_BRANCH=develop - -export UTPLSQL_DIR="utPLSQL_latest_release" -export UT3_DEVELOP_SCHEMA=UT3_DEVELOP -export UT3_DEVELOP_SCHEMA_PASSWORD=ut3 -export UT3_RELEASE_VERSION_SCHEMA=UT3 -export UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3 -export UT3_TABLESPACE=users diff --git a/development/utPSLQLv3-modules.png b/development/utPSLQLv3-modules.png deleted file mode 100644 index eecfdf684..000000000 Binary files a/development/utPSLQLv3-modules.png and /dev/null differ diff --git a/development/ut_debug_enable.sql b/development/ut_debug_enable.sql deleted file mode 100644 index 5ae2c7048..000000000 --- a/development/ut_debug_enable.sql +++ /dev/null @@ -1,10 +0,0 @@ ---This is only typically needed by developers of utplsql ---Running this script recompiles the packages with tracing turned on. - -alter session set PLSQL_Warnings = 'enable:all'; -alter session set PLSQL_CCFlags = 'ut_trace:true'; - -alter package ut_annotations compile debug package; -alter package ut_suite_manager compile debug package; -alter package ut_utils compile debug package; -exit diff --git a/development/utplsql_style_check.sql b/development/utplsql_style_check.sql deleted file mode 100644 index 00d562541..000000000 --- a/development/utplsql_style_check.sql +++ /dev/null @@ -1,68 +0,0 @@ -alter session set plscope_settings= 'identifiers:all'; -set linesize 300 -set pagesize 10000 - ---install or comple all code here -exec dbms_utility.compile_schema(USER,compile_all => TRUE,reuse_settings => FALSE); -set echo off -set feedback off - -var errcnt number - -column errcnt_a noprint new_value errcnt_a -column errcnt_l noprint new_value errcnt_l -column errcnt_c noprint new_value errcnt_c - -column NAME FORMAT A30 -column TYPE FORMAT A18 -column OBJECT_NAME FORMAT A30 -column OBJECT_TYPE FORMAT A18 -column USAGE FORMAT A16 -column LINE FORMAT 99999 -column COL FORMAT 9999 - -PROMPT parameters that are not prefixed with "a_" -select name, type, object_name, object_type, usage, line, col, count(*) over() errcnt_a - from user_identifiers - where type like 'FORMAL%' and usage = 'DECLARATION' - and name != 'SELF' - and name not like 'A#_%' escape '#' - order by object_name, object_type, line, col -; - -PROMPT -PROMPT -PROMPT variables that are not prefixed with "l_" -select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_l - from user_identifiers i - join user_identifiers p - on p.object_name = i.object_name and p.object_type = i.object_type - and i.usage_context_id = p.usage_id - where i.type like 'VARIABLE' and i.usage = 'DECLARATION' - and i.object_type not in ('TYPE') - and (i.name not like 'L#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR','TRIGGER') - or i.name not like 'G#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR','TRIGGER')) - and p.type != 'RECORD' - order by object_name, object_type, line, col -; - -PROMPT -PROMPT -PROMPT constants that are not prefixed with with "c_" -PROMPT global constants that are not prefixed with "gc_" -select i.name, i.type, i.object_name, i.object_type, i.usage, i.line, i.col, count(*) over() errcnt_c - from user_identifiers i - join user_identifiers p - on p.object_name = i.object_name and p.object_type = i.object_type - and i.usage_context_id = p.usage_id - where i.type like 'CONSTANT' and i.usage = 'DECLARATION' - and (i.name not like 'C#_%' escape '#' and p.type in ('PROCEDURE','FUNCTION','ITERATOR') - or i.name not like 'GC#_%' escape '#' and p.type not in ('PROCEDURE','FUNCTION','ITERATOR')) - order by object_name, object_type, line, col -; - - -exec :errcnt := nvl('&errcnt_a',0) + nvl('&errcnt_l',0) + nvl('&errcnt_c',0); - ---quit :errcnt -exit :errcnt diff --git a/docs/about/authors.md b/docs/about/authors.md deleted file mode 100644 index 2c2abf826..000000000 --- a/docs/about/authors.md +++ /dev/null @@ -1,26 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -### utPLSQL v3 Major Contributors - -**Listed Alphabetically** - -| Name | GitHub account -| ---------------- | -------------- -| David Pyke | [Shoelace](https://github.com/Shoelace) -| Jacek Gebal | [jgebal](https://github.com/jgebal) -| Lukasz Wasylow | [lwasylow](https://github.com/lwasylow/) -| Pavel Kaplya | [Pazus](https://github.com/Pazus) -| Robert Love | [rlove](https://github.com/rlove) -| Samuel Nitsche | [pesse](https://github.com/pesse/) -| Vinicius Avellar | [viniciusam](https://github.com/viniciusam/) - - - -Many thanks to all the [contributors](https://github.com/utPLSQL/utPLSQL/graphs/contributors) - -### Special thanks to prior major contributors - -- Steven Feuerstein - Original Author of utPLSQL v1 and v2 -- Chris Rimmer -- Patrick Barel -- Paul Walker diff --git a/docs/about/license.md b/docs/about/license.md deleted file mode 100644 index 0485779e5..000000000 --- a/docs/about/license.md +++ /dev/null @@ -1,17 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -# Version Information - -**utPLSQL version 3** is licensed under -[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) - -External code used in the development of this project, but is not required for use. - -| Tool | License | Purpose | -| ---- | --------| --------| -| [Travis-Oracle](https://github.com/cbandy/travis-oracle) | [ISC](https://github.com/cbandy/travis-oracle/blob/master/LICENSE) | Install Oracle for Travis Builds | -| [mkDocs](http://www.mkdocs.org/) | [BSD](http://www.mkdocs.org/about/license/) | Produce HTML version of documentation | - -**Note:** - -Version 1 & 2 of utPLSQL were licensed under GPL, version 3 was a complete rewrite from scratch which a allowed us to change the license to be more permissive. diff --git a/docs/about/project-details.md b/docs/about/project-details.md deleted file mode 100644 index 81e4f976e..000000000 --- a/docs/about/project-details.md +++ /dev/null @@ -1,18 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -# utPLSQL Project Details - -[![chat](http://img.shields.io/badge/GitHub_Project-Active-blue.svg)](https://github.com/utPLSQL/utPLSQL) -[![license](http://img.shields.io/badge/license-apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) -[![twitter](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL) - - -utPLSQL is open source project [hosted on GitHub](https://github.com/utPLSQL/utPLSQL). - -Contributions, help and constructive feedback is always appreciated. - -If you are interested in helping please read our [contributing guide](https://github.com/utPLSQL/utPLSQL/blob/develop/CONTRIBUTING.md) - - - diff --git a/docs/about/support.md b/docs/about/support.md deleted file mode 100644 index 4ac661e10..000000000 --- a/docs/about/support.md +++ /dev/null @@ -1,7 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -# How to get support - -- Look into [utPLSQL github discussions](https://github.com/utPLSQL/utPLSQL/discussions) to find support, ask questions and share ideas -- If needed open a new [issue on github](https://github.com/utPLSQL/utPLSQL/issues) for bugs or feature requests - diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png deleted file mode 100644 index 7c34109d0..000000000 Binary files a/docs/assets/favicon.png and /dev/null differ diff --git a/docs/assets/icon-transparent.png b/docs/assets/icon-transparent.png deleted file mode 100644 index 6e4534aad..000000000 Binary files a/docs/assets/icon-transparent.png and /dev/null differ diff --git a/docs/compare_version2_to_3.md b/docs/compare_version2_to_3.md deleted file mode 100644 index 5f53e41d4..000000000 --- a/docs/compare_version2_to_3.md +++ /dev/null @@ -1,56 +0,0 @@ -For version 3 has been a complete rewrite of the framework, the way it can be used is different to -the previous versions, but also more in line with other modern unit-testing frameworks like JUnit and RSpec. - -There is a [migration tool](https://github.com/utPLSQL/utPLSQL-v2-v3-migration) that can help you to migrate your existing utPLSQL v2 tests to the v3 capabilities. - -# Feature comparison - -| Feature | Version 2 | Version 3 | -| -------------------------------------- | ---------------------- | ---------------------- | -| Easy to install | Yes | Yes | -| Documentation | Yes | Yes | -| License | GPL v2 | Apache 2.0 | -| **Tests Creation** | | | -| Declarative test configuration | No | Yes - Annotations1| -| Tests as Packages | Yes | Yes | -| Multiple Tests in a single Package | Yes | Yes | -| Optional Setup/Teardown | No | Yes | -| Different Setup/Teardown
For Each Test in a Single Package| No | Yes - Annotations1 | -| Suite Definition Storage | Tables | Package - Annotations1 | -| Multiple Suites | Yes | Yes | -| Suites can contain Suites | No | Yes | -| Automatic Test detection | No | Yes - Annotations1| -| Unconstrained naming of Test packages | No - prefixes | Yes - name not relevant| -| Require Prefix on Test procedures | No - prefixes | Yes - name not relevant| -| Auto Compilation of Tests | Yes | No (Let us know if you use this) | -| Assertion Library | 30 assertions2 | 26 matchers (13 + 13 negated) | -| Extendable assertions | No | Yes - custom matchers | -| PLSQL Record Assertions | generated code through **utRecEq** Package | [possible on Oracle 12c+](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1) using [cursor matchers](userguide/expectations.md#comparing-cursors)| -| Test Skeleton Generation | Yes | No (Let us know if you use this) | -| **Test Execution3** | | | -| Single Test Package Execution | Yes | Yes | -| Single Test Procedure Execution | No | Yes | -| Test Suite Execution | Yes | Yes | -| Subset of Suite Execution | No | Yes | -| Multiple Suite Execution | No | Yes | -| Organizing Suites into hierarchies | No | Yes | -| **Code Coverage Reporting** | No | Yes | -| Html Coverage Report | No | Yes | -| Sonar XML Coverage Report | No | Yes | -| Coveralls Json Coverage Report | No | Yes | -| Framework Transaction Control | No | Yes - Annotations1 | -| **Test Output** | | | -| Real-time test execution progress reporting | No | Yes | -| Multiple Output Reporters can be used during test execution | No| Yes | -| DBMS_OUTPUT | Yes | Yes (clean formatting) | -| File | Yes (to db server only)| Yes (on client side) | -| Stored in Table | Yes | No (can be added as custom reporter) | -| XUnit format support | No | Yes | -| HTML Format | Yes | No | -| Custom Output reporter | Yes-needs configuration| Yes - no config needed | - -1 Annotations are specially formatted comments in your package specification. This enables *declarative* test configuration that is coupled with the source code. See Documentation for more details. - -2 **utAssert2** package - Contains 59 Assertions - 2 Not implemented = 57, 28 are duplicated only change on outcome_in parameter 57-28 = 29, **utPipe** package - Contains 1 Assertion 29 + 1 = 30 - -3 Test execution comparison is in a single call so the results are combined. We know it was always possible to group in any way with multiple calls. But that may not be desired under a CI system where you want a single JUnit XML Output. diff --git a/docs/images/3_steps_to_run_utPLSQL.gif b/docs/images/3_steps_to_run_utPLSQL.gif deleted file mode 100644 index ec99033e9..000000000 Binary files a/docs/images/3_steps_to_run_utPLSQL.gif and /dev/null differ diff --git a/docs/images/coverage_html_details.png b/docs/images/coverage_html_details.png deleted file mode 100644 index 1dffd0385..000000000 Binary files a/docs/images/coverage_html_details.png and /dev/null differ diff --git a/docs/images/coverage_html_summary.png b/docs/images/coverage_html_summary.png deleted file mode 100644 index fd96360b7..000000000 Binary files a/docs/images/coverage_html_summary.png and /dev/null differ diff --git a/docs/images/documentation_reporter.png b/docs/images/documentation_reporter.png deleted file mode 100644 index d4f485164..000000000 Binary files a/docs/images/documentation_reporter.png and /dev/null differ diff --git a/docs/images/documentation_reporter_color.png b/docs/images/documentation_reporter_color.png deleted file mode 100644 index 9cacb5e3f..000000000 Binary files a/docs/images/documentation_reporter_color.png and /dev/null differ diff --git a/docs/images/example_1_coverage_mapping.png b/docs/images/example_1_coverage_mapping.png deleted file mode 100644 index 2066292e1..000000000 Binary files a/docs/images/example_1_coverage_mapping.png and /dev/null differ diff --git a/docs/images/example_1_test_mapping.png b/docs/images/example_1_test_mapping.png deleted file mode 100644 index cf3d14649..000000000 Binary files a/docs/images/example_1_test_mapping.png and /dev/null differ diff --git a/docs/images/example_2_coverage_mapping.png b/docs/images/example_2_coverage_mapping.png deleted file mode 100644 index 6e363da75..000000000 Binary files a/docs/images/example_2_coverage_mapping.png and /dev/null differ diff --git a/docs/images/example_2_test_mapping.png b/docs/images/example_2_test_mapping.png deleted file mode 100644 index 91a7b6c0e..000000000 Binary files a/docs/images/example_2_test_mapping.png and /dev/null differ diff --git a/docs/images/example_3_coverage_mapping.png b/docs/images/example_3_coverage_mapping.png deleted file mode 100644 index de347ed89..000000000 Binary files a/docs/images/example_3_coverage_mapping.png and /dev/null differ diff --git a/docs/images/example_3_test_mapping.png b/docs/images/example_3_test_mapping.png deleted file mode 100644 index d639f3f55..000000000 Binary files a/docs/images/example_3_test_mapping.png and /dev/null differ diff --git a/docs/images/example_4_coverage_mapping.png b/docs/images/example_4_coverage_mapping.png deleted file mode 100644 index 9bee46c33..000000000 Binary files a/docs/images/example_4_coverage_mapping.png and /dev/null differ diff --git a/docs/images/example_4_test_mapping.png b/docs/images/example_4_test_mapping.png deleted file mode 100644 index 83479cd41..000000000 Binary files a/docs/images/example_4_test_mapping.png and /dev/null differ diff --git a/docs/images/extended_coverage_html_line.png b/docs/images/extended_coverage_html_line.png deleted file mode 100644 index 4a3ed4609..000000000 Binary files a/docs/images/extended_coverage_html_line.png and /dev/null differ diff --git a/docs/images/extended_coverage_html_summary.png b/docs/images/extended_coverage_html_summary.png deleted file mode 100644 index f4e5768a1..000000000 Binary files a/docs/images/extended_coverage_html_summary.png and /dev/null differ diff --git a/docs/images/junit_errors.png b/docs/images/junit_errors.png deleted file mode 100644 index 1703abb3e..000000000 Binary files a/docs/images/junit_errors.png and /dev/null differ diff --git a/docs/images/junit_summary.png b/docs/images/junit_summary.png deleted file mode 100644 index ee792357b..000000000 Binary files a/docs/images/junit_summary.png and /dev/null differ diff --git a/docs/images/supported_by_redgate_100.png b/docs/images/supported_by_redgate_100.png deleted file mode 100644 index ea9f93ac5..000000000 Binary files a/docs/images/supported_by_redgate_100.png and /dev/null differ diff --git a/docs/images/tap_reporter_colored.png b/docs/images/tap_reporter_colored.png deleted file mode 100644 index d4a5e9326..000000000 Binary files a/docs/images/tap_reporter_colored.png and /dev/null differ diff --git a/docs/images/tap_reporter_no_color.png b/docs/images/tap_reporter_no_color.png deleted file mode 100644 index e7379a889..000000000 Binary files a/docs/images/tap_reporter_no_color.png and /dev/null differ diff --git a/docs/images/tap_reporter_suitepath.png b/docs/images/tap_reporter_suitepath.png deleted file mode 100644 index 488c7cfbf..000000000 Binary files a/docs/images/tap_reporter_suitepath.png and /dev/null differ diff --git a/docs/images/teamcity_report_example.png b/docs/images/teamcity_report_example.png deleted file mode 100644 index b00ea44a8..000000000 Binary files a/docs/images/teamcity_report_example.png and /dev/null differ diff --git a/docs/images/teamcity_report_example_errors.png b/docs/images/teamcity_report_example_errors.png deleted file mode 100644 index fe4523894..000000000 Binary files a/docs/images/teamcity_report_example_errors.png and /dev/null differ diff --git a/docs/images/tfs_details.png b/docs/images/tfs_details.png deleted file mode 100644 index 27dded5e6..000000000 Binary files a/docs/images/tfs_details.png and /dev/null differ diff --git a/docs/images/tfs_summary.png b/docs/images/tfs_summary.png deleted file mode 100644 index c47048efa..000000000 Binary files a/docs/images/tfs_summary.png and /dev/null differ diff --git a/docs/images/utPLSQL-testing-framework-transparent_120.png b/docs/images/utPLSQL-testing-framework-transparent_120.png deleted file mode 100644 index 98a24faf0..000000000 Binary files a/docs/images/utPLSQL-testing-framework-transparent_120.png and /dev/null differ diff --git a/docs/images/venn21.gif b/docs/images/venn21.gif deleted file mode 100644 index 0efecae07..000000000 Binary files a/docs/images/venn21.gif and /dev/null differ diff --git a/docs/images/venn22.gif b/docs/images/venn22.gif deleted file mode 100644 index 52768b71f..000000000 Binary files a/docs/images/venn22.gif and /dev/null differ diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 459bc9535..000000000 --- a/docs/index.md +++ /dev/null @@ -1,58 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -## What is utPLSQL - -utPLSQL is a Unit Testing framework for Oracle PL/SQL. -The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/) - -## Demo project - -Have a look at [utPLSQL demo project](https://github.com/utPLSQL/utPLSQL-demo-project/) to see: - -- sample code and tests -- demo of deployment automation that leverages: - - Flyway / Liquidbase for scripting and deployment of DB changes - - Docker container with Oracle XE Database - - GitHub Actions and Azure Pipelines to orchestrate the deployment and testing process - - utPLSQL framework for writhing, execution of tests as well as reporting test results and code coverage - - [Sonar]((https://sonarcloud.io/project/overview?id=utPLSQL:utPLSQL-demo-project).) for code quality gate, test results and code coverage reporting - -## Three steps - -With just three simple steps you can define and run your unit tests for PLSQL code. - -1. Install the utPLSQL framework -2. Create Unit Tests to for the code -3. Run the tests - -Here is how you can simply create tested code, unit tests and execute the tests using SQL Developer - -![3_steps](images/3_steps_to_run_utPLSQL.gif) - -Check out the sections on [annotations](userguide/annotations.md) and [expectations](userguide/expectations.md) to see how to define your tests. - - -## Command line - -You can use the utPLSQL command line client [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) to run tests without the need for Oracle Client or any IDE like SQLDeveloper/TOAD etc. - -Amongst many benefits they provide ability to: - -* see the progress of test execution for long-running tests - real-time reporting -* use many reporting formats simultaneously and save reports to files (publish) -* map your project source files and test files into database objects - -Download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) and you are good to go. -See [project readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details. - -## Coverage - -It is best to use utPLSQL-cli or execute tests and gather code coverage from command line. -Check out the [coverage documentation](userguide/coverage.md) for options of coverage reporting - - - - - - - diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css deleted file mode 100644 index 7f05ab831..000000000 --- a/docs/stylesheets/extra.css +++ /dev/null @@ -1,12 +0,0 @@ -[data-md-color-scheme="default"] { - --md-primary-fg-color: #2f8bff; - --md-accent-fg-color: #1f5db0; - --md-accent-fg-color--transparent: #1f5db0; -} - -[data-md-color-scheme="slate"] { - --md-hue: 200; - --md-primary-fg-color: #2f8bff; - --md-accent-fg-color: #1f5db0; - --md-accent-fg-color--transparent: #1f5db0; -} diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md deleted file mode 100644 index c0cbffb0e..000000000 --- a/docs/userguide/advanced_data_comparison.md +++ /dev/null @@ -1,518 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -# Advanced data comparison - -utPLSQL expectations incorporates advanced data comparison options when comparing compound data-types: - -- refcursor -- object type -- nested table and varray -- json data-types - -Advanced data-comparison options are available for the [`equal`](expectations.md#equal) and [`contain`](expectations.md#include--contain) matcher. - -Syntax - -``` - ut.expect( a_actual {data-type} ).to_( equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]); - ut.expect( a_actual {data-type} ).not_to( equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]) ); - ut.expect( a_actual {data-type} ).to_equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]); - ut.expect( a_actual {data-type} ).not_to_equal( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]] ); - ut.expect( a_actual {data-type} ).to_( contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]); - ut.expect( a_actual {data-type} ).not_to( contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]) ); - ut.expect( a_actual {data-type} ).to_contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]); - ut.expect( a_actual {data-type} ).not_to_contain( a_expected {data-type})[.extendend_option()[.extendend_option()[...]]]); -``` - -`extended_option` can be one of: - - - `include(a_items varchar2)` - item or comma separated list of items to include - - `exclude(a_items varchar2)` - item or comma separated list of items to exclude - - `include(a_items ut_varchar2_list)` - table of items to include - - `exclude(a_items ut_varchar2_list)` - table of items to exclude - - `unordered` - ignore order of data sets when comparing data. Default when comparing data-sets with `to_contain` - - `join_by(a_columns varchar2)` - column or comma separated list of columns to join two cursors by - - `join_by(a_columns ut_varchar2_list)` - table of columns to join two cursors by - - `unordered_columns` / `uc` - ignore the ordering of columns / attributes in compared data-sets. Column/attribute names will be used to identify data to be compared and the position will be ignored. - -Each item in the comma separated list can be: -- a column name of cursor to be compared -- an attribute name of object type to be compared -- an attribute name of object type within a table of objects to be compared -- Include and exclude option will not support implicit colum names that starts with single quota, or in fact any other special characters e.g. <, >, & - -Each element in `ut_varchar2_list` nested table can be an item or a comma separated list of items. - -When specifying column/attribute names, keep in mind that the names are **case sensitive**. - -## Excluding elements from data comparison - -Consider the following examples -```sql linenums="1" -declare - l_expected sys_refcursor; - l_actual sys_refcursor; -begin - open l_expected for select 'text' ignore_me, d.* from user_tables d; - open l_actual for select sysdate "ADate", d.* from user_tables d; - ut.expect( l_actual ).to_equal( l_expected ).exclude( 'IGNORE_ME,ADate' ); -end; -/ -declare - l_expected sys_refcursor; - l_actual sys_refcursor; -begin - open l_expected for select 'text' ignore_me, d.* from user_tables d where rownum = 1; - open l_actual for select sysdate "ADate", d.* from user_tables d; - ut.expect( l_actual ).to_contain( l_expected ).exclude( 'IGNORE_ME,ADate' ); -end; -/ -``` -Produces: -``` -SUCCESS - Actual: refcursor [ count = 23 ] was expected to equal: refcursor [ count = 23 ] - -SUCCESS - Actual: refcursor [ count = 23 ] was expected to contain: refcursor [ count = 1 ] -``` - -Columns 'ignore_me' and "ADate" will get excluded from data comparison. -The actual data is equal/contains expected, when those columns are excluded. - -**Note** ->This option is useful in scenarios, when you need to exclude incomparable/unpredictable column data like CREATE_DATE of a record that is maintained by default value on a table column. - -## Selecting columns for data comparison - -Consider the following example -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL from dual a connect by level < 4; - open l_actual for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL, a.* from all_objects a where rownum < 4; - ut.expect( l_actual ).to_equal( l_expected ).include( 'RN,A_Column,SOME_COL' ); -end; -/ -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL from dual a connect by level < 4; - open l_actual for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL, a.* from all_objects a where rownum < 6; - ut.expect( l_actual ).to_contain( l_expected ).include( 'RN,A_Column,SOME_COL' ); -end; -/ -``` -Produces: -``` -SUCCESS - Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ] - -SUCCESS - Actual: refcursor [ count = 5 ] was expected to contain: refcursor [ count = 3 ] -``` - -Only columns `RN`,`A_Column` and `SOME_COL ` will be included in data comparison. -The actual data is equal/contains expected, when only those columns are included. - -**Note** ->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. - -## Combining include/exclude options -You can chain the advanced options in an expectation and mix the `varchar2` with `ut_varchar2_list` arguments. -When doing so, the final list of items to include/exclude will be a concatenation of all items. - -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL from dual a connect by level < 4; - open l_actual for select rownum as rn, 'a' as "A_Column", 'Y' SOME_COL, a.* from all_objects a where rownum < 4; - ut.expect( l_actual ).to_equal( l_expected ) - .include( 'RN') - .include( ut_varchar2_list( 'A_Column', 'SOME_COL' ) ) - .exclude( 'SOME_COL' ); -end; -/ -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL from dual a connect by level < 4; - open l_actual for select rownum as rn, 'a' as "A_Column", 'Y' SOME_COL, a.* from all_objects a where rownum < 6; - ut.expect( l_actual ).to_contain( l_expected ) - .include( 'RN') - .include( ut_varchar2_list( 'A_Column', 'SOME_COL' ) ) - .exclude( 'SOME_COL' ); -end; -/ -``` - -Results: -``` -SUCCESS - Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ] - -SUCCESS - Actual: refcursor [ count = 5 ] was expected to contain: refcursor [ count = 3 ] -``` - -Example of `include / exclude` for anydata.convertCollection - -```sql linenums="1" -create or replace type person as object( - name varchar2(100), - age integer -) -/ -create or replace type people as table of person -/ - -declare - l_actual people := people(person('Matt',45)); - l_expected people :=people(person('Matt',47)); -begin - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include('NAME'); -end; - -declare - l_actual people := people(person('Matt',45)); - l_expected people :=people(person('Matt',47)); -begin - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).exclude('AGE'); -end; - -declare - l_actual people := people(person('Matt',45)); - l_expected people :=people(person('Matt',47)); -begin - ut3.ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)).include('AGE'); -end; -/ -``` - -Results: -``` -SUCCESS - Actual: ut3.people [ count = 1 ] was expected to equal: ut3.people [ count = 1 ] - -SUCCESS - Actual: ut3.people [ count = 1 ] was expected to equal: ut3.people [ count = 1 ] - -FAILURE - Actual: ut3.people [ count = 1 ] was expected to equal: ut3.people [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Actual: 45 - Row No. 1 - Expected: 47 - at "anonymous block", line 5 - -``` - -## Unordered - -Unordered option allows for quick comparison of two compound data types without need of ordering them in any way. - -Result of such comparison will be limited to only information about row existing or not existing in given set without actual information about exact differences. - -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for - select username, user_id from all_users - union all - select 'TEST' username, -600 user_id from dual - order by 1 desc; - open l_actual for - select username, user_id from all_users - union all - select 'TEST' username, -610 user_id from dual - order by 1 asc; - ut.expect( l_actual ).to_equal( l_expected ).unordered; -end; -/ -``` - -Above test will result in two differences of one row extra and one row missing. -``` -FAILURE - Actual: refcursor [ count = 29 ] was expected to equal: refcursor [ count = 29 ] - Diff: - Rows: [ 2 differences ] - Extra: TEST-610 - Missing: TEST-600 - at "anonymous block", line 15 -``` -**Note** -> Consider using `join_by( columns... )` over `unordered()` with the `equal` matcher. The `join_by` method is much faster at performing data comparison. -> -> The `contain` matcher is not considering the order of the compared data-sets. Using `unordered` makes no difference (it's default). - - -## Join By option - -The `join_by` syntax enables comparison of unordered compound data types by joining data using specified columns. - -You can join two compound data types by defining join column(s) that will be used to uniquely identify and compare data rows. -With this option, framework is able to identify which rows are missing, which are extra and which are different without need to have both cursors uniformly ordered. -When the specified join column(s) are not unique, join will partition set over rows with the same key and join on row number as well as given join key. -The extra or missing rows will be presented to user as well as all non-matching rows. - -Join by option can be used in conjunction with include or exclude options. -However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key, as the key was excluded. - -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for - select username, user_id from all_users - union all - select 'TEST' username, -600 user_id from dual - order by 1 desc; - open l_actual for - select username, user_id from all_users - union all - select 'TEST' username, -610 user_id from dual - order by 1 asc; - ut.expect( l_actual ).to_equal( l_expected ).join_by('USERNAME'); -end; -/ -``` - -Above test will result in a difference in row 'TEST' regardless of data order. -``` -FAILURE - Actual: refcursor [ count = 29 ] was expected to equal: refcursor [ count = 29 ] - Diff: - Rows: [ 1 differences ] - PK TEST - Actual: -610 - PK TEST - Expected: -600 - PK TEST - Extra: TEST-610 - at "anonymous block", line 15 -``` - -**Note** - -> When using `join_by`, the join column(s) are displayed first (as PK) to help you identify the mismatched rows/columns. - -You can use `join_by` syntax in combination with `contain` matcher. - -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_actual for select username, user_id from all_users; - open l_expected for - select username, user_id from all_users - union all - select 'TEST' username, -610 user_id from dual; - - ut.expect( l_actual ).to_contain( l_expected ).join_by('USERNAME'); -end; -/ -``` - -Above test will indicate that in actual data-set -```sql linenums="1" -FAILURE - Actual: refcursor [ count = 28 ] was expected to contain: refcursor [ count = 29 ] - Diff: - Rows: [ 1 differences ] - PK TEST - Missing: TEST-610 - at "anonymous block", line 11 -``` - -### Joining using multiple columns - -You can specify multiple columns in `join_by` - -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for - select username, user_id, created from all_users - order by 1 desc; - open l_actual for - select username, user_id, created from all_users - union all - select 'TEST' username, -610 user_id, sysdate from dual - order by 1 asc; - ut.expect( l_actual ).to_equal( l_expected ).join_by('USERNAME, USER_ID'); -end; -/ -``` - -Produces: -``` -FAILURE - Actual: refcursor [ count = 29 ] was expected to equal: refcursor [ count = 28 ] - Diff: - Rows: [ 1 differences ] - PK TEST-610 - Extra: TEST-6102019-07-11 - at "anonymous block", line 13 -``` - -### Joining using attributes of object in column list - -`join_by` allows for joining data by attributes of object from column list of the compared compound data types. - -To reference attribute as PK, use slash symbol `/` to separate nested elements. - -In the below example, cursors are joined using the `NAME` attribute of object in column `SOMEONE` - -```sql linenums="1" -create or replace type person as object( - name varchar2(100), - age integer -) -/ -create or replace type people as table of person -/ - -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for - select person('Jack',42) someone from dual union all - select person('Pat', 44) someone from dual union all - select person('Matt',45) someone from dual; - open l_actual for - select person('Matt',55) someone from dual union all - select person('Pat', 44) someone from dual; - ut.expect( l_actual ).to_equal( l_expected ).join_by( 'SOMEONE/NAME' ); -end; -/ -``` - -Produces: -``` -FAILURE - Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ] - Diff: - Rows: [ 2 differences ] - PK Matt - Actual: Matt55 - PK Matt - Actual: 55 - PK Matt - Expected: Matt45 - PK Matt - Expected: 45 - PK Jack - Missing: Jack42 - at "anonymous block", line 12 -``` - -**Note** -> `join_by` does not support joining on individual elements of nested table. You can still use data of the nested table as a PK value. -> When collection is referenced in `join_by`, test will fail with appropriate message, as it cannot perform a join. - -```sql linenums="1" -create or replace type person as object( - name varchar2(100), - age integer -) -/ -create or replace type people as table of person -/ - -create or replace package body test_join_by is - procedure test_join_by_collection_elem is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_expected for select people(person('Matt',45)) persons from dual; - open l_actual for select people(person('Matt',45)) persons from dual; - ut.expect( l_actual ).to_equal( l_expected ).join_by('PERSONS/PERSON/NAME'); - end; - -end; -/ -``` - -``` -FAILURE - Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] - Diff: - Unable to join sets: - Join key PERSONS/PERSON/NAME does not exists in expected - Join key PERSONS/PERSON/NAME does not exists in actual - Please make sure that your join clause is not refferring to collection element - - at "anonymous block", line 7 -``` - -**Note** ->`join_by` option is slower to process as it needs to perform a cursor join. It is still faster than the `unordered`. - -## Defining item lists in option - -You may provide items for `include`/`exclude`/`join_by` as a single varchar2 value containing comma-separated list of attributes. - -You may provide items for `include`/`exclude`/`join_by` as a a ut_varchar2_list of attributes. - -**Note** -- object type attributes are nested under `` element -- nested table and varray items type attributes are nested under `` elements - -Example of a valid parameter to include columns: `RN`, `A_Column`, `SOME_COL` in data comparison. -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL from dual a connect by level < 4; - open l_actual for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL, a.* from all_objects a where rownum < 4; - ut.expect( l_actual ).to_equal( l_expected ).include( 'RN,A_Column,SOME_COL' ); - open l_expected for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL from dual a connect by level < 4; - open l_actual for select rownum as rn, 'a' as "A_Column", 'x' SOME_COL, a.* from all_objects a where rownum < 4; - ut.expect( l_actual ).to_equal( l_expected ).include( ut_varchar2_list( 'RN', 'A_Column', 'SOME_COL' ) ); -end; -/ -``` - -``` -SUCCESS - Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ] -SUCCESS - Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ] -``` - -## Unordered columns / uc option - -If you need to perform data comparison of compound data types without strictly depending on column order in the returned result-set, use the `unordered_columns` option. -Shortcut name `uc` is also available for that option. - -Expectations that compare compound data type data with `unordered_columns` option, will not fail when columns are ordered differently. - -This option can be useful whn we have no control over the ordering of the column or the column order is not of importance from testing perspective. - -```sql linenums="1" -declare - 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 object_type, owner, object_name from all_objects where owner = user - and rownum < 20; - - --Assert - ut.expect(l_actual).to_contain(l_expected).unordered_columns(); -end; -/ -``` - -Produces: -``` -SUCCESS - Actual: refcursor [ count = 348 ] was expected to contain: refcursor [ count = 19 ] -``` diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md deleted file mode 100644 index 3dc42e429..000000000 --- a/docs/userguide/annotations.md +++ /dev/null @@ -1,2203 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -Annotations are used to configure tests and suites in a declarative way similar to modern OOP languages. This way, test configuration is stored along with the test logic inside the test package. -No additional configuration files or tables are needed for test cases. The annotation names are based on popular testing frameworks such as JUnit. -The framework runner searches for all the suitable annotated packages, automatically configures suites, forms the suite hierarchy, executes it and reports results in specified formats. - -Annotation is defined by: - -- single line comment `--` (double hyphen) -- followed directly by a `%` (percent) -- followed by annotation name -- followed by optional annotation text placed in single brackets. - -All text between first opening bracket and last closing bracket in annotation line is considered to be annotation text - -For example `--%suite(The name of my test suite)` represents `suite` annotation with `The name of my test suite` as annotation text. - -utPLSQL interprets the whole line of annotation and will treat text from the first opening bracket in the line to the last closing bracket in that line as annotation text - -In below example we have a `suite` annotation with `Stuff) -- we should name this ( correctly ` as the annotation text - -`--%suite(Stuff) -- we should name this ( correctly )` - -Do not place comments within annotation line to avoid unexpected behaviors. - -**Note:** ->Annotations are interpreted only in the package specification and are case-insensitive. We strongly recommend using lower-case annotations as described in this documentation. - -There are two distinct types of annotations, identified by their location in package. -- package annotations -- procedure annotations - -### Procedure level annotations - -Annotation placed directly before a procedure (`--%test`, `--%beforeall`, `--%beforeeach` etc.). -There **can not** be any empty lines or comments between annotation line and procedure line. -There can be many annotations for a procedure. - -Valid procedure annotations example: -```sql linenums="1" -package test_package is - --%suite - - - --%test() - --%disabled - procedure my_first_procedure; - - $if dbms_db_version.version >= 12 $then --This is ok - annotation before procedure - --%test() - procedure my_first_procedure; - $end - - --A comment goes before annotations - --%test() - procedure my_first_procedure; -end; -``` - -Invalid procedure annotations examples: -```sql linenums="1" -package test_package is - --%suite - - --%test() --This is wrong as there is an empty line between procedure and annotation - - procedure my_first_procedure; - - --%test() - --This is wrong as there is a comment line between procedure and annotation - procedure proc1; - - --%test() --This is wrong as there is a compiler directive between procedure and annotation - $if dbms_db_version.version >= 12 $then - procedure proc_12; - $end - - --%test() - -- procedure another_proc; - /* The above is wrong as the procedure is commented out - and annotation is not procedure annotation anymore */ - -end; -``` - -### Package level annotations - -Those annotations placed at any place in package except directly before procedure (`--%suite`, `--%suitepath` etc.). -We strongly recommend putting package level annotations at the very top of package except for the `--%context` annotations (described below) - -Valid package annotations example: -```sql linenums="1" -package test_package is - - --%suite - - --%suitepath(org.utplsql.example) - - --%beforeall(some_package.some_procedure) - - --%context - - --%test() - procedure my_first_procedure; - --%endcontext -end; -``` - -Invalid package annotations examples: -```sql linenums="1" -package test_package is - --%suite --This is wrong as suite annotation is not a procedure annotation - procedure irrelevant; - - --%context --This is wrong as there is no empty line between package level annotation and procedure level annotation - --%test() - procedure my_first_procedure; - -end; -``` - -## Supported annotations - -| Annotation | Level | Description | -|------------------------------------------------------------|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `--%suite( )` | Package | Mandatory. Marks package as a test suite. Optional suite description can be provided (see `displayname`). | -| `--%suitepath( )` | Package | Similar to java package. The annotation allows logical grouping of suites into hierarchies. | -| `--%displayname( )` | Package/procedure | Human-readable and meaningful description of a context/suite/test. Overrides the `` provided with `suite`/`test`/`context` annotation. This annotation is redundant and might be removed in future releases. | -| `--%test( )` | Procedure | Denotes that the annotated procedure is a unit test procedure. Optional test description can be provided (see `displayname`). | -| `--%throws( [,...] )` | Procedure | Denotes that the annotated test procedure must throw one of the exceptions provided. Supported forms of exceptions are: numeric literals, numeric constant names, exception constant names, predefined Oracle exception names. | -| `--%beforeall` | Procedure | Denotes that the annotated procedure should be executed once before all elements of the suite. | -| `--%beforeall( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed once before all elements of the suite. | -| `--%afterall` | Procedure | Denotes that the annotated procedure should be executed once after all elements of the suite. | -| `--%afterall( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed once after all elements of the suite. | -| `--%beforeeach` | Procedure | Denotes that the annotated procedure should be executed before each `%test` procedure in the suite. | -| `--%beforeeach( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed before each `%test` procedure in the suite. | -| `--%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` procedure in the suite. | -| `--%aftereach( [[.].][,...] )` | Package | Denotes that the mentioned procedure(s) should be executed after each `%test` procedure in the suite. | -| `--%beforetest( [[.].][,...] )` | Procedure | Denotes that mentioned procedure(s) should be executed before the annotated `%test` procedure. | -| `--%aftertest( [[.].][,...] )` | Procedure | Denotes that mentioned procedure(s) should be executed after the annotated `%test` procedure. | -| `--%rollback( )` | Package/procedure | Defines transaction control. Supported values: `auto`(default) - a savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) | -| `--%disabled( )` | Package/procedure | Used to disable a suite, whole context or a test. Disabled suites/contexts/tests do not get executed, they are however marked and reported as disabled in a test run. The reason that will be displayed next to disabled tests is decided based on hierarchy suites -> context -> test | -| `--%context( )` | Package | Denotes start of a named context (sub-suite) in a suite package an optional description for context can be provided. | -| `--%name( )` | Package | Denotes name for a context. Must be placed after the context annotation and before start of nested context. | -| `--%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 - -The `--%suite` annotation denotes PLSQL package as a unit test suite. -It accepts an optional description that will be visible when running the tests. -When description is not provided, package name is displayed on report. - -**Note** ->Package is considered a test-suite only when package specification contains the `--%suite` annotation at the package level. -> ->Some annotations like `--%suite`, `--%test` and `--%displayname` accept parameters. The parameters for annotations need to be placed in brackets. -Values for parameters should be provided without any quotation marks. -If the parameters are placed without brackets or with incomplete brackets, they will be ignored. -> ->Example: `--%suite(The name of suite without closing bracket` ->Example: `--%suite The name of suite without brackets` - - -Suite package without description. -```sql linenums="1" -create or replace package test_package as - --%suite -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -test_package - -Finished in .002415 seconds -0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -Suite package with description. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - -Finished in .001646 seconds -0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -When multiple `--%suite` annotations are specified in package, the first annotation will be used and a warning message will appear indicating duplicate annotation. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - --%suite(Bad annotation) -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - - -Warnings: - - 1) test_package - Duplicate annotation "--%suite". Annotation ignored. - at "TESTS_OWNER.TEST_PACKAGE", line 3 - -Finished in .003318 seconds -0 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s) -``` - -When `--%suite` annotation is bound to procedure, it is ignored and results in package not getting recognized as test suite. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - procedure some_proc; -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -ORA-20204: Suite package TESTS_OWNER.test_package not found -ORA-06512: at "UT3.UT_RUNNER", line 106 -ORA-06512: at "UT3.UT", line 115 -ORA-06512: at "UT3.UT", line 306 -ORA-06512: at "UT3.UT", line 364 -ORA-06512: at line 1 -``` - - -### Test - -The `--%test` annotation denotes procedure withing test suite as a unit test. -It accepts an optional description that will be reported when the test is executed. -When description is not provided, procedure name is displayed on report. - - -If `--%test` raises an unhandled exception the following will happen: -- the test will be marked as errored and exception stack trace will be captured and reported -- the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test -- the `--%afterall` procedures **will be executed** -- test execution will continue uninterrupted for rest of the suite - -Test procedure without description. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test - procedure some_test; -end; -/ -create or replace package body test_package as - procedure some_test is begin null; end; -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - some_test [.003 sec] - -Finished in .004109 seconds -1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -Test procedure with description. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - procedure some_test; -end; -/ -create or replace package body test_package as - procedure some_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [.005 sec] - -Finished in .006828 seconds -1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -When multiple `--%test` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - --%test(Duplicate description) - procedure some_test; -end; -/ -create or replace package body test_package as - procedure some_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [.007 sec] - - -Warnings: - - 1) test_package - Duplicate annotation "--%test". Annotation ignored. - at "TESTS_OWNER.TEST_PACKAGE.SOME_TEST", line 5 - -Finished in .008815 seconds -1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s) -``` - -### Disabled -Marks annotated suite package or test procedure as disabled. -You can provide the reason why the test is disabled that will be displayed in output. - -Disabling suite. -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - --%disabled(Reason for disabling suite) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; -end; -/ -create or replace package body test_package as - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [0 sec] (DISABLED - Reason for disabling suite) - Description of another behavior [0 sec] (DISABLED - Reason for disabling suite) - -Finished in .001441 seconds -2 tests, 0 failed, 0 errored, 2 disabled, 0 warning(s) -``` - -Disabling the context(s). -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%context(Context1) - - --%test(Description of tested behavior) - procedure some_test; - - --%endcontext - - --%context(Context2) - - --%disabled(Reason for disabling context2) - - --%test(Description of another behavior) - procedure other_test; - - --%endcontext -end; -/ -create or replace package body test_package as - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Context1 - Description of tested behavior [.002 sec] - Context2 - Description of another behavior [0 sec] (DISABLED - Reason for disabling context2) - -Finished in .005079 seconds -2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) -``` - -Disabling individual test(s). -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - --%disabled(Reason for disabling test) - procedure other_test; -end; -/ -create or replace package body test_package as - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [.004 sec] - Description of another behavior [0 sec] (DISABLED - Reason for disabling test) - -Finished in .005868 seconds -2 tests, 0 failed, 0 errored, 1 disabled, 0 warning(s) -``` - -### Beforeall - -There are two possible ways to use the `--%beforeall` annotation. - -As a procedure level annotation: -```sql linenums="1" ---%suite(Some test suite) - ---%beforeall -procedure to_be_executed_before_all; - ---%test -procedure some_test; -``` -Marks annotated procedure to be executed before all test procedures in a suite. - -As a package level annotation (not associated with any procedure). -```sql linenums="1" ---%suite(Some test suite) - ---%beforeall(to_be_executed_before_all, other_package.some_setup) - ---%test -procedure some_test; - -procedure to_be_executed_before_all; - -``` -Indicates that the procedure(s) mentioned as the annotation parameter are to be executed before all test procedures in a suite. - - -If `--%beforeall` raises an exception, suite content cannot be safely executed as the setup was not executed successfully for the suite. - -If `--%beforeall` raises an exception the following will happen: - -- the `--%beforeall` procedures that follow the failed one, **will not be executed** -- all `--%test` procedures and their `--%beforeeach`, `--%aftereach`, `--%beforetest` and `--%aftertest` procedures within suite package **will not be executed** -- all `--%test` procedures **will be marked as failed** -- the `--%afterall` procedures **will be executed** -- test execution will continue uninterrupted for other suite packages - -When multiple `--%beforeall` procedures are defined in a suite package, all of them will be executed before invoking any test. - -For multiple `--%beforeall` procedures order of execution is defined by annotation position in the package specification. - -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; - - --%beforeall - procedure setup_stuff; - -end; -/ -create or replace package body test_package as - procedure setup_stuff is - begin - dbms_output.put_line('--- SETUP_STUFF invoked ---'); - end; - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` - -``` -Tests for a package - --- SETUP_STUFF invoked --- - Description of tested behavior [.004 sec] - Description of another behavior [.003 sec] - -Finished in .012292 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -In the below example a combination pacakge and procedure level `--%beforeall` annotations is used. -The order of execution of the beforeall procedures is determined by the annotation position in package. -All of the `--%beforeall` procedures get invoked before any test is executed in a suite. -```sql linenums="1" - create or replace package test_package as - --%suite(Tests for a package) - - --%beforeall(initial_setup,test_package.another_setup) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; - - --%beforeall - procedure next_setup; - - --%beforeall(one_more_setup) - - procedure another_setup; - procedure one_more_setup; - procedure initial_setup; - - end; - / - create or replace package body test_package as - procedure one_more_setup is - begin - dbms_output.put_line('--- ONE_MORE_SETUP invoked ---'); - end; - - procedure next_setup is - begin - dbms_output.put_line('--- NEXT_SETUP invoked ---'); - end; - - procedure another_setup is - begin - dbms_output.put_line('--- ANOTHER_SETUP invoked ---'); - end; - - procedure initial_setup is - begin - dbms_output.put_line('--- INITIAL_SETUP invoked ---'); - end; - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; - end; - / -``` - -```sql linenums="1" - exec ut.run('test_package'); -``` - -``` -Tests for a package - --- INITIAL_SETUP invoked --- - --- ANOTHER_SETUP invoked --- - --- NEXT_SETUP invoked --- - --- ONE_MORE_SETUP invoked --- - Description of tested behavior [.003 sec] - Description of another behavior [.002 sec] - -Finished in .018944 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -When multiple `--%beforeall` annotations are specified for a procedure, the first annotation will be used and a warning message will appear indicating duplicate annotation. -When procedure is annotated as both `--%beforeall` and `--%test`, the procedure will become a test and a warning message will appear indicating invalid annotation combination. -```sql linenums="1" - create or replace package test_package as - --%suite(Tests for a package) - - --%beforeall - --%beforeall - procedure initial_setup; - - --%test(Description of tested behavior) - --%beforeall - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; - - end; - / - create or replace package body test_package as - - procedure initial_setup is - begin - dbms_output.put_line('--- INITIAL_SETUP invoked ---'); - end; - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; - end; - / -``` - -```sql linenums="1" - exec ut.run('test_package'); -``` - -``` -Tests for a package - --- INITIAL_SETUP invoked --- - Description of tested behavior [.003 sec] - Description of another behavior [.004 sec] - - -Warnings: - - 1) test_package - Duplicate annotation "--%beforeall". Annotation ignored. - at "UT3_TESTER.TEST_PACKAGE.INITIAL_SETUP", line 5 - 2) test_package - Annotation "--%beforeall" cannot be used with annotation: "--%test" - at "UT3_TESTER.TEST_PACKAGE.SOME_TEST", line 9 - -Finished in .012158 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 2 warning(s) -``` - - -### Afterall - -There are two possible ways to use the `--%afterall` annotation. - -As a procedure level annotation: -```sql linenums="1" ---%suite(Some test suite) - ---%afterall -procedure to_be_executed_after_all; - ---%test -procedure some_test; -``` -Marks annotated procedure to be executed after all test procedures in a suite. - -As a package level annotation (not associated with any procedure). -```sql linenums="1" ---%suite(Some test suite) - ---%afterall(to_be_executed_after_all, other_package.some_cleanup) - ---%test -procedure some_test; - -procedure to_be_executed_after_all; -``` - -Indicates that the procedure(s) mentioned as the annotation parameter are to be executed after all test procedures in a suite. - -If `--%afterall` raises an exception the following will happen: - -- a warning will be raised, indicating that `--%afterall` procedure has failed -- execution will continue uninterrupted for rest of the suite - -If `--%afterall` raises an exception, it can have negative impact on other tests, as the environment was not cleaned-up after the tests. -This however doesn't have direct impact on test execution within current suite, as the tests are already complete by the time `--%afterall` is called. - -When multiple `--%afterall` procedures are defined in a suite, all of them will be executed after invoking all tests from the suite. - -For multiple `--%afterall` procedures order of execution is defined by annotation position in the package specification. - -All rules defined for `--%beforeall` also apply for `--%afterall` annotation. See [beforeall](#Beforeall) for more details. - -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; - - --%afterall - procedure cleanup_stuff; - -end; -/ -create or replace package body test_package as - procedure cleanup_stuff is - begin - dbms_output.put_line('---CLEANUP_STUFF invoked ---'); - end; - - procedure some_test is begin null; end; - - procedure other_test is begin null; end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` - -``` -Tests for a package - Description of tested behavior [.003 sec] - Description of another behavior [.005 sec] - ---CLEANUP_STUFF invoked --- - -Finished in .014161 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -### Beforeeach - -The procedure annotated as `--%beforeeach` is getting executed before each test in a suite. -That means that the procedure will be executed as many times as there are test in suite package. - -There are two possible ways to use the `--%beforeeach` annotation. - -As a procedure level annotation: -```sql linenums="1" ---%suite(Some test suite) - ---%beforeeach -procedure to_be_executed_before_each; - ---%test -procedure some_test; -``` -Marks annotated procedure to be executed before each test procedures in a suite. - -As a package level annotation (not associated with any procedure). -```sql linenums="1" ---%suite(Some test suite) - ---%beforeeach(to_be_executed_before_each, other_package.some_setup) - ---%test -procedure some_test; - -procedure to_be_executed_before_each; -``` - -Indicates that the procedure(s) mentioned as the annotation parameter are to be executed before each test procedure in a suite. - - -If a test is marked as disabled the `--%beforeeach` procedure is not invoked for that test. - -If `--%beforeeach` raises an unhandled exception the following will happen: - -- the following `--%beforeeach` as well as all `--%beforetest` for that test **will not be executed** -- the test will be marked as errored and exception stack trace will be captured and reported -- the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test -- the `--%afterall` procedures **will be executed** -- test execution will continue uninterrupted for rest of the suite - -As a rule, the `--%beforeeach` execution gets aborted if preceding `--%beforeeach` failed. - -When multiple `--%beforeeach` procedures are defined in a suite, all of them will be executed before invoking each test. - -For multiple `--%beforeeach` procedures order of execution is defined by annotation position in the package specification. - -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; - - --%beforeeach - procedure setup_for_test; - - --%beforeall - procedure setup_stuff; -end; -/ -create or replace package body test_package as - procedure setup_stuff is - begin - dbms_output.put_line('---SETUP_STUFF invoked ---'); - end; - - procedure setup_for_test is - begin - dbms_output.put_line('---SETUP_FOR_TEST invoked ---'); - end; - - procedure some_test is - begin - dbms_output.put_line('---SOME_TEST invoked ---'); - end; - - procedure other_test is - begin - dbms_output.put_line('---OTHER_TEST invoked ---'); - end; -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_package'); -``` - -``` -Tests for a package - ---SETUP_STUFF invoked --- - Description of tested behavior [.004 sec] - ---SETUP_FOR_TEST invoked --- - ---SOME_TEST invoked --- - Description of another behavior [.006 sec] - ---SETUP_FOR_TEST invoked --- - ---OTHER_TEST invoked --- - -Finished in .014683 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -See [beforeall](#Beforeall) for more examples. - -### Aftereach - -Marks annotated procedure to be executed after each test procedure in a suite. - -The procedure annotated as `--%aftereach` is getting executed after each test in a suite. -That means that the procedure will be executed as many times as there are test in suite package. - -There are two possible ways to use the `--%aftereach` annotation. - -As a procedure level annotation: -```sql linenums="1" ---%suite(Some test suite) - ---%aftereach -procedure to_be_executed_after_each; - ---%test -procedure some_test; -``` -Marks annotated procedure to be executed after each test procedures in a suite. - -As a package level annotation (not associated with any procedure). -```sql linenums="1" ---%suite(Some test suite) - ---%aftereach(to_be_executed_after_each, other_package.some_setup) - ---%test -procedure some_test; - -procedure to_be_executed_after_each; -``` - -Indicates that the procedure(s) mentioned as the annotation parameter are to be executed after each test procedure in a suite. - -If a test is marked as disabled the `--%aftereach` procedure is not invoked for that test. - -If `--%aftereach` raises an unhandled exception the following will happen: - -- the test will be marked as errored and exception stack trace will be captured and reported -- the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test -- the `--%afterall` procedures **will be executed** -- test execution will continue uninterrupted for rest of the suite - -When multiple `--%aftereach` procedures are defined in a suite, all of them will be executed after invoking each test. - -For multiple `--%aftereach` procedures order of execution is defined by the annotation position in the package specification. - -As a rule, the `--%aftereach` gets executed even if the associated `--%beforeeach`, `--%beforetest`, `--%test` or other `--%aftereach` procedures have raised unhandled exceptions. - -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - procedure some_test; - - --%test(Description of another behavior) - procedure other_test; - - --%aftereach - procedure cleanup_for_test; - - --%afterall - procedure cleanup_stuff; -end; -/ -create or replace package body test_package as - procedure cleanup_stuff is - begin - dbms_output.put_line('---CLEANUP_STUFF invoked ---'); - end; - - procedure cleanup_for_test is - begin - dbms_output.put_line('---CLEANUP_FOR_TEST invoked ---'); - end; - - procedure some_test is - begin - dbms_output.put_line('---SOME_TEST invoked ---'); - end; - - procedure other_test is - begin - dbms_output.put_line('---OTHER_TEST invoked ---'); - end; -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [.006 sec] - ---SOME_TEST invoked --- - ---CLEANUP_FOR_TEST invoked --- - Description of another behavior [.006 sec] - ---OTHER_TEST invoked --- - ---CLEANUP_FOR_TEST invoked --- - ---CLEANUP_STUFF invoked --- - -Finished in .018115 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -See [beforeall](#Beforeall) for more examples. - -### Beforetest - -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. - -If a test is marked as disabled the `--%beforetest` procedures are not invoked for that test. - -If `--%beforetest` raises an unhandled exception the following will happen: - -- the following `--%beforetest` for that test **will not be executed** -- the test will be marked as errored and exception stack trace will be captured and reported -- the `--%aftertest`, `--%aftereach` procedures **will be executed** for the errored test -- the `--%afterall` procedures **will be executed** -- test execution will continue uninterrupted for rest of the suite - -When multiple `--%beforetest` procedures are defined for a test, all of them will be executed before invoking the test. - -The order of execution for `--%beforetest` procedures is defined by: - -- position of procedure on the list within single annotation -- annotation position - -As a rule, the `--%beforetest` execution gets aborted if preceding `--%beforeeach` or `--%beforetest` failed. - -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - --%beforetest(test_package.setup_for_a_test) - --%beforetest(another_setup_for_a_test) - procedure some_test; - - --%test(Description of another behavior) - --%beforetest(test_package.setup_for_a_test, another_setup_for_a_test) - procedure other_test; - - procedure another_setup_for_a_test; - - procedure setup_for_a_test; - -end; -/ -create or replace package body test_package as - procedure setup_for_a_test is - begin - dbms_output.put_line('---SETUP_FOR_A_TEST invoked ---'); - end; - - procedure another_setup_for_a_test is - begin - dbms_output.put_line('---ANOTHER_SETUP_FOR_A_TEST invoked ---'); - end; - - procedure some_test is - begin - dbms_output.put_line('---SOME_TEST invoked ---'); - end; - - procedure other_test is - begin - dbms_output.put_line('---OTHER_TEST invoked ---'); - end; -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [.008 sec] - ---SETUP_FOR_A_TEST invoked --- - ---ANOTHER_SETUP_FOR_A_TEST invoked --- - ---SOME_TEST invoked --- - Description of another behavior [.005 sec] - ---SETUP_FOR_A_TEST invoked --- - ---ANOTHER_SETUP_FOR_A_TEST invoked --- - ---OTHER_TEST invoked --- - -Finished in .015185 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - - -### Aftertest - -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. - -If `--%aftertest` raises an unhandled exception the following will happen: - -- the test will be marked as errored and exception stack trace will be captured and reported -- the following `--%aftertest` and all `--%aftereach` procedures **will be executed** for the errored test -- the `--%afterall` procedures **will be executed** -- test execution will continue uninterrupted for rest of the suite - -When multiple `--%aftertest` procedures are defined for a test, all of them will be executed after invoking the test. - -The order of execution for `--%aftertest` procedures is defined by: - -- position of procedure on the list within single annotation -- annotation position - -As a rule, the `--%aftertest` gets executed even if the associated `--%beforeeach`, `--%beforetest`, `--%test` or other `--%aftertest` procedures have raised unhandled exceptions. - -```sql linenums="1" -create or replace package test_package as - --%suite(Tests for a package) - - --%test(Description of tested behavior) - --%aftertest(test_package.cleanup_for_a_test) - --%aftertest(another_cleanup_for_a_test) - procedure some_test; - - --%test(Description of another behavior) - --%aftertest(test_package.cleanup_for_a_test, another_cleanup_for_a_test) - procedure other_test; - - procedure another_cleanup_for_a_test; - - procedure cleanup_for_a_test; - -end; -/ -create or replace package body test_package as - procedure cleanup_for_a_test is - begin - dbms_output.put_line('---CLEANUP_FOR_A_TEST invoked ---'); - end; - - procedure another_cleanup_for_a_test is - begin - dbms_output.put_line('---ANOTHER_CLEANUP_FOR_A_TEST invoked ---'); - end; - - procedure some_test is - begin - dbms_output.put_line('---SOME_TEST invoked ---'); - end; - - procedure other_test is - begin - dbms_output.put_line('---OTHER_TEST invoked ---'); - end; -end; -/ -``` -```sql linenums="1" -exec ut.run('test_package'); -``` -``` -Tests for a package - Description of tested behavior [.008 sec] - ---SOME_TEST invoked --- - ---CLEANUP_FOR_A_TEST invoked --- - ---ANOTHER_CLEANUP_FOR_A_TEST invoked --- - Description of another behavior [.006 sec] - ---OTHER_TEST invoked --- - ---CLEANUP_FOR_A_TEST invoked --- - ---ANOTHER_CLEANUP_FOR_A_TEST invoked --- - -Finished in .016873 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -### Context - -In most of the cases, the code to be tested is consisting of PLSQL packages containing procedures and functions. -When creating test suites, it's quite common to maintain `one to one` relationship between test suite packages and tested code. - -When it comes to test procedures themselves, it is best practice to have one test procedure for one tested behavior of the code that is tested. -The relationship between test procedure and tested code will be therefore `many to one` or `many to many` in most of the cases. - -With this comes a challenge. How to group tests, related to one tested behavior, so that it is obvious that they relate to the same thing. - -This is where utPLSQL contexts come handy. - -Contexts allow for creating sub-suites within a suite package and they allow for grouping of tests that are somehow related. - -In essence, context behaves like a suite within a suite. - -Context have following characteristics: - -- context starts with the `--%context` annotation and ends with `--%endcontext`. Everything placed between those two annotations belongs to that context -- can have a description provided as parameter for example `--%context(Some interesting stuff)`. -- can have a name provided with `--%name` annotation. This is different than with `suite` and `test` annotations, where name is taken from `package/procedure` name. -- contexts can be nested, you can place a context inside another context -- when no name is provided for context, the context is named `context_N` where `N` is the number of the context in suite or parent context. -- context name must be unique within it's parent (suite / parent context) -- if context name is not unique within it's parent, context and it's entire content is excluded from execution -- context name should not contain spaces or special characters -- context name cannot contain a `.` (full stop/period) character -- suite/context can have multiple nested sibling contexts in it -- contexts can have their own `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures -- `--%beforeall`, `--%beforeeach`, `--%afterall` and `--%aftereach` procedures defined at ancestor level, propagate to context -- if `--%endcontext` is missing for a context, the context spans to the end of package specification - -The below example illustrates usage of `--%context` for separating tests for individual procedures of package. - -Sample tables and code -```sql linenums="1" -create table rooms ( - room_key number primary key, - name varchar2(100) not null -); - -create table room_contents ( - contents_key number primary key, - room_key number not null, - name varchar2(100) not null, - create_date timestamp default current_timestamp not null, - constraint fk_rooms foreign key (room_key) references rooms (room_key) -); - -create or replace package rooms_management is - - procedure remove_rooms_by_name( a_name rooms.name%type ); - - procedure add_rooms_content( - a_room_name rooms.name%type, - a_content_name room_contents.name%type - ); - -end; -/ - -create or replace package body rooms_management is - procedure remove_rooms_by_name( a_name rooms.name%type ) is - begin - if a_name is null then - raise program_error; - end if; - delete from rooms where name like a_name; - end; - - procedure add_rooms_content( - a_room_name rooms.name%type, - a_content_name room_contents.name%type - ) is - l_room_key rooms.room_key%type; - begin - - select room_key into l_room_key - from rooms where name = a_room_name; - - insert into room_contents - (contents_key, room_key, name) - select nvl(max(contents_key)+1, 1) as contents_key, - l_room_key, - a_content_name - from room_contents; - end; -end; -/ -``` - -Below test suite defines: - -- `--%beforeall` outside of context, that will be executed before all tests -- `--%context(remove_rooms_by_name)` to group tests related to `remove_rooms_by_name` functionality -- `--%context(add_rooms_content)` to group tests related to `add_rooms_content` functionality - -```sql linenums="1" -create or replace package test_rooms_management is - - gc_null_value_exception constant integer := -1400; - --%suite(Rooms management) - - --%beforeall - procedure setup_rooms; - - - --%context(remove_rooms_by_name) - --%displayname(Remove rooms by name) - - --%test(Removes a room without content in it) - procedure remove_empty_room; - - --%test(Raises exception when null room name given) - --%throws(-6501) - procedure null_room_name; - - --%endcontext - - --%context(add_rooms_content) - --%displayname(Add content to a room) - - --%test(Fails when room name is not valid) - --%throws(no_data_found) - procedure fails_on_room_name_invalid; - - --%test(Fails when content name is null) - --%throws(test_rooms_management.gc_null_value_exception) - procedure fails_on_content_null; - - --%test(Adds a content to existing room) - procedure add_content_success; - - --%endcontext - -end; -/ - -create or replace package body test_rooms_management is - - procedure setup_rooms is - begin - insert all - into rooms values(1, 'Dining Room') - into rooms values(2, 'Living Room') - into rooms values(3, 'Bathroom') - select 1 from dual; - - insert all - into room_contents values(1, 1, 'Table', sysdate) - into room_contents values(3, 1, 'Chair', sysdate) - into room_contents values(4, 2, 'Sofa', sysdate) - into room_contents values(5, 2, 'Lamp', sysdate) - select 1 from dual; - - dbms_output.put_line('---SETUP_ROOMS invoked ---'); - end; - - procedure remove_empty_room is - l_rooms_not_named_b sys_refcursor; - l_remaining_rooms sys_refcursor; - begin - open l_rooms_not_named_b for select * from rooms where name not like 'B%'; - - rooms_management.remove_rooms_by_name('B%'); - - open l_remaining_rooms for select * from rooms; - ut.expect( l_remaining_rooms ).to_equal(l_rooms_not_named_b); - end; - - procedure room_with_content is - begin - rooms_management.remove_rooms_by_name('Living Room'); - end; - - procedure null_room_name is - begin - --Act - rooms_management.remove_rooms_by_name(NULL); - --Assert done by --%throws annotation - end; - - procedure fails_on_room_name_invalid is - begin - --Act - rooms_management.add_rooms_content('bad room name','Chair'); - --Assert done by --%throws annotation - end; - - procedure fails_on_content_null is - begin - --Act - rooms_management.add_rooms_content('Dining Room',null); - --Assert done by --%throws annotation - end; - - procedure add_content_success is - l_expected room_contents.name%type; - l_actual room_contents.name%type; - begin - --Arrange - l_expected := 'Table'; - - --Act - rooms_management.add_rooms_content( 'Dining Room', l_expected ); - --Assert - select name into l_actual from room_contents - where contents_key = (select max(contents_key) from room_contents); - - ut.expect( l_actual ).to_equal( l_expected ); - end; - -end; -/ -``` - -When the tests are executed -```sql linenums="1" -exec ut.run('test_rooms_management'); -``` -The following report is displayed -``` -Rooms management - ---SETUP_ROOMS invoked --- - remove_rooms_by_name - Removes a room without content in it [.015 sec] - Raises exception when null room name given [.002 sec] - add_rooms_content - Fails when room name is not valid [.003 sec] - Fails when content name is null [.003 sec] - Adds a content to existing room [.003 sec] - -Finished in .035261 seconds -5 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -Example of nested contexts test suite specification. -*Source - [slide 145](https://www.slideshare.net/Kevlin/structure-and-interpretation-of-test-cases/145?src=clipshare) of Structure and Interpretation of Test Cases by Kevlin Henney* - -```sql linenums="1" -create or replace package queue_spec as - --%suite(Queue specification) - - --%context(A new queue) - - --%test(Is empty) - procedure is_empty; - --%test(Preserves positive bounding capacity) - procedure positive_bounding_capacity; - --%test(Cannot be created with non positive bounding capacity) - procedure non_positive_bounding_cap; - --%endcontext - --%context(An empty queue) - - --%test(Dequeues an empty value) - procedure deq_empty_value; - --%test(Remains empty when null enqueued) - procedure empty_with_null_enq; - --%test(Becomes non empty when non null value enqueued) - procedure non_empty_after_enq; - --%endcontext - --%context(A non empty queue) - - --%context(that is not full) - - --%test(Becomes longer when non null value enqueued) - procedure grow_on_enq_non_null; - --%test(Becomes full when enqueued up to capacity) - procedure full_on_enq_to_cap; - --%endcontext - --%context(that is full) - - --%test(Ignores further enqueued values) - procedure full_ignore_enq; - --%test(Becomes non full when dequeued) - procedure non_full_on_deq; - --%endcontext - - --%test(Dequeues values in order enqueued) - procedure dequeue_ordered; - --%test(Remains unchanged when null enqueued) - procedure no_change_on_null_enq; - --%endcontext -end; -``` - - -When such specification gets executed `ut.run('queue_spec'')` (without body created) you will see the nesting of tests within contexts. -``` -Queue specification - An empty queue - Dequeues an empty value [.014 sec] (FAILED - 1) - Remains empty when null enqueued [.004 sec] (FAILED - 2) - Becomes non empty when non null value enqueued [.005 sec] (FAILED - 3) - A non empty queue - that is not full - Becomes longer when non null value enqueued [.005 sec] (FAILED - 4) - Becomes full when enqueued up to capacity [.005 sec] (FAILED - 5) - That is full - Ignores further enqueued values [.004 sec] (FAILED - 6) - Becomes non full when dequeued [.005 sec] (FAILED - 7) - Dequeues values in order enqueued [.006 sec] (FAILED - 8) - Remains unchanged when null enqueued [.004 sec] (FAILED - 9) - A new queue - Is empty [.007 sec] (FAILED - 10) - Preserves positive bounding capacity [.006 sec] (FAILED - 11) - Cannot be created with non positive bounding capacity [.005 sec] (FAILED - 12) -Failures: - 1) deq_empty_value - ORA-04067: not executed, package body "UT3.QUEUE_SPEC" does not exist - ORA-06508: PL/SQL: could not find program unit being called: "UT3.QUEUE_SPEC" - ORA-06512: at line 6 -... -Finished in .088573 seconds -12 tests, 0 failed, 12 errored, 0 disabled, 0 warning(s) -``` - -Suite nesting allows for organizing tests into human-readable specification of behavior. - -### Name -The `--%name` annotation is currently only used only for naming a context. -If a context doesn't have explicit name specified, then the name is given automatically by framework. - -The automatic name will be `context_#n` where `n` is a context number within a suite/parent context. - -The `--%name` can be useful when you would like to run only a specific context or its items by `suitepath`. - -Consider the below example. - -```sql linenums="1" -create or replace package queue_spec as - --%suite(Queue specification) - - --%context(A new queue) - - --%test(Cannot be created with non positive bounding capacity) - procedure non_positive_bounding_cap; - --%endcontext - --%context(An empty queue) - - --%test(Becomes non empty when non null value enqueued) - procedure non_empty_after_enq; - --%endcontext - --%context(A non empty queue) - - --%context(that is not full) - - --%test(Becomes full when enqueued up to capacity) - procedure full_on_enq_to_cap; - --%endcontext - --%context(that is full) - - --%test(Becomes non full when dequeued) - procedure non_full_on_deq; - --%endcontext - - --%endcontext -end; -``` - -In the above code, suitepaths, context names and context descriptions will be as follows. - -| suitepath | description | name | -|----------------------------------|----------------------|------------| -| queue_spec | Queue specification | queue_spec | -| queue_spec.context_#1 | A new queue | context_#1 | -| queue_spec.context_#2 | An empty queue | context_#2 | -| queue_spec.context_#3 | A non empty queue | context_#3 | -| queue_spec.context_#3.context_#1 | that is not full | context_#1 | -| queue_spec.context_#3.context_#2 | that is full | context_#2 | - -In order to run only the tests for the context `A non empty queue that is not full` you will need to call utPLSQL as below: -```sql linenums="1" - exec ut.run(':queue_spec.context_#3.context_#1'); -``` - -You can use `--%name` annotation to explicitly name contexts on suitepath. -```sql linenums="1" -create or replace package queue_spec as - --%suite(Queue specification) - - --%context(A new queue) - --%name(a_new_queue) - - --%test(Cannot be created with non positive bounding capacity) - procedure non_positive_bounding_cap; - --%endcontext - --%context(An empty queue) - --%name(an_empty_queue) - - --%test(Becomes non empty when non null value enqueued) - procedure non_empty_after_enq; - --%endcontext - --%context(A non empty queue) - --%name(a_non_empty_queue) - - --%context(that is not full) - --%name(that_is_not_full) - - --%test(Becomes full when enqueued up to capacity) - procedure full_on_enq_to_cap; - --%endcontext - --%context(that is full) - --%name(that_is_full) - - --%test(Becomes non full when dequeued) - procedure non_full_on_deq; - --%endcontext - - --%endcontext -end; -``` - -In the above code, suitepaths, context names and context descriptions will be as follows. - -| suitepath | description | name | -|-----------------------------------------------|-----------------------|-------------------| -| queue_spec | Queue specification | queue_spec | -| queue_spec.a_new_queue | A new queue | a_new_queue | -| queue_spec.an_empty_queue | An empty queue | an_empty_queue | -| queue_spec.a_non_empty_queue | A non empty queue | a_non_empty_queue | -| queue_spec.a_non_empty_queue.that_is_not_full | that is not full | that_is_not_full | -| queue_spec.a_non_empty_queue.that_is_full | that is full | that_is_full | - - -The `--%name` annotation is only relevant for: - -- running subsets of tests by given context suitepath -- some of test reports, like `ut_junit_reporter` that use suitepath or test-suite element names (not descriptions) for reporting - -#### Name naming convention - -The value of `--%name` annotation must follow the following naming rules: - -- cannot contain spaces -- cannot contain a `.` (full stop/dot) -- is case-insensitive - -### Tags - -Tag is a label attached to the test or a suite. It is used for identification and execution of a group of tests / suites that share the same tag. - -It allows for grouping of tests / suites using various categorization and place tests / suites in multiple buckets. Same tests can be grouped with other tests based on the functionality , frequency, type of output etc. - -e.g. - -```sql linenums="1" ---%tags(batch,daily,csv) -``` - -or - -```sql linenums="1" ---%tags(online,json) ---%tags(api) -``` - -Tags are defined as a comma separated list within the `--%tags` annotation. - -When a suite/context is tagged, all of its children will automatically inherit the tag and get executed along with the parent, unless they are excluded explicitly at runtime with a negated tag expression. -See [running unit tests](running-unit-tests.md) for more information on using tags to filter test suites that are to be executed. - -#### Tag naming convention - -Tags must follow the below naming convention: - -- tag is case sensitive -- tag must not contain any of the following reserved characters: - - comma (,) - - left or right parenthesis ((, )) - - ampersand (&) - - vertical bar (|) - - exclamation point (!) -- tag cannot be null or blank -- tag cannot start with a dash, e.g. `-some-stuff` is **not** a valid tag -- tag cannot contain spaces, e.g. `test of batch`. To create a multi-word tag use underscores or dashes, e.g. `test_of_batch`, `test-of-batch` -- leading and trailing spaces are ignored in tag name, e.g. `--%tags( tag1 , tag2 )` becomes `tag1` and `tag2` tag names -- tag cannot be one of two reserved words: `none` and `any`. `none` and `any` as a tag will be treated as no tag - - -### Suitepath - -It is very likely that the application for which you are going to introduce tests consists of many different packages, procedures and functions. -Usually procedures can be logically grouped inside a package, there also might be several logical groups of procedures in a single package and packages might be grouped into modules and modules into subject areas. - -As your project grows, the codebase will grow to. utPLSQL allows you to group packages into modules and also allows for nesting modules. - -Let's say you have a complex insurance application that deals with policies, claims and payments. The payment module contains several packages for payment recognition, charging, planning etc. The payment recognition module among others contains a complex `recognize_payment` procedure that associates received money to the policies. - -If you want to create tests for your application it is recommended to structure your tests similarly to the logical structure of your application. So you end up with something like: -* Integration tests - * Policy tests - * Claim tests - * Payment tests - * Payments recognition - * Payments set off - -The `--%suitepath` annotation is used for such grouping. Even though test packages are defined in a flat structure the `--%suitepath` is used by the framework to form them into a hierarchical structure. - -Your payments recognition test package might look like: -```sql linenums="1" -create or replace package test_payment_recognition as - - --%suite(Payment recognition tests) - --%suitepath(payments) - - --%test(Recognize payment by policy number) - procedure test_recognize_by_num; - - --%test(Recognize payment by payment purpose) - procedure test_recognize_by_purpose; - - --%test(Recognize payment by customer) - procedure test_recognize_by_customer; - -end test_payment_recognition; -``` - -And payments set off test package: -```sql linenums="1" -create or replace package test_payment_set_off as - - --%suite(Payment set off tests) - --%suitepath(payments) - - --%test(Creates set off) - procedure test_create_set_off; - - --%test(Cancels set off) - procedure test_cancel_set_off; - -end test_payment_set_off; -``` - -When you execute tests for your application, the framework constructs a test suite for each test package. Then it combines suites into grouping suites by the `--%suitepath` annotation value so that the fully qualified path to the `recognize_by_num` procedure is `USER:payments.test_payment_recognition.test_recognize_by_num`. If any of its expectations fails then the test is marked as failed, also the `test_payment_recognition` suite, the parent suite `payments` and the whole run is marked as failed. -The test report indicates which expectation has failed on the payments module. The payments recognition submodule is causing the failure as `recognize_by_num` has not met the expectations of the test. Grouping tests into modules and submodules using the `--%suitepath` annotation allows you to logically organize your project's flat structure of packages into functional groups. - -An additional advantage of such grouping is the fact that every element level of the grouping can be an actual unit test package containing a common module level setup for all of the submodules. So in addition to the packages mentioned above you could have the following package. -```sql linenums="1" -create or replace package payments as - - --%suite(Payments) - - --%beforeall - procedure set_common_payments_data; - - --%afterall - procedure reset_common_paymnets_data; - -end payments; -``` - -When executing tests, `path` for executing tests can be provided in three ways: - -* schema - execute all tests in the schema -* [schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests by `suitepath` in all suites on path suite1[.suite2][.suite3]...[.procedure]. If schema is not provided, then the current schema is used. Example: `:all.rooms_tests` -* [schema.]package[.procedure] - execute all tests in the specified test package. The whole hierarchy of suites in the schema is built before all before/after hooks or part suites for the provided suite package are executed as well. Example: `tests.test_contact.test_last_name_validator` or simply `test_contact.test_last_name_validator` if `tests` is the current schema. - - -### Rollback - -By default, changes performed by every setup, cleanup and test procedure are isolated by savepoints. -This solution is suitable for use-cases where the code that is being tested as well as the unit tests themselves do not use transaction control (commit/rollback) or DDL commands. - -In general, your unit tests should not use transaction control as long as the code you are testing is not using it too. -Keeping the transactions uncommitted allows your changes to be isolated and the execution of tests does not impact others who might be using a shared development database. - -If you are in a situation where the code you are testing uses transaction control (common case with ETL code), then your tests probably should not use the default automatic transaction control. -In that case use the annotation `--%rollback(manual)` on the suite level to disable automatic transaction control for the entire suite. -If you are using nested suites, you need to make sure that the entire suite all the way to the root is using manual transaction control. - -It is possible with utPLSQL to change the transaction control on individual suites or tests that are part of complex suite. -It is strongly recommended not to have mixed transaction control in a suite. -Mixed transaction control settings will not work properly when your suites are using shared setup/cleanup with beforeall, afterall, beforeeach or aftereach annotations. -Your suite will most likely fail with error or warning on execution. Some of the automatic rollbacks will probably fail to execute depending on the configuration you have. - -In some cases it is necessary to perform DDL as part of setup or cleanup for the tests. -It is recommended to move such DDL statements to a procedure with `pragma autonomous_transaction` to eliminate implicit commits in the main session that is executing all your tests. -Doing so allows your tests to use the framework's automatic transaction control and releases you from the burden of manual cleanup of data that was created or modified by test execution. - -When you are testing code that performs explicit or implicit commits, you may set the test procedure to run as an autonomous transaction with `pragma autonomous_transaction`. -Keep in mind that when your test runs as autonomous transaction it will not see the data prepared in a setup procedure unless the setup procedure committed the changes. - -**Note** -> The `--%suitepath` annotation, when used, must be provided with a value of path. -> The path in suitepath cannot contain spaces. Dot (.) identifies individual elements of the path. -> -> Example: `--%suitepath(org.utplsql.core.utils)` -> - - -### Throws - -The `--%throws` annotation allows you to specify a list of exceptions as one of: - -- number literals - example `--%throws(-20134)` -- variables of type exception defined in a package specification - example `--%throws(exc_pkg.c_exception_No_variable)` -- variables of type number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)` -- [predefined oracle exceptions](https://docs.oracle.com/cd/E11882_01/timesten.112/e21639/exceptions.htm#CIHFIGFE) - example `--%throws(no_data_found)` - -The annotation is ignored, when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. - -If `--%throws` annotation is specified with arguments and no exception is raised, the test is marked as failed. - -If `--%throws` annotation is specified with arguments and exception raised is not on the list of provided exceptions, the test is marked as failed. - -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 linenums="1" -create or replace package exc_pkg is - c_e_option1 constant number := -20200; - c_e_option2 constant varchar2(10) := '-20201'; - c_e_option3 number := -20202; - - e_option4 exception; - pragma exception_init(e_option4, -20203); - -end; -/ - -create or replace package example_pgk as - - --%suite(Example Throws Annotation) - - --%test(Throws one of the listed exceptions) - --%throws(-20145,bad,-20146, -20189 ,-20563) - procedure raised_one_listed_exception; - - --%test(Throws different exception than expected) - --%throws(-20144) - procedure raised_different_exception; - - --%test(Throws different exception than listed) - --%throws(-20144,-00001,-20145) - procedure raised_unlisted_exception; - - --%test(Gives failure when an exception is expected and nothing is thrown) - --%throws(-20459, -20136, -20145) - procedure nothing_thrown; - - --%test(Throws package exception option1) - --%throws(exc_pkg.c_e_option1) - procedure raised_option1_exception; - - --%test(Throws package exception option2) - --%throws(exc_pkg.c_e_option2) - procedure raised_option2_exception; - - --%test(Throws package exception option3) - --%throws(exc_pkg.c_e_option3) - procedure raised_option3_exception; - - --%test(Throws package exception option4) - --%throws(exc_pkg.e_option4) - procedure raised_option4_exception; - - --%test(Raise name exception) - --%throws(DUP_VAL_ON_INDEX) - procedure raise_named_exc; - - --%test(Invalid throws annotation) - --%throws - procedure bad_throws_annotation; - -end; -/ -create or replace package body example_pgk is - procedure raised_one_listed_exception is - begin - raise_application_error(-20189, 'Test error'); - end; - - procedure raised_different_exception is - begin - raise_application_error(-20143, 'Test error'); - end; - - procedure raised_unlisted_exception is - begin - raise_application_error(-20143, 'Test error'); - end; - - procedure nothing_thrown is - begin - ut.expect(1).to_equal(1); - end; - - procedure raised_option1_exception is - begin - raise_application_error(exc_pkg.c_e_option1, 'Test error'); - end; - - procedure raised_option2_exception is - begin - raise_application_error(exc_pkg.c_e_option2, 'Test error'); - end; - - procedure raised_option3_exception is - begin - raise_application_error(exc_pkg.c_e_option3, 'Test error'); - end; - - procedure raised_option4_exception is - begin - raise exc_pkg.e_option4; - end; - - procedure raise_named_exc is - begin - raise DUP_VAL_ON_INDEX; - end; - - procedure bad_throws_annotation is - begin - null; - end; -end; -/ - -exec ut3.ut.run('example_pgk'); -``` - -Running the test will give report: -``` -Example Throws Annotation - Throws one of the listed exceptions [.002 sec] - Throws different exception than expected [.002 sec] (FAILED - 1) - Throws different exception than listed [.003 sec] (FAILED - 2) - Gives failure when an exception is expected and nothing is thrown [.002 sec] (FAILED - 3) - Throws package exception option1 [.003 sec] - Throws package exception option2 [.002 sec] - Throws package exception option3 [.002 sec] - Throws package exception option4 [.002 sec] - Raise name exception [.002 sec] - Invalid throws annotation [.002 sec] - -Failures: - - 1) raised_different_exception - Actual: -20143 was expected to equal: -20144 - ORA-20143: Test error - ORA-06512: at "UT3.EXAMPLE_PGK", line 9 - ORA-06512: at "UT3.EXAMPLE_PGK", line 9 - ORA-06512: at line 6 - - 2) raised_unlisted_exception - Actual: -20143 was expected to be one of: (-20144, -1, -20145) - ORA-20143: Test error - ORA-06512: at "UT3.EXAMPLE_PGK", line 14 - ORA-06512: at "UT3.EXAMPLE_PGK", line 14 - ORA-06512: at line 6 - - 3) nothing_thrown - Expected one of exceptions (-20459, -20136, -20145) but nothing was raised. - - -Warnings: - - 1) example_pgk - Invalid parameter value "bad" for "--%throws" annotation. Parameter ignored. - at "UT3.EXAMPLE_PGK.RAISED_ONE_LISTED_EXCEPTION", line 6 - 2) example_pgk - "--%throws" annotation requires a parameter. Annotation ignored. - at "UT3.EXAMPLE_PGK.BAD_THROWS_ANNOTATION", line 42 - -Finished in .025784 seconds -10 tests, 3 failed, 0 errored, 0 disabled, 2 warning(s) -``` - -## Order of execution - -```sql linenums="1" -create or replace package test_employee_pkg is - - --%suite(Employee management) - --%suitepath(com.my_company.hr) - --%rollback(auto) - - --%beforeall - procedure setup_employees; - - --%beforeall - procedure setup_departments; - - --%afterall - procedure cleanup_log_table; - - --%context(add_employee) - - --%beforeeach - procedure setup_for_add_employees; - - --%test(Raises exception when employee already exists) - --%throws(-20145) - procedure add_existing_employee; - - --%test(Inserts employee to emp table) - procedure add_employee; - - --%endcontext - - - --%context(remove_employee) - - --%beforeall - procedure setup_for_remove_employee; - - --%test(Removed employee from emp table) - procedure del_employee; - - --%endcontext - - --%test(Test without context) - --%beforetest(setup_another_test) - --%aftertest(cleanup_another_test) - procedure some_test; - - --%test(Name of test) - --%disabled - procedure disabled_test; - - --%test(Name of test) - --%rollback(manual) - procedure no_transaction_control_test; - - procedure setup_another_test; - - procedure cleanup_another_test; - - --%beforeeach - procedure set_session_context; - - --%aftereach - procedure cleanup_session_context; - -end test_employee_pkg; -``` - -When processing the test suite `test_employee_pkg` defined in [Example of annotated test package](#example), the order of execution will be as follows. - -``` - create a savepoint 'before-suite' - execute setup_employees (--%beforeall) - execute setup_departments (--%beforeall) - - create a savepoint 'before-context' - create savepoint 'before-test' - execute test_setup (--%beforeeach) - execute setup_for_add_employees (--%beforeeach from context) - execute add_existing_employee (--%test) - execute test_cleanup (--%aftereach) - rollback to savepoint 'before-test' - create savepoint 'before-test' (--%suite) - execute test_setup (--%beforeeach) - execute setup_for_add_employees (--%beforeeach from context) - execute add_employee (--%test) - execute test_cleanup (--%aftereach) - rollback to savepoint 'before-test' - rollback to savepoint 'before-context' - - create a savepoint 'before-context' - execute setup_for_remove_employee (--%beforeall from context) - create savepoint 'before-test' - execute test_setup (--%beforeeach) - execute add_existing_employee (--%test) - execute test_cleanup (--%aftereach) - rollback to savepoint 'before-test' - rollback to savepoint 'before-context' - - create savepoint 'before-test' - execute test_setup (--%beforeeach) - execute some_test (--%test) - execute test_cleanup (--%aftereach) - rollback to savepoint 'before-test' - - create savepoint 'before-test' - execute test_setup (--%beforeeach) - execute setup_another_test (--%beforetest) - execute another_test (--%test) - execute cleanup_another_test (--%aftertest) - execute test_cleanup (--%beforeeach) - rollback to savepoint 'before-test' - - mark disabled_test as disabled (--%test --%disabled) - - execute test_setup (--%beforeeach) - execute no_transaction_control_test (--%test) - execute test_cleanup (--%aftertest) - - execute global_cleanup (--%afterall) - rollback to savepoint 'before-suite' -``` - -!!! note - utPLSQL does not guarantee ordering of tests in suite. On contrary utPLSQL might give random order of tests/contexts in suite.
- Order of execution within multiple occurrences of `before`/`after` procedures is determined by the order of annotations in specific block (context/suite) of package specification. - -## sys_context - -It is possible to access information about currently running suite. -The information is available by calling `sys_context( 'UT3_INFO', attribute )`. -It can be accessed from any procedure invoked as part of utPLSQL test execution. - -!!! note - Context name is derived from schema name where utPLSQL is installed.
- The context name in below examples represents the default install schema -> `UT3`
- If you install utPLSQL into another schema the context name will be different.
- For example if utPLSQL is installed into `HR` schema, the context name will be `HR_INFO` - -Following attributes are populated: - -| Name | Scope | Description | -|-------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| -| COVERAGE_RUN_ID | run | Value of COVERAGE_RUN_ID used by utPLSQL internally for coverage gathering | -| RUN_PATHS | run | list of suitepaths / suitenames used as input parameters for call to `ut.run(...)` or `ut_runner.run(...)` | -| SUITE_DESCRIPTION | run | the description of test suite that is currently being executed | -| SUITE_PACKAGE | run | the owner and name of test suite package that is currently being executed | -| SUITE_PATH | run | the suitepath for the test suite package that is currently being executed | -| SUITE_START_TIME | run | the execution start timestamp of test suite package that is currently being executed | -| CURRENT_EXECUTABLE_NAME | run | the owner.package.procedure of currently running test suite executable | -| CURRENT_EXECUTABLE_TYPE | run | the type of currently running test suite executable (one of: `beforeall`, `beforeeach`, `beforetest`, `test`, `aftertest`, `aftereach`, `afterall` | - | CONTEXT_DESCRIPTION | suite context | the description of test suite context that is currently being executed | - | CONTEXT_NAME | suite context | the name of test suite context that is currently being executed | - | CONTEXT_PATH | suite context | the suitepath for the currently executed test suite context | - | CONTEXT_START_TIME | suite context | the execution start timestamp for the currently executed test suite context | -| TEST_DESCRIPTION | test* | the description of test for which the current executable is being invoked | -| TEST_NAME | test* | the name of test for which the current executable is being invoked | -| TEST_START_TIME | test* | the execution start timestamp of test that is currently being executed (the time when first `beforeeach`/`beforetest` was called for that test) | - -!!! note "Scopes" - - run - context information is available in any element of test run
- - suite context - context information is available in any element nested within a suite context
- - test* - context information is available when executing following procedure types: test, beforetest, aftertest, beforeeach or aftereach - - -Example: -```sql linenums="1" -create or replace procedure which_procecure_called_me is -begin - dbms_output.put_line( - 'Currently running utPLSQL ' ||sys_context( 'ut3_info', 'current_executable_type' ) - ||' ' ||sys_context( 'ut3_info', 'current_executable_name' ) - ); -end; -/ - -create or replace package test_call is - - --%suite - - --%beforeall - procedure beforeall; - - --%beforeeach - procedure beforeeach; - - --%test - procedure test1; - - --%test - procedure test2; - -end; -/ - -create or replace package body test_call is - - procedure beforeall is - begin - which_procecure_called_me(); - dbms_output.put_line('Current test procedure is: '||sys_context('ut3_info','test_name')); - end; - - procedure beforeeach is - begin - which_procecure_called_me(); - dbms_output.put_line('Current test procedure is: '||sys_context('ut3_info','test_name')); - end; - - procedure test1 is - begin - which_procecure_called_me(); - ut.expect(sys_context('ut3_info','suite_package')).to_equal(user||'.test_call'); - end; - - procedure test2 is - begin - which_procecure_called_me(); - ut.expect(sys_context('ut3_info','test_name')).to_equal(user||'.test_call.test2'); - end; - -end; -/ -``` - -```sql linenums="1" -exec ut.run('test_call'); -``` - -``` -test_call - Currently running utPLSQL beforeall UT3.test_call.beforeall - Current test procedure is: - test1 [.008 sec] - Currently running utPLSQL beforeeach UT3.test_call.beforeeach - Current test procedure is: UT3.test_call.test1 - Currently running utPLSQL test UT3.test_call.test1 - test2 [.004 sec] - Currently running utPLSQL beforeeach UT3.test_call.beforeeach - Current test procedure is: UT3.test_call.test2 - Currently running utPLSQL test UT3.test_call.test2 - -Finished in .021295 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - - -## Annotation cache - -utPLSQL needs to scan the source of package specifications to identify and parse annotations. -To improve framework startup time, especially when dealing with database users owning large amounts of packages, the framework has a built-in persistent cache for annotations. - -The annotation cache is checked for staleness and refreshed automatically on every run. The initial startup of utPLSQL for a schema will take longer than consecutive executions. - -If you are in a situation where your database is controlled via CI/CD server and is refreshed/wiped before each run of your tests, consider building the annotation cache upfront and taking a snapshot of the database after the cache has been refreshed. - -To build the annotation cache without actually invoking any tests, call `ut_runner.rebuild_annotation_cache(a_object_owner)` for every unit test owner for which you want to have the annotation cache prebuilt. -Example: -```sql linenums="1" -exec ut_runner.rebuild_annotation_cache('HR'); -``` - -To purge the annotation cache call `ut_runner.purge_cache(a_object_owner, a_object_type)`. -Both parameters are optional and if not provided, all owners/object_types will be purged. -Example: -```sql linenums="1" -exec ut_runner.purge_cache('HR', 'PACKAGE'); -``` - diff --git a/docs/userguide/best-practices.md b/docs/userguide/best-practices.md deleted file mode 100644 index 45be3be59..000000000 --- a/docs/userguide/best-practices.md +++ /dev/null @@ -1,46 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -The following are best practices we at utPLSQL have learned about PL/SQL and Unit Testing. - -## Test Isolation and Dependency - - - Tests should not depend on a specific order to run - - Tests should not depend on other tests to execute - - Tests should not depend on specific database state, they should setup the expected state before being run - - Tests should keep the environment unchanged post execution - - -## Writing tests - - - Tests should not mimic / duplicate the logic of tested code - - Tests should contain zero logic (or as close to zero as possible) - - The 3A rule: - - Arrange (setup inputs/data/environment for the tested code) - - Act (execute code under test) - - Assert (validate the outcomes of the execution) - - Each tested procedure/function/trigger (code block) should have more than one test - - Each test should check only one behavior (one requirement) of the code block under test - - Tests should be maintained as thoroughly as production code - - Every test needs to be built so that it can fail, tests that do not fail when needed are useless - -## Gaining value from the tests - - - Tests are only valuable if they are executed frequently; ideally with every change to the project code - - Tests need to run very fast; the slower the tests, the longer you wait. Build tests with performance in mind (do you really need to have 10k rows to run the tests?) - - Tests that are executed infrequently can quickly become stale and end up adding overhead rather than value. Maintain tests as you would maintain code. - - Tests that are failing need to be addressed immediately. How can you trust your tests when 139 of 1000 tests are failing for a month? Will you recognise each time that it is still the same 139 tests? - -## Tests are not for production - - Tests will generate and operate on fake data. They might insert, update and delete data. You don't want tests to run on a production database and affect real life data. - -## Tests and their relationship to code under test - - Tests and the code under test should be in separate packages. This is a fundamental separation of responsibilities. - - It is common for test code to be in the same schema as the tested code. This removes the need to manage privileges for the tests. - -## Version Control - -Use a version control system for your code. -Don't just trust the database for code storage. -This includes both the code under test, and the unit tests you develop as well. -Treat the database as a target/destination for your code, not as a source of it. diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md deleted file mode 100644 index adf36baa6..000000000 --- a/docs/userguide/coverage.md +++ /dev/null @@ -1,910 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -utPLSQL comes with a built-in coverage reporting engine. The code coverage reporting uses package DBMS_PROFILER (and DBMS_PLSQL_CODE_COVERAGE on Oracle database version 12.2 and above) provided with Oracle database. -Code coverage is gathered for the following source types: - -* package bodies -* type bodies -* triggers -* procedures -* functions - -!!! note - - The package and type specifications are excluded from code coverage analysis. - This limitation is introduced to avoid false-negatives. - Typically package specifications contain no executable code. - The only exception is initialization of global constants and variables in package specification. - Since most package specifications are not executable at all, there is no information available - on the number of lines covered and those would be reported as 0% covered, which is not desirable. - -To obtain information about code coverage for unit tests, run utPLSQL with one of built-in code coverage reporters. -The following code coverage reporters are supplied with utPLSQL: - -* `ut_coverage_html_reporter` - generates a HTML coverage report providing summary and detailed information on code coverage. The HTML reporter is based on the open-source [simplecov-html](https://github.com/colszowka/simplecov-html) reporter for Ruby. It includes source code of the code that was covered (if the code is accessible for test user) -* `ut_coveralls_reporter` - generates a [Coveralls compatible JSON](https://coveralls.zendesk.com/hc/en-us/articles/201774865-API-Introduction) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by cloud services like [Coveralls](https://coveralls.io) -* `ut_coverage_sonar_reporter` - generates a [Sonar Compatible XML](https://docs.sonarqube.org/latest/analysis/generic-test/) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like [SonarQube](https://www.sonarqube.org/) and [SonarCloud](https://about.sonarcloud.io/) -* `ut_coverage_cobertura_reporter` - generates a basic Cobertura coverage (http://cobertura.sourceforge.net/xml/coverage-04.dtd) report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like TFS and Jenkins. Check this link for an example of XML generated by Java: https://raw.githubusercontent.com/jenkinsci/cobertura-plugin/master/src/test/resources/hudson/plugins/cobertura/coverage-with-data.xml - -## Security model -utPLSQL code coverage uses DBMS_PROFILER to gather information about the execution of code under test and therefore follows the [DBMS_PROFILER's Security Model](https://docs.oracle.com/database/121/ARPLS/d_profil.htm#ARPLS67465). -In order to be able to gather coverage information, the user executing unit tests needs to be either: - -* The owner of the code that is being tested -* Have the following privileges to be able to gather coverage on code owned by other users: - * `create any procedure` system privilege - * `execute` privilege on the code that is being tested (not only the unit tests) or `execute any procedure` system privilege - -If you have `execute` privilege on the code that is being tested, but do not have `create any procedure` system privilege, then the code that is being tested will be reported as not covered (coverage = 0%). -If you have `execute` privilege only on the unit tests, but do not have `execute` privilege on the code that is being tested, the code will not be reported by coverage - as if it did not exist in the database. -If the code that is being tested is compiled as NATIVE, the code coverage will not be reported as well. - -## Manually running unit tests with coverage -Using the code coverage functionality is as easy as using any other [reporter](reporters.md) for the utPLSQL test-run. Run your tests from your preferred SQL tool and save the reporter results to a file. -All you need to do, is pass the constructor of the reporter to the `ut.run` procedure call. - -Example: -```sql linenums="1" -set serveroutput on -begin - ut.run(ut_coverage_html_reporter()); -end; -/ -``` -The above command executes all unit tests in the **current schema**, gathers information about code coverage for all sources in that schema and outputs the HTML report as text into DBMS_OUTPUT. -The `ut_coverage_html_reporter` will produce an interactive HTML report. You can see a sample of code coverage for the utPLSQL project [here](https://utplsql.github.io/utPLSQL-coverage-html/) - -The report provides summary information with a list of source code that should be covered. - -![Coverage Summary page](../images/coverage_html_summary.png) - -The report allow you to navigate to each source file and inspect line by line coverage. - -![Coverage Details page](../images/coverage_html_details.png) - - -### Oracle 12.2 extended coverage with profiler and block coverage -Using data collected from profiler and block coverage running parallel we are able to enrich information about coverage. -For every line recorded by the profiler if we have a partially covered same line in block coverage we will display that information -presenting line as partially covered, displaying number of block and how many blocks have been covered in that line.The feature will be automatically enabled in the Oracle database version 12.2 and higher, for older versions current profiler will be used. - -utPLSQL installation automatically creates tables needed by `dbms_plsql_code_coverage` on databases in versions above 12c Release 1. -Due to security model of `dbms_plsql_code_coverage` package, utPLSQL grants access to those tables and creates synonyms for those tables. -The access and synonyms will be public when using the headless installation. This approach avoids complexity of forcing every user of utPLSQL framework to create tables on their own. - -Sample output: - -![Package Coverage Summary](../images/extended_coverage_html_summary.png) - -![Line Coverage Details](../images/extended_coverage_html_line.png) - - - -### Coverage reporting options - -There are two distinct ways to gather code coverage: -- Coverage on database schema(s) -- Coverage on project files - -Those two options are mutually exclusive and cannot be mixed. -By default, when using one of coverage reporters, coverage is gathered on schema(s). -The database schema(s) containing the tests that were executed during the run will be reported on by coverage reporter. - -The parameters used to execute tests determine if utPLSQL will be using one approach or the other. -If parameter `a_source_file_mappings` or `a_source_files` is provided, then coverage is gathered on project files provided, otherwise coverage is gathered on schemas. - - -!!! note - Regardless of the options provided, all unit test packages are excluded from the coverage report. Coverage reports provide information only about the **tested** code. - -The default behavior of coverage reporting can be altered using invocation parameters. - -### Schema based Coverage - -To gather coverage for all objects in the **current schema** execute tests with coverage report as argument. -This is the default reporting option and therefore additional coverage options don't need to be provided. - -```sql linenums="1" -exec ut.run(ut_coverage_html_reporter()); -``` - -!!! note - - When no filters are used, the size of the coverage report will depend two factors:
- - the type of report (does the report include source code or not)
- - the amount of source code in the database schema
- Keep in mind that for schemas containing a lot of code, it can take quite some time to produce the coverage report. - -#### Setting coverage schema(s) - -By default, coverage is gathered on the schema(s) derived from suite paths provided to execute tests. -This is a valid approach as long as your test packages and tested code share the same schema. - -So when you run: -```sql linenums="1" -exec ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter()); -``` -Coverage will be gathered on both `user_1` and `user_2` objects. - -If your tests live in a different schema from the tested code you may override the default behavior by providing an explicit list of coverage schema names. - -In the example below, coverage will still be gathered for `user_1` and `user_2` objects, even thought we run the tests located in schema `unit_test_schema` - -```sql linenums="1" -begin - ut.run('unit_test_schema', ut_coverage_html_reporter(), - a_coverage_schemes => ut_varchar2_list('user_1','user_2') - ); -end; -``` - -#### Filtering objects in coverage reports - -Multiple parameters can be used to define the scope of coverage report. - -- `a_source_file_mappings ( ut_file_mappings )` - map of filenames to database objects. It is used for file-based coverage - see below. -- `a_include_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be included in the coverage report. Case-insensitive. -- `a_include_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be included in the coverage report. Case-insensitive. -- `a_exclude_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be excluded from the coverage report. Case-insensitive. -- `a_exclude_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be excluded from the coverage report. Case-insensitive. -- `a_coverage_schemes ( ut_varchar2_list )` - List of database schema names to gather coverage on. -- `a_include_objects ( ut_varchar2_list )` - list of `[object_owner.]object_name` to be included in the coverage report. -- `a_exclude_objects ( ut_varchar2_list )` - list of `[object_owner.]object_name` to be excluded from the coverage report. - -You may specify both _include_ and _exclude_ options to gain more control over what needs to be included / excluded from the coverage report. - - -!!! warning "Important note" - - The order of priority is for evaluation of include/exclude filter parameters is as follows.
- - if `a_source_file_mappings` is defined then all include/exclude parameters are ignored (see section below for usage of `a_source_file_mappings` parameter )
- - else if `a_include_schema_expr` or `a_include_object_expr` parameter is specified then parameters `a_coverage_schemes` and `a_include_objects` are ignored
- - else if `a_include_objects` is specified then the coverage is gathered only on specified database objects.
- - if `a_coverage_schemes` is specified then those schemas are used for objects in `a_include_objects` without schema name
- - if `a_coverage_schemes` is not specified then schema from paths (`a_paths`) parameter are used for objects in `a_include_objects` without schema name
- - else if, only the `a_coverage_schemes` is specified then the coverage is gathered only on specified database schemas
- - else if no coverage specific parameters are provided coverage is gathered on all schemas specified in paths passed to run procedure
- - else if no paths were specified, the coverage is gathered on current schema of the session running the tests - -The exclude parameters are not mutually-exclusive and can be mixed together. All of exclude parameters are always applied. - -Example: Limiting coverage by schema regex. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_schema_expr => '^ut3_develop' - ); -end; -``` -Will result in showing coverage for all schemas that match regular expression `^ut3_develop` - -Example: Limiting coverage by schema regex with parameter `a_include_objects` ignored. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_schema_expr => '^ut3_develop', a_include_objects => ut_varchar2_list( 'ut3_tester_helper.regex_dummy_cov' ) - ); -end; -``` -Will result in showing coverage for all schemas that match regular expression `^ut3_develop`. - -Example: Limiting coverage by object regex. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_object_expr => 'regex123' - ); -end; -``` -Will result in showing coverage for all objects that name match regular expression `regex123`. - -Example: Limiting coverage by object regex with parameter `a_include_objects` ignored. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_object_expr => 'utl', a_include_objects => ut_varchar2_list( 'user_2.utils_package' ) - ); -end; -``` -Will result in showing coverage for all objects that name match regular expression `utl`. - -Example: Limiting coverage by excluding schema with regex. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_schema_expr => 'er_1$' - ); -end; -``` -Will result in showing coverage for objects in all schema except schemas that are matching regular expression `er_1$` - -Example: Limiting coverage by excluding schema with regex and excluding specific object. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_schema_expr => 'er_1$', a_exclude_objects => ut_varchar2_list( 'user_2.utils_package' ) - ); -end; -``` -Will result in showing coverage for objects in all schemas except schemas that are matching regular expression `er_1$` -Will also exclude object `user_2.utils_package` from coverage report - -Example: Limiting coverage by excluding objects with regex. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_object_expr => 'utl' - ); -end; -``` -Will result in showing coverage for all objects that name is not matching regular expression `utl`. - -Example: Limiting coverage by excluding objects with regex with parameter `a_exclude_objects` ignored. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_object_expr => 'utl', a_exclude_objects => ut_varchar2_list( 'user_2.utils_package' ) - ); -end; -``` -Will result in showing coverage for all objects that name is not matching regular expression `utl`. -Will also exclude object `user_2.utils_package` from coverage report - - -Example: Limiting coverage by object name, for tested code located in the same schema as the unit tests. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_objects=>ut_varchar2_list('award_bonus') - ); -end; -``` -Executes all tests in schemas: `user_1` and `user_2`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus` - - -Example: Limiting coverage by object name, for tested code located in different schemas than the unit tests. -```sql linenums="1" -begin - ut.run( - 'unit_test_schema', ut_coverage_html_reporter(), - a_coverage_schemes => ut_varchar2_list('user_1','user_2'), - a_include_objects => ut_varchar2_list('award_bonus', 'betwnstr') - ); -end; -``` -Executes all tests in schema `unit_test_schema`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus`, `user_1.betwnstr`, `user_2.betwnstr`. -Objects that do not exist in the database but were specified in `a_include_objects` will be ignored. - -Example: Limiting coverage by object owner and name. -```sql linenums="1" -begin - ut.run( - 'unit_test_schema', ut_coverage_html_reporter(), - a_include_objects => ut_varchar2_list('user_1.award_bonus','user_2.betwnstr') - ); -end; -``` -Executes all tests in schema `unit_test_schema`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.betwnstr` - -The `a_exclude_objects` can be used in the same way as `a_include_objects`. - -Example: Excluding objects from coverage report by providing a list of object owner/name to be excluded. -```sql linenums="1" -begin - ut.run( - 'unit_test_schema.test_award_bonus', ut_coverage_html_reporter(), - a_exclude_objects => ut_varchar2_list('ut3_user.betwnstr') - ); -end; -``` -Executes test `test_award_bonus` in schema `unit_test_schema`. Coverage will be reported on all objects in schema `ut3_user` except the `betwnstr` object. - -!!! note - Filtering using `a_include_objects` and `a_exclude_objects` is only applicable when gathering coverage for a schema. Those filters are not applied when reporting coverage on project files. - -!!! note - When running coverage on schema objects, all source code of package bodies, functions, procedures, type bodies and triggers that were not executed will be reported as having 0% code coverage and all source code lines will show as uncovered. - This is different from the behavior when gathering coverage on project files. - - -### Project based Coverage - -utPLSQL provides reporters that produce reports consumable by external tools like `Sonar`/`SonarCloud` & `Coveralls`. - -Services like Sonar, Coveralls and others perform analysis based on source code in project files. -They are abstracted from database, schema names, packages, procedures and functions, and operate on a more generic concept of project source code. - -To be able to effectively use reporters dedicated for those tools, utPLSQL provides functionality for mapping database object names to project files. - -There are a few significant differences when running coverage on project files compared to running coverage on schema(s). - -- Coverage is only reported on objects that were successfully mapped to project files. -- Project files (database objects) that were not executed at all are not reported as fully uncovered. It is up to the consumer (Sonar/Coveralls) to determine if project file should be considered as 0% coverage or just ignored. - -In order to successfully use coverage on project files, those files must be mapped to database objects. - -Though you can gather project based code coverage directly using `exec ut.run(...)`, it is highly recommended to use [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) command line client. - -The examples below are using utPLSQL-cli to execute tests and gather coverage information. - -#### File mapping using default parameters - -The example below illustrates a directory structure supported by the default parameters of utPLSQL. -The structure represents a multi-schema project with file names indicating object owner. -``` -C: - \my_project - \sources - \hotel.add_rooms_content.prc - \hotel.remove_rooms_by_name.prc - \hotel.rooms.tbl - \hr.award_bonus.prc - \hr.betwnstr.fnc - \hr.employees_test.tbl - \tests - \hotel.test_add_room_content.pkb - \hotel.test_add_room_content.pks - \hotel.test_remove_rooms_by_name.pkb - \hotel.test_remove_rooms_by_name.pks - \hr.test_award_bonus.pkb - \hr.test_award_bonus.pks - \hr.test_betwnstr.pkb - \hr.test_betwnstr.pks -``` - -By default, utPLSQL will convert file paths into database objects using the following regular expression `/(((\w|[$#])+)\.)?((\w|[$#])+)\.(\w{3})$` - -- object owner (if it is present) is identified by the expression in the second set of brackets -- object name is identified by the expression in the fourth set of brackets -- object type is identified by the expression in the sixth set of brackets - - -!!! note - utPLSQL will replace any '\\' with '/' for the purpose of mapping files to objects. The paths shown in the results will remain (contain '\' where it was present). - This is done to simplify the syntax of regular expressions. Regular expression will always use '/' as a directory separator on a file path regardless of whether you're on a Windows or Unix system. - -!!! note - Below examples assume that you have downloaded latest version of [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli/releases) - and extracted it into your projects root directory - and that you run the utPLSQL-cli from that directory. - -Windows: -```pwsh -utPLSQL-cli\bin\utplsql run test_runner/pass@db_host:db_port/db_service_name ^ - -p=hr,hotel ^ - -source_path=sources ^ - -test_path=tests ^ - -f=ut_coverage_html_reporter -o=coverage.html ^ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -Bash: -```bash -utPLSQL-cli/bin/utplsql run test_runner/pass@db_host:db_port/db_service_name \ - -p=hr,hotel \ - -source_path=sources \ - -test_path=tests \ - -f=ut_coverage_html_reporter -o=coverage.html \ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -The above commands will: - -- connect as user `test_runner` -- run all utPLSQL v3 tests for users `hr`, `hotel` -- map database code to project files in `sources` directory and save code coverage results into `coverage.html` -- map test packages to project files in `tests` directory and save test results into `test_results.xml` - -To better understand the default regular expression used, have a look [here](https://regex101.com/r/4qP6Aj/3). - -Tested code is mapped to files in `coverage.html` - -![coverage.html](../images/example_1_coverage_mapping.png) - -Unit test code is mapped to files in `test_results.xml` - -![coverage.html](../images/example_1_test_mapping.png) - -#### Using custom regular expressions - -If your project directory structure is different, you can use additional configuration parameters to tell utPLSQL how the project files are to be mapped into database objects. - -Example: Using custom regular expressions on a multi-schema project with separate directories for each object owner. -``` -C: - \my_project - \sources - \hotel - \add_rooms_content.prc - \remove_rooms_by_name.prc - \rooms.tbl - \hr - \award_bonus.prc - \betwnstr.fnc - \employees_test.tbl - \tests - \hotel - \test_add_room_content.pkb - \test_add_room_content.pks - \test_remove_rooms_by_name.pkb - \test_remove_rooms_by_name.pks - \hr - \test_award_bonus.pkb - \test_award_bonus.pks - \test_betwnstr.pkb - \test_betwnstr.pks -``` - -The command below will gather coverage and map files to database objects using custom regular expression. -Note that the owner/name/type subexpressions don't need to be explicitly specified if they are same as default values ( 2/3/4 ). -In the below example, they were specified explicitly only for `source_path`, `test_path` doesn't have subexpressions specified and so they are default (2/3/4). - -Windows: -```pwsh -utPLSQL-cli\bin\utplsql run test_runner/pass@db_url ^ - -p=hr,hotel ^ - -source_path=sources ^ - -regex_expression="/((\w+)/)?(\w+)\.(\w{3})$" ^ - -owner_subexpression=2 ^ - -name_subexpression=3 ^ - -type_subexpression=4 ^ - -test_path=tests -regex_expression="/((\w+)/)?(\w+)\.(\w{3})$" ^ - -f=ut_coverage_html_reporter -o=coverage.html ^ - -f=ut_sonar_test_reporter -o=test_results.xml ^ -``` - -Bash: -```bash -utPLSQL-cli/bin/utplsql run test_runner/pass@db_url \ - -source_path=sources \ - -regex_expression="/((\w+)/)?(\w+)\.(\w{3})$" \ - -owner_subexpression=2 \ - -name_subexpression=3 \ - -type_subexpression=4 \ - -test_path=tests -regex_expression="/((\w+)/)?(\w+)\.(\w{3})$" \ - -owner_subexpression=2 \ - -name_subexpression=3 \ - -type_subexpression=4 \ - -f=ut_coverage_html_reporter -o=coverage.html \ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -You can specify different mapping rules for source files and for test files - see [utPLSQL-cli readme](https://github.com/utPLSQL/utPLSQL-cli) for details. - -To better understand the regular expression used, have a look [here](https://regex101.com/r/0lk0rV/1/). - -Tested code is mapped to files in `coverage.html` - -![coverage.html](../images/example_2_coverage_mapping.png) - -Unit test code is mapped to files in `test_results.xml` - -![coverage.html](../images/example_2_test_mapping.png) - - -#### Explicitly specifying object owner - -When dealing with projects that operate within a single schema the project structure probably doesn't indicate the owner. -In such scenarios, you can explicitly specify the object owner for both tests and source code. - -Example: Single-schema project - no indication of object owner -``` -C: - \my_project - \sources - \betwnstr.fnc - \tests - \test_betwnstr.pkb - \test_betwnstr.pks -``` - -The command below will gather coverage and map files to database objects. -For the database objects mapped to `souces` directory user `code_owner` will be used. -For the database objects mapped to `tests` directory user `tests_owner` will be used. - -Windows: -```pwsh -utPLSQL-cli\bin\utplsql run test_runner/pass@db_url ^ - -p=tests_owner ^ - -source_path=sources -owner=code_owner ^ - -test_path=tests -owner=tests_owner ^ - -f=ut_coverage_html_reporter -o=coverage.html ^ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -Bash: -```bash -utPLSQL-cli/bin/utplsql run test_runner/pass@db_url \ - -p=tests_owner \ - -source_path=sources -owner=code_owner \ - -test_path=tests -owner=tests_owner \ - -f=ut_coverage_html_reporter -o=coverage.html \ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -!!! note - When the project folder structure does not provide any information about source code owner and test owner, you can specify the owner for tests and owner for code explicitly. - Such project configuration supports only single-owner for source code and single owner for tests. - -Tested code is mapped to files in `coverage.html` - -![coverage.html](../images/example_3_coverage_mapping.png) - -Unit test code is mapped to files in `test_results.xml` - -![coverage.html](../images/example_3_test_mapping.png) - - -#### Custom mapping of object types - -By default, when mapping project files to database objects, utPLSQL will identify the object type by file extension. - -The table below represents the default mapping of file extensions to database object types. - -| file extension | object type | -| -------------- | ----------- | -| tpb | type body | -| pkb | package body | -| bdy | package body | -| trg | trigger | -| fnc | function | -| prc | procedure | - -If your project naming convention differs and your file extensions do not match the above, or you simply name all of your files with `.sql` suffix, you can still use utPLSQL, but you need to provide custom mapping for object types. - - -Example: Multi-schema project with separate directories for each object owner and object type -``` -C: - \my_project - \sources - \hotel - \functions - \packages - \packages_bodies - \procedures - \add_rooms_content.sql - \remove_rooms_by_name.sql - \tables - \rooms.sql - \triggers - \types - \type_bodies - \hr - \functions - \betwnstr.sql - \packages - \package_bodies - \procedures - \award_bonus.sql - \tables - \employees_test.sql - \triggers - \types - \types_bodies - \tests - \hotel - \packages - \test_add_room_content.sql - \test_remove_rooms_by_name.sql - \packages_bodies - \test_add_room_content.sql - \test_remove_rooms_by_name.sql - \hr - \packages - \test_award_bonus.sql - \test_betwnstr.sql - \packages_bodies - \test_award_bonus.sql - \test_betwnstr.sql -``` - - -Windows: -```pwsh -utPLSQL-cli\bin\utplsql run test_runner/pass@db_url ^ - -p=hr,hotel ^ - -source_path=sources ^ - -regex_expression="/(\w+)/(\w+)/(\w+)\..{3}$" ^ - -type_mapping="packages_bodies=PACKAGE BODY/types_bodies=TYPE BODY/triggers=TRIGGER/procedures=PROCEDURE/functions=FUNCTION" ^ - -owner_subexpression=1 ^ - -name_subexpression=3 ^ - -type_subexpression=2 ^ - -test_path=tests -regex_expression="/(\w+)/(\w+)/(\w+)\..{3}$" ^ - -type_mapping="packages_bodies=PACKAGE BODY/types_bodies=TYPE BODY/triggers=TRIGGER/procedures=PROCEDURE/functions=FUNCTION" ^ - -owner_subexpression=1 ^ - -name_subexpression=3 ^ - -type_subexpression=2 ^ - -f=ut_coverage_html_reporter -o=coverage.html ^ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -Bash: -```bash -utPLSQL-cli/bin/utplsql run test_runner/pass@db_urll \ - -p=hr,hotel \ - -source_path=sources \ - -regex_expression="/(\w+)/(\w+)/(\w+)\..{3}$" \ - -type_mapping="packages_bodies=PACKAGE BODY/types_bodies=TYPE BODY/triggers=TRIGGER/procedures=PROCEDURE/functions=FUNCTION" \ - -owner_subexpression=1 \ - -name_subexpression=3 \ - -type_subexpression=2 \ - -test_path=tests -regex_expression="/(\w+)/(\w+)/(\w+)\..{3}$" \ - -type_mapping="body=PACKAGE BODY/type_body=TYPE BODY/trigger=TRIGGER" \ - -owner_subexpression=1 \ - -name_subexpression=3 \ - -type_subexpression=2 \ - -f=ut_coverage_html_reporter -o=coverage.html \ - -f=ut_sonar_test_reporter -o=test_results.xml -``` - -The parameter `type_mapping` accepts a list of a key-value pairs representing a mapping of regex subexpression to database object type. - -To better understand the regular expression used, have a look [here](https://regex101.com/r/Vd97v0/1). - -Tested code is mapped to files in `coverage.html` - -![coverage.html](../images/example_4_coverage_mapping.png) - -Unit test code is mapped to files in `test_results.xml` - -![coverage.html](../images/example_4_test_mapping.png) - -#### Object-file mapping rules - -In order to allow deterministic and accurate mapping of database source-code into project files, the project directory and file structure needs to meet certain criteria. - -- Source code is kept separate from test code (separate directories) -- Each database (source-code) object is stored in an individual file. Package/type specification is kept separate from its body. -- File name (file path) contains the name of database object -- Each file-path clearly identifies object type (by file extension) -- Each file contains representation of database object "as is". No extra commands (like `set echo off` `ALTER SESSION SET PLSQL_CCFLAGS = 'debug:TRUE';`) or blank lines are present before `CREATE TYPE`,`CREATE TYPE` etc. -- When project is spanning across multiple database schemes, each file-path clearly and uniformly identifies object owner - - -#### File mapping from SQL - -The `ut.run` command provides interface to map project into database objects when executing tests. -While it is much easier to perform mapping directly from command line, it is possible to achieve similar functionality from any SQL client. -The main differences when using the `ut.run(...)` command, will be: - -- you can only use single reporter and therefore will get only one report from test execution -- you need to provide fill list of project files rather than point to `sources` and `tests` directories - -Example project directory structure. -``` -C: - \my_project - \sources - \hotel - \functions - \packages - \packages_bodies - \procedures - \add_rooms_content.sql - \remove_rooms_by_name.sql - \tables - \rooms.sql - \triggers - \types - \type_bodies - \hr - \functions - \betwnstr.sql - \packages - \package_bodies - \procedures - \award_bonus.sql - \tables - \employees_test.sql - \triggers - \types - \types_bodies - \tests - \hotel - \packages - \test_add_room_content.sql - \test_remove_rooms_by_name.sql - \packages_bodies - \test_add_room_content.sql - \test_remove_rooms_by_name.sql - \hr - \packages - \test_award_bonus.sql - \test_betwnstr.sql - \packages_bodies - \test_award_bonus.sql - \test_betwnstr.sql -``` - -To execute all tests and map database source code into source file names you could use the following command in any SQL client: - -```sql linenums="1" -begin - ut.run( - ut_varchar2_list('hr','hotel'), - ut_coverage_html_reporter(), - a_source_file_mappings => - ut_file_mapper.build_file_mappings( - a_file_paths => ut_varchar2_list( - 'sources\hotel\procedures\add_rooms_content.sql', - 'sources\hotel\procedures\remove_rooms_by_name.sql', - 'sources\hotel\tables\rooms.sql', - 'sources\hr\functions\betwnstr.sql', - 'sources\hr\procedures\award_bonus.sql', - 'sources\hr\tables\employees_test.sql' - ), - a_regex_pattern => '/(\w+)/(\w+)/(\w+)\..{3}$', - a_object_owner_subexpression => 1, - a_object_name_subexpression => 3, - a_object_type_subexpression => 2, - a_file_to_object_type_mapping => ut_key_value_pairs( - ut_key_value_pair('packages_bodies', 'PACKAGE BODY'), - ut_key_value_pair('types_bodies', 'TYPE BODY'), - ut_key_value_pair('triggers', 'TRIGGER'), - ut_key_value_pair('procedures', 'PROCEDURE'), - ut_key_value_pair('functions', 'FUNCTION') - ) - ) - ); -end; -``` - -To execute all tests and map database tests code into test file names you could use the following command in any SQL client: -```sql linenums="1" -begin - ut.run( - ut_varchar2_list('hr','hotel'), - ut_sonar_test_reporter(), - a_test_file_mappings => - ut_file_mapper.build_file_mappings( - a_file_paths => ut_varchar2_list( - 'tests\hotel\packages\test_add_room_content.sql', - 'tests\hotel\packages\test_remove_rooms_by_name.sql', - 'tests\hotel\packages_bodies\test_add_room_content.sql', - 'tests\hotel\packages_bodies\test_remove_rooms_by_name.sql', - 'tests\hr\packages\test_award_bonus.sql', - 'tests\hr\packages\test_betwnstr.sql', - 'tests\hr\packages_bodies\test_award_bonus.sql', - 'tests\hr\packages_bodies\test_betwnstr.sql' - ), - a_regex_pattern => '/(\w+)/(\w+)/(\w+)\..{3}$', - a_object_owner_subexpression => 1, - a_object_name_subexpression => 3, - a_object_type_subexpression => 2, - a_file_to_object_type_mapping => ut_key_value_pairs( - ut_key_value_pair('packages_bodies', 'PACKAGE BODY'), - ut_key_value_pair('types_bodies', 'TYPE BODY'), - ut_key_value_pair('triggers', 'TRIGGER'), - ut_key_value_pair('procedures', 'PROCEDURE'), - ut_key_value_pair('functions', 'FUNCTION') - ) - ) - ); -end; -``` - -## Reporting coverage outside utPLSQL and in parallel sessions - -utPSLQL allows fo standalone reporting code coverage across multiple database sessions. This functionality enables coverage reporting for external testing tools. - -Following API calls enable the standalone coverage reporting. - -- `ut_runner.coverage_start( coverage_run_id );` - initiates code coverage within a session -- `ut_runner.coverage_stop();` - stops gathering of code coverage within a session -- `.get_report( ... )` - coverage reporters function producing coverage report as pipelined data-set (to be used in SQL query) -- `.get_report_cursor( ... )` - coverage reporters function producing coverage report as ref-cursor - -Example: -```sql linenums="1" ---SESSION 1 --- gather coverage on code using specific coverage_run_id value -declare - l_coverage_run_id raw(32); -begin - l_coverage_run_id := 'A6AA5B7361251CE6E053020011ACA055'; --- l_coverage_run_id := sys_guid; - ut_runner.coverage_start(l_coverage_run_id); - - --The code to gather coverage on goes here - - ut_runner.coverage_stop(); -end; -/ -``` - -```sql linenums="1" ---SESSION 2 --- alternative approach --- gather coverage on code using specific coverage_run_id value -exec ut_runner.coverage_start('A6AA5B7361251CE6E053020011ACA055'); - ---The code to gather coverage on goes here - -exec ut_runner.coverage_stop(); -``` - - -```sql linenums="1" ---SESSION 1 or SESSION2 2 or SESSION 3 --- run after calls in SESSION 1 & 2 are finished --- retrieve coverage report in HTML format coverage_run_id value -select * - from table( - ut_coverage_html_reporter().get_report( - a_coverage_options => ut_coverage_options( - coverage_run_id => 'A6AA5B7361251CE6E053020011ACA055' - ) - ) - ); -``` - -```sql linenums="1" ---SESSION 1 or SESSION2 2 or SESSION 3 --- run after calls in SESSION 1 & 2 are finished -declare - l_results_cursor sys_refcursor; -begin - l_results_cursor := ut_coverage_html_reporter().get_report_cursor( - a_coverage_options => ut_coverage_options( - coverage_run_id => 'A6AA5B7361251CE6E053020011ACA055' - ) - ); - --fetch and process the cursor results - close l_results_cursor; -end; -/ -``` - -Specification of parameters for `get_report` and `get_report_cursor` -```sql linenums="1" -function get_report( - a_coverage_options ut_coverage_options, - a_client_character_set varchar2 := null -) return ut_varchar2_rows pipelined -``` - -```sql linenums="1" -function get_report_cursor( - a_coverage_options ut_coverage_options, - a_client_character_set varchar2 := null -) return sys_refcursor -``` -```sql linenums="1" -ut_coverage_options( - coverage_run_id raw, - schema_names ut_varchar2_rows := null, - exclude_objects ut_varchar2_rows := null, - include_objects ut_varchar2_rows := null, - file_mappings ut_file_mappings := null - include_schema_expr varchar2(4000) := null, - include_object_expr varchar2(4000) := null, - exclude_schema_expr varchar2(4000) := null, - exclude_object_expr varchar2(4000) := null -); -``` - -The `a_client_character_set` is used to provide character set to the report. Coverage reports in XML and HTML format include this information to assure that HMTL/XML encoding tag is aligned with encoding of the report produced. -Use this parameter to provide encoding of your client application. - -The `a_coverage_options` parameter is used to control the scope and formatting of data returned by report. - -`ut_coverage_options` object accepts the following arguments - -- `coverage_run_id` - identifier of coverage run to generate report for - data-type `RAW(32)` -- `schema_names` - optional - list of schema names to include in coverage report - data-type `UT_VARCHAR2_ROWS` -- `exclude_objects` - optional - list of object names to exclude from report - data-type `UT_VARCHAR2_ROWS` -- `include_objects` - optional - list of object names to gather coverage on - data-type `UT_VARCHAR2_ROWS` -- `file_mappings` - optional - list of schema names to gather coverage on - data-type `UT_FILE_MAPPINGS` -- `include_schema_expr` - optional - regular expression to match against schema name to include in coverage - data-type `VARCHAR2(4000)` -- `include_object_expr` - optional - regular expression to match against object name to include in coverage - data-type `VARCHAR2(4000)` -- `exclude_schema_expr` - optional - regular expression to match against schema name to exclude in coverage - data-type `VARCHAR2(4000)` -- `exclude_object_expr` - optional - regular expression to match against object name to exclude in coverage - data-type `VARCHAR2(4000)` - -`coverage_run_id` parameter identifies a common coverage run. The valid value type for that parameter is RAW(32). -It is recommended to use `sys_guid()` to generate a common, unique identifier for a specific coverage run. -If the identifier is not unique, previous runs of coverage that used the same `coverage_run_id` will be aggregated to the resulting coverage report. - -For details on the meaning of `schema_names`, `exclude_objects`, `include_objects`, `file_mappings` see sections above. -Note that data-types of include/exclude/schema lists are different when calling `ut.run` vs. calling `get_report/get_report_cursor`. - diff --git a/docs/userguide/exception-reporting.md b/docs/userguide/exception-reporting.md deleted file mode 100644 index e042d61ed..000000000 --- a/docs/userguide/exception-reporting.md +++ /dev/null @@ -1,131 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -utPLSQL is responsible for handling exceptions wherever they occur in the test run. The framework is trapping most of the exceptions so that the test execution is not affected by individual tests or test packages throwing an exception. -The framework provides a full stacktrace for every exception that was thrown. The reported stacktrace does not include any utPLSQL library calls in it. -To achieve rerunability, the package state invalidation exceptions (ORA-04068, ORA-04061) are not handled and test execution will be interrupted if such exceptions are encountered. This is because of how Oracle behaves on those exceptions. - -Test execution can fail for different reasons. The failures on different exceptions are handled as follows: - -| Problem / error | Framework behavior | -|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| A test package **without body** | each `--%test` is reported as failed with exception, nothing is executed | -| A test package with **invalid body** | each `--%test` is reported as failed with exception, nothing is executed | -| A test package with **invalid spec** | package is not considered a valid unit test package and is excluded from execution. When trying to run a test package with invalid spec explicitly, exception is raised. Only valid specifications are parsed for annotations | -| A test package that is raising an exception in `--%beforeall` | each `--%test` is reported as failed with exception, `--%test`, `--%beforeeach`, `--%beforetest`, `--%aftertest` and `--%aftereach` are not executed. `--%afterall` is executed to allow cleanup of whatever was done in `--%beforeall` | -| A test package that is raising an exception in `--%beforeeach` | each `--%test` is reported as failed with exception, `--%test`, `--%beforetest` and `--%aftertest` is not executed. The `--%aftereach` and `--%afterall` blocks are getting executed to allow cleanup of whatever was done in `--%before...` blocks | -| A test package that is raising an exception in `--%beforetest` | the `--%test` is reported as failed with exception, `--%test` is not executed. The `--%aftertest`, `--%aftereach` and `--%afterall` blocks are getting executed to allow cleanup of whatever was done in `--%before...` blocks | -| A test package that is raising an exception in `--%test` | the `--%test` is reported as failed with exception. The execution of other blocks continues normally | -| A test package that is raising an exception in `--%aftertest` | the `--%test` is reported as failed with exception. The execution of other blocks continues normally | -| A test package that is raising an exception in `--%aftereach` | each `--%test` is reported as failed with exception. | -| A test package that is raising an exception in `--%afterall` | all blocks of the package are executed, as the `--%afterall` is the last step of package execution. Exception in `--%afterall` is not affecting test results. A warning with exception stacktrace is displayed in the summary | - - -!!! warning - If an exception is thrown in an `afterall` procedure then **no failure reported by utPLSQL**.
- Framework will only report a warning on the suite that the `afterall` belongs to. - -Example of reporting with exception thrown in `%beforetest`: -```` -Remove rooms by name - Removes a room without content in it (FAILED - 1) - Does not remove room when it has content - Raises exception when null room name given - -Failures: - - 1) remove_empty_room - - error: ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 39 - ORA-06512: at line 6 - -Finished in ,039346 seconds -3 tests, 0 failed, 1 errored, 0 ignored. -```` - -Example of reporting with exception thrown in `%test`: -``` -Remove rooms by name - Removes a room without content in it (FAILED - 1) - Does not remove room when it has content - Raises exception when null room name given - -Failures: - - 1) remove_empty_room - - error: ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 48 - ORA-06512: at line 6 - -Finished in ,035726 seconds -3 tests, 0 failed, 1 errored, 0 ignored. -``` - -Example of reporting with exception thrown in `%aftertest`: -``` -Remove rooms by name - Removes a room without content in it (FAILED - 1) - Does not remove room when it has content - Raises exception when null room name given - -Failures: - - 1) remove_empty_room - - error: ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 42 - ORA-06512: at line 6 - -Finished in ,045523 seconds -3 tests, 0 failed, 1 errored, 0 ignored. -``` - -Example of reporting with exception thrown in `%aftereach`: -``` -Remove rooms by name - Removes a room without content in it (FAILED - 1) - Does not remove room when it has content (FAILED - 2) - Raises exception when null room name given (FAILED - 3) - -Failures: - - 1) remove_empty_room - - error: ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 31 - ORA-06512: at line 6 - - 2) room_with_content - - error: ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 31 - ORA-06512: at line 6 - - 3) null_room_name - - error: ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 31 - ORA-06512: at line 6 - -Finished in ,034863 seconds -3 tests, 0 failed, 3 errored, 0 ignored. -``` - -Example of reporting with exception thrown in `%afterall`: -``` -Remove rooms by name - Removes a room without content in it - Does not remove room when it has content - Raises exception when null room name given - -Warnings: - - 1) test_remove_rooms_by_name - Afterall procedure failed: - ORA-20001: Test exception - ORA-06512: at "UT3.TEST_REMOVE_ROOMS_BY_NAME", line 35 - ORA-06512: at line 6 - -Finished in ,044902 seconds -3 tests, 0 failed, 0 errored, 0 ignored. 1 warning(s) -``` diff --git a/docs/userguide/expectations.md b/docs/userguide/expectations.md deleted file mode 100644 index 0ea5e2e73..000000000 --- a/docs/userguide/expectations.md +++ /dev/null @@ -1,1935 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -## Expectation concepts - -Validation of the code under test (the tested logic of procedure/function etc.) is performed by comparing the actual data against the expected data. - -utPLSQL uses expectations and matchers to perform the check on the data. - -Example of an expectation -```sql linenums="1" -begin - ut.expect( 'the tested value' ).to_equal('the expected value'); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: 'the tested value' (varchar2) was expected to equal: 'the expected value' (varchar2) - at "anonymous block", line 2 -``` - -Expectation is a combination of: - -- the expected value -- optional custom message for the expectation -- the matcher used to perform comparison -- the matcher parameters (actual value), depending on the matcher type - - -Matcher defines the comparison operation to be performed on expected (and actual) value. -Pseudo-code: -```sql linenums="1" - ut.expect( a_actual {data-type} [, a_message {varchar2}] ).to_( {matcher} ); - ut.expect( a_actual {data-type} [, a_message {varchar2}] ).not_to( {matcher} ); -``` - -Expectations provide two variants of syntax that you can use. Both variants are functionally-equal but give different usage flexibility. - -Syntax where matcher is passed as parameter to the expectation: -```sql linenums="1" - ut.expect( a_actual ).to_( {matcher} ); - ut.expect( a_actual ).not_to( {matcher} ); - -- example - ut.expect( 1 ).to_( be_null() ); -``` - -Shortcut syntax, where matcher is directly part of expectation: -```sql linenums="1" - ut.expect( a_actual ).to_{matcher}; - ut.expect( a_actual ).not_to_{matcher}; - - --example - ut.expect( 1 ).to_be_null(); -``` - -When using shortcut syntax you don't need to surround matcher with brackets. Shortcut syntax is provided for convenience. - -If you would like to perform more dynamic checks in your code, you could pass the matcher into a procedure like in the below example: -```sql linenums="1" -declare - procedure do_check( p_actual varchar2, p_matcher ut_matcher ) is - begin - ut.expect(p_actual).to_( p_matcher ); - end; -begin - do_check( 'a', equal('b') ); - do_check( 'Alibaba', match('ali','i') ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: 'a' (varchar2) was expected to equal: 'b' (varchar2) - at "anonymous block", line 4 - at "anonymous block", line 7 -SUCCESS - Actual: 'Alibaba' (varchar2) was expected to match: 'ali' , modifiers 'i' -``` - -!!! note - In order to keep the document brief, the examples in the document are only using the standalone expectations syntax. - -## Using expectations - -There are two ways to use expectations: -- by invoking utPLSQL framework to execute suite(s) of utPLSQL tests -- without invoking the utPLSQL framework - running expectations standalone - -## Running expectations within utPLSQL framework - -When expectations are run as a part of a test suite, the framework tracks: - -- status of each expectation -- outcomes (messages) produced by each expectation -- call stack to each expectation - -In this case: - -- expectation results of are not sent directly to `dbms_output` -- utPLSQL Reporters used when running suite decide on how the expectation results are formatted and displayed - -Example of test suite with an expectation: -```sql linenums="1" -create or replace package test_divide as - --%suite(Divide two numbers) - - --%test(Returns result when divisor is not zero) - procedure divide_6_by_2; - - --%test(Throws exception when divisor is zero) - --%throws(zero_divide) - procedure divide_by_0_throws; -end; -/ - -create or replace package body test_divide as - procedure divide_6_by_2 is - begin - ut.expect(6/2).to_equal(3); - end; - - procedure divide_by_0_throws is - begin - ut.expect(6/0).to_be_not_null(); - end; -end; -/ - -exec ut.run('test_divide'); - -drop package test_divide; -``` - -Produces following outputs: -``` -Package TEST_DIVIDE compiled - - -Package Body TEST_DIVIDE compiled - -Divide two numbers - Returns result when divisor is not zero [.003 sec] - Throws exception when divisor is zero [.003 sec] - -Finished in .009774 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) - - - -PL/SQL procedure successfully completed. - - -Package TEST_DIVIDE dropped. -``` - -Please read about different options for [running test suites](running-unit-tests.md). - -## Running expectations outside utPLSQL framework -When expectations are invoked outside of utPLSQL framework the outputs from expectations are redirected straight to `dbms_output`. - -!!! note - The output from expectation contains call stack trace only when expectation fails.
- Source code of the line which called the expectation is only reported when the line is part of in-database code (package) and the user calling expectation has privileges to see that source code. - -!!! warning "**Important**" - Please do not use expectations as part of your production code. They are not designed to be used as part of your code. Expectations are meant to be used only as part of your day-to-day testing activities. - - -## Matchers -utPLSQL provides the following matchers to perform checks on the expected and actual values. - -- `be_between( a_upper_bound {data-type}, a_lower_bound {data-type} )` -- `be_empty()` -- `be_false()` -- `be_greater_than( a_expected {data-type} )` -- `be_greater_or_equal( a_expected {data-type} )` -- `be_less_or_equal( a_expected {data-type} )` -- `be_less_than( a_expected {data-type} )` -- `be_like( a_mask {varchar2} [, a_escape_char {varchar2}] )` -- `be_not_null()` -- `be_null()` -- `be_true()` -- `equal( a_expected {data-type} [, a_nulls_are_equal {boolean}] )` -- `contain( a_expected {data-type})` -- `have_count( a_expected {integer} )` -- `match( a_patter {varchar2} [, a_modifiers {varchar2}] )` - -## Providing a custom message -You can provide a custom failure message by passing it as the second parameter to the expectation. -`ut.expect( a_actual {data-type}, a_message {varchar2} ).to_{matcher}` - -Example: -````sql linenums="1" -exec ut.expect( 'supercat', 'checked superhero-animal was not a dog' ).to_equal('superdog'); -```` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - "checked superhero-animal was not a dog" - Actual: 'supercat' (varchar2) was expected to equal: 'superdog' (varchar2) - at "anonymous block", line 1 -``` -If the message is provided, it is being added to the normal failure message returned by the matcher. -This is mostly useful when your expectations accept dynamic content, as you can provide additional context to make failing test results more readable. - -In most cases, there is no need to provide custom message to expectation. This is because utPLSQL identifies: - -- The test used to execute the expectation -- The line number where the expectation is placed in your test code -- The line text of the expectation - -Custom message is useful, if your expectation is placed in a shared procedure to perform a check and your test is using the procedure multiple times. - -Example: -```sql linenums="1" -create or replace package shared_expectation_test is - --%suite - - --%test - procedure the_test; -end; -/ -create or replace package body shared_expectation_test is - procedure table_is_empty(p_table_name varchar2) is - l_count integer; - begin - execute immediate 'select count(*) from '||p_table_name into l_count; - ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); - end; - - procedure the_test is - begin - table_is_empty('ALL_USERS'); - table_is_empty('ALL_TABLES'); - end; -end; -/ - -exec ut.run('shared_expectation_test'); -``` - -Returns following output via DBMS_OUTPUT: -``` -shared_expectation_test - the_test [.064 sec] (FAILED - 1) - -Failures: - - 1) the_test - "Checking table ALL_USERS" - Actual: 28 (number) was expected to equal: 0 (number) - at "UT3_USER.SHARED_EXPECTATION_TEST.TABLE_IS_EMPTY", line 6 ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); - at "UT3_USER.SHARED_EXPECTATION_TEST.THE_TEST", line 11 - - "Checking table ALL_TABLES" - Actual: 55 (number) was expected to equal: 0 (number) - at "UT3_USER.SHARED_EXPECTATION_TEST.TABLE_IS_EMPTY", line 6 ut.expect( l_count, 'Checking table '||p_table_name ).to_equal(0); - at "UT3_USER.SHARED_EXPECTATION_TEST.THE_TEST", line 12 - -Finished in .066344 seconds -1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -In the tests results window you can see the list of failed expectations for a test as well as: - -- the additional message for expectation -- the reason why the expectation failed -- the line number of the expectation -- the line text of the expectations -- the call stack for the expectation (in the example it's the lines that called the procedure `table_is_empty`) - -## 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: -```sql linenums="1" -begin - ut.expect( a_actual {data-type} ).to_{matcher}; - ut.expect( a_actual {data-type} ).to_( {matcher} ); -end; -``` - -Syntax to check for matcher evaluating to false: -```sql linenums="1" -begin - ut.expect( a_actual {data-type} ).not_to_{matcher}; - ut.expect( a_actual {data-type} ).not_to( {matcher} ); -end; -``` - -If a matcher evaluated to NULL, then both `to_` and `not_to` will cause the expectation to report failure. - -Example: -```sql linenums="1" -declare - l_actual boolean; -begin - ut.expect( l_actual ).to_be_true(); - ut.expect( l_actual ).not_to_be_true(); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: NULL (boolean) was expected to be true - at "anonymous block", line 4 -FAILURE - Actual: NULL (boolean) was expected not to be true - at "anonymous block", line 5 -``` -Since NULL is neither *true* nor *false*, both expectations will report failure. - -## Supported data types - -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 | 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 | -| **be_within().of_()** | | | | X | X | X | X | X | | | | | | | | -| **be_within_pct().of_()** | | | | | X | | | | | | | | | | | - -## Expecting exceptions - -Testing is not limited to checking for happy-path scenarios. When writing tests, you often want to validate that in specific scenarios, an exception is thrown. - -Use the `--%throws` annotation, to test for expected exceptions. - -Example: -```sql linenums="1" -create or replace function divide(x varchar2, y varchar2) return number is -begin - return x/y; -end; -/ - -create or replace package test_divide as - --%suite(Divide function) - - --%test(Throws divisor equal) - --%throws(-01476) - procedure raises_divisor_exception; -end; -/ - -create or replace package body test_divide is - - procedure raises_divisor_exception is - x integer; - begin - x := divide(6,0); - end; - -end; -/ - -exec ut.run('test_divide'); -``` - -Returns following output via DBMS_OUTPUT: -``` -Divide function - Throws divisor equal [.007 sec] - -Finished in .009229 seconds -1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -For more details see documentation of the [`--%throws` annotation.](annotations.md#throws) - - -## Matchers - -You can choose different matchers to validate that your PL/SQL code is working as expected. - - -### be_between -Validates that the actual value is between the lower and upper bound. - -Example: -```sql linenums="1" -declare - l_timestamp timestamp := current_timestamp; - l_timestamp_tz timestamp with time zone := systimestamp; - l_timestamp_ltz timestamp with local time zone := systimestamp; - l_interval_ds interval day to second := interval '1' second; - l_interval_ym interval year to month := interval '1' year; -begin - ut.expect( 3 ).to_be_between( 1, 3 ); - ut.expect( 5 ).to_( be_between( 1, 3 ) ); - ut.expect( 3 ).not_to_be_between( 1, 3 ); - ut.expect( 5 ).not_to( be_between( 1, 3 ) ); - ut.expect( sysdate ).to_be_between( sysdate, sysdate + 1 ); - ut.expect( l_timestamp ).to_be_between( l_timestamp, l_timestamp ); - ut.expect( systimestamp ).to_be_between( l_timestamp_tz, systimestamp ); - ut.expect( systimestamp ).to_be_between( l_timestamp_ltz, l_timestamp_ltz ); - ut.expect( l_interval_ds ).to_be_between( interval '0.1' second, interval '1' day ); - ut.expect( l_interval_ym ).to_be_between( interval '12' month, interval '12' year ); - ut.expect( 'Abb' ).to_be_between( 'Aba', 'Abc' ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: 3 (number) was expected to be between: 1 and 3 -FAILURE - Actual: 5 (number) was expected to be between: 1 and 3 - at "anonymous block", line 9 -FAILURE - Actual: 3 (number) was expected not to be between: 1 and 3 - at "anonymous block", line 10 -SUCCESS - Actual: 5 (number) was expected not to be between: 1 and 3 -SUCCESS - Actual: 2019-07-07T21:25:27 (date) was expected to be between: 2019-07-07T21:25:27 and 2019-07-08T21:25:27 -SUCCESS - Actual: 2019-07-07T22:25:27.701546000 (timestamp) was expected to be between: 2019-07-07T22:25:27.701546000 and 2019-07-07T22:25:27.701546000 -SUCCESS - Actual: 2019-07-07T21:25:27.705768000 +00:00 (timestamp with time zone) was expected to be between: 2019-07-07T21:25:27.701596000 +00:00 and 2019-07-07T21:25:27.705808000 +00:00 -FAILURE - The matcher 'be between' cannot be used with data type (timestamp with time zone). - at "anonymous block", line 15 -SUCCESS - Actual: +000000000 00:00:01.000000000 (interval day to second) was expected to be between: +000000000 00:00:00.100000000 and +000000001 00:00:00.000000000 -SUCCESS - Actual: +000000001-00 (interval year to month) was expected to be between: +000000001-00 and +000000012-00 -SUCCESS - Actual: 'Abb' (varchar2) was expected to be between: 'Aba' and 'Abc' -``` - -### be_empty -Unary matcher that validates if the provided dataset is empty. - -Can be used with `BLOB`,`CLOB`, `refcursor` or `nested table`/`varray` passed as `ANYDATA` - -!!! note - BLOB/CLOB that is initialized is not NULL but it is actually equal to `empty_blob()`/`empty_clob()`. - - -Example: -```sql linenums="1" -declare - l_cursor sys_refcursor; -begin - open l_cursor for select * from dual where 0=1; - ut.expect( l_cursor ).to_be_empty(); - ut.expect( anydata.convertCollection(ut_varchar2_list()) ).to_( be_empty() ); - ut.expect( empty_clob() ).not_to_be_empty(); - ut.expect( empty_blob() ).not_to( be_empty() ); - ut.expect( 1 ).not_to( be_empty() ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: (refcursor [ count = 0 ]) - Data-types: - VARCHAR2 - Data: - was expected to be empty -SUCCESS - Actual: (ut3.ut_varchar2_list [ count = 0 ]) - Data-types: - VARCHAR2 - Data: - was expected to be empty -FAILURE - Actual: EMPTY (clob) was expected not to be empty - at "anonymous block", line 7 -FAILURE - Actual: EMPTY (blob) was expected not to be empty - at "anonymous block", line 8 -FAILURE - The matcher 'be empty' cannot be used with data type (number). - at "anonymous block", line 9 -``` - -### be_false -Unary matcher that validates if the provided value is false. - -Usage: -```sql linenums="1" -begin - ut.expect( ( 1 = 0 ) ).to_be_false(); - ut.expect( ( 1 = 1 ) ).to_( be_false() ); - ut.expect( ( 1 = 0 ) ).not_to_be_false(); - ut.expect( ( 1 = 1 ) ).not_to( be_false() ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: FALSE (boolean) was expected to be false -FAILURE - Actual: TRUE (boolean) was expected to be false - at "anonymous block", line 3 -FAILURE - Actual: FALSE (boolean) was expected not to be false - at "anonymous block", line 4 -SUCCESS - Actual: TRUE (boolean) was expected not to be false -``` - -### be_greater_or_equal -Checks if the actual value is greater or equal than the expected. - -Usage: -```sql linenums="1" -begin - ut.expect( sysdate ).to_be_greater_or_equal( sysdate - 1 ); - ut.expect( sysdate ).to_( be_greater_or_equal( sysdate + 1 ) ); - ut.expect( sysdate ).not_to_be_greater_or_equal( sysdate - 1 ); - ut.expect( sysdate ).not_to( be_greater_or_equal( sysdate + 1 ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: 2019-07-07T22:43:29 (date) was expected to be greater or equal: 2019-07-06T22:43:29 (date) -FAILURE - Actual: 2019-07-07T22:43:29 (date) was expected to be greater or equal: 2019-07-08T22:43:29 (date) - at "anonymous block", line 3 -FAILURE - Actual: 2019-07-07T22:43:29 (date) was expected not to be greater or equal: 2019-07-06T22:43:29 (date) - at "anonymous block", line 4 -SUCCESS - Actual: 2019-07-07T22:43:29 (date) was expected not to be greater or equal: 2019-07-08T22:43:29 (date) -``` - -### be_greater_than -Checks if the actual value is greater than the expected. - -Usage: -```sql linenums="1" -begin - ut.expect( 2 ).to_be_greater_than( 1 ); - ut.expect( 0 ).to_( be_greater_than( 1 ) ); - ut.expect( 2 ).not_to_be_greater_than( 1 ); - ut.expect( 0 ).not_to( be_greater_than( 1 ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: 2 (number) was expected to be greater than: 1 (number) -FAILURE - Actual: 0 (number) was expected to be greater than: 1 (number) - at "anonymous block", line 3 -FAILURE - Actual: 2 (number) was expected not to be greater than: 1 (number) - at "anonymous block", line 4 -SUCCESS - Actual: 0 (number) was expected not to be greater than: 1 (number) -``` - -### be_less_or_equal -Checks if the actual value is less or equal than the expected. - -Usage: -```sql linenums="1" -begin - ut.expect( 3 ).to_be_less_or_equal( 3 ); - ut.expect( 4 ).to_( be_less_or_equal( 3 ) ); - ut.expect( 3 ).not_to_be_less_or_equal( 3 ); - ut.expect( 4 ).not_to( be_less_or_equal( 3 ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: 3 (number) was expected to be less or equal: 3 (number) -FAILURE - Actual: 4 (number) was expected to be less or equal: 3 (number) - at "anonymous block", line 3 -FAILURE - Actual: 3 (number) was expected not to be less or equal: 3 (number) - at "anonymous block", line 4 -SUCCESS - Actual: 4 (number) was expected not to be less or equal: 3 (number) -``` - -### be_less_than -Checks if the actual value is less than the expected. - -Usage: -```sql linenums="1" -begin - ut.expect( 3 ).to_be_less_than( 2 ); - ut.expect( 0 ).to_( be_less_than( 2 ) ); - ut.expect( 3 ).not_to_be_less_than( 2 ); - ut.expect( 0 ).not_to( be_less_than( 2 ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: 3 (number) was expected to be less than: 2 (number) - at "anonymous block", line 2 -SUCCESS - Actual: 0 (number) was expected to be less than: 2 (number) -SUCCESS - Actual: 3 (number) was expected not to be less than: 2 (number) -FAILURE - Actual: 0 (number) was expected not to be less than: 2 (number) - at "anonymous block", line 5 -``` - -### be_like -Validates that the actual value is like the expected expression. - -Syntax: - -`ut.expect( a_actual ).to_be_like( a_mask [, a_escape_char] )` - -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`. - -Usage: -```sql linenums="1" -begin - ut.expect( 'Lorem_impsum' ).to_be_like( '%rem%'); - ut.expect( 'Lorem_impsum' ).to_be_like( '%rem\_i%', '\' ); - ut.expect( 'Lorem_impsum' ).to_( be_like( 'Lor_m%' ) ); - ut.expect( 'Lorem_impsum' ).not_to_be_like( '%rem%'); - ut.expect( 'Lorem_impsum' ).not_to( be_like( '%reM%') ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: 'Lorem_impsum' (varchar2) was expected to be like: '%rem%' -SUCCESS - Actual: 'Lorem_impsum' (varchar2) was expected to be like: '%rem\_i%' , escape '\' -SUCCESS - Actual: 'Lorem_impsum' (varchar2) was expected to be like: 'Lor_m%' -FAILURE - Actual: 'Lorem_impsum' (varchar2) was expected not to be like: '%rem%' - at "anonymous block", line 5 -SUCCESS - Actual: 'Lorem_impsum' (varchar2) was expected not to be like: '%reM%' -``` - -### be_not_null -Unary matcher that validates if the actual value is not null. - -Usage: -```sql linenums="1" -begin - ut.expect( to_clob('ABC') ).to_be_not_null(); - ut.expect( to_clob('') ).to_( be_not_null() ); - ut.expect( to_clob('ABC') ).not_to_be_not_null(); - ut.expect( '').not_to( be_not_null() ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: 'ABC' (clob) was expected to be not null -FAILURE - Actual: NULL (clob) was expected to be not null - at "anonymous block", line 3 -FAILURE - Actual: 'ABC' (clob) was expected not to be not null - at "anonymous block", line 4 -SUCCESS - Actual: NULL (varchar2) was expected not to be not null -``` - -### be_null -Unary matcher that validates if the actual value is null. - -Usage: -```sql linenums="1" -begin - ut.expect( '' ).to_be_null(); - ut.expect( 0 ).to_( be_null() ); - ut.expect( '' ).not_to_be_null(); - ut.expect( 0 ).not_to( be_null() ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: NULL (varchar2) was expected to be null -FAILURE - Actual: 0 (number) was expected to be null - at "anonymous block", line 3 -FAILURE - Actual: NULL (varchar2) was expected not to be null - at "anonymous block", line 4 -SUCCESS - Actual: 0 (number) was expected not to be null -``` - -### be_true -Unary matcher that validates if the provided value is true. - -Usage: -```sql linenums="1" -begin - ut.expect( ( 1 = 0 ) ).to_be_true(); - ut.expect( ( 1 = 1 ) ).to_( be_true() ); - ut.expect( ( 1 = 0 ) ).not_to_be_true(); - ut.expect( ( 1 = 1 ) ).not_to( be_true() ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: FALSE (boolean) was expected to be true - at "anonymous block", line 2 -SUCCESS - Actual: TRUE (boolean) was expected to be true -SUCCESS - Actual: FALSE (boolean) was expected not to be true -FAILURE - Actual: TRUE (boolean) was expected not to be true - at "anonymous block", line 5 -``` - -### have_count -Unary matcher that validates if the provided dataset count is equal to expected value. - -Can be used with `refcursor`, `json` or `table type` - -Usage: -```sql linenums="1" -declare - l_cursor sys_refcursor; - l_collection ut_varchar2_list; -begin - open l_cursor for select * from dual connect by level <=10; - ut.expect( l_cursor ).to_have_count(10); - open l_cursor for select rownum from xmltable('1 to 5'); - ut.expect( l_cursor ).to_( have_count(10) ); - l_collection := ut_varchar2_list( 'a', 'a', 'b' ); - ut.expect( anydata.convertCollection( l_collection ) ).not_to_have_count(10); - ut.expect( anydata.convertCollection( l_collection ) ).not_to( have_count(3) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: (refcursor [ count = 10 ]) was expected to have [ count = 10 ] -FAILURE - Actual: (refcursor [ count = 5 ]) was expected to have [ count = 10 ] - at "anonymous block", line 8 -SUCCESS - Actual: ut3.ut_varchar2_list [ count = 3 ] was expected not to have [ count = 10 ] -FAILURE - Actual: ut3.ut_varchar2_list [ count = 3 ] was expected not to have [ count = 3 ] - at "anonymous block", line 11 -``` - -### match -Validates that the actual value is matching the expected regular expression. - -Syntax: - -`ut.expect( a_actual ).to_match( a_pattern [, a_modifiers] );` - -Parameters `a_pattern` and `a_modifiers` represent a valid regexp pattern accepted by [Oracle REGEXP_LIKE condition](https://docs.oracle.com/database/121/SQLRF/conditions007.htm#SQLRF00501) - -Usage: -```sql linenums="1" -begin - ut.expect( '123-456-ABcd' ).to_match( '\d{3}-\d{3}-[a-z]{4}', 'i' ); - ut.expect( 'some value' ).to_( match( '^some.*' ) ) ; - ut.expect( '123-456-ABcd' ).not_to_match( '\d{3}-\d{3}-[a-z]{4}', 'i' ); - ut.expect( 'some value' ).not_to( match( '^some.*' ) ) ; -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: '123-456-ABcd' (varchar2) was expected to match: '\d{3}-\d{3}-[a-z]{4}' , modifiers 'i' -SUCCESS - Actual: 'some value' (varchar2) was expected to match: '^some.*' -FAILURE - Actual: '123-456-ABcd' (varchar2) was expected not to match: '\d{3}-\d{3}-[a-z]{4}' , modifiers 'i' - at "anonymous block", line 4 -FAILURE - Actual: 'some value' (varchar2) was expected not to match: '^some.*' - at "anonymous block", line 5 -``` - -### equal -The `equal` matcher is very restrictive. Test using this matcher succeeds only when the compared data-types are exactly the same. -If you are comparing a `varchar2` to a `number`, it will fail even if the text contains the same numeric value as the number. -The matcher will also fail when comparing a `timestamp` to a `timestamp with timezone` data-type etc. - -The matcher enables detection of data-type changes. -If you expect your variable to be a number and it is now some other type, the test will fail and give you early indication of a potential problem. - -To keep it simple, the `equal` matcher will only succeed if you compare apples to apples. - -Syntax: - -`ut.expect( a_actual ).to_equal( a_expected [, a_nulls_are_equal])[.advanced_options]` -Example usage -```sql linenums="1" -declare - l_actual varchar2(20); - l_expected varchar2(20); -begin - --Arrange - l_actual := 'a dog'; - --Assert - ut.expect( l_actual ).to_equal( 'other_dog' ); - ut.expect( l_actual ).to_equal( '' ); - ut.expect( l_actual ).to_equal( 1 ); - - l_actual := null; - ut.expect( l_actual ).to_equal( '' ); - ut.expect( l_actual ).to_equal( '', a_nulls_are_equal => false ); - ut.expect( l_actual ).not_to_equal( '' ); - ut.expect( sysdate ).to_equal( sysdate ); - ut.expect( sysdate ).to_equal( current_timestamp ); - ut.expect( current_timestamp ).to_equal( systimestamp ); - ut.expect( to_clob('varchar') ).to_equal( 'varchar' ); - ut.expect( to_blob('aa') ).to_equal( to_blob('aa') ); - ut.expect( to_clob('aa') ).to_equal( to_clob('aa') ); - ut.expect( to_blob('aa') ).to_equal( to_clob('aa') ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: 'a dog' (varchar2) was expected to equal: 'other_dog' (varchar2) - at "anonymous block", line 8 -FAILURE - Actual: 'a dog' (varchar2) was expected to equal: NULL (varchar2) - at "anonymous block", line 9 -FAILURE - Actual (varchar2) cannot be compared to Expected (number) using matcher 'equal'. - at "anonymous block", line 10 -SUCCESS - Actual: NULL (varchar2) was expected to equal: NULL (varchar2) -FAILURE - Actual: NULL (varchar2) was expected to equal: NULL (varchar2) - at "anonymous block", line 14 -FAILURE - Actual: NULL (varchar2) was expected not to equal: NULL (varchar2) - at "anonymous block", line 15 -SUCCESS - Actual: 2019-07-07T22:50:21 (date) was expected to equal: 2019-07-07T22:50:21 (date) -FAILURE - Actual (date) cannot be compared to Expected (timestamp with time zone) using matcher 'equal'. - at "anonymous block", line 17 -FAILURE - Actual: 2019-07-07T23:50:21.159268000 +01:00 (timestamp with time zone) was expected to equal: 2019-07-07T22:50:21.159296000 +00:00 (timestamp with time zone) - at "anonymous block", line 18 -FAILURE - Actual (clob) cannot be compared to Expected (varchar2) using matcher 'equal'. - at "anonymous block", line 19 -SUCCESS - Actual: 'AA' (blob) was expected to equal: 'AA' (blob) -SUCCESS - Actual: 'aa' (clob) was expected to equal: 'aa' (clob) -FAILURE - Actual (blob) cannot be compared to Expected (clob) using matcher 'equal'. - at "anonymous block", line 22 -``` - - -!!! note - **by default, comparing NULL to NULL gives success**
- The `a_nulls_are_equal` parameter controls the behavior of a `null = null` comparison.
- To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal => false` to the `equal` matcher. - -### contain - -This matcher supports only compound data-types comparison. It check if the actual set contains all values of expected subset. - -When comparing data using the `contain` matcher, the data-types of columns for compared compound types must be exactly the same. - -The matcher supports all advanced comparison options as `equal` like: `include` , `exclude`, `join_by` etc.. - -The matcher is successful when actual data set contains all of the values from expected results. - -The matcher will cause a test to fail if actual data set does not contain some of expected values. - -![included_set](../images/venn21.gif) - -**Example 1.** -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - --Arrange - open l_actual for select rownum as rn from dual a connect by level < 10; - open l_expected for select rownum as rn from dual a connect by level < 4 - union all select rownum as rn from dual a connect by level < 4; - - --Act - ut.expect(l_actual).to_contain(l_expected); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: refcursor [ count = 9 ] was expected to contain: refcursor [ count = 6 ] - Diff: - Rows: [ 3 differences ] - Missing: 1 - Missing: 2 - Missing: 3 - at "anonymous block", line 11 -``` - - -When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicates. - -**Example 2.** -```sql linenums="1" -declare - l_actual ut_varchar2_list; - l_expected ut_varchar2_list; -begin - l_actual := ut_varchar2_list( 1, 2, 3, 4, 5, 6, 7, 8, 1 ); - l_expected := ut_varchar2_list( 1, 2, 1, 2 ); - ut.expect( anydata.convertCollection( l_actual ) ).to_contain( anydata.convertCollection( l_expected ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: ut3.ut_varchar2_list [ count = 9 ] was expected to contain: ut3.ut_varchar2_list [ count = 4 ] - Diff: - Rows: [ 1 differences ] - Missing: 2 - at "anonymous block", line 7 -``` - -The negated version of `contain` ( `not_to_contain` ) is successful only when all values from expected set are not part of actual (they are disjoint and there is no overlap). - - -![not_overlapping_set](../images/venn22.gif) - -**Example 3.** -```sql linenums="1" -declare - l_actual ut_varchar2_list; - l_expected ut_varchar2_list; -begin - l_actual := ut_varchar2_list( 'A', 'B', 'C' ); - l_expected := ut_varchar2_list( 'A', 'B', 'E' ); - ut.expect( anydata.convertCollection( l_actual ) ).to_contain( anydata.convertCollection( l_expected ) ); - ut.expect( anydata.convertCollection( l_actual ) ).not_to_contain( anydata.convertCollection( l_expected ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: ut3.ut_varchar2_list [ count = 3 ] was expected to contain: ut3.ut_varchar2_list [ count = 3 ] - Diff: - Rows: [ 1 differences ] - Missing: E - at "anonymous block", line 7 -FAILURE - Actual: (ut3.ut_varchar2_list [ count = 3 ]) - Data-types: - VARCHAR2 - Data: - ABC - was expected not to contain:(ut3.ut_varchar2_list [ count = 3 ]) - Data-types: - VARCHAR2 - Data: - ABE - at "anonymous block", line 8 -``` - -**Example 4.** - -```sql linenums="1" -declare - l_actual ut_varchar2_list; - l_expected ut_varchar2_list; -begin - l_actual := ut_varchar2_list( 'A', 'B', 'C', 'D' ); - l_expected := ut_varchar2_list( 'A', 'B', 'D' ); - ut.expect( anydata.convertCollection( l_actual ) ).to_contain( anydata.convertCollection( l_expected ) ); - ut.expect( anydata.convertCollection( l_actual ) ).not_to_contain( anydata.convertCollection( l_expected ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: ut3.ut_varchar2_list [ count = 4 ] was expected to contain: ut3.ut_varchar2_list [ count = 3 ] -FAILURE - Actual: (ut3.ut_varchar2_list [ count = 4 ]) - Data-types: - VARCHAR2 - Data: - ABCD - was expected not to contain:(ut3.ut_varchar2_list [ count = 3 ]) - Data-types: - VARCHAR2 - Data: - ABD - at "anonymous block", line 8 -``` - -**Example 5.** - -```sql linenums="1" -declare - l_actual ut_varchar2_list; - l_expected ut_varchar2_list; -begin - l_actual := ut_varchar2_list( 'A', 'B', 'C' ); - l_expected := ut_varchar2_list( 'D', 'E', 'F' ); - ut.expect( anydata.convertCollection( l_actual ) ).to_contain( anydata.convertCollection( l_expected ) ); - ut.expect( anydata.convertCollection( l_actual ) ).not_to_contain( anydata.convertCollection( l_expected ) ); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: ut3.ut_varchar2_list [ count = 3 ] was expected to contain: ut3.ut_varchar2_list [ count = 3 ] - Diff: - Rows: [ 3 differences ] - Missing: D - Missing: E - Missing: F - at "anonymous block", line 7 -SUCCESS - Actual: (ut3.ut_varchar2_list [ count = 3 ]) - Data-types: - VARCHAR2 - Data: - ABC - was expected not to contain:(ut3.ut_varchar2_list [ count = 3 ]) - Data-types: - VARCHAR2 - Data: - DEF -``` - -### to_be_within of - -Determines whether expected value is within range (tolerance) from another value. - -The logical formual used for calcuating the matcher is: -``` - result := ( abs( expected - actual ) <= distance ) -``` -The actual formula used for calculation is more complex to handle different data-types of expected/actual values as well as differnet types of distance value. -The matcher will fail if the `expected` and `actual` are more than `distance` apart from each other. -The matcher will fail if the dataypes of `expected` and `actual` are not the same. - -The matcher works with data-types: `number`, `date`, `timestamp`, `timestamp with time zone`, `timestamp with local time zone` -The data-types of compared values must match exactly and if type does not match, the expectation will fail. - -| expected/actual
data-type | distance data-type | -|:------------------------------:|:----------------------:| -| number | number | -| date | interval day to second | -| date | interval year to month | -| timestamp | interval day to second | -| timestamp | interval year to month | -| timestamp with time zone | interval day to second | -| timestamp with time zone | interval year to month | -| timestamp with local time zone | interval day to second | -| timestamp with local time zone | interval year to month | - - -The distance must be expressed as a non-negative number or non-negative interval. - ->Note: -> Interval year-to-moth as a distance is giving sucess if the distance between the given dates/timestamps evaluates to value less or equal of the specified interval -> Keep in mind that a checking for distance of `interval '0-1' year to month` will actuall be successful if the distance is less than a month and 15 days. -> This is due to how oracle evaluates conversion between timestamp difference converted to `year to month interval`. -> The behavior is similar to a call to `months_between()` function with results rounded to full monts ie. round(months_between(date, date)) - -**Example 1.** -```sql linenums="1" -begin - ut.expect(3).to_be_within(1).of_(4); -end; -/ -``` - -**Example 2.** -```sql linenums="1" -begin - ut.expect(3).to_be_within(1).of_(5); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -Failures: - - 1) wihtin_test - Actual: 3 (number) was expected to be within 1 of 5 (number) - at "UT3_DEVELOP.UT_BE_WITHIN.OF_", line 48 l_result.expectation.to_(l_result ); - at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5 -``` - -**Example 3.** -```sql linenums="1" -begin - ut.expect(sysdate).to_be_within(interval '1' day).of_(sysdate+2); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -Failures: - - 1) wihtin_test - Actual: 2020-06-07T13:32:58 (date) was expected to be within 1 day of 2020-06-09T13:32:58 (date) - at "UT3_DEVELOP.UT_BE_WITHIN.OF_", line 55 l_result.expectation.to_(l_result ); - at "UT3_DEVELOP.TEST_BETWNSTR.WIHTIN_TEST", line 5 -``` - - -### to_be_within_pct of - -Determines whether actual value is within percentage range of expected value. -The matcher only works with `number` data-type. - -The percentage deviation (distance) must be expressed as a non-negative number. -The formula used for calcuation of expectation is: -``` - result := ( ( distance ) * expected >= abs( expected - actual ) * 100 ) -``` - -**Example 1.** -```sql linenums="1" -begin - ut.expect(9).to_be_within_pct(10).of_(10); -end; -/ -``` - -``` -SUCCESS - Actual: 9 (number) was expected to be within 10 % of 10 (number) -``` - - -## Comparing cursors, object types, nested tables and varrays - -utPLSQL is capable of comparing compound data-types including: - -- ref cursors -- object types -- nested table/varray types - -### Notes on comparison of compound data - -- Compound data can contain elements of any data-type. This includes blob, clob, object type, nested table, varray or even a nested-cursor within a cursor. -- Attributes in nested table and array types are compared as **ordered lists of elements**. If order of attributes in nested table and array differ, expectation will fail. -- Columns in compound data are compared as **ordered list of elements** by default. Use `unordered_columns` option when order of columns in cursor is not relevant -- Comparison of compound data is data-type aware. So a column `ID NUMBER` in a cursor is not the same as `ID VARCHAR2(100)`, even if they both hold the same numeric values. -- Comparison of cursor columns containing `DATE` will only compare date part **and ignore time** by default. See [Comparing cursor data containing DATE fields](#comparing-cursor-data-containing-date-fields) to check how to enable date-time comparison in cursors. -- Comparison of cursor returning `TIMESTAMP` **columns** against cursor returning `TIMESTAMP` **bind variables** requires variables to be cast to proper precision. This is an Oracle SQL - PLSQL compatibility issue and usage of CAST is the only known workaround for now. See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples. -- To compare nested table/varray type you need to convert it to `anydata` by using `anydata.convertCollection()` -- To compare object type you need to convert it to `anydata` by using `anydata.convertObject()` -- It is possible to compare PL/SQL records, collections, varrays and associative arrays. To compare this types of data, use cursor comparison feature of utPLSQL and TABLE operator in SQL query - - On Oracle 11g Release 2 - pipelined table functions are needed (see section [Implicit (Shadow) Types in this artcile](https://oracle-base.com/articles/misc/pipelined-table-functions)) - - On Oracle 12c and above - use [TABLE function on nested tables/varrays/associative arrays of PL/SQL records](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1) -- utPLSQL is not able to distinguish between NULL and whitespace-only column/attribute value when comparing compound data. This is due to Oracle limitation on of XMLType. - See [issue #880](https://github.com/utPLSQL/utPLSQL/issues/880) for details. *Note: This behavior might be fixed in future releases, when utPLSQL is no longer depending on XMLType for compound data comparison.* - -utPLSQL offers advanced data-comparison options, for comparing compound data-types. The options allow you to: - -- define columns/attributes to exclude from comparison -- define columns/attributes to include in comparison -- and more ... - -For details on available options and how to use them, read the [advanced data comparison](advanced_data_comparison.md) guide. - -### Diff functionality for compound data-types - -When comparing compound data, utPLSQL will determine the difference between the expected and the actual data. -The diff includes: - -- differences in column names, column positions and column data-type for cursor data -- only data in columns/rows that differ - -The diff aims to make it easier to identify what is not expected in the actual data. - -Consider the following expected cursor data - -| ID (NUMBER)| FIRST_NAME (VARCHAR2) | LAST_NAME (VARCHAR2) | SALARY (NUMBER) | -|:----------:|:----------------------:|:----------------------:|:---------------:| -| 1 | JACK | SPARROW | 10000 | -| 2 | LUKE | SKYWALKER | 1000 | -| 3 | TONY | STARK | 1000000 | - -And the actual cursor data: - -|~~GENDER (VARCHAR2)~~| FIRST_NAME (VARCHAR2) | LAST_NAME (VARCHAR2) | SALARY *(VARCHAR2)* | *ID* (NUMBER) | -|:-------------------:|:---------------------:|:--------------------:|:-------------------:|:-------------:| -| M | JACK | SPARROW | **25000** | 1 | -| M | TONY | STARK | 1000000 | 3 | -| **F** | **JESSICA** | **JONES** | **2345** | **4** | -| M | LUKE | SKYWALKER | 1000 | 2 | - - -The two data-sets above have the following differences: - -- column ID is misplaced (should be first column but is last) -- column SALARY has data-type VARCHAR2 but should be NUMBER -- column GENDER exists in actual but not in the expected (it is an Extra column) -- data in column SALARY for row number 1 in actual is not matching expected -- row number 2 in actual (ID=3) is not matching expected -- row number 3 in actual (ID=4) is not matching expected -- row number 4 in actual (ID=2) is not expected in results (Extra row in actual) - -utPLSQL will report all of the above differences in a readable format to help you identify what is not correct in the compared dataset. - -Below example illustrates, how utPLSQL will report such differences. -```sql linenums="1" -declare - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - open l_expected for - select 1 as ID, 'JACK' as FIRST_NAME, 'SPARROW' AS LAST_NAME, 10000 AS SALARY - from dual union all - select 2 as ID, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 1000 AS SALARY - from dual union all - select 3 as ID, 'TONY' as FIRST_NAME, 'STARK' AS LAST_NAME, 100000 AS SALARY - from dual; - open l_actual for - select 'M' AS GENDER, 'JACK' as FIRST_NAME, 'SPARROW' AS LAST_NAME, 1 as ID, '25000' AS SALARY - from dual union all - select 'M' AS GENDER, 'TONY' as FIRST_NAME, 'STARK' AS LAST_NAME, 3 as ID, '100000' AS SALARY - from dual union all - select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY - from dual union all - select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY - from dual; - ut.expect(l_actual).to_equal(l_expected); -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ] - Diff: - Columns: - Column is misplaced. Expected position: 1, actual position: 4. - Column data-type is invalid. Expected: NUMBER, actual: VARCHAR2. - Column [position: 1, data-type: CHAR] is not expected in results. - Rows: [ 4 differences ] - Row No. 1 - Actual: 25000 - Row No. 1 - Expected: 10000 - Row No. 2 - Actual: TONYSTARK3100000 - Row No. 2 - Expected: 2LUKESKYWALKER1000 - Row No. 3 - Actual: JESSICAJONES42345 - Row No. 3 - Expected: 3TONYSTARK100000 - Row No. 4 - Extra: MLUKESKYWALKER21000 - Row No. 4 - Extra: MLUKESKYWALKER21000 - at "anonymous block", line 21 -``` - -utPLSQL identifies and reports on columns: - -- column misplacement -- column data-type mismatch -- extra/missing columns - -When comparing rows utPLSQL: - -- reports only mismatched columns when rows match -- reports columns existing in both data-sets when whole row is not matching -- reports whole extra (not expected) row from actual when actual has extra rows -- reports whole missing (expected) row from expected when expected has extra rows - - -### Object and nested table data-type comparison examples - -When comparing object type / nested table / varray, utPLSQL will check: - -- if data-types match -- if data in the compared elements is the same. - -The diff functionality for objects / nested tables / varrays is similar to diff on cursors. -When diffing, utPLSQL will not check name and data-type of individual attribute as the type itself defines the underlying structure. - -Below examples demonstrate how to compare object and nested table data-types. - -Object type comparison. -```sql linenums="1" -create type department as object(name varchar2(30)) -/ - -create or replace function get_dept return department is -begin - return department('IT'); -end; -/ - -exec ut.expect( anydata.convertObject( get_dept() ) ).to_equal( anydata.convertObject( department('HR') ) ); - -drop function get_dept; -drop type department; -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: ut3.department was expected to equal: ut3.department - Diff: - Rows: [ 1 differences ] - Row No. 1 - Actual: IT - Row No. 1 - Expected: HR - at "anonymous block", line 1 -``` - -Table type comparison. -```sql linenums="1" -create type department as object(name varchar2(30)) -/ -create type departments as table of department -/ -create or replace function get_depts return departments is -begin - return departments( department('IT'), department('HR') ); -end; -/ - -declare - v_expected departments; -begin - v_expected := departments(department('HR'), department('IT') ); - ut.expect( anydata.convertCollection( get_depts() ) ).to_equal( anydata.convertCollection( v_expected ) ); -end; -/ - -drop type function get_depts; -drop type departments; -drop type department; -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: ut3.departments [ count = 2 ] was expected to equal: ut3.departments [ count = 2 ] - Diff: - Rows: [ 2 differences ] - Row No. 1 - Actual: IT - Row No. 1 - Expected: HR - Row No. 2 - Actual: HR - Row No. 2 - Expected: IT - at "anonymous block", line 5 -``` - -Some of the possible combinations of anydata and their results: -```sql linenums="1" -clear screen -set serverout on -set feedback off - -create or replace type t_tab_varchar is table of varchar2(1) -/ -create or replace type dummy_obj as object ( - id number, - "name" varchar2(30), - "Value" varchar2(30) -) -/ -create or replace type dummy_obj_lst as table of dummy_obj -/ -create or replace type t_varray is varray(1) of number -/ - -exec ut.expect( anydata.convertObject( dummy_obj( 1, 'A', '0' ) ) ).to_equal( anydata.convertObject( dummy_obj(1, 'A', '0') ) ); -exec ut.expect( anydata.convertCollection( t_tab_varchar('A') ) ).to_equal( anydata.convertCollection( t_tab_varchar('A') ) ); -exec ut.expect( anydata.convertCollection( t_tab_varchar('A') ) ).to_equal( anydata.convertCollection( t_tab_varchar('B') ) ); -exec ut.expect( anydata.convertCollection( t_tab_varchar() ) ).to_be_null(); -exec ut.expect( anydata.convertCollection( t_tab_varchar() ) ).to_equal( anydata.convertCollection( t_tab_varchar() ) ); -exec ut.expect( anydata.convertCollection( t_tab_varchar() ) ).to_equal( anydata.convertCollection( t_tab_varchar('A') ) ); -exec ut.expect( anydata.convertCollection( t_tab_varchar() ) ).to_have_count(0); -exec ut.expect( anydata.convertCollection( t_tab_varchar() ) ).to_equal( anydata.convertCollection( t_tab_varchar() ) ); -exec ut.expect( anydata.convertCollection( t_tab_varchar() ) ).to_equal( anydata.convertCollection( t_tab_varchar('A') ) ); -exec ut.expect( anydata.convertCollection( dummy_obj_lst( dummy_obj( 1, 'A', '0' ) ) ) ).to_equal( anydata.convertCollection( dummy_obj_lst( dummy_obj( 1, 'A', '0' ) ) ) ); -exec ut.expect( anydata.convertCollection( dummy_obj_lst( dummy_obj( 1, 'A', '0' ) ) ) ).to_equal( anydata.convertCollection( dummy_obj_lst( dummy_obj( 2, 'A', '0' ) ) ) ); -exec ut.expect( anydata.convertCollection( dummy_obj_lst() ) ).to_equal( anydata.convertCollection( dummy_obj_lst( dummy_obj( 1, 'A', '0' ) ) ) ); -exec ut.expect( anydata.convertCollection( dummy_obj_lst() ) ).to_be_null(); -exec ut.expect( anydata.convertCollection( dummy_obj_lst() ) ).to_equal( anydata.convertCollection( dummy_obj_lst() ) ); -exec ut.expect( anydata.convertCollection( dummy_obj_lst() ) ).to_have_count(0); -exec ut.expect( anydata.convertCollection( dummy_obj_lst() ) ).to_equal( anydata.convertCollection( dummy_obj_lst(dummy_obj(1, 'A', '0') ) ) ); -exec ut.expect( anydata.convertCollection( dummy_obj_lst() ) ).to_equal( anydata.convertCollection( dummy_obj_lst() ) ); -exec ut.expect( anydata.convertCollection( t_varray() ) ).to_be_null(); -exec ut.expect( anydata.convertCollection( t_varray() ) ).to_equal( anydata.convertCollection( t_varray() ) ); -exec ut.expect( anydata.convertCollection( t_varray() ) ).to_equal( anydata.convertCollection( t_varray(1) ) ); -exec ut.expect( anydata.convertCollection( t_varray() ) ).to_have_count(0); -exec ut.expect( anydata.convertCollection( t_varray() ) ).to_equal( anydata.convertCollection( t_varray() ) ); -exec ut.expect( anydata.convertCollection( t_varray() ) ).to_equal( anydata.convertCollection( t_varray(1) ) ); -exec ut.expect( anydata.convertCollection( t_varray(1) ) ).to_equal( anydata.convertCollection( t_varray(1) ) ); -exec ut.expect( anydata.convertCollection( t_varray(1) ) ).to_equal( anydata.convertCollection( t_varray(2) ) ); - -drop type t_varray; -drop type dummy_obj_lst; -drop type dummy_obj; -drop type t_tab_varchar; -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: ut3.dummy_obj was expected to equal: ut3.dummy_obj - -SUCCESS - Actual: ut3.t_tab_varchar [ count = 1 ] was expected to equal: ut3.t_tab_varchar [ count = 1 ] - -FAILURE - Actual: ut3.t_tab_varchar [ count = 1 ] was expected to equal: ut3.t_tab_varchar [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Actual: A - Row No. 1 - Expected: B - at "anonymous block", line 1 - -FAILURE - Actual: (ut3.t_tab_varchar [ count = 0 ]) - Data-types: - VARCHAR2 - Data: - was expected to be null - at "anonymous block", line 1 - -SUCCESS - Actual: ut3.t_tab_varchar [ count = 0 ] was expected to equal: ut3.t_tab_varchar [ count = 0 ] - -FAILURE - Actual: ut3.t_tab_varchar [ count = 0 ] was expected to equal: ut3.t_tab_varchar [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Missing: A - at "anonymous block", line 1 - -SUCCESS - Actual: (ut3.t_tab_varchar [ count = 0 ]) was expected to have [ count = 0 ] - -SUCCESS - Actual: ut3.t_tab_varchar [ count = 0 ] was expected to equal: ut3.t_tab_varchar [ count = 0 ] - -FAILURE - Actual: ut3.t_tab_varchar [ count = 0 ] was expected to equal: ut3.t_tab_varchar [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Missing: A - at "anonymous block", line 1 - -SUCCESS - Actual: ut3.dummy_obj_lst [ count = 1 ] was expected to equal: ut3.dummy_obj_lst [ count = 1 ] - -FAILURE - Actual: ut3.dummy_obj_lst [ count = 1 ] was expected to equal: ut3.dummy_obj_lst [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Actual: 1 - Row No. 1 - Expected: 2 - at "anonymous block", line 1 - -FAILURE - Actual: ut3.dummy_obj_lst [ count = 0 ] was expected to equal: ut3.dummy_obj_lst [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Missing: 1A0 - at "anonymous block", line 1 - -FAILURE - Actual: (ut3.dummy_obj_lst [ count = 0 ]) - Data-types: - DUMMY_OBJ - Data: - was expected to be null - at "anonymous block", line 1 - -SUCCESS - Actual: ut3.dummy_obj_lst [ count = 0 ] was expected to equal: ut3.dummy_obj_lst [ count = 0 ] - -SUCCESS - Actual: (ut3.dummy_obj_lst [ count = 0 ]) was expected to have [ count = 0 ] - -FAILURE - Actual: ut3.dummy_obj_lst [ count = 0 ] was expected to equal: ut3.dummy_obj_lst [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Missing: 1A0 - at "anonymous block", line 1 - -SUCCESS - Actual: ut3.dummy_obj_lst [ count = 0 ] was expected to equal: ut3.dummy_obj_lst [ count = 0 ] - -FAILURE - Actual: (ut3.t_varray [ count = 0 ]) - Data-types: - NUMBER - Data: - was expected to be null - at "anonymous block", line 1 - -SUCCESS - Actual: ut3.t_varray [ count = 0 ] was expected to equal: ut3.t_varray [ count = 0 ] - -FAILURE - Actual: ut3.t_varray [ count = 0 ] was expected to equal: ut3.t_varray [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Missing: 1 - at "anonymous block", line 1 - -SUCCESS - Actual: (ut3.t_varray [ count = 0 ]) was expected to have [ count = 0 ] - -SUCCESS - Actual: ut3.t_varray [ count = 0 ] was expected to equal: ut3.t_varray [ count = 0 ] - -FAILURE - Actual: ut3.t_varray [ count = 0 ] was expected to equal: ut3.t_varray [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Missing: 1 - at "anonymous block", line 1 - -SUCCESS - Actual: ut3.t_varray [ count = 1 ] was expected to equal: ut3.t_varray [ count = 1 ] - -FAILURE - Actual: ut3.t_varray [ count = 1 ] was expected to equal: ut3.t_varray [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Actual: 1 - Row No. 1 - Expected: 2 - at "anonymous block", line 1 -``` - -### Comparing cursor data containing DATE fields - -!!! warning "Important" - - utPLSQL uses XMLType internally to represent rows of the cursor data. This is by far the most flexible method and allows comparison of cursors containing LONG, CLOB, BLOB, user defined types and even nested cursors.
- Due to the way Oracle handles DATE data type when converting from cursor data to XML, utPLSQL has no control over the DATE formatting.
- The NLS_DATE_FORMAT setting from the moment the cursor was opened determines the formatting of dates used for cursor data comparison.
- By default, Oracle NLS_DATE_FORMAT is timeless, so data of DATE datatype, will be compared ignoring the time component.
- -You should surround cursors and expectations with procedures `ut.set_nls`, `ut.reset_nls`. -This way, the DATE data in cursors will be properly formatted for comparison using date-time format. - -The example below makes use of `ut.set_nls`, `ut.reset_nls`, so that the date in `l_expected` and `l_actual` is compared using date-time formatting. -```sql linenums="1" -clear screen -alter session set nls_date_format='yyyy-mm-dd'; -set serverout on -set feedback off -create table events ( description varchar2(4000), event_date date ) -/ -declare - c_description constant varchar2(30) := 'Test event'; - c_event_date constant date := to_date('2016-09-08 06:51:22','yyyy-mm-dd hh24:mi:ss'); - c_second constant number := 1/24/60/60; - l_actual sys_refcursor; - l_expected sys_refcursor; -begin - --Arrange - insert into events (description, event_date) values (c_description, c_event_date); - - begin - -- Change the NLS settings for date to be ISO date-time 'YYYY-MM-DD HH24:MI:SS' - ut.set_nls(); - --Act - open l_expected for select c_description as description, c_event_date + c_second as event_date from dual; - open l_actual for select description, event_date from events; - --Assert - ut.expect( l_actual ).not_to_equal( l_expected ); - -- Reset the NLS settings to their default values after cursor data was processed - ut.reset_nls(); - end; - - begin - --Act - open l_expected for select c_description as description, c_event_date + c_second as event_date from dual; - open l_actual for select description, event_date from events; - --Assert - ut.expect( l_actual ).not_to_equal( l_expected ); - end; - --Cleanup - rollback; -end; -/ - -drop table events; -``` - -In the above example: - -- The first expectation is successful, as the `l_expected` cursor contains different date-time then the cursor returned by `get_events` function call -- The second expectation fails, as the column `event_date` will get compared as DATE without TIME (using default current session NLS date format) - -Output via DBMS_OUTPUT from the above example: -``` -SUCCESS - Actual: (refcursor [ count = 1 ]) - Data-types: - VARCHAR2DATE - Data: - Test event2016-09-08T06:51:22 - was expected not to equal: (refcursor [ count = 1 ]) - Data-types: - VARCHAR2DATE - Data: - Test event2016-09-08T06:51:23 -FAILURE - Actual: (refcursor [ count = 1 ]) - Data-types: - VARCHAR2DATE - Data: - Test event2016-09-08 - was expected not to equal: (refcursor [ count = 1 ]) - Data-types: - VARCHAR2DATE - Data: - Test event2016-09-08 - at "anonymous block", line 28 -``` - -### Comparing cursor data containing TIMESTAMP bind variables - -To properly compare `timestamp` column data returned by cursor against bind variable data from another cursor, a conversion needs to be done. - -This applies to `timestamp`,`timestamp with timezone`, `timestamp with local timezone` data types. - -Example below illustrates usage of `cast` operator to assure appropriate precision is applied on timestamp bind-variables in cursor result-set - -```sql linenums="1" -clear screen -set serverout on -set feedback off - -create table timestamps ( - ts3 timestamp (3), - ts6 timestamp (6), - ts9 timestamp (9) -); - -declare - l_time timestamp(9); - l_expected sys_refcursor; - l_actual sys_refcursor; -begin - --Arrange - l_time := systimestamp; - - insert into timestamps (ts3, ts6, ts9) values (l_time, l_time, l_time); - - begin - --Act - open l_expected for - select - cast(l_time as timestamp(3)) as ts3, - cast(l_time as timestamp(6)) as ts6, - cast(l_time as timestamp(9)) as ts9 - from dual; - - open l_actual for select ts3, ts6, ts9 from timestamps; - - --Assert - ut.expect (l_actual).to_equal (l_expected); - end; - begin - open l_expected for - select l_time as ts3, l_time as ts6, l_time as ts9 from dual; - - open l_actual for select ts3, ts6, ts9 from timestamps; - - --Assert - ut.expect (l_actual).to_equal (l_expected); - end; -end; -/ - -drop table timestamps; -``` - -Returns following output via DBMS_OUTPUT: -``` -SUCCESS - Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] -FAILURE - Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] - Diff: - Rows: [ 1 differences ] - Row No. 1 - Actual: 2019-07-08T22:08:41.8992019-07-08T22:08:41.899319 - Row No. 1 - Expected: 2019-07-08T22:08:41.8993190002019-07-08T22:08:41.899319000 - at "anonymous block", line 32 -``` - -## Comparing Json objects - -utPLSQL is capable of comparing json data-types of `json_element_t` **on Oracle 12.2 and above**, and also `json` **on Oracle 21 and above** - -!!! note - Whenever a database is upgraded to compatible version the utPLSQL needs to be reinstalled to pick up json changes. E.g. upgrade from 18c to 21c to enable `json` type compare. - - -### 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 -- From version 21 and above a native `json` type is supported. - - - -Compare JSON example using `json_element_t`: -```sql linenums="1" -declare - l_expected json_element_t; - l_actual json_element_t; -begin - l_expected := json_element_t.parse(' - { - "Actors": [ - { - "name": "Tom Cruise", - "age": 56, - "Birthdate": "July 3, 1962", - "hasChildren": true, - "children": [ - "Connor" - ] - }, - { - "name": "Robert Downey Jr.", - "age": 53, - "Birthdate": "April 4, 1965", - "hasChildren": true, - "children": [ - "Exton Elias" - ] - } - ] - }' - ); - - l_actual := json_element_t.parse(' - { - "Actors": [ - { - "name": "Tom Cruise", - "age": 56, - "Birthdate": "1962.07.03", - "hasChildren": true, - "children": [ - "Suri", - "Isabella Jane", - "Connor" - ] - }, - { - "name": "Jr., Robert Downey", - "age": 53, - "Birthdate": "April 4, 1965", - "hasChildren": true, - "children": [ - "Indio Falconer", - "Avri Roel", - "Exton Elias" - ] - } - ] - }' - ); - - ut.expect( l_actual ).to_equal( l_expected ); - -end; -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: json was expected to equal: json - Diff: 8 differences found - 4 unequal values, 4 missing properties - Extra property: "Avri Roel" on path: $."Actors"[1]."children"[1] - Extra property: "Isabella Jane" on path: $."Actors"[0]."children"[1] - Extra property: "Connor" on path: $."Actors"[0]."children"[2] - Extra property: "Exton Elias" on path: $."Actors"[1]."children"[2] - Actual value: "Robert Downey Jr." was expected to be: "Jr., Robert Downey" on path: $."Actors"[1]."name" - Actual value: "July 3, 1962" was expected to be: "1962.07.03" on path: $."Actors"[0]."Birthdate" - Actual value: "Connor" was expected to be: "Suri" on path: $."Actors"[0]."children"[0] - Actual value: "Exton Elias" was expected to be: "Indio Falconer" on path: $."Actors"[1]."children"[0] - at "anonymous block", line 59 -``` - -Comparing parts of JSON example using `json_element_t` subtypes: -```sql linenums="1" -declare - l_actual json_object_t; - l_actual_extract json_array_t; - l_expected json_array_t; -begin - -- Arrange - l_expected := json_array_t.parse(' - [ - "Indio Falconer", - "Avri Roel", - "Exton Elias" - ]' - ); - - l_actual := 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", - "Exton Elias" - ] - } - ] - }' - ); - - l_actual_extract := json_array_t(json_query(l_actual.stringify,'$.Actors[1].children')); - --Act - ut.expect(l_actual_extract).to_equal(l_expected); - -end; -/ -``` - -Returns following output via DBMS_OUTPUT: -``` -FAILURE - Actual: json was expected to equal: json - Diff: 2 differences found - 1 unequal values, 1 missing properties - Missing property: "Exton Elias" on path: $[2] - Actual value: "Avri Roel" was expected to be: "Exton Elias" on path: $[1] - at "anonymous block", line 55 -``` diff --git a/docs/userguide/getting-started.md b/docs/userguide/getting-started.md deleted file mode 100644 index cd4feb46a..000000000 --- a/docs/userguide/getting-started.md +++ /dev/null @@ -1,323 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -# Getting started with TDD and utPLSQL - -utPLSQL is designed in a way that allows you to follow -[Test Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development) software development process. - -Below is an example of building a simple function with TDD. - -## Gather requirements - -We have a requirement to build a function that will return a substring of a string that is passed to the function. - -The function should accept three parameters: - -- input_string -- start_position -- end_position - -## Create a test - -We will start from the bare minimum and move step by step, executing tests every time we make minimal progress. -This way, we assure we don't jump ahead too much and produce code that is untested or untestable. - -### Create test package - -```sql linenums="1" -create or replace package test_betwnstr as - - --%suite(Between string function) - -end; -/ -``` - -Execute all tests: `begin ut.run(); end;` - -Test results: -``` -Between string function - -Finished in .451423 seconds -0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -### Define specification for the test - -```sql linenums="1" -create or replace package test_betwnstr as - - --%suite(Between string function) - - --%test(Returns substring from start position to end position) - procedure basic_usage; - -end; -/ -``` - -Execute test package: `begin ut.run('test_betwnstr'); end;` - -Test results: -``` -Between string function - Returns substring from start position to end position (FAILED - 1) - -Failures: - - 1) basic_usage - ORA-04067: not executed, package body "UT3_USER.TEST_BETWNSTR" does not exist - ORA-06508: PL/SQL: could not find program unit being called: "UT3_USER.TEST_BETWNSTR" - ORA-06512: at line 6 -Finished in .509673 seconds -1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s) -``` - -Well our test is failing as the package specification requires a body. - -### Define body of first test - -```sql linenums="1" -create or replace package body test_betwnstr as - - procedure basic_usage is - begin - ut.expect( betwnstr( '1234567', 2, 5 ) ).to_equal('2345'); - end; - -end; -/ -``` - -Execute test package: `begin ut.run('test_betwnstr'); end;` - -Test results: -``` -Between string function - Returns substring from start position to end position (FAILED - 1) - -Failures: - - 1) basic_usage - ORA-04063: package body "UT3_USER.TEST_BETWNSTR" has errors - ORA-06508: PL/SQL: could not find program unit being called: "UT3_USER.TEST_BETWNSTR" - ORA-06512: at line 6 -Finished in .415851 seconds -1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s) -``` - -Our test is failing as the test suite package body is invalid. -Looks like we need to define the function we want to test. - -## Implement code to fulfill the requirement - -### Define tested function - -```sql linenums="1" -create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 -is -begin - return substr( a_string, a_start_pos, a_end_pos - a_start_pos ); -end; -/ -``` - -Execute test package: `begin ut.run('test_betwnstr'); end;` - -Test results: -``` -Between string function - Returns substring from start position to end position (FAILED - 1) - -Failures: - - 1) basic_usage - Actual: '234' (varchar2) was expected to equal: '2345' (varchar2) - at ""UT3_USER.TEST_BETWNSTR"", line 5 - -Finished in .375178 seconds -1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -So now we see that our test works but the function does not return the expected results. -Let us fix this and continue from here. - -### Fix the tested function - -The function returned a string one character short, so we need to add 1 to the substr parameter. - -```sql linenums="1" -create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 -is -begin - return substr( a_string, a_start_pos, a_end_pos - a_start_pos + 1 ); -end; -/ -``` - -Execute test package: `begin ut.run('test_betwnstr'); end;` - -Test results: -``` -Between string function - Returns substring from start position to end position - -Finished in .006077 seconds -1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -So our test is now passing, great! - -## Refactor - -Once our tests are passing, we can safely refactor (restructure) the code as we have a safety harness -in place to ensure that after the restructuring and cleanup of the code, everything is still working. - -One thing worth mentioning is that refactoring of tests is as important as refactoring of code. Maintainability of both is equally important. - -## Further requirements - -It seems like our work is done. We have a function that returns a substring from start position to end position. -As we move through the process of adding tests, it's very important to think about edge cases. - -Here is a list of edge cases for our function: - -- start position zero -- input string is null -- start position is null -- end position is null -- start position is negative -- start position is bigger than end position -- start position is negative -- end position is negative - -We should define expected behavior for each of these edge cases. -Once defined we can start implementing tests for those behaviors and adjust the tested function to meet the requirements specified in the tests. - -### Add test for additional requirement - -A new requirement was added: - Start position zero - should be treated as start position one - -```sql linenums="1" -create or replace package test_betwnstr as - - --%suite(Between string function) - - --%test(Returns substring from start position to end position) - procedure basic_usage; - - --%test(Returns substring when start position is zero) - procedure zero_start_position; - -end; -/ - -create or replace package body test_betwnstr as - - procedure basic_usage is - begin - ut.expect( betwnstr( '1234567', 2, 5 ) ).to_equal('2345'); - end; - - procedure zero_start_position is - begin - ut.expect( betwnstr( '1234567', 0, 5 ) ).to_equal('12345'); - end; - -end; -/ -``` - -Execute test package: `begin ut.run('test_betwnstr'); end;` - -Test results: -``` -Between string function - Returns substring from start position to end position - Returns substring when start position is zero (FAILED - 1) - -Failures: - - 1) zero_start_position - Actual: '123456' (varchar2) was expected to equal: '12345' (varchar2) - at ""UT3_USER.TEST_BETWNSTR"", line 10 - -Finished in .232584 seconds -2 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -Looks like our function does not work as expected for zero start position. - -### Implementing the requirement - -Let's fix our function so that the new requirement is met - -```sql linenums="1" -create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 -is -begin - if a_start_pos = 0 then - return substr( a_string, a_start_pos, a_end_pos - a_start_pos ); - else - return substr( a_string, a_start_pos, a_end_pos - a_start_pos + 1); - end if; -end; -/ -``` - -Execute test package: `begin ut.run('test_betwnstr'); end;` - -Test results: -``` -Between string function - Returns substring from start position to end position - Returns substring when start position is zero - -Finished in .012718 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -Great! We have made some visible progress. - -### Refactoring - -When all tests are passing we can proceed with a safe cleanup of our code. - -The function works well, but we use the `return` twice, which is not the best coding practice. - -An alternative implementation could be cleaner. -```sql linenums="1" -create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 -is -begin - return substr( a_string, a_start_pos, a_end_pos - greatest( a_start_pos, 1 ) + 1 ); -end; -/ -``` - -As we refactor we should probably run our tests as often as we compile code, so we know not only that the code compiles, but also works as expected. - -``` -Between string function - Returns substring from start position to end position - Returns substring when start position is zero - -Finished in .013739 seconds -2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) -``` - -## Remaining requirements - -You may continue on with the remaining edge cases from here. - -- identify requirement -- define requirement with test -- run test to check if requirement is met -- implement code to meet requirement -- run test to check if requirement is met -- refactor/cleanup code and tests - -Hope you will enjoy it as much as we do. - diff --git a/docs/userguide/install.md b/docs/userguide/install.md deleted file mode 100644 index 6724ac6ab..000000000 --- a/docs/userguide/install.md +++ /dev/null @@ -1,313 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -## Supported database versions - -utPLSQL is continuously tested against following versions of Oracle databases - -* 11g R2 -* 12c -* 12c R2 -* 18c -* 19c - -We do our best to assure full compatibility with supported versions of Oracle databases [See](http://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf#page=6) - -## Requirements - -utPLSQL will run on any Oracle Database version 11g relase 2 or above. - -### Licensed features required - -utPLSQL doesn't require any extra licensed features of Oracle database. It can be installed on any Standard Edition Oracle Database. - -In fact, it even supports Oracle 11g XE which is a free Oracle Database version with minimal features and storage limits. - -### Storage requirements - -utPLSQL will use tablespace for the following: -- storage of annotation cache -- storage of suite cache -- storage of profiler results -- storage for staging utPLSQL reports outputs - - -utPLSQL purges the staging storage for reports while fetching reports to screen / saving reports to files. - -Suite and annotation cache storage requirements are minimal and unless you have hundreds of thousands of tests, you'll probably not even notice the space used. - -Profiler results may require regular purging to assure low space consumption. -utPLSQl does not purge profiler tables as those tables can can be shared with other tools. - - -## Downloading utPLSQL - -### Manual download - -- Go to GitHub releases page for utPLSQL [`https://github.com/utPLSQL/utPLSQL/releases`](https://github.com/utPLSQL/utPLSQL/releases) -- Choose the version to download - latest is always greatest -- Download one of files - - utPLSQL.tar.gz - - utPLSQL.zip - -The files have identical content but use different compression (tar / zip ) so choose whichever you prefer depending on your platform (Win/Mac/Unix/Linux). - - -### Scripted download of latest utPLSQL version - -The below snippets can be used to download latest version of utPLSQL from github releases. - -After downloading follow the installation instructions in next sections of this document. - -#### Unix/Linux - -```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') -# Download the latest release "zip" file -curl -Lk "${UTPLSQL_DOWNLOAD_URL}" -o utPLSQL.zip -# Extract downloaded "zip" file -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') -``` - -#### Windows - -To run the script on windows you will need [PowerShell 3.0](https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/02/weekend-scripter-install-powershell-3-0-on-windows-7/) or above. -You will also need .NET 4.0 Framework or above. - -```batch -$archiveName = 'utPLSQL.zip' -$latestRepo = Invoke-WebRequest https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest -$repo = $latestRepo.Content | Convertfrom-Json - -$urlList = $repo.assets.browser_download_url - -Add-Type -assembly "system.io.compression.filesystem" - -foreach ($i in $urlList) { - - $fileName = $i.substring($i.LastIndexOf("/") + 1) - - if ( $fileName.substring($fileName.LastIndexOf(".") + 1) -eq 'zip' ) { - Invoke-WebRequest $i -OutFile $archiveName - $fileLocation = Get-ChildItem | where {$_.Name -eq $archiveName} - - if ($fileLocation) { - [io.compression.zipfile]::ExtractToDirectory($($fileLocation.FullName),$($fileLocation.DirectoryName)) - } - } -} -``` - -## Headless installation - -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 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 and utPLSQL cache data (default `users`) - -The scripts need to be executed by `SYSDBA`, in order to grant access to `DBMS_LOCK` and `DBMS_CRYPTO` system packages. - -!!! warning "Important" - - `DBMS_LOCK` is required for session synchronization between main session and session consuming realtime reports.
- - 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.
- - When installed 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:
- `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 -sqlplus sys/sys_pass@db as sysdba @install_headless.sql -``` - -Invoking script with parameters: -```bash -cd source -sqlplus sys/sys_pass@db as sysdba @install_headless.sql utp3 my_verySecret_password utp3_tablespace -``` - -### 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 -``` - -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 -``` - -## 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 a shared schema is really not recommended as you loose isolation of framework. - -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 - - CREATE TYPE - - CREATE TABLE - - CREATE SEQUENCE - - 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. - -utPLSQL is using [DBMS_PROFILER tables](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476) for code coverage. The tables required by DBMS_PROFILER will be created in the installation schema unless they already exist. - -It is up to DBA to maintain the storage of the profiler tables. - -## Manual installation procedure - -### 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 - - `password` - the password to be set for that user - - `tablespace name` - the tablespace name to hold data created during test execution - -Example invocation: -```bash -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, 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. - -Example invocation: -```bash -cd source -sqlplus admin/admins_password@database @install.sql ut3 -``` - -### 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 after the utPLSQL installation. The framework will detect the presence of DDL trigger and act accordingly. - - -### 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: - - - use grants and synonyms to public, to allow all users to access the framework - - use synonyms and grants for individual users to limit the access to the framework - -To grant utPLSQL to public execute script `source/create_synonyms_and_grants_for_public.sql` and provide `schema_name` where utPLSQL is installed. - -Example invocation: -```bash -cd source -sqlplus admin/admins_password@database @create_synonyms_and_grants_for_public.sql ut3 -``` -To grant utPLSQL to an individual user, execute scripts `source/create_user_grants.sql` and `source/create_user_synonyms.sql`, provide `schema_name` where utPLSQL is installed and `user_name` to grant access for. - -Example invocation: -```bash -cd source -sqlplus ut3_owner_schema/ut3_password@database @create_user_grants.sql ut3 hr -sqlplus user/user_password@database @create_user_synonyms.sql ut3 hr -``` - -The following tools that support the SQL*Plus commands can be used to run the installation script: - - - SQL*Plus - - [SQLcl](http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html) - - [Oracle SQL Developer](http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html) - -## Checking environment and utPLSQL version - -To check the framework version execute the following query: -```sql linenums="1" -select substr(ut.version(),1,60) as ut_version from dual; -``` - -Additionally you may retrieve more information about your environment by executing the following query: -```sql linenums="1" -select - xmlserialize( content xmltype(ut_run_info()) as clob indent size = 2 ) - from dual; -``` - -## Additional requirements - -In order to use the Code Coverage functionality of utPLSQL, users executing the tests must have the CREATE privilege on the PLSQL code that the coverage is gathered on. -This is a requirement of [DBMS_PROFILER package](https://docs.oracle.com/cd/E18283_01/appdev.112/e16760/d_profil.htm#i999476). - -In practice, user running tests for PLSQL code that he does not own, needs to have CREATE ANY PROCEDURE/CREATE ANY TRIGGER privileges. -Running code coverage on objects that the user does not own will **not produce any coverage information** without those privileges. - -## Uninstalling utPLSQL - -To uninstall run `uninstall.sql` and provide `schema_name` where utPLSQL is installed. - -Example invocation: -```bash -cd source -sqlplus admin/admins_password@database @uninstall.sql ut3 -``` - -The uninstall script will remove all the objects installed by the installation script. -Additionally, all the public and private synonyms pointing to the objects in the utPLSQL schema will be removed. - -If you have extended any utPLSQL types such as a custom reporter, these will need to be dropped before the uninstall, otherwise the uninstall script might fail. - -The uninstall script does not drop the schema. - -**In order for the uninstall to be successful, you need to use the uninstall script that was provided with the exact utPLSQL version installed on your database.** -i.e. the uninstall script provided with version 3.1.11 will not work correctly if you want to remove version 3.0.0 from your database. - -Alternatively you can drop the user that owns utPLSQL and re-create it using headless install. - -## Version upgrade - -Currently, the only way to upgrade version of utPLSQL v3.0.0 and above is to remove the previous version and install the new version. - -## Working with utPLSQL v2 - -If you are using utPLSQL v2, you can still install utPLSQL v3. -The only requirement is that utPLSQL v3 needs to be installed in a different schema than utPLSQL v2. - -utPLSQL v3 and utPLSQL v2 do not collide on public synonym names. diff --git a/docs/userguide/querying_suites.md b/docs/userguide/querying_suites.md deleted file mode 100644 index 0cdc2d7fa..000000000 --- a/docs/userguide/querying_suites.md +++ /dev/null @@ -1,93 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -## Obtaining information about suites - -utPLSQL framework provides ability to read inforamtion about unit test suites that exist in a schema. - -Pipelined table function `ut_runner.get_suites_info(a_owner, a_package_name)` allows you to retrieve information about: - -- all suites that exist in a given user/schema -- individual test suite pacakage - -Querying the data from function provides the follwing details: - -- `object_owner` - the owner of test suite packages -- `object_name` - the name of test suite package -- `item_name` - the name of suite/test -- `item_description` - the description of suite/suite item -- `item_type` - the type of item (UT_SUITE/UT_SUITE_CONTEXT/UT_TEST/UT_LOGICAL_SUITE) -- `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 linenums="1" -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 linenums="1" -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 linenums="1" -select * from table(ut_runner.get_suites_info(USER, 'TEST_STUFF')) where item_type = 'UT_TEST'; -``` - -To get a full information about suites that have a path like `ut3:tests.test_package_*` including suite description, all contexts and tests in a suite -```sql linenums="1" -select * from table(ut_runner.get_suites_info('ut3:tests.test_package_*') where item_type = 'UT_TEST'; -``` - -To get a full information about suites that have object name like `test_package_*` including suite description, all contexts and tests in a suite -```sql linenums="1" -select * from table(ut_runner.get_suites_info('test_package_*')); -``` - -## Checking if schema contains tests - -Function `ut_runner.has_suites(a_owner)` returns boolean value indicating if given schema contains test suites. - -Example: -```sql linenums="1" -begin - if ut_runner.has_suites(USER) then - dbms_output.put_line( 'User '||USER||' owns test suites' ); - else - dbms_output.put_line( 'User '||USER||' does not own test suites' ); - end if; -end; -``` - -## Checking if package is a test suite - -Function `ut_runner.is_suite(a_owner, a_package_name) ` returns boolean value indicating if given package is a test suites. - -Example: -```sql linenums="1" -begin - if ut_runner.is_suite(USER,'TEST_STUFF') then - dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is a test suite' ); - else - dbms_output.put_line( 'Package '||USER||'.TEST_STUFF is not a test suite' ); - end if; -end; -``` - -## Checking if procedure is a test within a suite - -Function `ut_runner.is_test(a_owner, a_package_name, a_procedure_name) ` returns boolean value indicating if given package is a test suites. - -Example: -```sql linenums="1" -begin - if ut_runner.is_test(USER,'TEST_STUFF','A_TEST_TO_CHECK_STUFF') then - dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is a test' ); - else - dbms_output.put_line( 'Procedure '||USER||'.TEST_STUFF.A_TEST_TO_CHECK_STUFF is not a test' ); - end if; -end; -``` - diff --git a/docs/userguide/reporters.md b/docs/userguide/reporters.md deleted file mode 100644 index b417ba25c..000000000 --- a/docs/userguide/reporters.md +++ /dev/null @@ -1,210 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -utPLSQL provides several reporting formats. The sections below describe most of them. - -## Documentation reporter - -The `ut_documentation_reporter` is the default reporting format used by the framework. -It provides a human readable test results. - -To invoke tests with documentation reporter use one of following calls from sql console (SQLPlus) - -`exec ut.run();` - -`exec ut.run(ut_documentation_reporter());` - -Example outputs from documentation reporter. - -![doc_reporter_outputs](../images/documentation_reporter.png) - -Documentation reporter provides the following information. - -- Test suite name or test package name (nested with suitepath if suitepath is used) -- Test description name or test procedure name -- Information about test failing `(FAILED - n)` -- Information about disabled test `(IGNORED)` -- List of all errors and failures -- Summary with total number of tests, number of tests with status and timing for the execution - - -### Color output from documentation reporter - -When invoking tests with documentation reporter and your command line supports ANSICONSOLE (default on Unix) [available for Windows](http://adoxa.altervista.org/ansicon/), you can obtain the coloured outputs from the documentation reporter. - -To invoke tests with documentation reporter in color mode use one of following calls. - -`exec ut.run(a_color_console=>true);` - -`exec ut.run(ut_documentation_reporter(), a_color_console=>true);` - -Example outputs from documentation reporter. - -![doc_reporter_outputs](../images/documentation_reporter_color.png) - - -## JUnit reporter - -Most of continuous integration servers (like Jenkins) are capable of consuming unit test execution results in [JUnit](https://en.wikipedia.org/wiki/JUnit) format. -The `ut_junit_reporter` in earlier version referred as `ut_xunit_reporter` is producing outcomes as JUnit-compatible XML unit test report, that can be used by CI servers to display their custom reports and provide metrics (like tests execution trends). -Please note that in previous versions it was called ut_xunit_reporter and for backward compatibility that name still exists. - -Invocation of tests with JUnit reporter. - -`exec ut.run(ut_junit_reporter());` - -The `ut_junit_reporter` doesn't accept any arguments. - -Example of junit report integrated with [Jenkins CI](https://jenkins.io/) - -![junit_reporter_outputs](../images/junit_summary.png) - -Example of failure report details - -![junit_reporter_outputs](../images/junit_errors.png) - - - -## Teamcity reporter - -[Teamcity](https://www.jetbrains.com/teamcity/) is a CI server by Jetbrains. It supports JUnit reporting and additionally has it's own format of reporting that allows tracking of progress of a CI step/task as it executes. -The TeamCity format developed by Jetbrains is supported by utPLSQL with `ut_teamcity_reporter`. - -Invocation of tests with Teamcity reporter. - -`exec ut.run(ut_teamcity_reporter());` - -The `ut_teamcity_reporter` doesn't accept any arguments. - -Example of unit test report from Teamcity CI server. - -![junit_reporter_outputs](../images/teamcity_report_example.png) - -Example of failure report details - -![junit_reporter_outputs_errors](../images/teamcity_report_example_errors.png) - - -## Sonar test reporter - -If you are using [SonarQube](https://www.sonarqube.org/) or [SonarCloud](https://about.sonarcloud.io/) to do static code analysis for you PLSQL projects, -your code analysis can benefit from code coverage and test results. -utPLSQL provides two reporters to for SonarQube: - -- `ut_sonar_test_reporter` - provides an XML output of each test executed per each project test file (package) -- `ut_coverage_sonar_reporter` - provides XML output of code coverage per each project source file - -`ut_sonar_test_reporter` needs to be called with a list of paths to test files (packages). -The paths to files can be relative to the project root directory (recommended) or be absolute. - -`ut_coverage_sonar_reporter` needs to be called with a list of paths to source files for your project. -The paths to files can be relative to the project root directory (recommended) or be absolute. - -Providing invalid paths or paths to non-existing files will result in failure when publishing test results/coverage results to sonar server. - -For details on how to invoke reporter with paths, see the [Code coverage](coverage.md) section. - -## TFS / VSTS Reporter - -If you are using [TFS](https://www.visualstudio.com/tfs/) or [VSTS](https://www.visualstudio.com/team-services/) to do static code analysis for you PLSQL projects and run builds, -your code analysis can benefit from code coverage and test results. TFS reporter is designed specifically to [work with Microsoft Team Fundation Server](https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts) report format which is very old version of [JUnit](https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd). -Main difference between standard JUnit is that elements cannot be nested and attribute skipped is not present. - -utPLSQL provides a dedicated `ut_tfs_junit_reporter` reporter to for TFS / VSTS servers. The reporter provides an XML output of each test executed per each project test file (package). -Example of test report from TFS CI server. - -Summary: - -![tfs_junit_reporter_outputs](../images/tfs_summary.png) - -Details: - -![tfs_junit_reporter_outputs](../images/tfs_details.png) - - -## Coverage reporters - -utPLSQL comes with a set of build-in coverage reporters. -[Code coverage](coverage.md) section describes in details how to use configure and use code coverage. - -## TAP Reporter - -The `ut_tap_reporter` produces output compatible with the [Test Anything Protocol](https://testanything.org) (Version 14). TAP output can be consumed by a TAP consumer that can aggregate results from testsuites across different programming languages while maintaining good readability for humans. - -![tap_output_no_color](../images/tap_reporter_no_color.png) - -If you use a compatible terminal, you can also have a colored result. Only top level `not ok`-results will be colored: - -![tap_colored_output](../images/tap_reporter_colored.png) - -Suites (and suitepaths) and contexts are included as [commented subtests](https://testanything.org/tap-version-14-specification.html#:~:text=Commented%20Subtests) including a summary of the tests performed for that specific context/suite. This example package has the suitepath "org.utplsql.tests.helpers": - -![tap_include_suitepath](../images/tap_reporter_suitepath.png) - -## Debug reporter - -The `ut_debug_reporter` provides a highly verbose output containing thorough details about framework and test execution. - -Use this reporter only when you need to investigate framework issues or raise a bug report to utPLSQL team. - -Usage of this reporter might have impact on performance of test-suite execution. - -Amongst others, reporter provides the following information: - -- framework version -- database version -- database OS -- database, instance and session NLS settings -- timing of each event -- time between events logged -- time from start of the run -- stack trace -- information about input parameters for the run including - - run paths - - source file mappings - - test file mappings - - coverage schemas - - coverage exclusions and inclusions - - client character set -- information about every step of the run including - - every suite and context - - every before/after procedure - - every test - - every expectation and it's result - -Some information in debug log might be redundant. - -!!! note - Some information in debug log may be sensitive. In particular:
- - expectation results and messages (logged even for successful runs)
- - test structure
- - db object names
- - etc. - -## Custom reporters - -It is possible to add your own reporters by creating an appropriate object type. -In principle, it has to be a subtype of `ut_reporter_base`. However, if the reporter is expected to produce output consumable by a client oustside of the database (e.g. the data has to be reported to the screen or to a file), then you should base it on `ut_output_reporter_base` (which is a subtype of `ut_reporter_base`). In contrast, if you would like to create a reporter that, for example, saves the data to a database table, then it should be based directly on `ut_reporter_base`. (Currently, all reporters in the utPLSQL framework are based on `ut_output_reporter_base`.) Coverage reporters are based on `ut_coverage_reporter_base` (a subtype of `ut_output_reporter_base`). - -If you need to produce a colored text output from the custom reporter, then you can build it basing on `ut_console_reporter_base` (a subtype of `ut_output_reporter_base`). In many cases it may also be more convenient to create the custom reporter type under a more specialized type, like `ut_documentation_reporter` or `ut_junit_reporter`, and override just some of the functionality. - -It is recommended to create the reporter type in the schema where utPLSQL is installed (by default it is the `UT3` schema). Note that before running the utPLSQL uninstall scripts, all custom reporters should be dropped (cf. [the installation documentation](install.md)). In particular, when upgrading to a newer version of utPLSQL, one has to drop the custom reporters and recreate them after the upgrade. - -!!! note - Please make sure that grants have been added and synonyms created for the custom reporter in order for reporter to be accessible the same way as other reporters. - Assuming that reporter with name `customer_reporter` was created in schema `UT3` -```sql - grant execute on ut3.custom_reporter to public; - create or replace public synonym custom_reporter for ut3.custom_reporter; -``` - - - -!!! note - It is possible, but cumbersome, to use another schema for storing the custom reporters. This requires to create a synonym for the base reporter type in the schema that is going to own the custom reporter, and to provide appropriate grants both to the owner of the custom reporter and to the user running the reporter. After upgrading or reinstalling utPLSQL, the extra privileges need to be recreated. This approach is not recommended. - -Assuming that the custom reporter type is created in the `UT3` schema, to run the tests using a custom reporter just call: `exec ut.run(ut3.custom_reporter_name());`, optionally providing parameter values to the `custom_reporter_name` constructor. - -One may get acquainted with the source code of the standard reporters bundled with utPLSQL (including the coverage reporters) by browsing the [`source/reporters/`](https://github.com/utPLSQL/utPLSQL/tree/develop/source/reporters) directory. The base reporter types `ut_reporter_base`, `ut_output_reporter_base` and `ut_console_reporter_base` are defined in [`source/core/types`](https://github.com/utPLSQL/utPLSQL/tree/develop/source/core/types). The base coverage reporter type `ut_coverage_reporter_base` is in [`source/core/coverage`](https://github.com/utPLSQL/utPLSQL/tree/develop/source/core/coverage). There are also two examples of custom reporters in [`examples/custom_reporters/`](https://github.com/utPLSQL/utPLSQL/tree/develop/examples/custom_reporters), both extending the functionality of `ut_documentation_reporter`: - -* `ut_custom_reporter` accepts an integer parameter `a_tab_size`; it alters the behaviour of `ut_documentation_reporter` by changing the size of the indentation according to the parameter value (by default the indentation is increased). -* `ut_expectations_reporter` accepts a `varchar2` parameter `a_report_all_expectations`; if its value is `'Y'` (which is the default), then the reporter shows the results of all expectations that are run. This stays in contrast with `ut_documentation_reporter`, which shows the results of all tests that are run, but only of the expectations that failed (keep in mind that a single test may consist of several expectations). diff --git a/docs/userguide/running-unit-tests.md b/docs/userguide/running-unit-tests.md deleted file mode 100644 index 28e02d5b8..000000000 --- a/docs/userguide/running-unit-tests.md +++ /dev/null @@ -1,570 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -utPLSQL framework provides two main entry points to run unit tests from within the database: - -- `ut.run` procedures and functions -- `ut_runner.run` procedures - -These two entry points differ in purpose and behavior. -Most of the time you will want to use `ut.run` as `ut_runner.run` is designed for API integration and does not display the results to the screen. - -## Running from CI servers and command line - -The best way to run your tests from CI server or command line is to use the [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) command line client. - -Amongst many benefits it provides ability to: -* see the progress of test execution for long-running tests - real-time reporting -* use many reporting formats simultaneously and save reports to files (publish) -* map your project source files and test files into database objects - -You may download the latest release of the command line client from [here](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) or do it automatically using the command below (Unix). - -```bash -#!/bin/bash -# Get the url to latest release "zip" file -DOWNLOAD_URL=$(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL-cli/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip\"" | sed 's/"//g') -# Download the latest release "zip" file -curl -Lk "${DOWNLOAD_URL}" -o utplsql-cli.zip -# Extract downloaded "zip" file -unzip -q utplsql-cli.zip -``` - - -## ut.run - -The `ut` package contains overloaded `run` procedures and functions. -The `run` API is designed to be called directly by a developer when using an IDE/SQL console to execute unit tests. -The main benefit of using this API is it's simplicity. -A single line call is enough to execute a set of tests from one or more schemes. - -The **procedures** execute the specified tests and produce output to DBMS_OUTPUT using the specified reporter. -The **functions** can only be used in SELECT statements. They execute the specified tests and produce outputs as a pipelined data stream to be consumed by a select statement. - -### ut.run procedures - -The examples below illustrate different ways and options to invoke `ut.run` procedures. -You can use a wildcard character `*` to call tests by part of their name or to call tests that are located on paths matched by part of path string. -Wildcard character can be placed anywhere on the path and can occur mutliple times. -Schema name cannot contain a wildcard character whether is in a suitepath call or call by object name. - -```sql linenums="1" -alter session set current_schema=hr; -set serveroutput on -begin - ut.run(); -end; -``` -Executes all tests in current schema (_HR_). - - -```sql linenums="1" -set serveroutput on -begin - ut.run('HR'); -end; -``` -Executes all tests in specified schema (_HR_). - - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr:com.my_org.my_project'); -end; -``` - -Executes all tests from all packages that are on the _com.my_org.my_project_ suitepath. -Check the [annotations documentation](annotations.md) to find out about suitepaths and how they can be used to organize test packages for your project. - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr:com*'); -end; -``` - -Executes all tests in schema `hr` from all packages that are on suitepath starting with `com`. - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr:co*.my_*.my_*'); -end; -``` - -Executes all tests in schema `hr` from all packages that starting with `my_` and all tests starting with `my_*` that are on suitepath starting with `co` . - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus'); -end; -``` -Executes all tests from package _hr.test_apply_bonus_. - - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus.bonus_cannot_be_negative'); -end; -``` -Executes single test procedure _hr.test_apply_bonus.bonus_cannot_be_negative_. - - -```sql linenums="1" -set serveroutput on -begin - ut.run(ut_varchar2_list('hr.test_apply_bonus','cust')); -end; -``` -Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_ (passing individual items to be executed as elements of the ut_varchar2_list table type). - - -```sql linenums="1" -set serveroutput on -begin - ut.run(ut_varchar2_list('hr.test_apply_bonus,cust')); -end; -``` -Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_ (passing all items as a comma-separated-list of values into a single element of the ut_varchar2_list table type). - - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus,cust'); -end; -``` - -Executes all tests from package _hr.test_apply_bonus_ and all tests from schema _cust_ (no explicit ut_varchar2_list table type). - -Using a list of items to execute allows you to execute a fine-grained set of tests. - -List can be passed as a comma separated list or a list of *ut_varchar2_list objects* or as a list within ut_varchar2_list. - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr.test*'); -end; -``` -Executes all tests in schema `hr` located in packages starting with name `test`. - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus.bonus_*'); -end; -``` -Executes test procedures with names starting with `bonus` in package `hr.test_apply_bonus` . - - -**Note:** - -`ut_documentation_reporter` is the default reporter for all APIs defined for running unit tests. - -The `ut.run` procedures and functions accept `a_reporter` attribute that defines the reporter to be used in the run. -You can execute any set of tests with any of the predefined reporters. - -```sql linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus', ut_junit_reporter()); -end; -``` -Executes all tests from package _HR.TEST_APPLY_BONUS_ and provide outputs to DBMS_OUTPUT using the JUnit reporter. - - -For details on build-in reporters look at [reporters documentation](reporters.md). - -### ut.run functions - -The `ut.run` functions provide exactly the same functionality as the `ut.run` procedures. -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 linenums="1" -select * from table(ut.run('hr.test_apply_bonus', ut_junit_reporter())); -``` - -## ut_runner.run procedures - -The `ut_runner` package provides an API for integrating utPLSQL with other products. Maven, Jenkins, SQL Develper, PL/SQL Developer, TOAD and others can leverage this API to call utPLSQL. - -The main difference compared to the `ut.run` API is that `ut_runner.run` does not print output to the screen. - -`ut_runner.run` accepts multiple reporters. Each reporter pipes to a separate output (uniquely identified by output_id). -Outputs of multiple reporters can be consumed in parallel. This allows for live reporting of test execution progress with threads and several database sessions. - -`ut_runner.run` API is used by utPLSQL-cli, utPLSQL-SQLDeveloper extension and utPLSQL-maven-plugin and allows for: -- deciding on the scope of test run (by schema names, object names, suite paths or tags ) -- running tests with several concurrent reporters -- real-time reporting of test execution progress -- controlling colored text output to the screen -- controlling scope of code coverage reports -- mapping of database source code to project files -- controlling behavior on test-failures -- controlling client character set for HTML and XML reports -- controlling rollback behavior of test-run -- controlling random order of test execution - -Running with multiple reporters. - -- in the main thread (session), define the reporters to be used. Each reporter has it's output_id and so you need to extract and store those output_ids. -- 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 `reporter.get_lines` table function or from `reporter.get_lines_cursor()` by providing the `reporter_id` defined in the main thread. -- each reporter for each test-run must have a unique `reporter_id`. The `reporter_id` is used between two sessions to identify the data stream - -Example: -```sql linenums="1" ---main test run ( session 1 ) -declare - l_reporter ut_realtime_reporter := ut_realtime_reporter(); -begin - l_reporter.set_reporter_id( 'd8a79e85915640a6a4e1698fdf90ba74' ); - l_reporter.output_buffer.init(); - ut_runner.run (ut_varchar2_list ('ut3_tester','ut3_user'), ut_reporters( l_reporter ) ); -end; -/ -``` - -```sql linenums="1" ---report consumer ( session 2 ) -set arraysize 1 -set pagesize 0 - -select * - from table( - ut_realtime_reporter() - .set_reporter_id('d8a79e85915640a6a4e1698fdf90ba74') - .get_lines() - ); -``` - -```sql linenums="1" ---alternative version of report consumer ( session 2 ) -set arraysize 1 -set pagesize 0 - -select - ut_realtime_reporter() - .set_reporter_id('d8a79e85915640a6a4e1698fdf90ba74') - .get_lines_cursor() - from dual; -``` - - -## 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 linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus', a_random_test_order => true); -end; -``` - -```sql linenums="1" -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 linenums="1" -set serveroutput on -begin - ut.run('hr.test_apply_bonus', a_random_test_order_seed => 302980531); -end; -``` - -```sql linenums="1" -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. - -## Run by Tags - -In addition to the path, you can filter the tests to be run by specifying tags. Tags are defined in the test / context / suite with the `--%tags`-annotation ([Read more](annotations.md#tags)). -Multiple tags are separated by comma. - - -### Tag Expressions - -Tag expressions are boolean expressions created by combining tags with the `!`, `&`, `|` operators. Tag expressions can be grouped using `(` and `)` braces. Grouping tag expressions affects operator precedence. - -Two reserved keywords, `any` and `none`, can be used when creating a tag expression to run tests. -- `any` keyword represents tests and suites with any tags -- `none` keyword represents tests and suites without tags - -These keywords may be combined with other expressions just like normal tags. - -!!! note - When specifying `none`, be aware that it will exclude any tests/suites/contexts contained within a tagged suite. - -| Operator | Meaning | -| -------- | --------| -| ! | not | -| & | and | -| \| | or | - -If you are tagging your tests across multiple dimensions, tag expressions help you to select which tests to execute. When tagging by test type (e.g., micro, integration, end-to-end) and feature (e.g., product, catalog, shipping), the following tag expressions can be useful. - - -| Tag Expression | Selection | -| -------- | --------| -| product | all tests for product | -| catalog \| shipping | all tests for catalog plus all tests for shipping | -| catalog & shipping | all tests that are tagged with both `catalog` and `shipping` tags | -| product & !end-to-end | all tests tagged `product`, except the tests tagged `end-to-end` | -| (micro \| integration) & (product \| shipping) | all micro or integration tests for product or shipping | - - -Taking the last expression above `(micro | integration) & (product | shipping)` - -| --%tags |included in run | -| -------- | --------| -| micro | no | -| integration | no | -| micro | no | -| product | no | -| shipping | no | -| micro | no | -| micro, integration | no | -| product, shipping | no | -| micro, product | yes | -| micro, shipping | yes | -| integration, product | yes | -| integration, shipping | yes | -| integration, micro, shipping | yes | -| integration, micro, product | yes | -| integration, shipping ,product | yes | -| micro, shipping ,product | yes | -| integration, micro, shipping ,product | yes | - - -### Sample execution of test with tags. - -Execution of the test with tag expressions is done using the parameter `a_tags`. -Given a test package `ut_sample_test` defined below - -```sql linenums="1" -create or replace package ut_sample_test is - - --%suite(Sample Test Suite) - --%tags(api) - - --%test(Compare Ref Cursors) - --%tags(complex,fast) - procedure ut_refcursors1; - - --%test(Run equality test) - --%tags(simple,fast) - 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; -/ -``` - -```sql linenums="1" -select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'api')); -``` -The above call will execute all tests from `ut_sample_test` package as the whole suite is tagged with `api` - -```sql linenums="1" -select * from table(ut.run(a_tags => 'fast&complex')); -``` -The above call will execute only the `ut_sample_test.ut_refcursors1` test, as only the test `ut_refcursors1` is tagged with `complex` and `fast` - -```sql linenums="1" -select * from table(ut.run(a_tags => 'fast')); -``` -The above call will execute both `ut_sample_test.ut_refcursors1` and `ut_sample_test.ut_test` tests, as both tests are tagged with `fast` - -### Excluding tests/suites by tags - -It is possible to exclude parts of test suites with tags. -In order to do so, prefix the tag name to exclude with a `!` (exclamation) sign when invoking the test run which is equivalent of `-` (dash) in legacy notation. -Examples (based on above sample test suite) - -```sql linenums="1" -select * from table(ut.run(a_tags => '(api|fast)&!complex')); -``` - -or - -```sql linenums="1" -select * from table(ut.run(a_tags => '(api|fast)&!complex&!test1')); -``` - -which is equivalent of exclusion on whole expression - -```sql linenums="1" -select * from table(ut.run(a_tags => '(api|fast)&!(complex|test1)')); -``` - -The above calls will execute all suites/contexts/tests that are marked with any of tags `api` or `fast` except those suites/contexts/tests that are marked as `complex` and except those suites/contexts/tests that are marked as `test1`. -Given the above example package `ut_sample_test`, only `ut_sample_test.ut_test` will be executed. - - -### Sample execution with `any` and `none` - -Given a sample test package: - -```sql linenums="1" -create or replace package ut_sample_test is - - --%suite(Sample Test Suite) - - --%test(Compare Ref Cursors) - --%tags(complex,fast) - procedure ut_refcursors1; - - --%test(Run equality test) - --%tags(simple,fast) - procedure ut_test; - - --%test(Run equality test no tag) - procedure ut_test_no_tag; - -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; - - procedure ut_test_no_tag is - begin - ut.expect(1).to_equal(0); - end; - -end ut_sample_test; -/ -``` - -```sql linenums="1" -select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'none')); -``` - -The above call will execute tests `ut_test_no_tag` - -```sql linenums="1" -select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'any')); -``` - -The above call will execute tests `ut_test` and `ut_refcursors1` - -```sql linenums="1" -select * from table(ut.run(a_path => 'ut_sample_test',a_tags => 'none|simple')); -``` - -The above call will execute tests `ut_test_no_tag` and `ut_test` - -```sql linenums="1" -select * from table(ut.run(a_tags => 'none|!simple')); -``` - -The above call will execute tests `ut_test_no_tag` and `ut_refcursors1` - -## 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 linenums="1" -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. - -If you run your tests using `utPLSQL-cli`, this is done automatically and no action needs to be taken. - -To make sure that the reports will display your national characters properly when running from IDE like SQLDeveloper/TOAD/SQLPlus or sqlcl you need to provide the charaterset manualy to `ut.run`. - -Example call with characterset provided: -```sql linenums="1" -begin - ut.run('hr.test_apply_bonus', ut_junit_reporter(), a_client_character_set => 'Windows-1251'); -end; -``` diff --git a/docs/userguide/upgrade.md b/docs/userguide/upgrade.md deleted file mode 100644 index 818a592bc..000000000 --- a/docs/userguide/upgrade.md +++ /dev/null @@ -1,9 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.1.14.4342--develop-blue.svg) - -# Upgrading from version 2 - -utPLSQL v3 is a total rewrite of the framework. -To make utPLSQL v2 packages run on v3 framework you need to install and execute migration utility. -See the [utPLSQL-v2-v3-migration](https://github.com/utPLSQL/utPLSQL-v2-v3-migration) project for details on how to install and execute the migration. - - diff --git a/documentation/src/admin.html b/documentation/src/admin.html new file mode 100644 index 000000000..18fe01ba6 --- /dev/null +++ b/documentation/src/admin.html @@ -0,0 +1,222 @@ + + + + + + + + + +

Administrative Topics

+ +

Configuring UTL_FILE

+ +

Join the Project Team

+ +

Reporting Bugs and Enhancement Requests

+ +

Administrative Topics

+ +

Configuring UTL_FILE

+

+ If you want utPLSQL to automatically recompile your test packages, you + will need to make sure that UTL_FILE is enabled in your database (this + allows you to read/write operating system files). The database initialization + parameter file (aka, the "init.ora" file) must have at least one utl_file_dir + parameter in it for this to work. Here is some background and guidelines + for working with UTL_FILE: +

+

+ UTL_FILE lets you read and write files accessible from the server on + which your database is running. So, theoretically, you could use UTL_FILE + to write right over your tablespace data files, control files and so on. + That is, of course, a very bad idea. Server security requires the ability + to place restrictions on where you can read and write your files. +

+

+ UTL_FILE implements this security by limiting access to files that reside + in one of the directories specified in the init.ora file (parameter initialization + file) for the database instance on which UTL_FILE is running. +

+

+ When you call UTL_FILE.FOPEN to open a file, you must specify both the + location and the name of the file, in separate arguments. This file location + is then checked against the list of accessible directories. +

+

+ The format of the parameter for file access in the init.ora file is: +

+
+utl_file_dir = <directory>
+
+

+ Include a parameter for utl_file_dir for each directory you want to make + accessible for UTL_FILE operations. The following entries, for example, + enable four different directories in Unix: +

+ +
+utl_file_dir = /tmp
+utl_file_dir = /ora_apps/hr/time_reporting
+utl_file_dir = /ora_apps/hr/time_reporting/log
+utl_file_dir = /users/test_area
+
+ +

+ To bypass server security and allow read/write access to all directories, + you can use this special syntax: +

+ +
+utl_file_dir = *
+
+ +

+ You should not use this option on production systems. In a development + system, this entry certainly makes it easier for developers to get up and + running on UTL_FILE and test their code. You should, however, only allow + access to a few specific directories when you move the application to production. +

+

Some observations on working with and setting up accessible directories with UTL_FILE:

+

+ Access is not recursive through subdirectories. If the following lines + were in your init.ora file, for example, +

+ +
+utl_file_dir = c:\group\dev1
+utl_file_dir = c:\group\prod\oe
+utl_file_dir = c:\group\prod\ar
+
+ +

+ then you would not be able to open a file in the c:\group\prod\oe\reports + subdirectory. +

+

+ Do not include the following entry in Unix systems: +

+ +
+utl_file_dir = .
+
+ +

+ This would allow you to read/write on the current directory in the operating + system. +

+

+ Do not enclose the directory names within single or double quotes. +

+

+ In the UNIX environment, a file created by UTL_FILE.FOPEN has as its + owner the shadow process running the Oracle instance. This is usually the + oracle owner. If you try to access these files outside of UTL_FILE, you + will need to have the correct privileges (or be logged in as oracle) to + access or change these files. +

+

+ You should not end your directory name with a delimiter, such as the + forward slash in Unix. The following specification of a directory will + result in problems when trying to read from or write to the directory: +

+ +
+utl_file_dir = /tmp/orafiles/
+
+ +

+ After you modify your parameter initialization file, you will need to stop + and then restart your database instance. +

+

Test UTL_FILE Access

+

+ If you have never before used or relied on UTL_FILE, you should write + a simple test to verify that UTL_FILE is now working. You can use the code + shown below (after changing your directory names and names for existing + and new files) to make sure you've got it running properly. +

+ +
+SET SERVEROUTPUT ON
+
+DECLARE
+   fid UTL_FILE.FILE_TYPE;
+   v VARCHAR2(32767);
+   PROCEDURE recNgo (str IN VARCHAR2)
+   IS
+   BEGIN
+      DBMS_OUTPUT.PUT_LINE ('UTL_FILE error ' || str);
+
+      UTL_FILE.FCLOSE (fid);
+   END;
+BEGIN
+   /* Change the directory name to one to which you at least 
+   || THINK you have read/write access.
+   */
+   fid := UTL_FILE.FOPEN ('e:\demo', 'existing_file', 'R');
+   UTL_FILE.GET_LINE (fid, v);
+   dbms_output.put_line (v);
+
+   UTL_FILE.FCLOSE (fid);
+
+   fid := UTL_FILE.FOPEN ('e:\demo', 'new_file', 'W');
+
+   UTL_FILE.PUT_LINE (fid, v);
+
+   UTL_FILE.FCLOSE (fid);
+EXCEPTION
+   WHEN UTL_FILE.INVALID_PATH
+      THEN recNgo ('invalid_path');
+   WHEN UTL_FILE.INVALID_MODE
+      THEN recNgo ('invalid_mode');
+   WHEN UTL_FILE.INVALID_FILEHANDLE
+      THEN recNgo ('invalid_filehandle');
+   WHEN UTL_FILE.INVALID_OPERATION
+      THEN recNgo ('invalid_operation');
+   WHEN UTL_FILE.READ_ERROR
+      THEN recNgo ('read_error');
+   WHEN UTL_FILE.WRITE_ERROR
+      THEN recNgo ('write_error');
+   WHEN UTL_FILE.INTERNAL_ERROR
+      THEN recNgo ('internal_error');
+END;
+/
+
+

+ If an error occurs, it will be displayed on your screen (note: the "set + serveroutput on" is not required for UTL_FILE to work, but simply to display + any errors which might occur). +

+ +

Join the utPLSQL Project Team

+ +

+ To take part in the utPLSQL project, have a look round the + utPLSQL project site, + in particular the CONTRIBUTING.md + and issues tracker. + Once you are up to speed on the project, you can choose a issue and begin to contribute. +

+ +

Reporting Bugs and Enhancement Requests

+ +

+ To identify the version of utPLSQL you are running, + you can execute the following program in SQL*Plus: +

+ +
+SQL> set serveroutput on
+SQL> exec dbms_output.put_line (utPLSQL.version)
+
+ +

+ You can also look inside the utPLSQL package (utPLSQL.pkb) + and check the value of the g_version private variable. +

+ + + + diff --git a/documentation/src/authors.txt b/documentation/src/authors.txt new file mode 100644 index 000000000..5fe198187 --- /dev/null +++ b/documentation/src/authors.txt @@ -0,0 +1,6 @@ +# This contains a list of authors and their +# email address, separated by a comma +# +Steven Feuerstein,steven@stevenfeuerstein.com +Chris Rimmer,c@24.org.uk +Patrick Barel,pbarel@vda.nl diff --git a/documentation/src/build_docs.pl b/documentation/src/build_docs.pl new file mode 100755 index 000000000..b980d529b --- /dev/null +++ b/documentation/src/build_docs.pl @@ -0,0 +1,239 @@ +#!/usr/bin/perl -w +# +# This perl script builds the documentation for utPLSQL +# $Id$ +# + +use strict; +use warnings; +use 5.010; +use File::Copy; + + +#Holds the map +my @map; + +#Holds the top navigation string +my $nav = ''; + +#Hold the copyright strings +my $copyright; +my $copymeta; +my $authormeta; +my $copyrightyears; + + +populate_map(); +build_copyright(); + +#Now build the documentation +my $index; +my $nextprev; + +my $outputpath = '..\output'; +mkdir($outputpath); +output_doc_dir($outputpath); + +sub output_doc_dir { + #The directory the output goes into + my ($OUTDIR) = @_; + + foreach $index (0..$#map){ + + open (my $outfile, '>', "$OUTDIR/$map[$index]->[0]") or die "Cannot open $OUTDIR/$map[$index]->[0] $!"; + build_nextprev($index); + + print $outfile html_header($map[$index]->[1]); + + #Either print the body, or construct it for the document map + if ($index != $#map){ + print $outfile html_main("$map[$index]->[0]"); + } else { + print $outfile html_docmap(); + } + + print $outfile html_footer(); + close $outfile; + } + + copy ("utplsql.css", "$OUTDIR"); + copy ("utplsql.jpg", "$OUTDIR"); +} + + +sub populate_map { + #Read the map file + open (my $mapfile, '<', 'map.txt') or die "Cannot open map.txt $!"; + my ($filename,$desc,$section); + + while (<$mapfile>){ + #Ignore lines starting with #, or empty + if (not /^#/ and /\S/){ + chomp; + + #Split on comma + ($filename, $desc) = split /,/; + + $section = 0; + + #Add entries ending in * to navigation bar + if ($desc =~ s/\*$//){ + $nav .= " | " if $nav; + $nav .= "$desc\n"; + $section = 1; + } + push @map, [$filename, $desc, $section]; + } + } + close $mapfile; + + #Add the document map + push @map, ["map.html", "Document Map", 1]; + $nav = "[ $nav | Document Map ]"; +} + + +sub build_copyright { + #Read the authors file + open (my $authorsfile, '<', 'authors.txt') or die "Cannot open authors.txt $!"; + my ($name, $email); + while (<$authorsfile>){ + + #Ignore lines starting with #, or empty + if (not /^#/ and /\S/){ + chomp; + ($name, $email) = split /,/; + $copyright .= ', ' if $copyright; + $copyright .= "$name"; + $authormeta .= ', ' if $authormeta; + $authormeta .= $name; + } + } + close $authorsfile; + + #Read the copyright_years file + open (my $copyrightyearsfile, '<', 'copyright_years.txt') or die "Cannot open copyright_years.txt $!"; + my $year; + while (<$copyrightyearsfile>){ + + #Ignore lines starting with #, or empty + if (not /^#/ and /\S/){ + chomp; + $copyrightyears .= ', ' if $copyrightyears; + $copyrightyears .= $_; + } + } + close $copyrightyearsfile; + + $copyright .= ' and the utPLSQL Project'; + $authormeta .= ' and the utPLSQL Project'; + + #Put together the rest of the copyright notices + $copyright = "Copyright © $copyrightyears $copyright. All rights reserved"; + $copymeta = "(C) $copyrightyears $authormeta"; +} + + +sub logo { + return '
utPLSQL logo
'; +} + + +sub build_nextprev { + my ($index) = @_; + + if ($index != 0){ + $nextprev = '< Previous Section: '.($map[$index-1]->[1]).''; + } else { + $nextprev = ''; + } + if ($index != $#map){ + $nextprev .= ' | ' if $nextprev; + $nextprev .= 'Next Section: '.($map[$index+1]->[1]).' >'; + } +} + +sub html_header { + my ($page_title) = @_; + my $head; + $head = "\n\n\n"; + $head .= "\n"; + $head .= "\n\n\n"; + $head .= "\n"; + $head .= "\n"; + $head .= " \n"; + $head .= " $page_title\n"; + $head .= " \n"; + $head .= " \n"; + $head .= " \n"; + $head .= " \n"; + $head .= " \n"; + $head .= " \n"; + $head .= "\n"; + $head .= "\n"; + $head .= logo()."\n"; + $head .= "

$nav

\n"; + $head .= "

$nextprev

\n"; + + return $head; +} + + +sub html_main { + my ($src_filename) = @_; + + my $body = ""; + my $in_body; + open (my $src_file, '<', $src_filename) or die "Cannot open $src_filename $!"; + while (<$src_file>){ + if (/(.*)/){ + $_ = "$1\n"; + $in_body = 1; + } + if (/(.*)/i){ + $in_body = 0; + $body .= "$1\n"; + } + $body .= $_ if $in_body; + } + close $src_file; + + return $body +} + + +sub html_docmap { + my $body; + $body = "

Document Map

\n"; + foreach (@map){ + $body .= "

"; + if ($_->[2]){ + $body .= ""; + } else { + $body .= "  "; + } + $body .= "[0]\">$_->[1]"; + $body .= "" if $_->[2]; + $body .= "

"; + } + + return $body; +} + + +sub html_footer { + my $footer; + $footer = "

$nextprev

\n\n"; + $footer .= logo()."\n\n"; + $footer .= "

\n"; + $footer .= " \n"; + $footer .= " \"Valid\n"; + $footer .= " \n"; + $footer .= "

\n\n"; + $footer .= "

$copyright

\n"; + $footer .= "\n"; + $footer .= ""; + + return $footer; +} \ No newline at end of file diff --git a/documentation/src/buildpack.html b/documentation/src/buildpack.html new file mode 100644 index 000000000..180cf2f19 --- /dev/null +++ b/documentation/src/buildpack.html @@ -0,0 +1,34 @@ + + + + + + + + + +

Build Test Packages

+ +

+ We learn best by following the examples of those who have gone before + us. So you will find in this document sample test packages and different + approaches to using utPLSQL to test your PL/SQL code like it has never + been tested before! +

+

+ Spend some time in the general How to Build a Test + Package so that you are comfortable with the basic steps necessary + to integrate your test code into the utPLSQL framework. The Test Run section + offers a narrative presentation of building a test package; it makes a + nice follow-up to the How To section if you still feel any uncertainty. + Then you will be more than ready to explore the Examples. +

+ +

How to Build a Test Package

+ +

A "Test Run" with utPLSQL

+ + + + diff --git a/documentation/src/copyright_years.txt b/documentation/src/copyright_years.txt new file mode 100644 index 000000000..1c07d8fc8 --- /dev/null +++ b/documentation/src/copyright_years.txt @@ -0,0 +1,4 @@ +# This contains a list of years for the copyright notices +# +2000-2005 +2014-2016 \ No newline at end of file diff --git a/documentation/src/defsuite.html b/documentation/src/defsuite.html new file mode 100644 index 000000000..9577786af --- /dev/null +++ b/documentation/src/defsuite.html @@ -0,0 +1,106 @@ + + + + + + + + + +

Defining Test Suites

+ +

+ If you define test suites and register packages + within those suites, then utPLSQL will run an unlimited number of + tests with a single command. +

+ +

Note

+ +
    +
  • + All suite names are stored in upper case. +
  • + +
  • + If you do not specify a directory (dir_in), + you will need to call utConfig.setdir if you want automatic compilation + of your packages to occur. +
  • + +
  • + If you supply a value for seq_in, packages + will be compiled and tested in ascending numeric sequence order. +
  • + +
  • + When you call utSuite.rem, it will remove all + packages for that suite by calling utPackage.rem. +
  • +
+ +

utSuite - Define Test Suites

+ +

To create and remove test suites, call these programs:

+ +
+PROCEDURE utSuite.add (
+   name_in          IN VARCHAR2,
+   desc_in          IN VARCHAR2 := NULL,
+   rem_if_exists_in IN BOOLEAN  := TRUE
+);
+
+PROCEDURE utSuite.rem (name_in IN VARCHAR2);
+
+ +

+ These programs manipulate the contents of the ut_suite + table. See the tables.sql file for the DDL creating this table. +

+ +

utPackage - Define Test Packages for a Suite

+ +

To register a package in a suite, call the following:

+ +
+PROCEDURE utPackage.add (
+   suite_in          IN VARCHAR2,
+   package_in        IN VARCHAR2,
+   samepackage_in    IN BOOLEAN := FALSE,
+   prefix_in         IN VARCHAR2 := NULL,
+   dir_in            IN VARCHAR2 := NULL,
+   seq_in            IN PLS_INTEGER := NULL,
+   owner_in          IN VARCHAR2 := NULL,
+   add_tests_in      IN BOOLEAN := FALSE,
+   test_overloads_in IN BOOLEAN := FALSE
+);
+
+ +

+ This manipulates the contents of the ut_package + table. See the tables.sql file for the DDL creating this table. +

+ +

+ Here is a sample script that defines a very small + portion of the PL/Vision test suite: +

+ +
+BEGIN
+   utSuite.add ('PLVision');
+
+   utPackage.add('PLVision', 'PLVstr', dir_in => 'e:\utplsql\test');
+
+   utPackage.add ('PLVision', 'PLVdate', dir_in => 'e:\utplsql\test'');
+
+   utPLSQL.testsuite ('PLVision', recompile_in => TRUE);
+
+END;
+/
+
+ + + + diff --git a/documentation/src/examples.html b/documentation/src/examples.html new file mode 100644 index 000000000..540284b43 --- /dev/null +++ b/documentation/src/examples.html @@ -0,0 +1,33 @@ + + + + + + + + + +

Examples

+ +

+ We learn best by following the examples of those who have gone before + us. So you will find in this document sample test packages and different + approaches to using utPLSQL to test your PL/SQL code like it has never + been tested before! +

+ +

Test a Procedure

+ +

Test a Function

+ +

Test an Entire Package API

+ +

Put Test Code in Same Package

+ +

Use Non-Default Prefix

+ +

Create and Run a Test Suite

+ + + diff --git a/documentation/src/fileout.html b/documentation/src/fileout.html new file mode 100644 index 000000000..b0a6d82c5 --- /dev/null +++ b/documentation/src/fileout.html @@ -0,0 +1,172 @@ + + + + + + + + + +

Configuring the File Reporter

+ +

Outline

+ +

+ By default, the results of a test run are written to the screen + (via the default Output Reporter). The subprograms described in this + section were created by Rainer Medert to allow these results to be written + to file instead. They form part of the utConfig package. Don't forget that + you will first need to enable file output from the database via the + UTL_FILE_DIR parameter in order to do this. +

+ +

Turning file output on

+ +

+ To turn on file output, you will need to switch to using the File + Reporter, or a custom reporter that uses it. See the page on Custom Reporter Packages for details. +

+ +

Setting the directory to be used

+ +

+ Once file output has been turned on, you can specify which directory the + files will be written to using the following procedure: +

+ +
+PROCEDURE setfiledir (
+   dir_in      IN VARCHAR2 := NULL, 
+   username_in IN VARCHAR2 := NULL
+);
+
+ +

+ the directory given will have to have been specified for output in a + UTL_FILE_DIR database parameter, as mentioned above. +

+ +

To see which directory is being used for output, use the following:

+ +
+FUNCTION filedir (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;
+
+ +

Formatting the output filenames

+ +

The structure of the filenames used for output is as follows:

+ +
+<user-prefix>_[program-name_]<date><extension>
+
+ +

Each of these elements can be configured using the following procedures.

+ +

+ The user-prefix is an arbitrary string. It defaults to the username of + the currently connected user, but can be set (and returned) using the + following: +

+ +
+-- Set the file prefix for a user
+PROCEDURE setuserprefix (
+   userprefix_in IN VARCHAR2 := NULL, 
+   username_in   IN VARCHAR2 := NULL
+);
+
+-- Get the file prefix for a user
+FUNCTION userprefix (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;
+
+ +

+ The program-name is the name of the tested program, or the test suite + being run. By default, this is element is not used in the generated filename. + To turn this on or off (and to determine the current setting), use the + following: +

+ +
+-- Set the include program name flag for a user
+PROCEDURE setincludeprogname (
+   incname_in  IN BOOLEAN := FALSE, 
+   username_in IN VARCHAR2 := NULL
+);
+
+-- Get the include program name flag for a user
+FUNCTION includeprogname (username_in IN VARCHAR2 := NULL) RETURN BOOLEAN;
+
+ +

+ The date element of the filename is simply SYSDATE converted to a string. + The default format is 'YYYYDDMMHH24MISS', but this can be set (and + returned) using the following: +

+ +
+-- Set the date format for a user
+PROCEDURE setdateformat (
+   dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss', 
+   username_in   IN VARCHAR2 := NULL
+);
+          
+-- Get the date format for a user
+FUNCTION dateformat (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;
+
+ +

+ The final element of the filename that can be configured is the extension. + This defaults to ".UTF" but can be set (and returned) using the following: +

+ +
+-- Set the file extension for a user
+PROCEDURE setfileextension (
+   fileextension_in IN VARCHAR2 := '.UTF', 
+   username_in IN VARCHAR2 := NULL
+);
+
+-- Get the file extension for a user
+FUNCTION fileextension (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;
+
+ +

+ Note The initial dot must be included, otherwise there will be none + in the resulting filename! +

+ +

Setting all the parameters at once

+ +

+ It is possible to set all the file output parameters at once using the + following procedure: +

+ +
+PROCEDURE setfileinfo ( 
+   dir_in           IN VARCHAR2 := NULL,
+   userprefix_in    IN VARCHAR2 := NULL, 
+   incname_in       IN BOOLEAN  := FALSE,     
+   dateformat_in    IN VARCHAR2 := 'yyyyddmmhh24miss', 
+   fileextension_in IN VARCHAR2 := '.UTF',
+   username_in      IN VARCHAR2 := NULL
+);
+
+ +

+ To get back all of the file output parameters simultaneously, use the + following function: +

+ +
+FUNCTION fileinfo (username_in IN VARCHAR2 := NULL) RETURN rec_fileinfo;
+
+ +

+ The record type rec_fileinfo is defined in the utConfig + package and has one field for each of the parameters. +

+ + + diff --git a/documentation/src/fourstep.html b/documentation/src/fourstep.html new file mode 100644 index 000000000..35cc894d0 --- /dev/null +++ b/documentation/src/fourstep.html @@ -0,0 +1,629 @@ + + + + + + + + + +

The Four Step Program to Using utPLSQL

+ +

Step 1. Install utPLSQL.

+ +

Step 2. Choose a program to test and identify the test cases.

+ +

Step 3. Build a test package.

+ +

Step 4. Run your test.

+ +

A note on which schemas to use

+ +

+ + + + Where to go from here +

+ +

Step 1. Install (and Upgrade) utPLSQL.

+ +

+ Note: if you have already installed a previous version of + utPLSQL, you will use these same steps to perform your install. The + installation procedure does not remove any objects, such as tables, + prior to installation. If you wish to install a fresh copy of utPLSQL, and not upgrade + over the existing installation, please follow the steps below for removing + utPLSQL. +

+ +

+ Connect via SQL*Plus to the session that will own the + utPLSQL components. If you do not already have a schema defined, then you must + create it. The utPLSQL schema must have the authority to: +

+ +
    +
  • Create a session.
  • +
  • Create tables, views, packages and sequences.
  • +
+ +

+ If you like, you can install utPLSQL into the SYSTEM schema, which will avoid the need to create + a new user. However, you may prefer to keep everything in a separate place. + The following is an example script submitted by Bill Pribyl, which creates a user "UTP" with sufficient privileges + to install utPLSQL. Obviously it is only an example and will need to be changed for your environment: +

+ +
+connect system/manager
+create user utp identified by utp default tablespace
+  users temporary tablespace temp;
+
+grant create session, create table, create procedure,
+  create sequence, create view, create public synonym,
+  drop public synonym to utp;
+
+alter user utp quota unlimited on users;
+
+ +

+ Note If the schema in question does not have the ability to create + and drop public synonyms or execute privilege on DBMS_PIPE, you may get + error messages when installing. However, utPLSQL will still function + correctly. +

+ +

+ Once you have connected to the schema, run the ut_i_do.sql + file with the parameter "install" to install all utPLSQL objects. You should ensure that + the working directory of your SQL*Plus + session is the directory holding the utPLSQL files, then issue this as follows: +

+ +
+SQL> @ut_i_do install
+
+ +

+ This file will create all tables, packages and other objects needed. + Note that the installation script + creates some files dynamically using the SPOOL command. For this reason, it is + necessary that you have write permission in the directory. +

+ +

To check the installation of utPLSQL, examine the ut_i_install.log file.

+ +

Removing utPLSQL

+ +

+ To de-install the product, run the ut_i_do.sql + script again, but with the parameter "uninstall", as in: +

+ +
+SQL> @ut_i_do uninstall
+
+ +

Step 2. Choose a program to test and identify the test cases.

+ +

+ You may want to test a single stand-alone procedure or + function, or a set of programs in a package. Pick the program and then come up + with the set of different cases you want to test. This data will determine what + kind of and how many tests you run for your program. +

+ +

+ Suppose, for example, that I have created a stand alone function called + betwnStr (a variation on SUBSTR that returns a sub-string based on a starting + and ending location) that is stored in betwnstr.sf (1): +

+ +
+CREATE OR REPLACE FUNCTION betwnStr (
+   string_in IN VARCHAR2,
+   start_in  IN INTEGER,
+   end_in    IN INTEGER
+)
+RETURN VARCHAR2
+IS
+BEGIN
+   RETURN (
+      SUBSTR (
+         string_in,
+         start_in,
+         end_in - start_in + 1
+      )
+   );
+END;
+
+ +

+ To test this function, I will want to pass in a variety of + inputs, as shown in this table: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Start

+
+

End

+
+

Result

+
+

NULL

+
+

NOT NULL

+
+

NULL

+
+

NOT NULL

+
+

NULL

+
+

NULL

+
+

NULL

+
+

NULL

+
+

NULL

+
+

3 (positive number)

+
+

1 (smaller positive number)

+
+

NULL

+
+

3 (positive number)

+
+

100 (larger than length of string)

+
+

Remainder of string from 3

+
+ +

So now I know what I want to test and how I want to test it.

+ +

Step 3. Build a test package.

+ +

+ utPLSQL offers an easy, automated way to run your tests. To + work automatically, though, you have to follow some rules so that utPLSQL can + find and execute your test code. Here are the rules: +

+ +

The test code must be placed inside a test package.

+ +

+ The test package specification should + be stored in a file named ut_<program>.pks and the body must be stored in + a file named ut_<program>.pkb (by following this naming convention, + utPLSQL can be set to automatically recompile your test package before each + test). +

+ +

+ The test package must contain a setup procedure called ut_setup and a teardown procedure called ut_teardown, neither of + which take any arguments. +

+ +

+ The test package should have a separate procedure for each program to be + tested in this package. +

+ +

+ Now, you should know that there are a number of bells and + whistles in utPLSQL that allow you to change many default values (such as the + prefixes used for the setup, teardown and test procedures) and behavior of the + utPLSQL packages. While you are "Getting Started", however, we will + rely completely on the defaults and get you up and testing ASAP. +

+ +

+ So if I am going to test the stand-alone procedure, betwnstr, my test + package specification, saved in ut_betwnstr.pks(1), + will look like this: +

+ +
+CREATE OR REPLACE PACKAGE ut_betwnstr
+IS
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+   
+   PROCEDURE ut_betwnstr;
+END ut_betwnstr;
+/
+
+ +

+ Now let's build the package body, saved in ut_betwnstr.pkb(1). In this very simple + case, I don't have to set up any data structures and I do not, therefore, have + to tear anything down. My teardown procedure can be empty (but it must + be present). So I have: +

+ +
+CREATE OR REPLACE PACKAGE BODY ut_betwnstr
+IS
+   PROCEDURE ut_setup IS
+   BEGIN
+      NULL;
+   END;
+   
+   PROCEDURE ut_teardown
+   IS
+   BEGIN
+      NULL;
+   END;
+
+ +

+ Time to build the unit test procedure. To do this, I need to + go back to my grid of test cases and translate those sets of data inputs and + results into calls to programs in the utAssert + package. +

+ +

+ utAssert offers a number of "assertion routines" that test the + values or expression you pass to them and then record the results in utPLSQL. + You can, with utAssert, test for equality between two strings or files or + tables or collections. You can test to see if an expression evaluates to NULL. + I can use both of these types of assertions (equality and IS NULL) for my test + cases, which I repeat below: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Start

+
+

End

+
+

Result

+
+

NULL

+
+

NOT NULL

+
+

NULL

+
+

NOT NULL

+
+

NULL

+
+

NULL

+
+

NULL

+
+

NULL

+
+

NULL

+
+

3 (positive number)

+
+

1 (smaller positive number)

+
+

NULL

+
+

3 (positive number)

+
+

100 (larger than length of string)

+
+

Remainder of string

+
+ +

+ Here's how it works: for each test case, I provide a string description of + the case, then the expression I want to evaluate. Let's start with + "typical valid usage". I pass a string "abcdefg", a start + location of 3 and end location of 5, and betwnstr should return + "cde". I express that in my unit test procedure as follows: +

+ +
+PROCEDURE ut_betwnstr IS
+BEGIN
+   utAssert.eq (
+      'Typical valid usage',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => 3,
+         END_IN => 5
+      ),
+      'cde'
+   );
+
+ +

+ Notice that I call utAssert.eq because I want to compare the + value returned by betwnstr with the string "cde". They should + be equal. +

+ +

+ I can now write another call to a utAssert program for each of my cases. In + this very next example, I call utAssert.isnull, because I am expecting betwnstr + to return a NULL value. +

+ +
+      utAssert.isnull (
+         'NULL start',
+         BETWNSTR(
+            STRING_IN => 'abcdefg',
+            START_IN => NULL,
+            END_IN => 5
+         )
+      );
+      
+      utAssert.isnull (
+         'NULL end',
+         BETWNSTR(
+            STRING_IN => 'abcdefg',
+            START_IN => 2,
+            END_IN => NULL
+         )
+      );
+      
+      utAssert.isnull (
+         'End smaller than start',
+         BETWNSTR(
+            STRING_IN => 'abcdefg',
+            START_IN => 5,
+            END_IN => 2
+         )
+      );
+      
+      utAssert.eq (
+         'End larger than string length',
+         BETWNSTR(
+            STRING_IN => 'abcdefg',
+            START_IN => 3,
+            END_IN => 200
+         ),
+         'cdefg'
+      );
+
+   END ut_BETWNSTR;
+   
+END ut_betwnstr;
+/
+
+ +

+ I have now created my unit test program for the betwnstr + function. I will compile both these files to make sure there are no compile + errors: +

+ +
+SQL> @ut_betwnstr.pks
+
+Package created.
+
+SQL> @ut_betwnstr.pkb
+
+Package body created.
+
+ +

+ Note: when you run your test, utPLSQL will by default + attempt to recompile your test package to ensure that the latest changes are + incorporated into the test. It is still worth doing an initial compile to make + sure you built your test properly. You will also need to make sure that UTL_FILE is installed and configured so that your + test package files can be read and compiled by utPLSQL. +

+ +

+ So with the test package in place and compiling, now let's + see how we go about running the test. +

+ +

Step 4. Run your test.

+ +

+ You've built your code, you've built your test package, + you've compiled that test package. Now it's time to run the test. Start up + SQL*Plus and connect to the schema owning the code you want to test. +

+ +

+ Then run your test package within the utPLSQL testing framework by calling utPLSQL.test: +

+ +
+SQL> exec utplsql.test ('betwnstr', recompile_in => FALSE)
+
+ +

+ That second parameter in the call to utplsql.test, + "recompile_in => FALSE", tells utPLSQL that you have already + compiled your test package. You can also have utPLSQL automatically recompile your test package + each time you run a test. +

+ +

+ If the test does not find any errors (which means that the assertion + programs did not detect any conflicts), you will see this output: +

+ +
+SQL> exec utplsql.test ('betwnstr', recompile_in => FALSE)
+SUCCESS: "betwnstr"
+
+ +

If the test detected a failure, you will see output along these lines:

+ +
+SQL> exec utplsql.test ('betwnstr', recompile_in => FALSE)
+FAILURE: "betwnstr"
+BETWNSTR: IS NULL: NULL start
+BETWNSTR: End larger than string length; expected "cdeg", got "cdefg"
+
+ +

+ As you can see, utPLSQL tells you the description of the + test case that failed, and also shows you as much as it can about what caused + the failure. +

+ +

+ You have now successfully installed utPLSQL, written a test package and run + your test! +

+ +

Automatic Recompilation of Test Package

+ +

+ utPLSQL will, by default, attempt to recompile your test package code + (which must be put in two files <name>.pks for the package specification + and <name>.pkb for the package body). This of course assumes that the files + are situated on the same machine as your database. If this is not the case, you can + turn off this functionality by calling utConfig.autocompile + as follows: +

+ +
+utConfig.autocompile(false);
+
+ +

+ If you do wish to use this functionality, utPLSQL needs + the UTL_FILE package provided by Oracle to read the source code files and then + compile the code found in those files. Before using UTL_FILE you must configure it for use from within PL/SQL. + Once you have confirmed that UTL_FILE works in your database instance, you + must tell utPLSQL where the test package is located by calling utPLSQL.setdir. + If you do not do this, then utPLSQL will not be able to recompile your test + package before each run, and instead will display an error message. +

+ +

+ Call the utConfig.setdir program to tell + utPLSQL the location of your source code. Suppose that I stored all my code in e:\utplsql\testall. Then I would make this + call in SQL*Plus: +

+ +
+SQL> exec utplsql.setdir ('e:\utplsql\testall')
+
+ +

A note on which schemas to use

+ +

+ In step 1, above, we described which user should own the objects which make up the utPLSQL framework. + However, there has often been confusion about which schema should contain the test packages and which schema to connect as + when running the tests. There are many ways to do it, but the simplest is as follows: +

+
    +
  • It doesn't matter which schema owns utPLSQL itself, so long as other users have access to it.
  • +
  • The test packages should go in the same schema as the code that is being tested.
  • +
  • You should connect as the user who owns the test packages (and hence the tested code) when running the tests
  • +
+ +

Where to go from here

+ +

+ If you proceeded through all four steps, you should now have + used utPLSQL successfully to test a very simple function (betwnstr) or your own + functionality. This will undoubtedly leave you very excited about using utPLSQL + to handle much more complex code and elaborate testing requirements. +

+ +

+ To find out more about the different features and + functionality available in utPLSQL, visit the User + Guide. +

+ +

+ To read through a more thorough presentation of how to build + test packages in utPLSQL, visit How to + Build Test Packages. +

+ +

+ To see a wide array of examples of building test cases and + different kinds of test packages, visit the Examples + document. +

+ +
+ +

Footnotes

+ +

1. This file is to be found in the Examples directory of the utPLSQL distribution.

+ + + + + diff --git a/documentation/src/glossreq.html b/documentation/src/glossreq.html new file mode 100644 index 000000000..3947ffdeb --- /dev/null +++ b/documentation/src/glossreq.html @@ -0,0 +1,131 @@ + + + + + + + + + +

Glossary and Requirements

+ +

Glossary

+ +

+ Before diving into the details, let's make sure + we have a common vocabulary. +

+ +

Unit Test

+ +

+ A test of a single unit or program. Suppose you + have built product.total_sales, a function to calculate and return total + sales of the specified product for a given date period. You will then build + a single procedure to perform the test for that function. +

+ +

Test Case

+ +

+ Individual cases or test scenarios for a unit test. + You will want to try out different scenarios (valid and invalid product + Ids, various date ranges, etc.). Each different combination of inputs (parameter + values) is a different test case. These are bundled up and executed within + the single unit test procedure. +

+ +

Package Test

+ +

+ A set of unit tests which test the functionality + of all programs in a single PL/SQL package (or a single stand-alone program + unit - procedure or function). +

+ +

+ The way utPLSQL works today, you must define + your various tests cases and unit tests within a test package (though it + could be the same package containing the functionality). +

+ +

Test Suite

+ +

+ A series of package tests. Obviously, any application + of non-trivial complexity will consist of multiple packages, each covering + their own area of functionality. A test suite contains a series of packages + that can then be tested in sequence by executing the test suite as a whole. +

+ +

Requirements

+ +

+ If you are using Oracle8i or above, utPLSQL takes advantage + of a number of Oracle8i features, including autonomous transactions, invoker + rights and native dynamic SQL. utPLSQL will however still run on Oracle7 + (7.3.4 and above) and Oracle8. +

+ +

Requirements for using utPLSQL include:

+ +
    +
  • +

    + The schema owning utPLSQL objects must have the ability to create tables and packages. +

    +
  • +
  • +

    + If you want utPLSQL to automatically recompile test packages for you, you + will need to have UTL_FILE installed and + configured to read from the directory or directories in which your package + source files are located. +

    +
  • +
  • +

    + Optional: The ability to create public synonyms. The installation script will attempt + to create public synonyms. If your schema does not have the authority to + do so, these commands will fail, but utPLSQL will still be available for + use in the owning schema. +

    +
  • +
  • +

    + Optional:Execute privilege on the DBMS_PIPE package. Without this, the UTPIPE package will not compile. + However, this is only required if you want to test data accessed via DBMS_PIPE. +

    +
  • +
+ +

Requirements for Executing Test Code

+ +

+ If you install and use utPLSQL from within a single schema (ie, the same schema that owns utPLSQL code and tables owns the code + you want to test, as well as the test packages), then no additional privileges are needed. +

+

+ If, however, you install utPLSQL in a shared schema and then access it from other schemas, you may need to grant additional + privileges to the utPLSQL schema. utPLSQL uses dynamic PL/SQL to run the test code. It therefore requires directly granted + EXECUTE privileges on those code elements (both the code to be tested and the test packages) -- or the AUTHID CURRENT_USER + capability of Oracle8i and above. +

+ +

For Oracle8i and above

+

+ You do not need to grant any additional privileges, unless you want to test code owned by one schema from another schema. + In that case, you will need to grant EXECUTE to the schema from which you run your tests on both the code to be tested and the test package. +

+ +

For Oracle7 and Oracle8

+

+ You must grant EXECUTE to the utPLSQL schema on both the code to be tested and the test package. + These grants must be made directly and not through roles. +

+ + + + + diff --git a/documentation/src/howto.html b/documentation/src/howto.html new file mode 100644 index 000000000..c97ce465d --- /dev/null +++ b/documentation/src/howto.html @@ -0,0 +1,609 @@ + + + + + + + + + +

How to build a test package

+ +

Instructions

+

+ To use utPLSQL, you will build a test package containing your unit tests. + This test package must conform to the API (application programmatic interface) + rules of utPLSQL, so that utPLSQL can run your tests automatically. +

+ +

Every test package must have:

+ +
+

+ A setup procedure - register your unit test and set + up any data structures needed for testing. +

+ +

+ A teardown procedure - remove any data structures + created for testing. +

+ +

+ One or more unit test procedures - perform the + unit tests. +

+
+ +

+ The names you give to your test package, setup, teardown and unit test + proceedures must also follow the utPLSQL Naming Conventions. +

+ +

Setup Procedure

+ +

+ The utPLSQL.test and utPLSQL.testsuite programs + will call the setup procedure of your test package before it runs any unit + tests. Use this procedure to define your unit tests and also initialize + any data structures needed for your units. The package specification header + for this procedure must be of this form: +

+ +
+CREATE OR REPLACE PACKAGE <prefix><package>
+IS
+   PROCEDURE <prefix>setup;
+
+ +

+ where <prefix> is the unit test prefix and <package> + is the name of the package (or stand alone program) to be tested. The default + naming convention is that your test package and all utPLSQL programs, including + the setup procedure, have a prefix of "ut_", as in: +

+ +
+CREATE OR REPLACE PACKAGE ut_<program>
+IS
+   PROCEDURE ut_setup;
+
+ +

+ Note: if you are using manual + registration of unit tests (which is not the default setting + and is not recommeded), see Naming Conventions + for details on when and how to apply prefixes to your package and procedure + names. +

+ +

+ Now let's take a look at the body/implementation + of the setup procedure and how you can use it to define test data structures + and, optionally, register unit tests. +

+ +

Define test data structures

+ +

+ You should use the setup procedure to define data structures you + need in one or more of your tests. You might, for example, want to create + a temporary table to hold information for comparison. You might populate + a collection or a record a scalar global variable. +

+ +

+ Here is an example of such a procedure (see the file ut_te_employee.pkb + in the Examples directory of the utPLSQL distribution for the full implementation): +

+ +
+PROCEDURE ut_setup
+IS
+BEGIN
+   ut_teardown;
+
+   EXECUTE IMMEDIATE 'CREATE TABLE ut_employee AS
+         SELECT * FROM employee';
+
+   EXECUTE IMMEDIATE 'CREATE TABLE ut_DEL1 AS
+         SELECT * FROM employee';
+
+   EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_DEPT_LOOKUP AS
+         SELECT * FROM employee';
+END;
+
+ +

+ For each of my tests, I create a separate table to modify and then use + in my utAssert comparison. +

+ +

+ You could place these statements in each of the individual unit test + procedures. The advantage of storing them all in the single setup procedure + is that they are easier to manage -- and also easier to tear down or destroy + when you are done. +

+ +

Manual registration of unit tests

+ +

+ If you have decided to choose manual + registration of your unit test procedures, then you will need to register + each procedure with a call to utPLSQL.registertest + in the setup procedure. This is not recommended. But if you insist... +

+ +

+ Here is an example of a setup procedure for the + PLVdate package: +

+ +
+CREATE OR REPLACE PACKAGE BODY ut_plvdate
+IS
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      utplsql.addtest ('ut_to_date');
+      utplsql.addtest ('ut_to_char');
+   END;
+
+ +

+ The names passed to the utPLSQL.addtest procedure + must match the interface of the defined unit test procedures + with the following interface. So the above two calls to addtest tell utPLSQL + to look for two unit test procedures named ut_to_date and ut_to_char. +

+ +

Teardown Procedure

+ +

+ The utPLSQL.test and utPLSQL.testsuite programs + will call the teardown procedure of your test package after it runs all + unit tests. Use this procedure to destroy or remove any data structures + that were needed for your units. The contents of this procedure should, + in general, be the logical reverse of the contents of the setup + procedure. The package specification header for this procedure must + be of this form: +

+ +
+CREATE OR REPLACE PACKAGE <prefix><package>
+IS
+   PROCEDURE <prefix>teardown;
+
+ +

+ where <prefix> is the unit test prefix and <package> + is the name of the package (or stand alone program) to be tested. +

+ +

+ The default naming convention is that your test + package and all utPLSQL programs, including the teardown procedure, have + a prefix of "ut_", as in: +

+ +
+CREATE OR REPLACE PACKAGE ut_<program>
+IS
+   PROCEDURE ut_teardown;
+
+ +

+ Note: if you are using manual + registration of unit tests (which is not the default setting + and is not recommeded), see Naming Conventions + for details on when and how to apply prefixes to your package and procedure + names. +

+ +

+ Now let's take a look at the body/implementation + of the teardown procedure and how you can use it to remove test data structures. +

+ +

+ Here is an example of the most common type of teardown + procedure -- it does nothing: +

+ +
+CREATE OR REPLACE PACKAGE ut_sales_pkg
+IS
+   PROCEDURE teardown
+   IS
+   BEGIN
+      NULL;
+   END;
+
+ +

+ This is what your teardown procedure will look like + when you do not need to create any special data structures for your tests. + If I were testing a simple string utility, for example, I do not need a + database table or collection to run my tests. Note that even if your teardown + procedure does nothing, it still must be present in the package specification + and body. utPLSQL will look for and try to execute the procedure as + part of its S.O.P. (standard operating procedure). +

+ +

+ Now, if your setup procedure creates something, + you should probably destroy it in teardown. You might drop or truncate + tables, do a ROLLBACK or simply make sure files and cursors are closed. + Here is an example of such a procedure: +

+ +
+PROCEDURE teardown
+IS
+BEGIN
+   mycollection.DELETE;
+   EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || workspace_tab;
+   DBMS_SESSION.FREE_UNUSED_USER_MEMORY;
+END;
+
+ +

The Unit Test Procedure

+ +

+ The unit test procedure is, of course, where it + gets really interesting and very application specific. +

+ +

The general format for a test procedure is as follows:

+ +
+CREATE OR REPLACE PACKAGE <prefix><package>
+IS
+   PROCEDURE <prefix><program>;
+
+ +

+ where <prefix> is the unit test prefix and <package> + is the name of the package (or stand alone program) to be tested. The default + naming convention is that your test package and the unit test procedure + each have a prefix of "ut_". You can override that prefix with another + of your own choosing in your call to utPLSQL.test + or utPLSQL.testsuite. Under some circumstances, you can drop + the prefix on the unit test procedure, but this is not recommended. see + Naming Conventions. for details. +

+ +

+ Here is a very generic version of a unit test package + specification and a single unit test procedure: +

+ +
+-- Test package for stand alone program
+CREATE OR REPLACE PACKAGE ut_<package>
+IS
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+   PROCEDURE ut_<program>;
+END;
+
+ +

+ The body of your unit test procedure is, well, mostly + yours to figure out, since we don't know what you are testing and how you + need to test it. The basic format of this test procedure, however, should + be: +

+ +
+PROCEDURE <myprogram>
+IS
+BEGIN
+   <run package.myprogram or set up for test>
+
+   -- call a utAssert assertion to check results:
+   utAssert.<assertion> (...);
+
+   <repeat of the above for different test cases>
+EXCEPTION
+   WHEN OTHERS
+   THEN
+      utAssert.this (
+         'Unknown failure of <package.myprogram>: ' || SQLERRM,
+         FALSE);
+END;
+
+ +

+ You should include a call to a utAssert assertion program in the exception + section to trap unexpected errors and register a test failure (I pass FALSE + for the second argument, which guarantees a failure!). You might, of course, + have other handlers to trap specific exceptions like NO_DATA_FOUND and + either register a failure or ignore the exception, since it might not be + an actual test failure. +

+ +

+ Here is an example of a unit test procedure that contains multiple calls + to assertion programs for different test cases. +

+ +
+PROCEDURE ut_BETWNSTR IS
+BEGIN
+   utAssert.eq (
+      'Typical valid usage',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => 3,
+         END_IN => 5
+      ),
+      'cde'
+   );
+      
+   utAssert.isnull (
+      'NULL start',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => NULL,
+         END_IN => 5
+      )
+   );
+
+   utAssert.isnull (
+      'NULL end',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => 2,
+         END_IN => NULL
+      )
+   );
+      
+   utAssert.isnull (
+      'End smaller than start',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => 5,
+         END_IN => 2
+      )
+   );
+      
+   utAssert.eq (
+      'End larger than string length',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => 3,
+         END_IN => 200
+      ),
+      'cdefg'
+   );
+      
+END ut_BETWNSTR;
+
+ +

+ In the above case, I am testing a function, so I call the function "in + line" with the assertion program. When testing a procedure, you will call + the procedure first and then call the appropriate assertion program to + test the outcome. +

+ +

+ Explore the Examples to learn about different + ways to write unit test procedures. +

+ +

Naming Conventions

+ +

+ When you execute a test or test suite, utPLSQL looks for a test package, + based on the name of the program you are testing. It then attempts to execute + specific programs within that package. utPLSQL allows you to test stand-alone + programs (procedure or function) or package-based programs. When testing + the contents of a package, you can place your unit test procedures in the + same + package or a separate test package. That's a lot of flexibility, and + flexibility generally leads to confusion. +

+ +

+ To make things as simple as possible, the default mode of utPLSQL follows + this simple rule: +

+ +

+ Your unit test package and each utPLSQL-related program in that package + (setup, teardown and unit tests) must all use the same prefix. +

+ +

+ The default prefix is "ut_", but you can override that with your own. + If you follow this rule (and you can follow it very easily by using the + utGen + package to generate a starting point for your test packages), utPLSQL +

+ +

+ If you are following the utPLSQL defaults and letting the utility automatically + detect and execute unit tests, do not read any further! +

+ +

+ If you choose to perform manual + registration of your unit tests, then read the following sections carefully, + as there is a scenario in which you should not apply the utPLSQL + prefix to your unit test procedures. +

+ +

+ This section describes the conventions or rules that utPLSQL follows + to locate and execute your unit tests. There are three different "scenarios" + to consider: +

+ +

Separate test package to test package-based programs

+ +

Separate test package to test a stand-alone program

+ +

Single package containing both source to be tested and unit test programs

+ +

+ While these rules might seem confusing at first glance, you will find + over time that they are designed to make the issue of what things are named + as transparent as possible when you run your tests. In other words, you + simply ask to test "mypackage"; you don't have to run some oddly-named + program with a prefix in front of it. +

+ +

+ In addition, you can use the utGen package to + generate a starting point for your test packages. utGen will automatically + follow the rules; you only need to "fill in the blanks" of your unit test + procedures within the established headers. +

+ +

Separate test package to test package-based programs

+ +

+ If you are placing your unit test code in a package separate from your + source code (the default setting), then the name of that test package must + be of the form: +

+ +
+<prefix><package>
+
+ +

+ where <prefix> is the utPLSQL prefix and <package> is the name of + the package containing the programs to be tested. +

+ +

You specify the prefix in one of the following ways:

+ +
    +
  • + When you call utPLSQL.test or utPLSQL.testsuite, you can pass a value for + the prefix_in parameter (the default is "ut_"). +
  • + +
  • + When you call utPackage.add to add a package + to a suite, you can pass a value for the prefix_in parameter (the default + is "ut_"). This prefix is then stored in the ut_package table. +
  • +
+ +

+ The names of the test package programs, on the other hand, should not + have a prefix before them. These prefixes are not necessary to distinguish + the test procedure with the program being tested, since they are defined + in different packages. +

+ +

Separate test package to test a stand-alone program

+ +

+ If you are placing your unit test code in a package separate from your + source code (the default setting), then the name of that test package must + be of the form: +

+ +
+<prefix><program>
+
+ +

+ where <prefix> is the utPLSQL prefix and <program> is the name of + the stand-alone program you plan to test. +

+

+ You specify the prefix in one of the following ways: +

+ +
    +
  • + When you call utPLSQL.test or utPLSQL.testsuite, you can pass a value for + the prefix_in parameter (the default is "ut_"). +
  • + +
  • + When you call utPackage.add to add a package + to a suite, you can pass a value for the prefix_in parameter (the default + is "ut_"). This prefix is then stored in the ut_package table. +
  • +
+ +

+ The names of the test package programs, on the other hand, also must have + the same prefix. This is necessary to avoid confusing naming conflicts + between the program you are testing and the name of the unit test procedure + for that program, as in the following package that tests the betwnstr function: +

+ +
+CREATE OR REPLACE PACKAGE ut_betwnstr
+IS
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+   PROCEDURE ut_betwnstr;
+END ut_betwnstr;
+/
+
+ +

+ I suppose that looks odd; I have created a function named ut_betwnstr.ut_betwnstr + and it would be very strange to write code like that. But that is the whole + point of utPLSQL: I don't have to write code like that. I just run + my test with nothing more than this: +

+ +
+SQL> exec utPLSQL.test ('betwnstr')
+
+ +

Single package containing both source to be tested and unit test programs

+ +

+ Finally, there is the scenario in which a developer places all of her test + programs (setup, teardown and unit tests) in the same package as the code + to be tested. In this case, there is no separate test package, so all of + the test programs must use the utPLSQL prefix, as in: +

+ +
+CREATE OR REPLACE PACKAGE str
+IS
+   FUNCTION betwn (
+      string_in IN VARCHAR2,
+      start_in IN PLS_INTEGER,
+      end_in IN PLS_INTEGER
+   )
+      RETURN VARCHAR2;
+      
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+   PROCEDURE ut_betwn;
+      
+END str;
+/
+
+ +

You specify the prefix in one of the following ways:

+ +
+
    +
  • + When you call utPLSQL.test or utPLSQL.testsuite, you can pass a value for + the prefix_in parameter (the default is "ut_"). When you call utPackage.add + to add a package to a suite, you can pass a value for the prefix_in parameter + (the default is "ut_"). This prefix is then stored in the ut_package table. +
  • +
+
+ + + + diff --git a/documentation/src/index.html b/documentation/src/index.html new file mode 100644 index 000000000..c2bad8cff --- /dev/null +++ b/documentation/src/index.html @@ -0,0 +1,82 @@ + + + + + + + + + +

Table of Contents

+ +

Welcome to utPLSQL - a unit testing framework for the Oracle PL/SQL Language

+ +

Getting Started

+ +
+

+ This document tells you the minimum you need + to know in order to get started with utPLSQL: how to install the software, + build simple test packages, and run your tests. +

+
+ +

Build Test Packages

+ +
+

+ utPLSQL provides with you a framework in which + to run your tests. You still have to write your test code, and that code + must follow some rules if utPLSQL is going to know how to run those tests. +

+
+ +

Examples

+ +
+

+ There is no better way to learn how to build + and run utPLSQL test packages than to work from the many examples found + here. +

+
+ +

User Guide

+ +
+

+ Once you are familiar with utPLSQL basics, have + run some tests, and are ready to learn and use more of the many utPLSQL + features, the User Guide will tell you all you need to know about the different + features and programs of utPLSQL. +

+
+ +

Release Notes

+ +
+

+ Well, you know what these are: a description + of fixes and enhancements in the latest release! +

+
+ +

Document Map

+ +
+

The full list of the pages in the documentation

+
+

Web Site

+

+ https://utplsql.github.io/ Contains links to various resources such as: +

    +
  • How to contribute
  • +
  • Download Location of the recent release
  • +
  • For support, bug reports or enhancement ideas, you can always visit the issue tracker page.
  • +
+

+ + + + diff --git a/documentation/src/map.txt b/documentation/src/map.txt new file mode 100644 index 000000000..b974631a9 --- /dev/null +++ b/documentation/src/map.txt @@ -0,0 +1,35 @@ +# This file contains a list of files and titles to +# make up the documentation. The filename and title +# should be separated by a comma. An asterisk after +# the title means that that file gets added to the +# Navigation Bar and is highlighted in the document +# Map. Note that the document map is not in this list +# but is added automatically at the end. +# +index.html,Home* +started.html,Getting Started* +glossreq.html,Glossary and Requirements +fourstep.html,The Four Step Program to using utPLSQL +admin.html,Administrative Topics +buildpack.html,Build Test Packages* +howto.html,How to build a test package +testrun.html,A 'Test Run' with utPLSQL +examples.html,Examples* +testproc.html,Test a Procedure +testfunc.html,Test a Function +testapi.html,Test an Entire Package API +samepack.html,Put Test Code in Same Package +prefix.html,Use Non-Default Prefix +suite.html,Create and Run a Test Suite +userguide.html,User Guide* +utplsql.html,utPLSQL Package +utconfig.html,utConfig Package +utresult.html,utResult Package +utassert.html,utAssert Package +utgen.html,utGen Package +utoutput.html,utOutput Package +utreceq.html,utRecEq Package +defsuite.html,Defining Test Suites +reporter.html,Custom Reporter Packages +fileout.html,Configuring the File Reporter +release.html,Release Notes* diff --git a/documentation/src/prefix.html b/documentation/src/prefix.html new file mode 100644 index 000000000..fcf968062 --- /dev/null +++ b/documentation/src/prefix.html @@ -0,0 +1,55 @@ + + + + + + + + + +

Use Non-Default Prefix

+ +

+ The default prefix for utPLSQL is "ut_", but you don't have to use that + prefix. There are some situations where you absolutely will not want to + use the default prefix. Suppose, for example, that you have written a package + with ten procedures, each of which already have "ut_" as a prefix + (it might stand for "Unified Technologies" or "Underside Treatment: or...well, + you get the picture). +

+ +

+ Since this prefix is not hard-coded into utPLSQL, you can very easily + specify your own prefix. You can do this when you run a test, as in: +

+ +
+SQL> utPLSQL.test ('te_employee', prefix_in => 'test_');
+
+ +

You can also specify a prefix when you add a package to a test suite, as in:

+ +
+SQL> utPackage.add ('mysuite', 'mypackage' prefix_in => 'test_');
+
+ +

+ Of course, when you specify a non-default prefix, you must also build your + test package using that prefix. If you plan to generate a starting point + for your package with utGen, be sure to specify your prefix at that point, + as in: +

+ +
+SQL> utGen.testpkg('mypackage' prefix_in => 'test_');
+
+ +

+ For an example of a package with a non-default prefix, check out test_te_employee.pks + and test_te_employee.pkb (Both to be found in the Examples directory of the utPLSQL distribution). +

+ + + + diff --git a/documentation/src/readme.txt b/documentation/src/readme.txt new file mode 100644 index 000000000..3c81d826f --- /dev/null +++ b/documentation/src/readme.txt @@ -0,0 +1,71 @@ +================================== +HOW TO BUILD UTPLSQL DOCUMENTATION +================================== +$Id$ +================================== + +The utPLSQL documentation is built from a series of simple HTML files in the +src directory. These files have none of the navigation bars, logos or +next/previous links which appear in the final documentation. They are also +stripped of font, color and style information at compile-time to let the +stylesheet (utplsql.css) determine the overall look-and-feel. + +--------- +THE FILES +--------- + +The files are compiled into a documentation set situated in the top-level +documentation directory using the 2 control files, map.txt and authors.txt. +The first of these is the driving file, giving a list of the files to be +included. The second gives a list of authors to be included in the copyright +notice on each page and referenced in the Meta tags. + +The format of map.txt is as follows: + + # Any line starting with a # is + # considered a comment + # + index.html,Home* + started.html,Getting Started* + another.html,Further Docs + another2.html,Yet more docs + +Each line consists of the filename to be included and the title of the page, +separated with a comma. Any file whose title is followed by an asterisk is +considered the start of a new section. This means a link to the file will +appear in the navigation bar at the top of each page and it will appear in +bold in the document map. Note that the document map itself does not appear +in map.txt, but is always added at the end and is considered a new section. +This page is entirely generated at compile-time. + +The format of authors.txt is as follows: + + # Again, lines starting # are ignored + # + Steven Feuerstein,steven@stevenfeuerstein.com + Chris Rimmer,c@24.org.uk + A N Other,ano@ther.net + +Each line in this file simply gives the name of the author and their email +address, separated with a comma. + +----------- +THE SCRIPTS +----------- + +The 2 Perl scripts used to build the documentation are clean_html.pl and +build_docs.pl. + +The first of these simply strips HTML files down to the basics, removing +everything from the header and removing Javascript, fonts, color etc. It +requires the HTML::TagFilter module which in turn also requires the +HTML::Parser and HTML::Tagset modules (all available from search.cpan.org). + +The second script goes through each file listed in map.txt, cleans it using +the previous script and then adds logos, navigation bars, next/previous links, +copyright information etc. The resulting files are put in the top-level +documentation directory. + +NOTE: Anything within a source file before the +"" comment line and after the +"" comment line is ignored. diff --git a/documentation/src/release.html b/documentation/src/release.html new file mode 100644 index 000000000..b63702964 --- /dev/null +++ b/documentation/src/release.html @@ -0,0 +1,693 @@ + + + + + + + + + +

Release Notes

+ +

Known Issues

+

utPLSQL version 2.x

+
    +
  • + There is an issue surrounding the use of utPLSQL on Oracle 8.1.7 where + the tests use database links. This is because Oracle will consider + the transaction to be distributed and utPLSQL v2 uses autonomous transactions + while the tests are running. This situation causes ORA-00164 in 8.1.7 + (and apparently should not have been allowed in 8.1.5 or 8.1.6 either). It + is possible to work around this problem by turning off autonomous transactions + , but this can cause other problems if the tests themselves have rollbacks + within them. +
  • + +
  • + The utAssert.eqtable assertion program will not work with tables that + contain non-scalar datatypes, such as LOBs, XMLType, collections and so on. +
  • +
+ +

Change History

+ +

utPLSQL version 2.3.1 (7th July 2016)

+ +
    +
  • Updated documentation to reference GitHub.
  • +
+ + +

utPLSQL version 2.3.0 (8th February 2015)

+ + + +

utPLSQL version 2.2.3 (30th August 2014)

+ +
    +
  • + Bug 35: Fixed an issue with utAssert.eqQuery failing with long select statements. +
  • +
  • + Bug 39: Corrected a spelling mistake in the documentation. +
  • +
+ +

utPLSQL version 2.2.2 (4th May 2014)

+ +
    +
  • + Bug 32: Fixed issue with "eqquery" failing if a statement contained "UNION ALL". +
  • +
  • + Bug 33: Fixed issue which meant tests ran in an undetermined order (they will now run in alphabetical order). +
  • +
+ +

utPLSQL version 2.2.1 (6th April 2014)

+ +
    +
  • + Bug 29: Fixed issue with the Uninstall leaving two views behind. +
  • +
  • + Bug 38: Fixed issue which prevented building the documentation depending on the build environment. +
  • +
  • + Feature Request 6: Updated documentation and made it all valid XHTML. +
  • +
+ +

utPLSQL version 2.2

+ +
    +
  • + This version introduces the concept of Output Reporters. The existing code to output to DBMS_OUPUT or to file has been refactored to + fit into this framework. As a result of this, the pl procedure in the utplsql package has been moved to the utreport package. +
  • +
  • + The installation procedure has been changed so that the database version is picked up more robustly. Version 2.2 works with 10g, + which previous versions did not. It should also work with future versions (so long as the version is to be found in the same place + in the data dictionary). +
  • +
  • + There are also a variety of small fixes in this release. +
  • +
+ +

utPLSQL version 2.1.1

+ +
    +
  • + This version has a variety of small fixes and is released to coincide + with OUnit version 1.0. +
  • +
  • + The installation procedure has been changed and a variety of bugs with it have been fixed. +
  • +
  • + utGen.exe has been removed from the "core" utPLSQL distribution. The functionallity it supplied will be included in a future version of Ounit. +
  • +
+ +

utPLSQL version 2.0.10.1

+ +
    +
  • + Allow user to specify (as part of their individual configuration) that they + only want to show failed tests, and then whether all information or just the + description (request from Heinz of UBS). Supersedes the + utresult.ignore_successes and utresult.include_successes (whose settings do not + persist across sessions). +
  • +
  • + Support for testing contents of REF CURSORs (cursor variables) has been added + (provided by Venky Mangapillai) with the eq_refc_table and eq_refc_query + assertion routines. +
  • +
  • + Adds testpkg_from_table to utgen to allow generation of a test package directly + from the new ut_grid table (provided by Patrick Barel). Patrick has also built + a Windows-based front end, utGen.exe, that allows us to populate this grid very + easily. Thanks, Patrick! +
  • +
  • + Add ut_outcome_seq sequence for ut_outcome table. +
  • +
  • + Add control_info and test_info columns to ut_outcome table. +
  • +
  • + Add ability to direct output from utPLSQL's test run (the test results) to a + file instead of to the screen. This functionality was provided by Rainer + Medert. The documentation for this feature has not yet been integrated into the + documentation set. You will find the "beta" documentation in the + file_output_spec.doc in the doc directory. +
  • +
+ +

utPLSQL version 2.0.9.2

+ +
    +
  • + Surround AUTHID CURRENT_USER clause of utreceq.pks to allow for installation on + Oracle7 and Oracle8. +
  • +
  • + Add override_package_in argument to utPLSQL.test so that you can bypass the + standard ut_<package> naming conventions for testing. This is useful + when your package name's length is 28 or above. By passing in the override + package name, you can avoid the name limitation. +
  • +
  • + New assertion programs to validate DBMS_OUTPUT text that is generated from + within a program. +
  • +
  • + Add utplsql.run and utplsql.runsuite to run a named test package directly, and + not correlate it via the name of the program being tested. +
  • +
+ +

utPLSQL version 2.0.9.1

+ +
    +
  • + Add ut_reqeq table and utreceq package to support the creation of "record + equal" functions (contributed by Dan Spencer). +
  • +
  • + Modify utPLSQL.test so that the record comparison functions are generated + and recompiled whenever the source code is recompiled. + Call utreceq.add to register a package-table combination. +
  • +
  • + Modified utpackage.id_from_name to take an owner_in parameter with a + NULL default value. v_owner is set to nvl(owner_in,user). added + owner = v_owner and suite_id is null to the WHERE clause. +
  • +
  • + Modified utpackage.add to add in a record with suite_id NULL if one + doesn't exist. +
  • +
  • + Modified utpackage.upd - changed parameter suite_in to suite_id_in (the + type was INTEGER). Changed the UPDATE WHERE clause first line + to NVL(suite_id,0) = NVL(suite_id_in,0). +
  • +
  • + Modified utplsql.testsuite - v_suite (the suite id) was in the + call to utplsql.test while the utplsql.test parameter list was expecting + the suite name. The results of a test run are now logged to the + appropriate record in ut_package [the record for the suite if run from + testsuite, the record with suite_id NULL if run via an EXEC UTPLSQL.TEST('packagename')]. +
  • +
  • + Add objExists and objNotExists assertion programs +
  • +
  • + Changes to utPLSQL.test engine so that you can test programs define + in one schema from another schema. +
  • +
  • + Add previous_passed and previous_failed to utAssert and utAssert2 +
  • +
  • + Set order in which test case results are displayed to the order in which + they are run by adding the tc_run_id to the utr_outcome table. +
  • +
+ +

utPLSQL version 2.0.8.2

+ +
    +
  • + Change ut_utp LOB column to VARCHAR2 for the time being. +
  • +
  • + Fixed ALTER TABLE statement in ut_config.tab. +
  • +
  • + Change utplsql.test to allow for compilation of test package before + extracting list of test procedures from that package (avoids the " + Warning...no tests were identified for execution!" message). +
  • + +
  • + Add utAssert2.eval generic comparison program, and also utAssert.eval, + with an overloading for just two values, to make it really easy to use. +
  • +
  • + Add utGen.receq_package procedure. It currently ONLY writes the code + out to the screen via DBMS_OUTPUT.PUT_LINE. It does not, in other words, + support the multiple outputs of utGen.testpkg. +
  • +
  • + Update the utplsql_install.sql script to recognize Oracle9.0 and Oracle9.1 + versions and install all 8i features for those versions (there is nothing + specific to 9i at this time). +
  • +
+ +

utPLSQL version 2.0.8.1

+ +
    +
  • + Fixes to a number of minor installation errors. +
  • +
  • + Offers option in utPLSQL.test to request that setup and teardown is + executed with each test procedure and not the test package level. + Implements a new features in utPLSQL.test that allows you to specify + that you want to run the setup and teardown procedures before and after + EACH unit test procedure, as opposed to running them once for the unit + test package as a whole. To utilize this feature, simply pass a value + of TRUE to the new per_method_setup_in parameter of utPLSQL.test as + shown below: +
  • +
+ +
+SQL> exec utplsql.test ('str', per_method_setup_in => true)
+
+ +

utPLSQL version 2.0.7

+ +
    +
  • + Revamp utAssert2.define_message implement to simplify creation of new assertion + programs +
  • +
  • + Modify implementation if ieqminus to avoid duplicate column +
  • +
  • + Change naming conventions for utPLSQL2 from prefix to delimiter driven + (utconfig.delimiter):QU##NNN. This affects only those test packages + which use the utPLSQL2.test program to run the tests (ie for version 1 + utPLSQL test packages and utPLSQL.test, you can still use your prefix-based approaches). +
  • +
  • + Add utAssert2.fileExists +
  • +
  • + Compile utAssert2 with AUTHID CURRENT_USER for Oracle8i and above. +
  • +
  • + (2.0.7.2) Fix index creation for ut_assertion table. +
  • +
  • + (2.0.7.2) Fix foreign key definition in ut_argument. +
  • +
  • + (2.0.7.2) Fix foreign key definition in uta_eq. +
  • +
+ +

utPLSQL version 2.0.6

+ +
    +
  • + Fix to utgen.pkb to allow generation of procedure bodies when no grid is used. +
  • +
  • + Allow developers to turn off display of successful results (utResult.include_successes) +
  • +
+ +

utPLSQL version 2.0.5

+ +
    +
  • + Allow user to specify individual program or programs (via wildcard) to be tested + from a whole package. +
  • +
  • + Add ut_deterministic and ut_deterministic_arg tables to facilitate generate of + test packages for deterministic functions. +
  • +
  • + Add ut_deterministic.fmx Oracle Forms GUI to allow easy generation of test packages + for deterministic functions. +
  • +
+ +

utPLSQL version 2.0.4

+ +
    +
  • + Implement test suite execution in utPLSQL2. +
  • +
  • + Implement ut_suite_utp table (and the corresponding utsuiteutp package) as an intersection + of ut_suite and ut_utp, defining all those UTPs in a given suite. +
  • +
  • + Improved error handling with utrerror assertions and general reporting mechanisms. + Assertion and error handling logic applied to define-time packages like utsuite + and utsuiteutp. +
  • +
  • + Revamp installation process; no longer use OraShare, remove testcase2 entirely. +
  • +
  • + Create stand alone utverify procedure. +
  • +
+ +

utPLSQL version 2.0.3

+ +
    +
  • + Add utr_error table and utrerror package; now all errors are logged to the table + for viewing afterwards. utPLSQL NEVER passes back an unhandled exception + to the console. +
  • +
  • + utAssert.eqfile now flags problems when opening files. +
  • +
+ +

utPLSQL version 2.0.2

+ +
    +
  • + Clarify how that null_ok_in is supposed to work. For utAssert.this, it should + mean that if the value of the Boolean expression coming in is null, then + that means "success". For eq, it shoudl mean that if BOTH values coming in + are NULL, that is "success". For eqfile, if both files are empty...etc. +
  • +
  • + Add null_ok_in to eqqueryvalue assertions. +
  • +
  • + Add utassert.eqqueryvalue for NUMBER +
  • +
  • + Enhance utgen to properly generate code for overloaded programs in packages +
  • +
+ +

utPLSQL version 2.0.1

+ +
    +
  • + Store results in utr_outcome tables +
  • +
  • + Support results reporting compatibility with V1 +
  • +
  • + Display results of all test, success and failure. +
  • +
+ +

utPLSQL version 1.5.6

+ +
    +
  • + New version of documentation courtesy of Chris Rimmer. Thanks, Chris! +
  • +
  • + utAssert fix in eqcoll to check for both values being null. +
  • +
  • + Enhancements to utGen to generate more self-explanatory code; comments + are now inserted to show the different sections in a standard test case + sequence. +
  • +
  • + Revamped installation procedure based on OraShare utility. +
  • +
  • + Add utGen.testpkg overloadings and new programs to support passing of + argument grids via collection, file or string (this feature is currently + undocumented outside of the release notes). +
  • +
+ +

utPLSQL version 1.5.5

+ +

Bug Fixes

+ +
    +
  • + Change calls from DBMS_OUTPUT.PUT_LINE to utPLSQL.pl to avoid output + errors. +
  • +
  • + Avoid use of DBMS_SQL to obtain sequence values for Oracle7 and Oracle8 + installations of utPLSQL. +
  • +
+ +

Enhancements

+ +
    +
  • + Addition of utConfig package (created and integrated by Chris Rimmer) + to isolate all tester configuration information. +
  • +
+ +

utPLSQL version 1.5.4

+ +

Bug Fixes

+ +
    +
  • + utPLSQL.setconfig now sets the user information properly when + the package is first initialized (bug introduced in 1.5.3). +
  • +
+ +

utPLSQL version 1.5.3

+ +

Documentation and Usage Changes

+ +
    +
  • + If you choose to manually register your tests with calls to utPLSQL.addtest + in your setup procedure, you must now INCLUDE the unit test prefix, + as in: + + + +
    +utPLSQL.addtest ('ut_betwnstr');
    +
    + + utPLSQL + will no longer add the prefix for you. This means that you may need to change + your calls to addtest -- or remove them entirely and rely on auto-registration. +
  • +
+ +

Bug Fixes

+ +
    +
  • + Auto-registration (using the ALL_ARGUMENTS data dictionary view) now + correctly ignores the setup and teardown procedures. +
  • +
+ +

Enhancements

+ +
    +
  • + If no tests are run for the specified program, then a warning is displayed, + after which the SUCCESS message is displayed. +
  • +
+ +

utPLSQL version 1.5.2

+ +

Bug Fixes

+ +
    +
  • + Fix setting of default prefix value in utPLSQL.pkb. +
  • + +
  • + If you request execution of a test suite that does not exist, that failure + will be reported. +
  • +
  • + If you request execution of a test for a program or package that does + not exist, that failure will be reported. +
  • +
  • + Unique index on ut_package changed to allow multiple entries for same + package, in different suites. +
  • +
+ +

Known Problems

+ +
    +
  • + When running a suite of test packages, the SUCCESS and FAILURE headers + will display for each package, and not for the overall suite. +
  • +
+ +

Enhancements

+ +
    +
  • + The utAssert package now offers isnull and isnotnull assertions overloaded + for Boolean values. +
  • +
+ +

utPLSQL version 1.5.1

+ +

Support for Oracle7.3, Oracle8 and Oracle8i

+ +

+ utPLSQL can now be used on any version of Oracle from 7.3.4 and above! The + installation script automatically detects your Oracle RDBMS version and adjusts + the code accordingly (Using a great SQL*Plus trick, courtesy of Vladimir + Trusevich; check out the references to &start81 and &start73 in the + source code, as well as the queries in code.sql, to get a sense of how we + can maintain a single base of code for all these versions!). +

+ +

There are some differences in how the code works:

+ +
    +
  • + In Oracle8i, the autonomous transaction feature is used to immediately + COMMIT any changes to underlying utPLSQL tables (such as defining a + test suite). In earlier versions, no COMMITs are performed by utPLSQL. +
  • +
+ +

+ In Oracle8i, the Invoker Rights model is used to allow all of utPLSQL code + to run under the authority of the invoker, not the owner/definer. In earlier + versions, the Definer Rights model is followed. So if you define utPLSQL + in a central schema and then share it with others via GRANTs and synonyms, + you may need to grant additional authority to the utPLSQL schema. +

+ + +

Stores Additional Configuration Information

+ +

+ When you set the directory for your test code (through a call to + utPLSQL.setdir + , utPLSQL.test or utPLSQL.testsuite), that value is stored in the uPLSQL + configuration table (ut_config). It will be used for current and future sessions + as the default, until you change it. +

+ +

+ The prefix you specify in calls to utPLSQL.setprefix + , utPLSQL.test or utPLSQL.testsuite will also be saved in the uPLSQL configuration + table. It will be used for current and future sessions as the default, until + you change it. +

+ +

Shows All Configuration Information

+ +

+ Call the utPLSQL.showconfig + procedure to display all of the stored configuration values for the specified + schema. +

+ +

utPLSQL version 1.4.1

+ +

Automatic Test Registration

+ +

+ You no longer have to manually register + your unit test procedures + in the setup procedure. Instead, utPLSQL will (in default mode) read and + execute the list of public procedures and functions from the ALL_ARGUMENTS + data dictionary view that conform to utPLSQL naming conventions. This enhancement + makes utPLSQL much easier and simpler to use than before. Simply use the + designated prefix (default being "ut_") on your program names, and they will + be executed. +

+ +

Improved error handling and reporting

+ +

Rather than display a small, easily missed test result, as in :

+ +
+SUCCESS: PLVstr
+
+ +

+ utPLSQL now displays a much more noticeable (though still lacking in + colors, as in red for failure and green for success) display of the "big + picture", as in: +

+ +
+SQL> exec utplsql.test ('str', dir_in=>'e:\openoracle\utplsql\utinstall\examples')
+.
+>    SSSS   U     U   CCC     CCC   EEEEEEE   SSSS     SSSS
+>   S    S  U     U  C   C   C   C  E        S    S   S    S
+>  S        U     U C     C C     C E       S        S
+>   S       U     U C       C       E        S        S
+>    SSSS   U     U C       C       EEEE      SSSS     SSSS
+>        S  U     U C       C       E             S        S
+>         S U     U C     C C     C E              S        S
+>   S    S   U   U   C   C   C   C  E        S    S   S    S
+>    SSSS     UUU     CCC     CCC   EEEEEEE   SSSS     SSSS
+.
+ SUCCESS: "str"
+
+ +

utPLSQL version 1.3.2

+ +

Improved Statistics Recording

+ +

+ utPLSQL will now record the status of the last test run in the ut_package + and ut_suite tables. It also correctly updates those tables with a count + of executions and failures. Finally, it is no longer necessary to define + your package in and run it from a test suite for results to be recorded. +

+ +

New Assertions and Assertion Features

+ +

+ utAssert now offers assertion routines that allow you to easily validate + the contents of PL/SQL collections (index-by tables, nested tables and varying + arrays) by running either the utassert.eqcoll + or utassert.ecollAPI + assertions. +

+ +

+ You can also now request that utAssert show the + results of a test immediately + after execution. This allows you to build small test scripts without have + to create a test package and run it through the utPLSQL test engine. +

+ +

Bug Fixes

+ +

+ Generally, error handling is now improved, particularly for compile errors + on test packages and modifications to underlying tables, such as ut_package. +

+ +

+ When a test has been completed, utPLSQL clears out the results information. +

+ + + + diff --git a/documentation/src/reporter.html b/documentation/src/reporter.html new file mode 100644 index 000000000..9f204e133 --- /dev/null +++ b/documentation/src/reporter.html @@ -0,0 +1,242 @@ + + + + + + + + + +

Custom Reporter Packages

+

+ Generally, the default output provided by utPLSQL is sufficient. This + just writes to the screen using DBMS_OUTPUT. If you are running it + interactively while doing some development, you just need to know if the + tests are passing and details of the failing tests. However, there are + cases where you'd like the results to be reported in a different format, + especially when the tests are being run in batch mode. To support this, + utPLSQL has the concept of Reporter Packages. utPLSQL is distributed with + the following reporter packages as standard: +

+ + + +

+ The naming convention is that reporter packages are called + UT<NAME>REPORTER. To set which reporter is used, you will + need to call utConfig.Setreporter, passing the name of the reporter. + To use the HTML reporter for example, you should issue the following command: +

+ +
+BEGIN
+   utConfig.setreporter('HTML');
+END; 
+
+ +

+ For more details of how to develop your own custom + reporter package, see below. +

+ +

Output Reporter

+ +

+ Contained in the UTOUTPUTREPORTER package, this simply encapsulates the + standard behaviour, whereby the output is written out to DBMS_OUTPUT. When a + problem occurs with another reporter, utPLSQL will automatically fall back on + this mechanism to report problems. This means it is wise to have DBMS_OUTPUT + enabled even if you are using another output method. +

+ +

File Reporter

+ +

+ This reporter, contained in the UTFILEREPORTER package, writes test results + out to a file. For details on how to configure this process, see the details + which can be found here. This functionality was + available before version 2.2 of utPLSQL, but has now been moved into its own + package. +

+ +

HTML Reporter

+ +

+ The package UTHTMLREPORTER is really just an example package to be used as + a basis for your own custom reporters. It builds on the filereporter described above to + send results to a file. The difference is that the results are presented in a (rather crude) + HTML table. +

+ +

Writing your own Reporter

+ +

+ To define your own reporter package you need it conform to a particular API. The various + procedures are then registered as 'callbacks' for utPLSQL to use. + An example package spec is given below. +

+ +
+CREATE OR REPLACE PACKAGE utMyRssReporter
+IS
+
+   PROCEDURE open;
+   PROCEDURE pl (str IN VARCHAR2);
+   
+   PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE);
+   PROCEDURE show_failure;
+   PROCEDURE show_result;
+   PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE);
+   
+   PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE);
+   PROCEDURE show_error;
+   PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE);   
+   
+   PROCEDURE close;
+   
+   PROCEDURE before_suite_results(suite_id IN ut_suite.id%TYPE);
+
+END utMyRssReporter;
+/
+
+ +

+ Your reporter package can define other functions and procedures, for + example to allow configuration, but all the procedures shown above should + be defined. The usage of these procedures follows. Note If you + want to keep the format of the output the same as for the Output Reporter, + but wish to send it elsewhere, you can define open, close and pl, but + simply call the equivalent procedure in utOutputReporter for the others. + For an example of this, see the File Reporter. +

+ +

open

+ +

+ This is called at the very start of the process and is the ideal place to + do initialization, such as opening any files that you will be writing to. +

+ +

pl

+

+ This is a general routine to simply write out the given string for purposes of logging etc. + If you don't want this to show up in your output, you can simply call utoutputreporter.pl to send this to DBMS_OUTPUT instead. +

+ +

before_results

+ +

+ As the name suggests, this is called before the results are output. Note that the tests have already completed at this point, + so it is possible to call utresult.success (run_id) to determine if the run was a success or not and display a large banner. +

+ +

show_failure

+ +

+ This is called when a failure is reported and we are only showing failures (i.e. utconfig.showfailuresonly has been set). + To get details of the failure, you will need to examine the package level record utreport.outcome. +

+ +

show_result

+ +

+ This is called whenever a result is reported and we are showing all + results. To get details, you will need to examine + utreport.outcome. See below for details. +

+ +

after_results

+

This is called after all the results have been sent for output.

+ +

before_errors

+

This is called before any errors are sent for output.

+ +

show_error

+

+ This is called for each error to output. To get details, you will need + to examine the package level record utreport.error. + See below for details. +

+ +

after_errors

+

This is called after any errors have been sent for output.

+ +

before_suite_results

+

+ This is called only when a suite is executed. It displays the overall + banner and suite execution statistics. +

+ +

Outcome and Error records

+

+ In order to keep the API as simple as possible, many of the procedures defined above take no parameters. In particular, details of the outcome or error which + triggered the callback are not passed through to your procedure. These are stored as package level records in the utReport package as shown below. +

+ +
+outcome utr_outcome%ROWTYPE;
+error utr_error%ROWTYPE;
+
+ +

The important fields in the outcome record are:

+ +
    +
  • status - This is a string which is either "SUCCESS" or "FAILURE" depending on the outcome of this test.
  • +
  • description - The text describing the success or failure.
  • +
+ +

The important fields in the error record are:

+ +
    +
  • errlevel - The Error Level
  • +
  • errcode - The Error Code
  • +
  • errtext - The Description of the error that occurred
  • +
+ +

Using Your Custom Reporter

+

+ To use your custom reporter, you simply call utConfig.Setreporter with the name of your reporter. So if + you have defined your reporter in the utMyRssReporter package, you need to call: +

+ +
+BEGIN
+   utConfig.setreporter('MyRss');
+END; 
+
+ +

+ Then you just run your tests as usual and hopefully your reporter will + format the results as you expect. +

+ +

Sending output to the current reporter

+

+ If you wish to send output to the current reporter, for example, for logging purposes, you should call utReport.pl. + This is part of the utReport package, which acts as a facade and passes any calls through to the current reporter package. + So if you have set up a custom reporter package 'utMyRssReporter' as shown above and called utConfig.setreporter('MyRss'), + any calls such as the following: +

+ +
+BEGIN
+  utReport.pl('Logging Message');
+END;
+
+ +

will be equivalent to

+ +
+BEGIN
+  utMyRssReporter.pl('Logging Message');
+END;
+
+ + + + diff --git a/documentation/src/samepack.html b/documentation/src/samepack.html new file mode 100644 index 000000000..e3a6a04fb --- /dev/null +++ b/documentation/src/samepack.html @@ -0,0 +1,203 @@ + + + + + + + + + +

Put Test Code in Same Package

+ +

+ In some cases (usually when your packages are small and the code you + need to write to construct your tests is also constrained), you will not + want to bother with creating a separate package to test your code. To do + this, you will put the setup, teardown and unit test procedures inside + the package specification and body. We look at two examples: +

+ + + +

Testing a simple string function

+

+ Suppose I have my basic sting package, containing (for now at least) just + a single function: +

+ +
+/*file str.pks */
+CREATE OR REPLACE PACKAGE str
+IS
+   FUNCTION betwn (
+      string_in IN VARCHAR2,
+      start_in IN PLS_INTEGER,
+      end_in IN PLS_INTEGER
+   )
+      RETURN VARCHAR2;
+END str;
+/
+
+ +

+ Now it is time to test the function. I really don't want to bother with + a separate package; let's keep it together. To do this, I change the specification + to: +

+ +
+CREATE OR REPLACE PACKAGE str
+IS
+   FUNCTION betwn (
+      string_in IN VARCHAR2,
+      start_in IN PLS_INTEGER,
+      end_in IN PLS_INTEGER
+   )
+      RETURN VARCHAR2;
+      
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+ 
+   -- For each program to test...
+   PROCEDURE ut_betwn;
+      
+END str;
+/
+
+ +

+ The package body contains nothing unusual; it is the same test for str.betwn + that you can find in the Testing + a Scalar Function example. But when I execute my test, I need to tell + utPLSQL that my test code is located in the same package: +

+ +
+SQL> exec utconfig.showconfig
+=============================================================
+utPLSQL Configuration for SCOTT
+   Directory: e:\openoracle\utplsql\utinstall\examples
+   Autcompile? Y
+   Manual test registration? N
+   Prefix = ut_
+=============================================================
+
+PL/SQL procedure successfully completed.
+
+SQL> exec utPLSQL.test ('str', samepackage_in => TRUE)
+.
+>    SSSS   U     U   CCC     CCC   EEEEEEE   SSSS     SSSS
+>   S    S  U     U  C   C   C   C  E        S    S   S    S
+>  S        U     U C     C C     C E       S        S
+>   S       U     U C       C       E        S        S
+>    SSSS   U     U C       C       EEEE      SSSS     SSSS
+>        S  U     U C       C       E             S        S
+>         S U     U C     C C     C E              S        S
+>   S    S   U   U   C   C   C   C  E        S    S   S    S
+>    SSSS     UUU     CCC     CCC   EEEEEEE   SSSS     SSSS
+.
+ SUCCESS: "str"
+ 
+ +

Testing the population of a collection

+

+ Collections are very useful structures, but they can be difficult to analyze + and compare. utPLSQL provides the utAssert.eqColl and utAssert.eqCollAPI + programs to help you do this. +

+

+ For this example, consider the fileIO package: it implements a path + feature for the UTL_FILE package. In other words, you request to open a + file and your file-opening program will search through each of the directories + in the path in sequence until it finds the file or exhausts the list. Here + is the specification of this package: +

+
+/*file filepath1.pkg */
+CREATE OR REPLACE PACKAGE fileIO
+IS
+   c_delim CHAR(1) := ';';
+   
+   dirs dirs_tabtype := dirs_tabtype ();
+   
+   -- Unit test list
+   ut_dirs dirs_tabtype := dirs_tabtype ();
+   
+   PROCEDURE setpath (str IN VARCHAR2, delim IN VARCHAR2 := c_delim);
+   FUNCTION path RETURN VARCHAR2;
+   FUNCTION pathlist RETURN dirs_tabtype;
+
+   FUNCTION open (file IN VARCHAR2, loc IN VARCHAR2 := NULL) RETURN UTL_FILE.FILE_TYPE;
+   
+   -- Unit test code in same package
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+   PROCEDURE ut_setpath;
+END;
+/
+
+ +

A few things to notice about this package:

+
    +
  • + It declares a publicly available collection, fileIO.dirs, in which the + path is deposited. Because it is declared in the package specification, + I can use the utAssert.eqColl procedure (if the collection was hidden in + the package body, I would have to use utAssert.eqCollAPI). +
  • +
  • + The test code is in the same package: the setup, + teardown and test pogram for fileIO.setpath. +
  • +
  • + I declare a second, publicly available collection, + fileIO.ut_dirs, against which I will compare the path that is populated + by fileIO.setpath. +
  • +
+ +

Given that, let's take a look at the implementation of the test program:

+ +
+PROCEDURE ut_setpath
+IS
+BEGIN
+   /* Populate base collection */
+   ut_dirs.DELETE;
+   
+   ut_dirs.EXTEND(2);
+   ut_dirs(1) := 'c:\temp';
+   ut_dirs(2) := 'e:\demo';
+   
+   /* Call setpath to do the work */
+   setpath ('c:\temp;e:\demo');
+   
+   utAssert.eqColl (
+      'Valid double entry',
+      'fileio.dirs',
+      'fileio.ut_dirs'
+      );
+END;
+
+ +

This program consists of three steps:

+ +
+
    +
  • + Populate the test collection with direct assignments. Call the setPath + program to populate the actual collection (fileIO.dirs). Call the assertion + program to compare the two. Notice that I pass the names of the + collections to the assertion program. utAssert uses dynamic SQL to build + a PL/SQL block "on the fly" that compares values from the collections. +
  • +
+
+ + + + diff --git a/documentation/src/started.html b/documentation/src/started.html new file mode 100644 index 000000000..b431d4540 --- /dev/null +++ b/documentation/src/started.html @@ -0,0 +1,62 @@ + + + + + + + + + +

Getting Started

+ +

+ This document gives you all the information you need to get started + with utPLSQL: how to install the product, build a test package and run + your test. If you are new to unit testing, you should take a few moments + to review the Glossary to familiarize yourself with the terminology. +

+ +

+ And it is always worthwhile reviewing requirements before installing + the software! +

+ +

What is utPLSQL and what do I need?

+ +
+

Glossary

+ +

Requirements

+
+ +

The Four Step Program to Using utPLSQL

+ +
+

Step 1. Install utPLSQL.

+ +

Step 2. Choose a program to test and identify the test cases.

+ +

Step 3. Build a test package.

+ +

Step 4. Run your test.

+ +

+ + Where To Go From Here +

+
+ +

Administrative Topics

+ +
+

Configuring UTL_FILE

+ +

Join the Project Team

+ +

Reporting Bugs and Enhancement Requests

+ +
+ + + diff --git a/documentation/src/suite.html b/documentation/src/suite.html new file mode 100644 index 000000000..035aed229 --- /dev/null +++ b/documentation/src/suite.html @@ -0,0 +1,75 @@ + + + + + + + + + +

Create and Run a Test Suite

+ +

+ Usually our applications are composed of multiple packages. To test + our application, we must test all of the packages. utPLSQL makes it easier + for you to do that by offering test suites. +

+

+ Here is an example of a script that defines a (partial) test suite for + PL/Vision, a code library available from RevealNet + as part of its Active PL/SQL Knowledge Base: +

+ +
+/*file plvision.tst */
+BEGIN
+   -- Define a test suite for PL/Vision
+   utsuite.add ('PLVision');
+   
+   -- Add packages for testing
+   utpackage.add (
+      'PLVision', 'PLVstr', dir_in => 'e:\openoracle\utplsql\examples');
+   utpackage.add (
+      'PLVision', 'PLVdate', dir_in => 'e:\openoracle\utplsql\examples');
+END;   
+/
+
+ +

+ This is a very simple test suite definition. I rely on all defaults, but + I specify a location for my test package code. By doing this, utPLSQL will + be able to find my test packages even if the default/current utPLSQL directory + is set to another location. +

+

+ If I want to, I can also specify the order in which packages are tested + by passing a value for the seq_in argument. I can request that the test + code be looked for in the same package as the source code, and so on. Here + is a rewriting of the above sutie creation script that demonstrates these + options: +

+ +
+BEGIN
+   utsuite.add ('PLVision');
+
+   utpackage.add ('PLVision',
+      'PLVstr',
+      dir_in => 'e:\openoracle\utplsql\examples',
+      seq_in => 1,
+      samepackage_in => TRUE
+   );
+
+   utpackage.add ('PLVision',
+      'PLVdate',
+      dir_in => 'e:\openoracle\utplsql\examples',
+      seq_in => 2,
+      samepackage_in => TRUE
+   );
+END;
+/
+ + + + diff --git a/documentation/src/template.html b/documentation/src/template.html new file mode 100644 index 000000000..b07d2978b --- /dev/null +++ b/documentation/src/template.html @@ -0,0 +1,35 @@ + + + + + + + + + +

Heading

+ +

Subheading 1

+

+ Some body text here... +

+
+BEGIN
+  Some.Example(Code);
+END;
+
+ +

Subheading 2

+

+ Some more body text here... +

+
    +
  • Point 1
  • +
  • Point 2
  • +
  • Point 3
  • +
+ + + + diff --git a/documentation/src/testapi.html b/documentation/src/testapi.html new file mode 100644 index 000000000..ef2e08c32 --- /dev/null +++ b/documentation/src/testapi.html @@ -0,0 +1,329 @@ + + + + + + + + + +

Test an Entire Package API

+ +

+ Most packages consist of lots more than a single program, and you will + generally want to test each and every of the programs listed in the package + specification. When you generate a test package with utGen, + it will produce a template unit test procedure for each program in the + package specification. You will then need to modify each of these programs. +

+

+ One example of this more complex package structure is the table encapsulation + package. This kind of package establishes a layer of code and therefore + control between application requirements and underlying data structures. + While the building of such a layer is uncommon in the world of PL/SQL developers, + it is strongly recommended practice. A variety of tools, in fact, offer + automated table encapsulation package generation, including Oracle + Designer, RevealNet's PL/Generator + and a variety of IDE (integrated development environment) tools. +

+

+ Suppose, then, that I used PL/Generator to generate a table encapsulation + package for the employee table. It would look like the code found in te_employee.pks + and te_employee.pkb(1) (being rather + lengthy, we will not reproduce it in the documentation. If you take a look, + you will see that their are dozens of programs in the API, which means + that you would have lots of work to do in building your unit test cases. + In addition, many of the programs will be performing DML operations (updating, + deleting, inserting). How you can easily and dependably test those programs? +

+

+ When you are dealing with lots of programs that have a uniform structure + and behavior (which should be the case if you are building table + API packages), then you should look for ways to generate, rather + than write manually, your test package. utGen cannot do this generation + work for you, since the logic in your encapsulation package is specific + to your environment. +

+

+ You can, instead, build your own custom generator or use an existing + generator that is sufficiently flexible to meet your needs. The original + creator of utPLSQL, Steven Feuerstein, + has also been working on generator utilities for a number of years. One + of these utilities, currently "code named" GenX, came in very handy for + creating a test package for his PL/Generator-generated encapsulation packages. +

+

+ Using CGML (Code Generation Markup Language), Steven created a template + (See te_utpkg.gdr in the Examples directory of the utPLSQL distribution) + that reads information from the data dictionary and defines the setup, + teardown and at least a good starting point for the unit test procedures. + Here is the template logic for the setup procedure: +

+
+   PROCEDURE {utprefix}setup
+   IS
+   BEGIN
+      -- Clean start
+      {utprefix}teardown;
+[ASIS]   
+      -- Generic copy of base table for testing 
+      EXECUTE IMMEDIATE 
+         'CREATE TABLE {tabprefix}[objname] AS
+            SELECT * FROM [objname]';
+            
+[ENDASIS]   
+   [FOREACH]prog
+   [IF]{allprogs}[EQ]Y[OR][progname][LIKE]UPD%[OR][progname][LIKE]INS%[OR][progname][LIKE]DEL%
+      -- Create copy of base table for this unit test.
+      EXECUTE IMMEDIATE 
+         'CREATE TABLE ^{progtab}^ AS
+[ASIS]   
+            SELECT * FROM [objname]';
+[ENDASIS]   
+            
+   [ENDIF]
+   [ENDFOREACH]
+   END;
+
+ +

+ You are not, of course, expected to understand all the logic and syntax + in this fragment. If you are interested in pursuing these sorts of genreation + opportunities and would like to check out GenX, drop a note to Steven + Feuerstein. +

+

+ Here is a portion of the generated logic (found in ut_te_employee.pks + and ut_te_employee.pkb"(1)), the + program that tests the delete operation in the encapsulation package: +

+ +
+   PROCEDURE ut_del1
+   IS
+      fdbk PLS_INTEGER;
+   BEGIN
+      /* Delete that finds now rows. */
+
+      EXECUTE IMMEDIATE '
+      DELETE FROM ut_DEL1
+       WHERE employee_id = -1
+      ';
+      te_employee.del (-1, rowcount_out => fdbk);
+      -- Test results
+      utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1');
+      /* Successful delete */
+
+      EXECUTE IMMEDIATE '
+      DELETE FROM ut_DEL1
+       WHERE employee_id between 7800 and 7899
+      ';
+
+      FOR rec IN (SELECT *
+                    FROM employee
+                   WHERE employee_id BETWEEN 7800 AND 7899)
+      LOOP
+         te_employee.del (
+            rec.employee_id,
+            rowcount_out => fdbk
+         );
+      END LOOP;
+
+      -- Test results
+      utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1');
+      ROLLBACK;
+   EXCEPTION
+      WHEN OTHERS
+      THEN
+         utassert.this (
+            'DEL1 exception ' || SQLERRM,
+            SQLCODE = 0
+         );
+   END;
+
+ +

+ In this procedure, I test for two scenarios: a delete that removes zero + rows and a delete that removes a specific set of rows. In both cases, I + perform the explicit (non-encapsulated) DML logic against a copy + of the actual table (this copy is created in the setup + procedure; that is the reason I use dynamic SQL to refer to this table + -- it doesn't exist when the package is compiled!). Then I do the (hopefully) + same operation by using the API program. Finally, I call the appropriate + utAssert assertion program to compare the results -- and at the end of + the procedure issue a ROLLBACK so that my "source" table (employee, in + this case), i set back to the original data state. Notice that I also put + an assertion program in the exception section to trap any errors and flag + it as a failed test. +

+

+ That should give you a good feel for the kind of code you might write + to test a table encapsulation package. The next two sections show you how + I used the setup and teardown procedures to manage the data structures + I use in my tests. +

+ +

Set Up Data Structures

+ +

+ As I contemplated how best to test these large packages, I revisited some + of my testing principles and found one to be of particular importance: +

+ +

Build isolated tests.

+ +

+ This principle is important because it allows you to run one, all or + a subset of your tests without having to worry about the impact or dependencies + on the other tests. And test isolation is particularly important + when testing DML operations. The way to validate a successful DML operation + is by analyzing the contents of the "source" table against a "test" table. + If all the tests modify the same test table, ti will be very difficult + if not impossible to verify success or notice failure. +

+

+ So I decided that the best way to run my unit tests for DML operations + was to create a separate test table for each unit test. As a consequence, + my setup procedure for the te_employee package looks like this: + (See ut_te_employee.pkb in the Examples directory of the utPLSQL distribution) +

+ +
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      ut_teardown;
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_employee AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_DEL1 AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_DEPT_LOOKUP AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_JOB_LOOKUP AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_MGR_LOOKUP AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_INS1 AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_UPD1 AS
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_UPD$HIRE_DATE1 AS   
+            SELECT * FROM employee';
+      EXECUTE IMMEDIATE 'CREATE TABLE ut_UPD$SALARY1 AS
+            SELECT * FROM employee';
+   END;
+
+ +

+ I first remove all my data structures using the teardown procedure to make + sure I have a clean start. Then I use dynamic SQL (the Oracle8i version) + to create all my tables. I must rely on dynamic SQL because PL/SQL does + not yet support native DDL statements, such as CREATE TABLE. +

+

+ Then I am set to test. +

+ +

Tear Down Data Structures

+ +

+ Well, if I am going to create a whole bunch of data structures to run my + tests, I had better get rid of those structures when I am done. Here is + the teardown program I generated for the te_employee package: +

+ +
+   PROCEDURE ut_teardown
+   IS
+   BEGIN
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_employee';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_DEL1';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_DELBY_EMP_DEPT_LOOKUP';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_DELBY_EMP_JOB_LOOKUP';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_DELBY_EMP_MGR_LOOKUP';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_INS1';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_UPD1';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_UPD$HIRE_DATE1';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+      BEGIN
+         EXECUTE IMMEDIATE 'DROP TABLE ut_UPD$SALARY1';
+      EXCEPTION
+         WHEN OTHERS
+         THEN
+            NULL;
+      END;
+
+   END;
+
+ +

+ Again, I use dynamic SQL, but enclose each DROP TABLE statement inside + its own exception section so that if for any reason the DROP fails, I continue + on in an attempt to get as much done as possible. +

+ +
+ +

Footnotes

+

+ 1. These files are in the Examples directory of the utPLSQL distribution. +

+ + + diff --git a/documentation/src/testfunc.html b/documentation/src/testfunc.html new file mode 100644 index 000000000..8a6fc6176 --- /dev/null +++ b/documentation/src/testfunc.html @@ -0,0 +1,116 @@ + + + + + + + + + +

Test a Function

+ +

+ As with the procedure, there are a couple of scenarios to consider: +

+ +
    +
  • + The function returns a scalar value (number, + date, string, Boolean). In this case, you can embed your call to the function + directly inside a call to a uAssert assertion program, making your test + procedure very concise and easy to write. +
  • +
  • + The function returns a non-scalar value, + such as an object or a collection. In this case, you will need to call + the function and then evaluate the contents of the returned structure. +
  • +
  • + A third situation to consider is that your function returns a value, but + it also takes a number of other actions, the success of which is not reflected + in the returned value. Fully testing such a function (one with "side effects") + can be very difficult, since you must test for a variety of conditions. +
  • +
+ +

Testing a Scalar Function

+ +

+ First, a test of a function returning a scalar value. Consider the following + packaged function: +

+ +
+/*file str.pks and str.pkb */
+CREATE OR REPLACE PACKAGE str
+IS
+   FUNCTION betwn (
+      string_in IN VARCHAR2,
+      start_in IN PLS_INTEGER,
+      end_in IN PLS_INTEGER
+   )
+      RETURN VARCHAR2;
+END str;
+/
+
+ +

+ The str.betwn function returns the sub-string of a string_in that is found + between the start and end locations specified by start_in and end_in. +

+ +

+ So...time to test! I generate a test package + and then modify the unit test procedure to check for various conditions: +

+ +
+/*file ut_str.pkb */
+CREATE OR REPLACE PACKAGE BODY ut_str
+IS
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      NULL;
+   END;
+   
+   PROCEDURE ut_teardown
+   IS
+   BEGIN
+      NULL;
+   END;
+
+   -- For each program to test...
+   PROCEDURE ut_betwn IS
+   BEGIN
+      utAssert.eq (
+         'Typical Valid Usage',
+         str.betwn ('this is a string', 3, 7),
+         'is is' 
+         );
+         
+      utAssert.eq (
+         'Test Negative Start',
+         str.betwn ('this is a string', -3, 7),
+         'ing'
+         );
+         
+      utAssert.isNULL (
+         'Start bigger than end',
+         str.betwn ('this is a string', 3, 1)
+         );
+   END ut_betwn;
+
+END ut_str;
+/
+
+ +

+ As you can see, my calls to str.betwn are embedded right within calls to + utAssert.eq and utAssert.isNULL, making my test code compact. +

+ + + + diff --git a/documentation/src/testproc.html b/documentation/src/testproc.html new file mode 100644 index 000000000..a00b1f523 --- /dev/null +++ b/documentation/src/testproc.html @@ -0,0 +1,299 @@ + + + + + + + + + +

Test a Procedure

+ +

There are a couple of scenarios to consider:

+ +
    +
  • + The procedure runs some code and then passes back results through the parameter + list. In this case, I can write a unit test that analyzes the OUT and IN + OUT argument values. +
  • +
  • + The procedure runs some code, which changes + other elements of the application (such as a database table or a file). + The parameter list does not contain arguments that can be analyzed for + successful execution. So to assert success, I will need to analyze/compare + the data structures that have been modified. +
  • +
+ +

Test Success Through Parameters

+ +

+ We'll start with a really simple example. I + have built a procedure that accepts two dates and returns the number of + seconds between them. Here it is: +

+ +
+/*file calc_secs_between.sp */
+CREATE OR REPLACE PROCEDURE calc_secs_between (
+   date1 IN DATE,
+   date2 IN DATE,
+   secs OUT NUMBER)
+IS
+BEGIN
+   -- 24 hours in a day, 
+   -- 60 minutes in an hour,
+   -- 60 seconds in a minute...
+   secs := (date2 - date1) * 24 * 60 * 60;
+END;
+/
+
+ +

+ After compiling my code cleanly, I generate + my test package: +

+ +
+SQL> SET SERVEROUTPUT ON FORMAT WRAPPED
+SQL> exec utGen.testpkg ('calc_secs_between ')
+CREATE OR REPLACE PACKAGE ut_calc_secs_between
+IS
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+
+   -- For each program to test...
+   PROCEDURE ut_CALC_SECS_BETWEEN;
+END ut_calc_secs_between;
+/
+CREATE OR REPLACE PACKAGE BODY ut_calc_secs_between
+IS
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      NULL;
+   END;
+
+   PROCEDURE ut_teardown
+   IS
+   BEGIN
+      NULL;
+   END;
+
+   -- For each program to test...
+   PROCEDURE ut_CALC_SECS_BETWEEN IS
+   BEGIN
+      CALC_SECS_BETWEEN (
+            DATE1 => ''
+            ,
+            DATE2 => ''
+            ,
+            SECS => ''
+       );
+
+      utAssert.this (
+         'Test of CALC_SECS_BETWEEN',
+         '<boolean expression>'
+         );
+   END ut_CALC_SECS_BETWEEN;
+
+END ut_calc_secs_between;
+/
+
+ +

+ I generated the output to the screen, but it + is actually easier to deposit the code directly into two separate files + for package spec and body, ut_calc_secs_between.pks and ut_calc_secs_between.pkb, + which I do as follows: +

+ +
+SQL> exec utGen.testpkg ('calc_secs_between ', output_type_in => utGen.c_file)
+
+ +

+ By conforming to this standard, utPLSQL can + automatically compile this code before each test. I now edit the ut_calc_secs_between + procedure to test for various cases: +

+ +
+PROCEDURE ut_CALC_SECS_BETWEEN 
+IS
+   secs PLS_INTEGER;
+BEGIN
+   CALC_SECS_BETWEEN (
+         DATE1 => SYSDATE
+         ,
+         DATE2 => SYSDATE
+         ,
+         SECS => secs
+    );
+
+   utAssert.eq (
+      'Same dates',
+      secs, 
+      0
+      );
+      
+   CALC_SECS_BETWEEN (
+         DATE1 => SYSDATE
+         ,
+         DATE2 => SYSDATE+1
+         ,
+         SECS => secs
+    );
+
+   utAssert.eq (
+      'Exactly one day',
+      secs, 
+      24 * 60 * 60
+      );
+      
+END ut_CALC_SECS_BETWEEN;
+
+ +

and now I can run my test:

+ +
+SQL> exec utplsql.test ('calc_secs_between')
+.
+>    SSSS   U     U   CCC     CCC   EEEEEEE   SSSS     SSSS
+>   S    S  U     U  C   C   C   C  E        S    S   S    S
+>  S        U     U C     C C     C E       S        S
+>   S       U     U C       C       E        S        S
+>    SSSS   U     U C       C       EEEE      SSSS     SSSS
+>        S  U     U C       C       E             S        S
+>         S U     U C     C C     C E              S        S
+>   S    S   U   U   C   C   C   C  E        S    S   S    S
+>    SSSS     UUU     CCC     CCC   EEEEEEE   SSSS     SSSS
+.
+ SUCCESS: "calc_secs_between"
+ 
+ +

+ Certainly, there are a variety of other conditions + to test, but this should give you a good idea of how to go about it! +

+ +

Test Success by Analyzing Impact

+ +

+ Now let's consider a more complicated situation. + I have a procedure that truncates all the rows in the specified table. + To do this I just use dynamic SQL, as you can see in: +

+ +
+/*file truncit.sp */
+CREATE OR REPLACE PROCEDURE truncit (
+   tab IN VARCHAR2,
+   sch IN VARCHAR2 := NULL
+)
+IS
+BEGIN
+   EXECUTE IMMEDIATE 'truncate table ' || NVL (sch, USER) || '.' || tab;
+END;
+/
+
+ +

+ After I run this test, I cannot simply check + the value returned by the procedure. Instead, I must check to see how many + rows are left in the table. Fortunately, I have another dynamic SQL utility + to help me out here, one that returns the count of rows in any table: + (Note that you could also use utAssert.eqqueryvalue here.) +

+ +
+/*file tabcount.sf */
+CREATE OR REPLACE FUNCTION tabcount (
+   sch IN VARCHAR2,
+   tab IN VARCHAR2)
+   RETURN INTEGER
+IS
+   retval  INTEGER;
+BEGIN
+   EXECUTE IMMEDIATE 
+      'SELECT COUNT(*) FROM ' || sch || '.' || tab
+      INTO retval; 
+   RETURN retval;
+EXCEPTION
+    WHEN OTHERS 
+    THEN
+       RETURN NULL; 
+END;
+/
+
+ +

+ So I will generate a package + to test truncit and then modify the package body: +

+ +
+SQL> SET SERVEROUTPUT ON FORMAT WRAPPED
+SQL> exec utGen.testpkg ('truncit', output_type_in => utGen.c_file)
+
+ +

+ To run my test, I need to truncate a table. + That is an irreversible action, so I will create a "temporary" table in + the setup procedure and drop it in the teardown procedure. Then I will + run my code and use tabCount to validate the results: +

+ +
+/*file ut_truncit.pkb */
+CREATE OR REPLACE PACKAGE BODY ut_truncit
+IS
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      EXECUTE IMMEDIATE 
+         'CREATE TABLE temp_emp AS SELECT * FROM employee';
+   END;
+   
+   PROCEDURE ut_teardown
+   IS
+   BEGIN
+      EXECUTE IMMEDIATE 
+         'DROP TABLE temp_emp';
+   END;
+
+   -- For each program to test...
+   PROCEDURE ut_TRUNCIT IS
+   BEGIN
+      TRUNCIT (
+            TAB => 'temp_emp'
+            ,
+            SCH => USER
+       );
+
+      utAssert.eq (
+         'Test of TRUNCIT',
+         tabcount (USER, 'temp_emp'),
+         0
+         );
+   END ut_TRUNCIT;
+
+END ut_truncit;
+/
+
+ +

+ Not quite as straightforward as checking values + returned in OUT or IN OUT arguments, but not too awful, right? Of course, + things can get considerably more complicated as your code (and the results + you must test for) grows more complex. Regardless, you will find it easier + to build and run your tests through utPLSQL than through more ad hoc and + considerably less organized approaches. +

+ + + + + diff --git a/documentation/src/testrun.html b/documentation/src/testrun.html new file mode 100644 index 000000000..f51722ff6 --- /dev/null +++ b/documentation/src/testrun.html @@ -0,0 +1,329 @@ + + + + + + + + + +

A "Test Run" with utPLSQL

+ +

+ I will put utPLSQL to work in a small-scale development + effort, to show you how it all hangs together. I've got a "hangnail" in + my PL/SQL development work, called SUBSTR. This function bothers me and + I want to take care of it. What's the problem? SUBSTR is great when you + know the starting location of a string and number of characters you want. In + many situations, though, I have the start and end locations and I need + to figure out the number of characters I then want. Is it: +

+ +
+mystring := SUBSTR (full_string, 5, 17); -- start and end? Nah...
+
+mystring := SUBSTR (full_string, 5, 12); -- end - start?
+
+mystring := SUBSTR (full_string, 5, 13); -- end - start + 1?
+
+mystring := SUBSTR (full_string, 5, 11); -- end - start 1 1?
+
+ +

+ Why should I have to remember stuff like this? I + never do, and so I take out a scrap of paper, write down 'abcdefgh', put + a mark over the "c" and another over the "g", count on my fingers and then + remember that of course the formula is "end - start + 1". +

+ +

+ All right, so I did that a dozen times, I am sick + of it and determined to stop wasting my time in the future. I will write + a function called "str.betwn" (the betwn function defined in the str package) + that does the work and the remembering for me. +

+ +

+ Instead of immediately coding the function, however, + I will first write my unit tests with utPLSQL! Since my source package + is named "str", I will create a test package named "ut_str". I am a lazy + fellow, so I will take the lazy way out and generate the starting point + for my package: +

+ +
+SQL> exec utgen.testpkg ('str', output_type_in => utplsql.c_file)
+
+ +

+ Note: for the above call to work, I must have already + set my default directory for utPLSQL, which I do via a SQL*Plus login script + that looks like this: +

+ +
+exec utplsql.setdir ('e:\utplsql\test')
+
+SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED
+
+ +

+ Otherwise, I would need to specify the directory + in my call to genpkg, as in: +

+ +
+SQL> exec utgen.testpkg ('str', output_type_in => utplsql.c_file, dir_in => 'e:\utplsql\test')
+
+ +

I then will find this package spec in the ut_str.pks file:

+ +
+CREATE OR REPLACE PACKAGE ut_str
+IS
+   PROCEDURE ut_setup;
+   PROCEDURE ut_teardown;
+   
+   -- For each program to test...
+   PROCEDURE ut_betwn;
+END ut_str;
+/
+
+ +

+ And I don't really have to modify the specification + at all. The body will, on the other hand, require some work, since I haven't + yet figured out a way to automatically generate the test code itself. Here + is the purely generated test package body found + in the ut_str.pkb file: +

+ +
+CREATE OR REPLACE PACKAGE BODY ut_str
+IS
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      NULL;
+   END;
+   
+   PROCEDURE ut_teardown
+   IS
+   BEGIN
+      NULL;
+   END;
+   
+   -- For each program to test...
+   PROCEDURE ut_betwn
+   IS
+   BEGIN
+      utAssert.this (
+         'Test of betwn',
+         <boolean expression>,
+      );
+   END;
+   
+END ut_str;
+/
+
+ +

+ The setup and teardown procedures are fine (I don't + have any special setup and therefore teardown requirements), but the ut_betwn + needs lots of work. It doesn't really test anything yet. +

+ +

+ Before I start writing my test code, however, I + will just sit back and think about what I want to test. Here are some inputs + that I can think of: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
StringStartEndExpected Result
"this is a string"3 (positive number)7 (bigger positive number)"is is"
"this is a string"-3 (invalid negative number)7 (bigger positive number)"ing" (consistent with SUBSTR behavior)
"this is a string"3 (positive number)1 (smaller positive number)NULL
+ + +

+ We could easily come up with a whole lot more test + cases - and if this was real life and not product documentation, I would + not move forward until I had identified all interesting tests. So let's + suppose I have done that and now I am ready to do some coding. Since I + am testing a function, I will want to compare the result of the function + call to my expected results. I will therefore change my assertion from + the generic "assert this" procedure to the utAssert.eq program, and put + the call to the function right into the assertion routine. Here, then, + is my first crack at transforming my ut_betwn procedure: +

+ +
+PROCEDURE ut_betwn IS
+BEGIN
+   utAssert.eq (
+      'Test of betwn',
+      str.betwn ('this is a string', 3, 7),
+      'is is'
+   );
+END;
+
+ +

+ Following the Extreme Programming philosophy ("code + a little, test a lot"), I will test this test case before I add all the + other test cases. I do this with a very simple call: +

+ +
+SQL> exec utplsql.test ('str')
+
+>    SSSS   U     U   CCC     CCC   EEEEEEE   SSSS     SSSS
+>   S    S  U     U  C   C   C   C  E        S    S   S    S
+>  S        U     U C     C C     C E       S        S
+>   S       U     U C       C       E        S        S
+>    SSSS   U     U C       C       EEEE      SSSS     SSSS
+>        S  U     U C       C       E             S        S
+>         S U     U C     C C     C E              S        S
+>   S    S   U   U   C   C   C   C  E        S    S   S    S
+>    SSSS     UUU     CCC     CCC   EEEEEEE   SSSS     SSSS
+
+>SUCCESS: "str"
+
+ +

+ Now, you could say: "Great it worked!" Or you could + say: "I have no idea if it worked. Maybe it always says success." + I go for the latter, so let's deliberately cause a failure: +

+ +
+PROCEDURE ut_betwn IS
+BEGIN
+   utAssert.eq (
+      'Test of betwn',
+      str.betwn ('this is a string', 3, 7),
+      'this is a pipe'
+   );
+END;
+
+ +

+ Saving the file (but not bothering to recompile, + since utPLSQL will do it for me automagically), + I then run my test again: +

+ +
+SQL> exec utplsql.test ('str', recompile_in=>false)
+
+>  FFFFFFF   AA     III  L      U     U RRRRR   EEEEEEE
+>  F        A  A     I   L      U     U R    R  E
+>  F       A    A    I   L      U     U R     R E
+>  F      A      A   I   L      U     U R     R E
+>  FFFF   A      A   I   L      U     U RRRRRR  EEEE
+>  F      AAAAAAAA   I   L      U     U R   R   E
+>  F      A      A   I   L      U     U R    R  E
+>  F      A      A   I   L       U   U  R     R E
+>  F      A      A  III  LLLLLLL  UUU   R     R EEEEEEE
+
+FAILURE: "str"
+
+BETWN: Typical Valid Usage; expected "is is", got "this is a pipe"
+
+ +

+ Now I have a higher degree of confidence that I + am getting this right. Excellent! Now I will add the other test cases: +

+ +
+PROCEDURE ut_betwn IS
+BEGIN
+   utAssert.eq (
+      'Typical Valid Usage',
+      str.betwn ('this is a string', 3, 7),
+      'is is'
+   );
+   
+   utAssert.eq (
+      'Test Negative Start',
+      str.betwn ('this is a string', -3, 7),
+      'ing'
+   );
+   
+   utAssert.isNULL (
+      'Start bigger than end',
+      str.betwn ('this is a string', 3, 1)
+   );
+END;
+
+ +

+ I will deliberately cause each of these tests to + fail, to give you a sense of the quality of feedback: +

+ +
+>  FFFFFFF   AA     III  L      U     U RRRRR   EEEEEEE
+>  F        A  A     I   L      U     U R    R  E
+>  F       A    A    I   L      U     U R     R E
+>  F      A      A   I   L      U     U R     R E
+>  FFFF   A      A   I   L      U     U RRRRRR  EEEE
+>  F      AAAAAAAA   I   L      U     U R   R   E
+>  F      A      A   I   L      U     U R    R  E
+>  F      A      A   I   L       U   U  R     R E
+>  F      A      A  III  LLLLLLL  UUU   R     R EEEEEEE
+
+FAILURE: "str"
+betwn: Typical Valid Usage; expected "is is", got "this is a pipe"
+betwn: Test Negative Start; expected "ing", got "BRRRING"
+betwn: IS NOT NULL: Start bigger than end
+
+ +

+ Faced with these results, I can zoom in on the code + within str.betwn that is causing these incorrect results. I resist the + temptation to fix the code for all my tests all at once. Instead, I make + one change at a time, then run my test again. I do that over and over again + until the failure for the single test case goes away. Then I move to the + next one. Eventually, I get a green light and am highly confident of my + program - if, of course, I really did come up with an exhaustive list of + tests. +

+ +

+ As I think of another test case, I add a call to + utAssert to run that test. +

+ +

+ As a bug is reported to me, I add a call to utAssert + to reproduce that bug. Then I repair my code. +

+ + + + diff --git a/documentation/src/userguide.html b/documentation/src/userguide.html new file mode 100644 index 000000000..ca07a47c4 --- /dev/null +++ b/documentation/src/userguide.html @@ -0,0 +1,53 @@ + + + + + + + + + +

User Guide

+ +

+ The utPLSQL unit testing framework consists of several different elements: +

+
    +
  • + A set of tables to hold information about unit tests and test suites. +
  • +
  • + A set of packages that allow you to run tests, + build test packages and access information about tests you have run. +
  • +
+ +

This document tells you how to use those utPLSQL packages:

+ +

utPLSQL - Register and run test packages

+ +

utConfig - Set how tests are run

+ +

+ utResult - Analyze and display results + of unit tests +

+ +

utAssert - Assert that code works properly

+ +

utGen - Generate test packages

+ +

utOutput - Handling DBMS_OUTPUT for testing

+ +

utRecEq - Generate functions to compare record types

+ +

Define Test Suites

+ +

Using and defining Custom Reporter Packages

+ +

Configuring the File Reporter

+ + + + diff --git a/documentation/src/utassert.html b/documentation/src/utassert.html new file mode 100644 index 000000000..4ed5acf94 --- /dev/null +++ b/documentation/src/utassert.html @@ -0,0 +1,1399 @@ + + + + + + + + + +

utAssert Package

+ +

This package contains the following procedures and functions:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
utAssert.thisGeneric "Assert This" Procedure
+ utAssert.isnull + utAssert.isnotnull + Check for NULL and NOT NULL values
utAssert.eqCheck Equality of Scalar Values
utAssert.eqtableCheck Equality of Database Tables
utAssert.eqtabcountCheck Equality of Table Counts
utAssert.eqqueryCheck Equality of Queries
utAssert.eqqueryvalueCheck Equality of Query against single value
utAssert.eqfileCheck Equality of Files
utAssert.eqpipeCheck Equality of Database Pipes
+ utAssert.eqcoll + utAssert.eqcollapi + Check Equality of Collections
utAssert.throwsCheck a procedure or function throws an exception
+ utAssert.previous_passed + utAssert.previous_failed + + Check if the previous assertion + passed or failed +
utAssert.eqoutputCheck Equality of DBMS_OUTPUT Collections
+ utAssert.objexists + utAssert.objnotexists + Check for existence of database objects
utAssert.eq_refc_queryCheck Equality of RefCursor and Query
utAssert.eq_refc_tableCheck Equality of RefCursor and Database Table
+

+ The utAssert package provides a set of assertion routines ("assert that + the following condition is true") that you will use to register the outcome + of a test case. You must call a utAssert assertion program after (or containing) + a test case so that the results of that test can be recorded and then reported. + See Build Test Packages for many examples and + more details on this process. Here is a very simple example, though, to give + you an idea of the code you would write: +

+ +
+PROCEDURE ut_BETWNSTR IS
+BEGIN
+   utAssert.eq (
+      'Typical valid usage',
+      BETWNSTR(
+         STRING_IN => 'abcdefg',
+         START_IN => 3,
+         END_IN => 5
+      ),
+      'cde'
+   );
+END;
+
+

+ utAssert offers a wide (and ever expanding) set of assertion programs that + allow you to efficiently (a) test the outcome of your unit test and (b) report + the results of that test to utPLSQL. You should review + Common Assertion Parameters and Behavior before using any specific assertion + program. It is also possible to build your own assertion + routine. Note: all utAssert assertions are defined in the ut_assertion + table, as well as actually coded in the utAssert package. +

+ +

Common Assertion Parameters and Behavior

+ +

+ Each type of assertion routine accepts different kinds of data, but there + are lots of similarities between the assertions, as well. Here is an explanation + of the common assertion parameters: +

+ + + + + + + + + + + + + + + + + + + + + + +
msg_in + A message to be displayed if the assertion + fails. This is the first argument and is mandatory, because the tests need + to be self documenting. +
check_this_in + The value to be checked.. If a Boolean expression, + this will usually include the invocation of the method being tested, resulting + in a single line of code for the entire test case. +
against_this_in + For assert_eq, the assertion routine will + check the check_this_in value against the against_this_in value. This parameter + should be the certifiably correct value. +
null_ok_in + TRUE if a NULL value should be interpreted + as a successful test, FALSE if NULL indicates failure. +
raise_exc_in + TRUE if it is OK for the assertion routine + to allow an exception to be propagated out unhandled. +
+ +

Generic "Assert This" Assertion Procedure

+ +

+ This most generic assertion program simply says "assert this" and passes + a Boolean expression. It is used by all the other assertion routines, which + construct a Boolean expression from their specific values and logic. +

+ +
+   PROCEDURE utAssert.this (
+      msg_in        IN VARCHAR2,
+      check_this_in IN BOOLEAN,
+      null_ok_in    IN BOOLEAN := FALSE,
+      raise_exc_in  IN BOOLEAN := FALSE
+   );
+
+ +

+ Use utAssert.this when you have a Boolean expression that you want to check, + as in: +

+ +
+BEGIN
+   ...
+   utAssert.this (
+      'Boolean function result',
+      is_valid_account (my_account)
+   );
+
+ +

+ You can also use this assertion to register a failure, most usually in + an exception section, as in: +

+ +
+EXCEPTION
+   WHEN OTHERS
+   THEN
+      utAssert.this (
+         SQLERRM,
+         FALSE
+      );
+
+ +

+ Generally, you should avoid utAssert.this and instead use a specialized + assertion routine, documented below. Most of the assertions give you the + ability check for equality (of scalars, such as strings, or more complex + data structures like tables, pipes and files): does the data generated by + my code match the expected value(s)? +

+ +

Check for NULL and NOT NULL Values

+ +

+ You can check to see if a value is NULL or is NOT NULL with the following + assertions: +

+ +
+PROCEDURE utAssert.isnotnull (
+   msg_in        IN VARCHAR2,
+   check_this_in IN VARCHAR2,
+   null_ok_in    IN BOOLEAN := FALSE,
+   raise_exc_in  IN BOOLEAN := FALSE
+);
+
+PROCEDURE utAssert.isnull (
+   msg_in        IN VARCHAR2,
+   check_this_in IN VARCHAR2,
+   null_ok_in    IN BOOLEAN := FALSE,
+   raise_exc_in  IN BOOLEAN := FALSE
+);
+
+PROCEDURE utAssert.isnotnull (
+   msg_in        IN VARCHAR2,
+   check_this_in IN BOOLEAN,
+   null_ok_in    IN BOOLEAN := FALSE,
+   raise_exc_in  IN BOOLEAN := FALSE
+);
+
+PROCEDURE utAssert.isnull (
+   msg_in        IN VARCHAR2,
+   check_this_in IN BOOLEAN,
+   null_ok_in    IN BOOLEAN := FALSE,
+   raise_exc_in  IN BOOLEAN := FALSE
+);
+
+ +

+ Use these assertions when you simply want to check if a scalar expression + (string, date, number and Boolean are supported) is NULL or NOT NULL, as + in: +

+ +
+BEGIN
+   ...
+   utAssert.isNULL (
+      'Should be nothing left',
+      TRANSLATE (digits_in_string, 'A1234567890', 'A')
+   );
+
+ +

Check Equality of Scalar Values

+

+ If you need to compare two dates or two strings or two numbers or two Booleans, + use the utAssert.eq assertion program. +

+ +

Here is the header for the scalar equality check assertion:

+ +
+PROCEDURE utAssert.eq (
+   msg_in          IN VARCHAR2,
+   check_this_in   IN VARCHAR2|BOOLEAN|DATE|NUMBER,
+   against_this_in IN VARCHAR2|BOOLEAN|DATE|NUMBER,
+   null_ok_in      IN BOOLEAN := FALSE,
+   raise_exc_in    IN BOOLEAN := FALSE
+);
+
+ +

+ If the two values are equal, your code gets a green light. Otherwise, utAssert + writes the test results to the utResult package, resulting in a red light + for the test. If NULL values are considered value for this test, pass TRUE + for null_ok_in. If you want the assertion to raise an exception on failure + and stop the test from proceeding, pass TRUE for raise_exc_in. Here is an + example of using the utAssert.eq program: +

+ +
   
+   PROCEDURE ut_emp_dept_lookuprowcount
+   IS
+      l_rowcount1 PLS_INTEGER;
+      l_rowcount2 PLS_INTEGER;
+      BEGIN
+         -- Run baseline code.
+         SELECT COUNT (*)
+         INTO l_rowcount1
+         FROM employee
+         WHERE department_id = 30;
+         
+         -- Compare to program call:
+         l_rowcount2 := te_employee.emp_dept_lookuprowcount (30);
+         
+         -- Test results
+         utassert.eq (
+            'Successful EMP_DEPT_LOOKUPROWCOUNT',
+            l_rowcount2,
+            l_rowcount1
+         );
+      END;
+
+ +

Check Equality of DatabaseTables

+ +

+ If your test performs DML operations (update, insert or delete), you will + need to check your results in a database table. You could do this by querying + the results into local variables and then calling utAssert.eq to check those + values against your expected data. That can be a very laborious process, + so utAssert offers the eqtable and equerry assertion routines to streamline + the process. Both these procedures use the MINUS SQL operator to essentially + "subtract" the contents of one table (query) from the other. If anything + is left, then the two tables (queries) are not the same and the test is given + a red light. As you can probably see, the structure of the two tables (queries) + must be identical for this assertion to work properly. The utAssert.eqtable + allows you to compare the contents of your data table (changed by your code) + against another table, which you can preset with the data you expect to see + after the test. Here is the header for eqtable: +

+ +
+PROCEDURE utAssert.eqtable (
+   msg_in           IN VARCHAR2,
+   check_this_in    IN VARCHAR2,
+   against_this_in  IN VARCHAR2,
+   check_where_in   IN VARCHAR2 := NULL,
+   against_where_in IN VARCHAR2 := NULL,
+   raise_exc_in     IN BOOLEAN := FALSE
+);
+
+ +

+ where check_this_in and against_this_in are the names of tables or views. + You can supply an optional WHERE clause to restrict the rows you wish to + compare. Here is an example that calls eqTable twice, to test two different + conditions. +

+ +
+PROCEDURE ut_del1
+IS
+   fdbk PLS_INTEGER;
+BEGIN
+   /* Delete that finds now rows. */
+
+   EXECUTE IMMEDIATE '
+   DELETE FROM ut_DEL1
+   WHERE employee_id = -1
+   ';
+   te_employee.del (-1, rowcount_out => fdbk);
+
+   -- Test results
+   utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1');
+
+   /* Successful delete */
+
+   EXECUTE IMMEDIATE '
+   DELETE FROM ut_DEL1
+   WHERE employee_id between 7800 and 7899
+   ';
+      
+   FOR rec IN (SELECT *
+                 FROM employee
+                WHERE employee_id BETWEEN 7800 AND 7899)
+   LOOP
+      te_employee.del (
+         rec.employee_id,
+         rowcount_out => fdbk
+      );
+   END LOOP;
+   
+   -- Test results
+   utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1');
+   ROLLBACK;
+EXCEPTION
+   WHEN OTHERS
+   THEN
+      utassert.this (
+         'DEL1 exception ' || SQLERRM,
+         SQLCODE = 0
+      );
+END;
+
+ +

Check Equality of Table Counts

+ +

+ If your tests simply produce the right number of rows in a table but not + a fixed set of values, you will not be able to use + utAssert.eqtable above. However, utAssert.eqtabcount allows you to simply + test that the numbers of rows are equal. The declaration of the procedure + is as follows: +

+ +
+PROCEDURE utAssert.eqtabcount (
+   msg_in           IN VARCHAR2,
+   check_this_in    IN VARCHAR2,
+   against_this_in  IN VARCHAR2,
+   check_where_in   IN VARCHAR2 := NULL,
+   against_where_in IN VARCHAR2 := NULL,
+   raise_exc_in     IN BOOLEAN := FALSE
+);
+
+ +

+ where check_this_in and against_this_in are the names of tables or views. + As in utAssert.eqtable, you can supply an optional WHERE clause to restrict + the rows you wish to compare. The following test will compare the number + of rows in the CD_COLLECTION and UT_TEST_5_1 tables where the given condition + holds: +

+ +
+utassert.eqtabcount('Test 5.1: Insert new rows',
+                    'CD_COLLECTION',
+                    'UT_TEST_5_1',
+                    'ARTIST = ''The Fall''',
+                    'ARTIST = ''The Fall''');
+
+ +

Asserting Query Equality

+ +

+ The utAssert.eqquery allows you to compare the data returned by two queries + (strings that are contained in the check_this_in and against_this_in parameters). + In this case, you specify the full SELECT statements for each query as the + parameters. By using equery, you may be able to avoid constructing a separate + table with preset data. +

+ +
+PROCEDURE utAssert.eqquery (
+   msg_in          IN VARCHAR2,
+   check_this_in   IN VARCHAR2,
+   against_this_in IN VARCHAR2,
+   raise_exc_in    IN BOOLEAN := FALSE
+);
+
+ +

+ If you want the assertion to raise an exception on failure and stop the + test from proceeding, pass TRUE for raise_exc_in. Here is an example of + using eqQuery: +

+ +
+PROCEDURE ut_upd1
+IS
+BEGIN
+   /* Update 3 columns by ID */
+   EXECUTE IMMEDIATE '
+   UPDATE ut_UPD1 SET
+      FIRST_NAME = ''SILLY'',
+      HIRE_DATE = trunc (SYSDATE+100),
+      COMMISSION = 5000
+    WHERE
+       EMPLOYEE_ID = 7600
+   ';
+   te_employee.upd (
+      7600,
+      first_name_in => 'SILLY',
+      commission_in => 5000,
+      hire_date_in => TRUNC (SYSDATE + 100),
+      rowcount_out => fdbk
+   );
+   -- Test results (audit fields are different so do a query)
+   utassert.eqquery (
+      'Update three columns',
+      'select first_name, commission, hire_date from EMPLOYEE',
+      'select first_name, commission, hire_date from ut_upd1'
+   );
+   ROLLBACK;
+END;
+
+ +

Check Query Equality against a Single Value

+

+ Often we will wish to test the result of a query against a single value rather + than another query as in utAssert.eqquery above. + It is possible to get around this problem by using a trivial query of the + form: +

+ +
+SELECT fixed_value
+FROM DUAL;
+
+ +

+ Unfortunately, if the query returns multiple values or the wrong value we + will only be told that the test has failed with no details. This is where + utAssert.eqqueryvalue comes to the rescue. The procedure is declared as + follows: +

+ +
+PROCEDURE utAssert.eqqueryvalue (
+   msg_in           IN VARCHAR2,
+   check_query_in   IN VARCHAR2,
+   against_value_in IN VARCHAR2|NUMBER|DATE,
+   raise_exc_in     IN BOOLEAN := FALSE
+);
+
+ +

+ Where check_query_in is the query in question and against_value_in is the + value to check it against. If the query returns more than one value, the + resulting error message will tell you this. Similarly, if the query returns + the wrong value, the message will state the expected and obtained values. + The following call compares the maximum value found in a table against a + given number value: +

+ +
+utAssert.eqqueryvalue('Maximum value test',
+                      'SELECT MAX(MEMORY)
+                       FROM COMPUTERS
+                       WHERE OS IN (''Linux'', ''Unix'')',
+                       256);
+
+ +

+ Obviously this should only return a single value, but if it returns something + other than 256, we'll know about it. +

+ +

Check Equality of Files

+ +

+ Many programs generate output to operating system files; alternatively, + you might write data to a file simply to test results. Use the eqfile assertion + for either of these scenarios. This procedure uses PL/SQL's UTL_FILE package + to compare the contents of two different files. Note: If you have not used + UTL_FILE in the past, you must configure + it before it can be used -- by utPLSQL or by your own code. UTL_FILE must + be allowed accss to either or both of the directories you specify (this involves + setting the utl_file_dir database parameter). +

+ +
+PROCEDURE utAssert.eqfile (
+   msg_in IN VARCHAR2,
+   check_this_in IN VARCHAR2,
+   check_this_dir_in IN VARCHAR2,
+   against_this_in IN VARCHAR2,
+   against_this_dir_in IN VARCHAR2 := NULL,
+   raise_exc_in IN BOOLEAN := FALSE
+);
+
+ +

+ If you want the assertion to raise an exception on failure and stop the + test from proceeding, pass TRUE for raise_exc_in. You must specify the directory + containing the "check this" file; if you do not specify a directory for the + "against this" file, the "check this" directory will be used. Here is an + example of using eqFile (see ut_DEPARTMENT2file.pkg in the Examples directory + for the full implementation): +

+ +
+PROCEDURE ut_DEPARTMENT2FILE IS
+BEGIN
+   DEPARTMENT2FILE (
+      LOC => 'c:\temp',
+      FILE => 'department.dat',
+      DELIM => '***'
+    );
+
+   utAssert.eqfile (
+      'Test of DEPARTMENT2FILE',
+      'department.dat',
+      'c:\temp',
+      'department.tst',
+      'c:\temp'
+      );      
+END ut_DEPARTMENT2FILE;
+
+ +

Check Equality of Database Pipes

+

+ Database pipes offer a handy mechanism for passing data between different + sessions connected to the RDBMS. It is important to know that pipes are being + filled properly; use the eqpipe to check this condition. With the eqpipe + procedure, you compare the contents of two different pipes. +

+ +
+PROCEDURE utAssert.eqpipe (
+   msg_in          IN VARCHAR2,
+   check_this_in   IN VARCHAR2,
+   against_this_in IN VARCHAR2,
+   raise_exc_in    IN BOOLEAN := FALSE
+);
+
+ +

+ If you want the assertion to raise an exception on failure and stop the + test from proceeding, pass TRUE for raise_exc_in. To check the contents + of a pipe based on the execution of code, you will need to populate a pipe + against which to test equality. The employee_pipe.pkg file in the Examples + directory contains a demonstration of the kind of code you might write to + do this. This package contains all of the unit test code within the same + package. Here is my unit test program, which relies on the utAssert.eqpipe + program: +

+ +
+PROCEDURE ut_fillpipe IS
+   stat PLS_INTEGER;
+BEGIN
+   emptypipe ('emps');
+   emptypipe ('emps2');
+   
+   fillpipe ('emps');
+   
+   /* Direct filling of pipe. */
+   
+   FOR rec IN (SELECT *
+                 FROM employee)
+   LOOP
+      DBMS_PIPE.RESET_BUFFER;
+      DBMS_PIPE.PACK_MESSAGE (rec.EMPLOYEE_ID);
+      DBMS_PIPE.PACK_MESSAGE (rec.LAST_NAME);
+      DBMS_PIPE.PACK_MESSAGE (rec.FIRST_NAME);
+      DBMS_PIPE.PACK_MESSAGE (rec.MIDDLE_INITIAL);
+      DBMS_PIPE.PACK_MESSAGE (rec.JOB_ID);
+      DBMS_PIPE.PACK_MESSAGE (rec.MANAGER_ID);
+      DBMS_PIPE.PACK_MESSAGE (rec.HIRE_DATE);
+      DBMS_PIPE.PACK_MESSAGE (rec.SALARY);
+      DBMS_PIPE.PACK_MESSAGE (rec.COMMISSION);
+      DBMS_PIPE.PACK_MESSAGE (rec.DEPARTMENT_ID);
+      DBMS_PIPE.PACK_MESSAGE (rec.CHANGED_BY);
+      DBMS_PIPE.PACK_MESSAGE (rec.CHANGED_ON);
+
+      stat := DBMS_PIPE.SEND_MESSAGE ('emps2', 0);
+   END LOOP;
+   
+   /* Compare the two */
+   utassert.eqpipe (
+      'Two employee pipes', 'emps', 'emps2');
+      
+END ut_fillpipe;
+
+ +

+ Since I have stored my unit test logic with my source code package, I would + run my test as follows: +

+ +
+SQL> exec utplsql.test ('employee_pipe', samepackage_in=>TRUE)
+FAILURE: "employee_pipe"
+fillpipe: Pipes equal? Compared "emps" against "emps2"
+
+ +

Check Equality of Collections

+ +

+ Collections are as close as you come to arrays in PL/SQL. They are very + useful for managing lists of information, but can be difficult to debug and + maintain. With the eqcoll and eqcollAPI procedures, you can compare the + contents of two different arrays. Use the eqColl procedure when you want + to compare two collections that are defined in the specification of a package. + Use the eqCollAPI procedure when you want to compare two collections that + are defined in the body of a package, with programs defined in the specification + (an API) to access and manipulate the collections. The collection equality + check headers are: +

+ +
+   /* Direct access to collections */
+   PROCEDURE utAssert.eqcoll (
+      msg_in IN VARCHAR2,
+      check_this_in IN VARCHAR2, /* pkg1.coll */
+      against_this_in IN VARCHAR2, /* pkg2.coll */
+      eqfunc_in IN VARCHAR2 := NULL,
+      check_startrow_in IN PLS_INTEGER := NULL,
+      check_endrow_in IN PLS_INTEGER := NULL,
+      against_startrow_in IN PLS_INTEGER := NULL,
+      against_endrow_in IN PLS_INTEGER := NULL,
+      match_rownum_in IN BOOLEAN := FALSE,
+      null_ok_in IN BOOLEAN := TRUE,
+      raise_exc_in IN BOOLEAN := FALSE
+   );
+  
+   /* API based access to collections */
+   PROCEDURE utAssert.eqcollapi (
+      msg_in IN VARCHAR2,
+      check_this_pkg_in IN VARCHAR2,
+      against_this_pkg_in IN VARCHAR2,
+      eqfunc_in IN VARCHAR2 := NULL,
+      countfunc_in IN VARCHAR2 := 'COUNT',
+      firstrowfunc_in IN VARCHAR2 := 'FIRST',
+      lastrowfunc_in IN VARCHAR2 := 'LAST',
+      nextrowfunc_in IN VARCHAR2 := 'NEXT',
+      getvalfunc_in IN VARCHAR2 := 'NTHVAL',
+      check_startrow_in IN PLS_INTEGER := NULL,
+      check_endrow_in IN PLS_INTEGER := NULL,
+      against_startrow_in IN PLS_INTEGER := NULL,
+      against_endrow_in IN PLS_INTEGER := NULL,
+      match_rownum_in IN BOOLEAN := FALSE,
+      null_ok_in IN BOOLEAN := TRUE,
+      raise_exc_in IN BOOLEAN := FALSE
+   );
+
+ +

where the eqcoll-specific parameters are as follows:

+ + + + + + + + + + + + + + + + + + +
ParameterDescription
msg_in The message to be displayed if the test failes
check_this_in + The name of the collection to be checked. + Format: package.collection. In other words, the collection must be defined + in a package specification. Use eqCollAPI (and check_this_pkg_in) if you + want to hide the declaration of your collection in your package body (recommended). +
against_this_in + The name of the collection to be checked + against. Format: package.collection. In other words, the collection must + be defined in a package specification. Use eqCollAPI (and check_this_pkg_in) + if you want to hide the declaration of your collection in your package body + (recommended). +
+ +

and the eqcollAPI-specific parameters are as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescription
msg_in The message to be displayed if the test failes
check_this_pkg_in + The name of the package that contains the + collection to be checked. +
against_this_pkg_in + The name of the package that contains the + collection to be checked against. +
countfunc_in + The name of the function in the package that + returns the number of rows defined in the collection. +
firstrowfunc_in + The name of the function in the package that + returns the first defined row in the collection. +
lastrowfunc_in + The name of the function in the package that + returns the last defined row in the collection. +
nextrowfunc_in + The name of the function in the package that + returns the next defined row in the collection from the specified row. +
getvalfunc_in + The name of the function in the package that + returns the contents of the specified row. +
+ +

The parameters common to both eqColl and eqCollAPI are as follows

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescription
eqfunc_in + The function used to determine if the contents + of each row of the two collections are the same. If you pass NULL for this + argument, then a standard equality check will be used. This is fine for scalar + values, but will not work, for example, with tables of records. +
check_startrow_in + The starting row in the check collection + for comparison. If NULL, then first row is used. +
check_endrow_in + The ending row in the check collection for + comparison. If NULL, then last row is used. +
against_startrow_in + The starting row in the against collection + for comparison. If NULL, then first row is used. +
against_endrow_in + The ending row in the against collection + for comparison. If NULL, then last row is used. +
match_rownum_in + Pass TRUE if you want to make sure that the + same row numbers are used in each collection. If FALSE, then the row numbers + can be different, but the contents of each corresponding row must be the same. +
null_ok_in + Pass TRUE if the assertion routine should + consider two NULL collections to be equal. +
raise_exc_in + If you want the assertion to raise an exception + on failure and stop the test from proceeding, pass TRUE for raise_exc_in. +
+ +

+ Here is an example of a script that uses utAssert.eqColl (taken from filepath1.pkg + in the Examples directory): +

+ +
+PROCEDURE ut_setpath
+IS
+BEGIN
+   /* Populate base collection */
+   ut_dirs.DELETE;
+   ut_dirs.EXTEND(2);
+   ut_dirs(1) := 'c:\temp';
+   ut_dirs(2) := 'e:\demo';
+   
+   /* Call setpath to do the work */
+   setpath ('c:\temp;e:\demo');
+   
+   utAssert.eqColl (
+      'Valid double entry',
+      'fileio.dirs',
+      'fileio.ut_dirs'
+      );
+END;
+
+ +

Checking a Procedure or Function throws an exception

+ +

+ Sometimes we design a procedure or function to throw an exception under certain + circumstances. This is something we'd like to be able to test for. Obviously + this is not particularly easy due to the way exceptions propagate through + the call stack. If we simply call the procedure in our test code, the exception + will have no chance of being caught within the utAssert package! Therefore, + we need to pass the tested call in to the package as a string. The procedure + utAssert.throws allows us to do this: +

+ +
+PROCEDURE throws (
+      msg_in VARCHAR2,
+      check_call_in IN VARCHAR2,
+      against_exc_in IN VARCHAR2|NUMBER
+   );
+
+

+ Where check_call_in is the call to be made, complete with parameters and + terminating semicolon. The argument against_exc_in is the exception we expect + to be thrown. This can be specified either as a named exception, or a SQLCODE + value. +

+

The following example shows both usages:

+ +
+/* Test the Except Function */
+PROCEDURE ut_except
+IS
+BEGIN
+
+   /* Call the procedure with a negative number */
+   /* We expect a NO_DATA_FOUND exception       */
+   utAssert.throws('Negative Number',
+      'Except(-1);',
+      'NO_DATA_FOUND'
+   );
+   
+   /* Call the procedure with zero and a string    */
+   /* over 2 in length - We expect a SQLCODE of -1 */  
+   utAssert.throws('Zero and String',
+      'Except(0, ''Hello'');',
+      -1
+     );
+END;
+
+ +

+ Note how we have to quote the string parameters to the call and terminate + the string with a semicolon. +

+ +

Check if the Previous Assertion Passed or Failed

+ +

+ Sometimes, a procedure may have a large number of effects that need to be + tested. For example, it might insert and update data in a series of + tables. To test all of these changes, it will be necessary to make + a series of calls to utAssert. This can have the effect that if the + procedure is not behaving as expected, then the user is presented with a + screenful of errors. To avoid this and just present them with a single + error, the functions previous_passed and previous_failed can be used. + These return a BOOLEAN argument giving the success or failure of the previously + called assertion. +

+ +

The following example gives a demonstration:

+ +
+/* Test the BookTrips Procedure */
+PROCEDURE ut_bookTrips
+IS 
+BEGIN
+
+  /* Call the procedure */
+  Vacation.bookTrips(5, 'Rio de Janeiro');
+  
+  /* Did it insert 5 rows into TRIPS table */
+  utAssert.eqqueryvalue('Insert 5 rows',
+    'SELECT COUNT(*)
+    FROM TRIPS
+    WHERE CITY = ''Rio de Janeiro''',
+    5);
+    
+  /* If that worked, look in more detail */
+  IF utAssert.previous_passed THEN
+    
+    /* Do they all have today's date? */
+    utAssert.eqqueryvalue('All with todays date',
+      'SELECT COUNT(*)
+       FROM TRIPS
+       WHERE CITY = ''Rio de Janeiro'''
+       AND TRUNC(CREATED) = TRUNC(SYSDATE)',
+       5);
+     
+    /* Do they all have a hotel specified? */
+    utAssert.eqqueryvalue('Hotel Specfied',
+      'SELECT COUNT(*)
+       FROM TRIPS T, HOTELS H
+       WHERE T.CITY = ''Rio de Janeiro'''
+       AND T.HOTEL = H.ID',
+       5);
+     
+ END IF;
+   
+END;
+
+ +

Comparing output from DBMS_OUTPUT

+ +

+ To complement the utOutput package, these + assertions allow you to easily compare collections of the type + DBMS_OUTPUT.CHARARR. Unlike the eqcoll and + eqcollapi assertions, this allows the comparison of locally defined + collections. The procedures are declared as follows: +

+ +
+PROCEDURE eqoutput (
+   msg_in                IN   VARCHAR2,
+   check_this_in         IN   DBMS_OUTPUT.CHARARR,
+   against_this_in       IN   DBMS_OUTPUT.CHARARR,
+   ignore_case_in        IN   BOOLEAN := FALSE,
+   ignore_whitespace_in  IN   BOOLEAN := FALSE,
+   null_ok_in            IN   BOOLEAN := TRUE,
+   raise_exc_in          IN   BOOLEAN := FALSE
+);
+
+PROCEDURE eqoutput (
+   msg_in                IN   VARCHAR2,
+   check_this_in         IN   DBMS_OUTPUT.CHARARR,
+   against_this_in       IN   VARCHAR2,
+   line_delimiter_in     IN   CHAR := NULL,
+   ignore_case_in        IN   BOOLEAN := FALSE,
+   ignore_whitespace_in  IN   BOOLEAN := FALSE,
+   null_ok_in            IN   BOOLEAN := TRUE,
+   raise_exc_in          IN   BOOLEAN := FALSE
+);
+
+ +

+ The first version simply compares two collections, whereas the second compares a collection against a delimited string. The delimiter + can be specified by the line_delimiter_in parameter. If NULL is passed in (which is the default) then the lines are delimited by carriage returns. + Thus to test a collection mybuff which should look like: +

+ +
+   mybuff(0) := 'Zidane';
+   mybuff(1) := 'Ronaldo';
+   mybuff(2) := 'Kahn';
+
+ +

we could pass in parameters:

+ +
+   check_this_in => 'Zidane|Ronaldo|Kahn';
+   line_delimiter_in => '|';
+
+ +

or:

+ +
+   check_this_in => 
+'Zidane
+Ronaldo
+Kahn';
+   line_delimiter_in => NULL;
+
+ +

There are also the following flags to modify the way that the line-by-line comparisons are carried out:

+ +
    +
  • ignore_case_in - this specifies that case should be ignored when comparing lines.
  • +
  • ignore_whitespace_in - this specifies that whitespace differences should be ignored when comparing lines.
  • +
+ +

+ Finally, note that only the text itself is compared. These assertions do + not care about how the records within the collections are numbered. +

+ +

Check for Existence of Database Objects

+ +

+ The following assertions (created by Raji) check that a named database + object exists or does not exist: +

+ +
+PROCEDURE objExists (
+   msg_in            IN   VARCHAR2,
+   check_this_in     IN   VARCHAR2,
+   null_ok_in        IN   BOOLEAN := FALSE,
+   raise_exc_in      IN   BOOLEAN := FALSE
+);
+
+PROCEDURE objnotExists (
+   msg_in            IN   VARCHAR2,
+   check_this_in     IN   VARCHAR2,
+   null_ok_in        IN   BOOLEAN := FALSE,
+   raise_exc_in      IN   BOOLEAN := FALSE
+);
+
+ +

+ In both cases, the check_this_in parameter gives the name of the object to + check for. So passing 'MYTHING' will check if the MYTHING object exists. This + is assumed to be in the current schema. To check for objects in a schema other + than the current one, simply add the name of the schema, separated by a dot. + So passing 'ANOTHER.THATTHING' will check for the existence of the THATTHING + object in the ANOTHER schema. +

+ +

Check Equality of RefCursor and Query

+ +

+ If you have a procedure or function that returns a REF CURSOR type you + often would like to compare the data of the REF CURSOR against a query (if + your REF CURSOR returns a complete table you can use + utAssert.eq_refc_table below). In this case, + you specify the REF CURSOR of the procedure or function and the full + SELECT statement as parameters. By using eq_refc_query, you may be able to + avoid the huge workload of constructing separate tables with preset data. +

+ +

+ Before calling the comparison you have to specifiy the parameters of the procedure or function you are going to use. + This is done with the procedures utPLSQL_Util.reg_In_Param, utPLSQL_Util.reg_InOut_Param or utPLSQL_Util.reg_Out_Param. + The details of the parameters are built up in a variable of type utplsql_util.utplsql_params, which is then passed into eq_refc_query. +

+ +
+PROCEDURE utPLSQL_Util.reg_In_Param (
+   par_pos            PLS_INTEGER,
+   par_val            VARCHAR2 | NUMBER | DATE,
+   params    IN OUT   utplsql_util.utplsql_params );
+
+PROCEDURE utPLSQL_Util.reg_InOut_Param (
+   par_pos            PLS_INTEGER,
+   par_val            VARCHAR2 | NUMBER | DATE,
+   params    IN OUT   utplsql_util.utplsql_params );
+
+PROCEDURE utPLSQL_Util.reg_Out_Param (
+   par_pos            PLS_INTEGER,
+   par_type           VARCHAR2,
+   params    IN OUT   utplsql_util.utplsql_params );
+
+ +

+ Having specified all the parameters for the procedure or function + returning the REF CURSOR, the comparison can be started. +

+ +
+PROCEDURE utAssert.eq_refc_query (
+   p_msg_nm          IN   VARCHAR2,
+   proc_name         IN   VARCHAR2,
+   params            IN   utplsql_util.utplsql_params,
+   cursor_position   IN   PLS_INTEGER,
+   qry               IN   VARCHAR2 );
+
+ +

where the reg_In_Param, reg_InOut_Param and reg_Out_Param-specific parameters are as follows:

+ + + + + + + + + + + + + + + + + + +
ParameterDescription
par_pos Defines the parameter position beginning with 1, or 0 specifying the return value
par_type Specifies the data type of the return value and must be one out of 'NUMBER', 'VARCHAR', 'CHAR' or 'REFCURSOR'
params The local variable to keep the values that is used as a parameter for eq_refc_query
+ +

and the eq_refc_query-specific parameters are as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescription
p_msg_nm The message to be displayed if the test fails
proc_name Specifies the procedure or function that delivers the REF CURSOR
params The parameter setting for the procedure or function
cursor_position Position of the REF CURSOR parameter to be checked, beginning with 1, or 0 to specify the return value of a function
qry The SELECT statement to be checked against
+ +

Finally, note that only the record itself is compared. These assertions do not care about how the records within the cursor are numbered.

+ + +

Check Equality of RefCursor and Database Table

+ +

+ If you have a procedure or function that returns a REF CURSOR type that represents a complete table or view you + often would like to compare the data of this REF CURSOR against the table or view + (if your REF CURSOR doesn't return a complete table or view you can use utAssert.eq_refc_query above). + In this case, you specify the REF CURSOR of the procedure or function and the table or view name as parameters. + By using eq_refc_table, you may be able to avoid the huge workload of constructing separate tables with preset data. +

+ +

+ Before calling the comparison you have to specifiy the parameters of the procedure or function you are going to use. + This is done with the procedures utPLSQL_Util.reg_In_Param, utPLSQL_Util.reg_InOut_Param or utPLSQL_Util.reg_Out_Param. + The details of the parameters are built up in a variable of type utplsql_util.utplsql_params, which is then passed into eq_refc_query. +

+ +
+PROCEDURE utPLSQL_Util.reg_In_Param (
+   par_pos            PLS_INTEGER,
+   par_val            VARCHAR2 | NUMBER | DATE,
+   params    IN OUT   utplsql_util.utplsql_params );
+
+PROCEDURE utPLSQL_Util.reg_InOut_Param (
+   par_pos            PLS_INTEGER,
+   par_val            VARCHAR2 | NUMBER | DATE,
+   params    IN OUT   utplsql_util.utplsql_params );
+
+PROCEDURE utPLSQL_Util.reg_Out_Param (
+   par_pos            PLS_INTEGER,
+   par_type           VARCHAR2,
+   params    IN OUT   utplsql_util.utplsql_params );
+
+ +

Having specified all the parameters for the procedure or function returning the REF CURSOR, the comparison can be started.

+ +
+PROCEDURE utAssert.eq_refc_table (
+   p_msg_nm          IN   VARCHAR2,
+   proc_name         IN   VARCHAR2,
+   params            IN   utplsql_util.utplsql_params,
+   cursor_position   IN   PLS_INTEGER,
+   table_name        IN   VARCHAR2 );
+
+ +

where the reg_In_Param, reg_InOut_Param and reg_Out_Param-specific parameters are as follows:

+ + + + + + + + + + + + + + + + + + +
ParameterDescription
par_pos Defines the parameter position beginning with 1, or 0 specifying the return value
par_type Specifies the data type of the return value and must be one out of 'NUMBER', 'VARCHAR', 'CHAR' or 'REFCURSOR'
params The local variable to keep the values that is used as a parameter for eq_refc_query
+ +

and the eq_refc_query-specific parameters are as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescription
p_msg_nm The message to be displayed if the test fails
proc_name Specifies the procedure or function that delivers the REF CURSOR
params The parameter setting for the procedure or function
cursor_position Position of the REF CURSOR parameter to be checked, beginning with 1, or 0 to specify the return value of a function
table_name The name of the table name or view to be checked against
+ +

Finally, note that only the record itself is compared. These assertions do not care about how the records within the cursor are numbered.

+ +

Building Your Own Assertion

+ +

+ You may want to build assertion routines that fit your specific needs. + If PL/SQL supported inheritance, you could extend the utAssert assertion + routines and then customize them through polymorphism. Lacking this feature, + however, you will write your own procedures that follow the same steps as + the pre-build assertions. In order to integrate the results of your assertion + test into the utResult package, you will want to mimic the utAssert.this procedure. + Here is its current implementation (Release 1.3.2); check the body of the + utAssert package for any changes. +

+ +
+PROCEDURE this (
+   msg_in        IN VARCHAR2,
+   check_this_in IN BOOLEAN,
+   null_ok_in    IN BOOLEAN := FALSE,
+   raise_exc_in  IN BOOLEAN := FALSE,
+   register_in   IN BOOLEAN := TRUE
+   )
+IS
+BEGIN
+   IF    NOT check_this_in
+      OR (    check_this_in IS NULL
+          AND NOT null_ok_in)
+   THEN
+      IF register_in
+      THEN
+         -- Registers the results in the utResult databank.
+         utresult.report (msg_in);
+      ELSE
+         utreport.pl (msg_in); -- used to be utplsql.pl (msg_in) (PBA 20050621)
+      END IF;
+      
+      IF showing_results AND register_in
+      THEN
+         -- Show the results of the test more recently run.
+         utresult.showlast;
+      END IF;
+
+      IF raise_exc_in
+      THEN
+         RAISE test_failure;
+      END IF;
+   END IF;
+END;
+
+ +

+ The most important statement to include in your assertion routine is the + call to utResult.report, which will log the results of the test. +

+ + + + diff --git a/documentation/src/utconfig.html b/documentation/src/utconfig.html new file mode 100644 index 000000000..2bf5bf9ac --- /dev/null +++ b/documentation/src/utconfig.html @@ -0,0 +1,604 @@ + + + + + + + + + +

utConfig Package

+ +

This package contains the following functions and procedures:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
utConfig.testerReturn whose configuration is used
utConfig.settesterSet whose configuration is used
utConfig.showconfigView a schema's configuration
utConfig.setdirSet the directory containing the test package code
utConfig.dirReturn the directory containing the test package code
utConfig.setprefixSet the default unit test prefix for your code
utConfig.prefixReturn the default unit test prefix for your code
utConfig.registertestSet the registration mode (manual or automatic)
utConfig.registeringReturn the registration mode
utConfig.autocompileSet autocompile feature
utConfig.autocompilingReturn the autocompile flag
utConfig.setdelimiterSet the V2 delimiter
utConfig.delimiterReturn the V2 delimiter
utConfig.showfailuresonlyTurn off the display of successful tests
utConfig.showingfailuresonlyReturn whether successful test results are shown or not
utConfig.setreporterSets the default Output Reporter to use
utConfig.getreporterGets the name of the default Output Reporter to use
utConfig.setfiledirSet the directory for file output
utConfig.filedirReturn which directory is used for file output
utConfig.setuserprefixSet the user prefix for output file names
utConfig.userprefixReturn the user prefix for output file names
utConfig.setincludeprognameSet whether to include the name of the program being tested in output file names
utConfig.includeprognameReturn whether to include the name of the program being tested in output file names
utConfig.setdateformatSet the date format for the date portion of output file names
utConfig.dateformatReturn the date format used to construct output file names
utConfig.setfileextensionSet the file extension for output file names
utConfig.fileextensionReturn the file extension used for output file names
utConfig.setfileinfoSet all of the above file output related items
utConfig.fileinfoReturn all of the above file output related items
+ +

+ To make it as easy as possible for you to run your tests, utPLSQL stores + various pieces of configuration data in the ut_config table. This data + is stored by schema name and is automatically loaded into utPLSQL the first + time you use this utility in your session. This configuration information + is also automatically updated whenever you call utPLSQL.test -- or any + of the utPLSQL programs specifically designed to change the configuration + settings. +

+ +

+ You can at any time view the utPLSQL configuration for the currently-connected + schema or for another schema (there is not at this point any schema-level + security; all utPLSQL users can view the configurations of all other users). +

+ +

The data that is currently maintained for a utPLSQL user are:

+ +

+ Test package directory - the location of the test package code + you want to run. You must specify a directory in order to allow utPLSQL + to automatically compile your test packages before each test run. +

+ +

+ Unit test prefix - the prefix used for test package names and + the program names within the package. If you do not specify a prefix, the + default of "ut_" is automatically applied. +

+ +

+ Unit test registration mode - This setting determines whether + utPLSQL will automatically identify the unit tests to be run (strongly + recommended) or if you have chosen to manually register your unit tests + in the test package setup procedure. +

+ +

+ Auto-compilation of test packages - By default, utPLSQL will + recompile your test package before execution. You can turn off this feature + and manually recompile only when you desire (a fine idea if your test package + has gotten very large!). +

+ +

Return whose configuration is being used

+ +

+ By default, the configuration stored for the currently-connected user will + be used. However, it is possible to use configurations stored against + other usernames. To show whose configuration is currently being used + the following function is used: +

+ +
+FUNCTION utConfig.tester RETURN VARCHAR2;
+
+ +

Set whose configuration is being used

+ +

+ This returns the configuration that will be used whenever a username is + not specified. To set this, the following procedure is used: +

+ +
+PROCEDURE utConfig.settester (username_in IN VARCHAR2 := USER);
+
+ +

View a schema's configuration

+ +

+ Call the utconfig.showconfig procedure to view the configuration for a specified + schema. The header is: +

+ +
+PROCEDURE utConfig.showconfig (username_in IN VARCHAR2 := NULL);
+
+ +

+ If you do not specify a schema, then the currently + used configuration is returned. Here is an example of output from this + procedure: +

+ +
+SQL> exec utconfig.showconfig
+=============================================================
+utPLSQL Configuration for SCOTT
+   Directory: /apps/utplsql/code
+   Autcompile? Y
+   Manual test registration? N
+   Prefix = test_
+=============================================================
+
+ +

And here is an example of calling showConfig for a different schema:

+ +
+SQL> exec utconfig.showconfig ('COMP')
+=============================================================
+utPLSQL Configuration for COMP
+   Directory: M:\shared_apps\utplsql\comp
+   Autcompile? N
+   Manual test registration? N
+   Prefix = ut_
+=============================================================
+
+ +

+ You might want to put a call to showConfig in your SQL*Plus login file + so that you are reminded on startup as to what the current settings are. + Here is such a script (to be found in Examples\login_sample.sql): +

+ +
+exec utconfig.setdir ('e:\openoracle\utplsql\utinstall\examples')
+SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED
+exec utconfig.showconfig
+
+ +

Set the directory containing the test package code

+ +

+ If you want utPLSQL to compile your test package, you must tell it the + directory in which your code is found. You can do this either when you + define your test suite and packages within the suite, or you can call the + utConfig.setdir procedure to set the directory for your current session. +

+ +

+ Note: as of v1.5.1, the value you pass in any of these programs is saved + in the configuration table and will be used in the future -- until you + change it by passing a different value. +

+ +

The header for this procedure is:

+ +
+PROCEDURE utConfig.setdir (dir_in IN VARCHAR2, username_in IN VARCHAR2 := NULL);
+
+ +

+ where dir_in is the directory and username_in is the name of the schema + to which this directory applies (NULL means the currently + used configuration is set), as in: +

+ +
+SQL> exec utconfig.setdir ('e:\demo\utplsql');
+
+ +

or, with the specification of a non-current schema:

+ +
+SQL> exec utconfig.setdir ('e:\demo\utplsql', 'ANALYSIS');
+
+ +

Note that this directory must be accessible through UTL_FILE.

+ +

+ You might consider putting the the call to utConfig.setdir into your + login.sql so that it is run automatically, each time your start up SQL*Plus + -- if you are always working from the same directory. +

+ +

Return the directory containing the test package code

+ +

You can obtain the current directory with a call to utConfig.dir:

+ +
+FUNCTION utConfig.dir (username_in IN VARCHAR2 := NULL)
+      RETURN VARCHAR2;
+
+ +

Set the default unit test prefix for your code.

+ +

+ The unit test prefix is very important in utPLSQL; the utility uses the + prefix to associate source code to be tested with the test package. The + prefix also allows utPLSQL to automatically identify the programs within + a test package that are to be executed as unit tests. +

+ +

+ The default prefix in utPLSQL is "ut_", but you can override this when + you call utPLSQL.test or by calling the utConfig.setprefix procedure: +

+ +
+PROCEDURE utConfig.setPrefix (
+   prefix_in IN VARCHAR2, username_in IN VARCHAR2 := NULL)
+
+ +

+ where prefix_in is the prefix and username_in is the name of the schema + to which this prefix applies (NULL means the currently + used configuration is set), as in: +

+ +
+SQL> exec utconfig.setPrefix ('tst#');
+
+ +

or, with the specification of a non-current schema:

+ +
+SQL> exec utconfig.setPrefix ('t_', 'ANALYSIS');
+
+ +

Return the default unit test prefix for your code.

+ +

You can obtain the current prefix with a call to utConfig.prefix:

+ +
+FUNCTION utConfig.prefix (username_in IN VARCHAR2 := NULL)
+      RETURN VARCHAR2;
+
+ +

+ uPLSQL currently does not support the use of a suffix, or combination of + suffix and prefix, to identify test packages and unit test procedures. +

+ +

Set the registration mode (manual or automatic).

+ +

+ As of utPLSQL v1.5.1, you no longer have to register your unit test procedures + in the setup procedure of your test package. Instead, utPLSQL will scan + the data dictionary (via theALL_ARGUMENTS view) for the names of all the + unit test procedures you have defined, and then run them. utPLSQL identifies + these programs by looking for all programs whose names start with the specified + prefix. +

+ +

+ If you so choose, you can request that utPLSQL turn off automatic detection + of unit test procedures and only run those programs listed in the setup + procedure. To do this, you call the utConfig.registerTest procedure: +

+ +
+PROCEDURE utConfig.registerTest (
+      onoff_in IN BOOLEAN,
+      username_in IN VARCHAR2 := NULL
+   );
+
+ +

as in:

+ +
+SQL> exec utConfig.registerTest (TRUE)
+
+ +

+ Note: if you are using automatic unit test detection, any calls to utPLSQL.addtest + in the setup procedure will be ignored. +

+ +

You can return the current registration mode using the following function:

+ +
+FUNCTION registeringtest (username_in IN VARCHAR2 := NULL)
+   RETURN BOOLEAN;
+
+ +

This returns TRUE if the registration mode has been set to manual and FALSE otherwise.

+ +

Set autocompile feature

+ +

+ The default settings for utPLSQL is to re-compile + your base package before each unit test. This guarantees that any recent + changes will be tested. It also saves you the step of doing an explicit + compile. +

+ +

In order to perform automatic compilation:

+ +
    +
  • + Your schema will need to + have either CREATE PROCEDURE or CREATE ANY PROCEDURE privileges granted + directly; + you cannot grant these privileges through roles. +
  • + +
  • + You will need to set or + pass the location of the source code. You can do this by calling utConfig.setdir + or by including the directory location in your call to utPLSQL.test + or utPLSQL.testsuite (the dir_in + parameter). +
  • + +
  • + The package specification + must be contained in a file named <package>.pks; the body must be stored + in <package>.pkb. +
  • + +
  • + You must have configured + the + UTL_FILE built-in package for use + on your database instance. +
  • +
+ +

+ In general (and the default), you should allow your + test package to be recompiled with each execution. You might want to avoid + recompilation if: +

+ +
    +
  • + You have made a copy of the package body with some + temporary changes and already compiled that. If you recompile automatically, + you will wipe out those changes. +
  • +
  • + You have not set up UTL_FILE + and you don't want to deal with it. +
  • +
  • + You are running the tests + on a server to which you have no access other than via a database connection. +
  • +
+ +

Turning off Auto-compile

+ +

+ If you are working with products like SQL*Navigator, + you may be always editing from code stored in the database. In this case, + you will never want to have utPLSQL recompile your code for you - it will + already be compiled and you do not need to hassle with UTL_FILE. +

+ +

You can avoid auto-recompilation in two ways:

+ +

+ 1. Pass a value of FALSE for the recompile_in argument + to utPLSQL.test or utPLSQL.testsuite. Here is an example: +

+ +
+BEGIN
+   -- Define a test suite for PL/Vision
+   utsuite.add ('PLVision');
+  
+   -- Add two packages for testing
+   utsuite.addpkg (
+      'PLVision', 'PLVstr', dir_in => 'e:\utplsql');
+   utsuite.addpkg (
+      'PLVision', 'PLVdate', dir_in => 'e:\utplsql');
+  
+   -- Run the test suite
+   utplsql.testsuite (
+      'PLVision', recompile_in => FALSE);
+END;
+/
+ +

+ If you know that you will never want to recompilation, + however, you can set the default behavior at the schema level by calling + the autocompile procedure +

+ +
+   PROCEDURE utConfig.autocompile (
+      onoff_in IN BOOLEAN,
+      username_in IN VARCHAR2 := NULL
+   );
+
+ +

+ So I can make the following + call to turn off autocompilation for the SCOTT schema: +

+ +
+SQL> exec utconfig.autocompile (FALSE, 'SCOTT')
+
+ +

+ This program updates the ut_config table with your information and then + commits the setting. +

+ +

+ You can determine the current + setting for auto-compilation at any time by calling the following function: +

+ +
+   FUNCTION utConfig.autocompiling (username_in IN VARCHAR2 := NULL)
+      RETURN BOOLEAN;
+
+ +

+ Note: When you set the schema-level recompilation + value to FALSE, that will override anything you pass in a call to utPLSQL.test + or utPLSQL.testsuite. +

+ +

V2 Delimiter

+ +

You can set the delimiter to be used in V2 procedure names using the following procedure:

+ +
+PROCEDURE setdelimiter (
+  delimiter_in IN VARCHAR2, 
+  username_in IN VARCHAR2 := NULL
+); 
+
+ +

while the current delimiter can be obtained by the function:

+ +
+FUNCTION delimiter (username_in IN VARCHAR2 := NULL)
+  RETURN VARCHAR2;
+
+ +

Turn off the display of successful test results

+ +

+ By default, the results of all the tests are shown. This includes both successful and unsuccessful + results. The following procedure allows you to limit the tests shown to only those that have failed: +

+ +
+PROCEDURE showfailuresonly (
+     onoff_in      IN   BOOLEAN,
+     username_in   IN   VARCHAR2 := NULL
+   );
+
+ +

the current setting can be obtained by the function:

+ +
+FUNCTION showingfailuresonly (username_in IN VARCHAR2 := NULL)
+      RETURN BOOLEAN;
+
+ +

Set and Get the default output reporter

+ +

+ By default, all results are sent to the screen via DBMS_OUTPUT. However, it is possible to use other output reporters as described in more detail + on this page. The following procedure allows you to set which output reporter should be used by default: +

+ +
+PROCEDURE setreporter (
+      reporter_in   IN   VARCHAR2
+     ,username_in   IN   VARCHAR2 := NULL
+   );
+
+ +

as usual, the current setting can be obtain by the following function:

+ +
+FUNCTION getreporter (username_in IN VARCHAR2 := NULL)
+      RETURN VARCHAR2;
+
+ + + + + diff --git a/documentation/src/utgen.html b/documentation/src/utgen.html new file mode 100644 index 000000000..0ce2eebc8 --- /dev/null +++ b/documentation/src/utgen.html @@ -0,0 +1,812 @@ + + + + + + + + + +

utGen Package

+ +

This package contains the following procedures and functions:

+ + + + + + + + + + + + + + + + + + +
utGen.testpkg (basic version)Generate skeleton test packages
+ utGen.testpkg (grid version)
+ utGen.testpkg_from_file
+ utGen.testpkg_from_string +
Generate skeleton test packages with test cases
utGen.pkgstringGet skeleton as a string
+ utGen.countRows +
utGen.firstRow +
utGen.firstBodyRow +
utGen.atFirstRow +
utGen.lastRow +
utGen.atLastRow +
utGen.setRow +
utGen.getRow +
utGen.nextRow +
utGen.prevRow +
utGen.showRows +
utGen.nthRow +
Get rows from generated skeleton test package as array
+ +

Generate Skeleton Test Packages

+ +

+ The utGen contains a procedure that allows you to generate a starting point + for a unit test package. This package can be sent to the screen, + a file, a delimited string or + an array (best for interfacing with a front end). + You can generate a stand-alone test package or code "fragments" to be placed + inside an existing source package. +

+ +

+ We strongly recommend that you use utGen.testpkg + as a starting point for all of your utPLSQL unit test construction. By + taking this approach, you will most easily (and transparently) conform + to the most up to date guidelines for utPLSQL test packages. +

+ +

+ Note: While utGen.testpkg goes as far as + possible to generate sensible unit test code, you will need to edit this + code before you can compile and use it. +

+ +

Here is the header of the testpkg procedure:

+ +
+   PROCEDURE utGen.testpkg (
+      package_in IN VARCHAR2,
+      program_in IN VARCHAR2 := '%',
+      samepackage_in IN BOOLEAN := FALSE,
+      prefix_in IN VARCHAR2 := NULL,
+      schema_in IN VARCHAR2 := NULL,
+      output_type_in IN PLS_INTEGER := c_screen,
+      dir_in IN VARCHAR2 := NULL,
+      delim_in IN VARCHAR2 := c_delim
+   );
+
+ +

And here is a description of the parameters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter NameUsage
package_in + The name of the package or stand-alone program for + which a test package is to be generated. +
program_in + The filter to be applied to the list of programs + for which unit test procedures will be generated. So if you only wanted + to generate unit tests for programs that start with "UPD", you would pass + 'UPD%' for this argument. +
samepackage_in + TRUE if you plan to insert the generated code into + the source package, FALSE if you want a stand-alone test package. +
prefix_in + The prefix to be used for the test package and/or + unit test procedures. See section " Organizing Your Test Code" for details. +
schema_in + The schema that owns the package or program specified + by package_in. The default is the currently connected schema. +
output_type_in + The type of output that will receive the generated + code. Valid options are defined as packaged constants: +
    +
  • utGen.c_file
  • +
  • utGen.c_screen
  • +
  • utGen.c_string
  • +
  • utGen.c_array
  • +
+ The following sections explain the way you would + work with these constants and the resulting generated code. +
dir_in + The location of the file containing the generated + code. Used only if you specify utGen.c_file for the output type. +
delim_in + The delimiter used to separate lines of generated + code. Used only if you specify utGen.c_string for the output type. +
+ +

+ Before you use utGen.testpkg, you should make a few + decisions about your generated code: +

+ +
    +
  • + Do you want the generated test code to be a stand-alone package or to be + inserted into an existing package? The default is stand-alone. Pass TRUE + for samepackage_in if you want to generate code that can be easily cut + and pasted into your source package. Note that utGen.testpkg does not + actually modify your source package. +
  • + +
  • + Do you want to generate a unit test program + for every procedure and function in your package? If so, then go with the + default for program_in. If, on the other hand, your package has one hundred + programs and you only want to test, say, only those programs that perform + updates, you might want to pass a non-trivial filter, such as "UPD%". +
  • + +
  • + Where do you want to send your output? You + can display to the screen, which can then be grabbed and put into a file + (or in SQL*Plus spool it directly to a file). You can send the code to + a file. You can deposit the code in a delimited string and then parse it + within your own environment. Finally -- and of most relevance if you are + building a GUI interface to utPLSQL -- you can generate to an internal + array and then retrieve individual rows of the arrays through the utGen + API. +
  • +
+ +

Here are some examples of using utGen.testpkg:

+ +
    +
  1. + Generate to the screen a stand-alone test package for the STR package: +
  2. +
+ +
+
+
+SQL> exec utGen.testpkg ('str')
+
+
+
+ +
    +
  1. + Generate to the screen unit test code to be embedded inside the STR package: +
  2. +
+ +
+
+
+SQL> exec utGen.testpkg ('str', samepackage_in => TRUE)
+
+
+
+ +
    +
  1. + Generate to the screen unit test code for all programs whose names contain + "STR" to be embedded inside the STR package,. +
  2. +
+ +
+
+
+SQL> exec utGen.testpkg ('str', '%STR%', samepackage_in => TRUE)
+
+
+
+ +

+ Now let's explore how to direct the generated code + to different types of output. +

+ +

Generating to Screen

+ +

+ The default behavior of utGen.testpkg is to generate + code to your screen (via DBMS_OUTPUT.PUT_LINE). So unless you specify some + other value for output_type_in, the code will be displayed on your screen + or within a window of your PL/SQL IDE (such as TOAD or SQL*Programmer and + so on). You can then transfer that content to a file, or move it to another + window for immediate editing and compilation. +

+

+ Here is an example of using utGen.testpkg, while + also spooling to a file: +

+ +
+SQL> set serveroutput on size 1000000
+SQL> spool str.pkg
+SQL> exec utgen.testpkg ('str')
+
+ +

...out comes the code...

+ +
+SQL> spool off
+
+ +

+ If DBMS_OUTPUT is not enabled in your session, then + utGen.testpkg will not generate any output. +

+ +

Generating to File

+ +

+ If you are working with utGen in a command line + style (ie, you are not using a utGen-enabled GUI), then you will probably + find it most useful to generate testing code directly to file. You do this + by specifying utGen.c_file for the output type. You must also specify the + directory in which you want the files (one for the package specification + and another for the body)created. +

+ +

+ Here's a generation request that creates two files + named ut_str.pks and ut_str.pkb in the /newcode directory: +

+ +
+SQL> exec utgen.testpkg ('str', output_type_in => utGen.c_file, dir_in => '/newcode')
+
+ +

Notes on generating to file:

+ +
    +
  1. + You do not have to specify a directory if you have previously (in your + current session) called utConfig.setdir to set the default directory for + all file-related utPLSQL operations. The following two lines of code are, + in other words, equivalent to the single line shown above: +
  2. +
+ + +
+
+
+SQL> exec utconfig.setdir ('/newcode')
+SQL> exec utgen.testpkg ('str', output_type_in => utGen.c_file);
+
+
+
+ +
    +
  1. + You set up the UTL_FILE package (add at least one utl_file_dir entry in + your database parameter initialization file) and make sure your directory + is accessible through UTL_FILE, before this operation can succeed. +
  2. +
+ +

Generating to String

+ +

+ If you are accessing utPLSQL functionality through + a GUI, you might find it more useful to direct output to a string (or array, + see next section). You probably don't want to hassle with UTL_FILE (server-based + file IO) and grabbing information from DBMS_OUTPUT.PUT_LINE is just a general + hassle. +

+ +

+ If you generate to a string, you can then retrieve + that string value into a local variable and then parse it for display and + manipulation. Here is an example of redirection to string: +

+ +
+BEGIN
+   utgen.testpkg ('str', output_type_in => utGen.c_string);
+END;
+
+ +

+ The generated code is composed of multiple lines + of information, so they need to be separated by a delimiter. The default + delimiter is the vertical bar, '|'. You can override that and provide your + own delimiter. In the following example, I have decided to use the carriage + return character as my delimiter: +

+ +
+BEGIN
+   utgen.testpkg (
+      'str',
+      output_type_in => utGen.c_string,
+      delim_in => CHR(10));
+END;
+
+ +

+ Great, so the code has been put in a string. How + do you get all that generated code? Call the utGen.pkgstring function: +

+ +
+FUNCTION utGen.pkgString RETURN VARCHAR2;
+
+ +

Generating to Array

+ +

+ If you are accessing utPLSQL functionality through + a GUI, you might find it more useful to direct output to an array. You + probably don't want to hassle with UTL_FILE (server-based file IO) and + grabbing information from DBMS_OUTPUT.PUT_LINE is just a general hassle. +

+ +

+ If you generate to an array, you can then retrieve + the individual lines of code in the array through an API provided by utGen + (the array itself is "hidden"). Here is an example of redirection to the + utGen array: +

+ +
+BEGIN
+   utgen.testpkg ('str', output_type_in => utGen.c_array);
+END;
+
+ +

+ Great, so the code has been put in an array. How + do you get all that generated code? Take advantage of the utGen + API to retrieve individual rows in the array, which offers these features: +

+ +

Get the number of rows currently in the array:

+ +
+   FUNCTION utGen.countRows RETURN PLS_INTEGER;
+
+ +

Get the absolute index of the first row in the array:

+ +
+   FUNCTION utGen.firstRow RETURN PLS_INTEGER;
+
+ +

Get the absolute index of the last row in the array:

+ +
+   FUNCTION utGen.lastRow RETURN PLS_INTEGER;
+
+ +

+ The API offers a set of programs to iterate through + the array, by maintaining a "current row" inside the package. You can: +

+ +

+ Find out if you are positioned at the first row + in the set: +

+ +
+   FUNCTION utGen.atFirstRow RETURN BOOLEAN;
+
+ +

+ Find out if you are positioned at the last row in + the set: +

+ +
+   FUNCTION utGen.atLastRow RETURN BOOLEAN;
+
+ +

+ Find the first relative row containing the start + of the package body definition. This is handy when you want to put the + code for the specification and body in separate windows and/or files: +

+ +
+   FUNCTION utGen.firstBodyRow RETURN PLS_INTEGER;
+
+ +

+ Retrieve the text in the Nth row of the array. This + gives you "random access" to the contents of the array. You can even specify + a negative direction to get the Nth row from the end of the array. +

+ +
+   FUNCTION utGen.nthRow (nth IN PLS_INTEGER, direction utGen.IN SIGNTYPE := 1) RETURN codeline_t;
+
+ +

+ Set the pointer in the array to the specified row + number. This allows you then move either forward or backward from that + row in the array (using nextRow and prevRow, respectively): +

+ +
+   PROCEDURE utGen.setRow (nth IN PLS_INTEGER);
+
+ +

+ Retrieve the line of code stored in the current + row in the array (set via setRow, nextRow or prevRow): +

+ +
+   FUNCTION utGen.getRow RETURN codeline_t;
+
+ +

Go to the next row in the array:

+ +
+   PROCEDURE utGen.nextRow;
+
+ +

Go to the previous row in the array:

+ +
+   PROCEDURE utGen.prevRow;
+
+ +

Show the contents of the array using DBMS_OUTPUT.PUT_LINE:

+ +
+   PROCEDURE utGen.showRows (
+      startRow IN PLS_INTEGER := NULL,
+      endRow IN PLS_INTEGER := NULL);
+
+ +

+ Here is the code I would write in PL/SQL using this + API to display the contents of the array (actually, it is the implementation + of showRows): +

+ +
+   PROCEDURE showrows (
+      startrow IN PLS_INTEGER := NULL,
+      endrow IN PLS_INTEGER := NULL
+   )
+   IS
+      v_start PLS_INTEGER
+                    := NVL (startrow, 1);
+      v_end PLS_INTEGER
+         := NVL (endrow, utGen.countRows);
+   BEGIN
+      FOR indx IN 1 .. utGen.countRows
+      LOOP
+         DBMS_OUTPUT.put_line (utGen.getRow (indx));
+      END LOOP;
+   END;
+
+ +

+ Here is the code I would write to separate out the + contents of the specification from the body: +

+ +
+   PROCEDURE showrows (
+      startrow IN PLS_INTEGER := NULL,
+      endrow IN PLS_INTEGER := NULL
+   )
+   IS
+      v_start PLS_INTEGER
+                    := NVL (startrow, 1);
+      v_end PLS_INTEGER
+         := NVL (endrow, utGen.countRows);
+   BEGIN
+      FOR indx IN 1 .. utGen.countRows
+      LOOP
+         IF indx = utGen.firstBodyRow
+         THEN
+            -- switch to Body window or file
+         END IF;
+         write_to_target (utGen.getRow (indx));
+      END LOOP;
+   END;
+
+ + +

Generating Test Packages with Test Cases

+ +

+ The procedures to generate test packages with test cases are similar to + testpkg above, but with a number of extra parameters: +

+ +
+ PROCEDURE testpkg (
+      package_in           IN   VARCHAR2,
+      grid_in              IN   grid_tt,
+      program_in           IN   VARCHAR2 := '%',
+      samepackage_in       IN   BOOLEAN := FALSE,
+      prefix_in            IN   VARCHAR2 := NULL,
+      schema_in            IN   VARCHAR2 := NULL,
+      output_type_in       IN   PLS_INTEGER := c_screen,
+      dir_in               IN   VARCHAR2 := NULL,
+      delim_in             IN   VARCHAR2 := c_delim,
+      date_format_in       IN   VARCHAR2 := 'MM/DD/YYYY',
+      only_if_in_grid_in   IN   BOOLEAN := FALSE
+   );
+
+   PROCEDURE testpkg_from_file (
+      package_in           IN   VARCHAR2,
+      gridfile_loc_in      IN   VARCHAR2,
+      gridfile_in          IN   VARCHAR2,
+      program_in           IN   VARCHAR2 := '%',
+      samepackage_in       IN   BOOLEAN := FALSE,
+      prefix_in            IN   VARCHAR2 := NULL,
+      schema_in            IN   VARCHAR2 := NULL,
+      output_type_in       IN   PLS_INTEGER := c_screen,
+      dir_in               IN   VARCHAR2 := NULL,
+      field_delim_in       IN   VARCHAR2 := '|',
+      arg_delim_in         IN   VARCHAR2 := c_delim,
+      date_format_in       IN   VARCHAR2 := 'MM/DD/YYYY',
+      only_if_in_grid_in   IN   BOOLEAN := FALSE
+   );
+
+   PROCEDURE testpkg_from_string (
+      package_in           IN   VARCHAR2,
+      grid_in              IN   VARCHAR2,
+      program_in           IN   VARCHAR2 := '%',
+      samepackage_in       IN   BOOLEAN := FALSE,
+      prefix_in            IN   VARCHAR2 := NULL,
+      schema_in            IN   VARCHAR2 := NULL,
+      output_type_in       IN   PLS_INTEGER := c_screen,
+      dir_in               IN   VARCHAR2 := NULL,
+      line_delim_in        IN   VARCHAR := CHR (10),
+      field_delim_in       IN   VARCHAR2 := '|',
+      arg_delim_in         IN   VARCHAR2 := c_delim,
+      date_format_in       IN   VARCHAR2 := 'MM/DD/YYYY',
+      only_if_in_grid_in   IN   BOOLEAN := FALSE
+   );
+
+ +

+ In each case, the idea is the same. We have to provide not only the + arguments supplied to the basic version of testpkg, but also details of each of + the test cases in a grid. In the first case, this is as a PL/SQL table, in the + second this is as a file and in the final case, this is as a string. +

+ +

The PL/SQL table passed to testpkg is defined as follows:

+ +
 
+TYPE grid_rt IS RECORD (
+      progname                      VARCHAR2 (100),
+      overload                      PLS_INTEGER,
+      tcname                        VARCHAR2 (100),
+      message                       VARCHAR2 (2000),
+      arglist                       VARCHAR2 (2000),
+      return_value                  VARCHAR2 (2000),
+      assertion_type                VARCHAR2 (100));
+
+   TYPE grid_tt IS TABLE OF grid_rt
+      INDEX BY BINARY_INTEGER; 
+
+ +

Where the definitions of the fields are as follows:

+ +
    +
  1. progname - This is the name of the subprogram to be tested.
  2. +
  3. + overload - This is the version of the subprogram where + overladed versions exist. (You may have to look in the data dictionary to + work this out). +
  4. +
  5. tcname - The name of the test case.
  6. +
  7. message - The message to be used in the assertion code.
  8. +
  9. arglist - The list of arguments to be passed to the subprogram.
  10. +
  11. return_value - The return value to be checked against.
  12. +
  13. + assertion_type - The type of assertion to be used. + Currently this is ignored unless it contains 'EQ' or 'ISNULL' +
  14. +
+ +

+ In testpkg_from_file and testpkg_from_string, exactly the same fields need + to be passed (and in the same order). These fields are separated by the + character given by the field_delim_in parameter which defaults to '|', the pipe + symbol. In the case of testpkg_from_string, we can also specify the line + delimiter in the line_delim_in parameter, which defaults to an ASCII linefeed + character. +

+ +

+ In all cases, the arguments specified in the arglist field are separated + by yet another delimiter, which is passed in the arg_delim_in parameter ( + or just delim_in in the case of testpkg). This defaults to a semicolon. +

+ +

+ The remaining arguments passed to these routines are date_format_in and + only_if_in_grid_in. The former gives the date format used in dates passed + through the arglist and return_values fields. The latter specifies if + tests should only be generated for subprograms listed in the grid or not. +

+ +

An Example

+ +

All of this is probably best explained with an example. Suppose I have a package defined as:

+ +
+CREATE OR REPLACE PACKAGE lottery AS
+  FUNCTION Draw (seed_in NUMBER := NULL, when_in DATE := NULL) RETURN VARCHAR2;
+END;
+
+ +

+ This returns a string describing a lottery draw, given a seed and a date. I + want to test the following conditions: (It doesn't make much sense, but hey, + it's only an example) +

+ +
    +
  • Passing both parameters as NULL, we should get back '01 02 03 04 05 06'.
  • +
  • Passing in 7 for the seed and 1 January 2001 for the date, we should get back '23 24 27 37 39 48'.
  • +
  • Passing in 0 for the seed and today's date, we should get back NULL
  • +
+ +

So to generate the skeleton I require I could run the following through SQL*Plus:

+ +
+set serveroutput on size 1000000
+declare
+  a_grid utgen.grid_tt;
+begin
+  
+  a_grid(0).progname := 'Draw';
+  a_grid(0).tcname := 'Test Case 1';
+  a_grid(0).message := 'The First Test';
+  a_grid(0).return_value := '01 02 03 04 05 06';
+  a_grid(0).assertion_type := 'EQ';
+  a_grid(1).progname := 'Draw';
+  a_grid(1).tcname := 'Test Case 2';
+  a_grid(1).message := 'The Second Test';
+  a_grid(1).arglist := '7;2001-01-01';
+  a_grid(1).return_value := '23 24 27 37 39 48';
+  a_grid(1).assertion_type := 'EQ';
+  a_grid(2).progname := 'Draw';
+  a_grid(2).tcname := 'Test Case 3';
+  a_grid(2).message := 'The Third Test';
+  a_grid(2).return_value := NULL;
+  a_grid(2).arglist := '0;!SYSDATE';
+  a_grid(2).assertion_type := 'ISNULL';
+  
+  utgen.testpkg(
+    package_in => 'LOTTERY', 
+    grid_in => a_grid, 
+    date_format_in => 'YYYY-MM-DD');
+end;
+/
+ +

or the equivalent:

+ +
+set serveroutput on size 1000000
+begin
+  utgen.testpkg_from_string (
+      package_in => 'LOTTERY',
+      grid_in =>
+'Draw||Test Case 1|The First Test||01 02 03 04 05 06|EQ
+Draw||Test Case 2|The Second Test|7;2001-01-01|23 24 27 37 39 48|EQ
+Draw||Test Case 3|The Third Test|0;!SYSDATE||ISNULL',
+      date_format_in => 'YYYY-MM-DD'
+   );
+end;
+/ 
+
+ +

which generate the following for the body of ut_draw (tidied up a little for compactness):

+ +
+PROCEDURE ut_DRAW
+IS
+   -- Verify and complete data types.
+   against_this VARCHAR2(2000);
+   check_this VARCHAR2(2000);
+BEGIN
+   
+   -- Define "control" operation for "Test Case 1"
+   against_this := '01 02 03 04 05 06';
+    
+   -- Execute test code for "Test Case 1"
+   check_this := 
+   LOTTERY.DRAW (SEED_IN => '', WHEN_IN => '');
+    
+   -- Assert success for "Test Case 1"
+   -- Compare the two values.
+   utAssert.eq ( 'The First Test', check_this, against_this);
+
+   -- End of test for "Test Case 1"
+   
+   -- Define "control" operation for "Test Case 2"
+   against_this := '23 24 27 37 39 48';
+    
+   -- Execute test code for "Test Case 2"
+   check_this := LOTTERY.DRAW (SEED_IN => 7, WHEN_IN => TO_DATE ('2001-01-01', 'YYYY-MM-DD'));
+    
+   -- Assert success for "Test Case 2"
+   -- Compare the two values.
+   utAssert.eq ( 'The Second Test', check_this, against_this);
+
+   -- End of test for "Test Case 2"
+   
+   -- Define "control" operation for "Test Case 3"
+   against_this := NULL;
+    
+   -- Execute test code for "Test Case 3"
+   check_this := 
+   LOTTERY.DRAW (SEED_IN => 0, WHEN_IN => SYSDATE);
+    
+   -- Assert success for "Test Case 3"
+   -- Check for NULL return value.
+   utAssert.isNULL ( 'The Third Test', check_this);
+
+   -- End of test for "Test Case 3"
+   
+END ut_DRAW;
+
+ +

+ Note that the different data types are handled automatically. So '2001-01-01' is converted to + a date using TO_DATE and the specified date format. However, we wanted to enter SYSDATE for our + argument in one of these cases. How do we stop this being converted into a date? The answer + is that we need to prefix the value with a '!' (an exclamation mark). This causes utGen to + pass this along 'as is' without attempting any conversion. Note that this cannot currently + be overridden, so if your data starts with an exclamation mark, you'll have to work around + this problem. +

+ + + + diff --git a/documentation/src/utoutput.html b/documentation/src/utoutput.html new file mode 100644 index 000000000..0d422fbee --- /dev/null +++ b/documentation/src/utoutput.html @@ -0,0 +1,201 @@ + + + + + + + + + +

utOutput Package

+ +

This package contains the following procedures and functions:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
utOutput.saveTurn on the 'save' flag
utOutput.nosaveTurn off the 'save' flag
utOutput.savingReturn the 'save' flag
utOutput.extractPull text from the DBMS_OUTPUT buffer
utOutput.replaceReplace saved output in the DBMS_OUTPUT buffer
utOutput.nextLinePull the next line from the DBMS_OUTPUT buffer
utOutput.countCount the lines in the DBMS_OUTPUT buffer
+ +

Outline of Usage

+ +

+ The problem with attempting to test output in PL/SQL is that there is a single + DBMS_OUTPUT buffer. When your test is run, there may already be output in the + buffer from other tests, or from the tested code. So what state should you + leave it in once you have finished? Perhaps you want all the output created by + your tested code to end up in the buffer as if it had been run normally (i.e. + not from within utPLSQL), or maybe you want only the text that was in the + buffer before you started to be left. +

+ +

+ This package attempts to allow to do any of these. There is a flag in the + package to determine whether text pulled from the output buffer should be + saved. This is set with 'save' and 'nosave' and returned by + 'saving'. Data is pulled from the buffer using 'extract', + while the procedure 'replace' puts any saved data back into the output + buffer. +

+ +

The intent is that it is used like this:

+ +
+PROCEDURE ut_my_test IS
+BEGIN
+
+  --Pull out any text already in the output buffer
+  utoutput.save;
+  utoutput.extract;
+
+  --Your testing code here, with saving turned on or off as you see fit
+
+  --Put text back in the output buffer 
+  utoutput.replace;
+
+END;
+
+ +

+ So to start with, we save any text already in the buffer. We then carry out + our testing. If we want the output generated by the testing to end up back in + the output buffer, we turn on saving. Finally, we put the saved text back. +

+ +

Warning

+ +

+ In the current version of utPLSQL (2.0.9.1) use of this package is virtually impossible with + utPLSQL tracing turned on. The reason for this is that this facility writes output using + DBMS_OUTPUT every time an assertion is called. +

+ +

Saving Output

+ +

The three routines for handling the save flag are:

+ +
+PROCEDURE save;
+
+PROCEDURE nosave;
+
+FUNCTION saving RETURN BOOLEAN;
+
+ +

+ Quite simply, 'save' turns the flag on, 'nosave' turns it off and 'saving' + returns its current value. +

+ +

Extracting Output

+ +

There are 4 versions of the extract routine to get text from the output buffer:

+ +
+FUNCTION extract (
+   buffer_out    OUT DBMS_OUTPUT.CHARARR,
+   max_lines_in  IN INTEGER := NULL,
+   save_in       IN BOOLEAN := saving
+) RETURN INTEGER;
+
+PROCEDURE extract (
+   buffer_out    OUT DBMS_OUTPUT.CHARARR,
+   max_lines_in  IN INTEGER := NULL,
+   save_in       IN BOOLEAN := saving
+);
+
+FUNCTION extract(
+   max_lines_in  IN INTEGER := NULL,
+   save_in       IN BOOLEAN := saving
+) RETURN INTEGER;
+
+PROCEDURE extract(
+   max_lines_in  IN INTEGER := NULL,
+   save_in       IN BOOLEAN := saving
+);
+
+ +

+ The function versions return the number of lines extracted from the + DBMS_OUTPUT buffer. The other parameters are used as follows: +

+ +
    +
  • buffer_out - This is a buffer in which to put the extracted text.
  • +
  • max_lines_in - This is the maximum number of lines to be extracted. If NULL is passed in (the default) then all the lines are extracted.
  • +
  • save_in - This specifies if the extracted output should be saved. It overrides the global save flag.
  • +
+ +

Replacing Output

+ +

The replace procedure takes no parameters:

+ +
+PROCEDURE replace;   
+
+ +

+ It simply puts the saved text back into the DBMS_OUTPUT buffer. Note that + the buffer is emptied at this point. +

+ +

Checking Output Line-by-Line

+ +

+ The nextLine function makes it easy to check output line-by-line as it + simply extracts and returns the next line of output: +

+ +
+FUNCTION nextLine(
+  raise_exc_in BOOLEAN := TRUE, 
+  save_in BOOLEAN := saving
+) RETURN VARCHAR2;   
+
+ +

+ The raise_exc_in flag determines if the function should throw the + exception utOutput.EMPTY_OUTPUT_BUFFER when asked for the next line from + an empty buffer. If no exception is thrown, NULL is returned. As with + extract, the save_in flag simply overrides the global save flag setting. +

+ +

Size of Output

+ +

This function simply counts the number of lines present in the output buffer:

+ +
+FUNCTION count RETURN INTEGER;   
+
+ +

Note that the output itself is left untouched.

+ + + + diff --git a/documentation/src/utplsql.css b/documentation/src/utplsql.css new file mode 100644 index 000000000..fe4a5d0e5 --- /dev/null +++ b/documentation/src/utplsql.css @@ -0,0 +1,39 @@ +/* utPLSQL Stylesheet */ +/*$Id$*/ + +/* For top-level headings and utPLSQL logo, we want a + purple bar across the page */ +H1, .purple_bar {font-family: Arial, Helvetica, Sans-Serif; + color: #ffffff; + background: #800080; + margin-left: 0px; + margin-right: 0px; + padding-left: 10px; + padding-top: 5px; + padding-bottom: 5px} + +/* Second level headings in purple */ +H2 {font-family: Arial, Helvetica, Sans-Serif; + color: #800080} + +/* Other headings in Sans Serif Font */ +H3, H4, H5, H6 {font-family: Arial, Helvetica, Sans-Serif} + +/* Pre formatted code is in a gray box, in monotype */ +Pre {font-family: Courier, Monotype; + font-size: smaller; + color: #000000; + background: #f0f0f0; + margin-left: 20px; + margin-right: 20px; + padding-left: 10px; + padding-top: 5px; + padding-bottom: 5px; + padding-right: 10px} + +/* Code in monotype */ +Code {font-family: Courier, Monotype; + font-size: smaller;} + +/* Copyright notice is tiny */ +.copyright {font-size: xx-small} diff --git a/documentation/src/utplsql.html b/documentation/src/utplsql.html new file mode 100644 index 000000000..061e45788 --- /dev/null +++ b/documentation/src/utplsql.html @@ -0,0 +1,672 @@ + + + + + + + + + +

utPLSQL Package

+ +

The utPLSQL package offers the following capabilities:

+ + + + + + + + + + + + + + + + + + + + + + +
+ utPLSQL.test
+ utPLSQL.run +
+ Run a test +
+ utPLSQL.testsuite
+ utPLSQL.runsuite +
+ Run a test suite +
+ utPLSQL.version + + Get the version of utPLSQL +
+ utPLSQL.trc
+ utPLSQL.notrc
+ utPLSQL.tracing +
+ Control utPLSQL's tracing mechanism +
+ utPLSQL.addtest + + Register a unit test in a test package +
+ +

Run a Test or Test Suite

+ +

+ With utPLSQL, you can run all the unit tests contained in a + single test package, or run the tests for a series of test packages defined in + a test suite. +

+ +

+ The utPLSQL package offers two procedures, test and testsuite, to make it + easy for you to run "red light, green light" tests. Before you can + use these programs, however, you must build + your own test package. +

+ +

To run a test for a single package, use the utPLSQL.test procedure:

+ +
+PROCEDURE utPLSQL.test (
+   package_in IN VARCHAR2,
+   samepackage_in IN BOOLEAN := FALSE,
+   prefix_in IN VARCHAR2 := NULL,
+   recompile_in IN BOOLEAN := TRUE,
+   dir_in IN VARCHAR2 := NULL,
+   suite_in in VARCHAR2 := NULL,
+   owner_in IN VARCHAR2 := NULL,
+   reset_results_in IN BOOLEAN := TRUE ,
+   from_suite_in         IN   BOOLEAN := FALSE,
+   subprogram_in         IN   VARCHAR2 := '%',
+   per_method_setup_in   IN   BOOLEAN := FALSE
+);
+
+ +

where the parameters are defined as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ package_in + + The name of the package or stand-alone program to be tested. +
+ samepackage_in + + Pass TRUE if your unit test programs are defined in the same + package as the source code to be tested. The default is that you have created + a separate package. +
+ prefix_in + + The prefix to be appended to package_in to come up with + the name of the test package. If you do not provide a value, the last prefix + you specified (or the default) will be used. +
+ recompile_in + + Pass FALSE if you do not want utPLSQL to automatically recompile your test package + before running the test. +
+ dir_in + + The directory containing the test package source code. If + you do not provide a value in your call to utPLSQL.test (the default) and if + you have not turned off automatic recompilation, utPLSQL will look for the + test package source code in the directory specified by a call to utConfig.setdir. If you do not provide a + value, the last directory you specified (if any) will be used. +
+ suite_in + + The name of the suite that contains the specified test + package. This is an optional value and is used to update statistics + for the test. +
+ owner_in + + The name of the schema that was specified when the test + suite was defined and the packaged added to the suite. This is an + optional value and is used to update statistics for + the test. +
+ reset_results_in + + Pass FALSE to tell utPLSQL to not reset the results + information, in which case you will still be able to view results by calling utResult.show . Otherwise, utPLSQL clears the result + data after each test. +
+ from_suite_in + + Pass TRUE to tell utPLSQL that this test is being run from + within a test suite (for internal use only). +
+ subprogram_in + + Pass a string to restrict which of the test procedures + will be executed for this run. Default of % means all tests will be run. +
+ per_method_setup_in + + Pass TRUE to run the setup and teardown procedure before + and after each unit test procedure is executed. Default of FALSE means that + these programs will be run once, at the start and end of the package test + execution as a whole. +
+ override_package_in + + Override the automatic determination of package names thus removing the + one to one relationship between test package and package to test. + Default is NULL. Instead of using this parameter consider the procedure run. +
+ +

Here are some examples of using the utPLSQL.test procedure:

+ +

+ 1. Run the unit test for the betwnstr function (by executing the ut_betwnstr + test package, since the default prefix is used). Do not recompile the test + package. +

+ +
+SQL> exec utPLSQL.test ('betwnstr', recompile_in => FALSE)
+
+ +

+ 2. Run all of the unit tests for the te_employee package, + stored in a test package called "test_te_employee" in the /tmp + directory. Recompile the test package before execution. +

+ +
+SQL> exec utPLSQL.test ('te_employee', prefix_in => 'test_', dir_in => '/tmp')
+
+ +

+ 3. Run all the unit tests for the corporate_polluters + package, located in the same package as the source code. +

+ +
+SQL> exec utPLSQL.test ('te_employee', samepackage_in => TRUE)
+
+ +

+ Since utPLSQL follows the red light-green light approach on + reporting results, each time you run utPLSQL.test, it will display the results. + If successful, you will see output like this: +

+ +
+SUCCESS: "betwnstr"
+
+ +

If the test fails at some point, you will see output like this:

+ +
+FAILURE: "betwnstr"
+BETWNSTR: IS NULL: NULL start
+BETWNSTR: End larger than string length; expected "cdeg", got "cdefg"
+
+ + +

Running a Test the other way

+ +

+ The normal usage of the test procedure as described above assumes that for + each package you want to test, say mypackage, has a package for + testing this package having the same name but with an additional prefix: + ut_mypackage. Instead of using this approach, you can use the procedure + run. This procedure runs a test package directly without any further + conditions on the name or other packages. The only condition that still applies + is the naming conventions necessary to make it a valid test package. +

+ +
+PROCEDURE run (
+    testpackage_in      IN VARCHAR2,
+    prefix_in           IN VARCHAR2 := NULL,
+    suite_in            IN VARCHAR2 := NULL,
+    owner_in            IN VARCHAR2 := NULL,
+    reset_results_in    IN BOOLEAN  := TRUE,
+    from_suite_in       IN BOOLEAN  := FALSE,
+    subprogram_in       IN VARCHAR2 := '%',
+    per_method_setup_id IN BOOLEAN  := FALSE);
+
+ +

where the parameters are defined as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ test_package_in + + The name of the test package to run. +
+ prefix_in + + The prefix to be appended to package_in to come up with + the name of the test package. If you do not provide a value, NULL is used as + a default. i.e. the package name is used as provided in the first parameter +
+ suite_in + + The name of the suite that contains the specified test + package. This is an optional value and is used to update statistics + for the test. +
+ owner_in + + The name of the schema that was specified when the test + suite was defined and the packaged added to the suite. This is an + optional value and is used to update statistics for + the test. +
+ reset_results_in + + Pass FALSE to tell utPLSQL to not reset the results + information, in which case you will still be able to view results by calling utResult.show . Otherwise, utPLSQL clears the result + data after each test. +
+ from_suite_in + + Pass TRUE to tell utPLSQL that this test is being run from + within a test suite (for internal use only). +
+ subprogram_in + + Pass a string to restrict which of the test procedures + will be executed for this run. Default of '%' means all tests will be run. +
+ per_method_setup_in + + Pass TRUE to run the setup and teardown procedure before + and after each unit test procedure is executed. Default of FALSE means that + these programs will be run once, at the start and end of the package test + execution as a whole. +
+ + + +

Running a Test Suite

+ +

+ In addition to running a test for a single test package, you + can set up a test suite that consists of one or more test packages. You can + then run an entire suite of tests with a call to utPLSQL.testsuite: +

+ +
+PROCEDURE utPLSQL.testsuite (
+   suite_in IN VARCHAR2,
+   recompile_in IN BOOLEAN := TRUE,
+   reset_results_in IN BOOLEAN := TRUE
+   per_method_setup_in in BOOLEAN := FALSE
+   );
+
+ +

+ where suite_in is the name of the suite and recompiled_in + determines the auto compilation behavior. +

+ +

+ Here is an example of the call I would make to run all my tests for the + PL/Vision library: +

+ +
+SQL> exec utplsql.testsuite ('plvision');
+
+ +

+ The parameter list for utPLSQL.testSuite is much shorter + than utPLSQL.test; rather than pass information like directory, owner name and + same-package through a parameter list, you define these characteristics in the + suite itself (stored in a series of utPLSQL tables). +

+ +

+ Before you can test an entire suite, you must define + the suite. +

+ + +

Running a Test Suite the other way

+ +

+ Similiar to the run procedure for single packages, there is the + runsuite procedure to run testsuites. When you use this procedure + there is no relationship assumed between the names of test packages specified in the + test suite and the procedures to be tested. +

+ +
+PROCEDURE utPLSQL.runsuite (
+   suite_in IN VARCHAR2,
+   reset_results_in IN BOOLEAN := TRUE
+   per_method_setup_in in BOOLEAN := FALSE
+   );
+
+ +

+ The usage of the parameters is just as in testsuite. +

+ + +

Recording and Accessing Test Statistics

+ +

+ If you have defined test suites, and packages within those + test suites, utPLSQL will update those definitions with the follow statistics + after each test is run: +

+ +
    +
  • Status of last run: success or failure?
  • +
  • Start and end times of last run
  • +
  • Total number of failures
  • +
  • Total number of executions of the test
  • +
+ +

+ All of this is done for you automatically. You can then write queries and reports against the + ut_package and ut_suite tables. +

+ + +

Return utPLSQL version

+ +

+ Run the utPLSQL.version function to return the version of + utPLSQL you have installed: +

+ +
+FUNCTION utPLSQL.version RETURN VARCHAR2
+
+ +

utPLSQL Trace

+ +

These routines are very simple and take no arguments:

+ +
+PROCEDURE trc;
+
+PROCEDURE notrc;
+
+FUNCTION tracing RETURN BOOLEAN;
+
+ +

+ The procedures trc and notrc are used to turn tracing on and off + respectively. The function tracing returns TRUE if tracing is currently turned + on and FALSE otherwise. This facility is useful when writing code in utPLSQL + (the framework itself, not your test code). An example of the output generated + is: +

+ +
+Initialized utPLSQL session...
+Setpkg to Lottery
+Package and program = ut_Lottery
+Same package? N
+Is package? Y
+Prefix = ut_
+Recompiling ut_Lottery in
+Runprog of ut_SETUP
+Package and program = ut_Lottery.ut_SETUP
+Same package? N
+Is package? Y
+Prefix = ut_
+Addtest
+Package and program = Lottery.UT_DRAW
+Same package? N
+Override? Y
+Prefix = ut_
+Runprog of UT_DRAW
+Package and program = ut_Lottery.UT_DRAW
+Same package? N
+Is package? Y
+Prefix = ut_
+.
+>  FFFFFFF   AA     III  L      U     U RRRRR   EEEEEEE
+>  F        A  A     I   L      U     U R    R  E
+>  F       A    A    I   L      U     U R     R E
+>  F      A      A   I   L      U     U R     R E
+>  FFFF   A      A   I   L      U     U RRRRRR  EEEE
+>  F      AAAAAAAA   I   L      U     U R   R   E
+>  F      A      A   I   L      U     U R    R  E
+>  F      A      A   I   L       U   U  R     R E
+>  F      A      A  III  LLLLLLL  UUU   R     R EEEEEEE
+.
+FAILURE: "Lottery"
+.
+> Individual Test Case Results:
+>
+FAILURE - EQ "Test of DRAW" Expected "01 02 05 27 43 49" and got "02 04 27 28 31 33"
+>
+>
+> Errors recorded in utPLSQL Error Log:
+>
+> NONE FOUND
+Runprog of ut_TEARDOWN
+Package and program = ut_Lottery.ut_TEARDOWN
+Same package? N
+Is package? Y
+Prefix = ut_
+
+PL/SQL procedure successfully completed.
+
+ +

Register a Unit Test

+ +

+ As of version 1.4.1, you + no longer have to explicitly register a unit test! The default + behavior of utPLSQL is now to extract from the data dictionary (via the + ALL_ARGUMENTS data dictionary view) the names of all the unit test procedures + you have defined, and then run them. utPLSQL identifies these programs by + looking for all programs whose names start with the specified prefix. +

+ +

+ If you decide that you want to explicitly register your unit + tests, then you will need to turn on manual registration: +

+ +
+SQL> exec utConfig.registertest (TRUE)
+
+ +

+ This setting is immediately saved in the database for your + schema. To turn off manual registration: +

+ +
+SQL> exec utConfig.registertest (FALSE)
+
+ +

+ So read no further unless you have turned on manual + registration! You might do this, for example, if you have already built a + number of test packages in a version of utPLSQL prior to 1.4.1 and do not want + to make any changes to your test package code. +

+ +

+ All aspects of manual registration of unit tests for a + program or package actually occur within the Unit Test Package itself, in the setup procedure. No persistent unit test information + is stored between runs of the unit test, unless you define that unit test + within a test suite. +

+ +

Use the utPLSQL.addtest procedure to register a unit test.

+ +
+   PROCEDURE utPLSQL.addtest (
+      NAME_IN IN VARCHAR2,
+      utprefix_in IN VARCHAR2,
+      iterations_in IN PLS_INTEGER := 1
+   );
+ 
+   PROCEDURE utPLSQL.addtest (
+      package_in IN VARCHAR2,
+      NAME_IN IN VARCHAR2,
+      utprefix_in IN VARCHAR2,
+      iterations_in IN PLS_INTEGER := 1
+   );
+
+ +

where

+ +

+ name_in is the name of the program you are + testing. Note that this is the name of the unit test procedure itself, + including the unit test prefix.. +

+ +

+ utprefix_in is the prefix to be applied to + name_in to construct the unit tst procedure. This is currently NOT IN USE; only + the package prefix specified in your call to utPLSQL.test and utPLSQL.testsuite + is used. +

+ +

+ iterations_in is the number of times you wish to + run the test (currently NOT IN USE). +

+ +

+ package_in is the name of the package containing + the unit test procedure. If you provide a package name when you call + utPLSQL.addtest, you will override the package name set when you called + utPLSQL.test -- but only for that one test. We recommend that you not change + the package name. +

+ +

+ Here is a setup procedure that sets up a series of tests for + a query-only encapsulation of the employee table: +

+ +
+CREATE OR REPLACE PACKAGE BODY ut_te_employee
+IS
+   PROCEDURE ut_setup
+   IS
+   BEGIN
+      utplsql.addtest ('UT_EMP_DEPT_LOOKUPROWCOUNT');
+      utplsql.addtest ('UT_EMP_JOB_LOOKUPROWCOUNT');
+      utplsql.addtest ('UT_EMP_MGR_LOOKUPROWCOUNT');
+      utplsql.addtest ('UT_HIRE_DATE$VAL');
+      utplsql.addtest ('UT_I_EMPLOYEE_NAME$ROW');
+      utplsql.addtest ('UT_I_EMPLOYEE_NAME$VAL');
+      utplsql.addtest ('UT_ONEROW');
+      utplsql.addtest ('UT_PKYROWCOUNT');
+      utplsql.addtest ('UT_ROWCOUNT');
+      utplsql.addtest ('UT_SALARY$VAL');
+   END;
+
+ +

+ Once you have placed your addtest programs into your test + package's setup procedure, you are ready to build your own unit tests. +

+ + + + + + diff --git a/documentation/src/utplsql.jpg b/documentation/src/utplsql.jpg new file mode 100644 index 000000000..288ee2622 Binary files /dev/null and b/documentation/src/utplsql.jpg differ diff --git a/documentation/src/utreceq.html b/documentation/src/utreceq.html new file mode 100644 index 000000000..46836d968 --- /dev/null +++ b/documentation/src/utreceq.html @@ -0,0 +1,116 @@ + + + + + + + + + +

utRecEq Package

+ +

This package contains the following procedures and functions:

+ + + + + + + + + + + + + + +
utRecEq.addAdd a record type comparison function
utRecEq.compileCompile a package's record type comparison functions
utRecEq.remRemove record type comparison functions
+ +

Generate functions to compare record types

+ +

+ This package (created by Dan Spencer) allows the creation of functions to + allow the comparison of record types based on tables or views (%ROWTYPE + records in other words). They are generated by the add procedure: +

+ +
+PROCEDURE add(
+   pkg_name_in IN ut_package.name%TYPE,
+   record_in  IN ut_receq.name%TYPE,
+   rec_owner_in  IN ut_receq.created_by%TYPE := USER
+);
+
+ +

+ The pkg_name_in parameter contains the name of a tested package you wish to + associate with this record type. Note that this package name should already + exist in the ut_package table. The record_in parameter contains the name of + the view or table whose record type is to be compared. The final (optional) + parameter contains the name of the schema in which the table or view exists. + It defaults to the current user. +

+ +

+ The generated function will be named EQ_{Record_Schema_}Record_Name. The + schema is only inserted when the record type is not within the current one. The + function will return TRUE if the two records are identical on a field-by-field + comparison and FALSE otherwise. Note that NULL fields are considered + equal. +

+ +

+ The details of the EQ_* functions and their association with tested packages held in two tables: +

+ +
    +
  • + UT_RECEQ - This table holds a list of the EQ_* functions including the + target table/view and the schema in which it is found. +
  • +
  • + UT_RECEQ_PKG - This table cross-references the tested packages against the functions listed in UT_RECEQ. +
  • +
+ +

Compile a package's record comparison functions

+ +

This routine recompiles all the EQ_* functions associated with a given package:

+ +
+PROCEDURE compile(pkg_name_in IN ut_package.name%TYPE);
+
+ +

+ when autocompiling is turned on, this is called by + utplsql.test or utplsql.testsuite before the test packages themselves are recompiled. +

+ +

Remove record comparison functions

+ +

To remove record comparison functions, use the following:

+ +
+PROCEDURE rem(
+   name_in  IN ut_receq.name%TYPE,
+   rec_owner_in   IN ut_receq.created_by%TYPE := USER
+   for_package_in IN BOOLEAN := FALSE
+);
+
+ +

+ If for_package_in is FALSE, then name_in is taken to refer to a record type to + remove, with rec_owner_in specifying the schema the record type is in. All package associations for this record type are removed and the EQ_* function is dropped. +

+ +

+ On the other hand, if for_package_in is TRUE, then name_in is taken to refer + to a package. In this case, all the package's associations are removed. If no + other package is associated with a given record, then the EQ_* function is + dropped. (Note that the rec_owner_in parameter is ignored here). +

+ + + + diff --git a/documentation/src/utresult.html b/documentation/src/utresult.html new file mode 100644 index 000000000..e99f66b40 --- /dev/null +++ b/documentation/src/utresult.html @@ -0,0 +1,168 @@ + + + + + + + + + +

utResult Package

+ +

This package contains the following procedures and functions:

+ + + + + + + + + + + + + + + + + + + + + + +
+ utResult.init + + Initialize the results data +
+ utResult.show +
utResult.showone +
utResult.showlast +
+ Show results +
+ utResult.success +
utResult.failure +
+ Show the success or failure of the last test +
+ utResult.firstresult +
utResult.nextresult +
utResult.nthresult +
utResult.resultcount +
+ Iterate through the results array +
+ utResult.include_successes
+ utResult.ignore_successes +
+ Control the display of passed tests +
+ +

+ The utResult package offers an API to the information + sent by the various utAssert assertion routines after a test is run. If + you employ the utPLSQL.test and utPLSQL.testsuite to run your tests, then + the results will be displayed by calling the utResult.show procedure. +

+

+ So, generally, you do not have to do anything to see or evaluate the results of + a test (or suite of tests). The information will be displayed on your screen + using DBMS_OUTPUT, or elsewhere if you use a custom output reporter. You might, + however, want to access this information in another environment (say, Oracle + Forms or Java, etc.). You might also want to build your own assertion logic or + test engine. In either of these cases, you will want to use the programs in the + utResult package. +

+ +

Initialize

+ +

Initialize the utResult data, setting it all back to NULL:

+ +
+PROCEDURE utResult.init;
+
+ +

Show Results

+ +

Show the results of your test with one of the following three procedures.

+ +
+PROCEDURE utResult.show (reset_in IN BOOLEAN := FALSE);
+PROCEDURE utResult.showone (indx_in in pls_integer);
+PROCEDURE utResult.showlast;
+
+ +

+ Use the show procedure to display the full set of results stored + in the utResult array. If you pass TRUE for its single argument, the results + informatino will be initialized. +

+ +

Use the showone procedure to show the Nth result.

+ +

Use the showlast procedure to show the results of the last test run.

+ +

Retrieve Test Status

+ +

+ The success and failure functions return the status of the most recently + executed test. +

+ +
+FUNCTION utResult.success RETURN BOOLEAN;
+FUNCTION utResult.failure RETURN BOOLEAN;
+
+ +

Scan Results Array

+ +

+ The utPLSQL.show procedure iterates through the contents of the utResult + array and displays the information found there. You can write the same + kind of logic by calling a combination of the following programs: +

+ +
+PROCEDURE utResult.firstresult;
+
+FUNCTION utResult.nextresult RETURN utResult.result_rt;
+
+PROCEDURE utResult.nextresult (
+   name_out OUT VARCHAR2,
+   msg_out OUT VARCHAR2,
+   case_indx_out OUT PLS_INTEGER
+);
+
+FUNCTION utResult.nthresult (indx_in IN PLS_INTEGER)
+   RETURN utResult.result_rt;
+
+PROCEDURE utResult.nthresult (
+   indx_in IN PLS_INTEGER,
+   name_out OUT VARCHAR2,
+   msg_out OUT VARCHAR2,
+   case_indx_out OUT PLS_INTEGER
+);
+
+FUNCTION utResult.resultcount RETURN PLS_INTEGER;
+
+ +

Control the Display of Success Messages

+ +

+ The following procedures turn on or off the display of success messages. In other words, + when turned on (as is the default) a message will be displayed for each successful assertion. + The specifications are as follows: +

+ +
+procedure include_successes;
+procedure ignore_successes; 
+
+ + + + diff --git a/documentation/src/writedoc.html b/documentation/src/writedoc.html new file mode 100644 index 000000000..376fc10b6 --- /dev/null +++ b/documentation/src/writedoc.html @@ -0,0 +1,149 @@ + + + + + How to add to the utPLSQL documentation set + + + +

Writing Documentation

+ +

+ The utPLSQL documentation is built from a series of simple HTML files in the + src directory. These files have none of the navigation bars, logos or + next/previous links which appear in the final documentation. They are also + stripped of font, color and style information at compile-time to let the + stylesheet (utplsql.css) determine the overall look-and-feel. +

+ +

+ Like the code, the documentation is held within GIT. + Changes should be made to the documentation/src directory. + Details on how to change and submit the changes back to the + project can be found in the CONTRIBUTING.md +

+ +

The HTML Files

+ +

+ As described above, the base files in the src directory are used to generate the final + product. To add new documentation to one of these files, or to correct errors, + simply edit it. It makes sense to follow the layout that is already present in the + file, adding links at the top of the page where appropriate. The HTML should be + kept simple, so use the relevant header styles (<H1>...<H6>) to label your sections + and subsections, use <pre> to mark sections of code etc. Let the stylesheet + do the work of setting the colors and fonts. +

+ +

+ If you are adding an entirely new file to the documentation, use the file + template.html as a basis. This contains the relevant comment + lines which tell the scripts which parts of the file to use + (see the note below). Finally, you will need to + edit map.txt to ensure that the file is linked from the other pages in + the documentation. This is described in the next section. +

+ +

The Control Files

+ +

+ The files are compiled into a documentation set situated in the top-level + documentation directory using the 3 control files: map.txt, authors.txt and copyright_years.txt. + The first of these is the driving file, giving a list of the files to be + included. The second gives a list of authors to be included in the copyright + notice on each page and referenced in the Meta tags (this is for + historical reasons and lists the original contributors of the + documentation - to keep it in line with the policy for source-code, all + future contributions will go under the name of "the utPLSQL Project"). The + third file lists the years for the copyright statement - i.e. years when + significant changes were published. +

+ +

The format of map.txt is as follows:

+ +
+   # Any line starting with a # is 
+   # considered a comment
+   #
+   index.html,Home*
+   started.html,Getting Started*
+   another.html,Further Docs
+   another2.html,Yet more docs
+
+ +

+ Each line consists of the filename to be included and the title of the page, + separated with a comma. Any file whose title is followed by an asterisk is + considered the start of a new section. This means a link to the file will + appear in the navigation bar at the top of each page and it will appear in + bold in the document map. Note that the document map itself does not appear + in map.txt, but is always added at the end and is considered a new section. + This page is entirely generated at compile-time. +

+ +

+ To add a new page to the documentation, simply add it to this file in the + correct position. Note that generally you will not be adding a new section! +

+ +

The format of authors.txt is as follows:

+ +
+   # Again, lines starting # are ignored
+   #
+   Steven Feuerstein,steven@stevenfeuerstein.com
+   Chris Rimmer,c@24.org.uk
+   A N Other,ano@ther.net
+
+ +

+ Each line in this file simply gives the name of the author and their email + address, separated with a comma. So if you've made a contribution and your name + is not listed, add it! +

+ +

The format of copyright_years.txt is as follows:

+ +
+   # Again, lines starting # are ignored
+   #
+   2000-2005
+   2014
+
+ +

+ Each line will be separated by a comma in the copyright statement, so the + above will generate: "2000-2005, 2014" +

+ +

The Scripts

+ +

+ The Perl script used to build the documentation is build_docs.pl. +

+ +

+ The script goes through each file listed in map.txt, cleans it up + and then adds logos, navigation bars, next/previous links, + copyright information etc. The resulting files are put in the top-level + documentation directory. +

+ +

+ The "cleaning" strips the source HTML files down to the basics, removing + everything from the header and removing Javascript, fonts, color, etc. It + requires the HTML::TagFilter module which in turn also requires the + HTML::Parser and HTML::Tagset modules (all available from search.cpan.org). +

+ +

+ NOTE: Anything within a source file before the + <!-- Begin utPLSQL Body --> comment line and after the + <!-- End utPLSQL Body --> comment line is ignored. +

+ +

Copyright 2002, 2014 Chris Rimmer and the utPLSQL Project. All rights reserved

+ + + diff --git a/examples/GEN_UT_BETWNSTR.PRC b/examples/GEN_UT_BETWNSTR.PRC new file mode 100644 index 000000000..82a014bff --- /dev/null +++ b/examples/GEN_UT_BETWNSTR.PRC @@ -0,0 +1,19 @@ +CREATE OR REPLACE PROCEDURE gen_ut_betwnstr +IS + utc VARCHAR2 (1000) + := '#program name|test case name|message|arguments|result|assertion type +betwnstr|normal|normal|abcdefgh;3;5|cde|eq +betwnstr|zero start|zero start|abcdefgh;0;2|abc|eq +betwnstr|null start|null start|abcdefgh;!null;2|null|isnull +betwnstr|null end|null end|abcdefgh;!3;!null|null|isnull'; +BEGIN + utconfig.setdir ('d:\openoracle\utplsql\examples'); + utconfig.showconfig; + utgen.testpkg_from_string ('betwnstr', + utc, + output_type_in=> utgen.c_file, + dir_in=> 'd:\openoracle\utplsql\examples' + ); +END; +/ + diff --git a/examples/RunAllExamples.sql b/examples/RunAllExamples.sql deleted file mode 100644 index f5f42b7f3..000000000 --- a/examples/RunAllExamples.sql +++ /dev/null @@ -1,10 +0,0 @@ -PROMPT Run all examples -set echo on -set feedback on -set linesize 1000 - --- Examples for users -@@RunUserExamples.sql - --- Framework developer examples -@@RunDeveloperExamples.sql diff --git a/examples/RunAllExamplesAsTests.sql b/examples/RunAllExamplesAsTests.sql deleted file mode 100644 index d089ba447..000000000 --- a/examples/RunAllExamplesAsTests.sql +++ /dev/null @@ -1,9 +0,0 @@ -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -@@RunAllExamples.sql - -prompt ******************************************************************************* -prompt All examples completed successfully -prompt ******************************************************************************* -prompt diff --git a/examples/RunCustomReportersExamples.sql b/examples/RunCustomReportersExamples.sql deleted file mode 100644 index 730946662..000000000 --- a/examples/RunCustomReportersExamples.sql +++ /dev/null @@ -1,10 +0,0 @@ -prompt ******************************************************************************* -prompt Running custom reporters examples -prompt ******************************************************************************* -Clear Screen -set echo off -set feedback on -set linesize 1000 - -@@custom_reporters/run_ut_custom_reporter.sql -@@custom_reporters/run_ut_expectations_reporter.sql diff --git a/examples/RunDeveloperExamples.sql b/examples/RunDeveloperExamples.sql deleted file mode 100644 index 2f4ca13e3..000000000 --- a/examples/RunDeveloperExamples.sql +++ /dev/null @@ -1,14 +0,0 @@ -PROMPT Run developer examples -Clear Screen -set echo on -set feedback on -set linesize 1000 - -exec ut_ansiconsole_helper.color_enabled(true); ---developer examples -prompt RunExampleTestAnnotationsParsingTimeHugePackage -@@developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql -prompt RunExampleTestSuite -@@developer_examples/RunExampleTestSuite.sql -prompt RunExampleTestSuiteWithCompositeReporter -@@developer_examples/RunExampleTestSuiteWithCompositeReporter.sql diff --git a/examples/RunExampleTestAnnotationBasedForCurrentSchema.sql b/examples/RunExampleTestAnnotationBasedForCurrentSchema.sql deleted file mode 100644 index 02f77970a..000000000 --- a/examples/RunExampleTestAnnotationBasedForCurrentSchema.sql +++ /dev/null @@ -1,14 +0,0 @@ ---Clear Screen -Set Serveroutput On Size Unlimited format truncated -set echo off ---install the example unit test packages -@@test_pkg1.pck -@@test_pkg2.pck - -begin - ut.run(); -end; -/ - -drop package test_pkg1; -drop package test_pkg2; diff --git a/examples/RunExpectations.sql b/examples/RunExpectations.sql deleted file mode 100644 index eed123e72..000000000 --- a/examples/RunExpectations.sql +++ /dev/null @@ -1,25 +0,0 @@ ---Shows how to create a test suite with the default reporter which is dbms_output ---No tables are used for this. ---Suite Management packages are when developed will make this easier. ---Clear Screen -Set Serveroutput On Size Unlimited format truncated -set linesize 10000 -set echo off ---install the example unit test packages -@@department.tps -@@departments.tps -@@demo_expectations.pck - -begin - ut_coverage.coverage_start(sys_guid()); - ut_coverage.set_develop_mode(true); - ut.run(); - ut_coverage.set_develop_mode(false); - ut_coverage.coverage_stop(); -end; -/ - -drop package demo_expectations; -drop type departments$; -drop type department$; - diff --git a/examples/RunUserExamples.sql b/examples/RunUserExamples.sql deleted file mode 100644 index 702ccbce8..000000000 --- a/examples/RunUserExamples.sql +++ /dev/null @@ -1,23 +0,0 @@ -PROMPT Run user examples -set echo on -set feedback on -set linesize 1000 - -prompt Common examples from web - -exec ut_ansiconsole_helper.color_enabled(true); -@@award_bonus/run_award_bonus_test.sql - -@@between_string/run_betwnstr_test.sql - -@@remove_rooms_by_name/run_remove_rooms_by_name_test.sql - -@@demo_of_expectations/run.sql - -prompt Additional examples -prompt RunExampleTestAnnotationBasedForCurrentSchema -@@RunExampleTestAnnotationBasedForCurrentSchema.sql -prompt RunExpectations -@@RunExpectations.sql - -@@RunWithDocumentationReporter.sql diff --git a/examples/RunWithDocumentationReporter.sql b/examples/RunWithDocumentationReporter.sql deleted file mode 100644 index 84a863f1f..000000000 --- a/examples/RunWithDocumentationReporter.sql +++ /dev/null @@ -1,93 +0,0 @@ -Set Serveroutput On Size Unlimited format truncated -set linesize 10000 -set echo off - -create or replace package demo_doc_reporter1 is - -- %suite - -- %displayname(Demo of documentation reporter) - - -- %test - -- %displayname(A passing test sample) - procedure passing_test; - -- %test - procedure test_without_name; - -- %test - -- %displayname(A failing test exsample) - procedure failing_test; - -- %test - procedure failing_no_name; - -- %test - -- %displayname(repoting exception) - procedure failing_exception_raised; -end; -/ - -create or replace package body demo_doc_reporter1 is - - procedure passing_test is begin null; end; - - procedure test_without_name is - begin - ut.expect(1).to_equal(1); - end; - - procedure failing_test is - begin - ut.expect(1).to_equal(2); - end; - procedure failing_no_name is - begin - ut.expect(sysdate).to_equal(to_char(sysdate)); - end; - procedure failing_exception_raised is - l_date date; - begin - l_date := to_date('abcd'); - end; -end; -/ - -create or replace package demo_doc_reporter2 is - -- %suite - -- %displayname(A suite package without body) - - -- %test - -- %displayname(A test) - procedure test1; - -- %test - procedure test2; -end; -/ - -create or replace package suite_package_without_name is - -- %suite - - -- %test - -- %displayname(A passing test sample) - procedure passing_test1; - -- %test - -- %displayname(A passing test sample) - procedure passing_test2; -end; -/ - -create or replace package body suite_package_without_name is - - procedure passing_test1 is begin null; end; - - procedure passing_test2 is - begin - ut.expect(1).to_equal(1); - end; -end; -/ - -begin - ut.run(); -end; -/ - - -drop package demo_doc_reporter2; -drop package suite_package_without_name; -drop package demo_doc_reporter1; diff --git a/examples/TESTIT.PRC b/examples/TESTIT.PRC new file mode 100644 index 000000000..da3fb43af --- /dev/null +++ b/examples/TESTIT.PRC @@ -0,0 +1,9 @@ +CREATE OR REPLACE PROCEDURE testit (prog_in IN VARCHAR2, recompile_in in boolean := true) +IS +BEGIN + utconfig.setdir ('d:\openoracle\utplsql\examples'); + utconfig.showconfig; + utplsql.test (prog_in, recompile_in => recompile_in); +END; +/ + diff --git a/examples/award_bonus/award_bonus.sql b/examples/award_bonus/award_bonus.sql deleted file mode 100644 index 787d5cfa4..000000000 --- a/examples/award_bonus/award_bonus.sql +++ /dev/null @@ -1,20 +0,0 @@ ---https://docs.oracle.com/database/sql-developer-4.2/RPTUG/sql-developer-unit-testing.htm#RPTUG45065 - - -create or replace procedure award_bonus (emp_id number, sales_amt number) as - commission real; - comm_missing exception; -begin - select commission_pct into commission - from employees_test - where employee_id = emp_id; - - if commission is null then - raise comm_missing; - else - update employees_test - set salary = nvl(salary,0) + sales_amt*commission - where employee_id = emp_id; - end if; -end; -/ diff --git a/examples/award_bonus/employees_test.sql b/examples/award_bonus/employees_test.sql deleted file mode 100644 index de46d31b0..000000000 --- a/examples/award_bonus/employees_test.sql +++ /dev/null @@ -1,7 +0,0 @@ -create table employees_test (employee_id number primary key, commission_pct number, salary number); -insert into employees_test values (1001, 0.2, 8400); -insert into employees_test values (1002, 0.25, 6000); -insert into employees_test values (1003, 0.3, 5000); --- next employee is not in the sales department, thus is not on commission. -insert into employees_test values (1004, null, 10000); -commit; diff --git a/examples/award_bonus/run_award_bonus_test.sql b/examples/award_bonus/run_award_bonus_test.sql deleted file mode 100644 index 7acbcdc08..000000000 --- a/examples/award_bonus/run_award_bonus_test.sql +++ /dev/null @@ -1,11 +0,0 @@ -@@employees_test.sql -@@award_bonus.sql -@@test_award_bonus.pkg - -set serveroutput on size unlimited format truncated - -exec ut.run(user||'.test_award_bonus'); - -drop package test_award_bonus; -drop procedure award_bonus; -drop table employees_test; diff --git a/examples/award_bonus/test_award_bonus.pkg b/examples/award_bonus/test_award_bonus.pkg deleted file mode 100644 index 5927310b3..000000000 --- a/examples/award_bonus/test_award_bonus.pkg +++ /dev/null @@ -1,84 +0,0 @@ -create or replace package test_award_bonus as - - -- %suite - -- %displayname(Award bonus) - - -- %test - -- %displayname(Sets new salary as pct commission * sales amount) - -- %beforetest(add_test_employee) - procedure update_employee_salary; - - -- %test - -- %displayname(Raises exception if null bonus is passed) - -- %beforetest(add_employee_with_null_comm) - procedure fail_on_null_bonus; - - procedure add_test_employee; - - procedure add_employee_with_null_comm; - -end; -/ -create or replace package body test_award_bonus as - - gc_test_employee constant integer := -1; - gc_salary constant number := 4500; - gc_commision_pct constant number := 0.2; - - procedure update_employee_salary is - results sys_refcursor; - expected sys_refcursor; - not_affected sys_refcursor; - c_sales_amount constant number := 1000; - begin - --arrange - open expected for - select (salary + c_sales_amount * gc_commision_pct) as new_salary - from employees_test where employee_id = gc_test_employee; - - open not_affected for - select * from employees_test where employee_id <> gc_test_employee; - - --act - award_bonus(emp_id => gc_test_employee, sales_amt => c_sales_amount); - - --assert - open results for - select salary as new_salary - from employees_test where employee_id = gc_test_employee; - - ut.expect( results ).to_equal( expected ); - - open results for - select * from employees_test where employee_id != gc_test_employee; - - ut.expect( results ).to_equal( not_affected ); - end; - - procedure fail_on_null_bonus is - begin - award_bonus(emp_id => gc_test_employee, sales_amt => null); - ut.expect( sqlcode ).not_to_equal( 0 ); - exception - when others then - ut.expect( sqlcode ).not_to_equal( 0 ); - end; - - procedure add_employee( emp_id number, comm_pct number, sal number ) is - begin - insert into employees_test (employee_id, commission_pct, salary) - values (emp_id, comm_pct, sal); - end; - - procedure add_test_employee is - begin - add_employee(gc_test_employee, 0.2, gc_salary); - end; - - procedure add_employee_with_null_comm is - begin - add_employee(gc_test_employee, null, gc_salary); - end; - -end; -/ diff --git a/examples/between_string/betwnstr.sql b/examples/between_string/betwnstr.sql deleted file mode 100644 index dcdf343d8..000000000 --- a/examples/between_string/betwnstr.sql +++ /dev/null @@ -1,9 +0,0 @@ -create or replace function betwnstr( a_string varchar2, a_start_pos integer, a_end_pos integer ) return varchar2 is - l_start_pos pls_integer := a_start_pos; -begin - if l_start_pos = 0 then - l_start_pos := 1; - end if; - return substr( a_string, l_start_pos, a_end_pos - l_start_pos + 1); -end; -/ diff --git a/examples/between_string/run_betwnstr_test.sql b/examples/between_string/run_betwnstr_test.sql deleted file mode 100644 index 31edc52cf..000000000 --- a/examples/between_string/run_betwnstr_test.sql +++ /dev/null @@ -1,11 +0,0 @@ -@@betwnstr.sql -@@test_betwnstr.pks -@@test_betwnstr.pkb - -set serveroutput on size unlimited format truncated - -exec ut.run(user||'.test_betwnstr'); - -drop package test_betwnstr; -drop function betwnstr; - diff --git a/examples/between_string/run_betwnstr_test_coverage.sql b/examples/between_string/run_betwnstr_test_coverage.sql deleted file mode 100644 index 098445cae..000000000 --- a/examples/between_string/run_betwnstr_test_coverage.sql +++ /dev/null @@ -1,22 +0,0 @@ -set trimspool on -set linesize 32767 -set pagesize 0 -set long 200000000 -set longchunksize 1000000 -@@betwnstr.sql -@@test_betwnstr.pks -@@test_betwnstr.pkb - -set serveroutput on size unlimited format truncated - -set feedback off -set termout off -spool coverage.html -exec ut.run(user, ut_coverage_html_reporter(a_project_name=>'Demo of between string function tests', a_include_object_list=>ut_varchar2_list('betwnstr'))); -spool off - - -drop package test_betwnstr; -drop function betwnstr; - -exit diff --git a/examples/between_string/test_betwnstr.pkb b/examples/between_string/test_betwnstr.pkb deleted file mode 100644 index f872f6447..000000000 --- a/examples/between_string/test_betwnstr.pkb +++ /dev/null @@ -1,29 +0,0 @@ -create or replace package body test_betwnstr as - - procedure normal_case is - begin - ut.expect( betwnstr( '1234567', 2, 5 ) ).to_equal('2345'); - end; - - procedure zero_start_position is - begin - ut.expect( betwnstr( '1234567', 0, 5 ) ).to_equal('12345'); - end; - - procedure big_end_position is - begin - ut.expect( betwnstr( '1234567', 0, 500 ) ).to_equal('1234567'); - end; - - procedure null_string is - begin - ut.expect( betwnstr( null, 2, 5 ) ).to_be_null; - end; - - procedure disabled_test is - begin - ut.expect( betwnstr( null, null, null) ).not_to_be_null; - end; - -end; -/ diff --git a/examples/between_string/test_betwnstr.pks b/examples/between_string/test_betwnstr.pks deleted file mode 100644 index 7b98d0005..000000000 --- a/examples/between_string/test_betwnstr.pks +++ /dev/null @@ -1,22 +0,0 @@ -create or replace package test_betwnstr as - - -- %suite(Between string function) - - -- %test(Returns substring from start position to end position) - procedure normal_case; - - -- %test(Returns substring when start position is zero) - procedure zero_start_position; - - -- %test(Returns string until end if end position is greater than string length) - procedure big_end_position; - - -- %test(Returns null for null input string value) - procedure null_string; - - -- %test(Demo of a disabled test) - -- %disabled - procedure disabled_test; - -end; -/ diff --git a/examples/betwnstr.sf b/examples/betwnstr.sf new file mode 100644 index 000000000..205f42c86 --- /dev/null +++ b/examples/betwnstr.sf @@ -0,0 +1,18 @@ +CREATE OR REPLACE FUNCTION betwnstr ( + string_in IN VARCHAR2, + start_in IN INTEGER, + end_in IN INTEGER +) + RETURN VARCHAR2 +IS + l_start PLS_INTEGER := start_in; +BEGIN + IF l_start = 0 + THEN + l_start := 1; + END IF; + + RETURN (SUBSTR (string_in, l_start, end_in - l_start + 1)); +END; +/ + diff --git a/examples/bewtnstr.utc b/examples/bewtnstr.utc new file mode 100644 index 000000000..b7349d9c5 --- /dev/null +++ b/examples/bewtnstr.utc @@ -0,0 +1,5 @@ +#program name|test case name|message|arguments|result|assertion type +betwnstr|Normal|Typical valid usage|abcdefg;2;5|bcde|eq +betwnstr|ZeroStart|Zero start value|abcdefg;0;5|abcde|eq +betwnstr|BigEnd|Way big end value|abcdefg;5;500|efg|eq +betwnstr|NULLstart|NULL start value|;5;500|null|isnull diff --git a/examples/calc_secs_between.sp b/examples/calc_secs_between.sp new file mode 100644 index 000000000..3aac1c686 --- /dev/null +++ b/examples/calc_secs_between.sp @@ -0,0 +1,10 @@ +CREATE OR REPLACE PROCEDURE calc_secs_between ( + date1 IN DATE, + date2 IN DATE, + secs OUT NUMBER +) +IS +BEGIN + secs := (date2 - date1) * 24 * 60 * 60; +END; +/ diff --git a/examples/custom_reporters/run_ut_custom_reporter.sql b/examples/custom_reporters/run_ut_custom_reporter.sql deleted file mode 100644 index dbb142ce1..000000000 --- a/examples/custom_reporters/run_ut_custom_reporter.sql +++ /dev/null @@ -1,16 +0,0 @@ -prompt ******************************************************************************* -prompt Runnign tests with UT_CUSTOM_REPORTER on top of UT_DOCUMENTATION_REPROTER -prompt ******************************************************************************* - -set echo off ---install the example unit test packages -@demo_of_expectations/demo_equal_matcher.sql -@@ut_custom_reporter.tps -@@ut_custom_reporter.tpb - -set serveroutput on size unlimited format truncated - -exec ut.run('demo_equal_matcher', ut_custom_reporter()); - -@demo_of_expectations/drop_demo_equal_matcher.sql -drop type ut_custom_reporter; diff --git a/examples/custom_reporters/run_ut_expectations_reporter.sql b/examples/custom_reporters/run_ut_expectations_reporter.sql deleted file mode 100644 index 90b1ff9ff..000000000 --- a/examples/custom_reporters/run_ut_expectations_reporter.sql +++ /dev/null @@ -1,16 +0,0 @@ -prompt ******************************************************************************* -prompt Runnign tests with UT_CUSTOM_REPORTER on top of UT_DOCUMENTATION_REPROTER -prompt ******************************************************************************* - -set echo off ---install the example unit test packages -@demo_of_expectations/demo_equal_matcher.sql -@@ut_expectations_reporter.tps -@@ut_expectations_reporter.tpb - -set serveroutput on size unlimited format truncated - -exec ut.run('demo_equal_matcher', ut_expectations_reporter()); - -@demo_of_expectations/drop_demo_equal_matcher.sql -drop type ut_expectations_reporter; diff --git a/examples/custom_reporters/ut_custom_reporter.tpb b/examples/custom_reporters/ut_custom_reporter.tpb deleted file mode 100644 index 48e8f4a96..000000000 --- a/examples/custom_reporters/ut_custom_reporter.tpb +++ /dev/null @@ -1,49 +0,0 @@ -create or replace type body ut_custom_reporter is - - constructor function ut_custom_reporter(a_tab_size integer default 4) return self as result is - begin - self.init($$plsql_unit); - self.lvl := 0; - self.tab_size := a_tab_size; - self.failed_test_running_count := 0; - return; - end; - - overriding member function tab(self in ut_custom_reporter) return varchar2 is - tab_str varchar2(255); - begin - tab_str := rpad(' ', lvl * tab_size); - return tab_str; - end tab; - - overriding member procedure print_text(a_text varchar2, a_item_type varchar2 := null) is - begin - (self as ut_documentation_reporter).print_text(tab || a_text, a_item_type); - end; - - overriding member procedure before_calling_suite(self in out nocopy ut_custom_reporter, a_suite ut_logical_suite) as - begin - (self as ut_documentation_reporter).before_calling_suite(a_suite); - lvl := lvl + 1; - end; - - overriding member procedure before_calling_test(self in out nocopy ut_custom_reporter, a_test ut_test) as - begin - (self as ut_documentation_reporter).before_calling_test(a_test); - lvl := lvl + 1; - end; - - overriding member procedure after_calling_test(self in out nocopy ut_custom_reporter, a_test ut_test) as - begin - lvl := lvl - 1; - (self as ut_documentation_reporter).after_calling_test(a_test); - end; - - overriding member procedure after_calling_suite(self in out nocopy ut_custom_reporter, a_suite ut_logical_suite) as - begin - lvl := lvl - 1; - (self as ut_documentation_reporter).after_calling_suite(a_suite); - end; - -end; -/ diff --git a/examples/custom_reporters/ut_custom_reporter.tps b/examples/custom_reporters/ut_custom_reporter.tps deleted file mode 100644 index 0cc3d67ed..000000000 --- a/examples/custom_reporters/ut_custom_reporter.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_custom_reporter under ut_documentation_reporter -( - tab_size integer, - --- Member functions and procedures - constructor function ut_custom_reporter(a_tab_size integer default 4) return self as result, - - /* The reporter is using base functions of parent type ( UT_DOCUMENTATION_REPORTER ) - It is altering the behavior of the base functions by change of the indentation. - So the custom reporter is same as documentation reporter except that the tab size is bigger. - Additionally, the reporter constructor accepts parameter to indicate the indentation size - */ - overriding member function tab(self in ut_custom_reporter) return varchar2, - overriding member procedure print_text(a_text varchar2, a_item_type varchar2 := null), - overriding member procedure before_calling_suite(self in out nocopy ut_custom_reporter, a_suite ut_logical_suite), - overriding member procedure before_calling_test(self in out nocopy ut_custom_reporter, a_test ut_test), - overriding member procedure after_calling_test(self in out nocopy ut_custom_reporter, a_test ut_test), - overriding member procedure after_calling_suite(self in out nocopy ut_custom_reporter, a_suite ut_logical_suite) -) -not final -/ diff --git a/examples/custom_reporters/ut_expectations_reporter.tpb b/examples/custom_reporters/ut_expectations_reporter.tpb deleted file mode 100644 index af9cceb28..000000000 --- a/examples/custom_reporters/ut_expectations_reporter.tpb +++ /dev/null @@ -1,149 +0,0 @@ -create or replace type body ut_expectations_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2020 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_expectations_reporter(a_report_all_expectations varchar2 := 'Y')return self as result is - begin - self.init($$plsql_unit); - self.lvl := 0; - self.report_all_expectations := substr(a_report_all_expectations,1,1); - self.failed_test_running_count := 0; - return; - end; - - /* The reporter procedure after_calling_test from ut_documentation_reporter is overriden here so that: - - the test name is printed - - the test staus is printed - - test duration is printed - - all expectation results from the test are printed (default) or only the failing ones - - error stack trace is printed - - dbms_output from test run is always printed - */ - overriding member procedure after_calling_test(a_test ut_test) as - l_message varchar2(4000); - - procedure print_expectation(a_expectation ut_expectation_result) is - l_lines ut_varchar2_list; - l_failed boolean := a_expectation.status > ut_utils.gc_success; - begin - if l_failed or self.report_all_expectations = 'Y' then - l_lines := a_expectation.get_result_lines(); - for i in 1 .. l_lines.count loop - if l_failed then - self.print_red_text(l_lines(i)); - else - self.print_green_text(l_lines(i)); - end if; - end loop; - self.print_cyan_text(a_expectation.caller_info); - self.print_text(' '); - end if; - end; - - procedure print_results_for_test(a_test ut_test) is - begin - self.lvl := self.lvl + 3; - self.print_red_text(ut_utils.table_to_clob( a_test.get_error_stack_traces() )); - for j in 1 .. a_test.all_expectations.count loop - print_expectation(a_test.all_expectations(j)); - end loop; - self.lvl := self.lvl - 3; - end; - begin - l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]'; - --if test failed, then add it to the failures list, print failure with number - if a_test.result = ut_utils.gc_disabled then - self.print_yellow_text(l_message || ' (DISABLED)'); - elsif a_test.result = ut_utils.gc_success then - self.print_green_text(l_message); - elsif a_test.result > ut_utils.gc_success then - self.failed_test_running_count := self.failed_test_running_count + 1; - self.print_red_text(l_message || ' (FAILED - ' || failed_test_running_count || ')'); - end if; - - print_results_for_test(a_test); - -- reproduce the output from before/after procedures and the test - self.print_clob(a_test.get_serveroutputs); - end; - - overriding member procedure after_calling_run(a_run in ut_run) as - l_summary_text varchar2(4000); - l_warning_index pls_integer := 0; - -- make all warning indexes uniformly indented - c_warnings_lpad constant integer := length(to_char(a_run.results_count.warnings_count)); - - procedure print_item_warnings(a_item in ut_suite_item) is - l_items ut_suite_items; - begin - if a_item is of (ut_logical_suite) then - l_items := treat(a_item as ut_logical_suite).items; - for i in 1 .. l_items.count loop - print_item_warnings(l_items(i)); - end loop; - end if; - - if a_item.warnings is not null and a_item.warnings.count > 0 then - for i in 1 .. a_item.warnings.count loop - l_warning_index := l_warning_index + 1; - self.print_text(' ' || lpad(l_warning_index, c_warnings_lpad) || ') ' || a_item.path); - self.lvl := self.lvl + 3; - self.print_red_text(a_item.warnings(i)); - self.lvl := self.lvl - 3; - end loop; - self.print_text(' '); - end if; - end; - - procedure print_warnings(a_run in ut_run) is - begin - if a_run.results_count.warnings_count > 0 then - self.print_text(' '); - self.print_text('Warnings:'); - self.print_text(' '); - for i in 1 .. a_run.items.count loop - print_item_warnings(treat(a_run.items(i) as ut_suite_item)); - end loop; - end if; - end; - - begin - print_warnings(a_run); - self.print_text('Finished in ' || a_run.execution_time || ' seconds'); - - l_summary_text := - a_run.results_count.total_count || ' tests, ' - || a_run.results_count.failure_count || ' failed, ' || a_run.results_count.errored_count || ' errored, ' - || a_run.results_count.disabled_count ||' disabled, ' || a_run.results_count.warnings_count || ' warning(s)'; - if a_run.results_count.failure_count + a_run.results_count.errored_count + a_run.results_count.warnings_count > 0 then - self.print_red_text(l_summary_text); - 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; - - overriding member function get_description return varchar2 as - begin - return 'A custom reporter for pretty-printing all expectation results directly under the test'; - end; - -end; -/ diff --git a/examples/custom_reporters/ut_expectations_reporter.tps b/examples/custom_reporters/ut_expectations_reporter.tps deleted file mode 100644 index a4238c302..000000000 --- a/examples/custom_reporters/ut_expectations_reporter.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_expectations_reporter under ut_documentation_reporter( - /* - utPLSQL - Version 3 - Copyright 2016 - 2020 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. - */ - report_all_expectations varchar2(1), - - - constructor function ut_expectations_reporter(a_report_all_expectations varchar2 := 'Y') return self as result, - - overriding member procedure after_calling_test(a_test ut_test), - overriding member procedure after_calling_run(a_run in ut_run), - - overriding member function get_description return varchar2 - -) -not final -/ diff --git a/examples/demo_expectations.pck b/examples/demo_expectations.pck deleted file mode 100644 index bf2cc93cf..000000000 --- a/examples/demo_expectations.pck +++ /dev/null @@ -1,558 +0,0 @@ -create or replace package demo_expectations is - - -- %suite - -- %displayname(Demoing expectations) - - -- %test - -- %displayname(demo of expectations with nulls) - procedure demo_nulls_on_expectations; - - -- %test - -- %displayname(demo of failure for to_equal expectation on value mismatch) - procedure demo_to_equal_failure; - - -- %test - -- %displayname(demo of failure for to_equal expectation on data type mismatch) - procedure demo_to_equal_failure_types; - - -- %test - -- %displayname(demo of success for to_equal expectation) - procedure demo_to_equal_success; - - -- %test - -- %displayname(demo of failure for to_be_true and to_be_false expectation) - procedure demo_to_be_true_false_failure; - - -- %test - -- %displayname(demo of success for to_be_true and to_be_false expectation) - procedure demo_to_be_true_false_success; - - -- %test - -- %displayname(demo of failure for to_be_null expectation ) - procedure demo_to_be_null_failure; - - -- %test - -- %displayname(demo of success for to_be_null expectation ) - procedure demo_to_be_null_success; - - -- %test - -- %displayname(demo of failure for to_be_not_null expectation ) - procedure demo_to_be_not_null_failure; - - -- %test - -- %displayname(demo of success for to_be_not_null expectation) - procedure demo_to_be_not_null_success; - - -- %test - -- %displayname(demo of failure for to_match expectation) - procedure demo_to_match_failure; - - -- %test - -- %displayname(demo of success for to_match expectation) - procedure demo_to_match_success; - - -- %test - -- %displayname(demo of failure for to_be_like expectation) - procedure demo_to_be_like_failure; - - -- %test - -- %displayname(demo of success for to_be_like expectation) - procedure demo_to_be_like_success; - - -- %test - -- %displayname(demo of failure for not_to expectations) - procedure demo_not_to_failure; - - -- %test - -- %displayname(demo of success for not_to expectations) - procedure demo_not_to_success; - -end; -/ -create or replace package body demo_expectations is - - procedure demo_nulls_on_expectations is - begin - --fails on incompatible data types - ut.expect( to_clob('a text'), 'this should fail' ).to_equal( 'a text' ); - ut.expect( to_clob('a text'), 'this should fail' ).to_( equal( 'a text' ) ); - ut.expect( cast(systimestamp as timestamp), 'this should fail' ).to_( equal( systimestamp ) ); - ut.expect( to_clob('a text'), 'this should fail' ).not_to( equal( 'a text' ) ); - ut.expect( cast(systimestamp as timestamp), 'this should fail' ).not_to( equal( systimestamp ) ); - - --fails on incompatible data types even if values are null - ut.expect( to_char(null), 'this should fail' ).to_( equal( to_char(null) ) ); - ut.expect( to_char(null), 'this should fail' ).not_to( equal( to_char(null) ) ); - - --fails as null is not comparable with not null - ut.expect( to_char(null), 'fails on null = not null' ).to_( equal( 'a text' ) ); - ut.expect( 'a text', 'fails on not null = null' ).to_( equal( to_char(null) ) ); - ut.expect( to_char(null), 'fails on null <> not null' ).not_to( equal( 'a text' ) ); - ut.expect( 'a text', 'fails on not null <> null' ).not_to( equal( to_char(null) ) ); - - ut.expect( to_char(null), 'fails on null like ''text''' ).to_( be_like( 'a text' ) ); - ut.expect( to_char(null), 'fails on null not like ''text''' ).not_to( be_like( 'a text' ) ); - - ut.expect( cast(null as boolean), 'fails on null = true' ).to_( be_true ); - ut.expect( cast(null as boolean), 'fails on null <> true' ).not_to( be_true ); - ut.expect( cast(null as boolean), 'fails on null = false' ).to_( be_false ); - ut.expect( cast(null as boolean), 'fails on null <> false' ).not_to( be_false ); - - end; - - procedure demo_to_equal_failure is - l_expected_anydata anydata := anydata.convertObject( department$('IT') ); - l_expected_blob blob := to_blob('AF12FF'); - l_expected_boolean boolean := true; - l_expected_clob clob := 'a string'; - l_expected_date date := sysdate; - l_expected_number number := 12345; - l_expected_timestamp timestamp with time zone := sysdate; - l_expected_timestamp_ltz timestamp with local time zone := sysdate; - l_expected_timestamp_tz timestamp with time zone := sysdate; - l_expected_varchar2 varchar2(100) := 'a string'; - l_actual_anydata anydata := anydata.convertCollection( departments$( department$('IT'), department$('HR') ) ); - l_actual_blob blob := to_blob('AF'); - l_actual_boolean boolean := false; - l_actual_clob clob := 'a different string'; - l_actual_date date := sysdate - 1; - l_actual_number number := 0.12345; - l_actual_timestamp timestamp with time zone := sysdate - 1; - l_actual_timestamp_ltz timestamp with local time zone := sysdate - 1; - l_actual_timestamp_tz timestamp with time zone := sysdate - 1; - l_actual_varchar2 varchar2(100) := 'a different string'; - l_actual_cursor sys_refcursor; - l_expected_cursor sys_refcursor; - begin - --using the to_equal( ) matcher - ut.expect( l_actual_anydata ).to_equal( l_expected_anydata ); - ut.expect( l_actual_blob ).to_equal( l_expected_blob ); - ut.expect( l_actual_boolean ).to_equal( l_expected_boolean ); - ut.expect( l_actual_clob ).to_equal( l_expected_clob ); - ut.expect( l_actual_date ).to_equal( l_expected_date ); - ut.expect( l_actual_number ).to_equal( l_expected_number ); - ut.expect( l_actual_timestamp ).to_equal( l_expected_timestamp ); - ut.expect( l_actual_timestamp_ltz ).to_equal( l_expected_timestamp_ltz ); - ut.expect( l_actual_timestamp_tz ).to_equal( l_expected_timestamp_tz ); - ut.expect( l_actual_varchar2 ).to_equal( l_expected_varchar2 ); - - --using the to_( equal( ) ) matcher - ut.expect( l_actual_anydata ).to_( equal( l_expected_anydata ) ); - ut.expect( l_actual_blob ).to_( equal( l_expected_blob ) ); - ut.expect( l_actual_boolean ).to_( equal( l_expected_boolean ) ); - ut.expect( l_actual_clob ).to_( equal( l_expected_clob ) ); - ut.expect( l_actual_date ).to_( equal( l_expected_date ) ); - ut.expect( l_actual_number ).to_( equal( l_expected_number ) ); - ut.expect( l_actual_timestamp ).to_( equal( l_expected_timestamp ) ); - ut.expect( l_actual_timestamp_ltz ).to_( equal( l_expected_timestamp_ltz ) ); - ut.expect( l_actual_timestamp_tz ).to_( equal( l_expected_timestamp_tz ) ); - ut.expect( l_actual_varchar2 ).to_( equal( l_expected_varchar2 ) ); - - open l_actual_cursor for select * from user_objects where rownum <6; - open l_expected_cursor for select * from user_objects where rownum <5; - - ut.expect(l_actual_cursor).to_equal(l_expected_cursor); - - end; - - procedure demo_to_equal_failure_types is - l_anydata anydata := anydata.convertObject( department$('IT') ); - l_blob blob := to_blob('AF12FF'); - l_boolean boolean := true; - l_clob clob := 'a string'; - l_date date := sysdate; - l_number number := 12345; - l_cursor sys_refcursor; - l_timestamp timestamp with time zone := sysdate; - l_timestamp_ltz timestamp with local time zone := sysdate; - l_timestamp_tz timestamp with time zone := sysdate; - l_varchar2 varchar2(100) := 'a string'; - begin - --using the to_equal( ) matcher - ut.expect( l_anydata ).to_equal( l_clob ); - ut.expect( l_blob ).to_equal( l_clob ); - ut.expect( l_boolean ).to_equal( l_number ); - ut.expect( l_clob ).to_equal( l_blob ); - ut.expect( l_date ).to_equal( l_timestamp ); - ut.expect( l_number ).to_equal( l_varchar2 ); - ut.expect( l_timestamp ).to_equal( l_timestamp_ltz ); - ut.expect( l_timestamp ).to_equal( l_timestamp_tz ); - ut.expect( l_timestamp_ltz ).to_equal( l_date ); - ut.expect( l_varchar2 ).to_equal( l_clob ); - open l_cursor for select * from user_objects where rownum <5; - ut.expect( l_cursor ).to_equal( l_varchar2 ); - - --using the to_( equal( ) ) matcher - ut.expect( l_clob ).to_( equal( l_anydata ) ); - ut.expect( l_blob ).to_( equal( l_clob ) ); - ut.expect( l_boolean ).to_( equal( l_number ) ); - ut.expect( l_clob ).to_( equal( l_blob ) ); - ut.expect( l_date ).to_( equal( l_timestamp ) ); - ut.expect( l_number ).to_( equal( l_varchar2 ) ); - ut.expect( l_timestamp ).to_( equal( l_timestamp_ltz ) ); - ut.expect( l_timestamp ).to_( equal( l_timestamp_tz ) ); - ut.expect( l_timestamp_ltz ).to_( equal( l_date ) ); - ut.expect( l_varchar2 ).to_( equal( l_clob ) ); - open l_cursor for select * from user_objects where rownum <5; - ut.expect( l_varchar2 ).to_( equal( l_cursor ) ); - - end; - - - procedure demo_to_equal_success is - l_anydata anydata := anydata.convertObject( department$('IT') ); - l_blob blob := to_blob('AF12FF'); - l_boolean boolean := true; - l_clob clob := 'a string'; - l_date date := sysdate; - l_number number := 12345; - l_timestamp timestamp with time zone := sysdate; - l_timestamp_ltz timestamp with local time zone := sysdate; - l_timestamp_tz timestamp with time zone := sysdate; - l_varchar2 varchar2(100) := 'a string'; - l_cursor1 sys_refcursor; - l_cursor2 sys_refcursor; - begin - --using the to_equal( ) matcher - ut.expect( l_anydata ).to_equal( l_anydata ); - ut.expect( l_blob ).to_equal( l_blob ); - ut.expect( l_boolean ).to_equal( l_boolean ); - ut.expect( l_clob ).to_equal( l_clob ); - ut.expect( l_date ).to_equal( l_date ); - ut.expect( l_number ).to_equal( l_number ); - ut.expect( l_timestamp ).to_equal( l_timestamp ); - ut.expect( l_timestamp_ltz ).to_equal( l_timestamp_ltz ); - ut.expect( l_timestamp_tz ).to_equal( l_timestamp_tz ); - ut.expect( l_varchar2 ).to_equal( l_varchar2 ); - open l_cursor1 for select * from all_objects where rownum <=50; - open l_cursor2 for select * from all_objects where rownum <=50; - ut.expect( l_cursor1 ).to_equal( l_cursor2 ); - - --using the to_( equal( ) ) matcher - ut.expect( l_anydata ).to_( equal( l_anydata ) ); - ut.expect( l_blob ).to_( equal( l_blob ) ); - ut.expect( l_boolean ).to_( equal( l_boolean ) ); - ut.expect( l_clob ).to_( equal( l_clob ) ); - ut.expect( l_date ).to_( equal( l_date ) ); - ut.expect( l_number ).to_( equal( l_number ) ); - ut.expect( l_timestamp ).to_( equal( l_timestamp ) ); - ut.expect( l_timestamp_ltz ).to_( equal( l_timestamp_ltz ) ); - ut.expect( l_timestamp_tz ).to_( equal( l_timestamp_tz ) ); - ut.expect( l_varchar2 ).to_( equal( l_varchar2 ) ); - - open l_cursor1 for select * from all_objects where rownum <=50; - open l_cursor2 for select * from all_objects where rownum <=50; - ut.expect( l_cursor1 ).to_( equal( l_cursor2 ) ); - end; - - procedure demo_to_be_true_false_failure is - l_null_boolean boolean; - begin - ut.expect( false ).to_be_true; - ut.expect( false ).to_( be_true ); - ut.expect( false ).to_( be_true() ); - ut.expect( l_null_boolean ).to_be_true; - ut.expect( l_null_boolean ).to_( be_true ); - ut.expect( l_null_boolean ).to_( be_true() ); - - ut.expect( 'a string value' ).to_( be_true() ); - - ut.expect( true ).to_be_false; - ut.expect( true ).to_( be_false ); - ut.expect( true ).to_( be_false() ); - ut.expect( l_null_boolean ).to_be_false; - ut.expect( l_null_boolean ).to_( be_false ); - ut.expect( l_null_boolean ).to_( be_false() ); - - ut.expect( 'a string value' ).to_( be_false() ); - end; - - procedure demo_to_be_true_false_success is - begin - ut.expect( true ).to_be_true; - ut.expect( true ).to_( be_true ); - ut.expect( true ).to_( be_true() ); - - ut.expect( false ).to_be_false; - ut.expect( false ).to_( be_false ); - ut.expect( false ).to_( be_false() ); - end; - - -- %test(demo of failure for to_be_null expectation ) - procedure demo_to_be_null_failure is - l_anydata anydata := anydata.convertObject( department$('IT') ); - l_blob blob := to_blob('AF12FF'); - l_boolean boolean := true; - l_clob clob := 'a string'; - l_date date := sysdate; - l_number number := 12345; - l_cursor sys_refcursor; - l_timestamp timestamp with time zone := systimestamp; - l_timestamp_ltz timestamp with local time zone := l_timestamp; - l_timestamp_tz timestamp with time zone := l_timestamp; - l_varchar2 varchar2(100) := 'a string'; - begin - open l_cursor for select * from user_objects where rownum <5; - --using the to_be_null() matcher - ut.expect( l_anydata ).to_be_null(); - ut.expect( l_blob ).to_be_null(); - ut.expect( l_boolean ).to_be_null(); - ut.expect( l_clob ).to_be_null(); - ut.expect( l_date ).to_be_null(); - ut.expect( l_number ).to_be_null; - ut.expect( l_timestamp ).to_be_null; - ut.expect( l_timestamp ).to_be_null; - ut.expect( l_timestamp_ltz ).to_be_null; - ut.expect( l_varchar2 ).to_be_null; - ut.expect( l_cursor ).to_be_null; - - --using the to_( be_null() ) matcher - open l_cursor for select * from user_objects where rownum <5; - ut.expect( l_anydata ).to_( be_null() ); - ut.expect( l_blob ).to_( be_null() ); - ut.expect( l_boolean ).to_( be_null() ); - ut.expect( l_clob ).to_( be_null() ); - ut.expect( l_date ).to_( be_null() ); - ut.expect( l_number ).to_( be_null ); - ut.expect( l_timestamp ).to_( be_null ); - ut.expect( l_timestamp ).to_( be_null ); - ut.expect( l_timestamp_ltz ).to_( be_null ); - ut.expect( l_varchar2 ).to_( be_null ); - ut.expect( l_cursor ).to_( be_null ); - end; - - -- %test(demo of failure for to_be_null expectation ) - procedure demo_to_be_null_success is - l_obj department$; - l_col departments$; - l_null_anydata_tab anydata := anydata.convertObject( l_obj ); - l_null_anydata_obj anydata := anydata.convertCollection( l_col ); - l_anydata anydata ; - l_blob blob ; - l_boolean boolean ; - l_clob clob ; - l_date date ; - l_number number ; - l_cursor sys_refcursor; - l_timestamp timestamp with time zone; - l_timestamp_ltz timestamp with local time zone; - l_timestamp_tz timestamp with time zone; - l_varchar2 varchar2(100); - begin - --using the to_be_null() matcher - ut.expect( l_null_anydata_tab ).to_be_null(); - ut.expect( l_null_anydata_obj ).to_be_null(); - ut.expect( l_anydata ).to_be_null(); - ut.expect( l_blob ).to_be_null(); - ut.expect( l_boolean ).to_be_null(); - ut.expect( l_clob ).to_be_null(); - ut.expect( l_date ).to_be_null(); - ut.expect( l_number ).to_be_null; - ut.expect( l_timestamp ).to_be_null; - ut.expect( l_timestamp ).to_be_null; - ut.expect( l_timestamp_ltz ).to_be_null; - ut.expect( l_varchar2 ).to_be_null; - ut.expect( l_cursor ).to_be_null; - - --using the to_( be_null() ) matcher - ut.expect( l_null_anydata_tab ).to_( be_null() ); - ut.expect( l_null_anydata_obj ).to_( be_null() ); - ut.expect( l_anydata ).to_( be_null() ); - ut.expect( l_blob ).to_( be_null() ); - ut.expect( l_boolean ).to_( be_null() ); - ut.expect( l_clob ).to_( be_null() ); - ut.expect( l_date ).to_( be_null() ); - ut.expect( l_number ).to_( be_null ); - ut.expect( l_timestamp ).to_( be_null ); - ut.expect( l_timestamp ).to_( be_null ); - ut.expect( l_timestamp_ltz ).to_( be_null ); - ut.expect( l_varchar2 ).to_( be_null ); - ut.expect( l_cursor ).to_( be_null ); - end; - - -- %test(demo of success for to_be_not_null expectation ) - procedure demo_to_be_not_null_failure is - l_obj department$; - l_col departments$; - l_null_anydata_tab anydata := anydata.convertObject( l_obj ); - l_null_anydata_obj anydata := anydata.convertCollection( l_col ); - l_anydata anydata ; - l_blob blob ; - l_boolean boolean ; - l_clob clob ; - l_date date ; - l_number number ; - l_cursor sys_refcursor; - l_timestamp timestamp with time zone; - l_timestamp_ltz timestamp with local time zone; - l_timestamp_tz timestamp with time zone; - l_varchar2 varchar2(100); - begin - --using the to_be_not_null() matcher - ut.expect( l_null_anydata_tab ).to_be_not_null(); - ut.expect( l_null_anydata_obj ).to_be_not_null(); - ut.expect( l_anydata ).to_be_not_null(); - ut.expect( l_blob ).to_be_not_null(); - ut.expect( l_boolean ).to_be_not_null(); - ut.expect( l_clob ).to_be_not_null(); - ut.expect( l_date ).to_be_not_null(); - ut.expect( l_number ).to_be_not_null; - ut.expect( l_timestamp ).to_be_not_null; - ut.expect( l_timestamp ).to_be_not_null; - ut.expect( l_timestamp_ltz ).to_be_not_null; - ut.expect( l_varchar2 ).to_be_not_null; - ut.expect( l_cursor ).to_be_not_null; - - --using the to_( be_not_null() ) matcher - ut.expect( l_null_anydata_tab ).to_( be_not_null() ); - ut.expect( l_null_anydata_obj ).to_( be_not_null() ); - ut.expect( l_anydata ).to_( be_not_null() ); - ut.expect( l_blob ).to_( be_not_null() ); - ut.expect( l_boolean ).to_( be_not_null() ); - ut.expect( l_clob ).to_( be_not_null() ); - ut.expect( l_date ).to_( be_not_null() ); - ut.expect( l_number ).to_( be_not_null ); - ut.expect( l_timestamp ).to_( be_not_null ); - ut.expect( l_timestamp ).to_( be_not_null ); - ut.expect( l_timestamp_ltz ).to_( be_not_null ); - ut.expect( l_varchar2 ).to_( be_not_null ); - ut.expect( l_cursor ).to_( be_not_null ); - end; - - -- %test(demo of success for to_be_not_null expectation) - procedure demo_to_be_not_null_success is - l_anydata anydata := anydata.convertObject( department$('IT') ); - l_blob blob := to_blob('AF12FF'); - l_boolean boolean := true; - l_clob clob := 'a string'; - l_date date := sysdate; - l_number number := 12345; - l_cursor sys_refcursor; - l_timestamp timestamp with time zone := sysdate; - l_timestamp_ltz timestamp with local time zone := sysdate; - l_timestamp_tz timestamp with time zone := sysdate; - l_varchar2 varchar2(100) := 'a string'; - begin - open l_cursor for select * from user_objects where rownum <5; - --using the to_be_not_null() matcher - ut.expect( l_anydata ).to_be_not_null(); - ut.expect( l_blob ).to_be_not_null(); - ut.expect( l_boolean ).to_be_not_null(); - ut.expect( l_clob ).to_be_not_null(); - ut.expect( l_date ).to_be_not_null(); - ut.expect( l_number ).to_be_not_null; - ut.expect( l_timestamp ).to_be_not_null; - ut.expect( l_timestamp ).to_be_not_null; - ut.expect( l_timestamp_ltz ).to_be_not_null; - ut.expect( l_varchar2 ).to_be_not_null; - ut.expect( l_cursor ).to_be_not_null; - - --using the to_( be_not_null() ) matcher - open l_cursor for select * from user_objects where rownum <5; - ut.expect( l_anydata ).to_( be_not_null() ); - ut.expect( l_blob ).to_( be_not_null() ); - ut.expect( l_boolean ).to_( be_not_null() ); - ut.expect( l_clob ).to_( be_not_null() ); - ut.expect( l_date ).to_( be_not_null() ); - ut.expect( l_number ).to_( be_not_null ); - ut.expect( l_timestamp ).to_( be_not_null ); - ut.expect( l_timestamp ).to_( be_not_null ); - ut.expect( l_timestamp_ltz ).to_( be_not_null ); - ut.expect( l_varchar2 ).to_( be_not_null ); - ut.expect( l_cursor ).to_( be_not_null ); - end; - - procedure demo_to_match_failure is - l_clob clob := 'There was a guy named Stephen'; - begin - ut.expect( 'STEPHEN' ).to_match('^Stephen$'); - ut.expect( 'stephen ' ).to_match('^Stephen$', 'i'); --case insensitive - ut.expect( 'stephen' ).to_( match('^Stephen$') ); - ut.expect( 'stephen ' ).to_( match('^Stephen$', 'i') ); --case insensitive - ut.expect( l_clob ).to_match('^Stephen$'); - ut.expect( l_clob ).to_match('^Stephen$', 'i'); --case insensitive - ut.expect( l_clob ).to_( match('^Stephen$') ); - ut.expect( l_clob ).to_( match('^Stephen$', 'i') ); --case insensitive - - ut.expect( sysdate ).to_( match(sysdate, 'i') ); --case insensitive - ut.expect( 12345 ).to_( match(12345, 'i') ); --case insensitive - - end; - - procedure demo_to_match_success is - l_clob clob := 'There was a guy named STEPHEN'; - begin - ut.expect( 'Hi, I am Stephen' ).to_match('Stephen$'); - ut.expect( 'stephen' ).to_match('^Stephen$', 'i'); --case insensitive - ut.expect( 'Hi, I am Stephen' ).to_( match('Stephen$') ); - ut.expect( 'stephen' ).to_( match('^Stephen$', 'i') ); --case insensitive - ut.expect( l_clob ).to_match('STEPHEN'); - ut.expect( l_clob ).to_match('Stephen$', 'i'); --case insensitive - ut.expect( l_clob ).to_( match('STEPHEN$') ); - ut.expect( l_clob ).to_( match('Stephen$', 'i') ); --case insensitive - end; - - procedure demo_to_be_like_failure is - l_clob clob := 'There was a guy named Stephen'; - begin - ut.expect( 'STEPHEN' ).to_be_like('Stephen'); - ut.expect( 'Stephen ' ).to_be_like('Stephen\_', '\'); --escape wildcards with '\' - ut.expect( 'stephen' ).to_( be_like('%Stephen%') ); - ut.expect( 'Stephen ' ).to_( be_like('Stephen^_', '^') ); --escape wildcards with '^' - ut.expect( l_clob ).to_be_like('%stephen'); - ut.expect( l_clob ).to_be_like('%Stephe\_', '\'); --escape wildcards with '\' - ut.expect( l_clob ).to_( be_like('%stephen') ); - ut.expect( l_clob ).to_( be_like('%Stephe\_', '\') ); --escape wildcards with '\' - - ut.expect( sysdate ).to_( be_like(sysdate) ); --case insensitive - ut.expect( 12345 ).to_( be_like(12345) ); --case insensitive - - end; - - procedure demo_to_be_like_success is - l_clob clob := 'There was a guy named STEPHEN_'; - begin - ut.expect( 'Hi, I am Stephen' ).to_be_like('%Stephen'); - ut.expect( 'stephen_' ).to_be_like('_tephen\_', '\'); --escape wildcards with '\' - ut.expect( 'Hi, I am Stephen' ).to_( be_like('%Stephen') ); - ut.expect( 'stephen_' ).to_( be_like('_tephen^_', '^')); --escape wildcards with '^' - ut.expect( l_clob ).to_be_like('%a%S_EP%'); - ut.expect( l_clob ).to_be_like('%a%S_EP%\_', '\'); --escape wildcards with '\' - ut.expect( l_clob ).to_( be_like('%a%S_EP%') ); - ut.expect( l_clob ).to_( be_like('%a%S_EP%\_', '\') ); --escape wildcards with '\' - end; - - procedure demo_not_to_failure is - begin - ut.expect( 'Hi, I am Stephen' ).not_to( be_like('%Stephen') ); - ut.expect( 'stephen' ).not_to( match('^Stephen$', 'i') ); --case insensitive - ut.expect( sysdate ).not_to( be_not_null() ); - ut.expect( to_char(null) ).not_to( be_null() ); - ut.expect( false ).not_to( be_false ); - ut.expect( true ).not_to( be_true ); - ut.expect( 123 ).not_to( be_false ); - ut.expect( sysdate ).not_to( be_true ); - ut.expect( 1 ).not_to( equal( 1 ) ); - ut.expect( 1 ).not_to( equal( '1' ) ); - ut.expect( to_char(null) ).not_to( equal( to_char(null) ) ); - end; - - procedure demo_not_to_success is - begin - ut.expect( sysdate ).not_to( be_null() ); - ut.expect( to_char(null) ).not_to( be_not_null() ); - ut.expect( true ).not_to( be_false ); - ut.expect( false ).not_to( be_true ); - ut.expect(sysdate).not_to( be_between(sysdate+1,sysdate+2) ); - ut.expect( 1 ).not_to( equal( 2 ) ); - ut.expect( 'asd' ).not_to( be_like('z%q') ); - - ut.expect( sysdate ).not_to_be_null(); - ut.expect( to_char(null) ).not_to_be_not_null(); - ut.expect(sysdate).not_to_be_between(sysdate+1,sysdate+2); - ut.expect( 1 ).not_to_equal( 2 ); - ut.expect( 'asd' ).not_to_be_like('z%q'); - end; - -end; -/ diff --git a/examples/demo_of_expectations/demo_equal_matcher.sql b/examples/demo_of_expectations/demo_equal_matcher.sql deleted file mode 100644 index f7b20581f..000000000 --- a/examples/demo_of_expectations/demo_equal_matcher.sql +++ /dev/null @@ -1,128 +0,0 @@ -create or replace type demo_department as object( - dept_name varchar2(30) -) -/ - -create or replace type demo_department_new as object( - dept_name varchar2(30) -) -/ - -create or replace type demo_departments as table of demo_department -/ - -create or replace package demo_equal_matcher as - - -- %suite - -- %displayname(Equal matcher) - -- %suitepath(org.utplsql.v3.demo.matchers) - - -- TODO this should go into context(compare_objects, Comparing objects) - -- %context(Comparing objects) - - -- %test - -- %displayname(Gives success when comparing identical objects containing identical data) - procedure object_compare_success; - - -- %test - -- %displayname(Gives failure when comparing to a null actual) - procedure object_compare_null_actual; - - -- %test - -- %displayname(Gives failure when comparing to a null expected) - procedure object_compare_null_expected; - - -- %test - -- %displayname(Gives success when comparing null actual to a null expected) - procedure object_compare_null_both_ok; - - -- %test - -- %displayname(Gives failure when comparing null actual to a null expected, setting null equal to false) - procedure object_compare_null_both_fail; - - -- %test - -- %displayname(Gives failure when comparing identical objects containing different data) - procedure object_compare_different_data; - - -- %test - -- %displayname(Gives failure when comparing different objects containing identical data) - procedure object_compare_different_type; - - -- %endcontext - -end; -/ - -create or replace package body demo_equal_matcher as - - procedure object_compare_success is - l_expected demo_department; - l_actual demo_department; - begin - --setup the expected - l_expected := demo_department('Sales'); - --get the actual data - l_actual := demo_department('Sales'); - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected) - ); - end; - - procedure object_compare_null_actual is - l_expected demo_department; - l_actual demo_department; - begin - --setup the expected - l_expected := demo_department('Sales'); - --get the actual data - -- nothing done - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected) - ); - end; - - procedure object_compare_null_expected is - l_expected demo_department; - l_actual demo_department; - begin - l_actual := demo_department('Sales'); - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)); - end; - - procedure object_compare_null_both_ok is - l_expected demo_department; - l_actual demo_department; - begin - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)); - end; - - procedure object_compare_null_both_fail is - l_expected demo_department; - l_actual demo_department; - begin - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected),a_nulls_are_equal => false); - end; - - - procedure object_compare_different_data is - l_expected demo_department; - l_actual demo_department; - begin - --setup the expected - l_expected := demo_department('Sales'); - --get the actual data - l_actual := demo_department('HR'); - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)); - end; - - procedure object_compare_different_type is - l_expected demo_department; - l_actual demo_department_new; - begin - --setup the expected - l_expected := demo_department('Sales'); - --get the actual data - l_actual := demo_department_new('Sales'); - ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)); - end; - -end; -/ diff --git a/examples/demo_of_expectations/drop_demo_equal_matcher.sql b/examples/demo_of_expectations/drop_demo_equal_matcher.sql deleted file mode 100644 index 8ec8cfa83..000000000 --- a/examples/demo_of_expectations/drop_demo_equal_matcher.sql +++ /dev/null @@ -1,5 +0,0 @@ -drop package demo_equal_matcher; -drop type demo_departments; -drop type demo_department_new; -drop type demo_department; - diff --git a/examples/demo_of_expectations/run.sql b/examples/demo_of_expectations/run.sql deleted file mode 100644 index 42a43400c..000000000 --- a/examples/demo_of_expectations/run.sql +++ /dev/null @@ -1,8 +0,0 @@ -@@demo_equal_matcher.sql - -set serveroutput on size unlimited format truncated - -exec ut.run(user||'.demo_equal_matcher'); - -@@drop_demo_equal_matcher.sql - diff --git a/examples/department.tps b/examples/department.tps deleted file mode 100644 index b2c76a343..000000000 --- a/examples/department.tps +++ /dev/null @@ -1,4 +0,0 @@ -create or replace type department$ as object( - dept_name varchar2(30) -) -/ diff --git a/examples/department.tst b/examples/department.tst new file mode 100644 index 000000000..92d1c2c1b --- /dev/null +++ b/examples/department.tst @@ -0,0 +1,11 @@ +10***ACCOUNTING***122 +20***RESEARCH***124 +30***SALES***123 +40***OPERATIONS***167 +12***RESEARCH12***122 +13***SALES13***122 +14***OPERATIONS14***122 +23***SALES23***124 +24***OPERATIONS24***124 +34***OPERATIONS34***123 +43***SALES43***167 diff --git a/examples/department2file.sp b/examples/department2file.sp new file mode 100644 index 000000000..e7b307292 --- /dev/null +++ b/examples/department2file.sp @@ -0,0 +1,22 @@ +CREATE OR REPLACE PROCEDURE DEPARTMENT2file ( + loc IN VARCHAR2, + file IN VARCHAR2 := 'DEPARTMENT.dat', + delim IN VARCHAR2 := '|' + ) +IS + fid UTL_FILE.FILE_TYPE; + line VARCHAR2(32767); +BEGIN + fid := UTL_FILE.FOPEN (loc, file, 'W'); + + FOR rec IN (SELECT * FROM DEPARTMENT) + LOOP + line := + TO_CHAR (rec.DEPARTMENT_ID) || delim || + rec.NAME || delim || + TO_CHAR (rec.LOC_ID); + UTL_FILE.PUT_LINE (fid, line); + END LOOP; + UTL_FILE.FCLOSE (fid); +END; +/ \ No newline at end of file diff --git a/examples/departments.tps b/examples/departments.tps deleted file mode 100644 index 335e56579..000000000 --- a/examples/departments.tps +++ /dev/null @@ -1,2 +0,0 @@ -create or replace type departments$ as table of department$ -/ diff --git a/examples/developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql b/examples/developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql deleted file mode 100644 index aea43e8aa..000000000 --- a/examples/developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql +++ /dev/null @@ -1,22 +0,0 @@ ---Shows that even a very large package specification can be parsed quite quickly ---Clear Screen -set serveroutput on -set echo off ---install the example unit test packages -@@tst_pkg_huge.pks - -declare - l_suites ut_suite_items; - l_items ut_suite_items; -begin - l_suites := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(USER||'.TST_PKG_HUGE')); - l_items := treat( - treat( treat( l_suites( 1 ) as ut_logical_suite ).items( 1 ) as ut_logical_suite ).items( 1 ) - as ut_logical_suite - ).items; - dbms_output.put_line('Created '||l_items.count||' tests in suite'); - dbms_output.put_line(' Last test name='||l_items(l_items.last).name); -end; -/ - -drop package tst_pkg_huge; diff --git a/examples/developer_examples/RunExampleTestSuite.sql b/examples/developer_examples/RunExampleTestSuite.sql deleted file mode 100644 index 950450cd5..000000000 --- a/examples/developer_examples/RunExampleTestSuite.sql +++ /dev/null @@ -1,54 +0,0 @@ ---Shows how to create a test suite in code and call the test runner. ---No tables are used for this. ---Suite Management packages are when developed will make this easier. ---Clear Screen -Set Serveroutput On Size Unlimited format truncated -set echo off ---install the example unit test packages -@@ut_exampletest.pks -@@ut_exampletest.pkb -@@ut_exampletest2.pks -@@ut_exampletest2.pkb - -declare - l_suite ut_logical_suite; - l_test ut_test; - l_expectation ut_expectation_result; -begin - l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1); - l_suite.description := 'Test Suite Name'; - l_test := ut_test(user, 'ut_exampletest','ut_exAmpletest',a_line_no=>3); - l_test.description := 'Example test1'; - l_test.before_test_list := ut_executables(ut_executable(user, 'ut_exampletest','Setup',ut_utils.gc_before_test)); - l_test.after_test_list := ut_executables(ut_executable(user, 'ut_exampletest','tEardown',ut_utils.gc_after_test)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := l_test; - - l_test := ut_test(user, 'UT_EXAMPLETEST2','ut_exAmpletest',a_line_no=>6); - l_test.description := 'Another example test'; - l_test.before_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','SETUP',ut_utils.gc_before_test)); - l_test.after_test_list := ut_executables(ut_executable(user, 'UT_EXAMPLETEST2','TEARDOWN',ut_utils.gc_after_test)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := l_test; - - l_suite.do_execute(); - - -- No reporter used in this example so outputing the results manually. - for test_idx in l_suite.items.first .. l_suite.items.last loop - l_test := treat(l_suite.items(test_idx) as ut_test); - dbms_output.put_line('---------------------------------------------------'); - dbms_output.put_line('Test:' || l_test.item.form_name); - dbms_output.put_line('Result: ' || ut_utils.test_result_to_char(l_test.result)); - dbms_output.put_line('expectation Results:'); - for i in 1 .. l_test.failed_expectations.count loop - l_expectation := l_test.failed_expectations(i); - dbms_output.put_line(i || ' - result: ' || ut_utils.test_result_to_char(l_expectation.result)); - dbms_output.put_line(i || ' - Message: ' || l_expectation.message); - end loop; - end loop; - dbms_output.put_line('---------------------------------------------------'); -end; -/ - -drop package ut_exampletest; -drop package ut_exampletest2; diff --git a/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql b/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql deleted file mode 100644 index e713fa02d..000000000 --- a/examples/developer_examples/RunExampleTestSuiteWithCompositeReporter.sql +++ /dev/null @@ -1,44 +0,0 @@ ---Shows how to create a test suite with the default reporter which is dbms_output ---No tables are used for this. ---Suite Management packages are when developed will make this easier. ---Clear Screen -Set Serveroutput On Size Unlimited format truncated -set echo off ---install the example unit test packages -@@ut_exampletest.pks -@@ut_exampletest.pkb -@@ut_exampletest2.pks -@@ut_exampletest2.pkb - -PROMPT Runs test report using composite reporter -declare - l_suite ut_logical_suite; - l_doc_reporter ut_output_reporter_base := ut_documentation_reporter(); - l_tc_reporter ut_output_reporter_base := ut_teamcity_reporter(); - l_run ut_run; -begin - ut_event_manager.initialize(); - ut_event_manager.add_listener(l_doc_reporter); - ut_event_manager.add_listener(l_tc_reporter); - ut_event_manager.trigger_event(ut_event_manager.gc_initialize, l_run); - - l_suite := ut_suite(user, 'ut_exampletest',a_line_no=>1); - l_suite.description := 'Test Suite Name'; - - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut_test(user,'ut_exampletest','ut_exAmpletest',a_line_no=>3); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut_test(user, 'UT_EXAMPLETEST2','UT_EXAMPLETEST',a_line_no=>6); - - -- provide a reporter to process results - l_run := ut_run(ut_suite_items(l_suite)); - l_run.do_execute(); - - ut_event_manager.trigger_event(ut_event_manager.gc_finalize, l_run); - l_doc_reporter.lines_to_dbms_output(0,0); - l_tc_reporter.lines_to_dbms_output(0,0); -end; -/ - -drop package ut_exampletest; -drop package ut_exampletest2; diff --git a/examples/developer_examples/tst_pkg_huge.pks b/examples/developer_examples/tst_pkg_huge.pks deleted file mode 100644 index 3f7220f61..000000000 --- a/examples/developer_examples/tst_pkg_huge.pks +++ /dev/null @@ -1,2522 +0,0 @@ -create or replace package tst_pkg_huge is - - -- %suite - -- %displayname(huge package suite name) - -- %suitepath(all.tests) - - - - -- %test - -- %displayname(Test number 1) - procedure test1; - - -- %test - -- %displayname(Test number 2) - procedure test2; - - -- %test - -- %displayname(Test number 3) - procedure test3; - - -- %test - -- %displayname(Test number 4) - procedure test4; - - -- %test - -- %displayname(Test number 5) - procedure test5; - - -- %test - -- %displayname(Test number 6) - procedure test6; - - -- %test - -- %displayname(Test number 7) - procedure test7; - - -- %test - -- %displayname(Test number 8) - procedure test8; - - -- %test - -- %displayname(Test number 9) - procedure test9; - - -- %test - -- %displayname(Test number 10) - procedure test10; - - -- %test - -- %displayname(Test number 11) - procedure test11; - - -- %test - -- %displayname(Test number 12) - procedure test12; - - -- %test - -- %displayname(Test number 13) - procedure test13; - - -- %test - -- %displayname(Test number 14) - procedure test14; - - -- %test - -- %displayname(Test number 15) - procedure test15; - - -- %test - -- %displayname(Test number 16) - procedure test16; - - -- %test - -- %displayname(Test number 17) - procedure test17; - - -- %test - -- %displayname(Test number 18) - procedure test18; - - -- %test - -- %displayname(Test number 19) - procedure test19; - - -- %test - -- %displayname(Test number 20) - procedure test20; - - -- %test - -- %displayname(Test number 21) - procedure test21; - - -- %test - -- %displayname(Test number 22) - procedure test22; - - -- %test - -- %displayname(Test number 23) - procedure test23; - - -- %test - -- %displayname(Test number 24) - procedure test24; - - -- %test - -- %displayname(Test number 25) - procedure test25; - - -- %test - -- %displayname(Test number 26) - procedure test26; - - -- %test - -- %displayname(Test number 27) - procedure test27; - - -- %test - -- %displayname(Test number 28) - procedure test28; - - -- %test - -- %displayname(Test number 29) - procedure test29; - - -- %test - -- %displayname(Test number 30) - procedure test30; - - -- %test - -- %displayname(Test number 31) - procedure test31; - - -- %test - -- %displayname(Test number 32) - procedure test32; - - -- %test - -- %displayname(Test number 33) - procedure test33; - - -- %test - -- %displayname(Test number 34) - procedure test34; - - -- %test - -- %displayname(Test number 35) - procedure test35; - - -- %test - -- %displayname(Test number 36) - procedure test36; - - -- %test - -- %displayname(Test number 37) - procedure test37; - - -- %test - -- %displayname(Test number 38) - procedure test38; - - -- %test - -- %displayname(Test number 39) - procedure test39; - - -- %test - -- %displayname(Test number 40) - procedure test40; - - -- %test - -- %displayname(Test number 41) - procedure test41; - - -- %test - -- %displayname(Test number 42) - procedure test42; - - -- %test - -- %displayname(Test number 43) - procedure test43; - - -- %test - -- %displayname(Test number 44) - procedure test44; - - -- %test - -- %displayname(Test number 45) - procedure test45; - - -- %test - -- %displayname(Test number 46) - procedure test46; - - -- %test - -- %displayname(Test number 47) - procedure test47; - - -- %test - -- %displayname(Test number 48) - procedure test48; - - -- %test - -- %displayname(Test number 49) - procedure test49; - - -- %test - -- %displayname(Test number 50) - procedure test50; - - -- %test - -- %displayname(Test number 51) - procedure test51; - - -- %test - -- %displayname(Test number 52) - procedure test52; - - -- %test - -- %displayname(Test number 53) - procedure test53; - - -- %test - -- %displayname(Test number 54) - procedure test54; - - -- %test - -- %displayname(Test number 55) - procedure test55; - - -- %test - -- %displayname(Test number 56) - procedure test56; - - -- %test - -- %displayname(Test number 57) - procedure test57; - - -- %test - -- %displayname(Test number 58) - procedure test58; - - -- %test - -- %displayname(Test number 59) - procedure test59; - - -- %test - -- %displayname(Test number 60) - procedure test60; - - -- %test - -- %displayname(Test number 61) - procedure test61; - - -- %test - -- %displayname(Test number 62) - procedure test62; - - -- %test - -- %displayname(Test number 63) - procedure test63; - - -- %test - -- %displayname(Test number 64) - procedure test64; - - -- %test - -- %displayname(Test number 65) - procedure test65; - - -- %test - -- %displayname(Test number 66) - procedure test66; - - -- %test - -- %displayname(Test number 67) - procedure test67; - - -- %test - -- %displayname(Test number 68) - procedure test68; - - -- %test - -- %displayname(Test number 69) - procedure test69; - - -- %test - -- %displayname(Test number 70) - procedure test70; - - -- %test - -- %displayname(Test number 71) - procedure test71; - - -- %test - -- %displayname(Test number 72) - procedure test72; - - -- %test - -- %displayname(Test number 73) - procedure test73; - - -- %test - -- %displayname(Test number 74) - procedure test74; - - -- %test - -- %displayname(Test number 75) - procedure test75; - - -- %test - -- %displayname(Test number 76) - procedure test76; - - -- %test - -- %displayname(Test number 77) - procedure test77; - - -- %test - -- %displayname(Test number 78) - procedure test78; - - -- %test - -- %displayname(Test number 79) - procedure test79; - - -- %test - -- %displayname(Test number 80) - procedure test80; - - -- %test - -- %displayname(Test number 81) - procedure test81; - - -- %test - -- %displayname(Test number 82) - procedure test82; - - -- %test - -- %displayname(Test number 83) - procedure test83; - - -- %test - -- %displayname(Test number 84) - procedure test84; - - -- %test - -- %displayname(Test number 85) - procedure test85; - - -- %test - -- %displayname(Test number 86) - procedure test86; - - -- %test - -- %displayname(Test number 87) - procedure test87; - - -- %test - -- %displayname(Test number 88) - procedure test88; - - -- %test - -- %displayname(Test number 89) - procedure test89; - - -- %test - -- %displayname(Test number 90) - procedure test90; - - -- %test - -- %displayname(Test number 91) - procedure test91; - - -- %test - -- %displayname(Test number 92) - procedure test92; - - -- %test - -- %displayname(Test number 93) - procedure test93; - - -- %test - -- %displayname(Test number 94) - procedure test94; - - -- %test - -- %displayname(Test number 95) - procedure test95; - - -- %test - -- %displayname(Test number 96) - procedure test96; - - -- %test - -- %displayname(Test number 97) - procedure test97; - - -- %test - -- %displayname(Test number 98) - procedure test98; - - -- %test - -- %displayname(Test number 99) - procedure test99; - - -- %test - -- %displayname(Test number 100) - procedure test100; - - -- %test - -- %displayname(Test number 101) - procedure test101; - - -- %test - -- %displayname(Test number 102) - procedure test102; - - -- %test - -- %displayname(Test number 103) - procedure test103; - - -- %test - -- %displayname(Test number 104) - procedure test104; - - -- %test - -- %displayname(Test number 105) - procedure test105; - - -- %test - -- %displayname(Test number 106) - procedure test106; - - -- %test - -- %displayname(Test number 107) - procedure test107; - - -- %test - -- %displayname(Test number 108) - procedure test108; - - -- %test - -- %displayname(Test number 109) - procedure test109; - - -- %test - -- %displayname(Test number 110) - procedure test110; - - -- %test - -- %displayname(Test number 111) - procedure test111; - - -- %test - -- %displayname(Test number 112) - procedure test112; - - -- %test - -- %displayname(Test number 113) - procedure test113; - - -- %test - -- %displayname(Test number 114) - procedure test114; - - -- %test - -- %displayname(Test number 115) - procedure test115; - - -- %test - -- %displayname(Test number 116) - procedure test116; - - -- %test - -- %displayname(Test number 117) - procedure test117; - - -- %test - -- %displayname(Test number 118) - procedure test118; - - -- %test - -- %displayname(Test number 119) - procedure test119; - - -- %test - -- %displayname(Test number 120) - procedure test120; - - -- %test - -- %displayname(Test number 121) - procedure test121; - - -- %test - -- %displayname(Test number 122) - procedure test122; - - -- %test - -- %displayname(Test number 123) - procedure test123; - - -- %test - -- %displayname(Test number 124) - procedure test124; - - -- %test - -- %displayname(Test number 125) - procedure test125; - - -- %test - -- %displayname(Test number 126) - procedure test126; - - -- %test - -- %displayname(Test number 127) - procedure test127; - - -- %test - -- %displayname(Test number 128) - procedure test128; - - -- %test - -- %displayname(Test number 129) - procedure test129; - - -- %test - -- %displayname(Test number 130) - procedure test130; - - -- %test - -- %displayname(Test number 131) - procedure test131; - - -- %test - -- %displayname(Test number 132) - procedure test132; - - -- %test - -- %displayname(Test number 133) - procedure test133; - - -- %test - -- %displayname(Test number 134) - procedure test134; - - -- %test - -- %displayname(Test number 135) - procedure test135; - - -- %test - -- %displayname(Test number 136) - procedure test136; - - -- %test - -- %displayname(Test number 137) - procedure test137; - - -- %test - -- %displayname(Test number 138) - procedure test138; - - -- %test - -- %displayname(Test number 139) - procedure test139; - - -- %test - -- %displayname(Test number 140) - procedure test140; - - -- %test - -- %displayname(Test number 141) - procedure test141; - - -- %test - -- %displayname(Test number 142) - procedure test142; - - -- %test - -- %displayname(Test number 143) - procedure test143; - - -- %test - -- %displayname(Test number 144) - procedure test144; - - -- %test - -- %displayname(Test number 145) - procedure test145; - - -- %test - -- %displayname(Test number 146) - procedure test146; - - -- %test - -- %displayname(Test number 147) - procedure test147; - - -- %test - -- %displayname(Test number 148) - procedure test148; - - -- %test - -- %displayname(Test number 149) - procedure test149; - - -- %test - -- %displayname(Test number 150) - procedure test150; - - -- %test - -- %displayname(Test number 151) - procedure test151; - - -- %test - -- %displayname(Test number 152) - procedure test152; - - -- %test - -- %displayname(Test number 153) - procedure test153; - - -- %test - -- %displayname(Test number 154) - procedure test154; - - -- %test - -- %displayname(Test number 155) - procedure test155; - - -- %test - -- %displayname(Test number 156) - procedure test156; - - -- %test - -- %displayname(Test number 157) - procedure test157; - - -- %test - -- %displayname(Test number 158) - procedure test158; - - -- %test - -- %displayname(Test number 159) - procedure test159; - - -- %test - -- %displayname(Test number 160) - procedure test160; - - -- %test - -- %displayname(Test number 161) - procedure test161; - - -- %test - -- %displayname(Test number 162) - procedure test162; - - -- %test - -- %displayname(Test number 163) - procedure test163; - - -- %test - -- %displayname(Test number 164) - procedure test164; - - -- %test - -- %displayname(Test number 165) - procedure test165; - - -- %test - -- %displayname(Test number 166) - procedure test166; - - -- %test - -- %displayname(Test number 167) - procedure test167; - - -- %test - -- %displayname(Test number 168) - procedure test168; - - -- %test - -- %displayname(Test number 169) - procedure test169; - - -- %test - -- %displayname(Test number 170) - procedure test170; - - -- %test - -- %displayname(Test number 171) - procedure test171; - - -- %test - -- %displayname(Test number 172) - procedure test172; - - -- %test - -- %displayname(Test number 173) - procedure test173; - - -- %test - -- %displayname(Test number 174) - procedure test174; - - -- %test - -- %displayname(Test number 175) - procedure test175; - - -- %test - -- %displayname(Test number 176) - procedure test176; - - -- %test - -- %displayname(Test number 177) - procedure test177; - - -- %test - -- %displayname(Test number 178) - procedure test178; - - -- %test - -- %displayname(Test number 179) - procedure test179; - - -- %test - -- %displayname(Test number 180) - procedure test180; - - -- %test - -- %displayname(Test number 181) - procedure test181; - - -- %test - -- %displayname(Test number 182) - procedure test182; - - -- %test - -- %displayname(Test number 183) - procedure test183; - - -- %test - -- %displayname(Test number 184) - procedure test184; - - -- %test - -- %displayname(Test number 185) - procedure test185; - - -- %test - -- %displayname(Test number 186) - procedure test186; - - -- %test - -- %displayname(Test number 187) - procedure test187; - - -- %test - -- %displayname(Test number 188) - procedure test188; - - -- %test - -- %displayname(Test number 189) - procedure test189; - - -- %test - -- %displayname(Test number 190) - procedure test190; - - -- %test - -- %displayname(Test number 191) - procedure test191; - - -- %test - -- %displayname(Test number 192) - procedure test192; - - -- %test - -- %displayname(Test number 193) - procedure test193; - - -- %test - -- %displayname(Test number 194) - procedure test194; - - -- %test - -- %displayname(Test number 195) - procedure test195; - - -- %test - -- %displayname(Test number 196) - procedure test196; - - -- %test - -- %displayname(Test number 197) - procedure test197; - - -- %test - -- %displayname(Test number 198) - procedure test198; - - -- %test - -- %displayname(Test number 199) - procedure test199; - - -- %test - -- %displayname(Test number 200) - procedure test200; - - -- %test - -- %displayname(Test number 201) - procedure test201; - - -- %test - -- %displayname(Test number 202) - procedure test202; - - -- %test - -- %displayname(Test number 203) - procedure test203; - - -- %test - -- %displayname(Test number 204) - procedure test204; - - -- %test - -- %displayname(Test number 205) - procedure test205; - - -- %test - -- %displayname(Test number 206) - procedure test206; - - -- %test - -- %displayname(Test number 207) - procedure test207; - - -- %test - -- %displayname(Test number 208) - procedure test208; - - -- %test - -- %displayname(Test number 209) - procedure test209; - - -- %test - -- %displayname(Test number 210) - procedure test210; - - -- %test - -- %displayname(Test number 211) - procedure test211; - - -- %test - -- %displayname(Test number 212) - procedure test212; - - -- %test - -- %displayname(Test number 213) - procedure test213; - - -- %test - -- %displayname(Test number 214) - procedure test214; - - -- %test - -- %displayname(Test number 215) - procedure test215; - - -- %test - -- %displayname(Test number 216) - procedure test216; - - -- %test - -- %displayname(Test number 217) - procedure test217; - - -- %test - -- %displayname(Test number 218) - procedure test218; - - -- %test - -- %displayname(Test number 219) - procedure test219; - - -- %test - -- %displayname(Test number 220) - procedure test220; - - -- %test - -- %displayname(Test number 221) - procedure test221; - - -- %test - -- %displayname(Test number 222) - procedure test222; - - -- %test - -- %displayname(Test number 223) - procedure test223; - - -- %test - -- %displayname(Test number 224) - procedure test224; - - -- %test - -- %displayname(Test number 225) - procedure test225; - - -- %test - -- %displayname(Test number 226) - procedure test226; - - -- %test - -- %displayname(Test number 227) - procedure test227; - - -- %test - -- %displayname(Test number 228) - procedure test228; - - -- %test - -- %displayname(Test number 229) - procedure test229; - - -- %test - -- %displayname(Test number 230) - procedure test230; - - -- %test - -- %displayname(Test number 231) - procedure test231; - - -- %test - -- %displayname(Test number 232) - procedure test232; - - -- %test - -- %displayname(Test number 233) - procedure test233; - - -- %test - -- %displayname(Test number 234) - procedure test234; - - -- %test - -- %displayname(Test number 235) - procedure test235; - - -- %test - -- %displayname(Test number 236) - procedure test236; - - -- %test - -- %displayname(Test number 237) - procedure test237; - - -- %test - -- %displayname(Test number 238) - procedure test238; - - -- %test - -- %displayname(Test number 239) - procedure test239; - - -- %test - -- %displayname(Test number 240) - procedure test240; - - -- %test - -- %displayname(Test number 241) - procedure test241; - - -- %test - -- %displayname(Test number 242) - procedure test242; - - -- %test - -- %displayname(Test number 243) - procedure test243; - - -- %test - -- %displayname(Test number 244) - procedure test244; - - -- %test - -- %displayname(Test number 245) - procedure test245; - - -- %test - -- %displayname(Test number 246) - procedure test246; - - -- %test - -- %displayname(Test number 247) - procedure test247; - - -- %test - -- %displayname(Test number 248) - procedure test248; - - -- %test - -- %displayname(Test number 249) - procedure test249; - - -- %test - -- %displayname(Test number 250) - procedure test250; - - -- %test - -- %displayname(Test number 251) - procedure test251; - - -- %test - -- %displayname(Test number 252) - procedure test252; - - -- %test - -- %displayname(Test number 253) - procedure test253; - - -- %test - -- %displayname(Test number 254) - procedure test254; - - -- %test - -- %displayname(Test number 255) - procedure test255; - - -- %test - -- %displayname(Test number 256) - procedure test256; - - -- %test - -- %displayname(Test number 257) - procedure test257; - - -- %test - -- %displayname(Test number 258) - procedure test258; - - -- %test - -- %displayname(Test number 259) - procedure test259; - - -- %test - -- %displayname(Test number 260) - procedure test260; - - -- %test - -- %displayname(Test number 261) - procedure test261; - - -- %test - -- %displayname(Test number 262) - procedure test262; - - -- %test - -- %displayname(Test number 263) - procedure test263; - - -- %test - -- %displayname(Test number 264) - procedure test264; - - -- %test - -- %displayname(Test number 265) - procedure test265; - - -- %test - -- %displayname(Test number 266) - procedure test266; - - -- %test - -- %displayname(Test number 267) - procedure test267; - - -- %test - -- %displayname(Test number 268) - procedure test268; - - -- %test - -- %displayname(Test number 269) - procedure test269; - - -- %test - -- %displayname(Test number 270) - procedure test270; - - -- %test - -- %displayname(Test number 271) - procedure test271; - - -- %test - -- %displayname(Test number 272) - procedure test272; - - -- %test - -- %displayname(Test number 273) - procedure test273; - - -- %test - -- %displayname(Test number 274) - procedure test274; - - -- %test - -- %displayname(Test number 275) - procedure test275; - - -- %test - -- %displayname(Test number 276) - procedure test276; - - -- %test - -- %displayname(Test number 277) - procedure test277; - - -- %test - -- %displayname(Test number 278) - procedure test278; - - -- %test - -- %displayname(Test number 279) - procedure test279; - - -- %test - -- %displayname(Test number 280) - procedure test280; - - -- %test - -- %displayname(Test number 281) - procedure test281; - - -- %test - -- %displayname(Test number 282) - procedure test282; - - -- %test - -- %displayname(Test number 283) - procedure test283; - - -- %test - -- %displayname(Test number 284) - procedure test284; - - -- %test - -- %displayname(Test number 285) - procedure test285; - - -- %test - -- %displayname(Test number 286) - procedure test286; - - -- %test - -- %displayname(Test number 287) - procedure test287; - - -- %test - -- %displayname(Test number 288) - procedure test288; - - -- %test - -- %displayname(Test number 289) - procedure test289; - - -- %test - -- %displayname(Test number 290) - procedure test290; - - -- %test - -- %displayname(Test number 291) - procedure test291; - - -- %test - -- %displayname(Test number 292) - procedure test292; - - -- %test - -- %displayname(Test number 293) - procedure test293; - - -- %test - -- %displayname(Test number 294) - procedure test294; - - -- %test - -- %displayname(Test number 295) - procedure test295; - - -- %test - -- %displayname(Test number 296) - procedure test296; - - -- %test - -- %displayname(Test number 297) - procedure test297; - - -- %test - -- %displayname(Test number 298) - procedure test298; - - -- %test - -- %displayname(Test number 299) - procedure test299; - - -- %test - -- %displayname(Test number 300) - procedure test300; - - -- %test - -- %displayname(Test number 301) - procedure test301; - - -- %test - -- %displayname(Test number 302) - procedure test302; - - -- %test - -- %displayname(Test number 303) - procedure test303; - - -- %test - -- %displayname(Test number 304) - procedure test304; - - -- %test - -- %displayname(Test number 305) - procedure test305; - - -- %test - -- %displayname(Test number 306) - procedure test306; - - -- %test - -- %displayname(Test number 307) - procedure test307; - - -- %test - -- %displayname(Test number 308) - procedure test308; - - -- %test - -- %displayname(Test number 309) - procedure test309; - - -- %test - -- %displayname(Test number 310) - procedure test310; - - -- %test - -- %displayname(Test number 311) - procedure test311; - - -- %test - -- %displayname(Test number 312) - procedure test312; - - -- %test - -- %displayname(Test number 313) - procedure test313; - - -- %test - -- %displayname(Test number 314) - procedure test314; - - -- %test - -- %displayname(Test number 315) - procedure test315; - - -- %test - -- %displayname(Test number 316) - procedure test316; - - -- %test - -- %displayname(Test number 317) - procedure test317; - - -- %test - -- %displayname(Test number 318) - procedure test318; - - -- %test - -- %displayname(Test number 319) - procedure test319; - - -- %test - -- %displayname(Test number 320) - procedure test320; - - -- %test - -- %displayname(Test number 321) - procedure test321; - - -- %test - -- %displayname(Test number 322) - procedure test322; - - -- %test - -- %displayname(Test number 323) - procedure test323; - - -- %test - -- %displayname(Test number 324) - procedure test324; - - -- %test - -- %displayname(Test number 325) - procedure test325; - - -- %test - -- %displayname(Test number 326) - procedure test326; - - -- %test - -- %displayname(Test number 327) - procedure test327; - - -- %test - -- %displayname(Test number 328) - procedure test328; - - -- %test - -- %displayname(Test number 329) - procedure test329; - - -- %test - -- %displayname(Test number 330) - procedure test330; - - -- %test - -- %displayname(Test number 331) - procedure test331; - - -- %test - -- %displayname(Test number 332) - procedure test332; - - -- %test - -- %displayname(Test number 333) - procedure test333; - - -- %test - -- %displayname(Test number 334) - procedure test334; - - -- %test - -- %displayname(Test number 335) - procedure test335; - - -- %test - -- %displayname(Test number 336) - procedure test336; - - -- %test - -- %displayname(Test number 337) - procedure test337; - - -- %test - -- %displayname(Test number 338) - procedure test338; - - -- %test - -- %displayname(Test number 339) - procedure test339; - - -- %test - -- %displayname(Test number 340) - procedure test340; - - -- %test - -- %displayname(Test number 341) - procedure test341; - - -- %test - -- %displayname(Test number 342) - procedure test342; - - -- %test - -- %displayname(Test number 343) - procedure test343; - - -- %test - -- %displayname(Test number 344) - procedure test344; - - -- %test - -- %displayname(Test number 345) - procedure test345; - - -- %test - -- %displayname(Test number 346) - procedure test346; - - -- %test - -- %displayname(Test number 347) - procedure test347; - - -- %test - -- %displayname(Test number 348) - procedure test348; - - -- %test - -- %displayname(Test number 349) - procedure test349; - - -- %test - -- %displayname(Test number 350) - procedure test350; - - -- %test - -- %displayname(Test number 351) - procedure test351; - - -- %test - -- %displayname(Test number 352) - procedure test352; - - -- %test - -- %displayname(Test number 353) - procedure test353; - - -- %test - -- %displayname(Test number 354) - procedure test354; - - -- %test - -- %displayname(Test number 355) - procedure test355; - - -- %test - -- %displayname(Test number 356) - procedure test356; - - -- %test - -- %displayname(Test number 357) - procedure test357; - - -- %test - -- %displayname(Test number 358) - procedure test358; - - -- %test - -- %displayname(Test number 359) - procedure test359; - - -- %test - -- %displayname(Test number 360) - procedure test360; - - -- %test - -- %displayname(Test number 361) - procedure test361; - - -- %test - -- %displayname(Test number 362) - procedure test362; - - -- %test - -- %displayname(Test number 363) - procedure test363; - - -- %test - -- %displayname(Test number 364) - procedure test364; - - -- %test - -- %displayname(Test number 365) - procedure test365; - - -- %test - -- %displayname(Test number 366) - procedure test366; - - -- %test - -- %displayname(Test number 367) - procedure test367; - - -- %test - -- %displayname(Test number 368) - procedure test368; - - -- %test - -- %displayname(Test number 369) - procedure test369; - - -- %test - -- %displayname(Test number 370) - procedure test370; - - -- %test - -- %displayname(Test number 371) - procedure test371; - - -- %test - -- %displayname(Test number 372) - procedure test372; - - -- %test - -- %displayname(Test number 373) - procedure test373; - - -- %test - -- %displayname(Test number 374) - procedure test374; - - -- %test - -- %displayname(Test number 375) - procedure test375; - - -- %test - -- %displayname(Test number 376) - procedure test376; - - -- %test - -- %displayname(Test number 377) - procedure test377; - - -- %test - -- %displayname(Test number 378) - procedure test378; - - -- %test - -- %displayname(Test number 379) - procedure test379; - - -- %test - -- %displayname(Test number 380) - procedure test380; - - -- %test - -- %displayname(Test number 381) - procedure test381; - - -- %test - -- %displayname(Test number 382) - procedure test382; - - -- %test - -- %displayname(Test number 383) - procedure test383; - - -- %test - -- %displayname(Test number 384) - procedure test384; - - -- %test - -- %displayname(Test number 385) - procedure test385; - - -- %test - -- %displayname(Test number 386) - procedure test386; - - -- %test - -- %displayname(Test number 387) - procedure test387; - - -- %test - -- %displayname(Test number 388) - procedure test388; - - -- %test - -- %displayname(Test number 389) - procedure test389; - - -- %test - -- %displayname(Test number 390) - procedure test390; - - -- %test - -- %displayname(Test number 391) - procedure test391; - - -- %test - -- %displayname(Test number 392) - procedure test392; - - -- %test - -- %displayname(Test number 393) - procedure test393; - - -- %test - -- %displayname(Test number 394) - procedure test394; - - -- %test - -- %displayname(Test number 395) - procedure test395; - - -- %test - -- %displayname(Test number 396) - procedure test396; - - -- %test - -- %displayname(Test number 397) - procedure test397; - - -- %test - -- %displayname(Test number 398) - procedure test398; - - -- %test - -- %displayname(Test number 399) - procedure test399; - - -- %test - -- %displayname(Test number 400) - procedure test400; - - -- %test - -- %displayname(Test number 401) - procedure test401; - - -- %test - -- %displayname(Test number 402) - procedure test402; - - -- %test - -- %displayname(Test number 403) - procedure test403; - - -- %test - -- %displayname(Test number 404) - procedure test404; - - -- %test - -- %displayname(Test number 405) - procedure test405; - - -- %test - -- %displayname(Test number 406) - procedure test406; - - -- %test - -- %displayname(Test number 407) - procedure test407; - - -- %test - -- %displayname(Test number 408) - procedure test408; - - -- %test - -- %displayname(Test number 409) - procedure test409; - - -- %test - -- %displayname(Test number 410) - procedure test410; - - -- %test - -- %displayname(Test number 411) - procedure test411; - - -- %test - -- %displayname(Test number 412) - procedure test412; - - -- %test - -- %displayname(Test number 413) - procedure test413; - - -- %test - -- %displayname(Test number 414) - procedure test414; - - -- %test - -- %displayname(Test number 415) - procedure test415; - - -- %test - -- %displayname(Test number 416) - procedure test416; - - -- %test - -- %displayname(Test number 417) - procedure test417; - - -- %test - -- %displayname(Test number 418) - procedure test418; - - -- %test - -- %displayname(Test number 419) - procedure test419; - - -- %test - -- %displayname(Test number 420) - procedure test420; - - -- %test - -- %displayname(Test number 421) - procedure test421; - - -- %test - -- %displayname(Test number 422) - procedure test422; - - -- %test - -- %displayname(Test number 423) - procedure test423; - - -- %test - -- %displayname(Test number 424) - procedure test424; - - -- %test - -- %displayname(Test number 425) - procedure test425; - - -- %test - -- %displayname(Test number 426) - procedure test426; - - -- %test - -- %displayname(Test number 427) - procedure test427; - - -- %test - -- %displayname(Test number 428) - procedure test428; - - -- %test - -- %displayname(Test number 429) - procedure test429; - - -- %test - -- %displayname(Test number 430) - procedure test430; - - -- %test - -- %displayname(Test number 431) - procedure test431; - - -- %test - -- %displayname(Test number 432) - procedure test432; - - -- %test - -- %displayname(Test number 433) - procedure test433; - - -- %test - -- %displayname(Test number 434) - procedure test434; - - -- %test - -- %displayname(Test number 435) - procedure test435; - - -- %test - -- %displayname(Test number 436) - procedure test436; - - -- %test - -- %displayname(Test number 437) - procedure test437; - - -- %test - -- %displayname(Test number 438) - procedure test438; - - -- %test - -- %displayname(Test number 439) - procedure test439; - - -- %test - -- %displayname(Test number 440) - procedure test440; - - -- %test - -- %displayname(Test number 441) - procedure test441; - - -- %test - -- %displayname(Test number 442) - procedure test442; - - -- %test - -- %displayname(Test number 443) - procedure test443; - - -- %test - -- %displayname(Test number 444) - procedure test444; - - -- %test - -- %displayname(Test number 445) - procedure test445; - - -- %test - -- %displayname(Test number 446) - procedure test446; - - -- %test - -- %displayname(Test number 447) - procedure test447; - - -- %test - -- %displayname(Test number 448) - procedure test448; - - -- %test - -- %displayname(Test number 449) - procedure test449; - - -- %test - -- %displayname(Test number 450) - procedure test450; - - -- %test - -- %displayname(Test number 451) - procedure test451; - - -- %test - -- %displayname(Test number 452) - procedure test452; - - -- %test - -- %displayname(Test number 453) - procedure test453; - - -- %test - -- %displayname(Test number 454) - procedure test454; - - -- %test - -- %displayname(Test number 455) - procedure test455; - - -- %test - -- %displayname(Test number 456) - procedure test456; - - -- %test - -- %displayname(Test number 457) - procedure test457; - - -- %test - -- %displayname(Test number 458) - procedure test458; - - -- %test - -- %displayname(Test number 459) - procedure test459; - - -- %test - -- %displayname(Test number 460) - procedure test460; - - -- %test - -- %displayname(Test number 461) - procedure test461; - - -- %test - -- %displayname(Test number 462) - procedure test462; - - -- %test - -- %displayname(Test number 463) - procedure test463; - - -- %test - -- %displayname(Test number 464) - procedure test464; - - -- %test - -- %displayname(Test number 465) - procedure test465; - - -- %test - -- %displayname(Test number 466) - procedure test466; - - -- %test - -- %displayname(Test number 467) - procedure test467; - - -- %test - -- %displayname(Test number 468) - procedure test468; - - -- %test - -- %displayname(Test number 469) - procedure test469; - - -- %test - -- %displayname(Test number 470) - procedure test470; - - -- %test - -- %displayname(Test number 471) - procedure test471; - - -- %test - -- %displayname(Test number 472) - procedure test472; - - -- %test - -- %displayname(Test number 473) - procedure test473; - - -- %test - -- %displayname(Test number 474) - procedure test474; - - -- %test - -- %displayname(Test number 475) - procedure test475; - - -- %test - -- %displayname(Test number 476) - procedure test476; - - -- %test - -- %displayname(Test number 477) - procedure test477; - - -- %test - -- %displayname(Test number 478) - procedure test478; - - -- %test - -- %displayname(Test number 479) - procedure test479; - - -- %test - -- %displayname(Test number 480) - procedure test480; - - -- %test - -- %displayname(Test number 481) - procedure test481; - - -- %test - -- %displayname(Test number 482) - procedure test482; - - -- %test - -- %displayname(Test number 483) - procedure test483; - - -- %test - -- %displayname(Test number 484) - procedure test484; - - -- %test - -- %displayname(Test number 485) - procedure test485; - - -- %test - -- %displayname(Test number 486) - procedure test486; - - -- %test - -- %displayname(Test number 487) - procedure test487; - - -- %test - -- %displayname(Test number 488) - procedure test488; - - -- %test - -- %displayname(Test number 489) - procedure test489; - - -- %test - -- %displayname(Test number 490) - procedure test490; - - -- %test - -- %displayname(Test number 491) - procedure test491; - - -- %test - -- %displayname(Test number 492) - procedure test492; - - -- %test - -- %displayname(Test number 493) - procedure test493; - - -- %test - -- %displayname(Test number 494) - procedure test494; - - -- %test - -- %displayname(Test number 495) - procedure test495; - - -- %test - -- %displayname(Test number 496) - procedure test496; - - -- %test - -- %displayname(Test number 497) - procedure test497; - - -- %test - -- %displayname(Test number 498) - procedure test498; - - -- %test - -- %displayname(Test number 499) - procedure test499; - - -- %test - -- %displayname(Test number 500) - procedure test500; - - -- %test - -- %displayname(Test with setup number 1) - -- %beforetest(test_setup1) - -- %aftertest(test_teardown1) - procedure test_with_procs1; - - procedure test_setup1; - - procedure test_teardown1; - - -- %test - -- %displayname(Test with setup number 2) - -- %beforetest(test_setup2) - -- %aftertest(test_teardown2) - procedure test_with_procs2; - - procedure test_setup2; - - procedure test_teardown2; - - -- %test - -- %displayname(Test with setup number 3) - -- %beforetest(test_setup3) - -- %aftertest(test_teardown3) - procedure test_with_procs3; - - procedure test_setup3; - - procedure test_teardown3; - - -- %test - -- %displayname(Test with setup number 4) - -- %beforetest(test_setup4) - -- %aftertest(test_teardown4) - procedure test_with_procs4; - - procedure test_setup4; - - procedure test_teardown4; - - -- %test - -- %displayname(Test with setup number 5) - -- %beforetest(test_setup5) - -- %aftertest(test_teardown5) - procedure test_with_procs5; - - procedure test_setup5; - - procedure test_teardown5; - - -- %test - -- %displayname(Test with setup number 6) - -- %beforetest(test_setup6) - -- %aftertest(test_teardown6) - procedure test_with_procs6; - - procedure test_setup6; - - procedure test_teardown6; - - -- %test - -- %displayname(Test with setup number 7) - -- %beforetest(test_setup7) - -- %aftertest(test_teardown7) - procedure test_with_procs7; - - procedure test_setup7; - - procedure test_teardown7; - - -- %test - -- %displayname(Test with setup number 8) - -- %beforetest(test_setup8) - -- %aftertest(test_teardown8) - procedure test_with_procs8; - - procedure test_setup8; - - procedure test_teardown8; - - -- %test - -- %displayname(Test with setup number 9) - -- %beforetest(test_setup9) - -- %aftertest(test_teardown9) - procedure test_with_procs9; - - procedure test_setup9; - - procedure test_teardown9; - - -- %test - -- %displayname(Test with setup number 10) - -- %beforetest(test_setup10) - -- %aftertest(test_teardown10) - procedure test_with_procs10; - - procedure test_setup10; - - procedure test_teardown10; - - -- %test - -- %displayname(Test with setup number 11) - -- %beforetest(test_setup11) - -- %aftertest(test_teardown11) - procedure test_with_procs11; - - procedure test_setup11; - - procedure test_teardown11; - - -- %test - -- %displayname(Test with setup number 12) - -- %beforetest(test_setup12) - -- %aftertest(test_teardown12) - procedure test_with_procs12; - - procedure test_setup12; - - procedure test_teardown12; - - -- %test - -- %displayname(Test with setup number 13) - -- %beforetest(test_setup13) - -- %aftertest(test_teardown13) - procedure test_with_procs13; - - procedure test_setup13; - - procedure test_teardown13; - - -- %test - -- %displayname(Test with setup number 14) - -- %beforetest(test_setup14) - -- %aftertest(test_teardown14) - procedure test_with_procs14; - - procedure test_setup14; - - procedure test_teardown14; - - -- %test - -- %displayname(Test with setup number 15) - -- %beforetest(test_setup15) - -- %aftertest(test_teardown15) - procedure test_with_procs15; - - procedure test_setup15; - - procedure test_teardown15; - - -- %test - -- %displayname(Test with setup number 16) - -- %beforetest(test_setup16) - -- %aftertest(test_teardown16) - procedure test_with_procs16; - - procedure test_setup16; - - procedure test_teardown16; - - -- %test - -- %displayname(Test with setup number 17) - -- %beforetest(test_setup17) - -- %aftertest(test_teardown17) - procedure test_with_procs17; - - procedure test_setup17; - - procedure test_teardown17; - - -- %test - -- %displayname(Test with setup number 18) - -- %beforetest(test_setup18) - -- %aftertest(test_teardown18) - procedure test_with_procs18; - - procedure test_setup18; - - procedure test_teardown18; - - -- %test - -- %displayname(Test with setup number 19) - -- %beforetest(test_setup19) - -- %aftertest(test_teardown19) - procedure test_with_procs19; - - procedure test_setup19; - - procedure test_teardown19; - - -- %test - -- %displayname(Test with setup number 20) - -- %beforetest(test_setup20) - -- %aftertest(test_teardown20) - procedure test_with_procs20; - - procedure test_setup20; - - procedure test_teardown20; - - -- %test - -- %displayname(Test with setup number 21) - -- %beforetest(test_setup21) - -- %aftertest(test_teardown21) - procedure test_with_procs21; - - procedure test_setup21; - - procedure test_teardown21; - - -- %test - -- %displayname(Test with setup number 22) - -- %beforetest(test_setup22) - -- %aftertest(test_teardown22) - procedure test_with_procs22; - - procedure test_setup22; - - procedure test_teardown22; - - -- %test - -- %displayname(Test with setup number 23) - -- %beforetest(test_setup23) - -- %aftertest(test_teardown23) - procedure test_with_procs23; - - procedure test_setup23; - - procedure test_teardown23; - - -- %test - -- %displayname(Test with setup number 24) - -- %beforetest(test_setup24) - -- %aftertest(test_teardown24) - procedure test_with_procs24; - - procedure test_setup24; - - procedure test_teardown24; - - -- %test - -- %displayname(Test with setup number 25) - -- %beforetest(test_setup25) - -- %aftertest(test_teardown25) - procedure test_with_procs25; - - procedure test_setup25; - - procedure test_teardown25; - - -- %test - -- %displayname(Test with setup number 26) - -- %beforetest(test_setup26) - -- %aftertest(test_teardown26) - procedure test_with_procs26; - - procedure test_setup26; - - procedure test_teardown26; - - -- %test - -- %displayname(Test with setup number 27) - -- %beforetest(test_setup27) - -- %aftertest(test_teardown27) - procedure test_with_procs27; - - procedure test_setup27; - - procedure test_teardown27; - - -- %test - -- %displayname(Test with setup number 28) - -- %beforetest(test_setup28) - -- %aftertest(test_teardown28) - procedure test_with_procs28; - - procedure test_setup28; - - procedure test_teardown28; - - -- %test - -- %displayname(Test with setup number 29) - -- %beforetest(test_setup29) - -- %aftertest(test_teardown29) - procedure test_with_procs29; - - procedure test_setup29; - - procedure test_teardown29; - - -- %test - -- %displayname(Test with setup number 30) - -- %beforetest(test_setup30) - -- %aftertest(test_teardown30) - procedure test_with_procs30; - - procedure test_setup30; - - procedure test_teardown30; - - -- %test - -- %displayname(Test with setup number 31) - -- %beforetest(test_setup31) - -- %aftertest(test_teardown31) - procedure test_with_procs31; - - procedure test_setup31; - - procedure test_teardown31; - - -- %test - -- %displayname(Test with setup number 32) - -- %beforetest(test_setup32) - -- %aftertest(test_teardown32) - procedure test_with_procs32; - - procedure test_setup32; - - procedure test_teardown32; - - -- %test - -- %displayname(Test with setup number 33) - -- %beforetest(test_setup33) - -- %aftertest(test_teardown33) - procedure test_with_procs33; - - procedure test_setup33; - - procedure test_teardown33; - - -- %test - -- %displayname(Test with setup number 34) - -- %beforetest(test_setup34) - -- %aftertest(test_teardown34) - procedure test_with_procs34; - - procedure test_setup34; - - procedure test_teardown34; - - -- %test - -- %displayname(Test with setup number 35) - -- %beforetest(test_setup35) - -- %aftertest(test_teardown35) - procedure test_with_procs35; - - procedure test_setup35; - - procedure test_teardown35; - - -- %test - -- %displayname(Test with setup number 36) - -- %beforetest(test_setup36) - -- %aftertest(test_teardown36) - procedure test_with_procs36; - - procedure test_setup36; - - procedure test_teardown36; - - -- %test - -- %displayname(Test with setup number 37) - -- %beforetest(test_setup37) - -- %aftertest(test_teardown37) - procedure test_with_procs37; - - procedure test_setup37; - - procedure test_teardown37; - - -- %test - -- %displayname(Test with setup number 38) - -- %beforetest(test_setup38) - -- %aftertest(test_teardown38) - procedure test_with_procs38; - - procedure test_setup38; - - procedure test_teardown38; - - -- %test - -- %displayname(Test with setup number 39) - -- %beforetest(test_setup39) - -- %aftertest(test_teardown39) - procedure test_with_procs39; - - procedure test_setup39; - - procedure test_teardown39; - - -- %test - -- %displayname(Test with setup number 40) - -- %beforetest(test_setup40) - -- %aftertest(test_teardown40) - procedure test_with_procs40; - - procedure test_setup40; - - procedure test_teardown40; - - -- %test - -- %displayname(Test with setup number 41) - -- %beforetest(test_setup41) - -- %aftertest(test_teardown41) - procedure test_with_procs41; - - procedure test_setup41; - - procedure test_teardown41; - - -- %test - -- %displayname(Test with setup number 42) - -- %beforetest(test_setup42) - -- %aftertest(test_teardown42) - procedure test_with_procs42; - - procedure test_setup42; - - procedure test_teardown42; - - -- %test - -- %displayname(Test with setup number 43) - -- %beforetest(test_setup43) - -- %aftertest(test_teardown43) - procedure test_with_procs43; - - procedure test_setup43; - - procedure test_teardown43; - - -- %test - -- %displayname(Test with setup number 44) - -- %beforetest(test_setup44) - -- %aftertest(test_teardown44) - procedure test_with_procs44; - - procedure test_setup44; - - procedure test_teardown44; - - -- %test - -- %displayname(Test with setup number 45) - -- %beforetest(test_setup45) - -- %aftertest(test_teardown45) - procedure test_with_procs45; - - procedure test_setup45; - - procedure test_teardown45; - - -- %test - -- %displayname(Test with setup number 46) - -- %beforetest(test_setup46) - -- %aftertest(test_teardown46) - procedure test_with_procs46; - - procedure test_setup46; - - procedure test_teardown46; - - -- %test - -- %displayname(Test with setup number 47) - -- %beforetest(test_setup47) - -- %aftertest(test_teardown47) - procedure test_with_procs47; - - procedure test_setup47; - - procedure test_teardown47; - - -- %test - -- %displayname(Test with setup number 48) - -- %beforetest(test_setup48) - -- %aftertest(test_teardown48) - procedure test_with_procs48; - - procedure test_setup48; - - procedure test_teardown48; - - -- %test - -- %displayname(Test with setup number 49) - -- %beforetest(test_setup49) - -- %aftertest(test_teardown49) - procedure test_with_procs49; - - procedure test_setup49; - - procedure test_teardown49; - - -- %test - -- %displayname(Test with setup number 50) - -- %beforetest(test_setup50) - -- %aftertest(test_teardown50) - procedure test_with_procs50; - - procedure test_setup50; - - procedure test_teardown50; - - -- %beforeeach - procedure def_setup; - - -- %aftereach - procedure def_teardown; - - -- %beforeall - procedure global_setup; - - --%afterall - procedure global_teardown; - -end; -/ diff --git a/examples/developer_examples/ut_exampletest.pkb b/examples/developer_examples/ut_exampletest.pkb deleted file mode 100644 index 1dd5734cb..000000000 --- a/examples/developer_examples/ut_exampletest.pkb +++ /dev/null @@ -1,24 +0,0 @@ -create or replace package body ut_exampletest -AS - - procedure Setup - as - begin - null; - end; - - procedure TearDown - as - begin - null; - end; - - procedure ut_exampletest - as - begin - ut.expect(1,'Test 1 Should Pass').to_equal(1); - ut.expect(2,'Test 2 Should Fail').to_equal(1); - end; - -END; -/ diff --git a/examples/developer_examples/ut_exampletest.pks b/examples/developer_examples/ut_exampletest.pks deleted file mode 100644 index afb488d48..000000000 --- a/examples/developer_examples/ut_exampletest.pks +++ /dev/null @@ -1,7 +0,0 @@ -create or replace package ut_exampletest -AS - procedure Setup; - procedure TearDown; - procedure ut_exampletest; -END; -/ diff --git a/examples/developer_examples/ut_exampletest2.pkb b/examples/developer_examples/ut_exampletest2.pkb deleted file mode 100644 index e35baa853..000000000 --- a/examples/developer_examples/ut_exampletest2.pkb +++ /dev/null @@ -1,24 +0,0 @@ -create or replace package body ut_exampletest2 -AS - - procedure Setup - as - begin - null; - end; - - procedure TearDown - as - begin - null; - end; - - procedure ut_exampletest - as - begin - ut.expect(1,'Test 1 Should Pass').to_equal(1); - ut.expect(2,'Test 2 Should Pass').to_equal(2); - end; - -END; -/ diff --git a/examples/developer_examples/ut_exampletest2.pks b/examples/developer_examples/ut_exampletest2.pks deleted file mode 100644 index 3e8e9820f..000000000 --- a/examples/developer_examples/ut_exampletest2.pks +++ /dev/null @@ -1,7 +0,0 @@ -create or replace package ut_exampletest2 -AS - procedure Setup; - procedure TearDown; - procedure ut_exampletest; -END; -/ diff --git a/examples/employee_pipe.pkg b/examples/employee_pipe.pkg new file mode 100644 index 000000000..cf99174dd --- /dev/null +++ b/examples/employee_pipe.pkg @@ -0,0 +1,265 @@ +CREATE OR REPLACE PACKAGE EMPLOYEE_pipe +-- Wrapper around pipe based on EMPLOYEE +-- Generated using GenX +-- Author: Steven Feuerstein, steven@stevenfeuerstein.com +IS + PROCEDURE setpipe (pipe_in IN VARCHAR2); + FUNCTION pipe RETURN VARCHAR; + + FUNCTION send ( + EMPLOYEE_ID_in IN number, + LAST_NAME_in IN varchar2, + FIRST_NAME_in IN varchar2, + MIDDLE_INITIAL_in IN varchar2, + JOB_ID_in IN number, + MANAGER_ID_in IN number, + HIRE_DATE_in IN date, + SALARY_in IN number, + COMMISSION_in IN number, + DEPARTMENT_ID_in IN number, + CHANGED_BY_in IN varchar2, + CHANGED_ON_in IN date, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER; + + FUNCTION send (rec IN EMPLOYEE%ROWTYPE, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER; + + FUNCTION receive ( + EMPLOYEE_ID_out OUT number, + LAST_NAME_out OUT varchar2, + FIRST_NAME_out OUT varchar2, + MIDDLE_INITIAL_out OUT varchar2, + JOB_ID_out OUT number, + MANAGER_ID_out OUT number, + HIRE_DATE_out OUT date, + SALARY_out OUT number, + COMMISSION_out OUT number, + DEPARTMENT_ID_out OUT number, + CHANGED_BY_out OUT varchar2, + CHANGED_ON_out OUT date, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER; + + FUNCTION receive (rec OUT EMPLOYEE%ROWTYPE, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER; + + PROCEDURE fillpipe (pipe_in IN VARCHAR2); + PROCEDURE emptypipe (pipe_in IN VARCHAR2); + + /* Unit Test code in same package */ + + PROCEDURE ut_setup; + + PROCEDURE ut_teardown; + + PROCEDURE ut_fillpipe; +END; +/ +CREATE OR REPLACE PACKAGE BODY EMPLOYEE_pipe +IS + g_name VARCHAR2(200) := 'EMPLOYEE_pipe'; + + PROCEDURE setpipe (pipe_in IN VARCHAR2) IS + BEGIN g_name := pipe_in; END; + + FUNCTION pipe RETURN VARCHAR IS BEGIN RETURN g_name; END; + + FUNCTION send ( + EMPLOYEE_ID_in IN number, + LAST_NAME_in IN varchar2, + FIRST_NAME_in IN varchar2, + MIDDLE_INITIAL_in IN varchar2, + JOB_ID_in IN number, + MANAGER_ID_in IN number, + HIRE_DATE_in IN date, + SALARY_in IN number, + COMMISSION_in IN number, + DEPARTMENT_ID_in IN number, + CHANGED_BY_in IN varchar2, + CHANGED_ON_in IN date, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER + IS + stat INTEGER; + BEGIN + DBMS_PIPE.RESET_BUFFER; + DBMS_PIPE.PACK_MESSAGE (EMPLOYEE_ID_in); + DBMS_PIPE.PACK_MESSAGE (LAST_NAME_in); + DBMS_PIPE.PACK_MESSAGE (FIRST_NAME_in); + DBMS_PIPE.PACK_MESSAGE (MIDDLE_INITIAL_in); + DBMS_PIPE.PACK_MESSAGE (JOB_ID_in); + DBMS_PIPE.PACK_MESSAGE (MANAGER_ID_in); + DBMS_PIPE.PACK_MESSAGE (HIRE_DATE_in); + DBMS_PIPE.PACK_MESSAGE (SALARY_in); + DBMS_PIPE.PACK_MESSAGE (COMMISSION_in); + DBMS_PIPE.PACK_MESSAGE (DEPARTMENT_ID_in); + DBMS_PIPE.PACK_MESSAGE (CHANGED_BY_in); + DBMS_PIPE.PACK_MESSAGE (CHANGED_ON_in); + + stat := DBMS_PIPE.SEND_MESSAGE (g_name, wait); + + RETURN stat; + END; + + FUNCTION receive ( + EMPLOYEE_ID_out OUT number, + LAST_NAME_out OUT varchar2, + FIRST_NAME_out OUT varchar2, + MIDDLE_INITIAL_out OUT varchar2, + JOB_ID_out OUT number, + MANAGER_ID_out OUT number, + HIRE_DATE_out OUT date, + SALARY_out OUT number, + COMMISSION_out OUT number, + DEPARTMENT_ID_out OUT number, + CHANGED_BY_out OUT varchar2, + CHANGED_ON_out OUT date, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER + IS + stat INTEGER; + BEGIN + --// Receive next message and unpack for each column. //-- + stat := DBMS_PIPE.RECEIVE_MESSAGE (g_name, wait); + + IF stat = 0 + THEN + DBMS_PIPE.UNPACK_MESSAGE (EMPLOYEE_ID_out); + DBMS_PIPE.UNPACK_MESSAGE (LAST_NAME_out); + DBMS_PIPE.UNPACK_MESSAGE (FIRST_NAME_out); + DBMS_PIPE.UNPACK_MESSAGE (MIDDLE_INITIAL_out); + DBMS_PIPE.UNPACK_MESSAGE (JOB_ID_out); + DBMS_PIPE.UNPACK_MESSAGE (MANAGER_ID_out); + DBMS_PIPE.UNPACK_MESSAGE (HIRE_DATE_out); + DBMS_PIPE.UNPACK_MESSAGE (SALARY_out); + DBMS_PIPE.UNPACK_MESSAGE (COMMISSION_out); + DBMS_PIPE.UNPACK_MESSAGE (DEPARTMENT_ID_out); + DBMS_PIPE.UNPACK_MESSAGE (CHANGED_BY_out); + DBMS_PIPE.UNPACK_MESSAGE (CHANGED_ON_out); + END IF; + + RETURN stat; + END; + + FUNCTION send (rec IN EMPLOYEE%ROWTYPE, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER + IS + stat PLS_INTEGER; + BEGIN + stat := send ( + rec.EMPLOYEE_ID, + rec.LAST_NAME, + rec.FIRST_NAME, + rec.MIDDLE_INITIAL, + rec.JOB_ID, + rec.MANAGER_ID, + rec.HIRE_DATE, + rec.SALARY, + rec.COMMISSION, + rec.DEPARTMENT_ID, + rec.CHANGED_BY, + rec.CHANGED_ON, + wait); + RETURN stat; + END; + + FUNCTION receive (rec OUT EMPLOYEE%ROWTYPE, + wait IN INTEGER := 0 + ) RETURN PLS_INTEGER + IS + stat PLS_INTEGER; + BEGIN + stat := receive ( + rec.EMPLOYEE_ID, + rec.LAST_NAME, + rec.FIRST_NAME, + rec.MIDDLE_INITIAL, + rec.JOB_ID, + rec.MANAGER_ID, + rec.HIRE_DATE, + rec.SALARY, + rec.COMMISSION, + rec.DEPARTMENT_ID, + rec.CHANGED_BY, + rec.CHANGED_ON, + wait); + RETURN stat; + END; + + PROCEDURE fillpipe (pipe_in IN VARCHAR2) + IS + stat PLS_INTEGER; + BEGIN + employee_pipe.setpipe (pipe_in); + + FOR rec IN (SELECT * + FROM employee) + LOOP + stat := employee_pipe.send (rec); + END LOOP; + END; + + PROCEDURE emptypipe (pipe_in IN VARCHAR2) + IS + stat PLS_INTEGER; + BEGIN + LOOP + stat := DBMS_PIPE.RECEIVE_MESSAGE (pipe_in, 0); + EXIT WHEN stat != 0; + END LOOP; + END; + + /* Unit Test code in same package */ + + PROCEDURE ut_setup IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown IS + BEGIN + NULL; + END; + + PROCEDURE ut_fillpipe IS + stat PLS_INTEGER; + BEGIN + emptypipe ('emps'); + emptypipe ('emps2'); + + fillpipe ('emps'); + + /* Direct filling of pipe. */ + + FOR rec IN (SELECT * + FROM employee) + LOOP + DBMS_PIPE.RESET_BUFFER; + DBMS_PIPE.PACK_MESSAGE (rec.EMPLOYEE_ID); + DBMS_PIPE.PACK_MESSAGE (rec.LAST_NAME); + DBMS_PIPE.PACK_MESSAGE (rec.FIRST_NAME); + DBMS_PIPE.PACK_MESSAGE (rec.MIDDLE_INITIAL); + DBMS_PIPE.PACK_MESSAGE (rec.JOB_ID); + DBMS_PIPE.PACK_MESSAGE (rec.MANAGER_ID); + DBMS_PIPE.PACK_MESSAGE (rec.HIRE_DATE); + DBMS_PIPE.PACK_MESSAGE (rec.SALARY); + DBMS_PIPE.PACK_MESSAGE (rec.COMMISSION); + DBMS_PIPE.PACK_MESSAGE (rec.DEPARTMENT_ID); + DBMS_PIPE.PACK_MESSAGE (rec.CHANGED_BY); + DBMS_PIPE.PACK_MESSAGE (rec.CHANGED_ON); + + stat := DBMS_PIPE.SEND_MESSAGE ('emps2', 0); + END LOOP; + + /* Compare the two */ + utassert.eqpipe ( + 'Two employee pipes', 'emps', 'emps2'); + + END ut_fillpipe; + +END; +/ \ No newline at end of file diff --git a/examples/filepath1.pkg b/examples/filepath1.pkg new file mode 100644 index 000000000..350b7f74f --- /dev/null +++ b/examples/filepath1.pkg @@ -0,0 +1,131 @@ +CREATE TYPE dirs_tabtype IS TABLE OF VARCHAR2(2000); +/ + +CREATE OR REPLACE PACKAGE fileIO +IS + c_delim CHAR(1) := ';'; + + dirs dirs_tabtype := dirs_tabtype (); + + -- Unit test list + ut_dirs dirs_tabtype := dirs_tabtype (); + + PROCEDURE setpath (str IN VARCHAR2, delim IN VARCHAR2 := c_delim); + FUNCTION path RETURN VARCHAR2; + FUNCTION pathlist RETURN dirs_tabtype; + + FUNCTION open (file IN VARCHAR2, loc IN VARCHAR2 := NULL) RETURN UTL_FILE.FILE_TYPE; + + -- Unit test code in same package + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + PROCEDURE ut_setpath; +END; +/ + +CREATE OR REPLACE PACKAGE BODY fileIO +IS + g_path VARCHAR2(32767); + g_delim CHAR(1) := c_delim; + + PROCEDURE setpath (str IN VARCHAR2, delim IN VARCHAR2 := c_delim) + IS + BEGIN + g_path := str; + g_delim := NVL (delim, c_delim); + str2list.parse (str, g_delim, 'fileIO', 'dirs'); + END; + + FUNCTION path RETURN VARCHAR2 + IS + BEGIN + RETURN g_path; + END; + + FUNCTION pathlist RETURN dirs_tabtype + IS + BEGIN + RETURN dirs; + END; + + FUNCTION open (file IN VARCHAR2, loc IN VARCHAR2 := NULL) RETURN UTL_FILE.FILE_TYPE + IS + indx PLS_INTEGER; + + /* Location of next path separator */ + v_lastsep PLS_INTEGER := 1; + v_sep PLS_INTEGER := INSTR (g_path, c_delim); + v_dir VARCHAR2(500); + retval UTL_FILE.FILE_TYPE; + + PROCEDURE set_next_dir IS + BEGIN + v_sep := INSTR (g_path, c_delim, v_sep+1); + IF v_sep = 0 + THEN + v_dir := SUBSTR (g_path, v_lastsep); + ELSE + v_dir := SUBSTR (g_path, v_lastsep, v_sep - v_lastsep); + END IF; + END; + BEGIN + IF loc IS NOT NULL + THEN + indx := NULL; + v_dir := loc; + ELSE + indx := dirs.FIRST; + v_dir := dirs(indx); + END IF; + + WHILE v_dir IS NOT NULL + LOOP + BEGIN + --DBMS_OUTPUT.PUT_LINE ('...looking in ' || v_dir); + retval := UTL_FILE.FOPEN (v_dir, file, 'R'); + EXIT; + EXCEPTION + WHEN OTHERS + THEN + indx := dirs.NEXT (indx); + IF indx IS NULL + THEN + v_dir := NULL; + ELSE + v_dir := dirs(indx); + END IF; + END; + END LOOP; + RETURN retval; + END; + + PROCEDURE ut_setup IS + BEGIN + NULL: + END; + + PROCEDURE ut_teardown + IS BEGIN NULL; END; + + PROCEDURE ut_setpath + IS + BEGIN + /* Populate base collection */ + ut_dirs.DELETE; + + ut_dirs.EXTEND(2); + ut_dirs(1) := 'c:\temp'; + ut_dirs(2) := 'e:\demo'; + + /* Call setpath to do the work */ + setpath ('c:\temp;e:\demo'); + + utAssert.eqColl ( + 'Valid double entry', + 'fileio.dirs', + 'fileio.ut_dirs' + ); + END; + +END; +/ diff --git a/examples/filepath2.pkg b/examples/filepath2.pkg new file mode 100644 index 000000000..c82ddbf4c --- /dev/null +++ b/examples/filepath2.pkg @@ -0,0 +1,177 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2000/09/16 06:52 */ + +CREATE OR REPLACE PACKAGE fileio +IS + c_delim CHAR (1) := ';'; + + TYPE dirs_ibtabtype IS TABLE OF VARCHAR2 (2000) + INDEX BY BINARY_INTEGER; + + PROCEDURE setpath (str IN VARCHAR2, delim IN VARCHAR2 := c_delim); + + FUNCTION path + RETURN VARCHAR2; + + FUNCTION pathlist + RETURN dirs_ibtabtype; + + PROCEDURE append (onedir IN VARCHAR2); + + PROCEDURE delete (rowindex IN PLS_INTEGER := NULL); + + FUNCTION COUNT + RETURN PLS_INTEGER; + + FUNCTION FIRST + RETURN PLS_INTEGER; + + FUNCTION LAST + RETURN PLS_INTEGER; + + FUNCTION NEXT (rowindex IN PLS_INTEGER := NULL) + RETURN PLS_INTEGER; + + FUNCTION nthval (rowindex IN PLS_INTEGER := NULL) + RETURN VARCHAR2; + + FUNCTION open (file IN VARCHAR2, loc IN VARCHAR2 := NULL) + RETURN UTL_FILE.file_type; +END; +/ + +CREATE OR REPLACE PACKAGE BODY fileio +IS + g_path VARCHAR2 (32767); + g_delim CHAR (1) := c_delim; + dirs dirs_ibtabtype; + + PROCEDURE setpath (str IN VARCHAR2, delim IN VARCHAR2 := c_delim) + IS + BEGIN + g_path := str; + g_delim := NVL (delim, c_delim); + str2list.parse (str, g_delim, 'fileIO', 'append', 'delete', 'VARCHAR2(32767)'); + END; + + PROCEDURE append (onedir IN VARCHAR2) + IS + BEGIN + dirs (NVL (dirs.LAST, 0) + 1) := onedir; + END; + + PROCEDURE delete (rowindex IN PLS_INTEGER := NULL) + IS + BEGIN + IF rowindex IS NULL + THEN + dirs.delete; + ELSE + dirs.delete (rowindex); + END IF; + END; + + FUNCTION COUNT + RETURN PLS_INTEGER + IS + BEGIN + RETURN dirs.COUNT; + END; + + FUNCTION FIRST + RETURN PLS_INTEGER + IS + BEGIN + RETURN dirs.FIRST; + END; + + FUNCTION LAST + RETURN PLS_INTEGER + IS + BEGIN + RETURN dirs.FIRST; + END; + + FUNCTION NEXT (rowindex IN PLS_INTEGER := NULL) + RETURN PLS_INTEGER + IS + BEGIN + RETURN dirs.NEXT (rowindex); + END; + + FUNCTION nthval (rowindex IN PLS_INTEGER := NULL) + RETURN VARCHAR2 + IS + BEGIN + RETURN dirs (rowindex); + END; + + FUNCTION path + RETURN VARCHAR2 + IS + BEGIN + RETURN g_path; + END; + + FUNCTION pathlist + RETURN dirs_ibtabtype + IS + BEGIN + RETURN dirs; + END; + + FUNCTION open (file IN VARCHAR2, loc IN VARCHAR2 := NULL) + RETURN UTL_FILE.file_type + IS + indx PLS_INTEGER; + /* Location of next path separator */ + v_lastsep PLS_INTEGER := 1; + v_sep PLS_INTEGER := INSTR (g_path, c_delim); + v_dir VARCHAR2 (500); + retval UTL_FILE.file_type; + + PROCEDURE set_next_dir + IS + BEGIN + v_sep := INSTR (g_path, c_delim, v_sep + 1); + + IF v_sep = 0 + THEN + v_dir := SUBSTR (g_path, v_lastsep); + ELSE + v_dir := SUBSTR (g_path, v_lastsep, v_sep - v_lastsep); + END IF; + END; + BEGIN + IF loc IS NOT NULL + THEN + indx := NULL; + v_dir := loc; + ELSE + indx := dirs.FIRST; + v_dir := dirs (indx); + END IF; + + WHILE v_dir IS NOT NULL + LOOP + BEGIN + --DBMS_OUTPUT.PUT_LINE ('...looking in ' || v_dir); + retval := UTL_FILE.fopen (v_dir, file, 'R'); + EXIT; + EXCEPTION + WHEN OTHERS + THEN + indx := dirs.NEXT (indx); + + IF indx IS NULL + THEN + v_dir := NULL; + ELSE + v_dir := dirs (indx); + END IF; + END; + END LOOP; + + RETURN retval; + END; +END; +/ diff --git a/examples/gen_ut_betwnstr.pro b/examples/gen_ut_betwnstr.pro new file mode 100644 index 000000000..e8e5ef26d --- /dev/null +++ b/examples/gen_ut_betwnstr.pro @@ -0,0 +1,17 @@ +CREATE OR REPLACE PROCEDURE gen_ut_betwnstr +IS + utc VARCHAR2 (1000) + := '#program name|overload|test case name|message|arguments|result|assertion type +betwnstr||normal|normal|abcdefgh;3;5|cde|eq +betwnstr||zero start|zero start|abcdefgh;0;2|abc|eq +betwnstr||null start|null start|abcdefgh;!null;2|null|isnull +betwnstr||null end|null end|abcdefgh;!3;!null|null|isnull'; +BEGIN + utconfig.setdir ('d:\openoracle\utplsql\examples'); + utconfig.showconfig; + utgen.testpkg_from_string ('betwnstr', + utc, + output_type_in=> utgen.c_file, + dir_in=> 'c:\temp' + ); +END; diff --git a/examples/gen_ut_betwnstr.sql b/examples/gen_ut_betwnstr.sql new file mode 100644 index 000000000..50e627682 --- /dev/null +++ b/examples/gen_ut_betwnstr.sql @@ -0,0 +1,20 @@ +DECLARE + utc VARCHAR2 (1000) + := '#program name|test case name|message|arguments|result|assertion type +betwnstr|1|normal|normal|abcdefgh;3;5|cde|eq +betwnstr|1|zero start|zero start|abcdefgh;0;2|ab|eq +betwnstr|1|null start|null start|abcdefgh;!null;2|null|isnull +betwnstr|1|big start small end|big start small end|abcdefgh;10;5|null|isnull +betwnstr|1|null end|null end|abcdefgh;!3;!null|null|isnull' +; +BEGIN + utgen.testpkg_from_string ('betwnstr', + utc + /*, + output_type_in=> utgen.c_file, + dir_in=> 'd:\demo-seminar' + */ + ); +END; +/ + diff --git a/examples/gen_ut_betwnstr_to_screen.sql b/examples/gen_ut_betwnstr_to_screen.sql new file mode 100644 index 000000000..d33f8bffc --- /dev/null +++ b/examples/gen_ut_betwnstr_to_screen.sql @@ -0,0 +1,16 @@ +/* Formatted on 2001/08/21 09:10 (RevealNet Formatter v4.4.1) */ +DECLARE + utc VARCHAR2 (1000) + := '#program name|test case name|message|arguments|result|assertion type +betwnstr|1|normal|normal|abcdefgh;3;5|cde|eq +betwnstr|1|zero start|zero start|abcdefgh;0;2|abc|eq +betwnstr|1|null start|null start|abcdefgh;!null;2|null|isnull +betwnstr|1|null end|null end|abcdefgh;!3;!null|null|isnull'; +BEGIN + utgen.testpkg_from_string ( + 'betwnstr', + utc + ); +END; +/ + diff --git a/examples/gen_ut_plvstr.pro b/examples/gen_ut_plvstr.pro new file mode 100644 index 000000000..90758e0cd --- /dev/null +++ b/examples/gen_ut_plvstr.pro @@ -0,0 +1,19 @@ +CREATE OR REPLACE PROCEDURE gen_ut_plvstr +IS + utc VARCHAR2 (1000) + := '#program name|overload#|test case name|message|arguments|result|assertion type +betwn|1|normal|normal|abcdefgh;3;5;TRUE|cde|eq +betwn|1|zero start|zero start|abcdefgh;0;2;TRUE|abc|eq +betwn|1|null start|null start|abcdefgh;!null;2;TRUE|null|isnull +betwn|1|null end|null end|abcdefgh;!3;!null;TRUE|null|isnull'; +BEGIN + utconfig.setdir ('d:\openoracle\utplsql\examples'); + utconfig.showconfig; + utgen.testpkg_from_string ('plvstr', + utc, + output_type_in=> utgen.c_file, + dir_in=> 'd:\openoracle\utplsql\examples', + schema_in => 'PLVPRO', + only_if_in_grid_in => TRUE + ); +END; diff --git a/examples/login.sql b/examples/login.sql new file mode 100644 index 000000000..b163d7576 --- /dev/null +++ b/examples/login.sql @@ -0,0 +1,7 @@ +BEGIN + utconfig.setdir ('d:\openoracle\utplsql\examples'); + utconfig.showconfig; +END; +/ + + diff --git a/examples/login_sample.sql b/examples/login_sample.sql new file mode 100644 index 000000000..4a54f6811 --- /dev/null +++ b/examples/login_sample.sql @@ -0,0 +1,4 @@ +exec utConfig.setdir ('YOUR DIRECTORY HERE') +REM exec utplsql.setdir ('e:\openoracle\utplsql\utinstall\examples') +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED +exec utConfig.showconfig diff --git a/examples/mybooks_setup.sql b/examples/mybooks_setup.sql new file mode 100644 index 000000000..ce8698b3d --- /dev/null +++ b/examples/mybooks_setup.sql @@ -0,0 +1,77 @@ +/**************************************************************************************** + + Author : Venky Mangapillai + Created : Mar'2002 + Description : This is the Prerequest program for UTPSQL test package called UT_MYBOOKS_PKG + +****************************************************************************************/ + +CREATE TABLE mybooks ( + book_id NUMBER, + book_nm VARCHAR2(30), + publish_dt DATE +) +/ +ALTER TABLE mybooks ADD CONSTRAINT mybooks_pk PRIMARY KEY (book_id) +/ +TRUNCATE TABLE mybooks +/ +INSERT INTO mybooks VALUES (1,'Sports History','01-JAN-2002'); +INSERT INTO mybooks VALUES (2,'World History','02-JAN-2002'); +INSERT INTO mybooks VALUES (3,'Medicine History','03-JAN-2002'); +INSERT INTO mybooks VALUES (4,'Market History','04-JAN-2002'); +INSERT INTO mybooks VALUES (5,'Weather History','05-JAN-2002'); + +CREATE OR REPLACE PACKAGE mybooks_pkg AS +TYPE mybooks_rec IS REF CURSOR RETURN mybooks%ROWTYPE; + +FUNCTION sel_book_func(bookid NUMBER) RETURN mybooks_rec; +PROCEDURE sel_book_proc(bookid NUMBER, rc OUT mybooks_rec); +FUNCTION sel_booknm(bookid NUMBER) RETURN VARCHAR2; +PROCEDURE ins(bookid NUMBER, booknm VARCHAR2,publishdt DATE); +PROCEDURE upd(bookid NUMBER, booknm VARCHAR2,publishdt DATE); +PROCEDURE del(bookid NUMBER); + +END; +/ +CREATE OR REPLACE PACKAGE BODY mybooks_pkg AS +FUNCTION sel_book_func(bookid NUMBER) RETURN mybooks_rec IS + rc mybooks_rec; +BEGIN + OPEN rc FOR SELECT * FROM mybooks WHERE book_id = bookid; + RETURN(rc); +END; + +FUNCTION sel_booknm(bookid NUMBER) RETURN VARCHAR2 IS + booknm VARCHAR2(30); +BEGIN + SELECT book_nm INTO booknm FROM mybooks WHERE book_id = bookid; + RETURN(booknm); +END; + +PROCEDURE ins(bookid NUMBER, booknm VARCHAR2,publishdt DATE) IS +BEGIN + INSERT INTO mybooks VALUES (bookid,booknm,publishdt); + COMMIT; +END; + +PROCEDURE upd(bookid NUMBER, booknm VARCHAR2,publishdt DATE) IS +BEGIN + UPDATE mybooks SET book_nm=booknm, publish_dt=publishdt WHERE book_id = bookid; + COMMIT; +END; + +PROCEDURE del(bookid NUMBER) IS +BEGIN + DELETE FROM mybooks WHERE book_id = bookid; + COMMIT; +END; + +PROCEDURE sel_book_proc(bookid NUMBER, rc OUT mybooks_rec) IS +BEGIN + OPEN rc FOR SELECT * FROM mybooks WHERE book_id = bookid; +END; + +END; +/ +show errors diff --git a/examples/plvision.tst b/examples/plvision.tst new file mode 100644 index 000000000..eb55e9ae3 --- /dev/null +++ b/examples/plvision.tst @@ -0,0 +1,16 @@ +BEGIN + -- Define a test suite for PL/Vision + utsuite.add ('PLVision'); + + -- Add two packages for testing + utpackage.add ( + 'PLVision', 'PLVstr', dir_in => 'e:\openoracle\utplsql\examples'); + utpackage.add ( + 'PLVision', 'PLVdate', dir_in => 'e:\openoracle\utplsql\examples'); + + -- Run the test suite + utplsql.testsuite ( + 'PLVision', recompile_in => TRUE); +END; +/ + diff --git a/examples/qu_betwnstr.pkb b/examples/qu_betwnstr.pkb new file mode 100644 index 000000000..d489db59a --- /dev/null +++ b/examples/qu_betwnstr.pkb @@ -0,0 +1,99 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2001/04/11 14:05 */ + +CREATE OR REPLACE PACKAGE BODY ut_betwnstr +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_betwnstr + IS + -- Verify and complete data types. + against_this VARCHAR2 (2000); + check_this VARCHAR2 (2000); + datapack utpack.datapack_t; + BEGIN + -- Define "control" operation for "normal" + + against_this := 'cde'; + -- Execute test code for "normal" + + check_this := + betwnstr (string_in=> 'abcdefgh', + start_in => 3, + end_in => 5 + ); + -- Assert success for "normal" + + -- Compare the two values. + -- This is generated so record is used to avoid overloading issues. + utassert2.eq (100, 'normal', check_this, against_this); + -- End of test for "normal" + + -- Define "control" operation for "zero start" + + against_this := 'abc'; + -- Execute test code for "zero start" + + check_this := + betwnstr (string_in=> 'abcdefgh', + start_in => 0, + end_in => 2 + ); + -- Assert success for "zero start" + + -- Compare the two values. + --utassert.eq ('zero start', check_this, against_this); + utassert2.eq (101, 'zero start', check_this, against_this); + -- End of test for "zero start" + + -- Define "control" operation for "null start" + + against_this := NULL; + -- Execute test code for "null start" + + check_this := + betwnstr (string_in=> 'abcdefgh', + start_in => NULL, + end_in => 2 + ); + -- Assert success for "null start" + + -- Check for NULL return value. + --utassert.isnull ('null start', against_this); + utassert2.isnull (102, 'null start', against_this); + -- End of test for "null start" + + -- Define "control" operation for "null end" + + against_this := NULL; + -- Execute test code for "null end" + + check_this := + betwnstr (string_in=> 'abcdefgh', + start_in => 3, + end_in => NULL + ); + -- Assert success for "null end" + + -- Check for NULL return value. + --utassert.isnull ('null end', against_this); + utassert2.isnull (103, 'null end', against_this); + -- End of test for "null end" + + utassert2.eqtable (104, 'compare emps', 'emp', 'emp2'); + + END ut_betwnstr; +END ut_betwnstr; +/ + + diff --git a/examples/readme.md b/examples/readme.md deleted file mode 100644 index 25aa807e3..000000000 --- a/examples/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -#Examples - Folder contains examples of Unit Tests. - \ No newline at end of file diff --git a/examples/registertests.sql b/examples/registertests.sql new file mode 100644 index 000000000..5ab6e7354 --- /dev/null +++ b/examples/registertests.sql @@ -0,0 +1,5 @@ +BEGIN + utplsql.trc; + utconfig.registertest (TRUE ); + utplsql.test ('betwnstr'); +END; diff --git a/examples/remove_rooms_by_name/remove_rooms_by_name.sql b/examples/remove_rooms_by_name/remove_rooms_by_name.sql deleted file mode 100644 index 6871692f5..000000000 --- a/examples/remove_rooms_by_name/remove_rooms_by_name.sql +++ /dev/null @@ -1,8 +0,0 @@ -create or replace procedure remove_rooms_by_name( l_name rooms.name%type ) is -begin - if l_name is null then - raise program_error; - end if; - delete from rooms where name like l_name; -end; -/ diff --git a/examples/remove_rooms_by_name/rooms.sql b/examples/remove_rooms_by_name/rooms.sql deleted file mode 100644 index 522c48f84..000000000 --- a/examples/remove_rooms_by_name/rooms.sql +++ /dev/null @@ -1,11 +0,0 @@ -create table rooms ( - room_key number primary key, - name varchar2(100) -); - -create table room_contents ( - contents_key number primary key, - room_key number, - name varchar2(100), - constraint fk_rooms foreign key (room_key) references rooms (room_key) -); diff --git a/examples/remove_rooms_by_name/run_remove_rooms_by_name_test.sql b/examples/remove_rooms_by_name/run_remove_rooms_by_name_test.sql deleted file mode 100644 index 2a95718a9..000000000 --- a/examples/remove_rooms_by_name/run_remove_rooms_by_name_test.sql +++ /dev/null @@ -1,13 +0,0 @@ -@@rooms.sql -@@remove_rooms_by_name.sql -@@test_remove_rooms_by_name.pkg - -set serveroutput on size unlimited format truncated - -exec ut.run(user||'.test_remove_rooms_by_name'); - -drop package test_remove_rooms_by_name; -drop procedure remove_rooms_by_name; -drop table room_contents; -drop table rooms; - diff --git a/examples/remove_rooms_by_name/test_remove_rooms_by_name.pkg b/examples/remove_rooms_by_name/test_remove_rooms_by_name.pkg deleted file mode 100644 index 7b88a471d..000000000 --- a/examples/remove_rooms_by_name/test_remove_rooms_by_name.pkg +++ /dev/null @@ -1,99 +0,0 @@ -create or replace package test_remove_rooms_by_name as - - -- %suite - -- %displayname(Remove rooms by name) - - -- %beforeall - procedure setup_rooms; - - -- %test - -- %displayname(Removes a room without content in it) - procedure remove_empty_room; - - -- %test - -- %displayname(Does not remove room when it has content) - procedure room_with_content; - - -- %test - -- %displayname(Raises exception when null room name given) - procedure null_room_name; - -end; -/ -create or replace package body test_remove_rooms_by_name as - - procedure setup_rooms is - begin - insert all - into rooms values(1, 'Dining Room') - into rooms values(2, 'Living Room') - into rooms values(3, 'Office') - into rooms values(4, 'Bathroom') - into rooms values(5, 'Bedroom') - select 1 from dual; - - insert all - into room_contents values(1, 1, 'Table') - into room_contents values(2, 1, 'Hutch') - into room_contents values(3, 1, 'Chair') - into room_contents values(4, 2, 'Sofa') - into room_contents values(5, 2, 'Lamp') - into room_contents values(6, 3, 'Desk') - into room_contents values(7, 3, 'Chair') - into room_contents values(8, 3, 'Computer') - into room_contents values(9, 3, 'Whiteboard') - select 1 from dual; - end; - - procedure remove_empty_room is - l_rooms_not_named_b sys_refcursor; - l_remaining_rooms sys_refcursor; - begin - open l_rooms_not_named_b for select * from rooms where name not like 'B%'; - - remove_rooms_by_name('B%'); - - open l_remaining_rooms for select * from rooms; - ut.expect( l_remaining_rooms ).to_equal(l_rooms_not_named_b); - end; - - procedure room_with_content is - l_rooms sys_refcursor; - l_remaining_rooms sys_refcursor; - begin - open l_rooms for select * from rooms; - - begin - remove_rooms_by_name('Living Room'); - ut.expect( sqlcode ).to_equal(-2292); - exception - when others then - ut.expect( sqlcode ).to_equal(-2292); - end; - - open l_remaining_rooms for select * from rooms; - - ut.expect( l_remaining_rooms ).to_equal( l_rooms ); - end; - - procedure null_room_name is - l_rooms sys_refcursor; - l_remaining_rooms sys_refcursor; - begin - open l_rooms for select * from rooms; - - begin - remove_rooms_by_name(NULL); - ut.expect( sqlcode ).to_equal(-6501); - exception - when others then - ut.expect( sqlcode ).to_equal(-6501); - end; - - open l_remaining_rooms for select * from rooms; - - ut.expect( l_remaining_rooms ).to_equal( l_rooms ); - end; - -end; -/ diff --git a/examples/showfailures.sql b/examples/showfailures.sql new file mode 100644 index 000000000..41e24aec8 --- /dev/null +++ b/examples/showfailures.sql @@ -0,0 +1,39 @@ +COLUMN suite format a42 heading '********* SUITE *********' + +COLUMN package format a16 heading '*** PACKAGE ***' + +COLUMN time_stamp format a18 + +COLUMN test format a80 fold_before heading "" + +COLUMN junk fold_after heading "" + +COLUMN junk2 fold_before heading "" + +SET pagesize 0 + +SET linesize 80 + +BREAK on suite noduplicates on package noduplicates on time_stamp noduplicates on junk noduplicates skip 6 + +SPOOL last_run_failures.txt + +SELECT '********************* SUITE ************ PACKAGE ********* Time +Stamp' + junk, + s.description suite, p.NAME PACKAGE, + TO_CHAR (p.last_end, 'dd-mon-yy hh24:mi:ss') time_stamp, + '-----------------------------' junk2, + DECODE ( + p.last_end, + NULL, 'Unable to Execute', + NVL (o.description, 'Passed all +Tests') + ) test + FROM utr_outcome o, ut_package p, ut_suite s + WHERE o.run_id(+) = p.last_run_id + AND o.status(+) = 'FAILURE' + AND s.id = p.suite_id +ORDER BY s.id, p.seq, p.last_end; + +SPOOL off diff --git a/examples/simple_example.sql b/examples/simple_example.sql new file mode 100644 index 000000000..3015ab72e --- /dev/null +++ b/examples/simple_example.sql @@ -0,0 +1,74 @@ +create or replace package SIMPLE_EXAMPLE +as + procedure DOUBLE_IT(V IN number,W OUT number); + function TRIPLE_IT(Y IN number) return number; + +end SIMPLE_EXAMPLE; +/ + +create or replace package body SIMPLE_EXAMPLE +as + procedure DOUBLE_IT(V IN number,W OUT number) + IS + BEGIN + W := 2*V; + END DOUBLE_IT; + + function TRIPLE_IT(Y IN number) return number + IS + BEGIN + RETURN 3*Y; + END TRIPLE_IT; + +end SIMPLE_EXAMPLE; +/ + +create or replace package UT_SIMPLE_EXAMPLE +as + procedure UT_SETUP; + procedure UT_TEARDOWN; + + procedure UT_DOUBLE_IT; + procedure UT_TRIPLE_IT; + +end UT_SIMPLE_EXAMPLE; +/ + +create or replace package body UT_SIMPLE_EXAMPLE +as + procedure UT_SETUP + IS + BEGIN + NULL; + END UT_SETUP; + + procedure UT_TEARDOWN + IS + BEGIN + NULL; + END UT_TEARDOWN; + + procedure UT_DOUBLE_IT + IS + A NUMBER; + BEGIN + + SIMPLE_EXAMPLE.DOUBLE_IT(NULL, A); + utAssert.isnull('Null value', A); + + SIMPLE_EXAMPLE.DOUBLE_IT(1, A); + utAssert.eq('Typical value', A, 2); + + END UT_DOUBLE_IT; + + procedure UT_TRIPLE_IT + IS + BEGIN + + utAssert.isnull('Null value', SIMPLE_EXAMPLE.TRIPLE_IT(null)); + utAssert.eq('Typical value', SIMPLE_EXAMPLE.TRIPLE_IT(1), 3); + + END UT_TRIPLE_IT; + +end UT_SIMPLE_EXAMPLE; +/ \ No newline at end of file diff --git a/examples/str.pkb b/examples/str.pkb new file mode 100644 index 000000000..3b572e628 --- /dev/null +++ b/examples/str.pkb @@ -0,0 +1,87 @@ +/* Formatted on 2001/11/19 15:15 (Formatter Plus v4.5.2) */ +CREATE OR REPLACE PACKAGE BODY str +IS + FUNCTION betwn ( + string_in IN VARCHAR2, + start_in IN PLS_INTEGER, + end_in IN PLS_INTEGER + ) + RETURN VARCHAR2 + IS + l_start PLS_INTEGER := start_in; + BEGIN + IF l_start = 0 + THEN + l_start := 1; + END IF; + + RETURN (SUBSTR ( + string_in, + l_start, + end_in + - l_start + + 1 + ) + ); + END; + + FUNCTION betwn2 ( + string_in IN VARCHAR2, + start_in IN PLS_INTEGER, + end_in IN PLS_INTEGER + ) + RETURN VARCHAR2 + IS + BEGIN + -- Handle negative values + IF end_in < 0 + THEN + RETURN betwn (string_in, start_in, end_in); + ELSE + RETURN (SUBSTR ( + string_in, + LENGTH (string_in) + + end_in + + 1, + start_in + - end_in + + 1 + ) + ); + END IF; + END; + + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_betwn + IS + BEGIN + utassert.eq ( + 'Typical Valid Usage', + str.betwn ('this is a string', 3, 7), + 'is is' + ); + utassert.eq ( + 'Test Negative Start', + str.betwn ('this is a string', -3, 7), + 'ing' + ); + utassert.isnull ( + 'Start bigger than end', + str.betwn ('this is a string', 3, 1) + ); + END; +END str; +/ + diff --git a/examples/str.pks b/examples/str.pks new file mode 100644 index 000000000..df3144765 --- /dev/null +++ b/examples/str.pks @@ -0,0 +1,26 @@ +/* Formatted on 2001/11/19 15:11 (Formatter Plus v4.5.2) */ +CREATE OR REPLACE PACKAGE str +IS + FUNCTION betwn ( + string_in IN VARCHAR2, + start_in IN PLS_INTEGER, + end_in IN PLS_INTEGER + ) + RETURN VARCHAR2; + + FUNCTION betwn2 ( + string_in IN VARCHAR2, + start_in IN PLS_INTEGER, + end_in IN PLS_INTEGER + ) + RETURN VARCHAR2; + + PROCEDURE ut_setup; + + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_betwn; +END str; +/ + diff --git a/examples/str2list.pkg b/examples/str2list.pkg new file mode 100644 index 000000000..eb47f5402 --- /dev/null +++ b/examples/str2list.pkg @@ -0,0 +1,215 @@ +CREATE OR REPLACE PACKAGE str2list +IS + PROCEDURE parse ( + str IN VARCHAR2, + delim IN VARCHAR2, + pkg IN VARCHAR2, + tab IN VARCHAR2, + datatype IN VARCHAR2 := 'VARCHAR2(32767)', + extend_needed BOOLEAN := FALSE + ); + + PROCEDURE parse ( + str IN VARCHAR2, + delim IN VARCHAR2, + pkg IN VARCHAR2, + appendproc IN VARCHAR2, /* pkg.appendproc (oneval); */ + deleteproc IN VARCHAR2, /* pkg.deleteproc (onerow); or pkg.deleteproc; */ + datatype IN VARCHAR2 + ); + + PROCEDURE showlist ( + pkg IN VARCHAR2, + tab IN VARCHAR2 + ); + + PROCEDURE showlist ( + pkg IN VARCHAR2, + firstrowproc IN VARCHAR2, + nextrowproc IN VARCHAR2, + getvalfunc IN VARCHAR2, + showproc IN VARCHAR2 := 'DBMS_OUTPUT.PUT_LINE', + datatype IN VARCHAR2 := 'VARCHAR2(32767)' + ); +END str2list; +/ +CREATE OR REPLACE PACKAGE BODY str2list +IS +procedure disperr (str in varchar2) is +begin + p.l ('Compilation/Execution Error:'); + p.l (SQLERRM); + p.l ('In:'); + p.l (str); +end; + + PROCEDURE parse ( + str IN VARCHAR2, + delim IN VARCHAR2, + pkg IN VARCHAR2, + tab IN VARCHAR2, + datatype IN VARCHAR2 := 'VARCHAR2(32767)', + extend_needed BOOLEAN := FALSE + ) + IS + tabname VARCHAR2 (100) := pkg || '.' || tab; + dynblock VARCHAR2 (32767); + extstring VARCHAR2 (100); + BEGIN + IF extend_needed + THEN + extstring := tabname || '.EXTEND;' + END IF; + + dynblock := + 'DECLARE + v_loc PLS_INTEGER; + v_startloc PLS_INTEGER := 1; + v_item ' || datatype || '; + BEGIN ' || + tabname || '.DELETE; + IF :str IS NOT NULL + THEN + LOOP + v_loc := INSTR (:str, :delim, v_startloc); + IF v_loc = v_startloc + THEN + v_item := NULL; + ELSIF v_loc = 0 + THEN + v_item := SUBSTR (:str, v_startloc); + ELSE + v_item := SUBSTR (:str, v_startloc, v_loc - v_startloc); + END IF;' || + + extstring || tabname || '(' || tabname || '.LAST) + := v_item; + + IF v_loc = 0 + THEN + EXIT; + ELSE + v_startloc := v_loc + 1; + END IF; + END LOOP; + END IF; + END;'; + + EXECUTE IMMEDIATE dynblock USING str, delim; + EXCEPTION + WHEN OTHERS + THEN + disperr (dynblock); + END; + + PROCEDURE parse ( + str IN VARCHAR2, + delim IN VARCHAR2, + pkg IN VARCHAR2, + appendproc IN VARCHAR2, + deleteproc IN VARCHAR2, + datatype IN VARCHAR2 + )IS + dynblock VARCHAR2 (32767); + BEGIN + dynblock := + 'DECLARE + v_loc PLS_INTEGER; + v_startloc PLS_INTEGER := 1; + v_item ' || datatype || '; + BEGIN + ' || pkg || '.' || deleteproc || '; + IF :str IS NOT NULL + THEN + LOOP + v_loc := INSTR (:str, :delim, v_startloc); + IF v_loc = v_startloc + THEN + v_item := NULL; + ELSIF v_loc = 0 + THEN + v_item := SUBSTR (:str, v_startloc); + ELSE + v_item := SUBSTR (:str, v_startloc, v_loc - v_startloc); + END IF;' || + pkg || + '.' || + appendproc || + '( v_item); + IF v_loc = 0 + THEN + EXIT; + ELSE + v_startloc := v_loc + 1; + END IF; + END LOOP; + END IF; + END;'; + EXECUTE IMMEDIATE dynblock USING str, delim; + EXCEPTioN + when others then disperr (dynblock); + END; + + PROCEDURE showlist ( + pkg IN VARCHAR2, + tab IN VARCHAR2 + ) + IS + tabname VARCHAR2 (100) := pkg || '.' || tab; + dynblock VARCHAR2 (32767); + BEGIN + dynblock := + 'DECLARE + indx PLS_INTEGER := ' || tabname || + '.FIRST; + v_startloc PLS_INTEGER := 1; + v_item VARCHAR2(32767); + BEGIN + LOOP + EXIT WHEN indx IS NULL; + DBMS_OUTPUT.PUT_LINE (' || + tabname || + '(indx)); + indx := ' || + tabname || + '.NEXT (indx); + END LOOP; + END;'; + EXECUTE IMMEDIATE dynblock; + EXCEPTioN + when others then disperr (dynblock); + END; + + PROCEDURE showlist ( + pkg IN VARCHAR2, + firstrowproc IN VARCHAR2, + nextrowproc IN VARCHAR2, + getvalfunc IN VARCHAR2, + showproc IN VARCHAR2 := 'DBMS_OUTPUT.PUT_LINE', + datatype IN VARCHAR2 := 'VARCHAR2(32767)' ) + IS + dynblock VARCHAR2 (32767); + BEGIN + dynblock := + 'DECLARE + indx PLS_INTEGER := ' || pkg || + '.' || firstrowproc || '; + v_startloc PLS_INTEGER := 1; + v_item ' || datatype || '; + BEGIN + LOOP + EXIT WHEN indx IS NULL;' || + showproc || ' (' || + pkg || '.' || getvalfunc || '(indx)); + indx := ' || + pkg || + '.' || nextrowproc || '(indx); + END LOOP; + END;'; + EXECUTE IMMEDIATE dynblock; + EXCEPTioN + when others then disperr (dynblock); + END; + +END str2list; +/ diff --git a/examples/str2list.tst b/examples/str2list.tst new file mode 100644 index 000000000..0c6526642 --- /dev/null +++ b/examples/str2list.tst @@ -0,0 +1,20 @@ +@str2list.pkg + +@filepath.pkg + +BEGIN + p.l ('Str2List Test Using Direct Collection Access'); + fileio.setpath ('a;b;c;d;efg;;'); + str2list.showlist ('fileio', 'dirs'); +END; +/ + +@filepath2.pkg + +BEGIN + p.l ('Str2List Test Using API'); + fileio.setpath ('a;b;c;d;efg;;'); + str2list.showlist ('fileio', 'first', 'next', 'val', 'p.l'); +END; +/ + \ No newline at end of file diff --git a/examples/str_same.pkb b/examples/str_same.pkb new file mode 100644 index 000000000..69a4070fb --- /dev/null +++ b/examples/str_same.pkb @@ -0,0 +1,20 @@ +CREATE OR REPLACE PACKAGE BODY str +IS + FUNCTION betwn ( + string_in IN VARCHAR2, + start_in IN PLS_INTEGER, + end_in IN PLS_INTEGER + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN ( + SUBSTR ( + string_in, + start_in, + end_in - start_in + 1 + ) + ); + END; +END str; +/ diff --git a/examples/str_same.pks b/examples/str_same.pks new file mode 100644 index 000000000..0fac975bd --- /dev/null +++ b/examples/str_same.pks @@ -0,0 +1,10 @@ +CREATE OR REPLACE PACKAGE str +IS + FUNCTION betwn ( + string_in IN VARCHAR2, + start_in IN PLS_INTEGER, + end_in IN PLS_INTEGER + ) + RETURN VARCHAR2; +END str; +/ diff --git a/examples/tabcount.sf b/examples/tabcount.sf new file mode 100644 index 000000000..4c28c8f29 --- /dev/null +++ b/examples/tabcount.sf @@ -0,0 +1,17 @@ +CREATE OR REPLACE FUNCTION tabcount ( + sch IN VARCHAR2, + tab IN VARCHAR2) + RETURN INTEGER +IS + retval INTEGER; +BEGIN + EXECUTE IMMEDIATE + 'SELECT COUNT(*) FROM ' || sch || '.' || tab + INTO retval; + RETURN retval; +EXCEPTION + WHEN OTHERS + THEN + RETURN NULL; +END; +/ diff --git a/examples/te_employee.pkb b/examples/te_employee.pkb new file mode 100644 index 000000000..92f4ea7d1 --- /dev/null +++ b/examples/te_employee.pkb @@ -0,0 +1,1710 @@ +--//----------------------------------------------------------------------- +--// ** PL/Generator Table Encapsulator for "employee" +--//----------------------------------------------------------------------- +--// (c) COPYRIGHT Personnel Policies, Inc. 1999. +--// All rights reserved. +--// +--// No part of this copyrighted work may be reproduced, modified, +--// or distributed in any form or by any means without the prior +--// written permission of Personnel Policies, Inc.. +--//----------------------------------------------------------------------- +--// This software was generated by RevealNet's PL/Generator (TM). +--// +--// For more information, visit www.revealnet.com or call 1.800.REVEAL4 +--//----------------------------------------------------------------------- +--// Stored In: te_employee.pkb +--// Created On: September 05, 2000 20:14:04 +--// Created By: SCOTT +--// PL/Generator Version: PRO-2000.1.1 +--//----------------------------------------------------------------------- +CREATE OR REPLACE PACKAGE BODY te_employee +IS + --// Package name and program name globals --// + c_pkgname VARCHAR2(30) := 'te_employee'; + g_progname VARCHAR2(30) := NULL; + + --// Update Flag private data structures. --// + TYPE frcflg_rt IS RECORD ( + last_name CHAR(1), + first_name CHAR(1), + middle_initial CHAR(1), + job_id CHAR(1), + manager_id CHAR(1), + hire_date CHAR(1), + salary CHAR(1), + commission CHAR(1), + department_id CHAR(1), + changed_by CHAR(1), + changed_on CHAR(1) + ); + + frcflg frcflg_rt; + emptyfrc frcflg_rt; + c_set CHAR(1) := 'Y'; + c_noset CHAR(1) := 'N'; + + TYPE tab_tabtype IS TABLE OF allcols_rt INDEX BY BINARY_INTEGER; + loadtab tab_tabtype; + FUNCTION version RETURN VARCHAR2 + IS + BEGIN + RETURN '7.09'; + END; + +--// Private Modules //-- + + --// For Dynamic SQL operations; currently unused. //-- + PROCEDURE initcur (cur_inout IN OUT INTEGER) + IS + BEGIN + IF NOT DBMS_SQL.IS_OPEN (cur_inout) + THEN + cur_inout := DBMS_SQL.OPEN_CURSOR; + END IF; + EXCEPTION + WHEN invalid_cursor + THEN + cur_inout := DBMS_SQL.OPEN_CURSOR; + END; + + PROCEDURE start_program (nm IN VARCHAR2, msg IN VARCHAR2 := NULL) IS + BEGIN + g_progname := nm; + END; + + PROCEDURE end_program IS + BEGIN + g_progname := NULL; + END; + +--// Cursor management procedures //-- + + --// Open the cursors with some options. //-- + PROCEDURE open_compforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + start_program ('open_compforpky_cur'); + + IF compforpky_cur%ISOPEN AND v_close + THEN + CLOSE compforpky_cur; + ELSIF compforpky_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN compforpky_cur ( + employee_id_in + ); + END IF; + + end_program; + END; + + PROCEDURE open_compbypky_cur ( + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF compbypky_cur%ISOPEN AND v_close + THEN + CLOSE compbypky_cur; + ELSIF compbypky_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN compbypky_cur; + END IF; + END; + + PROCEDURE open_emp_dept_lookup_comp_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_dept_lookup_comp_cur%ISOPEN AND v_close + THEN + CLOSE emp_dept_lookup_comp_cur; + ELSIF emp_dept_lookup_comp_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_dept_lookup_comp_cur ( + department_id_in + ); + END IF; + END; + + PROCEDURE open_emp_job_lookup_comp_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_job_lookup_comp_cur%ISOPEN AND v_close + THEN + CLOSE emp_job_lookup_comp_cur; + ELSIF emp_job_lookup_comp_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_job_lookup_comp_cur ( + job_id_in + ); + END IF; + END; + + PROCEDURE open_emp_mgr_lookup_comp_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_mgr_lookup_comp_cur%ISOPEN AND v_close + THEN + CLOSE emp_mgr_lookup_comp_cur; + ELSIF emp_mgr_lookup_comp_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_mgr_lookup_comp_cur ( + manager_id_in + ); + END IF; + END; + --// Open the cursors with some options. //-- + PROCEDURE open_nameforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + start_program ('open_nameforpky_cur'); + + IF nameforpky_cur%ISOPEN AND v_close + THEN + CLOSE nameforpky_cur; + ELSIF nameforpky_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN nameforpky_cur ( + employee_id_in + ); + END IF; + + end_program; + END; + + PROCEDURE open_namebypky_cur ( + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF namebypky_cur%ISOPEN AND v_close + THEN + CLOSE namebypky_cur; + ELSIF namebypky_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN namebypky_cur; + END IF; + END; + + PROCEDURE open_emp_dept_lookup_name_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_dept_lookup_name_cur%ISOPEN AND v_close + THEN + CLOSE emp_dept_lookup_name_cur; + ELSIF emp_dept_lookup_name_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_dept_lookup_name_cur ( + department_id_in + ); + END IF; + END; + + PROCEDURE open_emp_job_lookup_name_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_job_lookup_name_cur%ISOPEN AND v_close + THEN + CLOSE emp_job_lookup_name_cur; + ELSIF emp_job_lookup_name_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_job_lookup_name_cur ( + job_id_in + ); + END IF; + END; + + PROCEDURE open_emp_mgr_lookup_name_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_mgr_lookup_name_cur%ISOPEN AND v_close + THEN + CLOSE emp_mgr_lookup_name_cur; + ELSIF emp_mgr_lookup_name_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_mgr_lookup_name_cur ( + manager_id_in + ); + END IF; + END; + --// Open the cursors with some options. //-- + PROCEDURE open_allforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + start_program ('open_allforpky_cur'); + + IF allforpky_cur%ISOPEN AND v_close + THEN + CLOSE allforpky_cur; + ELSIF allforpky_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN allforpky_cur ( + employee_id_in + ); + END IF; + + end_program; + END; + + PROCEDURE open_allbypky_cur ( + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF allbypky_cur%ISOPEN AND v_close + THEN + CLOSE allbypky_cur; + ELSIF allbypky_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN allbypky_cur; + END IF; + END; + + PROCEDURE open_emp_dept_lookup_all_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_dept_lookup_all_cur%ISOPEN AND v_close + THEN + CLOSE emp_dept_lookup_all_cur; + ELSIF emp_dept_lookup_all_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_dept_lookup_all_cur ( + department_id_in + ); + END IF; + END; + + PROCEDURE open_emp_job_lookup_all_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_job_lookup_all_cur%ISOPEN AND v_close + THEN + CLOSE emp_job_lookup_all_cur; + ELSIF emp_job_lookup_all_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_job_lookup_all_cur ( + job_id_in + ); + END IF; + END; + + PROCEDURE open_emp_mgr_lookup_all_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ) + IS + v_close BOOLEAN := NVL (close_if_open, TRUE); + v_open BOOLEAN := TRUE; + BEGIN + IF emp_mgr_lookup_all_cur%ISOPEN AND v_close + THEN + CLOSE emp_mgr_lookup_all_cur; + ELSIF emp_mgr_lookup_all_cur%ISOPEN AND NOT v_close + THEN + v_open := FALSE; + END IF; + + IF v_open + THEN + OPEN emp_mgr_lookup_all_cur ( + manager_id_in + ); + END IF; + END; + + --// Close the cursors if they are open. //-- + PROCEDURE close_compforpky_cur + IS BEGIN + IF compforpky_cur%ISOPEN + THEN + CLOSE compforpky_cur; + END IF; + END; + + PROCEDURE close_compbypky_cur + IS BEGIN + IF compbypky_cur%ISOPEN + THEN + CLOSE compbypky_cur; + END IF; + END; + + PROCEDURE close_emp_dept_lookup_comp_cur + IS BEGIN + IF emp_dept_lookup_comp_cur%ISOPEN + THEN + CLOSE emp_dept_lookup_comp_cur; + END IF; + END; + + PROCEDURE close_emp_job_lookup_comp_cur + IS BEGIN + IF emp_job_lookup_comp_cur%ISOPEN + THEN + CLOSE emp_job_lookup_comp_cur; + END IF; + END; + + PROCEDURE close_emp_mgr_lookup_comp_cur + IS BEGIN + IF emp_mgr_lookup_comp_cur%ISOPEN + THEN + CLOSE emp_mgr_lookup_comp_cur; + END IF; + END; + + PROCEDURE close_nameforpky_cur + IS BEGIN + IF nameforpky_cur%ISOPEN + THEN + CLOSE nameforpky_cur; + END IF; + END; + + PROCEDURE close_namebypky_cur + IS BEGIN + IF namebypky_cur%ISOPEN + THEN + CLOSE namebypky_cur; + END IF; + END; + + PROCEDURE close_emp_dept_lookup_name_cur + IS BEGIN + IF emp_dept_lookup_name_cur%ISOPEN + THEN + CLOSE emp_dept_lookup_name_cur; + END IF; + END; + + PROCEDURE close_emp_job_lookup_name_cur + IS BEGIN + IF emp_job_lookup_name_cur%ISOPEN + THEN + CLOSE emp_job_lookup_name_cur; + END IF; + END; + + PROCEDURE close_emp_mgr_lookup_name_cur + IS BEGIN + IF emp_mgr_lookup_name_cur%ISOPEN + THEN + CLOSE emp_mgr_lookup_name_cur; + END IF; + END; + + PROCEDURE close_allforpky_cur + IS BEGIN + IF allforpky_cur%ISOPEN + THEN + CLOSE allforpky_cur; + END IF; + END; + + PROCEDURE close_allbypky_cur + IS BEGIN + IF allbypky_cur%ISOPEN + THEN + CLOSE allbypky_cur; + END IF; + END; + + PROCEDURE close_emp_dept_lookup_all_cur + IS BEGIN + IF emp_dept_lookup_all_cur%ISOPEN + THEN + CLOSE emp_dept_lookup_all_cur; + END IF; + END; + + PROCEDURE close_emp_job_lookup_all_cur + IS BEGIN + IF emp_job_lookup_all_cur%ISOPEN + THEN + CLOSE emp_job_lookup_all_cur; + END IF; + END; + + PROCEDURE close_emp_mgr_lookup_all_cur + IS BEGIN + IF emp_mgr_lookup_all_cur%ISOPEN + THEN + CLOSE emp_mgr_lookup_all_cur; + END IF; + END; + + PROCEDURE closeall + IS + BEGIN + close_compforpky_cur; + close_compbypky_cur; + close_emp_dept_lookup_comp_cur; + close_emp_job_lookup_comp_cur; + close_emp_mgr_lookup_comp_cur; + close_nameforpky_cur; + close_namebypky_cur; + close_emp_dept_lookup_name_cur; + close_emp_job_lookup_name_cur; + close_emp_mgr_lookup_name_cur; + close_allforpky_cur; + close_allbypky_cur; + close_emp_dept_lookup_all_cur; + close_emp_job_lookup_all_cur; + close_emp_mgr_lookup_all_cur; + END; + +--// Emulate aggregate-level record operations. //-- + + FUNCTION recseq (rec1 IN allcols_rt, rec2 IN allcols_rt) + RETURN BOOLEAN + IS + unequal_records EXCEPTION; + retval BOOLEAN; + BEGIN + retval := rec1.employee_id = rec2.employee_id OR + (rec1.employee_id IS NULL AND rec2.employee_id IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.last_name = rec2.last_name OR + (rec1.last_name IS NULL AND rec2.last_name IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.first_name = rec2.first_name OR + (rec1.first_name IS NULL AND rec2.first_name IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.middle_initial = rec2.middle_initial OR + (rec1.middle_initial IS NULL AND rec2.middle_initial IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.job_id = rec2.job_id OR + (rec1.job_id IS NULL AND rec2.job_id IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.manager_id = rec2.manager_id OR + (rec1.manager_id IS NULL AND rec2.manager_id IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.hire_date = rec2.hire_date OR + (rec1.hire_date IS NULL AND rec2.hire_date IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.salary = rec2.salary OR + (rec1.salary IS NULL AND rec2.salary IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.commission = rec2.commission OR + (rec1.commission IS NULL AND rec2.commission IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.department_id = rec2.department_id OR + (rec1.department_id IS NULL AND rec2.department_id IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.changed_by = rec2.changed_by OR + (rec1.changed_by IS NULL AND rec2.changed_by IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + retval := rec1.changed_on = rec2.changed_on OR + (rec1.changed_on IS NULL AND rec2.changed_on IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + RETURN TRUE; + EXCEPTION + WHEN unequal_records THEN RETURN FALSE; + END; + + FUNCTION recseq (rec1 IN pky_rt, rec2 IN pky_rt) + RETURN BOOLEAN + IS + unequal_records EXCEPTION; + retval BOOLEAN; + BEGIN + retval := rec1.employee_id = rec2.employee_id OR + (rec1.employee_id IS NULL AND rec2.employee_id IS NULL); + IF NOT NVL (retval, FALSE) THEN RAISE unequal_records; END IF; + RETURN TRUE; + EXCEPTION + WHEN unequal_records THEN RETURN FALSE; + END; + +--// Is the primary key NOT NULL? //-- + + FUNCTION isnullpky ( + rec_in IN allcols_rt + ) + RETURN BOOLEAN + IS + BEGIN + RETURN + rec_in.employee_id IS NULL + ; + END; + + FUNCTION isnullpky ( + rec_in IN pky_rt + ) + RETURN BOOLEAN + IS + BEGIN + RETURN + rec_in.employee_id IS NULL + ; + END; + +--// Query Processing --// + + FUNCTION onerow_internal ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN allcols_rt + IS + CURSOR onerow_cur + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = employee_id_in + ; + onerow_rec allcols_rt; + BEGIN + OPEN onerow_cur; + FETCH onerow_cur INTO onerow_rec; + CLOSE onerow_cur; + RETURN onerow_rec; + END onerow_internal; + + FUNCTION onerow ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN allcols_rt + IS + retval allcols_rt; + BEGIN + IF loadtab.EXISTS (employee_id_in) + THEN + retval := loadtab(employee_id_in); + ELSE + retval := onerow_internal (employee_id_in); + IF retval.EMPLOYEE_ID IS NOT NULL + THEN + --// Load the data into the table. --// + loadtab(employee_id_in) := retval; + END IF; + END IF; + RETURN retval; + END onerow; + + FUNCTION i_employee_name$pky ( + last_name_in IN EMPLOYEE.LAST_NAME%TYPE, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE + ) + RETURN pky_rt + IS + CURSOR getpky_cur + IS + SELECT + EMPLOYEE_ID + FROM EMPLOYEE + WHERE + LAST_NAME = i_employee_name$pky.last_name_in AND + FIRST_NAME = i_employee_name$pky.first_name_in AND + MIDDLE_INITIAL = i_employee_name$pky.middle_initial_in + ; + + getpky_rec getpky_cur%ROWTYPE; + retval pky_rt; + BEGIN + OPEN getpky_cur; + FETCH getpky_cur INTO getpky_rec; + IF getpky_cur%FOUND + THEN + retval.employee_id := getpky_rec.EMPLOYEE_ID; + END IF; + CLOSE getpky_cur; + RETURN retval; + END i_employee_name$pky; + + FUNCTION i_employee_name$row ( + last_name_in IN EMPLOYEE.LAST_NAME%TYPE, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE + ) + RETURN allcols_rt + IS + CURSOR onerow_cur + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + WHERE + LAST_NAME = i_employee_name$row.last_name_in AND + FIRST_NAME = i_employee_name$row.first_name_in AND + MIDDLE_INITIAL = i_employee_name$row.middle_initial_in + ; + onerow_rec allcols_rt; + BEGIN + OPEN onerow_cur; + FETCH onerow_cur INTO onerow_rec; + CLOSE onerow_cur; + RETURN onerow_rec; + END i_employee_name$row; + + FUNCTION i_employee_name$val ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN i_employee_name_rt + IS + v_onerow allcols_rt; + retval i_employee_name_rt; + BEGIN + v_onerow := onerow ( + employee_id_in + ); + + retval.last_name := v_onerow.last_name; + retval.first_name := v_onerow.first_name; + retval.middle_initial := v_onerow.middle_initial; + + RETURN retval; + END i_employee_name$val; + + --// For each update column ... //-- + + FUNCTION hire_date$val ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN EMPLOYEE.HIRE_DATE%TYPE + IS + CURSOR onecol_cur + IS + SELECT HIRE_DATE + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = employee_id_in + ; + retval EMPLOYEE.HIRE_DATE%TYPE; + BEGIN + OPEN onecol_cur; + FETCH onecol_cur INTO retval; + CLOSE onecol_cur; + RETURN retval; + END hire_date$val; + --// For each update column ... //-- + + FUNCTION salary$val ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN EMPLOYEE.SALARY%TYPE + IS + CURSOR onecol_cur + IS + SELECT SALARY + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = employee_id_in + ; + retval EMPLOYEE.SALARY%TYPE; + BEGIN + OPEN onecol_cur; + FETCH onecol_cur INTO retval; + CLOSE onecol_cur; + RETURN retval; + END salary$val; + + --// Count of all rows in table and for each foreign key. //-- + FUNCTION rowcount RETURN INTEGER + IS + retval INTEGER; + BEGIN + SELECT COUNT(*) INTO retval FROM EMPLOYEE; + RETURN retval; + END; + + FUNCTION pkyrowcount ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN INTEGER + IS + retval INTEGER; + BEGIN + SELECT COUNT(*) + INTO retval + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = employee_id_in + ; + RETURN retval; + END; + + FUNCTION emp_dept_lookuprowcount ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) + RETURN INTEGER + IS + retval INTEGER; + BEGIN + SELECT COUNT(*) INTO retval + FROM EMPLOYEE + WHERE + DEPARTMENT_ID = emp_dept_lookuprowcount.department_id_in + ; + RETURN retval; + END; + FUNCTION emp_job_lookuprowcount ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE + ) + RETURN INTEGER + IS + retval INTEGER; + BEGIN + SELECT COUNT(*) INTO retval + FROM EMPLOYEE + WHERE + JOB_ID = emp_job_lookuprowcount.job_id_in + ; + RETURN retval; + END; + FUNCTION emp_mgr_lookuprowcount ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE + ) + RETURN INTEGER + IS + retval INTEGER; + BEGIN + SELECT COUNT(*) INTO retval + FROM EMPLOYEE + WHERE + MANAGER_ID = emp_mgr_lookuprowcount.manager_id_in + ; + RETURN retval; + END; + + PROCEDURE lookup_fkydescs ( + --// Foreign key columns for emp_dept_lookup --// + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + emp_dept_lookup_out OUT te_department.i_department_name_rt, + --// Foreign key columns for emp_job_lookup --// + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + emp_job_lookup_out OUT te_job.i_job_function_rt, + --// Foreign key columns for emp_mgr_lookup --// + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + emp_mgr_lookup_out OUT te_employee.i_employee_name_rt, + record_error BOOLEAN := TRUE + ) + IS + BEGIN + emp_dept_lookup_out := + te_department.i_department_name$val ( + department_id_in + ); + emp_job_lookup_out := + te_job.i_job_function$val ( + job_id_in + ); + emp_mgr_lookup_out := + te_employee.i_employee_name$val ( + manager_id_in + ); + EXCEPTION + WHEN OTHERS + THEN + IF record_error + THEN + RAISE; + END IF; + RAISE; + END lookup_fkydescs; + + --// Generate the next primary key: single column PKYs only --// + FUNCTION nextpky RETURN EMPLOYEE.employee_id%TYPE + IS + retval EMPLOYEE.employee_id%TYPE; + BEGIN + SELECT EMPLOYEE_ID_SEQ.NEXTVAL INTO retval FROM dual; + RETURN retval; + END; + +--// Check Constraint Validation --// + + --// Check Constraint: DEPARTMENT_ID > 0 AND (salary > 0 OR salary IS NULL) --// + FUNCTION employee$complex$chk ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + salary_in IN EMPLOYEE.SALARY%TYPE + ) RETURN BOOLEAN + IS + BEGIN + RETURN (DEPARTMENT_ID_in > 0 AND (SALARY_in > 0 OR SALARY_in IS NULL)); + END employee$complex$chk; + + --// Check Constraint: DEPARTMENT_ID IS NOT NULL --// + FUNCTION notnull_department_id$chk ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) RETURN BOOLEAN + IS + BEGIN + RETURN (DEPARTMENT_ID_in IS NOT NULL); + END notnull_department_id$chk; + + --// Check Constraint: EMPLOYEE_ID IS NOT NULL --// + FUNCTION notnull_employee_id$chk ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) RETURN BOOLEAN + IS + BEGIN + RETURN (EMPLOYEE_ID_in IS NOT NULL); + END notnull_employee_id$chk; + + --// Check Constraint: "HIRE_DATE" IS NOT NULL --// + FUNCTION sys_c001373$chk ( + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE + ) RETURN BOOLEAN + IS + BEGIN + RETURN (HIRE_DATE_in IS NOT NULL); + END sys_c001373$chk; + + --// Check Constraint: "CHANGED_BY" IS NOT NULL --// + FUNCTION sys_c001376$chk ( + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE + ) RETURN BOOLEAN + IS + BEGIN + RETURN (CHANGED_BY_in IS NOT NULL); + END sys_c001376$chk; + + --// Check Constraint: "CHANGED_ON" IS NOT NULL --// + FUNCTION sys_c001377$chk ( + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE + ) RETURN BOOLEAN + IS + BEGIN + RETURN (CHANGED_ON_in IS NOT NULL); + END sys_c001377$chk; + + PROCEDURE validate ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE, + salary_in IN EMPLOYEE.SALARY%TYPE, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE, + record_error IN BOOLEAN := TRUE + ) + IS + BEGIN + IF NOT employee$complex$chk ( + department_id_in, + salary_in + ) + THEN + --//** General mechanism! //-- + RAISE_APPLICATION_ERROR (-20000, 'ORA-2290: CHECK CONSTRAINT (employee$complex) FAILED!'); + END IF; + IF NOT notnull_department_id$chk ( + department_id_in + ) + THEN + RAISE_APPLICATION_ERROR (-20000, 'Value of DEPARTMENT_ID cannot be NULL'); + END IF; + IF NOT notnull_employee_id$chk ( + employee_id_in + ) + THEN + RAISE_APPLICATION_ERROR (-20000, 'Value of EMPLOYEE_ID cannot be NULL'); + END IF; + IF NOT sys_c001373$chk ( + hire_date_in + ) + THEN + --//** General mechanism! //-- + RAISE_APPLICATION_ERROR (-20000, 'ORA-2290: CHECK CONSTRAINT (sys_c001373) FAILED!'); + END IF; + IF NOT sys_c001376$chk ( + changed_by_in + ) + THEN + --//** General mechanism! //-- + RAISE_APPLICATION_ERROR (-20000, 'ORA-2290: CHECK CONSTRAINT (sys_c001376) FAILED!'); + END IF; + IF NOT sys_c001377$chk ( + changed_on_in + ) + THEN + --//** General mechanism! //-- + RAISE_APPLICATION_ERROR (-20000, 'ORA-2290: CHECK CONSTRAINT (sys_c001377) FAILED!'); + END IF; + EXCEPTION + WHEN OTHERS + THEN + IF record_error + THEN + RAISE; + END IF; + RAISE; + END validate; + + PROCEDURE validate ( + rec_in IN allcols_rt, + record_error IN BOOLEAN := TRUE + ) + IS + BEGIN + validate ( + rec_in.employee_id, + rec_in.hire_date, + rec_in.salary, + rec_in.department_id, + rec_in.changed_by, + rec_in.changed_on, + record_error + ); + END validate; +--// Update Processing --// + + PROCEDURE reset$frc IS + BEGIN + frcflg := emptyfrc; + END reset$frc; + + FUNCTION last_name$frc (last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL) + RETURN EMPLOYEE.LAST_NAME%TYPE + IS + BEGIN + frcflg.last_name := c_set; + RETURN last_name_in; + END last_name$frc; + + FUNCTION first_name$frc (first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL) + RETURN EMPLOYEE.FIRST_NAME%TYPE + IS + BEGIN + frcflg.first_name := c_set; + RETURN first_name_in; + END first_name$frc; + + FUNCTION middle_initial$frc (middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL) + RETURN EMPLOYEE.MIDDLE_INITIAL%TYPE + IS + BEGIN + frcflg.middle_initial := c_set; + RETURN middle_initial_in; + END middle_initial$frc; + + FUNCTION job_id$frc (job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL) + RETURN EMPLOYEE.JOB_ID%TYPE + IS + BEGIN + frcflg.job_id := c_set; + RETURN job_id_in; + END job_id$frc; + + FUNCTION manager_id$frc (manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL) + RETURN EMPLOYEE.MANAGER_ID%TYPE + IS + BEGIN + frcflg.manager_id := c_set; + RETURN manager_id_in; + END manager_id$frc; + + FUNCTION hire_date$frc (hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT NULL) + RETURN EMPLOYEE.HIRE_DATE%TYPE + IS + BEGIN + frcflg.hire_date := c_set; + RETURN hire_date_in; + END hire_date$frc; + + FUNCTION salary$frc (salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL) + RETURN EMPLOYEE.SALARY%TYPE + IS + BEGIN + frcflg.salary := c_set; + RETURN salary_in; + END salary$frc; + + FUNCTION commission$frc (commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL) + RETURN EMPLOYEE.COMMISSION%TYPE + IS + BEGIN + frcflg.commission := c_set; + RETURN commission_in; + END commission$frc; + + FUNCTION department_id$frc (department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL) + RETURN EMPLOYEE.DEPARTMENT_ID%TYPE + IS + BEGIN + frcflg.department_id := c_set; + RETURN department_id_in; + END department_id$frc; + + FUNCTION changed_by$frc (changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT NULL) + RETURN EMPLOYEE.CHANGED_BY%TYPE + IS + BEGIN + frcflg.changed_by := c_set; + RETURN changed_by_in; + END changed_by$frc; + + FUNCTION changed_on$frc (changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT NULL) + RETURN EMPLOYEE.CHANGED_ON%TYPE + IS + BEGIN + frcflg.changed_on := c_set; + RETURN changed_on_in; + END changed_on$frc; + + PROCEDURE upd ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL, + job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL, + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT NULL, + salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL, + commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT NULL, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT NULL, + rowcount_out OUT INTEGER, + reset_in IN BOOLEAN DEFAULT TRUE + ) + IS + BEGIN + UPDATE EMPLOYEE SET + LAST_NAME = DECODE (frcflg.last_name, c_set, UPPER(last_name_in), + NVL (UPPER(last_name_in), LAST_NAME)), + FIRST_NAME = DECODE (frcflg.first_name, c_set, UPPER(first_name_in), + NVL (UPPER(first_name_in), FIRST_NAME)), + MIDDLE_INITIAL = DECODE (frcflg.middle_initial, c_set, UPPER(middle_initial_in), + NVL (UPPER(middle_initial_in), MIDDLE_INITIAL)), + JOB_ID = DECODE (frcflg.job_id, c_set, job_id_in, + NVL (job_id_in, JOB_ID)), + MANAGER_ID = DECODE (frcflg.manager_id, c_set, manager_id_in, + NVL (manager_id_in, MANAGER_ID)), + HIRE_DATE = DECODE (frcflg.hire_date, c_set, TRUNC(hire_date_in), + NVL (TRUNC(hire_date_in), HIRE_DATE)), + SALARY = DECODE (frcflg.salary, c_set, salary_in, + NVL (salary_in, SALARY)), + COMMISSION = DECODE (frcflg.commission, c_set, commission_in, + NVL (commission_in, COMMISSION)), + DEPARTMENT_ID = DECODE (frcflg.department_id, c_set, department_id_in, + NVL (department_id_in, DEPARTMENT_ID)), + CHANGED_BY = DECODE (frcflg.changed_by, c_set, USER, + NVL (USER, CHANGED_BY)), + CHANGED_ON = DECODE (frcflg.changed_on, c_set, SYSDATE, + NVL (SYSDATE, CHANGED_ON)) + WHERE + EMPLOYEE_ID = employee_id_in + ; + rowcount_out := SQL%ROWCOUNT; + IF reset_in THEN reset$frc; END IF; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END upd; + + --// Record-based Update --// + PROCEDURE upd ( + rec_in IN allcols_rt, + rowcount_out OUT INTEGER, + reset_in IN BOOLEAN DEFAULT TRUE) + IS + BEGIN + upd ( + rec_in.employee_id, + rec_in.last_name, + rec_in.first_name, + rec_in.middle_initial, + rec_in.job_id, + rec_in.manager_id, + rec_in.hire_date, + rec_in.salary, + rec_in.commission, + rec_in.department_id, + rec_in.changed_by, + rec_in.changed_on, + rowcount_out, + reset_in); + END upd; + + --// Update procedure for HIRE_DATE. --// + PROCEDURE upd$hire_date ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + UPDATE EMPLOYEE SET HIRE_DATE = TRUNC(hire_date_in) + WHERE + EMPLOYEE_ID = employee_id_in + ; + rowcount_out := SQL%ROWCOUNT; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END upd$hire_date; + + --// Update procedure for HIRE_DATE using records. --// + PROCEDURE upd$hire_date ( + rec_in IN pky_rt, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + upd$hire_date ( + rec_in.employee_id, + hire_date_in, + rowcount_out + ); + END upd$hire_date; + + --// Update procedure for SALARY. --// + PROCEDURE upd$salary ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + salary_in IN EMPLOYEE.SALARY%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + UPDATE EMPLOYEE SET SALARY = salary_in + WHERE + EMPLOYEE_ID = employee_id_in + ; + rowcount_out := SQL%ROWCOUNT; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END upd$salary; + + --// Update procedure for SALARY using records. --// + PROCEDURE upd$salary ( + rec_in IN pky_rt, + salary_in IN EMPLOYEE.SALARY%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + upd$salary ( + rec_in.employee_id, + salary_in, + rowcount_out + ); + END upd$salary; + +--// Insert Processing --// + + --// Initialize record with default values. --// + FUNCTION initrec (allnull IN BOOLEAN := FALSE) RETURN allcols_rt + IS + retval allcols_rt; + BEGIN + IF allnull THEN NULL; /* Default values are NULL already. */ + ELSE + retval.employee_id := NULL; + retval.last_name := NULL; + retval.first_name := NULL; + retval.middle_initial := NULL; + retval.job_id := NULL; + retval.manager_id := NULL; + retval.hire_date := SYSDATE; + retval.salary := NULL; + retval.commission := NULL; + retval.department_id := NULL; + retval.changed_by := USER; + retval.changed_on := SYSDATE; + END IF; + RETURN retval; + END; + + --// Initialize record with default values. --// + PROCEDURE initrec ( + rec_inout IN OUT allcols_rt, + allnull IN BOOLEAN := FALSE) + IS + BEGIN + rec_inout := initrec; + END; + + PROCEDURE ins$ins ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL, + job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL, + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT SYSDATE, + salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL, + commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT USER, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT SYSDATE, + upd_on_dup IN BOOLEAN := FALSE + ) + IS + BEGIN + validate ( + employee_id_in, + TRUNC(hire_date_in), + salary_in, + department_id_in, + USER, + SYSDATE, + TRUE + ); + INSERT INTO EMPLOYEE ( + EMPLOYEE_ID + ,LAST_NAME + ,FIRST_NAME + ,MIDDLE_INITIAL + ,JOB_ID + ,MANAGER_ID + ,HIRE_DATE + ,SALARY + ,COMMISSION + ,DEPARTMENT_ID + ,CHANGED_BY + ,CHANGED_ON + ) + VALUES ( + employee_id_in + ,UPPER(last_name_in) + ,UPPER(first_name_in) + ,UPPER(middle_initial_in) + ,job_id_in + ,manager_id_in + ,TRUNC(hire_date_in) + ,salary_in + ,commission_in + ,department_id_in + ,USER + ,SYSDATE + ); + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + IF NOT NVL (upd_on_dup, FALSE) + THEN + RAISE; + ELSE + DECLARE + v_errm VARCHAR2(2000) := SQLERRM; + v_rowcount INTEGER; + dotloc INTEGER; + leftloc INTEGER; + c_owner ALL_CONSTRAINTS.OWNER%TYPE; + c_name ALL_CONSTRAINTS.CONSTRAINT_NAME%TYPE; + BEGIN + dotloc := INSTR (v_errm,'.'); + leftloc := INSTR (v_errm,'('); + c_owner :=SUBSTR (v_errm, leftloc+1, dotloc-leftloc-1); + c_name := SUBSTR (v_errm, dotloc+1, INSTR (v_errm,')')-dotloc-1); + + --// Duplicate based on primary key //-- + IF 'EMP_PK' = c_name AND 'SCOTT' = c_owner + THEN + upd ( + employee_id_in, + last_name_in, + first_name_in, + middle_initial_in, + job_id_in, + manager_id_in, + hire_date_in, + salary_in, + commission_in, + department_id_in, + changed_by_in, + changed_on_in, + v_rowcount, + FALSE + ); + ELSE + --// Unique index violation. Cannot recover... //-- + RAISE; + END IF; + END; + END IF; + WHEN OTHERS + THEN + RAISE; + END ins$ins; + + --// Insert 1: with individual fields and return primary key //-- + PROCEDURE ins ( + last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL, + job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL, + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT SYSDATE, + salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL, + commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT USER, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT SYSDATE, + employee_id_out IN OUT EMPLOYEE.EMPLOYEE_ID%TYPE, + upd_on_dup IN BOOLEAN := FALSE + ) + IS + v_pky INTEGER := nextpky; + BEGIN + ins$ins ( + v_pky, + last_name_in, + first_name_in, + middle_initial_in, + job_id_in, + manager_id_in, + hire_date_in, + salary_in, + commission_in, + department_id_in, + changed_by_in, + changed_on_in, + upd_on_dup + ); + employee_id_out := v_pky; + END; + + --// Insert 2: with record, returning primary key. //-- + PROCEDURE ins ( + rec_in IN allcols_rt, + employee_id_out IN OUT EMPLOYEE.EMPLOYEE_ID%TYPE, + upd_on_dup IN BOOLEAN := FALSE + ) + IS + v_pky INTEGER := nextpky; + BEGIN + ins$ins ( + v_pky, + rec_in.last_name, + rec_in.first_name, + rec_in.middle_initial, + rec_in.job_id, + rec_in.manager_id, + rec_in.hire_date, + rec_in.salary, + rec_in.commission, + rec_in.department_id, + rec_in.changed_by, + rec_in.changed_on, + upd_on_dup + ); + employee_id_out := v_pky; + END; + +--// Delete Processing --// + + PROCEDURE del ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + rowcount_out OUT INTEGER) + IS + BEGIN + DELETE FROM EMPLOYEE + WHERE + EMPLOYEE_ID = employee_id_in + ; + rowcount_out := SQL%ROWCOUNT; + IF SQL%ROWCOUNT > 0 + THEN + loadtab.DELETE (employee_id_in); + END IF; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END del; + + --// Record-based delete --// + PROCEDURE del + (rec_in IN pky_rt, + rowcount_out OUT INTEGER) + IS + BEGIN + del ( + rec_in.employee_id, + rowcount_out); + END del; + + PROCEDURE del (rec_in IN allcols_rt, + rowcount_out OUT INTEGER) + IS + BEGIN + del ( + rec_in.employee_id, + rowcount_out); + END del; + + --// Delete all records for foreign key EMP_DEPT_LOOKUP. //-- + PROCEDURE delby_emp_dept_lookup ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + DELETE FROM EMPLOYEE + WHERE + DEPARTMENT_ID = delby_emp_dept_lookup.department_id_in + ; + rowcount_out := SQL%ROWCOUNT; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END delby_emp_dept_lookup; + + --// Delete all records for foreign key EMP_JOB_LOOKUP. //-- + PROCEDURE delby_emp_job_lookup ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + DELETE FROM EMPLOYEE + WHERE + JOB_ID = delby_emp_job_lookup.job_id_in + ; + rowcount_out := SQL%ROWCOUNT; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END delby_emp_job_lookup; + + --// Delete all records for foreign key EMP_MGR_LOOKUP. //-- + PROCEDURE delby_emp_mgr_lookup ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + rowcount_out OUT INTEGER + ) + IS + BEGIN + DELETE FROM EMPLOYEE + WHERE + MANAGER_ID = delby_emp_mgr_lookup.manager_id_in + ; + rowcount_out := SQL%ROWCOUNT; + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END delby_emp_mgr_lookup; + + + --// Program called by database initialization script to pin the package. //-- + PROCEDURE pinme + IS + BEGIN + --// Doesn't do anything except cause the package to be loaded. //-- + NULL; + END; + + + PROCEDURE load_to_memory + IS + BEGIN + loadtab.DELETE; + FOR rec IN ( + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + ) + LOOP + loadtab (rec.EMPLOYEE_ID) := rec; + END LOOP; + END; + + PROCEDURE showload ( + start_inout IN INTEGER := NULL, + end_inout IN INTEGER := NULL + ) + IS + v_row PLS_INTEGER := loadtab.FIRST; + v_last PLS_INTEGER := loadtab.LAST; + BEGIN + IF v_row IS NULL + THEN + DBMS_OUTPUT.PUT_LINE ('In-memory table for EMPLOYEE is empty!'); + ELSE + IF start_inout > v_row + THEN + v_row := loadtab.NEXT (start_inout-1); + END IF; + IF end_inout < v_last + THEN + v_last := loadtab.PRIOR (end_inout+1); + END IF; + LOOP + EXIT WHEN v_row > v_last OR v_row IS NULL; + DBMS_OUTPUT.PUT_LINE ('PKY Value/Row: ' || loadtab(v_row).EMPLOYEE_ID); + v_row := loadtab.NEXT (v_row); + END LOOP; + END IF; + END; +--// Initialization section for the package. --// +BEGIN + NULL; -- Placeholder. + load_to_memory; +END te_employee; +/ diff --git a/examples/te_employee.pks b/examples/te_employee.pks new file mode 100644 index 000000000..8ebcac964 --- /dev/null +++ b/examples/te_employee.pks @@ -0,0 +1,691 @@ +CREATE OR REPLACE PACKAGE te_employee +--//----------------------------------------------------------------------- +--// ** PL/Generator Table Encapsulator for "employee" +--//----------------------------------------------------------------------- +--// (c) COPYRIGHT Personnel Policies, Inc. 1999. +--// All rights reserved. +--// +--// No part of this copyrighted work may be reproduced, modified, +--// or distributed in any form or by any means without the prior +--// written permission of Personnel Policies, Inc.. +--//----------------------------------------------------------------------- +--// This software was generated by RevealNet's PL/Generator (TM). +--// +--// For more information, visit www.revealnet.com or call 1.800.REVEAL4 +--//----------------------------------------------------------------------- +--// Stored In: te_employee.pks +--// Created On: September 05, 2000 20:14:04 +--// Created By: SCOTT +--// PL/Generator Version: PRO-2000.1.1 +--//----------------------------------------------------------------------- +IS +--// Data Structures //-- + TYPE pky_rt IS RECORD ( + employee_id EMPLOYEE.EMPLOYEE_ID%TYPE + ); + + --// Modified version of %ROWTYPE for table with subset of columns //-- + TYPE allcols_rt IS RECORD ( + employee_id EMPLOYEE.EMPLOYEE_ID%TYPE, + last_name EMPLOYEE.LAST_NAME%TYPE, + first_name EMPLOYEE.FIRST_NAME%TYPE, + middle_initial EMPLOYEE.MIDDLE_INITIAL%TYPE, + job_id EMPLOYEE.JOB_ID%TYPE, + manager_id EMPLOYEE.MANAGER_ID%TYPE, + hire_date EMPLOYEE.HIRE_DATE%TYPE, + salary EMPLOYEE.SALARY%TYPE, + commission EMPLOYEE.COMMISSION%TYPE, + department_id EMPLOYEE.DEPARTMENT_ID%TYPE, + changed_by EMPLOYEE.CHANGED_BY%TYPE, + changed_on EMPLOYEE.CHANGED_ON%TYPE + ); + + TYPE cv_t IS REF CURSOR; + + TYPE i_employee_name_rt IS RECORD ( + last_name EMPLOYEE.LAST_NAME%TYPE, + first_name EMPLOYEE.FIRST_NAME%TYPE, + middle_initial EMPLOYEE.MIDDLE_INITIAL%TYPE + ); + CURSOR totsal_cur + IS + SELECT department_id, SUM(salary) total_salary + FROM employee + GROUP BY department_id; + + +--// Cursors //-- + + CURSOR compbypky_cur + IS + SELECT + employee_id, salary, commission + FROM EMPLOYEE + ORDER BY + EMPLOYEE_ID + ; + + CURSOR compforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + IS + SELECT + employee_id, salary, commission + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = compforpky_cur.employee_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_dept_lookup_comp_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) + IS + SELECT + employee_id, salary, commission + FROM EMPLOYEE + WHERE + DEPARTMENT_ID = emp_dept_lookup_comp_cur.department_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_job_lookup_comp_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE + ) + IS + SELECT + employee_id, salary, commission + FROM EMPLOYEE + WHERE + JOB_ID = emp_job_lookup_comp_cur.job_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_mgr_lookup_comp_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE + ) + IS + SELECT + employee_id, salary, commission + FROM EMPLOYEE + WHERE + MANAGER_ID = emp_mgr_lookup_comp_cur.manager_id_in + ; + + CURSOR namebypky_cur + IS + SELECT + last_name || ', ' || first_name full_name + FROM EMPLOYEE + ORDER BY + EMPLOYEE_ID + ; + + CURSOR nameforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + IS + SELECT + last_name || ', ' || first_name full_name + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = nameforpky_cur.employee_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_dept_lookup_name_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) + IS + SELECT + last_name || ', ' || first_name full_name + FROM EMPLOYEE + WHERE + DEPARTMENT_ID = emp_dept_lookup_name_cur.department_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_job_lookup_name_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE + ) + IS + SELECT + last_name || ', ' || first_name full_name + FROM EMPLOYEE + WHERE + JOB_ID = emp_job_lookup_name_cur.job_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_mgr_lookup_name_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE + ) + IS + SELECT + last_name || ', ' || first_name full_name + FROM EMPLOYEE + WHERE + MANAGER_ID = emp_mgr_lookup_name_cur.manager_id_in + ; + + CURSOR allbypky_cur + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + ORDER BY + EMPLOYEE_ID + ; + + CURSOR allforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + WHERE + EMPLOYEE_ID = allforpky_cur.employee_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_dept_lookup_all_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + WHERE + DEPARTMENT_ID = emp_dept_lookup_all_cur.department_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_job_lookup_all_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE + ) + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + WHERE + JOB_ID = emp_job_lookup_all_cur.job_id_in + ; + + --// Specified columns, all rows for this foreign key. //-- + CURSOR emp_mgr_lookup_all_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE + ) + IS + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + FROM EMPLOYEE + WHERE + MANAGER_ID = emp_mgr_lookup_all_cur.manager_id_in + ; + +--// Cursor management procedures //-- + + --// Open the cursors with some options. //-- + PROCEDURE open_compforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_compbypky_cur ( + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_dept_lookup_comp_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_job_lookup_comp_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_mgr_lookup_comp_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + PROCEDURE open_nameforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_namebypky_cur ( + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_dept_lookup_name_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_job_lookup_name_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_mgr_lookup_name_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + PROCEDURE open_allforpky_cur ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_allbypky_cur ( + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_dept_lookup_all_cur ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_job_lookup_all_cur ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + PROCEDURE open_emp_mgr_lookup_all_cur ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + close_if_open IN BOOLEAN := TRUE + ); + + --// Close the cursors if they are open. //-- + PROCEDURE close_compforpky_cur; + PROCEDURE close_compbypky_cur; + PROCEDURE close_emp_dept_lookup_comp_cur; + PROCEDURE close_emp_job_lookup_comp_cur; + PROCEDURE close_emp_mgr_lookup_comp_cur; + PROCEDURE close_nameforpky_cur; + PROCEDURE close_namebypky_cur; + PROCEDURE close_emp_dept_lookup_name_cur; + PROCEDURE close_emp_job_lookup_name_cur; + PROCEDURE close_emp_mgr_lookup_name_cur; + PROCEDURE close_allforpky_cur; + PROCEDURE close_allbypky_cur; + PROCEDURE close_emp_dept_lookup_all_cur; + PROCEDURE close_emp_job_lookup_all_cur; + PROCEDURE close_emp_mgr_lookup_all_cur; + PROCEDURE closeall; + +--// Analyze presence of primary key: is it NOT NULL? //-- + + FUNCTION isnullpky ( + rec_in IN allcols_rt + ) + RETURN BOOLEAN; + + FUNCTION isnullpky ( + rec_in IN pky_rt + ) + RETURN BOOLEAN; + +--// Emulate aggregate-level record operations. //-- + + FUNCTION recseq (rec1 IN allcols_rt, rec2 IN allcols_rt) + RETURN BOOLEAN; + + FUNCTION recseq (rec1 IN pky_rt, rec2 IN pky_rt) + RETURN BOOLEAN; + +--// Fetch Data //-- + + --// Fetch one row of data for a primary key. //-- + FUNCTION onerow ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN allcols_rt; + + --// For each unique index ... //-- + + FUNCTION i_employee_name$pky ( + last_name_in IN EMPLOYEE.LAST_NAME%TYPE, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE + ) + RETURN pky_rt + ; + + FUNCTION i_employee_name$val ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN i_employee_name_rt; + + FUNCTION i_employee_name$row ( + last_name_in IN EMPLOYEE.LAST_NAME%TYPE, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE + ) + RETURN allcols_rt; + + --// For each update column ... //-- + + FUNCTION hire_date$val ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN EMPLOYEE.HIRE_DATE%TYPE; + --// For each update column ... //-- + + FUNCTION salary$val ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN EMPLOYEE.SALARY%TYPE; + + --// Count of all rows in table and for each foreign key. //-- + FUNCTION rowcount RETURN INTEGER; + FUNCTION pkyrowcount ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) + RETURN INTEGER; + FUNCTION emp_dept_lookuprowcount ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) + RETURN INTEGER; + FUNCTION emp_job_lookuprowcount ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE + ) + RETURN INTEGER; + FUNCTION emp_mgr_lookuprowcount ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE + ) + RETURN INTEGER; + + PROCEDURE lookup_fkydescs ( + --// Foreign key columns for emp_dept_lookup //-- + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + emp_dept_lookup_out OUT te_department.i_department_name_rt, + --// Foreign key columns for emp_job_lookup //-- + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + emp_job_lookup_out OUT te_job.i_job_function_rt, + --// Foreign key columns for emp_mgr_lookup //-- + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + emp_mgr_lookup_out OUT te_employee.i_employee_name_rt, + record_error BOOLEAN := TRUE + ); +--// Check Constraint Validation //-- + + --// Check Constraint: DEPARTMENT_ID > 0 AND (salary > 0 OR salary IS NULL) //-- + FUNCTION employee$complex$chk ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + salary_in IN EMPLOYEE.SALARY%TYPE + ) RETURN BOOLEAN; + + --// Check Constraint: DEPARTMENT_ID IS NOT NULL //-- + FUNCTION notnull_department_id$chk ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE + ) RETURN BOOLEAN; + + --// Check Constraint: EMPLOYEE_ID IS NOT NULL //-- + FUNCTION notnull_employee_id$chk ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE + ) RETURN BOOLEAN; + + --// Check Constraint: "HIRE_DATE" IS NOT NULL //-- + FUNCTION sys_c001373$chk ( + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE + ) RETURN BOOLEAN; + + --// Check Constraint: "CHANGED_BY" IS NOT NULL //-- + FUNCTION sys_c001376$chk ( + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE + ) RETURN BOOLEAN; + + --// Check Constraint: "CHANGED_ON" IS NOT NULL //-- + FUNCTION sys_c001377$chk ( + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE + ) RETURN BOOLEAN; + PROCEDURE validate ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE, + salary_in IN EMPLOYEE.SALARY%TYPE, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE, + record_error IN BOOLEAN := TRUE + ); + + PROCEDURE validate ( + rec_in IN allcols_rt, + record_error IN BOOLEAN := TRUE + ); +--// Update Processing //-- + + PROCEDURE reset$frc; + + --// Force setting of NULL values //-- + + FUNCTION last_name$frc + (last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL) + RETURN EMPLOYEE.LAST_NAME%TYPE; + + FUNCTION first_name$frc + (first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL) + RETURN EMPLOYEE.FIRST_NAME%TYPE; + + FUNCTION middle_initial$frc + (middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL) + RETURN EMPLOYEE.MIDDLE_INITIAL%TYPE; + + FUNCTION job_id$frc + (job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL) + RETURN EMPLOYEE.JOB_ID%TYPE; + + FUNCTION manager_id$frc + (manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL) + RETURN EMPLOYEE.MANAGER_ID%TYPE; + + FUNCTION hire_date$frc + (hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT NULL) + RETURN EMPLOYEE.HIRE_DATE%TYPE; + + FUNCTION salary$frc + (salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL) + RETURN EMPLOYEE.SALARY%TYPE; + + FUNCTION commission$frc + (commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL) + RETURN EMPLOYEE.COMMISSION%TYPE; + + FUNCTION department_id$frc + (department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL) + RETURN EMPLOYEE.DEPARTMENT_ID%TYPE; + + FUNCTION changed_by$frc + (changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT NULL) + RETURN EMPLOYEE.CHANGED_BY%TYPE; + + FUNCTION changed_on$frc + (changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT NULL) + RETURN EMPLOYEE.CHANGED_ON%TYPE; + + PROCEDURE upd ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL, + job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL, + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT NULL, + salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL, + commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT NULL, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT NULL, + rowcount_out OUT INTEGER, + reset_in IN BOOLEAN DEFAULT TRUE + ); + + --// Record-based Update //-- + + PROCEDURE upd (rec_in IN allcols_rt, + rowcount_out OUT INTEGER, + reset_in IN BOOLEAN DEFAULT TRUE); + + + --// Update procedure for HIRE_DATE. --// + PROCEDURE upd$hire_date ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE, + rowcount_out OUT INTEGER + ); + + PROCEDURE upd$hire_date ( + rec_in IN pky_rt, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE, + rowcount_out OUT INTEGER + ); + + + --// Update procedure for SALARY. --// + PROCEDURE upd$salary ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + salary_in IN EMPLOYEE.SALARY%TYPE, + rowcount_out OUT INTEGER + ); + + PROCEDURE upd$salary ( + rec_in IN pky_rt, + salary_in IN EMPLOYEE.SALARY%TYPE, + rowcount_out OUT INTEGER + ); + +--// Insert Processing //-- + + --// Initialize record with default values. //-- + FUNCTION initrec (allnull IN BOOLEAN := FALSE) RETURN allcols_rt; + + --// Initialize record with default values. //-- + PROCEDURE initrec ( + rec_inout IN OUT allcols_rt, + allnull IN BOOLEAN := FALSE); + + + --// Generate next primary key: for single column PKs only. //-- + FUNCTION nextpky RETURN EMPLOYEE.employee_id%TYPE; + + PROCEDURE ins ( + last_name_in IN EMPLOYEE.LAST_NAME%TYPE DEFAULT NULL, + first_name_in IN EMPLOYEE.FIRST_NAME%TYPE DEFAULT NULL, + middle_initial_in IN EMPLOYEE.MIDDLE_INITIAL%TYPE DEFAULT NULL, + job_id_in IN EMPLOYEE.JOB_ID%TYPE DEFAULT NULL, + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE DEFAULT NULL, + hire_date_in IN EMPLOYEE.HIRE_DATE%TYPE DEFAULT SYSDATE, + salary_in IN EMPLOYEE.SALARY%TYPE DEFAULT NULL, + commission_in IN EMPLOYEE.COMMISSION%TYPE DEFAULT NULL, + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE DEFAULT NULL, + changed_by_in IN EMPLOYEE.CHANGED_BY%TYPE DEFAULT USER, + changed_on_in IN EMPLOYEE.CHANGED_ON%TYPE DEFAULT SYSDATE, + employee_id_out IN OUT EMPLOYEE.EMPLOYEE_ID%TYPE, + upd_on_dup IN BOOLEAN := FALSE + ); + + PROCEDURE ins (rec_in IN allcols_rt, + employee_id_out IN OUT EMPLOYEE.EMPLOYEE_ID%TYPE, + upd_on_dup IN BOOLEAN := FALSE + ); + +--// Delete Processing //-- + PROCEDURE del ( + employee_id_in IN EMPLOYEE.EMPLOYEE_ID%TYPE, + rowcount_out OUT INTEGER); + + --// Record-based delete //-- + PROCEDURE del (rec_in IN pky_rt, + rowcount_out OUT INTEGER); + + PROCEDURE del (rec_in IN allcols_rt, + rowcount_out OUT INTEGER); + + --// Delete all records for this EMP_DEPT_LOOKUP foreign key. //-- + PROCEDURE delby_emp_dept_lookup ( + department_id_in IN EMPLOYEE.DEPARTMENT_ID%TYPE, + rowcount_out OUT INTEGER + ); + + --// Delete all records for this EMP_JOB_LOOKUP foreign key. //-- + PROCEDURE delby_emp_job_lookup ( + job_id_in IN EMPLOYEE.JOB_ID%TYPE, + rowcount_out OUT INTEGER + ); + + --// Delete all records for this EMP_MGR_LOOKUP foreign key. //-- + PROCEDURE delby_emp_mgr_lookup ( + manager_id_in IN EMPLOYEE.MANAGER_ID%TYPE, + rowcount_out OUT INTEGER + ); + + --// Program called by database initialization script to pin the package. //-- + PROCEDURE pinme; + + --// Load and display index table of data - PK only. //-- + PROCEDURE load_to_memory; + + PROCEDURE showload ( + start_inout IN INTEGER := NULL, + end_inout IN INTEGER := NULL + ); + FUNCTION version RETURN VARCHAR2; +END te_employee; +/ diff --git a/examples/te_utpkg.gdr b/examples/te_utpkg.gdr new file mode 100644 index 000000000..a9976937a --- /dev/null +++ b/examples/te_utpkg.gdr @@ -0,0 +1,199 @@ +#===========================================================RevealNet GenX Driver========== +# Description: Create package to perform unit testing against base package with utPLSQL. +#========================================================================================== +# Category: Unit Test Package for Table Encapsulation package +#========================================================================================== +# Summary: Designed to be a DOUBLE PASS generation. Generate once against the +# package, then generate this output against the base table! +# +# WARNING: Generating duplicate of entire package! +# +#========================================================================================== +# Application area: Testing +#========================================================================================== +# Key words: PLSQL,PROG,ARG,UTPLSQL +#========================================================================================== +# Script Requirements/Dependencies +# Backend Version: PL/SQL 2.3 (Oracle 7.3) and above +# INCLUDEs: None +# EXECs: None +#========================================================================================== +# Generated Text Requirements/Dependencies +# Language and Version: PL/SQL 2.3 (Oracle 7.3) and above +# Operating System(s): Non-specific +#========================================================================================== +# Author: Steven Feuerstein, RevealNet: feuerstein@revealnet.com +#========================================================================================== +# Modification History +# +# When Who What +# ----------------------------------------------------------------------------------------- +# 05/2000 SEF Created +#========================================================================================== +[SETALIAS]allprogs[TO]N +[SETALIAS]utprefix[TO]ut_ +[SETALIAS]tabprefix[TO]{utprefix} +[SETALIAS]olprog[TO]\[progname][overload] +[SETALIAS]progtab[TO]\{tabprefix}{olprog} +[SETALIAS]oltestprog[TO]\{utprefix}{olprog} +[STOREIN]{utprefix}[objname].gdr +[ASIS] +[SET]objname[TO]#CHANGE THIS +[SETALIAS]tabprefix[TO]{utprefix} +[ENDASIS] +CREATE OR REPLACE PACKAGE [schema].{utprefix}[objname] AUTHID CURRENT_USER +-- SECOND PASS INSTRUCTIONS: +-- +-- Set the object name and generate this GDR to produce the test package. +-- After generation, save to pks and pkb files and put in the specific +-- code for the various tests. +IS + PROCEDURE {utprefix}setup; + + PROCEDURE {utprefix}teardown; + +[FOREACH]prog + [IF]{allprogs}[EQ]Y[OR][progname][LIKE]UPD%[OR][progname][LIKE]INS%[OR][progname][LIKE]DEL% + PROCEDURE ^{oltestprog}^; + [ENDIF] +[ENDFOREACH] + +END {utprefix}[objname]; +/ +CREATE OR REPLACE PACKAGE BODY [schema].{utprefix}[objname] AUTHID CURRENT_USER +IS + PROCEDURE {utprefix}setup + IS + BEGIN + -- Clean start + {utprefix}teardown; +[ASIS] + -- Generic copy of base table for testing + EXECUTE IMMEDIATE + 'CREATE TABLE {tabprefix}[objname] AS + SELECT * FROM [objname]'; + +[ENDASIS] + [FOREACH]prog + [IF]{allprogs}[EQ]Y[OR][progname][LIKE]UPD%[OR][progname][LIKE]INS%[OR][progname][LIKE]DEL% + -- Create copy of base table for this unit test. + EXECUTE IMMEDIATE + 'CREATE TABLE ^{progtab}^ AS +[ASIS] + SELECT * FROM [objname]'; +[ENDASIS] + + [ENDIF] + [ENDFOREACH] + END; + + PROCEDURE {utprefix}teardown + IS + BEGIN +[ASIS] + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE {tabprefix}[objname]'; + EXCEPTION WHEN OTHERS THEN NULL; + END; +[ENDASIS] + + [FOREACH]prog + [IF]{allprogs}[EQ]Y[OR][progname][LIKE]UPD%[OR][progname][LIKE]INS%[OR][progname][LIKE]DEL% + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ^{progtab}^'; + EXCEPTION WHEN OTHERS THEN NULL; + END; + [ENDIF] + [ENDFOREACH] + END; +[FOREACH]prog + [IF]{allprogs}[EQ]Y[OR][progname][LIKE]UPD%[OR][progname][LIKE]INS%[OR][progname][LIKE]DEL% + + PROCEDURE {utprefix}{utprefix}[progname][overload] + IS +[IF][progname][LIKE]INS%[OR][progname][LIKE]UPD% +[ASIS] +[FOREACH]col + v_[colname] [objname].[colname]%TYPE; +[ENDFOREACH] +[ENDASIS] +[ENDIF] + fdbk PLS_INTEGER; + BEGIN + -- Perform [progname] operation(s) using + -- explicit actions to measURE {utprefix}against. + + EXECUTE IMMEDIATE ' + [IF][progname][LIKE]INS% + INSERT INTO ^{progtab}^ ( +[ASIS] +[FOREACH]col[between], + [colname] +[ENDFOREACH] + ) + VALUES ( +[FOREACH]col[between], + :[colname] +[ENDFOREACH] + )' + USING +[FOREACH]col[between], + v_[colname] +[ENDFOREACH] + ; +[ENDASIS] + [ELSIF][progname][LIKE]UPD% + UPDATE ^{progtab}^ SET +[ASIS] +[FOREACH]nonpkycol[between], + [colname] = :[colname] +[ENDFOREACH] + WHERE +[FOREACH]pkycol[between] AND + [colname] = [coldmlval] +[ENDFOREACH] + ' + USING +[FOREACH]col[between], + v_[colname] +[ENDFOREACH] +[ENDASIS] + ; + [ELSIF][progname][LIKE]DEL% + DELETE FROM ^{progtab}^ + WHERE +[ASIS] +[FOREACH]pkycol[between] AND + [colname] = [coldmlval] +[ENDFOREACH] +[ENDASIS] + '; + [ENDIF] + + -- Compare to program call: + [progname] ( + ,rowcount => fdbk + ); + + -- Test results + utAssert.eqtable ( + 'Successful [progname][overload]', +[ASIS] + '[objname]', +[ENDASIS] + '^{progtab}^'); + + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failure. + utAssert.this ( + '^{progtab}^ exception ' || SQLERRM, + SQLCODE = 0); + END; + [ENDIF] +[ENDFOREACH] + +END {utprefix}[objname]; +/ diff --git a/examples/temp.sql b/examples/temp.sql new file mode 100644 index 000000000..0a0bf5ff1 --- /dev/null +++ b/examples/temp.sql @@ -0,0 +1,53 @@ +CREATE OR REPLACE FUNCTION betwnStr ( + string_in IN VARCHAR2, + start_in IN INTEGER, + end_in IN INTEGER + ) + RETURN VARCHAR2 +IS +BEGIN + raise value_Error; + + RETURN ( + SUBSTR ( + string_in, + start_in, + end_in - start_in + 1 + ) + ); +END; +/ +CREATE OR REPLACE PACKAGE BODY ut_betwnstr +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_BETWNSTR IS + BEGIN + utAssert.throws ( + 'NDF', + BETWNSTR( + STRING_IN => 'abcdefg' + , + START_IN => 3 + , + END_IN => 5 + ), + -6502 + ); + + + END ut_BETWNSTR; + +END ut_betwnstr; +/ diff --git a/examples/tequery_utpkg.gdr b/examples/tequery_utpkg.gdr new file mode 100644 index 000000000..761d06469 --- /dev/null +++ b/examples/tequery_utpkg.gdr @@ -0,0 +1,111 @@ +#===========================================================RevealNet GenX Driver========== +# Description: Create package to perform unit testing against base package with utPLSQL. +#========================================================================================== +# Category: Unit Test Package for Table Encapsulation package +#========================================================================================== +# Summary: Designed to be a DOUBLE PASS generation. Generate once against the +# package, then generate this output against the base table! +# +# WARNING: Generating duplicate of entire package! +# +#========================================================================================== +# Application area: Testing +#========================================================================================== +# Key words: PLSQL,PROG,ARG,UTPLSQL +#========================================================================================== +# Script Requirements/Dependencies +# Backend Version: PL/SQL 2.3 (Oracle 7.3) and above +# INCLUDEs: None +# EXECs: None +#========================================================================================== +# Generated Text Requirements/Dependencies +# Language and Version: PL/SQL 2.3 (Oracle 7.3) and above +# Operating System(s): Non-specific +#========================================================================================== +# Author: Steven Feuerstein, RevealNet: feuerstein@revealnet.com +#========================================================================================== +# Modification History +# +# When Who What +# ----------------------------------------------------------------------------------------- +# 05/2000 SEF Created +#========================================================================================== +[SETALIAS]utprefix[TO]ut# +[SETALIAS]tabprefix[TO]ut_ +[SETALIAS]olprog[TO]\[progname][overload] +[SETALIAS]progtab[TO]\{tabprefix}{olprog} +[SETALIAS]oltestprog[TO]\{utprefix}{olprog} +[STOREIN]{utprefix}[objname].gdr +[ASIS] +[SET]objname[TO]#CHANGE THIS +[SETALIAS]tabprefix[TO]ut_ +[ENDASIS] +CREATE OR REPLACE PACKAGE [schema].{utprefix}[objname] AUTHID CURRENT_USER +-- SECOND PASS INSTRUCTIONS: +-- +-- Set the object name and generate this GDR to produce the test package. +-- After generation, save to pks and pkb files and put in the specific +-- code for the various tests. +IS + [ASIS] + rec [objname]%ROWTYPE; +[ENDASIS] + + PROCEDURE {utprefix}setup; + + PROCEDURE {utprefix}teardown; + +[FOREACH]prog + [IF][progname][LIKE]%ROW%[OR][progname][LIKE]%$VAL[OR][progname][LIKE]$PKY + PROCEDURE ^{oltestprog}^; + [ENDIF] +[ENDFOREACH] + +END {utprefix}[objname]; +/ +CREATE OR REPLACE PACKAGE BODY [schema].{utprefix}[objname] AUTHID CURRENT_USER +IS + PROCEDURE setup + IS + BEGIN + -- Clean start + {utprefix}teardown; + END; + + PROCEDURE teardown + IS + BEGIN + NULL; + END; +[FOREACH]prog + [IF][progname][LIKE]%ROW%[OR][progname][LIKE]%$VAL[OR][progname][LIKE]$PKY + + PROCEDURE {utprefix}[progname][overload] + IS + BEGIN + -- Run baseline code. + + -- Compare to program call: + [progname] ( + ); + + -- Test results + utAssert.eqtable ( + 'Successful [progname][overload]', + [progname], + 'base query' + ); + + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failure. + utAssert.this ( + '[progname] exception ' || SQLERRM, + SQLCODE = 0); + END; + [ENDIF] +[ENDFOREACH] + +END {utprefix}[objname]; +/ diff --git a/examples/test_betwnstr.sql b/examples/test_betwnstr.sql new file mode 100644 index 000000000..5d60da691 --- /dev/null +++ b/examples/test_betwnstr.sql @@ -0,0 +1,3 @@ +begin + utplsql.test ('betwnstr'); +end; diff --git a/examples/test_pkg1.pck b/examples/test_pkg1.pck deleted file mode 100644 index 6c5a80cb3..000000000 --- a/examples/test_pkg1.pck +++ /dev/null @@ -1,110 +0,0 @@ -create or replace package test_pkg1 is - - /* - This is the correct annotation - */ - -- %suite - -- %displayname(Name of suite on test_pkg1) - -- %suitepath(all.globaltests) - - /* - Such comments are skipped - - test name - %test1 - %test2(name=123) - %test3(name2=123,tete=123) - %test4(name2=123,tete) - */ - /* - This procedure is annotated incorrectly as no correct annotations specified - Procedure is skipped while suite configuration - */ - --test name - --%test1 - --%test2 - --%displayname(name=123) - ---- %test3(name2=123,tete=123) - ---- asd %test4(name2=123,tete) - -- t3 t4 - procedure foo; - - -- %test - -- %displayname(Name of test1) - -- %beforetest(setup_test1) - -- %aftertest(teardown_test1) - procedure test1; - - -- %test - -- %displayname(Name of test2) - procedure test2; - - -- %beforeall - procedure global_setup; - - procedure setup_test1; - - procedure teardown_test1; - - -- %beforeeach - procedure def_setup; - - -- %aftereach - procedure def_teardown; - - --%afterall - procedure global_teardown; - -end; -/ -create or replace package body test_pkg1 is - - g_val1 number; - g_val2 number; - - procedure foo is - begin - null; - end; - - procedure test1 is - begin - ut.expect(g_val1,'1 equals 1 check').to_equal(1); - end; - - procedure test2 is - begin - ut.expect(g_val2,'2 equals 2 check').to_equal(2); - end; - - procedure global_setup is - begin - dbms_output.put_line('setup procedure of test_pkb1'); - end; - - procedure setup_test1 is - begin - g_val1 := 1; - end; - - procedure teardown_test1 is - begin - g_val1 := null; - end; - - procedure def_setup is - begin - g_val2 := 2; - end; - - procedure def_teardown is - begin - g_val2 := null; - end; - - procedure global_teardown is - begin - dbms_output.put_line('global teardown procedure of test_pkb1'); - end; -end test_pkg1; -/ diff --git a/examples/test_pkg2.pck b/examples/test_pkg2.pck deleted file mode 100644 index 3fe09cd56..000000000 --- a/examples/test_pkg2.pck +++ /dev/null @@ -1,33 +0,0 @@ -create or replace package test_pkg2 is - - /* - This is the correct annotation - */ - -- %suite - -- %displayname(Name of suite on test_pkg2) - -- %suitepath(all) - - -- %test - -- %displayname(Name of test1) - procedure test1; - - -- %test - -- %displayname(Name of test2) - procedure test2; - -end; -/ -create or replace package body test_pkg2 is - - procedure test1 is - begin - ut.expect(1,'1 equals 1 check').to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2,'2 equals 2 check').to_equal(2); - end; - -end test_pkg2; -/ diff --git a/examples/test_te_employee.pkb b/examples/test_te_employee.pkb new file mode 100644 index 000000000..c62c857fc --- /dev/null +++ b/examples/test_te_employee.pkb @@ -0,0 +1,916 @@ +CREATE OR REPLACE PACKAGE BODY test_te_employee +IS + g_rowcount1 PLS_INTEGER; + g_rowcount2 PLS_INTEGER; + + FUNCTION recseq ( + rec1 IN te_employee.i_employee_name_rt, + rec2 IN te_employee.i_employee_name_rt + ) + RETURN BOOLEAN + IS + unequal_records EXCEPTION; + retval BOOLEAN; + BEGIN + retval := + rec1.last_name = rec2.last_name + OR ( + rec1.last_name IS NULL + AND rec2.last_name IS NULL + ); + + IF NOT NVL (retval, FALSE) + THEN + RAISE unequal_records; + END IF; + + retval := + rec1.first_name = rec2.first_name + OR ( + rec1.first_name IS NULL + AND rec2.first_name IS NULL + ); + + IF NOT NVL (retval, FALSE) + THEN + RAISE unequal_records; + END IF; + + retval := + rec1.middle_initial = rec2.middle_initial + OR ( + rec1.middle_initial IS NULL + AND rec2.middle_initial IS NULL + ); + + IF NOT NVL (retval, FALSE) + THEN + RAISE unequal_records; + END IF; + + RETURN TRUE; + EXCEPTION + WHEN unequal_records + THEN + RETURN FALSE; + END; + + PROCEDURE test_setup + IS + BEGIN + test_teardown; + EXECUTE IMMEDIATE 'CREATE TABLE test_employee AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_DEL1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_DELBY_EMP_DEPT_LOOKUP AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_DELBY_EMP_JOB_LOOKUP AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_DELBY_EMP_MGR_LOOKUP AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_INS1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_UPD1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_UPD$HIRE_DATE1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE test_UPD$SALARY1 AS + SELECT * FROM employee'; + END; + + PROCEDURE test_teardown + IS + BEGIN + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_employee'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_DEL1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_DELBY_EMP_DEPT_LOOKUP'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_DELBY_EMP_JOB_LOOKUP'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_DELBY_EMP_MGR_LOOKUP'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_INS1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_UPD1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_UPD$HIRE_DATE1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE test_UPD$SALARY1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + END; + + PROCEDURE test_del1 + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DEL1 + WHERE employee_id = -1 + '; + te_employee.del (-1, rowcount_out => fdbk); + -- Test results + utassert.eqtable ('Delete rows', 'EMPLOYEE', 'test_DEL1'); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DEL1 + WHERE employee_id between 7800 and 7899 + '; + + FOR rec IN (SELECT * + FROM employee + WHERE employee_id BETWEEN 7800 AND 7899) + LOOP + te_employee.del ( + rec.employee_id, + rowcount_out => fdbk + ); + END LOOP; + + -- Test results + utassert.eqtable ('Delete rows', 'EMPLOYEE', 'test_DEL1'); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + utassert.this ( + 'DEL1 exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_delby_emp_dept_lookup + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DELBY_EMP_DEPT_LOOKUP + WHERE department_id = -1 + '; + te_employee.delby_emp_dept_lookup ( + -1, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Delete no rows via DELBY_EMP_DEPT_LOOKUP', + 'EMPLOYEE', + 'test_DELBY_EMP_DEPT_LOOKUP' + ); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DELBY_EMP_DEPT_LOOKUP + WHERE department_id = 20 + '; + te_employee.delby_emp_dept_lookup ( + 20, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Successful DELBY_EMP_DEPT_LOOKUP', + 'EMPLOYEE', + 'test_DELBY_EMP_DEPT_LOOKUP' + ); + ROLLBACK; + END; + + PROCEDURE test_delby_emp_job_lookup + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DELBY_EMP_JOB_LOOKUP + WHERE job_id = -1 + '; + te_employee.delby_emp_job_lookup ( + -1, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Delete no rows via DELBY_EMP_JOB_LOOKUP', + 'EMPLOYEE', + 'test_DELBY_EMP_JOB_LOOKUP' + ); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DELBY_EMP_JOB_LOOKUP + WHERE job_id = 668 + '; + te_employee.delby_emp_job_lookup ( + 668, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Successful DELBY_EMP_JOB_LOOKUP', + 'EMPLOYEE', + 'test_DELBY_EMP_JOB_LOOKUP' + ); + ROLLBACK; + END; + + PROCEDURE test_delby_emp_mgr_lookup + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DELBY_EMP_MGR_LOOKUP + WHERE manager_id = -1 + '; + te_employee.delby_emp_mgr_lookup ( + -1, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Delete no rows via DELBY_EMP_MGR_LOOKUP', + 'EMPLOYEE', + 'test_DELBY_EMP_MGR_LOOKUP' + ); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM test_DELBY_EMP_MGR_LOOKUP + WHERE manager_id = 7505 + '; + te_employee.delby_emp_mgr_lookup ( + 7505, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Successful DELBY_EMP_MGR_LOOKUP', + 'EMPLOYEE', + 'test_DELBY_EMP_MGR_LOOKUP' + ); + ROLLBACK; + END; + + PROCEDURE test_ins1 + IS + v_employee_id employee.employee_id%TYPE; + v_last_name employee.last_name%TYPE := 'GEORGE'; + v_first_name employee.first_name%TYPE := 'WASHINGTON'; + v_middle_initial employee.middle_initial%TYPE := 'M'; + v_job_id employee.job_id%TYPE := 688; + v_manager_id employee.manager_id%TYPE := 7505; + v_hire_date employee.hire_date%TYPE := SYSDATE; + v_salary employee.salary%TYPE := 1000; + v_commission employee.commission%TYPE := 3000; + v_department_id employee.department_id%TYPE := 30; + v_changed_by employee.changed_by%TYPE := USER; + v_changed_on employee.changed_on%TYPE := SYSDATE; + fdbk PLS_INTEGER; + BEGIN + EXECUTE IMMEDIATE ' + INSERT INTO test_INS1 ( + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON, + CREATED_BY, + CREATED_ON + ) + VALUES ( + employee_id_seq.NEXTVAL, + :LAST_NAME, + :FIRST_NAME, + :MIDDLE_INITIAL, + :JOB_ID, + :MANAGER_ID, + :HIRE_DATE, + :SALARY, + :COMMISSION, + :DEPARTMENT_ID, + :CHANGED_BY, + :CHANGED_ON, + USER, + SYSDATE + ) + ' + USING v_last_name, v_first_name, v_middle_initial, v_job_id, v_manager_id, v_hire_date, v_salary, v_commission, v_department_id, v_changed_by, v_changed_on; + SELECT employee_id_seq.nextval + INTO fdbk + FROM dual; + te_employee.ins ( + v_last_name, + v_first_name, + v_middle_initial, + v_job_id, + v_manager_id, + v_hire_date, + v_salary, + v_commission, + v_department_id, + v_changed_by, + v_changed_on, + fdbk + ); + + -- Test results (everything but ID) + utassert.eqquery ( + 'Insert One Row - check data', + 'SELECT + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON from employee where changed_on = ''' || + SYSDATE || + '''', + 'SELECT + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON from test_ins1 where changed_on = ''' || + SYSDATE || + '''' + ); + utassert.eqtabcount ( + 'Insert One Row - check count', + 'employee', + 'test_ins1' + ); + ROLLBACK; + END; + + PROCEDURE test_upd1 + IS + v_employee_id employee.employee_id%TYPE; + v_last_name employee.last_name%TYPE; + v_first_name employee.first_name%TYPE; + v_middle_initial employee.middle_initial%TYPE; + v_job_id employee.job_id%TYPE; + v_manager_id employee.manager_id%TYPE; + v_hire_date employee.hire_date%TYPE; + v_salary employee.salary%TYPE; + v_commission employee.commission%TYPE; + v_department_id employee.department_id%TYPE; + v_changed_by employee.changed_by%TYPE; + v_changed_on employee.changed_on%TYPE; + fdbk PLS_INTEGER; + BEGIN + /* Update 3 columns by ID */ + + EXECUTE IMMEDIATE ' + UPDATE test_UPD1 SET + FIRST_NAME = ''SILLY'', + HIRE_DATE = trunc (SYSDATE+100), + COMMISSION = 5000 + WHERE + EMPLOYEE_ID = 7600 + '; + te_employee.upd ( + 7600, + first_name_in => 'SILLY', + commission_in => 5000, + hire_date_in => TRUNC (SYSDATE + 100), + rowcount_out => fdbk + ); + -- Test results (audit fields are different so do a query) + utassert.eqquery ( + 'Update three columns', + 'select first_name, commission, hire_date from EMPLOYEE', + 'select first_name, commission, hire_date from test_upd1' + ); + ROLLBACK; + END; + + PROCEDURE test_upd$hire_date1 + IS + fdbk PLS_INTEGER; + BEGIN + /* Successful update by ID */ + + EXECUTE IMMEDIATE ' + UPDATE test_UPD$HIRE_DATE1 SET + hire_date = trunc (sysdate) + WHERE employee_id = 7698 + '; + te_employee.upd$hire_date ( + 7698, + TRUNC (SYSDATE), + rowcount_out => fdbk + ); + -- Test results + utassert.eqquery ( + 'Testing UPD$HIRE_DATE1', + 'select hire_date from EMPLOYEE', + 'select hire_date from test_UPD$HIRE_DATE1' + ); + ROLLBACK; + END; + + PROCEDURE test_upd$salary1 + IS + fdbk PLS_INTEGER; + BEGIN + /* Successful update by ID */ + + EXECUTE IMMEDIATE ' + UPDATE test_UPD$SALARY1 SET + salary = 5000 + WHERE employee_id = 7555 + '; + te_employee.upd$salary ( + 7555, + 5000, + rowcount_out => fdbk + ); + -- Test results + utassert.eqquery ( + 'Testing UPD$SALARY1', + 'select salary from EMPLOYEE', + 'select salary from test_UPD$SALARY1' + ); + ROLLBACK; + END; + + PROCEDURE test_emp_dept_lookuprowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE department_id = 30; + -- Compare to program call: + g_rowcount2 := + te_employee.emp_dept_lookuprowcount (30); + -- Test results + utassert.eq ( + 'Successful EMP_DEPT_LOOKUPROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_EMP_DEPT_LOOKUPROWCOUNT exception ' || + SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_emp_job_lookuprowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE job_id = 669; + -- Compare to program call: + g_rowcount2 := + te_employee.emp_job_lookuprowcount (669); + -- Test results + utassert.eq ( + 'Successful EMP_JOB_LOOKUPROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_EMP_JOB_LOOKUPROWCOUNT exception ' || + SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_emp_mgr_lookuprowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE manager_id = 7782; + -- Compare to program call: + g_rowcount2 := + te_employee.emp_mgr_lookuprowcount (7782); + -- Test results + utassert.eq ( + 'Successful EMP_MGR_LOOKUPROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_EMP_MGR_LOOKUPROWCOUNT exception ' || + SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_hire_date$val + IS + BEGIN + -- Test results + utassert.eqquery ( + 'Successful HIRE_DATE$VAL', + 'select te_employee.HIRE_DATE$VAL (employee_id) from employee', + 'select hire_Date from employee' + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_HIRE_DATE$VAL exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_i_employee_name$row + IS + rec1 te_employee.allcols_rt; + rec2 te_employee.allcols_rt; + BEGIN + -- Unsuccessful test + BEGIN + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE last_name = 'LANCE' + AND first_name = 'GREG' + AND middle_initial = 'J'; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Run program + begin + rec2 := + te_employee.i_employee_name$row ('LANCE', 'GREG', 'J'); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Test results + utassert.this ( + 'Unsuccessful I_EMPLOYEE_NAME$ROW', + te_employee.recseq (rec1, rec2) + ); + -- Successful test + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE last_name = 'LANCE' + AND first_name = 'GREGORY' + AND middle_initial = 'J'; + -- Run program + rec2 := + te_employee.i_employee_name$row ( + 'LANCE', + 'GREGORY', + 'J' + ); + -- Test results + utassert.this ( + 'Successful I_EMPLOYEE_NAME$ROW', + te_employee.recseq (rec1, rec2) + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_I_EMPLOYEE_NAME$ROW exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_i_employee_name$val + IS + rec1 te_employee.i_employee_name_rt; + rec2 te_employee.i_employee_name_rt; + BEGIN + -- Unsuccessful test + BEGIN + SELECT last_name, first_name, middle_initial + INTO rec1 + FROM employee + WHERE employee_id = -1; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Run program + begin + rec2 := te_employee.i_employee_name$val (-1); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + -- Test results + utassert.this ( + 'Unsuccessful I_EMPLOYEE_NAME$VAL', + recseq (rec1, rec2) + ); + -- Successful test + SELECT last_name, first_name, middle_initial + INTO rec1 + FROM employee + WHERE employee_id = 7839; + -- Run program + rec2 := te_employee.i_employee_name$val (7839); + -- Test results + utassert.this ( + 'Successful I_EMPLOYEE_NAME$VAL', + recseq (rec1, rec2) + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_I_EMPLOYEE_NAME$VAL exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_onerow + IS + rec1 te_employee.allcols_rt; + rec2 te_employee.allcols_rt; + BEGIN + -- Unsuccessful test + BEGIN + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE employee_id = -1; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Run program + begin + rec2 := te_employee.onerow (-1); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + -- Test results + utassert.this ( + 'Unsuccessful onerow', + te_employee.recseq (rec1, rec2) + ); + -- Successful test + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE employee_id = 7839; + -- Run program + rec2 := te_employee.onerow (7839); + -- Test results + utassert.this ( + 'Successful onerow', + te_employee.recseq (rec1, rec2) + ); + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_ONEROW exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_pkyrowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE employee_id = 7782; + -- Compare to program call: + g_rowcount2 := te_employee.pkyrowcount (7782); + -- Test results + utassert.eq ( + 'Successful PKYROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_PKYROWCOUNT exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_rowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee; + -- Compare to program call: + g_rowcount2 := te_employee.rowcount; + -- Test results + utassert.eq ( + 'Successful ROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_ROWCOUNT exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE test_salary$val + IS + BEGIN + -- Test results + utassert.eqquery ( + 'Successful SALARY$VAL', + 'select te_employee.SALARY$VAL (employee_id) from employee', + 'select salary from employee' + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE test_. + utassert.this ( + 'test_SALARY$VAL exception ' || SQLERRM, + SQLCODE = 0 + ); + END; +END test_te_employee; +/ diff --git a/examples/test_te_employee.pks b/examples/test_te_employee.pks new file mode 100644 index 000000000..738a1f64c --- /dev/null +++ b/examples/test_te_employee.pks @@ -0,0 +1,28 @@ +create or replace package test_TE_EMPLOYEE +IS + PROCEDURE test_setup; + + PROCEDURE test_teardown; + + PROCEDURE test_DEL1; + PROCEDURE test_DELBY_EMP_DEPT_LOOKUP; + PROCEDURE test_DELBY_EMP_JOB_LOOKUP; + PROCEDURE test_DELBY_EMP_MGR_LOOKUP; + PROCEDURE test_INS1; + PROCEDURE test_UPD1; + PROCEDURE test_UPD$HIRE_DATE1; + PROCEDURE test_UPD$SALARY1; + + PROCEDURE test_EMP_DEPT_LOOKUPROWCOUNT; + PROCEDURE test_EMP_JOB_LOOKUPROWCOUNT; + PROCEDURE test_EMP_MGR_LOOKUPROWCOUNT; + PROCEDURE test_HIRE_DATE$VAL; + PROCEDURE test_I_EMPLOYEE_NAME$ROW; + PROCEDURE test_I_EMPLOYEE_NAME$VAL; + PROCEDURE test_ONEROW; + PROCEDURE test_PKYROWCOUNT; + PROCEDURE test_ROWCOUNT; + PROCEDURE test_SALARY$VAL; + +END test_TE_EMPLOYEE; +/ diff --git a/examples/truncit.sp b/examples/truncit.sp new file mode 100644 index 000000000..854bbd328 --- /dev/null +++ b/examples/truncit.sp @@ -0,0 +1,9 @@ +CREATE OR REPLACE PROCEDURE truncit ( + tab IN VARCHAR2, + sch IN VARCHAR2 := NULL +) +IS +BEGIN + EXECUTE IMMEDIATE 'truncate table ' || NVL (sch, USER) || '.' || tab; +END; +/ \ No newline at end of file diff --git a/examples/ut_betwnstr.pkb b/examples/ut_betwnstr.pkb new file mode 100644 index 000000000..4362e155c --- /dev/null +++ b/examples/ut_betwnstr.pkb @@ -0,0 +1,122 @@ +CREATE OR REPLACE PACKAGE BODY ut_betwnstr +IS + PROCEDURE ut_setup + IS + BEGIN + DBMS_OUTPUT.PUT_LINE ('Ran setup'); + END; + + PROCEDURE ut_teardown + IS + BEGIN + DBMS_OUTPUT.PUT_LINE ('Ran teardown'); + END; + + PROCEDURE ut_BETWNSTR + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "normal" + against_this := 'cde'; + + -- Execute test code for "normal" + check_this := + BETWNSTR ( + STRING_IN => 'abcdefgh' + , + START_IN => 3 + , + END_IN => 5 + ); + + -- Assert success for "normal" by comparing the two values. + utAssert.eq ( + 'normal', + check_this, + against_this + ); + + -- End of test for "normal" + + -- Define "control" operation for "zero start" + + against_this := 'abc'; + + -- Execute test code for "zero start" + + check_this := + BETWNSTR ( + STRING_IN => 'abcdefgh' + , + START_IN => 0 + , + END_IN => 2 + ); + + -- Assert success for "zero start" + + -- Compare the two values. + utAssert.eq ( + 'zero start', + check_this, + against_this + ); + + -- End of test for "zero start" + + -- Define "control" operation for "null start" + + against_this := NULL; + + -- Execute test code for "null start" + + check_this := + BETWNSTR ( + STRING_IN => 'abcdefgh' + , + START_IN => null + , + END_IN => 2 + ); + + -- Assert success for "null start" + + -- Check for NULL return value. + utAssert.isNULL ( + 'null start', + check_this + ); + + -- End of test for "null start" + + -- Define "control" operation for "null end" + + against_this := NULL; + + -- Execute test code for "null end" + + check_this := + BETWNSTR ( + STRING_IN => 'abcdefgh' + , + START_IN => 3 + , + END_IN => null + ); + + -- Assert success for "null end" + + -- Check for NULL return value. + utAssert.isNULL ( + 'null end', + check_this + ); + + -- End of test for "null end" + END ut_BETWNSTR; + +END ut_betwnstr; +/ diff --git a/examples/ut_betwnstr.pks b/examples/ut_betwnstr.pks new file mode 100644 index 000000000..f40ca5f6b --- /dev/null +++ b/examples/ut_betwnstr.pks @@ -0,0 +1,9 @@ +CREATE OR REPLACE PACKAGE ut_betwnstr +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWNSTR; +END ut_betwnstr; +/ diff --git a/examples/ut_betwnstr_failures.pkb b/examples/ut_betwnstr_failures.pkb new file mode 100644 index 000000000..43836f285 --- /dev/null +++ b/examples/ut_betwnstr_failures.pkb @@ -0,0 +1,79 @@ +CREATE OR REPLACE PACKAGE BODY ut_betwnstr +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_BETWNSTR IS + BEGIN + utAssert.eq ( + 'Typical valid usage', + BETWNSTR( + STRING_IN => 'abcdefg' + , + START_IN => 3 + , + END_IN => 4 + ), + 'cde' + ); + + utAssert.isnull ( + 'NULL start', + BETWNSTR( + STRING_IN => 'abcdefg' + , + START_IN => 1 + , + END_IN => 5 + ) + ); + + + utAssert.isnull ( + 'NULL end', + BETWNSTR( + STRING_IN => 'abcdefg' + , + START_IN => 2 + , + END_IN => NULL + ) + ); + + utAssert.isnull ( + 'End smaller than start', + BETWNSTR( + STRING_IN => 'abcdefg' + , + START_IN => 5 + , + END_IN => 5 + ) + ); + + utAssert.eq ( + 'End larger than string length', + BETWNSTR( + STRING_IN => 'abcdefg' + , + START_IN => 3 + , + END_IN => 200 + ), + 'cdefg' + ); + + END ut_BETWNSTR; + +END ut_betwnstr; +/ diff --git a/examples/ut_betwnstr_gen.pkg b/examples/ut_betwnstr_gen.pkg new file mode 100644 index 000000000..d9855b047 --- /dev/null +++ b/examples/ut_betwnstr_gen.pkg @@ -0,0 +1,137 @@ +CREATE OR REPLACE PACKAGE ut_betwnstr +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWNSTR; +END ut_betwnstr; +/ +CREATE OR REPLACE PACKAGE BODY ut_betwnstr +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + -- For each program to test... + PROCEDURE ut_BETWNSTR + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "BETWNSTR" + + against_this := 'bcde'; + + -- Execute test code for "BETWNSTR" + + check_this := + BETWNSTR ( + STRING_IN => 'abcdefg' + , + START_IN => 2 + , + END_IN => 5 + ); + + -- Assert success for "BETWNSTR" + + -- Compare the two values. + utAssert.eq ( + 'Typical valid usage', + check_this, + against_this + ); + + -- End of test for "BETWNSTR" + + -- Define "control" operation for "BETWNSTR" + + against_this := 'abcde'; + + -- Execute test code for "BETWNSTR" + + check_this := + BETWNSTR ( + STRING_IN => 'abcdefg' + , + START_IN => 0 + , + END_IN => 5 + ); + + -- Assert success for "BETWNSTR" + + -- Compare the two values. + utAssert.eq ( + 'Zero start value', + check_this, + against_this + ); + + -- End of test for "BETWNSTR" + + -- Define "control" operation for "BETWNSTR" + + against_this := 'efg'; + + -- Execute test code for "BETWNSTR" + + check_this := + BETWNSTR ( + STRING_IN => 'abcdefg' + , + START_IN => 5 + , + END_IN => 500 + ); + + -- Assert success for "BETWNSTR" + + -- Compare the two values. + utAssert.eq ( + 'Way big end value', + check_this, + against_this + ); + + -- End of test for "BETWNSTR" + + -- Define "control" operation for "BETWNSTR" + + against_this := NULL; + + -- Execute test code for "BETWNSTR" + + check_this := + BETWNSTR ( + STRING_IN => NULL + , + START_IN => 5 + , + END_IN => 500 + ); + + -- Assert success for "BETWNSTR" + + -- Compare the two values. + utAssert.eq ( + 'NULL start value', + check_this, + against_this + ); + + -- End of test for "BETWNSTR" + END ut_BETWNSTR; + +END ut_betwnstr; +/ diff --git a/examples/ut_bstr.pkb b/examples/ut_bstr.pkb new file mode 100644 index 000000000..cc9077d4c --- /dev/null +++ b/examples/ut_bstr.pkb @@ -0,0 +1,47 @@ +CREATE OR REPLACE PACKAGE BODY ut_bstr +IS + PROCEDURE ut_setup + IS + BEGIN + DBMS_OUTPUT.PUT_LINE ('Ran bstr setup'); + END; + + PROCEDURE ut_teardown + IS + BEGIN + DBMS_OUTPUT.PUT_LINE ('Ran bstr teardown'); + END; + + PROCEDURE ut_BETWNSTR + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "normal" + against_this := 'cde'; + + -- Execute test code for "normal" + check_this := + BETWNSTR ( + STRING_IN => 'abcdefgh' + , + START_IN => 3 + , + END_IN => 5 + ); + + -- Assert success for "normal" by comparing the two values. + utAssert.eq ( + 'normal', + check_this, + against_this + ); + + -- End of test for "normal" + + END ut_BETWNSTR; + +END ut_bstr; +/ diff --git a/examples/ut_bstr.pks b/examples/ut_bstr.pks new file mode 100644 index 000000000..e164470df --- /dev/null +++ b/examples/ut_bstr.pks @@ -0,0 +1,9 @@ +CREATE OR REPLACE PACKAGE ut_bstr +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWNSTR; +END ut_bstr; +/ diff --git a/examples/ut_calc_secs_between.pkb b/examples/ut_calc_secs_between.pkb new file mode 100644 index 000000000..1c15541a5 --- /dev/null +++ b/examples/ut_calc_secs_between.pkb @@ -0,0 +1,51 @@ +CREATE OR REPLACE PACKAGE BODY ut_calc_secs_between +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_CALC_SECS_BETWEEN + IS + secs PLS_INTEGER; + BEGIN + CALC_SECS_BETWEEN ( + DATE1 => SYSDATE + , + DATE2 => SYSDATE + , + SECS => secs + ); + + utAssert.eq ( + 'Same dates', + secs, + 0 + ); + + CALC_SECS_BETWEEN ( + DATE1 => SYSDATE + , + DATE2 => SYSDATE+1 + , + SECS => secs + ); + + utAssert.eq ( + 'Exactly one day', + secs, + 24 * 60 * 60 + ); + + END ut_CALC_SECS_BETWEEN; + +END ut_calc_secs_between; +/ diff --git a/examples/ut_calc_secs_between.pks b/examples/ut_calc_secs_between.pks new file mode 100644 index 000000000..8d9c7f217 --- /dev/null +++ b/examples/ut_calc_secs_between.pks @@ -0,0 +1,9 @@ +CREATE OR REPLACE PACKAGE ut_calc_secs_between +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_CALC_SECS_BETWEEN; +END ut_calc_secs_between; +/ diff --git a/examples/ut_department2file.pkg b/examples/ut_department2file.pkg new file mode 100644 index 000000000..458ecc0ba --- /dev/null +++ b/examples/ut_department2file.pkg @@ -0,0 +1,45 @@ +CREATE OR REPLACE PACKAGE ut_DEPARTMENT2file +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_DEPARTMENT2FILE; +END ut_DEPARTMENT2file; +/ +CREATE OR REPLACE PACKAGE BODY ut_DEPARTMENT2file +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_DEPARTMENT2FILE IS + BEGIN + DEPARTMENT2FILE ( + LOC => 'c:\temp' + , + FILE => 'department2file.dat' + , + DELIM => '***' + ); + + utAssert.eqfile ( + 'Test of DEPARTMENT2FILE', + 'department2file.dat', + 'c:\temp', + 'department2file.tst', + 'c:\temp' + ); + END ut_DEPARTMENT2FILE; + +END ut_DEPARTMENT2file; +/ \ No newline at end of file diff --git a/examples/ut_mybooks_pkg.sql b/examples/ut_mybooks_pkg.sql new file mode 100644 index 000000000..6f13f4f13 --- /dev/null +++ b/examples/ut_mybooks_pkg.sql @@ -0,0 +1,337 @@ +/* Formatted on 2002/08/10 09:24 (Formatter Plus v4.7.0) */ +/**************************************************************************************** + + Author : Venky Mangapillai + Created : Mar'2002 + Description : Example test pcakage to test MYBOOKS_PKG package using UTPLSQL + Prerequests : Run the mybooks_setup.sql + +****************************************************************************************/ + + +/* --------------------------------------------------------------------------------- + This is the test package for the MYBOOKS_PKG package. + The test package name should be prefix with "ut_" before the real package name" + e.g "UT_MYBOOKS_PKG" is test package for "MYBOOKS_PKG" + + Here we are going to test the each procedure/function in MYBOOKS_PKG. + MYBOOKS_PKG package contains the following methods + + FUNCTION sel_book_func(bookid number) return mybooks_rec; + PROCEDURE sel_book_proc(bookid number, rc OUT mybooks_rec); + FUNCTION sel_booknm(bookid number) return varchar2; + PROCEDURE ins(bookid number, booknm varchar2,publishdt date); + PROCEDURE upd(bookid number, booknm varchar2,publishdt date); + PROCEDURE del(bookid number); + + Now we are going to test every function/procedure in MYBOOKS_PKG. Before that let's remember, + all the test procedure should start with "ut_" also. But need not end with with function/procedure name. + e.g you can name the test procedure as "ut_sel_book_func" or "ut_something" for procedure "sel_book_func". + But it is good practice to have the procedure name as test procedure. + Function/procedure can have many test procedures. e.g ut_sel_book_func can have two test procedures like + ut_sel_book_func_1 and ut_sel_book_func_2. + Basically the UTPLSQL tool take all the function/procedures in test packages and run one by one starting + with "ut_setup" and ending with "ut_teardown" in the alphabetical order. + + So the test procedures are + + PROCEDURE ut_2_sel_book_func; + PROCEDURE ut_3_sel_book_proc; + PROCEDURE ut_4_sel_booknm; + PROCEDURE ut_1_ins + PROCEDURE ut_5_upd + PROCEDURE ut_6_del + plus + PROCEDURE ut_setup -- to setup the test data. + PROCEDURE ut_teardown -- to clean up the test data. + + Here I used nunber 1,2,3.. after the "ut_". This is because I wanted the INS function to go first + before the DEL function. Otherwise DEL will get tested first and it will end up FAILURE. + This is one way to force the order of test procedure executions. If you are not + worried about the order you don't have to follow this. One more reason I needed here is because + I am using the same test record. Some tester use different test records for diffrent test procedures. + In that case you don't have to worry about the order. I did't the numbering for the ut_setup and ut_teardown + because ut_setup always gets executed first and ut_teardown always get executed last. Even if the test case fails + ut_teardown gets executed. + + Using these test procedures I will show how most of the assertion methods getting used. + Sounds interesting. Isn't it? + So lets get started writing the test package. + +--------------------------------------------------------------------------------------*/ + +-- As I mentioned earlier the test package whoud be prefixed with "ut_". + +CREATE OR REPLACE PACKAGE ut_mybooks_pkg +IS + -- Also the test procedures in the test package + PROCEDURE ut_setup; + + PROCEDURE ut_teardown; + + PROCEDURE ut_2_sel_book_func; + + PROCEDURE ut_3_sel_book_proc; + + PROCEDURE ut_4_sel_booknm; + + PROCEDURE ut_1_ins; + + PROCEDURE ut_5_upd; + + PROCEDURE ut_6_del; +END; +/ + +CREATE OR REPLACE PACKAGE BODY ut_mybooks_pkg +IS -- package body + +-- Here is my test record. + + bookid INTEGER := 100; + booknm VARCHAR2 (30) := 'American History-Vol1'; + publishdt DATE := '05-JAN-2002'; + +/* -------------------------------------------------- + UT_SETUP : setup the test data here. This is first + procedure gets executed automatically +----------------------------------------------------- */ + PROCEDURE ut_setup + IS + BEGIN + ut_teardown; -- drop the temp tables even though it should be there. Just extract caution + + -- "mybooks_part" table contains test record which we are going to test. + -- I am using 8i syntax. Change needed for 8.0 databases + EXECUTE IMMEDIATE 'create table mybooks_part as select * from mybooks where rownum < 1'; + EXECUTE IMMEDIATE 'insert into mybooks_part values (:bookid,:booknm,:publishdt)' + USING bookid, booknm, publishdt; + END; + +/* -------------------------------------------------- + UT_TEARDOWN : clean you data here. This is the last + procedure gets executed automatically +----------------------------------------------------- */ + PROCEDURE ut_teardown + IS + BEGIN + EXECUTE IMMEDIATE 'drop table mybooks_part'; -- Drop the temporary test table after the test + + DELETE FROM mybooks + WHERE book_id = bookid; --Delete the test record after the test + EXCEPTION + WHEN OTHERS + THEN + NULL; -- Ignore if any errors. + END; + +/* --------------------------------------------------------------------- + FUNCTION mybooks_pkg.sel_book_func( + bookid IN NUMBER, + RETURN REFCURSOR + + Assertion methods used : EQ_REFC_TABLE, EQ_REFC_QUERY +/* -------------------------------------------------------------------- */ + PROCEDURE ut_2_sel_book_func + IS + proc_params utplsql_util.utplsql_params; + BEGIN + -- Register the parameters + -- IMPORTANT: The position starts with 0 for functions. For procedures it starts with 1 + utplsql_util.reg_out_param (0, 'REFCURSOR', proc_params); + utplsql_util.reg_in_param (1, 100, proc_params); + -- Test the sel_book_func function. It compares the refcursor with mybooks_part table. + -- Here we expect the refcursor should return the records for the bookid=1. mybooks_part table + -- has bookid=1 record in it which we setup in the ut_setup procedure. + -- If rows matched then it results in SUCCESS otherwise FAILURE. + -- If SUCCESS then sel_book_func fuction behaves as we expected. + + utassert.eq_refc_table ( + 'sel_book_func-1', + 'mybooks_pkg.sel_book_func', + proc_params, + 0, + 'mybooks_part' + ); + -- Other ways to test this + utassert.eq_refc_query ( + 'sel_book_func-2', + 'mybooks_pkg.sel_book_func', + proc_params, + 0, + 'select * from mybooks_part' + ); + END; + +/* --------------------------------------------------------------------- + PROCEDURE mybooks_pkg.sel_book_proc( + bookid IN NUMBER, + mybooks_rec OUT REFCURSOR) + + Assertion methods used : EQ_REFC_TABLE, EQ_REFC_QUERY +/* -------------------------------------------------------------------- */ + PROCEDURE ut_3_sel_book_proc + IS + proc_params utplsql_util.utplsql_params; + BEGIN + -- This procedure I used this because I want to show how to handle the refcursor as OUT parameter + -- Register the parameters + -- IMPORTANT: The position starts with 0 for functions. For procedures it starts with 1 + utplsql_util.reg_in_param (1, 100, proc_params); + utplsql_util.reg_out_param (2, 'REFCURSOR', proc_params); + utassert.eq_refc_table ( + 'sel_book_proc-1', + 'mybooks_pkg.sel_book_proc', + proc_params, + 2, + 'mybooks_part' + ); + -- Other ways to test this + utassert.eq_refc_query ( + 'sel_book_proc-2', + 'mybooks_pkg.sel_book_proc', + proc_params, + 2, + 'select * from mybooks_part' + ); + END; + +/* -------------------------------------------------- + EQ : FUNCTION sel_booknm ( + bookid IN NUMBER, + ) RETRUN VARCHAR2 + + Assertion methods used : EQ +----------------------------------------------------- */ + PROCEDURE ut_4_sel_booknm + IS + BEGIN + -- We expect "American History-Vol1 " from the sel_booknm(100) function. + utassert.eq ('sel_booknm-1', booknm, mybooks_pkg.sel_booknm (bookid)); -- Success + END; + +/* -------------------------------------------------- + PROCEDURE ins ( + bookid IN NUMBER, + booknm IN VARCHAR2, + publishdt DATE + ) + + Assertion methods used : EQ , EQTABCOUNT, EQQUERYVALUE, EQQUERY, THROWS +----------------------------------------------------- */ + PROCEDURE ut_1_ins + IS + BEGIN + -- Call the INS function. + mybooks_pkg.ins (bookid, booknm, publishdt); + -- Check if the row inserted successfully + utassert.eq ('ins-1-4', booknm, mybooks_pkg.sel_booknm (bookid)); + --Other ways to check row inserted successfully and many more ways + utassert.eqqueryvalue ( + 'ins-2', + 'select count(*) from mybooks where book_id=' || TO_CHAR (bookid), + 1 + ); + utassert.eqqueryvalue ( + 'ins-3', + 'select book_nm from mybooks where book_id=' || bookid, + booknm + ); + utassert.eqquery ( + 'ins-4', + 'select * from mybooks where book_id=' || bookid, + 'select * from mybooks_part' + ); + -- Lets try the THROWS assertion method here. + -- If I insert the same bookid again I should get PRIMARY KEY violation error (ERRORCODE=-1 in oracle) + -- Here is the I am looking for "-1". If I get "-1" then SUCCESS otherwise FAIL + utassert.throws ( + 'ins-5', + 'mybooks_pkg.ins(' || bookid || ',''Something'',sysdate)', + -1 + ); + END; + +/* -------------------------------------------------- + PROCEDURE upd ( + bookid IN NUMBER, + booknm IN VARCHAR2, + publishdt DATE + ) + + Assertion methods used : EQ +----------------------------------------------------- */ + PROCEDURE ut_5_upd + IS + BEGIN + booknm := 'American History-Vol2'; -- new values + publishdt := '06-JAN-2002'; + -- Call the INS function. + mybooks_pkg.upd (bookid, booknm, publishdt); + -- Check if the row inserted successfully + utassert.eq ('ut_upd-1', booknm, mybooks_pkg.sel_booknm (bookid)); + END; + +/* -------------------------------------------------- + PROCEDURE del ( + bookid IN NUMBER + ) + + Assertion methods used : EQQUERY, THROWS +----------------------------------------------------- */ + PROCEDURE ut_6_del + IS + ret_val VARCHAR2 (30); + BEGIN + -- Call the DEL function. + DBMS_OUTPUT.put_line ('Id=' || TO_CHAR (bookid)); + mybooks_pkg.del (bookid); + -- Check if the row deleted successfully + utassert.eqqueryvalue ( + 'ut_del-1', + 'select count(*) from mybooks where book_id=100', + 0 + ); + + -- Other ways to test + --utassert.throws('ut_del-2','v_dummy := mybooks_pkg.sel_booknm(100)',100); -- 100 is "NO DATA FOUND" + + -- here is another way + BEGIN + ret_val := mybooks_pkg.sel_booknm (100); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + WHEN OTHERS + THEN + utassert.eq ('ut_del-3', 1, 2); -- Forced to fail 1<>2 + END; + END; +END; + + -- End of test package +/ +CREATE PUBLIC SYNONYM ut_mybooks_pkg for ut_mybooks_pkg +/ +GRANT execute on ut_mybooks_pkg to public +/ +show errors +/* -------------------------------------------------------------------------- + This is how you will run the test packages +-----------------------------------------------------------------------------*/ +set SERVEROUTPUT ON size 1000000 +REM exec utplsql.notrc +spool trc + +BEGIN + utplsql.test ('MYBOOKS_PKG'); + DBMS_OUTPUT.put_line (utplsql2.runnum); +END; +/ + +REM spool off + +/* --------------------------------------------------------------------------- + Now we are done and have wonderfull unit testing using UTPLSQL +-----------------------------------------------------------------------------*/ diff --git a/examples/ut_plvdate.pkb b/examples/ut_plvdate.pkb new file mode 100644 index 000000000..abd42ef3b --- /dev/null +++ b/examples/ut_plvdate.pkb @@ -0,0 +1,38 @@ +create or replace package BODY ut_plvdate +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + PROCEDURE ut_to_date + IS + str VARCHAR2 (2000) := '1/1/1'; + BEGIN + utassert.eq ( + 'DD-MON-YYYY Conversion', + STANDARD.TO_CHAR (PLVdate.to_date (str), 'DD-MON-YYYY'), + '01-JAN-2001' + ); + END; + + PROCEDURE ut_to_char + IS + dt DATE := SYSDATE; + BEGIN + utassert.eq ( + 'MMDDYYYY conversion', + PLVdate.to_char (SYSDATE, 'MMDDYYYY'), + STANDARD.TO_CHAR (SYSDATE, 'MMDDYYYY') + ); + END; + +END ut_plvdate; +/ diff --git a/examples/ut_plvdate.pks b/examples/ut_plvdate.pks new file mode 100644 index 000000000..83e362c5b --- /dev/null +++ b/examples/ut_plvdate.pks @@ -0,0 +1,12 @@ +create or replace package ut_PLVdate +IS + PROCEDURE ut_setup; + + PROCEDURE ut_teardown; + + PROCEDURE ut_to_date; + + PROCEDURE ut_to_char; + +END ut_PLVdate; +/ diff --git a/examples/ut_plvstr.pkb b/examples/ut_plvstr.pkb new file mode 100644 index 000000000..817b29d9d --- /dev/null +++ b/examples/ut_plvstr.pkb @@ -0,0 +1,134 @@ +CREATE OR REPLACE PACKAGE BODY ut_plvstr +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + -- For each program to test... + PROCEDURE ut_BETWN1 + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "normal" + + against_this := 'cde'; + + -- Execute test code for "normal" + + check_this := + PLVSTR.BETWN ( + STRING_IN => 'abcdefgh' + , + START_IN => 3 + , + END_IN => 5 + , + INCLUSIVE => TRUE + ); + + -- Assert success for "normal" + + -- Compare the two values. + utAssert.eq ( + 'normal', + check_this, + against_this + ); + + -- End of test for "normal" + + -- Define "control" operation for "zero start" + + against_this := 'abc'; + + -- Execute test code for "zero start" + + check_this := + PLVSTR.BETWN ( + STRING_IN => 'abcdefgh' + , + START_IN => 0 + , + END_IN => 2 + , + INCLUSIVE => TRUE + ); + + -- Assert success for "zero start" + + -- Compare the two values. + utAssert.eq ( + 'zero start', + check_this, + against_this + ); + + -- End of test for "zero start" + + -- Define "control" operation for "null start" + + against_this := NULL; + + -- Execute test code for "null start" + + check_this := + PLVSTR.BETWN ( + STRING_IN => 'abcdefgh' + , + START_IN => null + , + END_IN => 2 + , + INCLUSIVE => TRUE + ); + + -- Assert success for "null start" + + -- Check for NULL return value. + utAssert.isNULL ( + 'null start', + check_this + ); + + -- End of test for "null start" + + -- Define "control" operation for "null end" + + against_this := NULL; + + -- Execute test code for "null end" + + check_this := + PLVSTR.BETWN ( + STRING_IN => 'abcdefgh' + , + START_IN => 3 + , + END_IN => null + , + INCLUSIVE => TRUE + ); + + -- Assert success for "null end" + + -- Check for NULL return value. + utAssert.isNULL ( + 'null end', + check_this + ); + + -- End of test for "null end" + END ut_BETWN1; + +END ut_plvstr; +/ diff --git a/examples/ut_plvstr.pks b/examples/ut_plvstr.pks new file mode 100644 index 000000000..a735c36b4 --- /dev/null +++ b/examples/ut_plvstr.pks @@ -0,0 +1,9 @@ +CREATE OR REPLACE PACKAGE ut_plvstr +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWN1; +END ut_plvstr; +/ diff --git a/examples/ut_str.pkb b/examples/ut_str.pkb new file mode 100644 index 000000000..c5b6dfd0d --- /dev/null +++ b/examples/ut_str.pkb @@ -0,0 +1,54 @@ +CREATE OR REPLACE PACKAGE BODY ut_str +IS + PROCEDURE ut_setup + IS + BEGIN + DBMS_OUTPUT.PUT_LINE ('Ran setup'); + END; + + PROCEDURE ut_teardown + IS + BEGIN + DBMS_OUTPUT.PUT_LINE ('Ran teardown'); + END; + + -- For each program to test... + PROCEDURE ut_betwn IS + BEGIN + utAssert.eq ( + 'Typical Valid Usage', + str.betwn ('this is a string', 3, 7), + 'is is' + ); + + utAssert.eq ( + 'Null Start', + str.betwn ('this is a string', NULL, 7), + 'ing' + ); + + utAssert.isNULL ( + 'Start bigger than end', + str.betwn ('this is a string', 3, 1) + ); + + utAssert.eval ( + 'Complex expression', + ':p1 = :p2 or :p1 like :p2', + 'abc', + str.betwn ('abc%efg', 1,4) + ); + END ut_betwn; + + PROCEDURE ut_betwn2 IS + BEGIN + utAssert.eq ( + 'Typical Valid Usage', + str.betwn ('this is a string', -2, -6), + 'strin' + ); + + END ut_betwn2; + +END ut_str; +/ diff --git a/examples/ut_str.pks b/examples/ut_str.pks new file mode 100644 index 000000000..d02a56001 --- /dev/null +++ b/examples/ut_str.pks @@ -0,0 +1,10 @@ +CREATE OR REPLACE PACKAGE ut_str +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_betwn; + PROCEDURE ut_betwn2; +END ut_str; +/ diff --git a/examples/ut_te_employee.pkb b/examples/ut_te_employee.pkb new file mode 100644 index 000000000..6f424f4de --- /dev/null +++ b/examples/ut_te_employee.pkb @@ -0,0 +1,916 @@ +CREATE OR REPLACE PACKAGE BODY ut_te_employee +IS + g_rowcount1 PLS_INTEGER; + g_rowcount2 PLS_INTEGER; + + FUNCTION recseq ( + rec1 IN te_employee.i_employee_name_rt, + rec2 IN te_employee.i_employee_name_rt + ) + RETURN BOOLEAN + IS + unequal_records EXCEPTION; + retval BOOLEAN; + BEGIN + retval := + rec1.last_name = rec2.last_name + OR ( + rec1.last_name IS NULL + AND rec2.last_name IS NULL + ); + + IF NOT NVL (retval, FALSE) + THEN + RAISE unequal_records; + END IF; + + retval := + rec1.first_name = rec2.first_name + OR ( + rec1.first_name IS NULL + AND rec2.first_name IS NULL + ); + + IF NOT NVL (retval, FALSE) + THEN + RAISE unequal_records; + END IF; + + retval := + rec1.middle_initial = rec2.middle_initial + OR ( + rec1.middle_initial IS NULL + AND rec2.middle_initial IS NULL + ); + + IF NOT NVL (retval, FALSE) + THEN + RAISE unequal_records; + END IF; + + RETURN TRUE; + EXCEPTION + WHEN unequal_records + THEN + RETURN FALSE; + END; + + PROCEDURE ut_setup + IS + BEGIN + ut_teardown; + EXECUTE IMMEDIATE 'CREATE TABLE ut_employee AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_DEL1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_DEPT_LOOKUP AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_JOB_LOOKUP AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_DELBY_EMP_MGR_LOOKUP AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_INS1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_UPD1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_UPD$HIRE_DATE1 AS + SELECT * FROM employee'; + EXECUTE IMMEDIATE 'CREATE TABLE ut_UPD$SALARY1 AS + SELECT * FROM employee'; + END; + + PROCEDURE ut_teardown + IS + BEGIN + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_employee'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_DEL1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_DELBY_EMP_DEPT_LOOKUP'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_DELBY_EMP_JOB_LOOKUP'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_DELBY_EMP_MGR_LOOKUP'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_INS1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_UPD1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_UPD$HIRE_DATE1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + BEGIN + EXECUTE IMMEDIATE 'DROP TABLE ut_UPD$SALARY1'; + EXCEPTION + WHEN OTHERS + THEN + NULL; + END; + + END; + + PROCEDURE ut_del1 + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds no rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DEL1 + WHERE employee_id = -1 + '; + te_employee.del (-1, rowcount_out => fdbk); + -- Test results + utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1'); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DEL1 + WHERE employee_id between 7800 and 7899 + '; + + FOR rec IN (SELECT * + FROM employee + WHERE employee_id BETWEEN 7800 AND 7899) + LOOP + te_employee.del ( + rec.employee_id, + rowcount_out => fdbk + ); + END LOOP; + + -- Test results + utassert.eqtable ('Delete rows', 'EMPLOYEE', 'ut_DEL1'); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + utassert.this ( + 'DEL1 exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_delby_emp_dept_lookup + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DELBY_EMP_DEPT_LOOKUP + WHERE department_id = -1 + '; + te_employee.delby_emp_dept_lookup ( + -1, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Delete no rows via DELBY_EMP_DEPT_LOOKUP', + 'EMPLOYEE', + 'ut_DELBY_EMP_DEPT_LOOKUP' + ); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DELBY_EMP_DEPT_LOOKUP + WHERE department_id = 20 + '; + te_employee.delby_emp_dept_lookup ( + 20, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Successful DELBY_EMP_DEPT_LOOKUP', + 'EMPLOYEE', + 'ut_DELBY_EMP_DEPT_LOOKUP' + ); + ROLLBACK; + END; + + PROCEDURE ut_delby_emp_job_lookup + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DELBY_EMP_JOB_LOOKUP + WHERE job_id = -1 + '; + te_employee.delby_emp_job_lookup ( + -1, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Delete no rows via DELBY_EMP_JOB_LOOKUP', + 'EMPLOYEE', + 'ut_DELBY_EMP_JOB_LOOKUP' + ); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DELBY_EMP_JOB_LOOKUP + WHERE job_id = 668 + '; + te_employee.delby_emp_job_lookup ( + 668, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Successful DELBY_EMP_JOB_LOOKUP', + 'EMPLOYEE', + 'ut_DELBY_EMP_JOB_LOOKUP' + ); + ROLLBACK; + END; + + PROCEDURE ut_delby_emp_mgr_lookup + IS + fdbk PLS_INTEGER; + BEGIN + /* Delete that finds now rows. */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DELBY_EMP_MGR_LOOKUP + WHERE manager_id = -1 + '; + te_employee.delby_emp_mgr_lookup ( + -1, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Delete no rows via DELBY_EMP_MGR_LOOKUP', + 'EMPLOYEE', + 'ut_DELBY_EMP_MGR_LOOKUP' + ); + /* Successful delete */ + + EXECUTE IMMEDIATE ' + DELETE FROM ut_DELBY_EMP_MGR_LOOKUP + WHERE manager_id = 7505 + '; + te_employee.delby_emp_mgr_lookup ( + 7505, + rowcount_out => fdbk + ); + -- Test results + utassert.eqtable ( + 'Successful DELBY_EMP_MGR_LOOKUP', + 'EMPLOYEE', + 'ut_DELBY_EMP_MGR_LOOKUP' + ); + ROLLBACK; + END; + + PROCEDURE ut_ins1 + IS + v_employee_id employee.employee_id%TYPE; + v_last_name employee.last_name%TYPE := 'GEORGE'; + v_first_name employee.first_name%TYPE := 'WASHINGTON'; + v_middle_initial employee.middle_initial%TYPE := 'M'; + v_job_id employee.job_id%TYPE := 688; + v_manager_id employee.manager_id%TYPE := 7505; + v_hire_date employee.hire_date%TYPE := SYSDATE; + v_salary employee.salary%TYPE := 1000; + v_commission employee.commission%TYPE := 3000; + v_department_id employee.department_id%TYPE := 30; + v_changed_by employee.changed_by%TYPE := USER; + v_changed_on employee.changed_on%TYPE := SYSDATE; + fdbk PLS_INTEGER; + BEGIN + EXECUTE IMMEDIATE ' + INSERT INTO ut_INS1 ( + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON, + CREATED_BY, + CREATED_ON + ) + VALUES ( + employee_id_seq.NEXTVAL, + :LAST_NAME, + :FIRST_NAME, + :MIDDLE_INITIAL, + :JOB_ID, + :MANAGER_ID, + :HIRE_DATE, + :SALARY, + :COMMISSION, + :DEPARTMENT_ID, + :CHANGED_BY, + :CHANGED_ON, + USER, + SYSDATE + ) + ' + USING v_last_name, v_first_name, v_middle_initial, v_job_id, v_manager_id, v_hire_date, v_salary, v_commission, v_department_id, v_changed_by, v_changed_on; + SELECT employee_id_seq.nextval + INTO fdbk + FROM dual; + te_employee.ins ( + v_last_name, + v_first_name, + v_middle_initial, + v_job_id, + v_manager_id, + v_hire_date, + v_salary, + v_commission, + v_department_id, + v_changed_by, + v_changed_on, + fdbk + ); + + -- Test results (everything but ID) + utassert.eqquery ( + 'Insert One Row - check data', + 'SELECT + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON from employee where changed_on = ''' || + SYSDATE || + '''', + 'SELECT + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON from ut_ins1 where changed_on = ''' || + SYSDATE || + '''' + ); + utassert.eqtabcount ( + 'Insert One Row - check count', + 'employee', + 'ut_ins1' + ); + ROLLBACK; + END; + + PROCEDURE ut_upd1 + IS + v_employee_id employee.employee_id%TYPE; + v_last_name employee.last_name%TYPE; + v_first_name employee.first_name%TYPE; + v_middle_initial employee.middle_initial%TYPE; + v_job_id employee.job_id%TYPE; + v_manager_id employee.manager_id%TYPE; + v_hire_date employee.hire_date%TYPE; + v_salary employee.salary%TYPE; + v_commission employee.commission%TYPE; + v_department_id employee.department_id%TYPE; + v_changed_by employee.changed_by%TYPE; + v_changed_on employee.changed_on%TYPE; + fdbk PLS_INTEGER; + BEGIN + /* Update 3 columns by ID */ + + EXECUTE IMMEDIATE ' + UPDATE ut_UPD1 SET + FIRST_NAME = ''SILLY'', + HIRE_DATE = trunc (SYSDATE+100), + COMMISSION = 5000 + WHERE + EMPLOYEE_ID = 7600 + '; + te_employee.upd ( + 7600, + first_name_in => 'SILLY', + commission_in => 5000, + hire_date_in => TRUNC (SYSDATE + 100), + rowcount_out => fdbk + ); + -- Test results (audit fields are different so do a query) + utassert.eqquery ( + 'Update three columns', + 'select first_name, commission, hire_date from EMPLOYEE', + 'select first_name, commission, hire_date from ut_upd1' + ); + ROLLBACK; + END; + + PROCEDURE ut_upd$hire_date1 + IS + fdbk PLS_INTEGER; + BEGIN + /* Successful update by ID */ + + EXECUTE IMMEDIATE ' + UPDATE ut_UPD$HIRE_DATE1 SET + hire_date = trunc (sysdate) + WHERE employee_id = 7698 + '; + te_employee.upd$hire_date ( + 7698, + TRUNC (SYSDATE), + rowcount_out => fdbk + ); + -- Test results + utassert.eqquery ( + 'Testing UPD$HIRE_DATE1', + 'select hire_date from EMPLOYEE', + 'select hire_date from ut_UPD$HIRE_DATE1' + ); + ROLLBACK; + END; + + PROCEDURE ut_upd$salary1 + IS + fdbk PLS_INTEGER; + BEGIN + /* Successful update by ID */ + + EXECUTE IMMEDIATE ' + UPDATE ut_UPD$SALARY1 SET + salary = 5000 + WHERE employee_id = 7555 + '; + te_employee.upd$salary ( + 7555, + 5000, + rowcount_out => fdbk + ); + -- Test results + utassert.eqquery ( + 'Testing UPD$SALARY1', + 'select salary from EMPLOYEE', + 'select salary from ut_UPD$SALARY1' + ); + ROLLBACK; + END; + + PROCEDURE ut_emp_dept_lookuprowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE department_id = 30; + -- Compare to program call: + g_rowcount2 := + te_employee.emp_dept_lookuprowcount (30); + -- Test results + utassert.eq ( + 'Successful EMP_DEPT_LOOKUPROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_EMP_DEPT_LOOKUPROWCOUNT exception ' || + SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_emp_job_lookuprowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE job_id = 669; + -- Compare to program call: + g_rowcount2 := + te_employee.emp_job_lookuprowcount (669); + -- Test results + utassert.eq ( + 'Successful EMP_JOB_LOOKUPROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_EMP_JOB_LOOKUPROWCOUNT exception ' || + SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_emp_mgr_lookuprowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE manager_id = 7782; + -- Compare to program call: + g_rowcount2 := + te_employee.emp_mgr_lookuprowcount (7782); + -- Test results + utassert.eq ( + 'Successful EMP_MGR_LOOKUPROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_EMP_MGR_LOOKUPROWCOUNT exception ' || + SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_hire_date$val + IS + BEGIN + -- Test results + utassert.eqquery ( + 'Successful HIRE_DATE$VAL', + 'select te_employee.HIRE_DATE$VAL (employee_id) from employee', + 'select hire_Date from employee' + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_HIRE_DATE$VAL exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_i_employee_name$row + IS + rec1 te_employee.allcols_rt; + rec2 te_employee.allcols_rt; + BEGIN + -- Unsuccessful test + BEGIN + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE last_name = 'LANCE' + AND first_name = 'GREG' + AND middle_initial = 'J'; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Run program + begin + rec2 := + te_employee.i_employee_name$row ('LANCE', 'GREG', 'J'); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Test results + utassert.this ( + 'Unsuccessful I_EMPLOYEE_NAME$ROW', + te_employee.recseq (rec1, rec2) + ); + -- Successful test + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE last_name = 'LANCE' + AND first_name = 'GREGORY' + AND middle_initial = 'J'; + -- Run program + rec2 := + te_employee.i_employee_name$row ( + 'LANCE', + 'GREGORY', + 'J' + ); + -- Test results + utassert.this ( + 'Successful I_EMPLOYEE_NAME$ROW', + te_employee.recseq (rec1, rec2) + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_I_EMPLOYEE_NAME$ROW exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_i_employee_name$val + IS + rec1 te_employee.i_employee_name_rt; + rec2 te_employee.i_employee_name_rt; + BEGIN + -- Unsuccessful test + BEGIN + SELECT last_name, first_name, middle_initial + INTO rec1 + FROM employee + WHERE employee_id = -1; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Run program + begin + rec2 := te_employee.i_employee_name$val (-1); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + -- Test results + utassert.this ( + 'Unsuccessful I_EMPLOYEE_NAME$VAL', + recseq (rec1, rec2) + ); + -- Successful test + SELECT last_name, first_name, middle_initial + INTO rec1 + FROM employee + WHERE employee_id = 7839; + -- Run program + rec2 := te_employee.i_employee_name$val (7839); + -- Test results + utassert.this ( + 'Successful I_EMPLOYEE_NAME$VAL', + recseq (rec1, rec2) + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_I_EMPLOYEE_NAME$VAL exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_onerow + IS + rec1 te_employee.allcols_rt; + rec2 te_employee.allcols_rt; + BEGIN + -- Unsuccessful test + BEGIN + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE employee_id = -1; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + + -- Run program + begin + rec2 := te_employee.onerow (-1); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + NULL; + END; + -- Test results + utassert.this ( + 'Unsuccessful onerow', + te_employee.recseq (rec1, rec2) + ); + -- Successful test + SELECT + EMPLOYEE_ID, + LAST_NAME, + FIRST_NAME, + MIDDLE_INITIAL, + JOB_ID, + MANAGER_ID, + HIRE_DATE, + SALARY, + COMMISSION, + DEPARTMENT_ID, + CHANGED_BY, + CHANGED_ON + INTO rec1 + FROM employee + WHERE employee_id = 7839; + -- Run program + rec2 := te_employee.onerow (7839); + -- Test results + utassert.this ( + 'Successful onerow', + te_employee.recseq (rec1, rec2) + ); + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_ONEROW exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_pkyrowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee + WHERE employee_id = 7782; + -- Compare to program call: + g_rowcount2 := te_employee.pkyrowcount (7782); + -- Test results + utassert.eq ( + 'Successful PKYROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_PKYROWCOUNT exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_rowcount + IS + BEGIN + -- Run baseline code. + SELECT COUNT (*) + INTO g_rowcount1 + FROM employee; + -- Compare to program call: + g_rowcount2 := te_employee.rowcount; + -- Test results + utassert.eq ( + 'Successful ROWCOUNT', + g_rowcount2, + g_rowcount1 + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_ROWCOUNT exception ' || SQLERRM, + SQLCODE = 0 + ); + END; + + PROCEDURE ut_salary$val + IS + BEGIN + -- Test results + utassert.eqquery ( + 'Successful SALARY$VAL', + 'select te_employee.SALARY$VAL (employee_id) from employee', + 'select salary from employee' + ); + ROLLBACK; + EXCEPTION + WHEN OTHERS + THEN + -- Force registration of test failURE ut_. + utassert.this ( + 'ut_SALARY$VAL exception ' || SQLERRM, + SQLCODE = 0 + ); + END; +END ut_te_employee; +/ diff --git a/examples/ut_te_employee.pks b/examples/ut_te_employee.pks new file mode 100644 index 000000000..bb2160da5 --- /dev/null +++ b/examples/ut_te_employee.pks @@ -0,0 +1,28 @@ +create or replace package ut_TE_EMPLOYEE +IS + PROCEDURE ut_setup; + + PROCEDURE ut_teardown; + + PROCEDURE ut_DEL1; + PROCEDURE ut_DELBY_EMP_DEPT_LOOKUP; + PROCEDURE ut_DELBY_EMP_JOB_LOOKUP; + PROCEDURE ut_DELBY_EMP_MGR_LOOKUP; + PROCEDURE ut_INS1; + PROCEDURE ut_UPD1; + PROCEDURE ut_UPD$HIRE_DATE1; + PROCEDURE ut_UPD$SALARY1; + + PROCEDURE ut_EMP_DEPT_LOOKUPROWCOUNT; + PROCEDURE ut_EMP_JOB_LOOKUPROWCOUNT; + PROCEDURE ut_EMP_MGR_LOOKUPROWCOUNT; + PROCEDURE ut_HIRE_DATE$VAL; + PROCEDURE ut_I_EMPLOYEE_NAME$ROW; + PROCEDURE ut_I_EMPLOYEE_NAME$VAL; + PROCEDURE ut_ONEROW; + PROCEDURE ut_PKYROWCOUNT; + PROCEDURE ut_ROWCOUNT; + PROCEDURE ut_SALARY$VAL; + +END ut_TE_EMPLOYEE; +/ diff --git a/examples/ut_truncit.pkb b/examples/ut_truncit.pkb new file mode 100644 index 000000000..56d6d2fc9 --- /dev/null +++ b/examples/ut_truncit.pkb @@ -0,0 +1,34 @@ +CREATE OR REPLACE PACKAGE BODY ut_truncit +IS + PROCEDURE ut_setup + IS + BEGIN + EXECUTE IMMEDIATE + 'CREATE TABLE temp_emp AS SELECT * FROM employee'; + END; + + PROCEDURE ut_teardown + IS + BEGIN + EXECUTE IMMEDIATE + 'DROP TABLE temp_emp'; + END; + + -- For each program to test... + PROCEDURE ut_TRUNCIT IS + BEGIN + TRUNCIT ( + TAB => 'temp_emp' + , + SCH => USER + ); + + utAssert.eq ( + 'Test of TRUNCIT', + tabcount (USER, 'temp_emp'), + 0 + ); + END ut_TRUNCIT; + +END ut_truncit; +/ diff --git a/examples/ut_truncit.pks b/examples/ut_truncit.pks new file mode 100644 index 000000000..8b2255208 --- /dev/null +++ b/examples/ut_truncit.pks @@ -0,0 +1,9 @@ +CREATE OR REPLACE PACKAGE ut_truncit +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_TRUNCIT; +END ut_truncit; +/ diff --git a/examples/ut_vda$strings1.pkg b/examples/ut_vda$strings1.pkg new file mode 100644 index 000000000..6e71e068a --- /dev/null +++ b/examples/ut_vda$strings1.pkg @@ -0,0 +1,1469 @@ +CREATE OR REPLACE PACKAGE ut_VDA$STRINGS +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_ALL_TRIM; + PROCEDURE ut_INSTRW1; + PROCEDURE ut_INSTRW2; + PROCEDURE ut_REPLACE; + PROCEDURE ut_SCAN; + PROCEDURE ut_SCAN2; +END ut_VDA$STRINGS; +/ +CREATE OR REPLACE PACKAGE BODY ut_VDA$STRINGS +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + -- For each program to test... + PROCEDURE ut_ALL_TRIM + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'trim'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.ALL_TRIM ( + PI_TEXT => ' trim ' + , + PI_TRIM => ' ' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'trim all spaces', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + END ut_ALL_TRIM; + + PROCEDURE ut_INSTRW1 + IS + -- Verify and complete data types. + against_this BINARY_INTEGER; + check_this BINARY_INTEGER; + BEGIN + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 2; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'this is the search string' + , + VP_EXP => '_is' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of _is', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 'search' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of search', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 'search' + , + VP_POS => 1 + , + VP_OCC => 2 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'second occurence of search', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 1; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '%search%' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of %search%', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 'search' + , + VP_POS => 14 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of search starting at 14', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 'search' + , + VP_POS => 13 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of search starting at 13', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '%search%' + , + VP_POS => 13 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of %search% starting at 13', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 2; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '%search%' + , + VP_POS => 1 + , + VP_OCC => 2 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'second occurence of %search%', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_r' + , + VP_POS => 21 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s_r starting at 21', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 20; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_r' + , + VP_POS => 20 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s_r starting at 20', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 20; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_r' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s_r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%r' + , + VP_POS => 1 + , + VP_OCC => 3 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'third occurence of s%r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 7; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%r' + , + VP_POS => 1 + , + VP_OCC => 2 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'second occurence of s%r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%r' + , + VP_POS => 21 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s%r starting at 21', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 20; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%r' + , + VP_POS => 14 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s%r starting at 14', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%r' + , + VP_POS => 13 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s%r starting at 13', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 4; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%r' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s%r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 20; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_%ng' + , + VP_POS => 1 + , + VP_OCC => 4 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'fourth occurence of s_%ng', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 4; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_%ng' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s_%ng', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's__r' + , + VP_POS => 1 + , + VP_OCC => 3 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'third occurence of s__r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's__r' + , + VP_POS => 1 + , + VP_OCC => 2 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'second occurence of s__r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's__r' + , + VP_POS => 14 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s__r starting at 14', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's__r' + , + VP_POS => 13 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s__r starting at 13', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 13; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's__r' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of s__r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_r' + , + VP_POS => 1 + , + VP_OCC => 3 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'third occurence of s_r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_r' + , + VP_POS => 1 + , + VP_OCC => 2 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'second occurence of s_r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 2; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '%t_i_' + , + VP_POS => 1 + , + VP_OCC => 2 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'second occurence of %t_i_', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 1; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '%t_i_' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of %t_i_', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 20; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's%_%r' + , + VP_POS => 1 + , + VP_OCC => 4 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'fourth occurence of s%_%r', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 3; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '_s%s%s%s_' + , + VP_POS => 1 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of _s%s%s%s_', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => 's_%ng' + , + VP_POS => 1 + , + VP_OCC => 5 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'fifth occurence of s_%ng', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + VP_WRD => 'This is the search string' + , + VP_EXP => '%search%' + , + VP_POS => 14 + , + VP_OCC => 1 + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of %search% starting at 14', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + END ut_INSTRW1; + + PROCEDURE ut_INSTRW2 + IS + -- Verify and complete data types. + against_this NUMBER; + check_this NUMBER; + BEGIN + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 0; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.INSTRW ( + PI_TEXT => 'this is the search string' + , + PI_SEARCH => '_IS' + , + PI_POS => 1 + , + PI_NTH => 1 + , + PI_CASE => true + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'first occurence of _IS case sensitive', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + END ut_INSTRW2; + + PROCEDURE ut_REPLACE + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "replace" + + against_this := 'this is the search string'; + + -- Execute test code for "replace" + + check_this := + VDA$STRINGS.REPLACE ( + PI_SRCSTR => 'this is the search string' + , + PI_OLDSUBSTR => 'is' + , + PI_NEWSUBSTR => 'ese' + , + PI_START_OCCURENCE => 1 + , + PI_OCCURENCES => 1 + ); + + -- Assert success for "replace" + + -- Compare the two values. + utAssert.eq ( + 'replace is by ese', + check_this, + against_this + ); + + -- End of test for "replace" + END ut_REPLACE; + + PROCEDURE ut_SCAN + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word1'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN ( + PI_TEXT => 'word1::word2::word3::word4' + , + PI_NUM => 1 + , + PI_DELIMITER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'Find 1st word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word2'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN ( + PI_TEXT => 'word1::word2::word3::word4' + , + PI_NUM => 2 + , + PI_DELIMITER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'Find 2nd word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word4'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN ( + PI_TEXT => 'word1::word2::word3::word4' + , + PI_NUM => -1 + , + PI_DELIMITER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + 'Find last word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + END ut_SCAN; + + PROCEDURE ut_SCAN2 + IS + -- Verify and complete data types. + against_this VARCHAR2(2000); + check_this VARCHAR2(2000); + BEGIN + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word1'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 1 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '1st word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word4'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => -2 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '-2nd word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := NULL; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => -6 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Check for NULL return value. + utAssert.isNULL ( + '-6th word (null value)', + check_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word1'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => -5 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '-5th word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word2'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => -4 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '-4th word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := NULL; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => -3 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Check for NULL return value. + utAssert.isNULL ( + '-3nd word (null value)', + check_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word5'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => -1 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '-1st word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := NULL; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 3 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Check for NULL return value. + utAssert.isNULL ( + '3rd word (null value)', + check_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word5'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 5 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '5th word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := NULL; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 6 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Check for NULL return value. + utAssert.isNULL ( + '6th word (null value)', + check_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := NULL; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 0 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Check for NULL return value. + utAssert.isNULL ( + '0th word (null value)', + check_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word4'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 4 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '4th word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + + -- Define "control" operation for "VDA$STRINGS" + + against_this := 'word2'; + + -- Execute test code for "VDA$STRINGS" + + check_this := + VDA$STRINGS.SCAN2 ( + PI_TEXT => 'word1::word2::::word4::word5' + , + PI_NUM => 2 + , + PI_DELIMETER => '::' + ); + + -- Assert success for "VDA$STRINGS" + + -- Compare the two values. + utAssert.eq ( + '2nd word', + check_this, + against_this + ); + + -- End of test for "VDA$STRINGS" + END ut_SCAN2; + +END ut_VDA$STRINGS; +/ diff --git a/examples/utgen.txt b/examples/utgen.txt new file mode 100644 index 000000000..d6729d0c9 --- /dev/null +++ b/examples/utgen.txt @@ -0,0 +1,147 @@ +SQL> @@str_same.pks + +Package created. + +SQL> @@str_same.pkb + +Package body created. + +SQL> BEGIN + 2 p.l ('*** Basic package for stand alone procedure'); + 3 utgen.testpkg ('betwnstr'); + 4 + 5 p.l ('*** Basic package for package'); + 6 utgen.testpkg ('str'); + 7 + 8 p.l ('*** Place test code in same package as source'); + 9 utgen.testpkg ('str', samepackage_in => TRUE); + 10 + 11 p.l ('*** Change prefix, direct output to file'); + 12 utgen.testpkg ('str', prefix_in => 'tst_', output_type_in => utgen.c_file, + 13 dir_in => 'c:\temp'); + 14 END; + 15 / +*** Basic package for stand alone procedure +CREATE OR REPLACE PACKAGE ut_betwnstr +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWNSTR; +END ut_betwnstr; +/ +CREATE OR REPLACE PACKAGE BODY ut_betwnstr +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_BETWNSTR IS + BEGIN + utAssert.this ( + 'Test of BETWNSTR', + BETWNSTR( + STRING_IN => '' + , + START_IN => '' + , + END_IN => '' + ) + ); + END ut_BETWNSTR; + +END ut_betwnstr; +/ +*** Basic package for package +CREATE OR REPLACE PACKAGE ut_str +IS + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWN; +END ut_str; +/ +CREATE OR REPLACE PACKAGE BODY ut_str +IS + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_BETWN IS + BEGIN + utAssert.this ( + 'Test of BETWN', + STR.BETWN( + STRING_IN => '' + , + START_IN => '' + , + END_IN => '' + ) + ); + END ut_BETWN; + +END ut_str; +/ +*** Place test code in same package as source +-- START: place in specification of source package + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + -- For each program to test... + PROCEDURE ut_BETWN; +-- END: place in specification of source package +-- START: place in body of source package + PROCEDURE ut_setup + IS + BEGIN + NULL; + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + -- For each program to test... + PROCEDURE ut_BETWN IS + BEGIN + utAssert.this ( + 'Test of BETWN', + STR.BETWN( + STRING_IN => '' + , + START_IN => '' + , + END_IN => '' + ) + ); + END ut_BETWN; + +-- END: place in body of source package +*** Change prefix, direct output to file + +PL/SQL procedure successfully completed. + +SQL> SPOOL OFF diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 49356fd4e..000000000 --- a/mkdocs.yml +++ /dev/null @@ -1,105 +0,0 @@ -# Format documented here -# http://www.mkdocs.org/user-guide/configuration/ -# https://squidfunk.github.io/mkdocs-material/getting-started/ -# See this document for list of plugins to disable for offline (local) documentation -# https://squidfunk.github.io/mkdocs-material/setup/building-for-offline-usage/ - -edit_uri: "" -site_url: http://utPLSQL.org/ -site_name: utPLSQL-framework -site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL & SQL -copyright: Copyright © 2016 - 2026 utPLSQL Team -repo_url: https://github.com/utPLSQL/utPLSQL -extra_css: - - stylesheets/extra.css -theme: - name: material - palette: - # Palette toggle for light mode - - media: "(prefers-color-scheme: light)" - scheme: default - toggle: - icon: material/lightbulb-outline - name: Switch to dark mode - # Palette toggle for dark mode - - media: "(prefers-color-scheme: dark)" - scheme: slate - toggle: - icon: material/lightbulb - name: Switch to light mode - logo: assets/icon-transparent.png - favicon: assets/favicon.png - features: - - navigation.instant # disable for offline docs -# - navigation.indexes - - navigation.tabs - - navigation.tracking - - toc.follow - - toc.integrate - - search.suggest - - search.highlight -extra: -# homepage: http://jgebal.github.io/ -# homepage: http://utPLSQL.org/ - social: - - icon: fontawesome/brands/twitter - link: https://twitter.com/utPLSQL - - icon: fontawesome/regular/comment - link: https://github.com/utPLSQL/utPLSQL/discussions - - icon: fontawesome/brands/github - link: https://github.com/utPLSQL - - icon: fontawesome/solid/envelope - link: mailto:utPLSQL@utPLSQL.org - consent: - title: Cookie consent - description: >- - We use cookies to recognize your repeated visits and preferences, as well - as to measure the effectiveness of our documentation and whether users - find what they're searching for. With your consent, you're helping us to - make our documentation better. - version: # disable for offline docs - provider: mike # disable for offline docs -markdown_extensions: - - admonition - - pymdownx.details - - pymdownx.superfences - - pymdownx.highlight: - anchor_linenums: true - - pymdownx.inlinehilite - - pymdownx.snippets - - pymdownx.caret - - pymdownx.mark - - pymdownx.tilde - - toc: - permalink: true -use_directory_urls: false -strict: true - -plugins: - - search - - mike - - git-revision-date-localized: # disable for offline docs - enable_creation_date: true # disable for offline docs - type: datetime # disable for offline docs - -nav: - - User Guide: - - index.md - - Installation: userguide/install.md - - Getting Started: userguide/getting-started.md - - Annotations: userguide/annotations.md - - Expectations: userguide/expectations.md - - Advanced data comparison: userguide/advanced_data_comparison.md - - Running unit tests: userguide/running-unit-tests.md - - Querying for test suites: userguide/querying_suites.md - - Testing best practices: userguide/best-practices.md - - Upgrade utPLSQL: userguide/upgrade.md - - Reporting: - - Using reporters: userguide/reporters.md - - Code coverage: userguide/coverage.md - - Error handling and reporting: userguide/exception-reporting.md - - About: - - Project Details: about/project-details.md - - License: about/license.md - - Support: about/support.md - - Authors: about/authors.md diff --git a/mkdocs_offline.yml b/mkdocs_offline.yml deleted file mode 100644 index 9f0ef57af..000000000 --- a/mkdocs_offline.yml +++ /dev/null @@ -1,105 +0,0 @@ -# Format documented here -# http://www.mkdocs.org/user-guide/configuration/ -# https://squidfunk.github.io/mkdocs-material/getting-started/ -# See this document for list of plugins to disable for offline (local) documentation -# https://squidfunk.github.io/mkdocs-material/setup/building-for-offline-usage/ - -edit_uri: "" -site_url: http://utPLSQL.org/ -site_name: utPLSQL-framework -site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL & SQL -copyright: Copyright © 2016 - 2022 utPLSQL Team -#repo_url: https://github.com/utPLSQL/utPLSQL # disable for offline docs -extra_css: - - stylesheets/extra.css -theme: - name: material - palette: - # Palette toggle for light mode - - media: "(prefers-color-scheme: light)" - scheme: default - toggle: - icon: material/lightbulb-outline - name: Switch to dark mode - # Palette toggle for dark mode - - media: "(prefers-color-scheme: dark)" - scheme: slate - toggle: - icon: material/lightbulb - name: Switch to light mode - logo: assets/icon-transparent.png - favicon: assets/favicon.png - features: -# - navigation.instant # disable for offline docs -# - navigation.indexes - - navigation.tabs - - navigation.tracking - - toc.follow - - toc.integrate - - search.suggest - - search.highlight -extra: -# homepage: http://jgebal.github.io/ -# homepage: http://utPLSQL.org/ - social: - - icon: fontawesome/brands/twitter - link: https://twitter.com/utPLSQL - - icon: fontawesome/regular/comment - link: https://github.com/utPLSQL/utPLSQL/discussions - - icon: fontawesome/brands/github - link: https://github.com/utPLSQL - - icon: fontawesome/solid/envelope - link: mailto:utPLSQL@utPLSQL.org - consent: - title: Cookie consent - description: >- - We use cookies to recognize your repeated visits and preferences, as well - as to measure the effectiveness of our documentation and whether users - find what they're searching for. With your consent, you're helping us to - make our documentation better. -# version: # disable for offline docs -# provider: mike # disable for offline docs -markdown_extensions: - - admonition - - pymdownx.details - - pymdownx.superfences - - pymdownx.highlight: - anchor_linenums: true - - pymdownx.inlinehilite - - pymdownx.snippets - - pymdownx.caret - - pymdownx.mark - - pymdownx.tilde - - toc: - permalink: true -use_directory_urls: false -strict: true - -plugins: -# - search # disable for offline docs - - mike -# - git-revision-date-localized: # disable for offline docs -# enable_creation_date: true # disable for offline docs -# type: datetime # disable for offline docs - -nav: - - User Guide: - - index.md - - Installation: userguide/install.md - - Getting Started: userguide/getting-started.md - - Annotations: userguide/annotations.md - - Expectations: userguide/expectations.md - - Advanced data comparison: userguide/advanced_data_comparison.md - - Running unit tests: userguide/running-unit-tests.md - - Querying for test suites: userguide/querying_suites.md - - Testing best practices: userguide/best-practices.md - - Upgrade utPLSQL: userguide/upgrade.md - - Reporting: - - Using reporters: userguide/reporters.md - - Code coverage: userguide/coverage.md - - Error handling and reporting: userguide/exception-reporting.md - - About: - - Project Details: about/project-details.md - - License: about/license.md - - Support: about/support.md - - Authors: about/authors.md diff --git a/readme.md b/readme.md deleted file mode 100644 index 1ca252558..000000000 --- a/readme.md +++ /dev/null @@ -1,202 +0,0 @@ -![utPLSQL v3 | Testing Framework for PL/SQL](docs/images/utPLSQL-testing-framework-transparent_120.png) - ----------- - -[![license](https://img.shields.io/github/license/utPLSQL/utPLSQL.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![latest-release](https://img.shields.io/github/release/utPLSQL/utPLSQL.svg)](https://github.com/utPLSQL/utPLSQL/releases) -[![Download statistics](https://img.shields.io/github/downloads/utPLSQL/utPLSQL/total.svg)](http://gra.caldis.me/?url=https://github.com/utPLSQL/utPLSQL) -[![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) -[![twitter](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL) - -[![build](https://github.com/utPLSQL/utPLSQL/actions/workflows/build.yml/badge.svg)](https://github.com/utPLSQL/utPLSQL/actions/workflows/build.yml) -[![QualityGate](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL_utPLSQL&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=utPLSQL_utPLSQL) -[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL_utPLSQL&metric=coverage)](https://sonarcloud.io/summary/new_code?id=utPLSQL_utPLSQL) - ----------- -utPLSQL version 3 is a complete rewrite of utPLSQL v2 from scratch. -Version 2 still supports older versions of Oracle that are no longer available. -The community that had developed on GitHub decided that a new internal architecture was needed, from that version 3 was born. - -# Introduction -utPLSQL is a Unit Testing framework for Oracle PL/SQL and SQL. -The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/) - - -# Key features - -- multiple ways to compare data with [matchers](docs/userguide/expectations.md) -- native comparison of complex types (objects/collections/cursors) -- in-depth and consistent reporting of failures and errors for tests -- tests identified and configured by [annotations](docs/userguide/annotations.md) -- hierarchies of test suites configured with annotations -- automatic (configurable) transaction control -- Build-in [coverage](docs/userguide/coverage.md) reporting -- Integration with SonarQube, Coveralls, Jenkins and Teamcity with [reporters](docs/userguide/reporters.md) -- plugin architecture for reporters and matchers -- flexible and simple test invocation -- multi-reporting from test-run from [command line](https://github.com/utPLSQL/utPLSQL-cli) - -Requirements: - - Version of Oracle under [extended support](http://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf) (Currently 11.2 and above) - -# Download - -Published releases are available for download on the [utPLSQL GitHub Releases Page.](https://github.com/utPLSQL/utPLSQL/releases) - -# Documentation - -Full documentation of the project is automatically published on [utPLSQL github pages](https://utplsql.github.io/utPLSQL/) - -[Cheat-sheets](https://www.cheatography.com/jgebal/lists/utplsql-v3-cheat-sheets/) - -# Installation - -To install the utPLSQL into a new database schema and grant it to public, execute the script `install_headless.sql`. -This will create a new user `UT3`, grant all required privileges to that user and create PUBLIC synonyms needed. - -For detailed instructions on other install options see the [Install Guide](docs/userguide/install.md) - - -# Running tests - -To execute using development IDE (TOAD/SQLDeveloper/PLSQLDeveloper/other) use one of following commands. -```sql -begin - ut.run(); -end; -/ -``` -```sql -exec ut.run(); -``` -```sql -select * from table(ut.run()); -``` - -The above commands will run all the suites in the current schema and provide report to dbms_output or as a select statement. - -# Command line client - -You can use the utPLSQL command line client [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli) to run tests without the need for Oracle Client or any IDE like SQLDeveloper/TOAD etc. - -Amongst many benefits it provides ability to: -* see the progress of test execution for long-running tests - real-time reporting -* use many reporting formats simultaneously and save reports to files (publish) -* map your project source files and test files into database objects - -Download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) and are good to go. -See [project readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details. - - -# Example unit test packages - -**For examples of using Continuous Integration Server & SonarCloud with utPLSQL see the [utPLSQL demo project](https://github.com/utPLSQL/utPLSQL-demo-project/).** - - -The below test package is a fully-functional Unit Test package for testing a [`betwnstr` function](examples/between_string/betwnstr.sql). -The package specification is [annotated](docs/userguide/annotations.md) with special comments. -The annotations define that a package is a unit test suite, they also allow defining a description for the suite as well as the test itself. -The package body consists of procedures containing unit test code. To validate [an expectation](docs/userguide/expectations.md) in test, use `ut.expect( actual_data ).to_( ... )` syntax. - -```sql -create or replace package test_between_string as - - -- %suite(Between string function) - - -- %test(Returns substring from start position to end position) - procedure normal_case; - - -- %test(Returns substring when start position is zero) - procedure zero_start_position; - - -- %test(Returns string until end if end position is greater than string length) - procedure big_end_position; - - -- %test(Returns null for null input string value) - procedure null_string; -end; -/ - -create or replace package body test_between_string as - - procedure normal_case is - begin - ut.expect( betwnstr( '1234567', 2, 5 ) ).to_( equal('2345') ); - end; - - procedure zero_start_position is - begin - ut.expect( betwnstr( '1234567', 0, 5 ) ).to_( equal('12345') ); - end; - - procedure big_end_position is - begin - ut.expect( betwnstr( '1234567', 0, 500 ) ).to_( equal('1234567') ); - end; - - procedure null_string is - begin - ut.expect( betwnstr( null, 2, 5 ) ).to_( be_null ); - end; - -end; -/ -``` - -Outputs from running the above tests -``` -Between string function - Returns substring from start position to end position - Returns substring when start position is zero - Returns string until end if end position is greater than string length - Returns null for null input string value - -Finished in .036027 seconds -4 tests, 0 failures -``` - - -# Contributing to the project - -We welcome new developers to join our community and contribute to the utPLSQL project. -If you are interested in helping please read our [guide to contributing](CONTRIBUTING.md) -The best place to start is to read the documentation and get familiar with the existing code base. -[Github discussions](https://github.com/utPLSQL/utPLSQL/discussions) is the place to go if you want to talk with team members. - - ----------- -[__Authors__](docs/about/authors.md) - - ----------- -__Project Directories__ - -* .github - contains files needed for github Actions integration -* .travis - contains files needed for travis-ci integration -* client_source - Sources to be used on the client-side. Developer workstation or CI platform to run the tests. -* development - Set of useful scripts and utilities for development and debugging of utPLSQL -* docs - Documentation of the project -* examples - Example source code and unit tests -* source - The installation code for utPLSQL -* tests - Tests for utPLSQL framework - ----------- - - -# Version 2 to Version 3 Comparison - -[Version 2 to Version 3 Comparison](docs/compare_version2_to_3.md) - -# Supporters - -The utPLSQL project is community-driven and is not commercially motivated. Nonetheless, donations and other contributions are always welcome, and are detailed below. - - - - - - - - -
supported_by_redgateutPLSQL has been supported by Redgate in the form of sponsored stickers and t-shirts. Thank you for helping us spreading the word!
- diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index f23e8cf71..000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,38 +0,0 @@ -# must be unique in a given SonarQube instance -sonar.organization=utplsql -sonar.projectKey=utPLSQL_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.14-develop - -# 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. -# If not set, SonarQube starts looking for source code from the directory containing -# 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 -sonar.links.ci=https://travis-ci.org/utPLSQL/utPLSQL -sonar.links.homepage=https://github.com/utPLSQL/utPLSQL -sonar.projectDescription=PL/SQL Unit Testing Framework -sonar.plsql.file.suffixes=sql,tab,pkb,tpb -sonar.language=plsql - - -sonar.exclusions=**/*.sql - -sonar.pullrequest.provider=github -sonar.pullrequest.github.endpoint=https://api.github.com/ -sonar.pullrequest.github.repository=utPLSQL/utPLSQL - -sonar.plsql.jdbc.driver.class=oracle.jdbc.OracleDriver -sonar.plsql.jdbc.user=UT3_DEVELOP -sonar.plsql.jdbc.password=ut3 -sonar.plsql.defaultSchema=UT3_DEVELOP - - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 diff --git a/source/api/be_between.syn b/source/api/be_between.syn deleted file mode 100644 index c0972595d..000000000 --- a/source/api/be_between.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_between for ut_be_between; diff --git a/source/api/be_empty.syn b/source/api/be_empty.syn deleted file mode 100644 index a8e28de6e..000000000 --- a/source/api/be_empty.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_empty for ut_be_empty; diff --git a/source/api/be_false.syn b/source/api/be_false.syn deleted file mode 100644 index c2665bbcb..000000000 --- a/source/api/be_false.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_false for ut_be_false; diff --git a/source/api/be_greater_or_equal.syn b/source/api/be_greater_or_equal.syn deleted file mode 100644 index 386fe7f32..000000000 --- a/source/api/be_greater_or_equal.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_greater_or_equal for ut_be_greater_or_equal; diff --git a/source/api/be_greater_than.syn b/source/api/be_greater_than.syn deleted file mode 100644 index 6f97b7d22..000000000 --- a/source/api/be_greater_than.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_greater_than for ut_be_greater_than; diff --git a/source/api/be_less_or_equal.syn b/source/api/be_less_or_equal.syn deleted file mode 100644 index b2f836144..000000000 --- a/source/api/be_less_or_equal.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_less_or_equal for ut_be_less_or_equal; diff --git a/source/api/be_less_than.syn b/source/api/be_less_than.syn deleted file mode 100644 index fbef3b4c3..000000000 --- a/source/api/be_less_than.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_less_than for ut_be_less_than; diff --git a/source/api/be_like.syn b/source/api/be_like.syn deleted file mode 100644 index a8be1de71..000000000 --- a/source/api/be_like.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_like for ut_be_like; diff --git a/source/api/be_not_null.syn b/source/api/be_not_null.syn deleted file mode 100644 index d6458683a..000000000 --- a/source/api/be_not_null.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_not_null for ut_be_not_null; diff --git a/source/api/be_null.syn b/source/api/be_null.syn deleted file mode 100644 index 42f6516c3..000000000 --- a/source/api/be_null.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_null for ut_be_null; diff --git a/source/api/be_true.syn b/source/api/be_true.syn deleted file mode 100644 index bf7392a62..000000000 --- a/source/api/be_true.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_true for ut_be_true; diff --git a/source/api/be_within.syn b/source/api/be_within.syn deleted file mode 100644 index e00005bb7..000000000 --- a/source/api/be_within.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_within for ut_be_within; diff --git a/source/api/be_within_pct.syn b/source/api/be_within_pct.syn deleted file mode 100644 index 40e3fb8b9..000000000 --- a/source/api/be_within_pct.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym be_within_pct for ut_be_within_pct; diff --git a/source/api/contain.syn b/source/api/contain.syn deleted file mode 100644 index 5bce7d1d2..000000000 --- a/source/api/contain.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym contain for ut_contain; diff --git a/source/api/equal.syn b/source/api/equal.syn deleted file mode 100644 index 71ba58b53..000000000 --- a/source/api/equal.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym equal for ut_equal; diff --git a/source/api/have_count.syn b/source/api/have_count.syn deleted file mode 100644 index a406d47ec..000000000 --- a/source/api/have_count.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym have_count for ut_have_count; diff --git a/source/api/match.syn b/source/api/match.syn deleted file mode 100644 index ffbda35b1..000000000 --- a/source/api/match.syn +++ /dev/null @@ -1 +0,0 @@ -create synonym match for ut_match; diff --git a/source/api/ut.pkb b/source/api/ut.pkb deleted file mode 100644 index cff35b771..000000000 --- a/source/api/ut.pkb +++ /dev/null @@ -1,827 +0,0 @@ -create or replace package body ut is - - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - g_nls_date_format varchar2(4000); - gc_fail_on_errors constant boolean := false; - - g_result_line_no binary_integer; - g_result_lines ut_varchar2_list := ut_varchar2_list(); - - function version return varchar2 is - begin - return ut_runner.version(); - end; - - function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_compound is - begin - return ut_expectation_compound(ut_data_value_anydata(a_actual), a_message); - end; - - function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_blob(a_actual), a_message); - end; - - function expect(a_actual in boolean, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_boolean(a_actual), a_message); - end; - - function expect(a_actual in clob, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_clob(a_actual), a_message); - end; - - function expect(a_actual in date, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_date(a_actual), a_message); - end; - - function expect(a_actual in number, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_number(a_actual), a_message); - end; - - function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_timestamp(a_actual), a_message); - end; - - function expect(a_actual in timestamp_ltz_unconstrained, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_timestamp_ltz(a_actual), a_message); - end; - - function expect(a_actual in timestamp_tz_unconstrained, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_timestamp_tz(a_actual), a_message); - end; - - function expect(a_actual in varchar2, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_varchar2(a_actual), a_message); - end; - - function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound is - begin - return ut_expectation_compound(ut_data_value_refcursor(a_actual), a_message); - end; - - function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation is - begin - return ut_expectation(ut_data_value_yminterval(a_actual), a_message); - end; - - function expect(a_actual in dsinterval_unconstrained, a_message varchar2 := null) return ut_expectation is - begin - 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; - - function expect(a_actual in json , 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); - end; - - procedure raise_if_packages_invalidated is - e_package_invalidated exception; - pragma exception_init (e_package_invalidated, -04068); - begin - if ut_expectation_processor.invalidation_exception_found() then - ut_expectation_processor.reset_invalidation_exception(); - raise e_package_invalidated; - end if; - end; - - - procedure run_autonomous( - a_paths ut_varchar2_list, - a_reporter in out nocopy ut_reporter_base, - a_color_console integer, - 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, - a_random_test_order integer, - a_random_test_order_seed positive, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - pragma autonomous_transaction; - begin - a_reporter := coalesce(a_reporter,ut_documentation_reporter()); - ut_runner.run( - a_paths, - ut_reporters(a_reporter), - ut_utils.int_to_boolean(a_color_console), - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - gc_fail_on_errors, - a_client_character_set, - false, - ut_utils.int_to_boolean(a_random_test_order), - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - rollback; - end; - - procedure run_autonomous( - a_paths ut_varchar2_list, - a_reporter in out nocopy ut_reporter_base, - a_color_console integer, - 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, - a_random_test_order integer, - a_random_test_order_seed positive, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - pragma autonomous_transaction; - begin - - a_reporter := coalesce(a_reporter,ut_documentation_reporter()); - ut_runner.run( - a_paths, - ut_reporters(a_reporter), - ut_utils.int_to_boolean(a_color_console), - a_coverage_schemes, - ut_file_mapper.build_file_mappings(a_source_files), - ut_file_mapper.build_file_mappings(a_test_files), - a_include_objects, - a_exclude_objects, - gc_fail_on_errors, - a_client_character_set, - false, - ut_utils.int_to_boolean(a_random_test_order), - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - rollback; - end; - - function get_report_outputs( a_cursor sys_refcursor ) return varchar2 is - l_clob clob; - l_item_type varchar2(32767); - l_result varchar2(4000); - begin - if g_result_line_no is null then - fetch a_cursor into l_clob, l_item_type; - if a_cursor%notfound then - close a_cursor; - g_result_line_no := null; - g_result_lines := ut_varchar2_list(); - raise_if_packages_invalidated(); - raise no_data_found; - end if; - if l_clob is not null and l_clob != empty_clob() then - if length(l_clob) > ut_utils.gc_max_storage_varchar2_len then - g_result_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len); - else - g_result_lines := ut_varchar2_list(l_clob); - end if; - g_result_line_no := g_result_lines.first; - end if; - end if; - if g_result_line_no is not null then - l_result := g_result_lines(g_result_line_no); - g_result_line_no := g_result_lines.next(g_result_line_no); - end if; - return l_result; - end; - - function run( - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := a_reporter; - l_results sys_refcursor; - begin - run_autonomous( - ut_varchar2_list(), - l_reporter, - a_color_console, - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - if l_reporter is of (ut_output_reporter_base) then - l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); - g_result_lines := ut_varchar2_list(); - loop - pipe row( get_report_outputs( l_results ) ); - end loop; - end if; - return; - end; - - function run( - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := a_reporter; - l_results sys_refcursor; - begin - run_autonomous( - ut_varchar2_list(), - l_reporter, - a_color_console, - a_coverage_schemes, - a_source_files, - a_test_files, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - if l_reporter is of (ut_output_reporter_base) then - l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); - g_result_lines := ut_varchar2_list(); - loop - pipe row( get_report_outputs( l_results ) ); - end loop; - end if; - return; - end; - - function run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := a_reporter; - l_results sys_refcursor; - begin - run_autonomous( - a_paths, - l_reporter, - a_color_console, - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - if l_reporter is of (ut_output_reporter_base) then - l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); - g_result_lines := ut_varchar2_list(); - loop - pipe row( get_report_outputs( l_results ) ); - end loop; - end if; - return; - end; - - function run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := a_reporter; - l_results sys_refcursor; - begin - run_autonomous( - a_paths, - l_reporter, - a_color_console, - a_coverage_schemes, - a_source_files, - a_test_files, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - if l_reporter is of (ut_output_reporter_base) then - l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); - g_result_lines := ut_varchar2_list(); - loop - pipe row( get_report_outputs( l_results ) ); - end loop; - end if; - return; - end; - - function run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := a_reporter; - l_results sys_refcursor; - begin - run_autonomous( - ut_varchar2_list(a_path), - l_reporter, - a_color_console, - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - if l_reporter is of (ut_output_reporter_base) then - l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); - g_result_lines := ut_varchar2_list(); - loop - pipe row( get_report_outputs( l_results ) ); - end loop; - end if; - return; - end; - - function run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined is - l_reporter ut_reporter_base := a_reporter; - l_results sys_refcursor; - begin - run_autonomous( - ut_varchar2_list(a_path), - l_reporter, - a_color_console, - a_coverage_schemes, - a_source_files, - a_test_files, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - if l_reporter is of (ut_output_reporter_base) then - l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); - g_result_lines := ut_varchar2_list(); - loop - pipe row( get_report_outputs( l_results ) ); - end loop; - end if; - return; - end; - - procedure run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - l_reporter ut_reporter_base := a_reporter; - begin - if a_force_manual_rollback then - l_reporter := coalesce(l_reporter,ut_documentation_reporter()); - ut_runner.run( - a_paths, - ut_reporters(l_reporter), - a_color_console, - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - gc_fail_on_errors, - a_client_character_set, - a_force_manual_rollback, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - else - run_autonomous( - a_paths, - l_reporter, - ut_utils.boolean_to_int(a_color_console), - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - a_client_character_set, - ut_utils.boolean_to_int(a_random_test_order), - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - end if; - if l_reporter is of (ut_output_reporter_base) then - treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output(); - end if; - raise_if_packages_invalidated(); - end; - - procedure run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - l_reporter ut_reporter_base := a_reporter; - begin - ut.run( - a_paths, - l_reporter, - a_color_console, - a_coverage_schemes, - ut_file_mapper.build_file_mappings(a_source_files), - ut_file_mapper.build_file_mappings(a_test_files), - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_force_manual_rollback, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - end; - - procedure run( - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - begin - ut.run( - ut_varchar2_list(), - a_reporter, - a_color_console, - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_force_manual_rollback, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - end; - - procedure run( - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - begin - ut.run( - ut_varchar2_list(), - a_reporter, - a_color_console, - a_coverage_schemes, - a_source_files, - a_test_files, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_force_manual_rollback, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - end; - - procedure run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - begin - ut.run( - ut_varchar2_list(a_path), - a_reporter, - a_color_console, - a_coverage_schemes, - a_source_file_mappings, - a_test_file_mappings, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_force_manual_rollback, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - end; - - procedure run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - begin - ut.run( - ut_varchar2_list(a_path), - a_reporter, - a_color_console, - a_coverage_schemes, - a_source_files, - a_test_files, - a_include_objects, - a_exclude_objects, - a_client_character_set, - a_force_manual_rollback, - a_random_test_order, - a_random_test_order_seed, - a_tags, - a_include_schema_expr, - a_include_object_expr, - a_exclude_schema_expr, - a_exclude_object_expr - ); - end; - - - procedure set_nls is - begin - if g_nls_date_format is null then - select /*+ no_parallel */ nsp.value - into g_nls_date_format - from nls_session_parameters nsp - where parameter = 'NLS_DATE_FORMAT'; - end if; - execute immediate 'alter session set nls_date_format = '''||ut_utils.gc_date_format||''''; - end; - - procedure reset_nls is - begin - if g_nls_date_format is not null then - execute immediate 'alter session set nls_date_format = '''||g_nls_date_format||''''; - end if; - g_nls_date_format := null; - end; - -end ut; -/ diff --git a/source/api/ut.pks b/source/api/ut.pks deleted file mode 100644 index f72c82a0c..000000000 --- a/source/api/ut.pks +++ /dev/null @@ -1,299 +0,0 @@ -create or replace package ut authid current_user as - - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function version return varchar2; - - function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_compound; - - function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in boolean, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in clob, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in date, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in number, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound; - - function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in timestamp_ltz_unconstrained, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in timestamp_tz_unconstrained, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in varchar2, a_message varchar2 := null) return ut_expectation; - - function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation; - - 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; - - function expect(a_actual in json , a_message varchar2 := null) return ut_expectation_json; - - procedure fail(a_message in varchar2); - - function run( - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined; - - function run( - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined; - - function run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined; - - function run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined; - - function run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined; - - function run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console integer := 0, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_random_test_order integer := 0, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) return ut_varchar2_rows pipelined; - - procedure run( - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - procedure run( - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - procedure run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - procedure run( - a_paths ut_varchar2_list, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - procedure run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - procedure run( - a_path varchar2, - a_reporter ut_reporter_base := null, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_files ut_varchar2_list, - 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_force_manual_rollback boolean := false, - a_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - /** - * Helper procedure to set NLS session parameter for date processing in refcursor. - * It needs to be called before refcursor is open in order to have DATE data type data in refcursor - * properly transformed into XML format as a date-time element. - * If the function is not called before opening a cursor to be compared, the DATE data is compared using default NLS setting for date. - */ - procedure set_nls; - - /** - * Helper procedure to reset NLS session parameter to it's original state. - * It needs to be called after refcursor is open in order restore the original session state and keep the NLS date setting at default. - */ - procedure reset_nls; - -end ut; -/ diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb deleted file mode 100644 index 3ec2a5393..000000000 --- a/source/api/ut_runner.pkb +++ /dev/null @@ -1,272 +0,0 @@ -create or replace package body ut_runner is - - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Private functions - */ - - procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is - begin - ut_event_manager.trigger_event(ut_event_manager.gc_finalize, a_run); - ut_metadata.reset_source_definition_cache; - ut_utils.read_cache_to_dbms_output(); - ut_coverage_helper.cleanup_tmp_table(); - ut_compound_data_helper.cleanup_diff(); - if not a_force_manual_rollback then - rollback; - end if; - end; - - - /** - * Public functions - */ - function version return varchar2 is - begin - return ut_utils.gc_version; - end; - - function version_compatibility_check( a_requested varchar2, a_current varchar2 := null ) return integer is - l_result boolean := false; - l_requested ut_utils.t_version := ut_utils.to_version(a_requested); - l_current ut_utils.t_version := ut_utils.to_version(coalesce(a_current,version())); - begin - if l_requested.major = l_current.major - and (l_requested.minor < l_current.minor or l_requested.minor is null - or l_requested.minor = l_current.minor and (l_requested.bugfix <= l_current.bugfix or l_requested.bugfix is null)) then - l_result := true; - end if; - return ut_utils.boolean_to_int(l_result); - end; - - procedure run( - a_paths ut_varchar2_list, - a_reporters ut_reporters, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, - 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_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ) is - l_run ut_run; - l_coverage_schema_names ut_varchar2_rows; - l_paths ut_varchar2_list; - l_random_test_order_seed positive; - begin - ut_event_manager.initialize(); - if a_reporters is not empty then - for i in 1 .. a_reporters.count loop - ut_event_manager.add_listener( a_reporters(i) ); - end loop; - else - ut_event_manager.add_listener( ut_documentation_reporter() ); - end if; - ut_event_manager.add_listener( ut_session_info() ); - - 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; - - l_paths := ut_utils.filter_list(ut_utils.string_table_to_table(a_paths,','), '.+'); - if l_paths is null or l_paths is empty then - l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema')); - end if; - - begin - ut_expectation_processor.reset_invalidation_exception(); - 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 - l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths); - end if; - - l_run := ut_run( - a_run_paths => l_paths, - a_coverage_options => ut_coverage_options( - coverage_run_id => ut_coverage.get_coverage_run_id(), - schema_names => l_coverage_schema_names, - exclude_objects => ut_utils.convert_collection(a_exclude_objects), - include_objects => ut_utils.convert_collection(a_include_objects), - file_mappings => set(a_source_file_mappings), - include_schema_expr => a_include_schema_expr, - include_object_expr => a_include_object_expr, - exclude_schema_expr => a_exclude_schema_expr, - exclude_object_expr => a_exclude_object_expr - ), - a_test_file_mappings => set(a_test_file_mappings), - a_client_character_set => a_client_character_set, - a_random_test_order_seed => l_random_test_order_seed, - a_run_tags => a_tags - ); - - ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, a_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; - - l_run.do_execute(); - finish_run(l_run, a_force_manual_rollback); - exception - when others then - finish_run(l_run, a_force_manual_rollback); - dbms_output.put_line(dbms_utility.format_error_backtrace); - dbms_output.put_line(dbms_utility.format_error_stack); - raise; - end; - if a_fail_on_errors and l_run.result in (ut_utils.gc_failure, ut_utils.gc_error) then - raise_application_error(ut_utils.gc_some_tests_failed, 'Some tests failed'); - end if; - end; - - procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2 := null) is - begin - ut_annotation_manager.rebuild_annotation_cache(a_object_owner, coalesce(a_object_type,'PACKAGE')); - end; - - procedure purge_cache(a_object_owner varchar2 := null, a_object_type varchar2 := null) is - begin - ut_annotation_manager.purge_cache(a_object_owner, a_object_type); - end; - - function get_suites_info(a_owner varchar2, a_package_name varchar2) return ut_suite_items_info pipelined is - l_cursor sys_refcursor; - l_results ut_suite_items_info; - c_bulk_limit constant integer := 100; - l_path varchar2(4000) := nvl(a_owner,sys_context('userenv', 'current_schema'))||'.'||nvl(a_package_name,'*'); - begin - - l_cursor := ut_suite_manager.get_suites_info(ut_varchar2_list(l_path)); - loop - fetch l_cursor bulk collect into l_results limit c_bulk_limit; - for i in 1 .. l_results.count loop - pipe row (l_results(i)); - end loop; - exit when l_cursor%notfound; - end loop; - close l_cursor; - return; - end; - - function get_suites_info(a_path varchar2 := null) return ut_suite_items_info pipelined is - l_cursor sys_refcursor; - l_results ut_suite_items_info; - c_bulk_limit constant integer := 100; - i pls_integer; - begin - l_cursor := ut_suite_manager.get_suites_info(ut_varchar2_list(nvl(a_path,sys_context('userenv', 'current_schema')))); - loop - fetch l_cursor bulk collect into l_results limit c_bulk_limit; - i := l_results.first; - while (i is not null) loop - pipe row (l_results(i)); - i := l_results.next(i); - end loop; - exit when l_cursor%notfound; - end loop; - close l_cursor; - return; - end; - - function is_test(a_owner varchar2, a_package_name varchar2, a_procedure_name varchar2) return boolean is - l_result boolean := false; - begin - if a_owner is not null and a_package_name is not null and a_procedure_name is not null then - - l_result := ut_suite_manager.suite_item_exists( a_owner, a_package_name, a_procedure_name ); - - end if; - - return l_result; - end; - - function is_suite(a_owner varchar2, a_package_name varchar2) return boolean is - l_result boolean := false; - begin - if a_owner is not null and a_package_name is not null then - - l_result := ut_suite_manager.suite_item_exists( a_owner, a_package_name ); - - end if; - - return l_result; - end; - - function has_suites(a_owner varchar2) return boolean is - l_result boolean := false; - begin - if a_owner is not null then - - l_result := ut_suite_manager.suite_item_exists( a_owner ); - - end if; - - return l_result; - end; - - function get_reporters_list return tt_reporters_info pipelined is - l_owner varchar2(128) := upper(ut_utils.ut_owner()); - l_reporters ut_reporters_info; - l_result t_reporter_rec; - begin - loop - l_reporters := ut_utils.get_child_reporters( l_reporters ); - exit when l_reporters is null or l_reporters.count = 0; - for i in 1 .. l_reporters.count loop - if l_reporters(i).is_instantiable = 'Y' then - l_result.reporter_object_name := l_owner||'.'||l_reporters(i).object_name; - l_result.is_output_reporter := l_reporters(i).is_output_reporter; - pipe row( l_result ); - end if; - end loop; - end loop; - end; - - procedure coverage_start(a_coverage_run_id raw) is - begin - ut_coverage.coverage_start(a_coverage_run_id); - end; - - procedure coverage_stop is - begin - ut_coverage.coverage_stop; - end; - -end ut_runner; -/ diff --git a/source/api/ut_runner.pks b/source/api/ut_runner.pks deleted file mode 100644 index 85eff1c93..000000000 --- a/source/api/ut_runner.pks +++ /dev/null @@ -1,159 +0,0 @@ -create or replace package ut_runner authid current_user is - - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function version return varchar2; - - /** - * Check if version is compatible with another version (by default the current framework version) - * Version is compatible if: - * a_current.major = a_requested.major - * a_requested.minor < a_current.minor or a_requested.minor = a_current.minor and a_requested.bugfix <= a_current.bugfix - * - * @param a_requested requested utPLSQL version string - * @param a_current current utPLSQL version string, if null is passed, defaults to current framework version - * @return 1/0 1-true, 0-false - * @exception 20214 if passed version string is not matching version pattern - */ - function version_compatibility_check( a_requested varchar2, a_current varchar2 := null ) return integer; - - /** - * Execute specified suites/tests by paths - * @param a_paths list of schemes, packages, procedures or suite-paths to execute - * @param a_reporters list of reporter objects (formats) to use for reporting - * @param a_color_console true/false - should the console format reporters use ANSI color tags - * @param a_coverage_schemes list of database schemes to include in coverage - * @param a_source_file_mappings list of project source files mapped to DB objects that coverage should be reported on - * @param a_test_file_mappings list of project test files mapped to DB objects that test results should be reported on - * @param a_include_objects list of database objects (in format 'owner.name') that coverage should be reported on - * @param a_exclude_objects list of database objects (in format 'owner.name') that coverage should be skipped for - * @param a_fail_on_errors true/false - should an exception be thrown when tests are completed with failures/errors - * @param a_client_character_set if provided, affects some of reporters by setting specific character set for XML/HTML reports - * @param a_force_manual_rollback true/false - should the transaction control be forced to --%rollback(manual) and no rollback issued at the end of the run - * - * @example - * Parameter `a_paths` accepts values of the following formats: - * schema - executes all suites in the schema - * schema:suite1[.suite2] - executes all items of suite1 (suite2) in the schema. - * suite1.suite2 is a suitepath variable - * schema:suite1[.suite2][.test1] - executes test1 in suite suite1.suite2 - * schema.suite1 - executes the suite package suite1 in the schema "schema" - * all the parent suites in the hiearcy setups/teardown procedures as also executed - * all chile items are executed - * schema.suite1.test2 - executes test2 procedure of suite1 suite with execution of all parent setup/teardown procedures - */ - procedure run( - a_paths ut_varchar2_list, - a_reporters ut_reporters, - a_color_console boolean := false, - a_coverage_schemes ut_varchar2_list := null, - a_source_file_mappings ut_file_mappings := null, - a_test_file_mappings ut_file_mappings := null, - a_include_objects ut_varchar2_list := null, - 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_random_test_order boolean := false, - a_random_test_order_seed positive := null, - a_tags varchar2 := null, - a_include_schema_expr varchar2 := null, - a_include_object_expr varchar2 := null, - a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null - ); - - /** - * Rebuilds annotation cache for a specified schema and object type. - * It can be used to speedup execution of utPLSQL on a given schema - * if it is executed before initial call made to `ut.run` or `ut_runner.run` procedure. - * - * @param a_object_owner owner of objects to get annotations for - * @param a_object_type optional type of objects to get annotations for (defaults to 'PACKAGE') - */ - procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2 := null); - - /** - * Removes cached information about annotations for objects of specified type and specified owner - * - * @param a_object_owner optional - owner of objects to purge annotations for. If null (default) then all schemas are purged - * @param a_object_type optional - type of objects to purge annotations for. If null (default) then cache for all object types is purged - */ - procedure purge_cache(a_object_owner varchar2 := null, a_object_type varchar2 := null); - - - /** - * Returns a pipelined collection containing information about unit test suites and the tests contained in them - * - * @param a_owner owner of unit tests to retrieve (optional), if NULL, current schema is used - * @param a_package_name name of unit test package to retrieve (optional), if NULL all unit test packages are returned - * @return ut_suite_items_info table of objects - */ - function get_suites_info(a_owner varchar2, a_package_name varchar2) return ut_suite_items_info pipelined; - - /** - * Returns a pipelined collection containing information about unit test suites and the tests contained in them - * - * @param a_path a path from which we lookg for object or suite - */ - function get_suites_info(a_path varchar2 := null) return ut_suite_items_info pipelined; - - - /** - * Returns true if given procedure is a test in a test suite, false otherwise - * - * @param a_owner owner of test package - * @param a_package_name name of test package - * @param a_procedure_name name of test procedure - */ - function is_test(a_owner varchar2, a_package_name varchar2, a_procedure_name varchar2) return boolean; - - /** - * Returns true if given package is a test suite, false otherwise - * - * @param a_owner owner of test package - * @param a_package_name name of test package - */ - function is_suite(a_owner varchar2, a_package_name varchar2) return boolean; - - /** - * Returns true if given schema contains test suites, false otherwise - * - * @param a_owner owner of test package - */ - function has_suites(a_owner varchar2) return boolean; - - - type t_reporter_rec is record ( - reporter_object_name varchar2(250), -- full reporter name in format: owner.name - is_output_reporter varchar2(1) -- Y/N indication of reporter providing output for API - ); - type tt_reporters_info is table of t_reporter_rec ; - - /** Returns a list of available reporters. Gives information about whether a reporter is an output reporter or not - * - * @return tt_reporters_info - */ - function get_reporters_list return tt_reporters_info pipelined; - - procedure coverage_start(a_coverage_run_id raw); - - procedure coverage_stop; - -end ut_runner; -/ diff --git a/source/api/ut_suite_item_info.tpb b/source/api/ut_suite_item_info.tpb deleted file mode 100644 index 3315f7a16..000000000 --- a/source/api/ut_suite_item_info.tpb +++ /dev/null @@ -1,42 +0,0 @@ -create or replace type body ut_suite_item_info is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_disabled_reason varchar2, 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.disabled_reason := case when - a_disabled_flag = 1 then a_disabled_reason - else null - end; - 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 deleted file mode 100644 index 2c92f261d..000000000 --- a/source/api/ut_suite_item_info.tps +++ /dev/null @@ -1,32 +0,0 @@ -create or replace type ut_suite_item_info as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 ), -- the owner of test suite packages - object_name varchar2( 250 ), -- the name of test suite package - item_name varchar2( 250 ), -- the name of suite/test - item_description varchar2( 4000 ), -- the description of suite/suite item - 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_reason varchar2(4000), -- if disable flag is set then you can pass reason - 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_disabled_reason varchar2, 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 deleted file mode 100644 index 208098f9d..000000000 --- a/source/api/ut_suite_items_info.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_suite_items_info as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_suite_item_info -/ diff --git a/source/check_object_grants.sql b/source/check_object_grants.sql deleted file mode 100644 index 5f560e6b1..000000000 --- a/source/check_object_grants.sql +++ /dev/null @@ -1,46 +0,0 @@ -declare - $if dbms_db_version.version >= 18 $then - c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_CRYPTO'); - $else - c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_LOCK','DBMS_CRYPTO'); - $end - l_missing_grants varchar2(4000); - l_target_table varchar2(128); - l_owner_column varchar2(128); - - function get_view(a_dba_view_name varchar2) return varchar2 is - l_invalid_object_name exception; - l_result varchar2(128) := lower(a_dba_view_name); - pragma exception_init(l_invalid_object_name,-44002); - begin - l_result := dbms_assert.sql_object_name(l_result); - return l_result; - exception - when l_invalid_object_name then - return replace(l_result,'dba_','all_'); - end; - -begin - l_target_table := get_view('dba_tab_privs'); - l_owner_column := case when l_target_table like 'dba%' then 'owner' else 'table_schema' end; - execute immediate q'[ - select /*+ no_parallel */ listagg(' - '||object_name,CHR(10)) within group(order by object_name) - from ( - select column_value as object_name - from table(:l_expected_grants) - minus - select table_name as object_name - from ]'||l_target_table||q'[ - where grantee = SYS_CONTEXT('userenv','current_schema') - and ]'||l_owner_column||q'[ = 'SYS')]' - into l_missing_grants using c_expected_grants; - if l_missing_grants is not null then - raise_application_error( - -20000 - , 'The following object grants are missing for user "'||SYS_CONTEXT('userenv','current_schema')||'" to install utPLSQL:'||CHR(10) - ||l_missing_grants||CHR(10) - ||'Please read the installation documentation at http://utplsql.org/utPLSQL/' - ); - end if; -end; -/ diff --git a/source/check_sys_grants.sql b/source/check_sys_grants.sql deleted file mode 100644 index 79b657328..000000000 --- a/source/check_sys_grants.sql +++ /dev/null @@ -1,47 +0,0 @@ -define expected_grants = "&1" -declare - 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 - 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; - - with - x as ( - select '' as remove from dual - union all - select ' ANY' as remove from dual - ) - select listagg(' - '||privilege,CHR(10)) within group(order by privilege) - into l_missing_grants - from ( - select column_value as privilege - from table(l_expected_grants) - minus ( - select replace(p.privilege, x.remove) as privilege - from role_sys_privs p - join session_roles r using (role) - cross join x - union all - select replace(p.privilege, x.remove) as privilege - from user_sys_privs p - cross join x - ) - ); - if l_missing_grants is not null then - raise_application_error( - -20000 - , 'The following privileges are required for user "'||user||'" to install into schema "'||SYS_CONTEXT('userenv','current_schema')||'"'||CHR(10) - ||l_missing_grants - ||'Please read the installation documentation at http://utplsql.org/utPLSQL/' - ); - end if; -end; -/ diff --git a/source/core/annotations/ut_annotated_object.tps b/source/core/annotations/ut_annotated_object.tps deleted file mode 100644 index 3fda363fe..000000000 --- a/source/core/annotations/ut_annotated_object.tps +++ /dev/null @@ -1,25 +0,0 @@ -create type ut_annotated_object as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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), - object_name varchar2(250), - object_type varchar2(50), - parse_time timestamp, - annotations ut_annotations -) -/ - diff --git a/source/core/annotations/ut_annotated_objects.tps b/source/core/annotations/ut_annotated_objects.tps deleted file mode 100644 index c67c1bd53..000000000 --- a/source/core/annotations/ut_annotated_objects.tps +++ /dev/null @@ -1,20 +0,0 @@ -create type ut_annotated_objects as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_annotated_object -/ - diff --git a/source/core/annotations/ut_annotation.tps b/source/core/annotations/ut_annotation.tps deleted file mode 100644 index 3d0311571..000000000 --- a/source/core/annotations/ut_annotation.tps +++ /dev/null @@ -1,24 +0,0 @@ -create type ut_annotation as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - position number(5,0), - name varchar2(1000), - text varchar2(4000), - subobject_name varchar2(250) -) -/ - diff --git a/source/core/annotations/ut_annotation_cache.sql b/source/core/annotations/ut_annotation_cache.sql deleted file mode 100644 index 67149ce60..000000000 --- a/source/core/annotations/ut_annotation_cache.sql +++ /dev/null @@ -1,25 +0,0 @@ -create table ut_annotation_cache ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - cache_id number(20,0) not null, - annotation_position number(5,0) not null, - annotation_name varchar2(1000) not null, - annotation_text varchar2(4000), - subobject_name varchar2(250), - constraint ut_annotation_cache_pk primary key(cache_id, annotation_position), - constraint ut_annotation_cache_fk foreign key(cache_id) references ut_annotation_cache_info(cache_id) on delete cascade -); - -create index ut_annotation_cache_fk on ut_annotation_cache(cache_id); - diff --git a/source/core/annotations/ut_annotation_cache_info.sql b/source/core/annotations/ut_annotation_cache_info.sql deleted file mode 100644 index 167973a04..000000000 --- a/source/core/annotations/ut_annotation_cache_info.sql +++ /dev/null @@ -1,24 +0,0 @@ -create table ut_annotation_cache_info ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - cache_id number(20,0) not null, - object_owner varchar2(250) not null, - object_name varchar2(250) not null, - object_type varchar2(250) not null, - parse_time timestamp not null, - constraint ut_annotation_cache_info_pk primary key(cache_id) using index, - constraint ut_annotation_cache_info_uk unique (object_owner, object_type, object_name) using index, - constraint ut_annotation_cache_info_fk foreign key(object_owner, object_type) references ut_annotation_cache_schema(object_owner, object_type) on delete cascade -) organization index; - diff --git a/source/core/annotations/ut_annotation_cache_manager.pkb b/source/core/annotations/ut_annotation_cache_manager.pkb deleted file mode 100644 index e1131b3bd..000000000 --- a/source/core/annotations/ut_annotation_cache_manager.pkb +++ /dev/null @@ -1,226 +0,0 @@ -create or replace package body ut_annotation_cache_manager as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - procedure update_cache(a_object ut_annotated_object) is - l_cache_id integer; - l_timestamp timestamp := systimestamp; - pragma autonomous_transaction; - begin - update /*+ no_parallel */ ut_annotation_cache_schema s - set s.max_parse_time = l_timestamp - where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner; - - if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_annotation_cache_schema s - (object_owner, object_type, max_parse_time) - values (a_object.object_owner, a_object.object_type, l_timestamp); - end if; - - -- if not in trigger, or object has annotations - if a_object.annotations is not null and a_object.annotations.count > 0 then - - update /*+ no_parallel */ ut_annotation_cache_info i - set i.parse_time = l_timestamp - 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 /*+ no_parallel */ 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, l_timestamp) - returning cache_id into l_cache_id; - end if; - - delete /*+ no_parallel */ from ut_annotation_cache c where cache_id = l_cache_id; - - insert /*+ no_parallel */ into ut_annotation_cache - (cache_id, annotation_position, annotation_name, annotation_text, subobject_name) - select /*+ no_parallel */ l_cache_id, a.position, a.name, a.text, a.subobject_name - from table(a_object.annotations) a; - elsif a_object.annotations is null or a_object.annotations.count = 0 then - ut_annotation_cache_manager.remove_from_cache( - ut_annotation_objs_cache_info( - ut_annotation_obj_cache_info(a_object.object_owner, a_object.object_name, a_object.object_type, 'Y', null) - ) - ); - end if; - commit; - end; - - - procedure reset_objects_cache(a_objects ut_annotation_objs_cache_info) is - l_timestamp timestamp := systimestamp; - pragma autonomous_transaction; - begin - - delete /*+ no_parallel */ from ut_annotation_cache c - where c.cache_id - in (select /*+ no_parallel */ i.cache_id - from ut_annotation_cache_info i - join table (a_objects) o - on o.object_name = i.object_name - and o.object_type = i.object_type - and o.object_owner = i.object_owner - and o.needs_refresh = 'Y' - ); - - update /*+ no_parallel */ ut_annotation_cache_schema s - set s.max_parse_time = l_timestamp - where (s.object_owner, s.object_type) - in ( - select /*+ no_parallel */ o.object_owner, o.object_type - from table(a_objects) o - where o.needs_refresh = 'Y' - ); - - if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_annotation_cache_schema s - (object_owner, object_type, max_parse_time) - select /*+ no_parallel */ distinct o.object_owner, o.object_type, l_timestamp - from table(a_objects) o - where o.needs_refresh = 'Y'; - end if; - - merge /*+ no_parallel */ - into ut_annotation_cache_info i - using (select /*+ no_parallel */ o.object_name, o.object_type, o.object_owner - from table(a_objects) o - where o.needs_refresh = 'Y' - ) o - on (o.object_name = i.object_name - and o.object_type = i.object_type - and o.object_owner = i.object_owner) - when matched then - update - set parse_time = l_timestamp - when not matched then insert - (cache_id, object_owner, object_name, object_type, parse_time) - values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, l_timestamp); - - commit; - end; - - function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info is - l_result ut_annotation_objs_cache_info; - begin - select /*+ no_parallel */ ut_annotation_obj_cache_info( - object_owner => i.object_owner, - object_name => i.object_name, - object_type => i.object_type, - needs_refresh => 'N', - parse_time => i.parse_time - ) - bulk collect into l_result - from ut_annotation_cache_info i - where i.object_owner = a_object_owner - and i.object_type = a_object_type - and (i.parse_time > a_parsed_after or a_parsed_after is null); - return l_result; - 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 /*+ no_parallel */ * - 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 set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2) is - pragma autonomous_transaction; - begin - update /*+ no_parallel */ ut_annotation_cache_schema s - set s.full_refresh_time = s.max_parse_time - where s.object_owner = a_object_owner - and s.object_type = a_object_type; - commit; - end; - - procedure remove_from_cache(a_objects ut_annotation_objs_cache_info) is - pragma autonomous_transaction; - begin - - delete /*+ no_parallel */ from ut_annotation_cache_info i - where exists ( - select /*+ no_parallel */ 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; - - function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor is - l_results sys_refcursor; - begin - open l_results for - select /*+ no_parallel */ ut_annotated_object( - i.object_owner, i.object_name, i.object_type, i.parse_time, - cast( - collect( - ut_annotation( - c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name - ) order by c.annotation_position - ) as ut_annotations - ) - ) as annotated_object - from ut_annotation_cache_info i - join ut_annotation_cache c on i.cache_id = c.cache_id - where i.object_owner = a_object_owner and i.object_type = a_object_type - and (i.parse_time > a_parsed_after or a_parsed_after is null) - group by i.object_owner, i.object_type, i.object_name, i.parse_time; - return l_results; - end; - - procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is - l_filter varchar2(32767); - l_cache_filter varchar2(32767); - pragma autonomous_transaction; - begin - if a_object_owner is null and a_object_type is null then - l_filter := ':a_object_owner is null and :a_object_type is null'; - l_cache_filter := l_filter; - else - l_filter := case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end; - l_filter := l_filter || ' and ' || case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end; - l_cache_filter := ' c.cache_id in (select /*+ no_parallel */ i.cache_id from ut_annotation_cache_info i where ' || l_filter || ' )'; - end if; - execute immediate 'delete /*+ no_parallel */ from ut_annotation_cache c where ' || l_cache_filter - using a_object_owner, a_object_type; - - execute immediate ' delete /*+ no_parallel */ from ut_annotation_cache_info i where ' || l_filter - using a_object_owner, a_object_type; - - execute immediate ' delete /*+ no_parallel */ from ut_annotation_cache_schema s where ' || l_filter - using a_object_owner, a_object_type; - - commit; - end; - -end; -/ diff --git a/source/core/annotations/ut_annotation_cache_manager.pks b/source/core/annotations/ut_annotation_cache_manager.pks deleted file mode 100644 index 1e9734934..000000000 --- a/source/core/annotations/ut_annotation_cache_manager.pks +++ /dev/null @@ -1,72 +0,0 @@ -create or replace package ut_annotation_cache_manager authid definer as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - 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 - * We do not pass a collection here to avoid excessive memory usage - * when dealing with large number of objects - * - * @param a_object a `ut_annotated_object` containing object name, type, owner and `ut_annotations` - */ - procedure update_cache(a_object ut_annotated_object); - - /** - * Returns a ref_cursor containing `ut_annotated_object` as result - * Range of data returned is limited by the input collection o cache object info - * - * @param a_cached_objects - list of `ut_annotation_objs_cache_info` containing objects to get from cache - * @param a_min_parse_time - limit results to annotations parsed after specified time only, - * if null - all cached annotations for given objects are returned - */ - function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor; - - procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2); - - function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info; - - /** - * Returns information about all objects stored in annotation cache - */ - function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info; - - /** - * Resets cached information about annotations for objects on the list and updates parse_time in cache info table. - * - * @param a_objects a `ut_annotation_objs_cache_info` list with information about objects to remove annotations for - */ - procedure reset_objects_cache(a_objects ut_annotation_objs_cache_info); - - /** - * Removes information about objects on the list - * - * @param a_objects a `ut_annotation_objs_cache_info` list with information about objects to remove from cache - */ - procedure remove_from_cache(a_objects ut_annotation_objs_cache_info); - - /** - * Removes cached information about annotations for objects of specified type and specified owner - * - * @param a_object_owner owner of objects to purge annotations for - * @param a_object_type type of objects to purge annotations for - */ - procedure purge_cache(a_object_owner varchar2, a_object_type varchar2); - -end; -/ diff --git a/source/core/annotations/ut_annotation_cache_schema.sql b/source/core/annotations/ut_annotation_cache_schema.sql deleted file mode 100644 index 8889b9abf..000000000 --- a/source/core/annotations/ut_annotation_cache_schema.sql +++ /dev/null @@ -1,21 +0,0 @@ -create table ut_annotation_cache_schema ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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, - max_parse_time date not null, - full_refresh_time timestamp, - 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 deleted file mode 100644 index b371b382b..000000000 --- a/source/core/annotations/ut_annotation_cache_seq.sql +++ /dev/null @@ -1,16 +0,0 @@ -create sequence ut_annotation_cache_seq - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ -cache 100; - diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb deleted file mode 100644 index 65f7b3e40..000000000 --- a/source/core/annotations/ut_annotation_manager.pkb +++ /dev/null @@ -1,326 +0,0 @@ -create or replace package body ut_annotation_manager as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - ------------------------------ - --private definitions - - function user_can_see_whole_schema( a_schema_name varchar2 ) return boolean is - begin - return sys_context('userenv','current_user') = a_schema_name - or ut_metadata.user_has_execute_any_proc() - or ut_metadata.is_object_visible('dba_objects'); - end; - - function get_non_existing_objects( a_object_owner varchar2, a_object_type varchar2 ) return ut_annotation_objs_cache_info is - l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_object_to_delete ut_annotation_objs_cache_info := ut_annotation_objs_cache_info(); - l_cached_objects ut_annotation_objs_cache_info; - begin - l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type ); - - if l_cached_objects is not empty then - execute immediate 'select /*+ no_parallel cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */ - value(i) - from table( :l_data ) i - where - not exists ( - select 1 from '||l_objects_view||q'[ o - where o.owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = i.object_type - and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' - and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - )]' - bulk collect into l_object_to_delete - using l_cached_objects; - end if; - return l_object_to_delete; - end; - - function get_objects_to_refresh( - a_object_owner varchar2, - a_object_type varchar2, - a_modified_after timestamp - ) return ut_annotation_objs_cache_info is - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_refresh_needed boolean; - l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_cached_objects ut_annotation_objs_cache_info; - l_result ut_annotation_objs_cache_info := ut_annotation_objs_cache_info(); - begin - ut_event_manager.trigger_event( 'get_objects_to_refresh - start', ut_key_anyvalues().put('ut_trigger_check.is_alive()',ut_trigger_check.is_alive()) ); - - l_refresh_needed := ( ut_trigger_check.is_alive() = false ) or a_modified_after is null; - if l_refresh_needed then - --limit the list to objects that exist and are visible to the invoking user - --enrich the list by info about cache validity - l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type, a_modified_after ); - execute immediate - 'select /*+ no_parallel cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */ - '||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 => 'Y', - parse_time => c.parse_time - ) - from ]'||l_objects_view||' o - left join table( cast(:l_cached_objects as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) c - on o.owner = c.object_owner - and o.object_name = c.object_name - and o.object_type = c.object_type - where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' - and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - and case when o.last_ddl_time < cast(c.parse_time as date) then 'N' else 'Y' end = 'Y' - and ]' - || case - when a_modified_after is null - then ':a_modified_after is null' - else 'o.last_ddl_time >= cast(:a_modified_after as date)' - end - bulk collect into l_result using l_cached_objects, a_modified_after; - end if; - ut_event_manager.trigger_event('get_objects_to_refresh - end (count='||l_result.count||')'); - return l_result; - end; - - function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is - l_result sys_refcursor; - l_sources_view varchar2(200) := ut_metadata.get_source_view_name(); - l_card natural; - begin - l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh)); - open l_result for - q'[select /*+ no_parallel */ x.name, x.text - from (select /*+ cardinality( r ]'||l_card||q'[ )*/ - s.name, s.text, s.line, - max(case when s.text like '%--%\%%' escape '\' - and regexp_like(s.text,'^\s*--\s*%') - then 'Y' else 'N' end - ) - over(partition by s.name) is_annotated - from table(:a_objects_to_refresh) r - join ]'||l_sources_view||q'[ s - on s.name = r.object_name - and s.owner = r.object_owner - and s.type = r.object_type - where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' - and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - ) x - where x.is_annotated = 'Y' - order by x.name, x.line]' - using a_objects_to_refresh; - - return l_result; - end; - - procedure build_annot_cache_for_sources( - a_object_owner varchar2, - a_object_type varchar2, - a_sources_cursor sys_refcursor - ) is - l_annotations ut_annotations; - 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); - l_object_lines dbms_preprocessor.source_lines_t; - l_parse_time date := sysdate; - pragma autonomous_transaction; - begin - loop - 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, 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) - ); - l_object_lines.delete; - end if; - - l_name := l_names(i); - l_object_lines(l_object_lines.count+1) := l_lines(i); - end loop; - exit when a_sources_cursor%notfound; - - end loop; - if a_sources_cursor%rowcount > 0 then - 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) - ); - l_object_lines.delete; - end if; - close a_sources_cursor; - end; - - - procedure validate_annotation_cache( - a_object_owner varchar2, - a_object_type varchar2, - a_modified_after timestamp := null - ) is - l_objects_to_refresh ut_annotation_objs_cache_info; - l_modified_after timestamp := a_modified_after; - begin - if ut_annotation_cache_manager.get_cache_schema_info(a_object_owner, a_object_type).full_refresh_time is null then - l_modified_after := null; - end if; - - l_objects_to_refresh := get_objects_to_refresh(a_object_owner, a_object_type, l_modified_after); - - ut_event_manager.trigger_event('validate_annotation_cache - start (l_objects_to_refresh.count = '||l_objects_to_refresh.count||')'); - - - if user_can_see_whole_schema( a_object_owner ) then - --Remove non existing objects from cache only when user can see whole schema - ut_annotation_cache_manager.remove_from_cache( get_non_existing_objects( a_object_owner, a_object_type ) ); - end if; - - --if some source needs parsing and putting into cache - if l_objects_to_refresh.count > 0 then - --Delete annotations for objects that are to be refreshed - ut_annotation_cache_manager.reset_objects_cache(l_objects_to_refresh); - --Rebuild cache from objects source - build_annot_cache_for_sources( - a_object_owner, a_object_type, - get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_refresh) - ); - end if; - - if l_modified_after is null then - if user_can_see_whole_schema( a_object_owner ) then - ut_annotation_cache_manager.set_fully_refreshed( a_object_owner, a_object_type ); - else - -- if user cannot see full schema - we dont mark it as fully refreshed - -- it will get refreshed each time until someone with proper privs will refresh it - null; - end if; - end if; - ut_event_manager.trigger_event('validate_annotation_cache - end'); - end; - - ------------------------------------------------------------ - --public definitions - ------------------------------------------------------------ - procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is - begin - validate_annotation_cache( a_object_owner, a_object_type ); - end; - - procedure trigger_obj_annotation_rebuild is - l_sql_text ora_name_list_t; - l_parts binary_integer; - 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'); - -- remove "OWNER." from create or replace statement. - -- Owner is not supported along with AUTHID - see issue https://github.com/utPLSQL/utPLSQL/issues/1088 - l_sql_clob := regexp_replace(l_sql_clob, '^(package|type)\s+("?[[:alpha:]][[:alnum:]$#_]*"?\.)(.*)', '\1 \3', 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 /*+ no_parallel */ 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 /*+ no_parallel */ :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 /*+ no_parallel */ 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; - - 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( - ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y', null) - ) - ); - end if; - end if; - end; - - function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_modified_after timestamp) return sys_refcursor is - l_cursor sys_refcursor; - begin - ut_event_manager.trigger_event('get_annotated_objects - start: a_modified_after='||ut_utils.to_string(a_modified_after)); - validate_annotation_cache(a_object_owner, a_object_type, a_modified_after); - - --pipe annotations from cache - l_cursor := ut_annotation_cache_manager.get_annotations_parsed_since(a_object_owner, a_object_type, a_modified_after); - ut_event_manager.trigger_event('get_annotated_objects - end'); - return l_cursor; - end; - - procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is - begin - ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type); - end; - -end; -/ diff --git a/source/core/annotations/ut_annotation_manager.pks b/source/core/annotations/ut_annotation_manager.pks deleted file mode 100644 index 20fcd810f..000000000 --- a/source/core/annotations/ut_annotation_manager.pks +++ /dev/null @@ -1,60 +0,0 @@ -create or replace package ut_annotation_manager authid current_user as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Builds annotations out of database source code by reading it from cache - */ - - /** - * Gets annotations for all objects of a specified type for database schema. - * Annotations that are stale or missing are parsed and placed in persistent cache. - * After placing in cache, annotation data is returned as ref_cursor. - * - * @param a_object_owner owner of objects to get annotations for - * @param a_object_type type of objects to get annotations for - * @param a_modified_after return only objects modified after thr timestamp - * @return cursor containing annotated objects along with annotations for each object (nested) - */ - function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_modified_after timestamp) return sys_refcursor; - - /** - * Rebuilds annotation cache for a specified schema and object type. - * It can be used to speedup initial execution of utPLSQL on a given schema - * if it is executed before any call is made to `ut.run` or `ut_runner.run` procedure. - * - * @param a_object_owner owner of objects to get annotations for - * @param a_object_type type of objects to get annotations for - */ - 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 - * - * @param a_object_owner owner of objects to purge annotations for - * @param a_object_type type of objects to purge annotations for - */ - procedure purge_cache(a_object_owner varchar2, a_object_type varchar2); - - -end; -/ diff --git a/source/core/annotations/ut_annotation_obj_cache_info.tps b/source/core/annotations/ut_annotation_obj_cache_info.tps deleted file mode 100644 index 1db3fd190..000000000 --- a/source/core/annotations/ut_annotation_obj_cache_info.tps +++ /dev/null @@ -1,24 +0,0 @@ -create type ut_annotation_obj_cache_info as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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), - object_name varchar2(250), - object_type varchar2(250), - needs_refresh varchar2(1), - parse_time timestamp - ) -/ diff --git a/source/core/annotations/ut_annotation_objs_cache_info.tps b/source/core/annotations/ut_annotation_objs_cache_info.tps deleted file mode 100644 index fc96e7d25..000000000 --- a/source/core/annotations/ut_annotation_objs_cache_info.tps +++ /dev/null @@ -1,19 +0,0 @@ -create type ut_annotation_objs_cache_info as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_annotation_obj_cache_info -/ diff --git a/source/core/annotations/ut_annotation_parser.pkb b/source/core/annotations/ut_annotation_parser.pkb deleted file mode 100644 index 10bb76b3c..000000000 --- a/source/core/annotations/ut_annotation_parser.pkb +++ /dev/null @@ -1,252 +0,0 @@ -create or replace package body ut_annotation_parser as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - ------------------------------ - --private definitions - - type tt_comment_list is table of varchar2(32767) index by binary_integer; - - gc_annotation_qualifier constant varchar2(1) := '%'; - gc_annot_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*-- *('||gc_annotation_qualifier||'.*?)$'; -- chr(09) is a tab character - gc_comment_replacer_patter constant varchar2(50) := '{COMMENT#%N%}'; - gc_comment_replacer_regex_ptrn constant varchar2(25) := '{COMMENT#(\d+)}'; - gc_regexp_identifier constant varchar2(50) := '[[:alpha:]][[:alnum:]$#_]*'; - gc_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' || - gc_regexp_identifier || ')'; - gc_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || gc_regexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?'; - - - procedure add_annotation( - a_annotations in out nocopy ut_annotations, - a_position positiven, - a_comment varchar2, - a_subobject_name varchar2 := null - ) is - l_annotation_str varchar2(32767); - l_annotation_text varchar2(32767); - l_annotation_name varchar2(1000); - begin - -- strip everything except the annotation itself (spaces and others) - l_annotation_str := regexp_substr(a_comment, gc_annotation_pattern, 1, 1, modifier => 'i'); - if l_annotation_str is not null then - - -- get the annotation name and it's parameters if present - l_annotation_name := lower(regexp_substr(l_annotation_str ,'%(' || gc_regexp_identifier || ')', subexpression => 1)); - l_annotation_text := trim(regexp_substr(l_annotation_str, '\((.*?)\)\s*$', subexpression => 1)); - - a_annotations.extend; - a_annotations( a_annotations.last) := - ut_annotation(a_position, l_annotation_name, l_annotation_text, a_subobject_name); - end if; - end; - - procedure delete_processed_comments( a_comments in out nocopy tt_comment_list, a_annotations ut_annotations ) is - l_loop_index binary_integer := 1; - begin - l_loop_index := a_annotations.first; - while l_loop_index is not null loop - a_comments.delete( a_annotations(l_loop_index).position ); - l_loop_index := a_annotations.next( l_loop_index ); - end loop; - end; - - procedure add_annotations( - a_annotations in out nocopy ut_annotations, - a_source varchar2, - a_comments tt_comment_list, - a_subobject_name varchar2 := null - ) is - l_loop_index binary_integer := 1; - l_annotation_index binary_integer; - begin - -- loop while there are unprocessed comment blocks - while 0 != nvl(regexp_instr(srcstr => a_source - ,pattern => gc_comment_replacer_regex_ptrn - ,occurrence => l_loop_index - ,subexpression => 1) - ,0) loop - - -- define index of the comment block and get it's content from cache - l_annotation_index := regexp_substr( a_source ,gc_comment_replacer_regex_ptrn ,1 ,l_loop_index ,subexpression => 1); - add_annotation( a_annotations, l_annotation_index, a_comments( l_annotation_index ), a_subobject_name ); - l_loop_index := l_loop_index + 1; - end loop; - - end add_annotations; - - procedure add_procedure_annotations(a_annotations in out nocopy ut_annotations, a_source clob, a_comments in out nocopy tt_comment_list) is - l_proc_comments varchar2(32767); - l_proc_name varchar2(250); - l_annot_proc_ind number; - l_annot_proc_block varchar2(32767); - begin - -- loop through procedures and functions of the package and get all the comment blocks just before it's declaration - l_annot_proc_ind := 1; - loop - --find annotated procedure index - l_annot_proc_ind := regexp_instr(srcstr => a_source - ,pattern => gc_annotation_block_pattern - ,occurrence => 1 - ,modifier => 'i' - ,position => l_annot_proc_ind); - exit when l_annot_proc_ind = 0; - - --get the annotations with procedure name - l_annot_proc_block := regexp_substr(srcstr => a_source - ,pattern => gc_annotation_block_pattern - ,position => l_annot_proc_ind - ,occurrence => 1 - ,modifier => 'i'); - - --extract the annotations - l_proc_comments := trim(regexp_substr(srcstr => l_annot_proc_block - ,pattern => gc_annotation_block_pattern - ,modifier => 'i' - ,subexpression => 1)); - --extract the procedure name - l_proc_name := trim(regexp_substr(srcstr => l_annot_proc_block - ,pattern => gc_annotation_block_pattern - ,modifier => 'i' - ,subexpression => 5)); - - -- parse the comment block for the syntactically correct annotations and store them as an array - add_annotations(a_annotations, l_proc_comments, a_comments, l_proc_name); - - l_annot_proc_ind := instr(a_source, ';', l_annot_proc_ind + length(l_annot_proc_block) ); - end loop; - end add_procedure_annotations; - - function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is - l_comments tt_comment_list; - l_comment_pos binary_integer; - l_comment_line binary_integer; - l_comment_replacer varchar2(50); - l_source clob := a_source; - begin - l_comment_pos := 1; - loop - - l_comment_pos := regexp_instr(srcstr => a_source - ,pattern => gc_annot_comment_pattern - ,occurrence => 1 - ,modifier => 'm' - ,position => l_comment_pos); - - exit when l_comment_pos = 0; - - -- position index is shifted by 1 because gc_annot_comment_pattern contains ^ as first sign - -- but after instr index already points to the char on that line - l_comment_pos := l_comment_pos-1; - l_comment_line := length(substr(a_source,1,l_comment_pos))-length(replace(substr(a_source,1,l_comment_pos),chr(10)))+1; - l_comments(l_comment_line) := trim(regexp_substr(srcstr => a_source - ,pattern => gc_annot_comment_pattern - ,occurrence => 1 - ,position => l_comment_pos - ,modifier => 'm' - ,subexpression => 2)); - - l_comment_replacer := replace(gc_comment_replacer_patter, '%N%', l_comment_line); - - l_source := regexp_replace(srcstr => a_source - ,pattern => gc_annot_comment_pattern - ,replacestr => l_comment_replacer - ,position => l_comment_pos - ,occurrence => 1 - ,modifier => 'm'); - dbms_lob.freetemporary(a_source); - a_source := l_source; - dbms_lob.freetemporary(l_source); - l_comment_pos := l_comment_pos + length(l_comment_replacer); - - end loop; - - ut_utils.debug_log(a_source); - return l_comments; - end extract_and_replace_comments; - - ------------------------------------------------------------ - --public definitions - ------------------------------------------------------------ - - function parse_object_annotations(a_source clob) return ut_annotations is - l_source clob := a_source; - l_comments tt_comment_list; - l_annotations ut_annotations := ut_annotations(); - l_result ut_annotations; - l_comment_index positive; - begin - - l_source := ut_utils.replace_multiline_comments(l_source); - - -- replace all single line comments with {COMMENT#12} element and store it's content for easier processing - -- this call modifies l_source - l_comments := extract_and_replace_comments(l_source); - - add_procedure_annotations(l_annotations, l_source, l_comments); - - delete_processed_comments(l_comments, l_annotations); - - --at this point, only the comments not related to procedures are left, so we process them all as top-level - l_comment_index := l_comments.first; - while l_comment_index is not null loop - add_annotation( l_annotations, l_comment_index, l_comments( l_comment_index ) ); - l_comment_index := l_comments.next(l_comment_index); - end loop; - - dbms_lob.freetemporary(l_source); - - select /*+ no_parallel */ value(x) bulk collect into l_result from table(l_annotations) x order by x.position; - - return l_result; - end parse_object_annotations; - - 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(); - ex_package_is_wrapped exception; - pragma exception_init(ex_package_is_wrapped, -24241); - source_text_is_empty exception; - pragma exception_init(source_text_is_empty, -24236); - begin - if a_source_lines.count > 0 then - --convert to post-processed source clob - begin - --get post-processed source - 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))); - end loop; - --parse annotations - l_annotations := parse_object_annotations(l_source); - dbms_lob.freetemporary(l_source); - exception - when ex_package_is_wrapped or source_text_is_empty then - null; - end; - end if; - return l_annotations; - end; - -end; -/ diff --git a/source/core/annotations/ut_annotation_parser.pks b/source/core/annotations/ut_annotation_parser.pks deleted file mode 100644 index 2f474c883..000000000 --- a/source/core/annotations/ut_annotation_parser.pks +++ /dev/null @@ -1,44 +0,0 @@ -create or replace package ut_annotation_parser authid current_user as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Parses the source passed as input parameter and returns annotations - */ - - /** - * Runs the source lines through dbms_preprocessor to remove lines that were not compiled (conditional compilation) - * Parses the processed source code and converts it to annotations - * - * @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, a_object_type varchar2) return ut_annotations; - - - /** - * - * @private - * Parses source code and converts it to annotations - * - * @param a_source_lines ordered lines of source code to be parsed - * @return array containing annotations - */ - function parse_object_annotations(a_source clob) return ut_annotations; - -end; -/ diff --git a/source/core/annotations/ut_annotations.tps b/source/core/annotations/ut_annotations.tps deleted file mode 100644 index a6579d236..000000000 --- a/source/core/annotations/ut_annotations.tps +++ /dev/null @@ -1,19 +0,0 @@ -create type ut_annotations - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ -as table of ut_annotation -/ diff --git a/source/core/annotations/ut_trigger_annotation_parsing.trg b/source/core/annotations/ut_trigger_annotation_parsing.trg deleted file mode 100644 index 437b7742d..000000000 --- a/source/core/annotations/ut_trigger_annotation_parsing.trg +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 34e43ba46..000000000 --- a/source/core/annotations/ut_trigger_check.pkb +++ /dev/null @@ -1,39 +0,0 @@ -create or replace package body ut_trigger_check is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 - execute immediate 'create or replace synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object'; - 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 deleted file mode 100644 index cee0b06fd..000000000 --- a/source/core/annotations/ut_trigger_check.pks +++ /dev/null @@ -1,31 +0,0 @@ -create or replace package ut_trigger_check authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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/dbms_plssqlcode.sql b/source/core/coverage/dbms_plssqlcode.sql deleted file mode 100644 index 1ae287207..000000000 --- a/source/core/coverage/dbms_plssqlcode.sql +++ /dev/null @@ -1,67 +0,0 @@ -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - execute immediate q'[ - create table dbmspcc_blocks ( - run_id number(38, 0), - object_id number(38, 0), - block number(38, 0), - line number(38, 0) constraint dbmspcc_blocks_line_nn not null enable, - col number(38, 0) constraint dbmspcc_blocks_col_nn not null enable, - covered number(1, 0) constraint dbmspcc_blocks_covered_nn not null enable, - not_feasible number(1, 0) constraint dbmspcc_blocks_not_feasible_nn not null enable, - constraint dbmspcc_blocks_block_ck check ( block >= 0 ) enable, - constraint dbmspcc_blocks_line_ck check ( line >= 0 ) enable, - constraint dbmspcc_blocks_col_ck check ( col >= 0 ) enable, - constraint dbmspcc_blocks_covered_ck check ( covered in ( 0, 1 ) ) enable, - constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in ( 0, 1 ) ) enable, - constraint dbmspcc_blocks_pk primary key ( run_id, object_id, block ) using index - )]'; - end if; -end; -/ -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - execute immediate q'[ - create table dbmspcc_runs ( - run_id number(38, 0), - run_comment varchar2(4000 byte), - run_owner varchar2(128 byte) constraint dbmspcc_runs_run_owner_nn not null enable, - run_timestamp date constraint dbmspcc_runs_run_timestamp_nn not null enable, - constraint dbmspcc_runs_pk primary key ( run_id ) using index enable - )]'; - end if; -end; -/ -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - execute immediate q'[ - create table dbmspcc_units ( - run_id number(38, 0), - object_id number(38, 0), - owner varchar2(128 byte) constraint dbmspcc_units_owner_nn not null enable, - name varchar2(128 byte) constraint dbmspcc_units_name_nn not null enable, - type varchar2(12 byte) constraint dbmspcc_units_type_nn not null enable, - last_ddl_time date constraint dbmspcc_units_last_ddl_time_nn not null enable, - constraint dbmspcc_units_pk primary key ( run_id, object_id ) using index enable - )]'; - end if; -end; -/ diff --git a/source/core/coverage/proftab.sql b/source/core/coverage/proftab.sql deleted file mode 100644 index 62c69dc9a..000000000 --- a/source/core/coverage/proftab.sql +++ /dev/null @@ -1,106 +0,0 @@ -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'PLSQL_PROFILER_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - execute immediate q'[create table plsql_profiler_runs -( - runid number primary key, -- unique run identifier, - -- from plsql_profiler_runnumber - related_run number, -- runid of related run (for client/ - -- server correlation) - run_owner varchar2(128), -- user who started run - run_date date, -- start time of run - run_comment varchar2(2047), -- user provided comment for this run - run_total_time number, -- elapsed time for this run - run_system_info varchar2(2047), -- currently unused - run_comment1 varchar2(2047), -- additional comment - spare1 varchar2(256) -- unused -)]'; - execute immediate q'[comment on table plsql_profiler_runs is - 'Run-specific information for the PL/SQL profiler']'; - dbms_output.put_line('PLSQL_PROFILER_RUNS table created'); - end if; -end; -/ - -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - execute immediate q'[create table plsql_profiler_units -( - runid number references plsql_profiler_runs, - unit_number number, -- internally generated library unit # - unit_type varchar2(128), -- library unit type - unit_owner varchar2(128), -- library unit owner name - unit_name varchar2(128), -- library unit name - -- timestamp on library unit, can be used to detect changes to - -- unit between runs - unit_timestamp date, - total_time number DEFAULT 0 NOT NULL, - spare1 number, -- unused - spare2 number, -- unused - -- - primary key (runid, unit_number) -)]'; - execute immediate q'[comment on table plsql_profiler_units is - 'Information about each library unit in a run']'; - dbms_output.put_line('PLSQL_PROFILER_UNITS table created'); - end if; -end; -/ - -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_DATA' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - execute immediate q'[create table plsql_profiler_data -( - runid number, -- unique (generated) run identifier - unit_number number, -- internally generated library unit # - line# number not null, -- line number in unit - total_occur number, -- number of times line was executed - total_time number, -- total time spent executing line - min_time number, -- minimum execution time for this line - max_time number, -- maximum execution time for this line - spare1 number, -- unused - spare2 number, -- unused - spare3 number, -- unused - spare4 number, -- unused - -- - primary key (runid, unit_number, line#), - foreign key (runid, unit_number) references plsql_profiler_units -)]'; - execute immediate q'[comment on table plsql_profiler_data is - 'Accumulated data from all profiler runs']'; - dbms_output.put_line('PLSQL_PROFILER_DATA table created'); - end if; -end; -/ - -declare - l_seq_exist number; -begin - select count(*) into l_seq_exist from - (select sequence_name from all_sequences where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' and sequence_owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'PLSQL_PROFILER_RUNNUMBER' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_seq_exist = 0 then - execute immediate q'[create sequence plsql_profiler_runnumber start with 1 nocache]'; - dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER created'); - end if; -end; -/ - diff --git a/source/core/coverage/ut_coverage.pkb b/source/core/coverage/ut_coverage.pkb deleted file mode 100644 index 7eb5a34c2..000000000 --- a/source/core/coverage/ut_coverage.pkb +++ /dev/null @@ -1,327 +0,0 @@ -create or replace package body ut_coverage is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - g_develop_mode boolean not null := false; - g_is_started boolean not null := false; - g_coverage_run_id raw(32); - - procedure set_develop_mode(a_develop_mode in boolean) is - begin - g_develop_mode := a_develop_mode; - end; - - function is_develop_mode return boolean is - begin - return g_develop_mode; - end; - - function get_cov_sources_sql(a_coverage_options ut_coverage_options, a_skip_objects ut_object_names) return varchar2 is - l_result varchar2(32767); - l_full_name varchar2(32767); - l_join_mappings varchar2(32767); - l_filters varchar2(32767); - l_mappings_cardinality integer := 0; - l_regex_exc_filters varchar2(32767); - begin - l_result := q'[ - with - sources as ( - select /*+ cardinality(f {mappings_cardinality}) */ - {l_full_name} as full_name, s.owner, s.name, s.type, - s.line - - case - when s.type = 'TRIGGER' - then - /* calculate offset of line number for trigger source in coverage reporting */ - min(case when lower(s.text) like '%begin%' or lower(s.text) like '%declare%' or lower(s.text) like '%compound%' then s.line-1 end) - over (partition by s.owner, s.type, s.name) - else 0 - end as line, - s.text - from {sources_view} s {join_file_mappings} - where s.type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER') - {filters} - {regex_exc_filters} - and not exists ( - select /*+ cardinality(el {excuded_objects_cardinality})*/ 1 - from table(:l_excluded_objects) el - where s.owner = el.owner and s.name = el.name - ) - ), - coverage_sources as ( - select full_name, owner, name, type, line, text, - case - when - -- to avoid execution of regexp_like on every line - -- first do a rough check for existence of search pattern keyword - (lower(s.text) like '%procedure%' - or lower(s.text) like '%function%' - or lower(s.text) like '%begin%' - or lower(s.text) like '%end%' - or lower(s.text) like '%package%' - ) and - regexp_like( - s.text, - '^([\t ]*(((not)?\s*(overriding|final|instantiable)[\t ]*)*(static|constructor|member)?[\t ]*(procedure|function)|package([\t ]+body)|begin|end([\t ]+\S+)*[ \t]*;))', 'i' - ) - then 'Y' - end as to_be_skipped - from sources s - ) - select /*+ no_parallel */ full_name, owner, name, type, line, to_be_skipped, text - from coverage_sources s - -- Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter - where not exists ( - select /*+ cardinality(el {skipped_objects_cardinality})*/ 1 - from table(:l_skipped_objects) el - where s.owner = el.owner and s.name = el.name - ) - and line > 0 - ]'; - - if a_coverage_options.file_mappings is not empty then - l_mappings_cardinality := ut_utils.scale_cardinality(cardinality(a_coverage_options.file_mappings)); - l_full_name := 'f.file_name'; - l_join_mappings := ' - join table(:file_mappings) f - on s.name = f.object_name - and s.type = f.object_type - and s.owner = f.object_owner'; - elsif coalesce(a_coverage_options.include_schema_expr,a_coverage_options.include_object_expr) is not null then - l_full_name := q'[lower(s.type||' '||s.owner||'.'||s.name)]'; - if a_coverage_options.include_schema_expr is not null then - l_filters := q'[and regexp_like(s.owner,:a_include_schema_expr,'i')]'; - else - l_filters := 'and :a_include_schema_expr is null'; - end if; - if a_coverage_options.include_object_expr is not null then - l_filters := l_filters|| q'[ and regexp_like(s.name,:a_include_object_expr,'i')]'; - else - l_filters := l_filters|| 'and :a_include_object_expr is null'; - end if; - else - l_full_name := q'[lower(s.type||' '||s.owner||'.'||s.name)]'; - l_filters := case - when a_coverage_options.include_objects is not empty then ' - and (s.owner, s.name) in ( - select /*+ cardinality(il '||ut_utils.scale_cardinality(cardinality(a_coverage_options.include_objects))||') */ - il.owner, il.name - from table(:include_objects) il - )' - else ' - and s.owner in ( - select /*+ cardinality(t '||ut_utils.scale_cardinality(cardinality(a_coverage_options.schema_names))||') */ - upper(t.column_value) - from table(:l_schema_names) t)' - end; - end if; - - - if a_coverage_options.exclude_schema_expr is not null then - l_regex_exc_filters := q'[ and not regexp_like(s.owner,:a_exclude_schema_expr,'i')]'; - else - l_regex_exc_filters := ' and :a_exclude_schema_expr is null '; - end if; - - if a_coverage_options.exclude_object_expr is not null then - l_regex_exc_filters := l_regex_exc_filters||q'[ and not regexp_like(s.name,:a_exclude_obj_expr,'i')]'; - else - l_regex_exc_filters := l_regex_exc_filters||'and :a_exclude_obj_expr is null '; - end if; - - - - l_result := replace(l_result, '{sources_view}', ut_metadata.get_source_view_name()); - l_result := replace(l_result, '{l_full_name}', l_full_name); - l_result := replace(l_result, '{join_file_mappings}', l_join_mappings); - l_result := replace(l_result, '{filters}', l_filters); - l_result := replace(l_result, '{mappings_cardinality}', l_mappings_cardinality); - l_result := replace(l_result, '{skipped_objects_cardinality}', ut_utils.scale_cardinality(cardinality(a_skip_objects))); - l_result := replace(l_result, '{excuded_objects_cardinality}', ut_utils.scale_cardinality(cardinality(coalesce(a_coverage_options.exclude_objects, ut_object_names())))); - l_result := replace(l_result, '{regex_exc_filters}', l_regex_exc_filters); - - return l_result; - - end; - - function get_cov_sources_cursor(a_coverage_options in ut_coverage_options) return sys_refcursor is - l_cursor sys_refcursor; - l_skip_objects ut_object_names; - l_excluded_objects ut_object_names; - l_sql varchar2(32767); - 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 := coalesce( ut_utils.get_utplsql_objects_list() multiset union all ut_suite_manager.get_schema_ut_packages(a_coverage_options.schema_names, a_coverage_options.include_schema_expr) , ut_object_names() ); - end if; - - --Regex exclusion override the standard exclusion objects. - if a_coverage_options.exclude_schema_expr is null and a_coverage_options.exclude_object_expr is null then - l_excluded_objects := coalesce(a_coverage_options.exclude_objects, ut_object_names()); - end if; - - l_sql := get_cov_sources_sql(a_coverage_options, l_skip_objects); - - ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) ); - - if a_coverage_options.file_mappings is not empty then - open l_cursor for l_sql using a_coverage_options.file_mappings, a_coverage_options.exclude_schema_expr, - a_coverage_options.exclude_object_expr, l_excluded_objects, l_skip_objects; - elsif coalesce(a_coverage_options.include_schema_expr,a_coverage_options.include_object_expr) is not null then - open l_cursor for l_sql using a_coverage_options.include_schema_expr, a_coverage_options.include_object_expr, - a_coverage_options.exclude_schema_expr, a_coverage_options.exclude_object_expr, - l_excluded_objects, l_skip_objects; - elsif a_coverage_options.include_objects is not empty then - open l_cursor for l_sql using a_coverage_options.include_objects, a_coverage_options.exclude_schema_expr, - a_coverage_options.exclude_object_expr, l_excluded_objects, l_skip_objects; - else - open l_cursor for l_sql using a_coverage_options.schema_names, a_coverage_options.exclude_schema_expr, - a_coverage_options.exclude_object_expr, l_excluded_objects, l_skip_objects; - end if; - return l_cursor; - end; - - procedure populate_tmp_table(a_coverage_options ut_coverage_options) is - pragma autonomous_transaction; - l_cov_sources_crsr sys_refcursor; - l_cov_sources_data ut_coverage_helper.t_coverage_sources_tmp_rows; - begin - - if not ut_coverage_helper.is_tmp_table_populated() or is_develop_mode() then - ut_coverage_helper.cleanup_tmp_table(); - l_cov_sources_crsr := get_cov_sources_cursor(a_coverage_options); - - loop - fetch l_cov_sources_crsr bulk collect into l_cov_sources_data limit 10000; - - ut_coverage_helper.insert_into_tmp_table(l_cov_sources_data); - - exit when l_cov_sources_crsr%notfound; - end loop; - - close l_cov_sources_crsr; - end if; - commit; - end; - - - /** - * Public functions - */ - procedure coverage_start(a_coverage_run_id t_coverage_run_id) is - l_run_comment varchar2(200) := 'utPLSQL Code coverage run '||ut_utils.to_string(systimestamp); - l_line_coverage_id integer; - l_block_coverage_id integer; - begin - if not is_develop_mode() and not g_is_started then - g_coverage_run_id := a_coverage_run_id; - l_line_coverage_id := ut_coverage_helper_profiler.coverage_start( l_run_comment ); - l_block_coverage_id := ut_coverage_helper_block.coverage_start( l_run_comment ); - g_is_started := true; - ut_coverage_helper.set_coverage_run_ids(a_coverage_run_id, l_line_coverage_id, l_block_coverage_id); - end if; - end; - - procedure coverage_pause is - begin - if not is_develop_mode() then - ut_coverage_helper_profiler.coverage_pause(); - end if; - end; - - procedure coverage_resume is - begin - ut_coverage_helper_profiler.coverage_resume(); - end; - - procedure coverage_stop is - begin - if not is_develop_mode() then - g_is_started := false; - g_coverage_run_id := null; - ut_coverage_helper_block.coverage_stop(); - ut_coverage_helper_profiler.coverage_stop(); - end if; - end; - - function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage is - l_result_block ut_coverage.t_coverage; - l_result_profiler_enrich ut_coverage.t_coverage; - l_object ut_coverage.t_object_name; - l_line_no binary_integer; - l_coverage_options ut_coverage_options := a_coverage_options; - begin - --prepare global temp table with sources - ut_event_manager.trigger_event('about to populate coverage temp table'); - populate_tmp_table(l_coverage_options); - ut_event_manager.trigger_event('coverage temp table populated'); - - -- Get raw data for both reporters, order is important as tmp table will skip headers and dont populate - -- tmp table for block again. - l_result_profiler_enrich := ut_coverage_profiler.get_coverage_data( l_coverage_options ); - ut_event_manager.trigger_event('profiler coverage data retrieved'); - - -- If block coverage available we will use it. - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_result_block := ut_coverage_block.get_coverage_data( l_coverage_options ); - ut_event_manager.trigger_event('block coverage data retrieved'); - - -- Enrich profiler results with some of the block results - l_object := l_result_profiler_enrich.objects.first; - while (l_object is not null) loop - - l_line_no := l_result_profiler_enrich.objects(l_object).lines.first; - - -- to avoid no data found check if we got object in profiler - if l_result_block.objects.exists(l_object) then - while (l_line_no is not null) loop - -- To avoid no data check for object line - if l_result_block.objects(l_object).lines.exists(l_line_no) then - -- enrich line level stats - l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove; - l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks; - l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks; - -- enrich object level stats - l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove; - end if; - --At the end go to next line - l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no); - end loop; - --total level stats enrich - l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines; - -- At the end go to next object - end if; - - l_object := l_result_profiler_enrich.objects.next(l_object); - end loop; - ut_event_manager.trigger_event('coverage data combined'); - $end - - return l_result_profiler_enrich; - end get_coverage_data; - - function get_coverage_run_id return raw is - begin - if g_coverage_run_id is null then - g_coverage_run_id := sys_guid(); - end if; - return g_coverage_run_id; - end; - -end; -/ diff --git a/source/core/coverage/ut_coverage.pks b/source/core/coverage/ut_coverage.pks deleted file mode 100644 index 21f3b1f9e..000000000 --- a/source/core/coverage/ut_coverage.pks +++ /dev/null @@ -1,80 +0,0 @@ -create or replace package ut_coverage authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - subtype t_coverage_run_id is raw(32) not null; - - -- total run coverage information - subtype t_object_name is varchar2(257); - subtype t_line_no is binary_integer; - - type t_line_executions is record( - executions binary_integer - ,partcove binary_integer - ,no_blocks binary_integer - ,covered_blocks binary_integer); - - -- line coverage information indexed by line no. - type tt_lines is table of t_line_executions index by t_line_no; - - --unit coverage information record - type t_unit_coverage is record( - owner varchar2(128) - ,name varchar2(128) - ,covered_lines binary_integer := 0 - ,uncovered_lines binary_integer := 0 - ,partcovered_lines binary_integer := 0 - ,total_blocks binary_integer default null - ,covered_blocks binary_integer default null - ,uncovered_blocks binary_integer default null - ,total_lines binary_integer := 0 - ,executions number(38, 0) := 0 - ,lines tt_lines); - - -- coverage information indexed by full object name (schema.object) - type tt_program_units is table of t_unit_coverage index by t_object_name; - - -- total run coverage information - type t_coverage is record( - covered_lines binary_integer := 0 - ,uncovered_lines binary_integer := 0 - ,partcovered_lines binary_integer := 0 - ,total_lines binary_integer default null - ,total_blocks binary_integer default null - ,covered_blocks binary_integer default null - ,uncovered_blocks binary_integer default null - ,executions number(38, 0) := 0 - ,objects tt_program_units); - - procedure set_develop_mode(a_develop_mode in boolean); - - function is_develop_mode return boolean; - - procedure coverage_start(a_coverage_run_id t_coverage_run_id); - - procedure coverage_stop; - - procedure coverage_pause; - - procedure coverage_resume; - - function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage; - - function get_coverage_run_id return raw; - -end; -/ diff --git a/source/core/coverage/ut_coverage_block.pkb b/source/core/coverage/ut_coverage_block.pkb deleted file mode 100644 index a906b81a3..000000000 --- a/source/core/coverage/ut_coverage_block.pkb +++ /dev/null @@ -1,160 +0,0 @@ -create or replace package body ut_coverage_block is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - - type t_source_lines is table of binary_integer; - - /** - * Public functions - */ - - function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage is - l_line_calls ut_coverage_helper.t_unit_line_calls; - l_result ut_coverage.t_coverage; - l_new_unit ut_coverage.t_unit_coverage; - l_line_no binary_integer; - l_source_objects_crsr ut_coverage_helper.t_tmp_table_objects_crsr; - l_source_object ut_coverage_helper.t_tmp_table_object; - begin - - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor(); - loop - fetch l_source_objects_crsr - into l_source_object; - exit when l_source_objects_crsr%notfound; - - --get coverage data - l_line_calls := ut_coverage_helper_block.get_raw_coverage_data(l_source_object, a_coverage_options.coverage_run_id); - --if there is coverage, we need to filter out the garbage (badly indicated data) - if l_line_calls.count > 0 then - --remove lines that should not be indicted as meaningful - for i in 1 .. l_source_object.to_be_skipped_list.count loop - if l_source_object.to_be_skipped_list(i) is not null then - l_line_calls.delete(l_source_object.to_be_skipped_list(i)); - end if; - end loop; - end if; - - --if there are no file mappings or object was actually captured by profiler - if a_coverage_options.file_mappings is null or l_line_calls.count > 0 then - - --populate total stats - l_result.total_lines := nvl(l_result.total_lines,0) + l_source_object.lines_count; - - --populate object level coverage stats - if not l_result.objects.exists(l_source_object.full_name) then - l_result.objects(l_source_object.full_name) := l_new_unit; - l_result.objects(l_source_object.full_name).owner := l_source_object.owner; - l_result.objects(l_source_object.full_name).name := l_source_object.name; - l_result.objects(l_source_object.full_name).total_lines := l_source_object.lines_count; - end if; - --map to results - l_line_no := l_line_calls.first; - if l_line_no is null then - l_result.uncovered_lines := l_result.uncovered_lines + l_source_object.lines_count; - l_result.objects(l_source_object.full_name).uncovered_lines := l_source_object.lines_count; - else - loop - exit when l_line_no is null; - - --turn the block coverage into a line coverage format to allow for reading. - --whenever the linst is a part covered treat that line as a hit and execution but only part covered - - --total stats - --Get total blocks ,blocks covered, blocks not covered this will be used for PCT calc - l_result.total_blocks := nvl(l_result.total_blocks, 0) + l_line_calls(l_line_no).blocks; - l_result.covered_blocks := nvl(l_result.covered_blocks, 0) + l_line_calls(l_line_no).covered_blocks; - l_result.uncovered_blocks := nvl(l_result.uncovered_blocks, 0) + - (l_line_calls(l_line_no).blocks - l_line_calls(l_line_no).covered_blocks); - - --If line is partially covered add as part line cover and covered for line reporter - if l_line_calls(l_line_no).partcovered = 1 then - l_result.partcovered_lines := l_result.partcovered_lines + 1; - end if; - - if l_line_calls(l_line_no).covered_blocks > 0 then - l_result.covered_lines := l_result.covered_lines + 1; - end if; - - -- Use nvl as be default is null and screw the calcs - --Increase total blocks - l_result.objects(l_source_object.full_name).lines(l_line_no).no_blocks := l_line_calls(l_line_no).blocks; - l_result.objects(l_source_object.full_name).lines(l_line_no).covered_blocks := l_line_calls(l_line_no).covered_blocks; - l_result.objects(l_source_object.full_name).total_blocks := nvl(l_result.objects(l_source_object.full_name) - .total_blocks - ,0) + l_line_calls(l_line_no).blocks; - - --Total uncovered blocks is a line blocks minus covered blocsk - l_result.objects(l_source_object.full_name).uncovered_blocks := nvl(l_result.objects(l_source_object.full_name) - .uncovered_blocks - ,0) + - (l_line_calls(l_line_no).blocks - l_line_calls(l_line_no) - .covered_blocks); - - --If we have any covered blocks in line - if l_line_calls(l_line_no).covered_blocks > 0 then - --If any block is covered then we have a hit on that line - l_result.executions := l_result.executions + 1; - --object level stats - --If its part covered then mark it else treat as full cov - if l_line_calls(l_line_no).partcovered = 1 then - l_result.objects(l_source_object.full_name).partcovered_lines := l_result.objects(l_source_object.full_name) - .partcovered_lines + 1; - end if; - l_result.objects(l_source_object.full_name).covered_lines := l_result.objects(l_source_object.full_name) - .covered_lines + 1; - - --How many blocks we covered - l_result.objects(l_source_object.full_name).covered_blocks := nvl(l_result.objects(l_source_object.full_name) - .covered_blocks - ,0) + l_line_calls(l_line_no) - .covered_blocks; - - --Object line executions - l_result.objects(l_source_object.full_name).executions := nvl(l_result.objects(l_source_object.full_name) - .executions - ,0) + 1; - - l_result.objects(l_source_object.full_name).lines(l_line_no).executions := 1; - - --Whenever there is no covered block treat as uncovered (query returns only lines where the blocks are in code so we - --dont have a false results here when there is no blocks - elsif l_line_calls(l_line_no).covered_blocks = 0 then - l_result.uncovered_lines := l_result.uncovered_lines + 1; - l_result.objects(l_source_object.full_name).uncovered_lines := l_result.objects(l_source_object.full_name) - .uncovered_lines + 1; - l_result.objects(l_source_object.full_name).lines(l_line_no).executions := 0; - end if; - --increase part covered counter (+ 1/0) - l_result.objects(l_source_object.full_name).lines(l_line_no).partcove := l_line_calls(l_line_no).partcovered; - l_line_no := l_line_calls.next(l_line_no); - end loop; - end if; - end if; - - end loop; - - close l_source_objects_crsr; - $end - - return l_result; - end get_coverage_data; - -end; -/ diff --git a/source/core/coverage/ut_coverage_block.pks b/source/core/coverage/ut_coverage_block.pks deleted file mode 100644 index 01caca035..000000000 --- a/source/core/coverage/ut_coverage_block.pks +++ /dev/null @@ -1,22 +0,0 @@ -create or replace package ut_coverage_block authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage; - -end; -/ diff --git a/source/core/coverage/ut_coverage_helper.pkb b/source/core/coverage/ut_coverage_helper.pkb deleted file mode 100644 index e249b3381..000000000 --- a/source/core/coverage/ut_coverage_helper.pkb +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package body ut_coverage_helper is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - - - type t_proftab_row is record ( - line binary_integer, - calls number(38,0) - ); - - type t_proftab_rows is table of t_proftab_row; - - type t_block_row is record( - line binary_integer - ,blocks binary_integer - ,covered_blocks binary_integer); - - type t_block_rows is table of t_block_row; - - procedure insert_into_tmp_table(a_data t_coverage_sources_tmp_rows) is - begin - forall i in 1 .. a_data.count - insert /*+ no_parallel */ into ut_coverage_sources_tmp - (full_name,owner,name,type,line,text,to_be_skipped) - values(a_data(i).full_name,a_data(i).owner,a_data(i).name,a_data(i).type,a_data(i).line,a_data(i).text,a_data(i).to_be_skipped); - end; - - procedure cleanup_tmp_table is - pragma autonomous_transaction; - begin - execute immediate 'truncate table ut_coverage_sources_tmp'; - end; - - function is_tmp_table_populated return boolean is - l_result integer; - begin - select /*+ no_parallel */ 1 into l_result from ut_coverage_sources_tmp where rownum = 1; - return (l_result = 1); - exception - when no_data_found then - return false; - end; - - function get_tmp_table_objects_cursor return t_tmp_table_objects_crsr is - l_result t_tmp_table_objects_crsr; - begin - open l_result for - select /*+ no_parallel */ o.owner, o.name, o.type, o.full_name, max(o.line) as lines_count, - cast( - collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list - ) as to_be_skipped_list - from ut_coverage_sources_tmp o - group by o.owner, o.name, o.type, o.full_name; - - return l_result; - end; - - function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list is - l_result ut_varchar2_list; - begin - select /*+ no_parallel */ rtrim(s.text,chr(10)) as text - bulk collect into l_result - from ut_coverage_sources_tmp s - where s.owner = a_owner - and s.name = a_object_name - order by s.line; - - return l_result; - end; - - procedure set_coverage_run_ids( a_coverage_run_id raw, a_line_coverage_id integer, a_block_coverage_id integer ) is - pragma autonomous_transaction; - begin - insert /*+ no_parallel */ into ut_coverage_runs - ( coverage_run_id, line_coverage_id, block_coverage_id ) - values - ( a_coverage_run_id, a_line_coverage_id, a_block_coverage_id ); - commit; - end; - -end; -/ diff --git a/source/core/coverage/ut_coverage_helper.pks b/source/core/coverage/ut_coverage_helper.pks deleted file mode 100644 index cd6ed9ec7..000000000 --- a/source/core/coverage/ut_coverage_helper.pks +++ /dev/null @@ -1,67 +0,0 @@ -create or replace package ut_coverage_helper authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 line calls indexed by line number - --!!! this table is sparse!!! - --type t_unit_line_calls is table of number(38,0) index by binary_integer; - - type t_unit_line_call is record( - blocks binary_integer default 0 - ,covered_blocks binary_integer default 0 - ,partcovered binary_integer default 0 - ,calls binary_integer default 0); - - type t_unit_line_calls is table of t_unit_line_call index by binary_integer; - - type t_coverage_sources_tmp_row is record ( - full_name ut_coverage_sources_tmp.full_name%type, - owner ut_coverage_sources_tmp.owner%type, - name ut_coverage_sources_tmp.name%type, - type ut_coverage_sources_tmp.type%type, - line ut_coverage_sources_tmp.line%type, - to_be_skipped ut_coverage_sources_tmp.to_be_skipped%type, - text ut_coverage_sources_tmp.text%type - ); - - type t_coverage_sources_tmp_rows is table of t_coverage_sources_tmp_row; - - type t_tmp_table_object is record( - owner ut_coverage_sources_tmp.owner%type, - name ut_coverage_sources_tmp.name%type, - type ut_coverage_sources_tmp.type%type, - full_name ut_coverage_sources_tmp.full_name%type, - lines_count integer, - to_be_skipped_list ut_varchar2_list - ); - - type t_tmp_table_objects_crsr is ref cursor return t_tmp_table_object; - - procedure insert_into_tmp_table(a_data t_coverage_sources_tmp_rows); - - procedure cleanup_tmp_table; - - function is_tmp_table_populated return boolean; - - function get_tmp_table_objects_cursor return t_tmp_table_objects_crsr; - - function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list; - - procedure set_coverage_run_ids( a_coverage_run_id raw, a_line_coverage_id integer, a_block_coverage_id integer ); - -end; -/ diff --git a/source/core/coverage/ut_coverage_helper_block.pkb b/source/core/coverage/ut_coverage_helper_block.pkb deleted file mode 100644 index fb4d4812e..000000000 --- a/source/core/coverage/ut_coverage_helper_block.pkb +++ /dev/null @@ -1,110 +0,0 @@ -create or replace package body ut_coverage_helper_block is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - type t_block_row is record( - line binary_integer - ,blocks binary_integer - ,covered_blocks binary_integer); - - type t_block_rows is table of t_block_row; - - function coverage_start(a_run_comment varchar2) return integer is - begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - return dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment); - $else - return null; - $end - end; - - procedure coverage_stop is - begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - dbms_plsql_code_coverage.stop_coverage(); - $else - null; - $end - exception - when others then - if sqlcode = -08402 then - dbms_output.put_line('Unable to finish gathering coverage with DBMS_PLSQL_CODE_COVERAGE. '); - dbms_output.put_line('Encountered exception `ORA-08402` when calling procedure `DBMS_PLSQL_CODE_COVERAGE.STOP_COVERAGE()`.'); - dbms_output.put_line('Coverage report will only include line-level code-coverage (without branches).'); - dbms_output.put_line('Please reference following issue for details on possible causes: https://github.com/utPLSQL/utPLSQL/issues/1097 '); - end if; - end; - - function block_results(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return t_block_rows is - l_coverage_rows t_block_rows; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - begin - execute immediate q'[ - select /*+ no_parallel */ - line as line, - count(block) as blocks, - sum(covered) as covered_blocks - from (select line, - block, - max(covered) as covered - from dbmspcc_units ccu - join ]'||l_ut_owner||q'[.ut_coverage_runs r - on r.block_coverage_id = ccu.run_id - left join dbmspcc_blocks ccb - on ccu.run_id = ccb.run_id - and ccu.object_id = ccb.object_id - where r.coverage_run_id = :a_coverage_run_id - and ccu.owner = :a_object_owner - and ccu.name = :a_object_name - and ccu.type = :a_object_type - group by ccb.line, ccb.block - ) - group by line - having count(block) > 1 - order by line]' - bulk collect into l_coverage_rows - using - a_coverage_run_id, a_object.owner, - a_object.name, a_object.type; - - return l_coverage_rows; - end; - - function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls is - l_tmp_data t_block_rows; - l_results ut_coverage_helper.t_unit_line_calls; - - begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_tmp_data := block_results(a_object, a_coverage_run_id); - - for i in 1 .. l_tmp_data.count loop - l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks; - l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks; - l_results(l_tmp_data(i).line).partcovered := - case - when (l_tmp_data(i).covered_blocks > 0) - and (l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) - then 1 - else 0 - end; - end loop; - $end - return l_results; - end; -end; -/ diff --git a/source/core/coverage/ut_coverage_helper_block.pks b/source/core/coverage/ut_coverage_helper_block.pks deleted file mode 100644 index a147d9f4f..000000000 --- a/source/core/coverage/ut_coverage_helper_block.pks +++ /dev/null @@ -1,26 +0,0 @@ -create or replace package ut_coverage_helper_block authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function coverage_start(a_run_comment in varchar2) return integer; - - procedure coverage_stop; - - function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls; - -end; -/ diff --git a/source/core/coverage/ut_coverage_helper_profiler.pkb b/source/core/coverage/ut_coverage_helper_profiler.pkb deleted file mode 100644 index f29291efb..000000000 --- a/source/core/coverage/ut_coverage_helper_profiler.pkb +++ /dev/null @@ -1,93 +0,0 @@ -create or replace package body ut_coverage_helper_profiler is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - type t_proftab_row is record ( - line binary_integer, - calls number(38,0) - ); - - type t_proftab_rows is table of t_proftab_row; - - type t_block_row is record( - line binary_integer - ,blocks binary_integer - ,covered_blocks binary_integer); - - type t_block_rows is table of t_block_row; - - - function coverage_start(a_run_comment varchar2) return integer is - l_coverage_id integer; - begin - dbms_profiler.start_profiler(run_comment => a_run_comment, run_number => l_coverage_id); - return l_coverage_id; - end; - - procedure coverage_pause is - l_return_code binary_integer; - begin - l_return_code := dbms_profiler.pause_profiler(); - end; - - procedure coverage_resume is - l_return_code binary_integer; - begin - l_return_code := dbms_profiler.resume_profiler(); - end; - - procedure coverage_stop is - begin - dbms_profiler.stop_profiler(); - end; - - function proftab_results(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return t_proftab_rows is - l_coverage_rows t_proftab_rows; - begin - select /*+ no_parallel */ - d.line#, - case when sum(d.total_occur) = 0 and sum(d.total_time) > 0 then 1 else sum(d.total_occur) end total_occur - bulk collect into l_coverage_rows - from plsql_profiler_units u - join plsql_profiler_data d - on u.runid = d.runid - and u.unit_number = d.unit_number - join ut_coverage_runs r - on r.line_coverage_id = u.runid - where r.coverage_run_id = a_coverage_run_id - and u.unit_owner = a_object.owner - and u.unit_name = a_object.name - and u.unit_type = a_object.type - group by d.line#; - - return l_coverage_rows; - end; - - function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls is - l_tmp_data t_proftab_rows; - l_results ut_coverage_helper.t_unit_line_calls; - begin - l_tmp_data := proftab_results(a_object, a_coverage_run_id); - - for i in 1 .. l_tmp_data.count loop - l_results(l_tmp_data(i).line).calls := l_tmp_data(i).calls; - end loop; - return l_results; - end; - -end; -/ diff --git a/source/core/coverage/ut_coverage_helper_profiler.pks b/source/core/coverage/ut_coverage_helper_profiler.pks deleted file mode 100644 index 0c54a83bf..000000000 --- a/source/core/coverage/ut_coverage_helper_profiler.pks +++ /dev/null @@ -1,30 +0,0 @@ -create or replace package ut_coverage_helper_profiler authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function coverage_start(a_run_comment in varchar2) return integer; - - procedure coverage_stop; - - procedure coverage_pause; - - procedure coverage_resume; - - function get_raw_coverage_data(a_object ut_coverage_helper.t_tmp_table_object, a_coverage_run_id raw) return ut_coverage_helper.t_unit_line_calls; - -end; -/ diff --git a/source/core/coverage/ut_coverage_profiler.pkb b/source/core/coverage/ut_coverage_profiler.pkb deleted file mode 100644 index 663ceab7f..000000000 --- a/source/core/coverage/ut_coverage_profiler.pkb +++ /dev/null @@ -1,96 +0,0 @@ -create or replace package body ut_coverage_profiler is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Public functions - */ - function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage is - l_line_calls ut_coverage_helper.t_unit_line_calls; - l_result ut_coverage.t_coverage; - l_new_unit ut_coverage.t_unit_coverage; - l_line_no binary_integer; - l_source_objects_crsr ut_coverage_helper.t_tmp_table_objects_crsr; - l_source_object ut_coverage_helper.t_tmp_table_object; - begin - - l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor(); - loop - fetch l_source_objects_crsr into l_source_object; - exit when l_source_objects_crsr%notfound; - - --get coverage data - l_line_calls := ut_coverage_helper_profiler.get_raw_coverage_data( l_source_object, a_coverage_options.coverage_run_id); - - --if there is coverage, we need to filter out the garbage (badly indicated data from dbms_profiler) - if l_line_calls.count > 0 then - --remove lines that should not be indicted as meaningful - for i in 1 .. l_source_object.to_be_skipped_list.count loop - if l_source_object.to_be_skipped_list(i) is not null then - l_line_calls.delete(l_source_object.to_be_skipped_list(i)); - end if; - end loop; - end if; - - --if there are no file mappings or object was actually captured by profiler - if a_coverage_options.file_mappings is null or l_line_calls.count > 0 then - - --populate total stats - l_result.total_lines := nvl(l_result.total_lines,0) + l_source_object.lines_count; - --populate object level coverage stats - if not l_result.objects.exists(l_source_object.full_name) then - l_result.objects(l_source_object.full_name) := l_new_unit; - l_result.objects(l_source_object.full_name).owner := l_source_object.owner; - l_result.objects(l_source_object.full_name).name := l_source_object.name; - l_result.objects(l_source_object.full_name).total_lines := l_source_object.lines_count; - end if; - --map to results - l_line_no := l_line_calls.first; - if l_line_no is null then - l_result.uncovered_lines := l_result.uncovered_lines + l_source_object.lines_count; - l_result.objects(l_source_object.full_name).uncovered_lines := l_source_object.lines_count; - else - loop - exit when l_line_no is null; - - if l_line_calls(l_line_no).calls > 0 then - --total stats - l_result.covered_lines := l_result.covered_lines + 1; - l_result.executions := l_result.executions + l_line_calls(l_line_no).calls; - --object level stats - l_result.objects(l_source_object.full_name).covered_lines := l_result.objects(l_source_object.full_name).covered_lines + 1; - l_result.objects(l_source_object.full_name).executions := l_result.objects(l_source_object.full_name).executions + l_line_calls(l_line_no).calls; - elsif l_line_calls(l_line_no).calls = 0 then - l_result.uncovered_lines := l_result.uncovered_lines + 1; - l_result.objects(l_source_object.full_name).uncovered_lines := l_result.objects(l_source_object.full_name).uncovered_lines + 1; - end if; - l_result.objects(l_source_object.full_name).lines(l_line_no).executions := l_line_calls(l_line_no).calls; - - l_line_no := l_line_calls.next(l_line_no); - end loop; - end if; - end if; - - end loop; - - close l_source_objects_crsr; - - return l_result; - end get_coverage_data; - -end; -/ diff --git a/source/core/coverage/ut_coverage_profiler.pks b/source/core/coverage/ut_coverage_profiler.pks deleted file mode 100644 index 9ce9a27f0..000000000 --- a/source/core/coverage/ut_coverage_profiler.pks +++ /dev/null @@ -1,22 +0,0 @@ -create or replace package ut_coverage_profiler authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function get_coverage_data(a_coverage_options ut_coverage_options) return ut_coverage.t_coverage; - -end; -/ diff --git a/source/core/coverage/ut_coverage_reporter_base.tpb b/source/core/coverage/ut_coverage_reporter_base.tpb deleted file mode 100644 index da2bd27ad..000000000 --- a/source/core/coverage/ut_coverage_reporter_base.tpb +++ /dev/null @@ -1,113 +0,0 @@ -create or replace type body ut_coverage_reporter_base is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run) as - begin - (self as ut_output_reporter_base).before_calling_run(a_run); - ut_coverage.coverage_start(a_coverage_run_id => a_run.coverage_options.coverage_run_id); - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_before_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_before_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_before_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_before_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_before_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_before_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_test_execute(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_test_execute (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_after_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_after_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_after_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_after_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - overriding final member procedure before_calling_after_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_resume(); - end; - overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is - begin - ut_coverage.coverage_pause(); - end; - - final member function get_report( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined is - l_reporter ut_coverage_reporter_base := self; - begin - ut_coverage_helper.cleanup_tmp_table(); - (l_reporter as ut_output_reporter_base).before_calling_run(null); - l_reporter.after_calling_run( ut_run( a_coverage_options => a_coverage_options, a_client_character_set => a_client_character_set ) ); - for i in (select /*+ no_parallel */ x.text from table(l_reporter.get_lines(1, 1)) x ) loop - pipe row (i.text); - end loop; - return; - end; - - final member function get_report_cursor( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return sys_refcursor is - l_reporter ut_coverage_reporter_base := self; - l_result sys_refcursor; - begin - ut_coverage_helper.cleanup_tmp_table(); - (l_reporter as ut_output_reporter_base).before_calling_run(null); - l_reporter.after_calling_run( ut_run( a_coverage_options => a_coverage_options, a_client_character_set => a_client_character_set ) ); - open l_result for select /*+ no_parallel */ x.text from table(l_reporter.get_lines(1, 1)) x; - return l_result; - end; - -end; -/ diff --git a/source/core/coverage/ut_coverage_reporter_base.tps b/source/core/coverage/ut_coverage_reporter_base.tps deleted file mode 100644 index 305c5d757..000000000 --- a/source/core/coverage/ut_coverage_reporter_base.tps +++ /dev/null @@ -1,44 +0,0 @@ -create or replace type ut_coverage_reporter_base under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run), - overriding final member procedure before_calling_before_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_before_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - - overriding final member procedure before_calling_before_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_before_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - - overriding final member procedure before_calling_before_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_before_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - - overriding final member procedure before_calling_test_execute(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_test_execute (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - - overriding final member procedure before_calling_after_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_after_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - - overriding final member procedure before_calling_after_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_after_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - - overriding final member procedure before_calling_after_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable), - final member function get_report( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return ut_varchar2_rows pipelined, - final member function get_report_cursor( a_coverage_options ut_coverage_options, a_client_character_set varchar2 := null ) return sys_refcursor -) -not final not instantiable -/ diff --git a/source/core/coverage/ut_coverage_runs.sql b/source/core/coverage/ut_coverage_runs.sql deleted file mode 100644 index 78230240d..000000000 --- a/source/core/coverage/ut_coverage_runs.sql +++ /dev/null @@ -1,20 +0,0 @@ -declare - l_tab_exist number; -begin - select count(*) into l_tab_exist - from all_tables - where table_name = 'UT_COVERAGE_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA'); - if l_tab_exist = 0 then - execute immediate q'[create table ut_coverage_runs - ( - coverage_run_id raw(32) not null, - line_coverage_id number(38,0) unique not null, - block_coverage_id number(38,0) unique, - constraint ut_coverage_runs primary key (coverage_run_id, line_coverage_id) - ) organization index ]'; - execute immediate q'[comment on table ut_coverage_runs is - 'Map of block and line coverage runs for a test-run']'; - dbms_output.put_line('UT_COVERAGE_RUNS table created'); - end if; -end; -/ diff --git a/source/core/coverage/ut_coverage_sources_tmp.sql b/source/core/coverage/ut_coverage_sources_tmp.sql deleted file mode 100644 index c091d5955..000000000 --- a/source/core/coverage/ut_coverage_sources_tmp.sql +++ /dev/null @@ -1,26 +0,0 @@ -create global temporary table ut_coverage_sources_tmp( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - full_name varchar2(4000), - owner varchar2(250), - name varchar2(250), - type varchar2(250), - line number(38,0), - to_be_skipped varchar2(1), - text varchar2(4000), - constraint ut_coverage_sources_tmp_pk primary key (owner,name,type,line) -) on commit preserve rows; - ---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 deleted file mode 100644 index c0ea653ea..000000000 --- a/source/core/events/ut_event_item.tps +++ /dev/null @@ -1,25 +0,0 @@ -create or replace type ut_event_item authid current_user as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 type is a pre-declaration to be referenced by ut_event_listener_base - * The true abstract type is ut_suite_item - */ - self_type varchar2(250 byte) -) not final not instantiable -/ diff --git a/source/core/events/ut_event_listener.tps b/source/core/events/ut_event_listener.tps deleted file mode 100644 index bbcdbf218..000000000 --- a/source/core/events/ut_event_listener.tps +++ /dev/null @@ -1,35 +0,0 @@ -create or replace type ut_event_listener authid current_user as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 type is a pre-declaration to be referenced by ut_event_listener_base - * The true abstract type is ut_suite_item - */ - self_type varchar2(250 byte), - - /** - * Returns the list of events that are supported by particular implementation of the reporter - */ - not instantiable member function get_supported_events return ut_varchar2_list, - - /** - * Executes an action for a given event name - */ - not instantiable member procedure on_event( self in out nocopy ut_event_listener, a_event_name varchar2, a_event_item ut_event_item) -) not final not instantiable -/ diff --git a/source/core/events/ut_event_manager.pkb b/source/core/events/ut_event_manager.pkb deleted file mode 100644 index f51019421..000000000 --- a/source/core/events/ut_event_manager.pkb +++ /dev/null @@ -1,122 +0,0 @@ -create or replace package body ut_event_manager as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - type t_listeners is table of ut_event_listener; - subtype t_listener_number is binary_integer; - type t_listener_numbers is table of boolean index by t_listener_number; - type t_events_listeners is table of t_listener_numbers index by t_event_name; - - type t_event_manager is record ( - event_listener_index t_events_listeners, - listeners t_listeners - ); - type t_event_managers is table of t_event_manager; - - g_event_listeners_index t_events_listeners; - g_listeners t_listeners; - g_suspended_event_managers t_event_managers; - - procedure initialize is - begin - if g_listeners is not null and g_listeners.count > 0 then - if g_suspended_event_managers is null then - g_suspended_event_managers := t_event_managers(); - end if; - g_suspended_event_managers.extend; - g_suspended_event_managers(g_suspended_event_managers.count).event_listener_index := g_event_listeners_index; - g_suspended_event_managers(g_suspended_event_managers.count).listeners := g_listeners; - end if; - g_event_listeners_index.delete; - g_listeners := t_listeners(); - end; - - procedure dispose_listeners is - begin - if g_suspended_event_managers is not null and g_suspended_event_managers.count > 0 then - g_event_listeners_index := g_suspended_event_managers(g_suspended_event_managers.count).event_listener_index; - g_listeners := g_suspended_event_managers(g_suspended_event_managers.count).listeners; - g_suspended_event_managers.trim(1); - else - g_event_listeners_index.delete; - g_listeners := t_listeners(); - end if; - end; - - procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item := null ) is - - procedure trigger_listener_event( - a_listener_numbers t_listener_numbers, - a_event_name t_event_name, - a_event_object ut_event_item - ) is - l_listener_number t_listener_number := a_listener_numbers.first; - begin - while l_listener_number is not null loop - g_listeners(l_listener_number).on_event(a_event_name, a_event_object); - l_listener_number := a_listener_numbers.next(l_listener_number); - end loop; - end; - begin - if a_event_name is not null then - if g_event_listeners_index.exists(gc_all) then - trigger_listener_event( g_event_listeners_index(gc_all), a_event_name, a_event_object ); - end if; - if g_event_listeners_index.exists(a_event_name) then - trigger_listener_event( g_event_listeners_index(a_event_name), a_event_name, a_event_object ); - end if; - if a_event_name = ut_event_manager.gc_finalize then - dispose_listeners(); - end if; - end if; - end; - - procedure add_event( a_event_name t_event_name, a_listener_pos binary_integer ) is - begin - g_event_listeners_index(a_event_name)(a_listener_pos) := true; - end; - - procedure add_events( a_event_names ut_varchar2_list, a_listener_pos binary_integer ) is - begin - for i in 1 .. a_event_names.count loop - add_event( a_event_names(i), a_listener_pos ); - end loop; - end; - - function add_listener( a_listener ut_event_listener ) return t_listener_number is - begin - if g_listeners is null then - g_listeners := t_listeners(); - end if; - g_listeners.extend; - g_listeners(g_listeners.last) := a_listener; - return g_listeners.last; - end; - - procedure add_listener( a_listener ut_event_listener ) is - l_event_names ut_varchar2_list; - begin - if a_listener is not null then - l_event_names := a_listener.get_supported_events(); - if l_event_names is not empty then - add_events( l_event_names, add_listener( a_listener ) ); - end if; - end if; - end; - -end; -/ diff --git a/source/core/events/ut_event_manager.pks b/source/core/events/ut_event_manager.pks deleted file mode 100644 index 03b18b728..000000000 --- a/source/core/events/ut_event_manager.pks +++ /dev/null @@ -1,66 +0,0 @@ -create or replace package ut_event_manager authid current_user as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /* Constants: Event names */ - subtype t_event_name is varchar2(250); - - --capture all events - gc_all constant t_event_name := 'all'; - - gc_debug constant t_event_name := 'debug'; - - gc_initialize constant t_event_name := 'initialize'; - - gc_before_run constant t_event_name := 'before_run'; - gc_before_suite constant t_event_name := 'before_suite'; - - gc_before_before_all constant t_event_name := 'before_beforeall'; - gc_after_before_all constant t_event_name := 'after_beforeall'; - - gc_before_test constant t_event_name := 'beforetest'; - - gc_before_before_each constant t_event_name := 'before_beforeeach'; - gc_after_before_each constant t_event_name := 'after_beforeeach'; - gc_before_before_test constant t_event_name := 'before_beforetest'; - gc_after_before_test constant t_event_name := 'after_beforetest'; - - gc_before_test_execute constant t_event_name := 'before_test'; - gc_after_test_execute constant t_event_name := 'after_test'; - - gc_before_after_test constant t_event_name := 'before_aftertest'; - gc_after_after_test constant t_event_name := 'after_aftertest'; - gc_before_after_each constant t_event_name := 'before_aftereach'; - gc_after_after_each constant t_event_name := 'after_aftereach'; - - gc_after_test constant t_event_name := 'aftertest'; - - gc_before_after_all constant t_event_name := 'before_afterall'; - gc_after_after_all constant t_event_name := 'after_afterall'; - - gc_after_suite constant t_event_name := 'after_suite'; - gc_after_run constant t_event_name := 'after_run'; - - gc_finalize constant t_event_name := 'finalize'; - - procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item := null ); - - procedure initialize; - - procedure add_listener( a_listener ut_event_listener ); - -end; -/ diff --git a/source/core/output_buffers/ut_output_buffer_base.tpb b/source/core/output_buffers/ut_output_buffer_base.tpb deleted file mode 100644 index 20cec335e..000000000 --- a/source/core/output_buffers/ut_output_buffer_base.tpb +++ /dev/null @@ -1,155 +0,0 @@ -create or replace type body ut_output_buffer_base is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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); - select /*+ no_parallel */ count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id; - if ( l_exists > 0 ) then - update /*+ no_parallel */ ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id; - else - insert /*+ no_parallel */ into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date); - end if; - commit; - dbms_lock.allocate_unique( self.output_id, self.lock_handle); - self.is_closed := 0; - end; - - member procedure lock_buffer(a_timeout_sec number := null) is - l_status integer; - begin - l_status := dbms_lock.request( self.lock_handle, dbms_lock.x_mode, 5, false ); - if l_status != 0 then - raise_application_error(-20000, 'Cannot allocate lock for output buffer of reporter. lock request status = '||l_status||', lock handle = '||self.lock_handle||', self.output_id ='||self.output_id); - end if; - end; - - member procedure close(self in out nocopy ut_output_buffer_base) is - l_status integer; - begin - l_status := dbms_lock.release( self.lock_handle ); - if l_status != 0 then - raise_application_error(-20000, 'Cannot release lock for output buffer of reporter. Lock_handle = '||self.lock_handle||' status = '||l_status); - end if; - self.is_closed := 1; - end; - - - member procedure remove_buffer_info(self in ut_output_buffer_base) is - pragma autonomous_transaction; - begin - delete from ut_output_buffer_info_tmp a - where a.output_id = self.output_id; - commit; - end; - - member function timeout_producer_not_started( a_producer_started boolean, a_already_waited_sec number, a_init_wait_sec number ) return boolean - is - l_result boolean := false; - begin - if not a_producer_started and a_already_waited_sec >= a_init_wait_sec then - if a_init_wait_sec > 0 then - self.remove_buffer_info(); - raise_application_error( - ut_utils.gc_out_buffer_timeout, - 'Timeout occurred while waiting for report data producer to start. Waited for: '||ut_utils.to_string( a_already_waited_sec )||' seconds.' - ); - else - l_result := true; - end if; - end if; - return l_result; - end; - - member function timeout_producer_not_finished(a_producer_finished boolean, a_already_waited_sec number, a_timeout_sec number) return boolean - is - l_result boolean := false; - begin - if not a_producer_finished and a_timeout_sec is not null and a_already_waited_sec >= a_timeout_sec then - if a_timeout_sec > 0 then - self.remove_buffer_info(); - raise_application_error( - ut_utils.gc_out_buffer_timeout, - 'Timeout occurred while waiting for more data from producer. Waited for: '||ut_utils.to_string( a_already_waited_sec )||' seconds.' - ); - else - l_result := true; - end if; - end if; - return l_result; - end; - - member function get_lock_status return integer is - l_result integer; - l_release_status integer; - begin - l_result := dbms_lock.request( self.lock_handle, dbms_lock.s_mode, 0, false ); - if l_result = 0 then - l_release_status := dbms_lock.release( self.lock_handle ); - end if; - return l_result; - end; - - member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor is - l_lines sys_refcursor; - begin - open l_lines for - select /*+ no_parallel */ 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 number := null, a_timeout_sec number := 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; - if dbms_lob.getlength(l_clob) > 32767 then - 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; - else - dbms_output.put_line(l_clob); - end if; - 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 * 5); -- 5 days - 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 deleted file mode 100644 index f2d9ec686..000000000 --- a/source/core/output_buffers/ut_output_buffer_base.tps +++ /dev/null @@ -1,39 +0,0 @@ -create or replace type ut_output_buffer_base force authid definer as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - output_id raw(32), - is_closed number(1,0), - start_date date, - lock_handle varchar2(30 byte), - 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 procedure lock_buffer(a_timeout_sec number := null), - member function timeout_producer_not_started( a_producer_started boolean, a_already_waited_sec number, a_init_wait_sec number ) return boolean, - member function timeout_producer_not_finished(a_producer_finished boolean, a_already_waited_sec number, a_timeout_sec number) return boolean, - member function get_lock_status return integer, - member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor, - member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout number := null, a_timeout_sec number := null), - member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null), - member procedure remove_buffer_info(self in ut_output_buffer_base), - 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 number := null, a_timeout_sec number := 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 deleted file mode 100644 index af730d394..000000000 --- a/source/core/output_buffers/ut_output_buffer_info_tmp.sql +++ /dev/null @@ -1,25 +0,0 @@ -create table ut_output_buffer_info_tmp( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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, - start_date date not null, - constraint ut_output_buffer_info_tmp_pk primary key(output_id) -) organization index nologging initrans 10 -; - diff --git a/source/core/output_buffers/ut_output_buffer_tmp.sql b/source/core/output_buffers/ut_output_buffer_tmp.sql deleted file mode 100644 index 1ab19e534..000000000 --- a/source/core/output_buffers/ut_output_buffer_tmp.sql +++ /dev/null @@ -1,33 +0,0 @@ -create table ut_output_buffer_tmp( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 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_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; - -create sequence ut_output_buffer_tmp_seq cache 20; diff --git a/source/core/output_buffers/ut_output_bulk_buffer.tpb b/source/core/output_buffers/ut_output_bulk_buffer.tpb deleted file mode 100644 index cfc173e95..000000000 --- a/source/core/output_buffers/ut_output_bulk_buffer.tpb +++ /dev/null @@ -1,160 +0,0 @@ -create or replace type body ut_output_bulk_buffer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2023 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_bulk_buffer(self in out nocopy ut_output_bulk_buffer, a_output_id raw := null) return self as result is - begin - self.init(a_output_id, $$plsql_unit); - return; - end; - - overriding member procedure send_line(self in out nocopy ut_output_bulk_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 - 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 - insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); - end if; - commit; - end if; - end; - - overriding member procedure send_lines(self in out nocopy ut_output_bulk_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is - pragma autonomous_transaction; - begin - insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) - select /*+ no_parallel */ self.output_id, ut_output_buffer_tmp_seq.nextval, 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; - commit; - end; - - overriding member procedure send_clob(self in out nocopy ut_output_bulk_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 - 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 - insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); - end if; - commit; - end if; - end; - - overriding member procedure lines_to_dbms_output(self in ut_output_bulk_buffer, a_initial_timeout number := null, a_timeout_sec number := null) is - l_data sys_refcursor; - l_text ut_varchar2_rows; - l_item_type ut_varchar2_rows; - begin - l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); - loop - fetch l_data bulk collect into l_text, l_item_type limit 10000; - for idx in 1 .. l_text.count loop - dbms_output.put_line(l_text(idx)); - end loop; - exit when l_data%notfound; - end loop; - close l_data; - self.remove_buffer_info(); - end; - - overriding member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor is - lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); - l_already_waited_sec number(10,2) := 0; - l_sleep_time number(2,1); - l_exists integer; - l_finished boolean := false; - l_data_produced boolean := false; - l_producer_active boolean := false; - l_producer_started boolean := false; - l_producer_finished boolean := false; - l_results sys_refcursor; - begin - - while not l_finished loop - - if not l_data_produced then - select /*+ no_parallel */ count(1) into l_exists - from ut_output_buffer_tmp o - where o.output_id = self.output_id and rownum = 1; - l_data_produced := (l_exists = 1); - end if; - - l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; - l_producer_active := (self.get_lock_status() <> 0); - l_producer_started := (l_producer_active or l_data_produced ) or l_producer_started; - l_producer_finished := (l_producer_started and not l_producer_active) or l_producer_finished; - l_finished := - self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) - or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) - or l_producer_finished; - - dbms_lock.sleep(l_sleep_time); - l_already_waited_sec := l_already_waited_sec + l_sleep_time; - end loop; - - open l_results for - select /*+ no_parallel */ o.text, o.item_type - from ut_output_buffer_tmp o - where o.output_id = self.output_id - and o.text is not null - order by o.output_id, o.message_id; - - return l_results; - - end; - - /* Important note. - This function code is almost duplicated between two types for performance reasons. - The pipe row clause is much faster on VARCHAR2 then it is on clob. - That is the key reason for two implementations. - */ - overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined is - l_data sys_refcursor; - l_text ut_varchar2_rows; - l_item_type ut_varchar2_rows; - begin - l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); - loop - fetch l_data bulk collect into l_text, l_item_type limit 10000; - for idx in 1 .. l_text.count loop - pipe row( ut_output_data_row(l_text(idx), l_item_type(idx)) ); - end loop; - exit when l_data%notfound; - end loop; - close l_data; - self.remove_buffer_info(); - return; - end; - -end; -/ diff --git a/source/core/output_buffers/ut_output_bulk_buffer.tps b/source/core/output_buffers/ut_output_bulk_buffer.tps deleted file mode 100644 index d74d4ee14..000000000 --- a/source/core/output_buffers/ut_output_bulk_buffer.tps +++ /dev/null @@ -1,27 +0,0 @@ -create or replace type ut_output_bulk_buffer under ut_output_buffer_base ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2023 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_bulk_buffer(self in out nocopy ut_output_bulk_buffer, a_output_id raw := null) return self as result, - overriding member procedure send_line(self in out nocopy ut_output_bulk_buffer, a_text varchar2, a_item_type varchar2 := null), - overriding member procedure send_lines(self in out nocopy ut_output_bulk_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null), - overriding member procedure send_clob(self in out nocopy ut_output_bulk_buffer, a_text clob, a_item_type varchar2 := null), - overriding member procedure lines_to_dbms_output(self in ut_output_bulk_buffer, a_initial_timeout number := null, a_timeout_sec number := null), - overriding member function get_lines_cursor(a_initial_timeout number := null, a_timeout_sec number := null) return sys_refcursor, - overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined -) not final -/ diff --git a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql deleted file mode 100644 index 9ff9f7413..000000000 --- a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql +++ /dev/null @@ -1,49 +0,0 @@ -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 - 2021 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; -/ - -create sequence ut_output_clob_buffer_tmp_seq cache 20; diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tpb b/source/core/output_buffers/ut_output_clob_table_buffer.tpb deleted file mode 100644 index 3d49ab08d..000000000 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tpb +++ /dev/null @@ -1,134 +0,0 @@ -create or replace type body ut_output_clob_table_buffer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 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 - insert /*+ no_parallel */ into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_output_clob_buffer_tmp_seq.nextval, 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 /*+ no_parallel */ into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) - select /*+ no_parallel */ self.output_id, ut_output_clob_buffer_tmp_seq.nextval, 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; - 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 - insert /*+ no_parallel */ into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_output_clob_buffer_tmp_seq.nextval, a_text, a_item_type); - end if; - commit; - end; - - overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined is - lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); - l_buffer_rowids ut_varchar2_rows; - l_buffer_data ut_output_data_rows; - l_finished_flags ut_integer_list; - l_already_waited_sec number(10,2) := 0; - l_finished boolean := false; - l_sleep_time number(2,1); - l_lock_status integer; - l_producer_started boolean := false; - l_producer_finished boolean := false; - procedure get_data_from_buffer_table( - a_buffer_data out nocopy ut_output_data_rows, - a_buffer_rowids out nocopy ut_varchar2_rows, - a_finished_flags out nocopy ut_integer_list - ) is - lc_bulk_limit constant integer := 5000; - begin - with ordered_buffer as ( - select /*+ no_parallel index(a) */ ut_output_data_row(a.text, a.item_type), rowidtochar(a.rowid), is_finished - from ut_output_clob_buffer_tmp a - where a.output_id = self.output_id - and a.message_id <= (select min(message_id) from ut_output_clob_buffer_tmp o where o.output_id = self.output_id) + lc_bulk_limit - order by a.message_id - ) - select /*+ no_parallel */ b.* - bulk collect into a_buffer_data, a_buffer_rowids, a_finished_flags - from ordered_buffer b; - end; - - procedure remove_read_data(a_buffer_rowids ut_varchar2_rows) is - pragma autonomous_transaction; - begin - forall i in 1 .. a_buffer_rowids.count - delete from ut_output_clob_buffer_tmp a - where rowid = chartorowid(a_buffer_rowids(i)); - commit; - end; - - begin - while not l_finished loop - - l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; - l_lock_status := self.get_lock_status(); - get_data_from_buffer_table( l_buffer_data, l_buffer_rowids, l_finished_flags ); - - if l_buffer_data.count > 0 then - l_already_waited_sec := 0; - 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_buffer_rowids); - else - --nothing fetched from output, wait. - dbms_lock.sleep(l_sleep_time); - l_already_waited_sec := l_already_waited_sec + l_sleep_time; - end if; - - l_producer_started := (l_lock_status <> 0 or l_buffer_data.count > 0) or l_producer_started; - l_producer_finished := (l_producer_started and l_lock_status = 0 and l_buffer_data.count = 0) or l_producer_finished; - - l_finished := - self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) - or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) - or l_producer_finished - or l_finished; - - end loop; - - self.remove_buffer_info(); - 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 deleted file mode 100644 index 191e64c01..000000000 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tps +++ /dev/null @@ -1,25 +0,0 @@ -create or replace type ut_output_clob_table_buffer under ut_output_buffer_base ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 function get_lines(a_initial_timeout number := null, a_timeout_sec number := 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 deleted file mode 100644 index c5dd95e98..000000000 --- a/source/core/output_buffers/ut_output_data_row.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_output_data_row as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - text clob, - item_type varchar2(1000) -) -/ diff --git a/source/core/output_buffers/ut_output_data_rows.tps b/source/core/output_buffers/ut_output_data_rows.tps deleted file mode 100644 index 097e9beff..000000000 --- a/source/core/output_buffers/ut_output_data_rows.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_output_data_rows as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_output_data_row -/ diff --git a/source/core/output_buffers/ut_output_table_buffer.tpb b/source/core/output_buffers/ut_output_table_buffer.tpb deleted file mode 100644 index e8e2442a7..000000000 --- a/source/core/output_buffers/ut_output_table_buffer.tpb +++ /dev/null @@ -1,164 +0,0 @@ -create or replace type body ut_output_table_buffer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_table_buffer(self in out nocopy ut_output_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 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 - if lengthb(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 - insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); - end if; - commit; - end if; - end; - - 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 /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) - select /*+ no_parallel */ self.output_id, ut_output_buffer_tmp_seq.nextval, 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; - commit; - end; - - 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 - if ut_utils.lengthb_clob(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 - insert /*+ no_parallel */ into ut_output_buffer_tmp(output_id, message_id, text, item_type) - values (self.output_id, ut_output_buffer_tmp_seq.nextval, a_text, a_item_type); - end if; - commit; - end if; - end; - - overriding member procedure lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout number := null, a_timeout_sec number := null) is - l_data sys_refcursor; - l_text ut_varchar2_rows; - l_item_type ut_varchar2_rows; - begin - l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec); - loop - fetch l_data bulk collect into l_text, l_item_type limit 10000; - for idx in 1 .. l_text.count loop - dbms_output.put_line(l_text(idx)); - end loop; - exit when l_data%notfound; - end loop; - close l_data; - end; - - /* Important note. - This function code is almost duplicated between two types for performance reasons. - The pipe row clause is much faster on VARCHAR2 then it is on clob. - That is the key reason for two implementations. - */ - overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined is - lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); - l_buffer_texts ut_varchar2_rows; - l_buffer_item_types ut_varchar2_rows; - l_finished_flags ut_integer_list; - l_already_waited_sec number(10,2) := 0; - l_finished boolean := false; - l_sleep_time number(2,1); - l_lock_status integer; - l_producer_started boolean := false; - l_producer_finished boolean := false; - - procedure get_data_from_buffer_table( - a_buffer_texts out nocopy ut_varchar2_rows, - a_buffer_item_types out nocopy ut_varchar2_rows, - a_finished_flags out nocopy ut_integer_list - ) is - lc_bulk_limit constant integer := 20000; - pragma autonomous_transaction; - begin - delete /*+ no_parallel */ from ( - select /*+ no_parallel */ * - from ut_output_buffer_tmp a - where a.output_id = self.output_id - and a.message_id <= (select min(message_id) from ut_output_buffer_tmp o where o.output_id = self.output_id) + lc_bulk_limit - order by a.message_id - ) d - returning d.text, d.item_type, d.is_finished - bulk collect into a_buffer_texts, a_buffer_item_types, a_finished_flags; - commit; - end; - begin - while not l_finished loop - - l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; - l_lock_status := self.get_lock_status(); - get_data_from_buffer_table( l_buffer_texts, l_buffer_item_types, l_finished_flags ); - - if l_buffer_texts.count > 0 then - l_already_waited_sec := 0; - for i in 1 .. l_buffer_texts.count loop - if l_buffer_texts(i) is not null then - pipe row( ut_output_data_row(l_buffer_texts(i), l_buffer_item_types(i)) ); - elsif l_finished_flags(i) = 1 then - l_finished := true; - exit; - end if; - end loop; - else - --nothing fetched from output, wait. - dbms_lock.sleep(l_sleep_time); - l_already_waited_sec := l_already_waited_sec + l_sleep_time; - end if; - - l_producer_started := (l_lock_status <> 0 or l_buffer_texts.count > 0) or l_producer_started; - l_producer_finished := (l_producer_started and l_lock_status = 0 and l_buffer_texts.count = 0) or l_producer_finished; - - l_finished := - self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) - or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) - or l_producer_finished - or l_finished; - - end loop; - - self.remove_buffer_info(); - return; - end; - -end; -/ diff --git a/source/core/output_buffers/ut_output_table_buffer.tps b/source/core/output_buffers/ut_output_table_buffer.tps deleted file mode 100644 index 154ce4de6..000000000 --- a/source/core/output_buffers/ut_output_table_buffer.tps +++ /dev/null @@ -1,26 +0,0 @@ -create or replace type ut_output_table_buffer under ut_output_buffer_base ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result, - 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 lines_to_dbms_output(self in ut_output_table_buffer, a_initial_timeout number := null, a_timeout_sec number := null), - overriding member function get_lines(a_initial_timeout number := null, a_timeout_sec number := null) return ut_output_data_rows pipelined -) not final -/ diff --git a/source/core/session_context/ut_session_context.pkb b/source/core/session_context/ut_session_context.pkb deleted file mode 100644 index a97505e9c..000000000 --- a/source/core/session_context/ut_session_context.pkb +++ /dev/null @@ -1,48 +0,0 @@ -create or replace package body ut_session_context as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_context_name constant varchar2(30) := ut_utils.ut_owner()||'_INFO'; - - procedure set_context(a_name varchar2, a_value varchar2) is - begin - dbms_session.set_context( gc_context_name, a_name, a_value ); - end; - - procedure clear_context(a_name varchar2) is - begin - dbms_session.clear_context( namespace => gc_context_name, attribute => a_name ); - end; - - procedure clear_all_context is - begin - dbms_session.clear_all_context( namespace => gc_context_name ); - end; - - function is_ut_run return boolean is - l_paths varchar2(32767); - begin - l_paths := sys_context(gc_context_name, 'RUN_PATHS'); - return l_paths is not null; - end; - - function get_namespace return varchar2 is - begin - return gc_context_name; - end; - -end; -/ \ No newline at end of file diff --git a/source/core/session_context/ut_session_context.pks b/source/core/session_context/ut_session_context.pks deleted file mode 100644 index 63da3399e..000000000 --- a/source/core/session_context/ut_session_context.pks +++ /dev/null @@ -1,45 +0,0 @@ -create or replace package ut_session_context as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /* - * Sets value of a context - */ - procedure set_context(a_name varchar2, a_value varchar2); - - /* - * Clears value of a context - */ - procedure clear_context(a_name varchar2); - - /* - * Clears entire context for utPLSQL run - */ - procedure clear_all_context; - - /* - * Returns true, if session context UT3_INFO is not empty - */ - function is_ut_run return boolean; - - /* - * Returns utPLSQL session context namespace name - */ - function get_namespace return varchar2; - -end; -/ \ No newline at end of file diff --git a/source/core/session_context/ut_session_info.tpb b/source/core/session_context/ut_session_info.tpb deleted file mode 100644 index 7d469651a..000000000 --- a/source/core/session_context/ut_session_info.tpb +++ /dev/null @@ -1,183 +0,0 @@ -create or replace type body ut_session_info as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_session_info(self in out nocopy ut_session_info) return self as result is - begin - self.self_type := $$plsql_unit; - dbms_application_info.read_client_info( client_info ); - dbms_application_info.read_module( module, action ); - return; - end; - - -- run hooks - member procedure before_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is - begin - ut_session_context.set_context( 'run_paths', ut_utils.to_string( ut_utils.table_to_clob( a_run.run_paths,',' ), null ) ); - ut_session_context.set_context( 'coverage_run_id', rawtohex( a_run.coverage_options.coverage_run_id ) ); - dbms_application_info.set_module( 'utPLSQL', null ); - end; - - member procedure after_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is - begin - ut_session_context.clear_context( 'run_paths' ); - ut_session_context.clear_context( 'coverage_run_id' ); - dbms_application_info.set_module( module, action ); - dbms_application_info.set_client_info( client_info ); - end; - - -- suite hooks - member procedure before_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite) is - begin - if a_suite is not of (ut_suite_context) then - ut_session_context.set_context( 'suite_path', a_suite.path ); - ut_session_context.set_context( 'suite_package', a_suite.object_owner||'.'||a_suite.object_name ); - ut_session_context.set_context( 'suite_description', a_suite.description ); - ut_session_context.set_context( 'suite_start_time', ut_utils.to_string(a_suite.start_time) ); - dbms_application_info.set_module( 'utPLSQL', a_suite.object_name ); - else - ut_session_context.set_context( 'context_name', a_suite.name ); - ut_session_context.set_context( 'context_path', a_suite.path); - ut_session_context.set_context( 'context_description', a_suite.description ); - ut_session_context.set_context( 'context_start_time', ut_utils.to_string(a_suite.start_time) ); - end if; - end; - - member procedure after_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite) is - begin - if a_suite is not of (ut_suite_context) then - ut_session_context.clear_context( 'suite_package' ); - ut_session_context.clear_context( 'suite_path' ); - ut_session_context.clear_context( 'suite_description' ); - ut_session_context.clear_context( 'suite_start_time' ); - else - ut_session_context.clear_context( 'context_name' ); - ut_session_context.clear_context( 'context_path' ); - ut_session_context.clear_context( 'context_description' ); - ut_session_context.clear_context( 'context_start_time' ); - end if; - end; - - - member procedure before_calling_test(self in out nocopy ut_session_info, a_test in ut_test) is - begin - ut_session_context.set_context( 'test_name', a_test.object_owner||'.'||a_test.object_name||'.'||a_test.name ); - ut_session_context.set_context( 'test_description', a_test.description ); - ut_session_context.set_context( 'test_start_time', ut_utils.to_string(a_test.start_time) ); - end; - - member procedure after_calling_test (self in out nocopy ut_session_info, a_test in ut_test) is - begin - ut_session_context.clear_context( 'test_name' ); - ut_session_context.clear_context( 'test_description' ); - ut_session_context.clear_context( 'test_start_time' ); - end; - - member procedure before_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable) is - begin - ut_session_context.set_context( 'current_executable_type', a_executable.executable_type ); - ut_session_context.set_context( - 'current_executable_name', - a_executable.owner_name||'.'||a_executable.object_name||'.'||a_executable.procedure_name - ); - dbms_application_info.set_client_info( a_executable.procedure_name ); - end; - - member procedure after_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable) is - begin - ut_session_context.clear_context( 'current_executable_type' ); - ut_session_context.clear_context( 'current_executable_name' ); - dbms_application_info.set_client_info( null ); - end; - - member procedure on_finalize(self in out nocopy ut_session_info, a_run in ut_run) is - begin - dbms_application_info.set_client_info( client_info ); - dbms_application_info.set_module( module, action ); - ut_session_context.clear_all_context(); - end; - - overriding member function get_supported_events return ut_varchar2_list is - begin - return ut_varchar2_list( - ut_event_manager.gc_before_run, - ut_event_manager.gc_before_suite, - ut_event_manager.gc_before_test, - ut_event_manager.gc_before_before_all, - ut_event_manager.gc_before_before_each, - ut_event_manager.gc_before_before_test, - ut_event_manager.gc_before_test_execute, - ut_event_manager.gc_before_after_test, - ut_event_manager.gc_before_after_each, - ut_event_manager.gc_before_after_all, - ut_event_manager.gc_after_run, - ut_event_manager.gc_after_suite, - ut_event_manager.gc_after_test, - ut_event_manager.gc_after_before_all, - ut_event_manager.gc_after_before_each, - ut_event_manager.gc_after_before_test, - ut_event_manager.gc_after_test_execute, - ut_event_manager.gc_after_after_test, - ut_event_manager.gc_after_after_each, - ut_event_manager.gc_after_after_all, - ut_event_manager.gc_finalize - ); - end; - - overriding member procedure on_event( self in out nocopy ut_session_info, a_event_name varchar2, a_event_item ut_event_item) is - begin - case - when a_event_name in ( - ut_event_manager.gc_before_before_all, - ut_event_manager.gc_before_before_each, - ut_event_manager.gc_before_before_test, - ut_event_manager.gc_before_test_execute, - ut_event_manager.gc_before_after_test, - ut_event_manager.gc_before_after_each, - ut_event_manager.gc_before_after_all - ) - then before_calling_executable(treat(a_event_item as ut_executable)); - when a_event_name in ( - ut_event_manager.gc_after_before_all, - ut_event_manager.gc_after_before_each, - ut_event_manager.gc_after_before_test, - ut_event_manager.gc_after_test_execute, - ut_event_manager.gc_after_after_test, - ut_event_manager.gc_after_after_each, - ut_event_manager.gc_after_after_all - ) - then after_calling_executable(treat(a_event_item as ut_executable)); - when a_event_name = ut_event_manager.gc_before_test - then self.before_calling_test(treat(a_event_item as ut_test)); - when a_event_name = ut_event_manager.gc_after_test - then self.after_calling_test(treat(a_event_item as ut_test)); - when a_event_name = ut_event_manager.gc_after_suite - then after_calling_suite(treat(a_event_item as ut_logical_suite)); - when a_event_name = ut_event_manager.gc_before_suite - then before_calling_suite(treat(a_event_item as ut_logical_suite)); - when a_event_name = ut_event_manager.gc_before_run - then before_calling_run(treat(a_event_item as ut_run)); - when a_event_name = ut_event_manager.gc_after_run - then after_calling_run(treat(a_event_item as ut_run)); - when a_event_name = ut_event_manager.gc_finalize - then on_finalize(treat(a_event_item as ut_run)); - else null; - end case; - end; - -end; -/ \ No newline at end of file diff --git a/source/core/session_context/ut_session_info.tps b/source/core/session_context/ut_session_info.tps deleted file mode 100644 index 17e596d88..000000000 --- a/source/core/session_context/ut_session_info.tps +++ /dev/null @@ -1,49 +0,0 @@ -create or replace type ut_session_info under ut_event_listener ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - module varchar2(4000), - action varchar2(4000), - client_info varchar2(4000), - constructor function ut_session_info(self in out nocopy ut_session_info) return self as result, - - member procedure before_calling_run(self in out nocopy ut_session_info, a_run in ut_run), - member procedure after_calling_run (self in out nocopy ut_session_info, a_run in ut_run), - - member procedure before_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite), - member procedure after_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite), - - member procedure before_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable), - member procedure after_calling_executable (self in out nocopy ut_session_info, a_executable in ut_executable), - - member procedure before_calling_test(self in out nocopy ut_session_info, a_test in ut_test), - member procedure after_calling_test (self in out nocopy ut_session_info, a_test in ut_test), - - member procedure on_finalize(self in out nocopy ut_session_info, a_run in ut_run), - - /** - * Returns the list of events that are supported by particular implementation of the reporter - */ - overriding member function get_supported_events return ut_varchar2_list, - - /** - * Delegates execution of event into individual reporting procedures - */ - overriding member procedure on_event( self in out nocopy ut_session_info, a_event_name varchar2, a_event_item ut_event_item) - -) final -/ \ No newline at end of file diff --git a/source/core/types/ut_console_reporter_base.tpb b/source/core/types/ut_console_reporter_base.tpb deleted file mode 100644 index 909e9355a..000000000 --- a/source/core/types/ut_console_reporter_base.tpb +++ /dev/null @@ -1,45 +0,0 @@ -create or replace type body ut_console_reporter_base is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - static procedure set_color_enabled(a_flag boolean) is - begin - ut_ansiconsole_helper.color_enabled(a_flag); - end; - - member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is - begin - self.print_text(ut_ansiconsole_helper.red(a_text)); - end; - - member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is - begin - self.print_text(ut_ansiconsole_helper.green(a_text)); - end; - - member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is - begin - self.print_text(ut_ansiconsole_helper.yellow(a_text)); - end; - - member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is - begin - self.print_text(ut_ansiconsole_helper.cyan(a_text)); - end; - -end; -/ diff --git a/source/core/types/ut_console_reporter_base.tps b/source/core/types/ut_console_reporter_base.tps deleted file mode 100644 index a2c4b6b8c..000000000 --- a/source/core/types/ut_console_reporter_base.tps +++ /dev/null @@ -1,29 +0,0 @@ -create or replace type ut_console_reporter_base under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - static procedure set_color_enabled(a_flag boolean), - - member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2), - - member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2), - - member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2), - - member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2) - -) not final not instantiable -/ diff --git a/source/core/types/ut_coverage_options.tpb b/source/core/types/ut_coverage_options.tpb deleted file mode 100644 index a091802af..000000000 --- a/source/core/types/ut_coverage_options.tpb +++ /dev/null @@ -1,73 +0,0 @@ -create or replace type body ut_coverage_options as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_options( - self in out nocopy ut_coverage_options, - coverage_run_id raw, - schema_names ut_varchar2_rows := null, - exclude_objects ut_varchar2_rows := null, - include_objects ut_varchar2_rows := null, - file_mappings ut_file_mappings := null, - include_schema_expr varchar2 := null, - include_object_expr varchar2 := null, - exclude_schema_expr varchar2 := null, - exclude_object_expr varchar2 := null - ) return self as result is - function to_ut_object_list(a_names ut_varchar2_rows, a_schema_names ut_varchar2_rows) return ut_object_names is - l_result ut_object_names; - l_object_name ut_object_name; - begin - if a_names is not empty then - l_result := ut_object_names(); - for i in 1 .. a_names.count loop - l_object_name := ut_object_name(a_names(i)); - if l_object_name.owner is null then - for i in 1 .. cardinality(a_schema_names) loop - l_result.extend; - l_result(l_result.last) := ut_object_name(a_schema_names(i)||'.'||l_object_name.name); - end loop; - else - l_result.extend; - l_result(l_result.last) := l_object_name; - end if; - end loop; - end if; - return l_result; - end; - begin - self.coverage_run_id := coverage_run_id; - self.file_mappings := file_mappings; - self.schema_names := schema_names; - self.exclude_objects := ut_object_names(); - - if exclude_objects is not empty then - self.exclude_objects := to_ut_object_list(exclude_objects, self.schema_names); - end if; - - self.include_objects := to_ut_object_list(include_objects, self.schema_names); - - self.include_schema_expr := include_schema_expr; - self.include_object_expr := include_object_expr; - self.exclude_schema_expr := exclude_schema_expr; - self.exclude_object_expr := exclude_object_expr; - - - return; - end; -end; -/ diff --git a/source/core/types/ut_coverage_options.tps b/source/core/types/ut_coverage_options.tps deleted file mode 100644 index a8e3d5129..000000000 --- a/source/core/types/ut_coverage_options.tps +++ /dev/null @@ -1,41 +0,0 @@ -create or replace type ut_coverage_options force as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - coverage_run_id raw(32), - schema_names ut_varchar2_rows, - exclude_objects ut_object_names, - include_objects ut_object_names, - file_mappings ut_file_mappings, - include_schema_expr varchar2(4000), - include_object_expr varchar2(4000), - exclude_schema_expr varchar2(4000), - exclude_object_expr varchar2(4000), - constructor function ut_coverage_options( - self in out nocopy ut_coverage_options, - coverage_run_id raw, - schema_names ut_varchar2_rows := null, - exclude_objects ut_varchar2_rows := null, - include_objects ut_varchar2_rows := null, - file_mappings ut_file_mappings := null, - include_schema_expr varchar2 := null, - include_object_expr varchar2 := null, - exclude_schema_expr varchar2 := null, - exclude_object_expr varchar2 := null - ) return self as result -) -/ diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb deleted file mode 100644 index d2ce9b79d..000000000 --- a/source/core/types/ut_executable.tpb +++ /dev/null @@ -1,183 +0,0 @@ -create or replace type body ut_executable is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_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 is - begin - self.self_type := $$plsql_unit; - self.executable_type := a_executable_type; - self.owner_name := a_owner; - self.object_name := a_package; - self.procedure_name := a_procedure_name; - return; - end; - - member function form_name(a_skip_current_user_schema boolean := false) return varchar2 is - l_owner_name varchar2(250) := owner_name; - begin - 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 - l_completed_without_errors boolean; - begin - l_completed_without_errors := self.do_execute(a_item); - end do_execute; - - member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean is - l_statement varchar2(4000); - l_status number; - l_cursor_number number; - l_completed_without_errors boolean := true; - l_failed_with_invalid_pck boolean := true; - l_start_transaction_id varchar2(250); - l_end_transaction_id varchar2(250); - - function is_defined return boolean is - l_result boolean := false; - l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; - begin - - if self.object_name is null then - self.error_stack := l_message_part || 'package is not defined'; - elsif self.procedure_name is null then - self.error_stack := l_message_part || 'procedure is not defined'; - else - l_result := true; - end if; - - return l_result; - end is_defined; - - function is_invalid return boolean is - l_result boolean := true; - l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: '; - begin - - if not ut_metadata.package_valid(self.owner_name, self.object_name) then - 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 '||upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name)||' does not exist.'; - else - l_result := false; - end if; - - return l_result; - end is_invalid; - - procedure save_dbms_output is - l_status number; - l_line varchar2(32767); - begin - - dbms_output.get_line(line => l_line, status => l_status); - if l_status != 1 then - dbms_lob.createtemporary(self.serveroutput, true, dur => dbms_lob.session); - end if; - while l_status != 1 loop - if l_line is not null then - ut_utils.append_to_clob(self.serveroutput, l_line||chr(10)); - end if; - dbms_output.get_line(line => l_line, status => l_status); - end loop; - end save_dbms_output; - begin - l_start_transaction_id := dbms_transaction.local_transaction_id(true); - - --listener - before call to executable - ut_event_manager.trigger_event('before_'||self.executable_type, self); - - l_completed_without_errors := is_defined(); - if l_completed_without_errors then - l_statement := - 'declare' || chr(10) || - ' l_error_stack varchar2(32767);' || chr(10) || - ' l_error_backtrace varchar2(32767);' || chr(10) || - 'begin' || chr(10) || - ' begin' || 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) || - ' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) || - ' --raise on ORA-04068, ORA-04061: existing state of packages has been discarded to avoid unrecoverable session exception' || chr(10) || - ' end;' || chr(10) || - ' :a_error_stack := l_error_stack;' || chr(10) || - ' :a_error_backtrace := l_error_backtrace;' || chr(10) || - 'end;'; - - ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement); - - l_cursor_number := dbms_sql.open_cursor; - - /** - * The code will allow to execute once we check if packages are defined - * If it fail with 6550 (usually invalid package) it will check if because of invalid state or missing - * if for any other reason we will propagate it up as we didnt expected. - **/ - begin - dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native); - dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767); - dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767); - l_status := dbms_sql.execute(l_cursor_number); - dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack); - dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace); - dbms_sql.close_cursor(l_cursor_number); - exception - when ut_utils.ex_invalid_package then - l_failed_with_invalid_pck := is_invalid(); - dbms_sql.close_cursor(l_cursor_number); - if not l_failed_with_invalid_pck then - raise; - end if; - when others then - dbms_sql.close_cursor(l_cursor_number); - raise; - end; - - save_dbms_output; - - l_completed_without_errors := (self.error_stack||self.error_backtrace) is null; - if self.error_stack like '%ORA-04068%' or self.error_stack like '%ORA-04061%' then - ut_expectation_processor.set_invalidation_exception(); - end if; - end if; - - --listener - after call to executable - ut_event_manager.trigger_event('after_'||self.executable_type, self); - - l_end_transaction_id := dbms_transaction.local_transaction_id(); - if l_start_transaction_id != l_end_transaction_id or l_end_transaction_id is null then - a_item.add_transaction_invalidator(self.form_name()); - end if; - - return l_completed_without_errors; - - end do_execute; - - member function get_error_stack_trace return varchar2 is - begin - return rtrim(self.error_stack||self.error_backtrace, chr(10)); - end; -end; -/ diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps deleted file mode 100644 index aaa5a3a72..000000000 --- a/source/core/types/ut_executable.tps +++ /dev/null @@ -1,43 +0,0 @@ -create or replace type ut_executable under ut_event_item( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * The name of the event to be executed before and after the executable is invoked - */ - executable_type varchar2(250 char), - owner_name varchar2(250 char), - object_name varchar2(250 char), - procedure_name varchar2(250 char), - error_backtrace varchar2(4000), - error_stack varchar2(4000), - serveroutput clob, - /** - * Used for ordering of executables, as Oracle doesn not guarantee ordering of items in a nested table. - */ - 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(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 - * returns true if executed without exceptions - * returns false if exceptions were raised - */ - member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean, - member function get_error_stack_trace return varchar2 -) not final -/ diff --git a/source/core/types/ut_executable_test.tpb b/source/core/types/ut_executable_test.tpb deleted file mode 100644 index fa5872e04..000000000 --- a/source/core/types/ut_executable_test.tpb +++ /dev/null @@ -1,195 +0,0 @@ -create or replace type body ut_executable_test as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_executable_test( - self in out nocopy ut_executable_test, a_owner varchar2, a_package varchar2, - a_procedure_name varchar2, a_executable_type varchar2 - ) return self as result is - begin - self.self_type := $$plsql_unit; - self.executable_type := a_executable_type; - self.owner_name := a_owner; - self.object_name := a_package; - self.procedure_name := a_procedure_name; - return; - end; - - member procedure do_execute( - self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows - ) is - l_completed_without_errors boolean; - begin - l_completed_without_errors := self.do_execute(a_item, a_expected_error_codes); - end do_execute; - - member function do_execute( - self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows - ) return boolean is - l_expected_except_message varchar2(4000); - l_expected_error_numbers ut_integer_list; - - function build_exception_numbers_list( - a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows - ) return ut_integer_list is - l_exception_number integer; - l_exception_number_list ut_integer_list := ut_integer_list(); - c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$'; - - c_integer_exception constant varchar2(1) := 'I'; - c_named_exception constant varchar2(1) := 'N'; - - function is_valid_qualified_name (a_name varchar2) return boolean is - l_name varchar2(500); - begin - l_name := dbms_assert.qualified_sql_name(a_name); - return true; - exception when others then - return false; - end; - - function check_exception_type(a_exception_name in varchar2) return varchar2 is - l_exception_type varchar2(50); - begin - --check if it is a predefined exception - begin - execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; - l_exception_type := c_named_exception; - exception - when others then - if dbms_utility.format_error_stack() like '%PLS-00485%' then - declare - e_invalid_number exception; - pragma exception_init ( e_invalid_number, -6502 ); - begin - execute immediate 'declare x integer := '||a_exception_name||'; begin null; end;'; - l_exception_type := c_integer_exception; - exception - when others then - null; - end; - end if; - end; - return l_exception_type; - end; - - function get_exception_number (a_exception_var in varchar2) return integer is - l_exc_no integer; - l_exc_type varchar2(50); - function remap_no_data_found (a_number integer) return integer is - begin - return case a_number when 100 then -1403 else a_number end; - end; - begin - l_exc_type := check_exception_type(a_exception_var); - - execute immediate - case l_exc_type - when c_integer_exception then - 'declare l_exception number; begin :l_exception := '||a_exception_var||'; end;' - when c_named_exception then - 'begin raise '||a_exception_var||'; exception when others then :l_exception := sqlcode; end;' - else - 'begin :l_exception := null; end;' - end - using out l_exc_no; - - return remap_no_data_found(l_exc_no); - end; - - begin - if a_expected_error_codes is not empty then - for i in 1 .. a_expected_error_codes.count loop - /** - * Check if its a valid qualified name and if so try to resolve name to an exception number - */ - if is_valid_qualified_name(a_expected_error_codes(i)) then - l_exception_number := get_exception_number(a_expected_error_codes(i)); - elsif regexp_like(a_expected_error_codes(i), c_regexp_for_exception_no) then - l_exception_number := a_expected_error_codes(i); - end if; - - if l_exception_number is null then - a_item.put_warning( - 'Invalid parameter value "'||a_expected_error_codes(i)||'" for "--%throws" annotation. Parameter ignored.', - self.procedure_name, - a_item.line_no - ); - elsif l_exception_number >= 0 then - a_item.put_warning( - 'Invalid parameter value "'||a_expected_error_codes(i)||'" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.', - self.procedure_name, - a_item.line_no - ); - else - l_exception_number_list.extend; - l_exception_number_list(l_exception_number_list.last) := l_exception_number; - end if; - l_exception_number := null; - end loop; - end if; - - return l_exception_number_list; - end; - function failed_expec_errnum_message(a_expected_error_codes in ut_integer_list) return varchar is - l_actual_error_no integer; - l_expected_error_codes varchar2(4000); - l_fail_message varchar2(4000); - begin - --Convert the ut_varchar2_list to string to can construct the message - l_expected_error_codes := ut_utils.table_to_clob(a_expected_error_codes, ', '); - - if self.error_stack is null then - l_fail_message := 'Expected one of exceptions ('||l_expected_error_codes||') but nothing was raised.'; - else - l_actual_error_no := regexp_substr(self.error_stack, '^[[:alpha:]]{3}(-[0-9]+)', subexpression=>1); - if not l_actual_error_no member of a_expected_error_codes or l_actual_error_no is null then - l_fail_message := 'Actual: '||l_actual_error_no||' was expected to '; - if cardinality(a_expected_error_codes) > 1 then - l_fail_message := l_fail_message || 'be one of: ('||l_expected_error_codes||')'; - else - l_fail_message := l_fail_message || 'equal: '||l_expected_error_codes; - end if; - l_fail_message := substr( l_fail_message||chr(10)||self.error_stack||chr(10)||self.error_backtrace, 1, 4000 ); - end if; - end if; - - return l_fail_message; - end; - begin - --Create a ut_executable object and call do_execute after that get the data to know the test's execution result - self.do_execute(a_item); - l_expected_error_numbers := build_exception_numbers_list(a_item, a_expected_error_codes); - if l_expected_error_numbers is not null and l_expected_error_numbers is not empty then - l_expected_except_message := failed_expec_errnum_message( l_expected_error_numbers ); - - if l_expected_except_message is not null then - ut_expectation_processor.add_expectation_result( - ut_expectation_result(ut_utils.gc_failure, null, l_expected_except_message, false) - ); - end if; - self.error_stack := null; - self.error_backtrace := null; - end if; - - return (self.error_stack||self.error_backtrace) is null; - end; -end; -/ diff --git a/source/core/types/ut_executable_test.tps b/source/core/types/ut_executable_test.tps deleted file mode 100644 index 42b6080df..000000000 --- a/source/core/types/ut_executable_test.tps +++ /dev/null @@ -1,34 +0,0 @@ -create or replace type ut_executable_test authid current_user under ut_executable ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_executable_test( - self in out nocopy ut_executable_test, a_owner varchar2, a_package varchar2, - a_procedure_name varchar2, a_executable_type varchar2 - ) return self as result, - - member procedure do_execute( - self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows - ), - - member function do_execute( - self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows - ) return boolean - -) final; -/ diff --git a/source/core/types/ut_executables.tps b/source/core/types/ut_executables.tps deleted file mode 100644 index d6d52b3d2..000000000 --- a/source/core/types/ut_executables.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_executables as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_executable -/ diff --git a/source/core/types/ut_expectation_result.tpb b/source/core/types/ut_expectation_result.tpb deleted file mode 100644 index 0b3adf983..000000000 --- a/source/core/types/ut_expectation_result.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_expectation_result is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_result( - self in out nocopy ut_expectation_result, a_status integer, - a_description varchar2, a_message clob, a_include_caller_info boolean := true - ) return self as result is - begin - self.self_type := $$plsql_unit; - self.status := a_status; - self.description := a_description; - self.message := a_message; - if self.status = ut_utils.gc_failure and a_include_caller_info then - self.caller_info := ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack()); - end if; - return; - end; - - member function get_result_clob(self in ut_expectation_result) return clob is - l_result clob; - begin - if self.description is not null then - ut_utils.append_to_clob(l_result, '"'||self.description||'"'); - if self.message is not null then - ut_utils.append_to_clob(l_result, chr(10)); - end if; - end if; - ut_utils.append_to_clob(l_result, self.message); - return l_result; - end; - - member function get_result_lines(self in ut_expectation_result) return ut_varchar2_list is - begin - return ut_utils.clob_to_table(get_result_clob(), 4000 ); - end; - - member function result return integer is - begin - return self.status; - end; - -end; -/ diff --git a/source/core/types/ut_expectation_result.tps b/source/core/types/ut_expectation_result.tps deleted file mode 100644 index d4b4c7548..000000000 --- a/source/core/types/ut_expectation_result.tps +++ /dev/null @@ -1,45 +0,0 @@ -create or replace type ut_expectation_result under ut_event_item( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /* - * The expectation result status - */ - status integer(1), - /* - * User description provided with the expectation - */ - description varchar2(32767), - /* - * Additional information about the expression used by matcher - * Used for complex matcher: like, between, ut_match etc. - */ - message varchar2(32767), - /* - * The information about the line of code that invoked the expectation - */ - caller_info varchar2(32767), - constructor function ut_expectation_result( - self in out nocopy ut_expectation_result, a_status integer, - a_description varchar2, a_message clob, a_include_caller_info boolean := true - ) return self as result, - member function get_result_clob(self in ut_expectation_result) return clob, - member function get_result_lines(self in ut_expectation_result) return ut_varchar2_list, - member function result return integer -) -not final -/ diff --git a/source/core/types/ut_expectation_results.tps b/source/core/types/ut_expectation_results.tps deleted file mode 100644 index e5e4c6223..000000000 --- a/source/core/types/ut_expectation_results.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_expectation_results as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_expectation_result -/ diff --git a/source/core/types/ut_file_mapping.tpb b/source/core/types/ut_file_mapping.tpb deleted file mode 100644 index dab1e35c5..000000000 --- a/source/core/types/ut_file_mapping.tpb +++ /dev/null @@ -1,23 +0,0 @@ -create or replace type body ut_file_mapping as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - map member function pk return varchar2 is - begin - return object_type||' '||object_owner||'.'||object_name; - end; -end; -/ diff --git a/source/core/types/ut_file_mapping.tps b/source/core/types/ut_file_mapping.tps deleted file mode 100644 index 941d95283..000000000 --- a/source/core/types/ut_file_mapping.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_file_mapping as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - file_name varchar2(4000), - object_owner varchar2(4000), - object_name varchar2(4000), - object_type varchar2(4000), - map member function pk return varchar2 -) -/ diff --git a/source/core/types/ut_file_mappings.tps b/source/core/types/ut_file_mappings.tps deleted file mode 100644 index 240fb8dd7..000000000 --- a/source/core/types/ut_file_mappings.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_file_mappings as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_file_mapping -/ diff --git a/source/core/types/ut_integer_list.tps b/source/core/types/ut_integer_list.tps deleted file mode 100644 index ec9a2a78f..000000000 --- a/source/core/types/ut_integer_list.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_integer_list as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 integer -/ diff --git a/source/core/types/ut_key_value_pair.tps b/source/core/types/ut_key_value_pair.tps deleted file mode 100644 index 5a337e608..000000000 --- a/source/core/types/ut_key_value_pair.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_key_value_pair force as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - key varchar2(4000), - value varchar2(4000) -) -/ diff --git a/source/core/types/ut_key_value_pairs.tps b/source/core/types/ut_key_value_pairs.tps deleted file mode 100644 index 24bdded36..000000000 --- a/source/core/types/ut_key_value_pairs.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_key_value_pairs as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_key_value_pair -/ diff --git a/source/core/types/ut_logical_suite.tpb b/source/core/types/ut_logical_suite.tpb deleted file mode 100644 index 036d40d51..000000000 --- a/source/core/types/ut_logical_suite.tpb +++ /dev/null @@ -1,119 +0,0 @@ -create or replace type body ut_logical_suite as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2) is - begin - ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); - self.start_time := current_timestamp; - for i in 1 .. self.items.count loop - self.items(i).mark_as_skipped(coalesce(a_skip_reason,self.disabled_reason)); - end loop; - self.end_time := self.start_time; - ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self); - self.calc_execution_result(); - end; - - overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false) is - begin - self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end; - for i in 1 .. self.items.count loop - self.items(i).set_rollback_type(self.rollback_type, a_force); - end loop; - end; - - overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean is - l_suite_savepoint varchar2(30); - l_item_savepoint varchar2(30); - l_completed_without_errors boolean; - begin - ut_utils.debug_log('ut_logical_suite.execute'); - - ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); - self.start_time := current_timestamp; - - for i in 1 .. self.items.count loop - -- execute the item (test or suite) - self.items(i).do_execute(); - end loop; - - self.calc_execution_result(); - self.end_time := current_timestamp; - - ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self); - - return l_completed_without_errors; - end; - - overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite) is - l_result integer(1); - begin - if self.items is not null and self.items.count > 0 then - for i in 1 .. self.items.count loop - self.results_count.sum_counter_values( self.items(i).results_count ); - end loop; - l_result := self.results_count.result_status(); - else - --if suite is empty then it's successful (no errors) - l_result := ut_utils.gc_success; - end if; - - self.result := l_result; - end; - - overriding member procedure mark_as_errored(self in out nocopy ut_logical_suite, a_error_stack_trace varchar2) is - begin - ut_utils.debug_log('ut_logical_suite.fail'); - ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); - self.start_time := current_timestamp; - for i in 1 .. self.items.count loop - -- execute the item (test or suite) - self.items(i).mark_as_errored(a_error_stack_trace); - end loop; - self.calc_execution_result(); - self.end_time := self.start_time; - ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self); - end; - - overriding member function get_error_stack_traces return ut_varchar2_list is - begin - return ut_varchar2_list(); - end; - - overriding member function get_serveroutputs return clob is - begin - return null; - end; - - overriding member function get_transaction_invalidators return ut_varchar2_list is - l_result ut_varchar2_list; - l_child_results ut_varchar2_list; - begin - l_result := self.transaction_invalidators; - for i in 1 .. self.items.count loop - l_child_results := self.items(i).get_transaction_invalidators(); - for j in 1 .. l_child_results.count loop - if l_child_results(j) not member of l_result then - l_result.extend; l_result(l_result.last) := l_child_results(j); - end if; - end loop; - end loop; - return l_result; - end; - -end; -/ diff --git a/source/core/types/ut_logical_suite.tps b/source/core/types/ut_logical_suite.tps deleted file mode 100644 index c4f2f699b..000000000 --- a/source/core/types/ut_logical_suite.tps +++ /dev/null @@ -1,33 +0,0 @@ -create or replace type ut_logical_suite force under ut_suite_item ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * The list of items (suites/sub-suites/contexts/tests) to be invoked as part of this suite - */ - items ut_suite_items, - - overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite, a_skip_reason in varchar2), - overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false), - overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean, - overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite), - overriding member procedure mark_as_errored(self in out nocopy ut_logical_suite, a_error_stack_trace varchar2), - overriding member function get_error_stack_traces return ut_varchar2_list, - overriding member function get_serveroutputs return clob, - overriding member function get_transaction_invalidators return ut_varchar2_list -) not final -/ diff --git a/source/core/types/ut_object_name.tpb b/source/core/types/ut_object_name.tpb deleted file mode 100644 index 76acc15bf..000000000 --- a/source/core/types/ut_object_name.tpb +++ /dev/null @@ -1,42 +0,0 @@ -create or replace type body ut_object_name as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_object_name(self in out nocopy ut_object_name, owner varchar2, name varchar2) return self as result is - begin - self.owner := upper(owner); - self.name := upper(name); - return; - end; - - constructor function ut_object_name(self in out nocopy ut_object_name, a_unit_name varchar2) return self as result is - begin - if instr(a_unit_name,'.') > 0 then - self.owner := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 1)); - self.name := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 2)); - else - self.name := upper(a_unit_name); - end if; - return; - end; - - - map member function identity return varchar2 is - begin - return owner||'.'||name; - end; -end; -/ diff --git a/source/core/types/ut_object_name.tps b/source/core/types/ut_object_name.tps deleted file mode 100644 index 5f8f724c4..000000000 --- a/source/core/types/ut_object_name.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_object_name as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - owner varchar2(128), - name varchar2(128), - constructor function ut_object_name(self in out nocopy ut_object_name, owner varchar2, name varchar2) return self as result , - constructor function ut_object_name(self in out nocopy ut_object_name, a_unit_name varchar2) return self as result , - map member function identity return varchar2 -) final -/ diff --git a/source/core/types/ut_object_names.tps b/source/core/types/ut_object_names.tps deleted file mode 100644 index 03830be17..000000000 --- a/source/core/types/ut_object_names.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_object_names as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_object_name -/ diff --git a/source/core/types/ut_output_reporter_base.tpb b/source/core/types/ut_output_reporter_base.tpb deleted file mode 100644 index 48970be5a..000000000 --- a/source/core/types/ut_output_reporter_base.tpb +++ /dev/null @@ -1,88 +0,0 @@ -create or replace type body ut_output_reporter_base is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_reporter_base(self in out nocopy ut_output_reporter_base) return self as result is - begin - return; - end; - - member procedure init(self in out nocopy ut_output_reporter_base, a_self_type varchar2, a_output_buffer ut_output_buffer_base := null) is - begin - (self as ut_reporter_base).init(a_self_type); - self.output_buffer := coalesce(a_output_buffer, ut_output_table_buffer()); - self.set_reporter_id(self.output_buffer.output_id); - end; - - overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw) is - begin - self.id := a_reporter_id; - self.output_buffer.init(a_reporter_id); - end; - - member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base is - l_result ut_output_reporter_base := self; - begin - l_result.set_reporter_id(a_reporter_id); - return l_result; - end; - - member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null) is - begin - self.output_buffer.send_line(a_text, a_item_type); - end; - - member procedure print_text_lines(self in out nocopy ut_output_reporter_base, a_text_lines ut_varchar2_rows, a_item_type varchar2 := null) is - begin - self.output_buffer.send_lines(a_text_lines, a_item_type); - end; - - member procedure print_clob(self in out nocopy ut_output_reporter_base, a_clob clob, a_item_type varchar2 := null) is - begin - self.output_buffer.send_clob( a_clob, a_item_type ); - end; - - final member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural) return ut_output_data_rows pipelined is - begin - for i in (select /*+ no_parallel */ value(x) val from table(self.output_buffer.get_lines(a_initial_timeout, a_timeout_sec)) x ) loop - pipe row (i.val); - end loop; - end; - - final member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural) return sys_refcursor is - begin - return self.output_buffer.get_lines_cursor(a_initial_timeout, a_timeout_sec); - end; - - final member procedure lines_to_dbms_output(self in ut_output_reporter_base, a_initial_timeout natural := null, a_timeout_sec natural) is - begin - self.output_buffer.lines_to_dbms_output(a_initial_timeout, a_timeout_sec); - end; - - overriding final member procedure on_finalize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is - begin - self.output_buffer.close(); - end; - - overriding member procedure on_initialize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is - begin - self.output_buffer.lock_buffer(); - self.output_buffer.send_line(null, 'initialize'); - end; - -end; -/ diff --git a/source/core/types/ut_output_reporter_base.tps b/source/core/types/ut_output_reporter_base.tps deleted file mode 100644 index 21eed9957..000000000 --- a/source/core/types/ut_output_reporter_base.tps +++ /dev/null @@ -1,35 +0,0 @@ -create or replace type ut_output_reporter_base under ut_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - output_buffer ut_output_buffer_base, - constructor function ut_output_reporter_base(self in out nocopy ut_output_reporter_base) return self as result, - member procedure init(self in out nocopy ut_output_reporter_base, a_self_type varchar2, a_output_buffer ut_output_buffer_base := null), - overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw), - member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base, - - member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null), - member procedure print_text_lines(self in out nocopy ut_output_reporter_base, a_text_lines ut_varchar2_rows, a_item_type varchar2 := null), - member procedure print_clob(self in out nocopy ut_output_reporter_base, a_clob clob, a_item_type varchar2 := null), - - final member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined, - final member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor, - final member procedure lines_to_dbms_output(self in ut_output_reporter_base, a_initial_timeout natural := null, a_timeout_sec natural := null), - overriding final member procedure on_finalize(self in out nocopy ut_output_reporter_base, a_run in ut_run), - overriding member procedure on_initialize(self in out nocopy ut_output_reporter_base, a_run in ut_run) -) -not final not instantiable -/ diff --git a/source/core/types/ut_path_item.tpb b/source/core/types/ut_path_item.tpb deleted file mode 100644 index 6cdb2b8ad..000000000 --- a/source/core/types/ut_path_item.tpb +++ /dev/null @@ -1,42 +0,0 @@ -create or replace type body ut_path_item as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2) return self as result is - begin - self.schema_name := schema_name; - self.object_name := object_name; - self.procedure_name := procedure_name; - return; - end; - - constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2,suite_path varchar2) return self as result is - begin - self.schema_name := schema_name; - self.suite_path := suite_path; - return; - end; - - constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2) return self as result is - begin - self.schema_name := schema_name; - self.object_name := object_name; - self.procedure_name := procedure_name; - self.suite_path := suite_path; - return; - end; -end; -/ diff --git a/source/core/types/ut_path_item.tps b/source/core/types/ut_path_item.tps deleted file mode 100644 index c8ec81be5..000000000 --- a/source/core/types/ut_path_item.tps +++ /dev/null @@ -1,26 +0,0 @@ -create or replace type ut_path_item as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - schema_name varchar2(4000), - object_name varchar2(250), - procedure_name varchar2(250), - suite_path varchar2(4000), - constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2) return self as result, - constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, suite_path varchar2) return self as result, - constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2) return self as result -) -/ diff --git a/source/core/types/ut_path_items.tps b/source/core/types/ut_path_items.tps deleted file mode 100644 index 0c87cf28c..000000000 --- a/source/core/types/ut_path_items.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_path_items as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_path_item -/ diff --git a/source/core/types/ut_reporter_base.tpb b/source/core/types/ut_reporter_base.tpb deleted file mode 100644 index 017dc8971..000000000 --- a/source/core/types/ut_reporter_base.tpb +++ /dev/null @@ -1,221 +0,0 @@ -create or replace type body ut_reporter_base is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - final member procedure init(self in out nocopy ut_reporter_base, a_self_type varchar2) is - begin - self.self_type := a_self_type; - self.id := sys_guid(); - return; - end; - - member procedure set_reporter_id(self in out nocopy ut_reporter_base, a_reporter_id raw) is - begin - self.id := a_reporter_id; - end; - - member function get_reporter_id return raw is - begin - return self.id; - end; - - member function get_description return varchar2 is - begin - return 'No description available'; - end; - - -- run hooks - member procedure before_calling_run(self in out nocopy ut_reporter_base, a_run in ut_run) is - begin - null; - end; - - -- suite hooks - member procedure before_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is - begin - null; - end; - - member procedure before_calling_before_all(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_before_all (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - member procedure before_calling_before_each(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_before_each (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - -- test hooks - member procedure before_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is - begin - null; - end; - - member procedure before_calling_before_test(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_before_test (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - member procedure before_calling_test_execute(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_test_execute (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - member procedure before_calling_after_test(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_after_test (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - member procedure after_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is - begin - null; - end; - - --suite hooks continued - member procedure before_calling_after_each(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_after_each (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - member procedure before_calling_after_all(self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - member procedure after_calling_after_all (self in out nocopy ut_reporter_base, a_executable in ut_executable) is - begin - null; - end; - - member procedure after_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is - begin - null; - end; - - -- run hooks continued - member procedure after_calling_run (self in out nocopy ut_reporter_base, a_run in ut_run) is - begin - null; - end; - - overriding member function get_supported_events return ut_varchar2_list is - begin - return ut_varchar2_list( - ut_event_manager.gc_initialize, - ut_event_manager.gc_before_run, - ut_event_manager.gc_before_suite, - ut_event_manager.gc_before_test, - ut_event_manager.gc_before_before_all, - ut_event_manager.gc_before_before_each, - ut_event_manager.gc_before_before_test, - ut_event_manager.gc_before_test_execute, - ut_event_manager.gc_before_after_test, - ut_event_manager.gc_before_after_each, - ut_event_manager.gc_before_after_all, - ut_event_manager.gc_after_run, - ut_event_manager.gc_after_suite, - ut_event_manager.gc_after_test, - ut_event_manager.gc_after_before_all, - ut_event_manager.gc_after_before_each, - ut_event_manager.gc_after_before_test, - ut_event_manager.gc_after_test_execute, - ut_event_manager.gc_after_after_test, - ut_event_manager.gc_after_after_each, - ut_event_manager.gc_after_after_all, - ut_event_manager.gc_finalize - ); - end; - - overriding member procedure on_event( self in out nocopy ut_reporter_base, a_event_name varchar2, a_event_item ut_event_item) is - /* Resolves issue with ORA-21779 being thrown see issue: 1309 -> ( https://github.com/utPLSQL/utPLSQL/issues/1309#issuecomment-4020289898 ) */ - l_event_item ut_event_item := a_event_item; - begin - case a_event_name - when ut_event_manager.gc_initialize - then self.on_initialize(treat(l_event_item as ut_run)); - when ut_event_manager.gc_before_run - then self.before_calling_run(treat(l_event_item as ut_run)); - when ut_event_manager.gc_before_suite - then self.before_calling_suite(treat(l_event_item as ut_logical_suite)); - when ut_event_manager.gc_before_before_all - then self.before_calling_before_all(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_before_before_each - then self.before_calling_before_each(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_before_test - then self.before_calling_test(treat(l_event_item as ut_test)); - when ut_event_manager.gc_before_before_test - then self.before_calling_before_test(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_before_test_execute - then self.before_calling_test_execute(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_before_after_test - then self.before_calling_after_test(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_before_after_each - then self.before_calling_after_each(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_before_after_all - then self.before_calling_after_all(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_run - then self.after_calling_run(treat(l_event_item as ut_run)); - when ut_event_manager.gc_after_suite - then self.after_calling_suite(treat(l_event_item as ut_logical_suite)); - when ut_event_manager.gc_after_before_all - then self.after_calling_before_all(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_before_each - then self.after_calling_before_each(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_test - then self.after_calling_test(treat(l_event_item as ut_test)); - when ut_event_manager.gc_after_before_test - then self.after_calling_before_test(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_test_execute - then self.after_calling_test_execute(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_after_test - then self.after_calling_after_test(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_after_each - then self.after_calling_after_each(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_after_after_all - then self.after_calling_after_all(treat(l_event_item as ut_executable)); - when ut_event_manager.gc_finalize - then self.on_finalize(treat(l_event_item as ut_run)); - else null; - end case; - end; - -end; -/ diff --git a/source/core/types/ut_reporter_base.tps b/source/core/types/ut_reporter_base.tps deleted file mode 100644 index de157136e..000000000 --- a/source/core/types/ut_reporter_base.tps +++ /dev/null @@ -1,82 +0,0 @@ -create or replace type ut_reporter_base under ut_event_listener ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - id raw(32), - final member procedure init(self in out nocopy ut_reporter_base, a_self_type varchar2), - member procedure set_reporter_id(self in out nocopy ut_reporter_base, a_reporter_id raw), - member function get_reporter_id return raw, - member function get_description return varchar2, - - -- run hooks - member procedure before_calling_run(self in out nocopy ut_reporter_base, a_run in ut_run), - - -- suite hooks - member procedure before_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite), - - member procedure before_calling_before_all(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_before_all (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - member procedure before_calling_before_each(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_before_each (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - -- test hooks - member procedure before_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test), - - member procedure before_calling_before_test(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_before_test (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - member procedure before_calling_test_execute(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_test_execute (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - member procedure before_calling_after_test(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_after_test (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - member procedure after_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test), - - --suite hooks continued - member procedure before_calling_after_each(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_after_each (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - member procedure before_calling_after_all(self in out nocopy ut_reporter_base, a_executable in ut_executable), - member procedure after_calling_after_all (self in out nocopy ut_reporter_base, a_executable in ut_executable), - - member procedure after_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite), - - -- run hooks continued - member procedure after_calling_run (self in out nocopy ut_reporter_base, a_run in ut_run), - - -- This method is executed when reporter is getting finalized - -- it differs from after_calling_run, as it is getting called, even when the run fails - -- This way, you may close all open outputs, files, connections etc. that need closing before the run finishes - not instantiable member procedure on_finalize(self in out nocopy ut_reporter_base, a_run in ut_run), - - -- This method is executed when run is getting initialized - not instantiable member procedure on_initialize(self in out nocopy ut_reporter_base, a_run in ut_run), - - /** - * Returns the list of events that are supported by particular implementation of the reporter - */ - overriding member function get_supported_events return ut_varchar2_list, - - /** - * Delegates execution of event into individual reporting procedures - */ - overriding member procedure on_event( self in out nocopy ut_reporter_base, a_event_name varchar2, a_event_item ut_event_item) - -) -not final not instantiable -/ diff --git a/source/core/types/ut_reporter_info.tps b/source/core/types/ut_reporter_info.tps deleted file mode 100644 index f09c42e07..000000000 --- a/source/core/types/ut_reporter_info.tps +++ /dev/null @@ -1,23 +0,0 @@ -create or replace type ut_reporter_info as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_name varchar2(250), - is_output_reporter varchar2(1), - is_instantiable varchar2(1), - is_final varchar2(1) -) -/ diff --git a/source/core/types/ut_reporters.tps b/source/core/types/ut_reporters.tps deleted file mode 100644 index a2802bb26..000000000 --- a/source/core/types/ut_reporters.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_reporters as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_reporter_base; -/ diff --git a/source/core/types/ut_reporters_info.tps b/source/core/types/ut_reporters_info.tps deleted file mode 100644 index 82c264f36..000000000 --- a/source/core/types/ut_reporters_info.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_reporters_info as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_reporter_info; -/ \ No newline at end of file diff --git a/source/core/types/ut_results_counter.tpb b/source/core/types/ut_results_counter.tpb deleted file mode 100644 index 811389e0e..000000000 --- a/source/core/types/ut_results_counter.tpb +++ /dev/null @@ -1,74 +0,0 @@ -create or replace type body ut_results_counter as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_results_counter(self in out nocopy ut_results_counter) return self as result is - begin - self.disabled_count := 0; - self.success_count := 0; - self.failure_count := 0; - self.errored_count := 0; - self.warnings_count := 0; - return; - end; - - member procedure set_counter_values(self in out nocopy ut_results_counter, a_status integer) is - begin - self.disabled_count := case when a_status = ut_utils.gc_disabled then 1 else 0 end; - self.success_count := case when a_status = ut_utils.gc_success then 1 else 0 end; - self.failure_count := case when a_status = ut_utils.gc_failure then 1 else 0 end; - self.errored_count := case when a_status = ut_utils.gc_error then 1 else 0 end; - end; - - member procedure sum_counter_values(self in out nocopy ut_results_counter, a_item ut_results_counter) is - begin - self.disabled_count := self.disabled_count + a_item.disabled_count; - self.success_count := self.success_count + a_item.success_count; - self.failure_count := self.failure_count + a_item.failure_count; - self.errored_count := self.errored_count + a_item.errored_count; - self.warnings_count := self.warnings_count + a_item.warnings_count; - end; - - member procedure increase_warning_count(self in out nocopy ut_results_counter, a_count integer := 1) is - begin - self.warnings_count := self.warnings_count + nvl(a_count,0); - end; - - member function total_count return integer is - begin - --skip warnings here - return self.disabled_count + self.success_count + self.failure_count + self.errored_count; - end; - - member function result_status return integer is - l_result integer; - begin - if self.errored_count > 0 then - l_result := ut_utils.gc_error; - elsif self.failure_count > 0 then - l_result := ut_utils.gc_failure; - elsif self.success_count > 0 then - l_result := ut_utils.gc_success; - elsif self.disabled_count > 0 then - l_result := ut_utils.gc_disabled; - else - l_result := ut_utils.gc_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/core/types/ut_results_counter.tps b/source/core/types/ut_results_counter.tps deleted file mode 100644 index 913ae0967..000000000 --- a/source/core/types/ut_results_counter.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_results_counter as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - disabled_count integer, - success_count integer, - failure_count integer, - errored_count integer, - warnings_count integer, - constructor function ut_results_counter(self in out nocopy ut_results_counter) return self as result, - member procedure set_counter_values(self in out nocopy ut_results_counter, a_status integer), - member procedure sum_counter_values(self in out nocopy ut_results_counter, a_item ut_results_counter), - member procedure increase_warning_count(self in out nocopy ut_results_counter, a_count integer := 1), - member function total_count return integer, - member function result_status return integer -) -/ diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb deleted file mode 100644 index 660c88791..000000000 --- a/source/core/types/ut_run.tpb +++ /dev/null @@ -1,112 +0,0 @@ -create or replace type body ut_run as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_run( - self in out nocopy ut_run, - a_items ut_suite_items := null, - a_run_paths ut_varchar2_list := null, - a_coverage_options ut_coverage_options := 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 varchar2 := null - ) return self as result is - 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 := a_coverage_options; - return; - end; - - overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2) is - begin - null; - end; - - overriding member function do_execute(self in out nocopy ut_run) return boolean is - l_completed_without_errors boolean; - begin - ut_utils.debug_log('ut_run.execute'); - - ut_event_manager.trigger_event(ut_event_manager.gc_before_run, self); - self.start_time := current_timestamp; - - -- clear anything that might stay in the session's cache - ut_expectation_processor.clear_expectations; - - for i in 1 .. self.items.count loop - l_completed_without_errors := self.items(i).do_execute(); - end loop; - - self.calc_execution_result(); - - self.end_time := current_timestamp; - - ut_event_manager.trigger_event(ut_event_manager.gc_after_run, self); - - return l_completed_without_errors; - end; - - overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false) is - begin - self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end; - for i in 1 .. self.items.count loop - self.items(i).set_rollback_type(self.rollback_type, a_force); - end loop; - end; - - overriding member procedure calc_execution_result(self in out nocopy ut_run) is - l_result integer(1); - begin - if self.items is not null and self.items.count > 0 then - for i in 1 .. self.items.count loop - self.results_count.sum_counter_values( self.items(i).results_count ); - end loop; - l_result := self.results_count.result_status(); - else - --if suite is empty then it's successful (no errors) - l_result := ut_utils.gc_success; - end if; - - self.result := l_result; - end; - - overriding member procedure mark_as_errored(self in out nocopy ut_run, a_error_stack_trace varchar2) is - begin - null; - end; - - overriding member function get_error_stack_traces return ut_varchar2_list is - begin - return ut_varchar2_list(); - end; - - overriding member function get_serveroutputs return clob is - begin - return null; - end; - - -end; -/ diff --git a/source/core/types/ut_run.tps b/source/core/types/ut_run.tps deleted file mode 100644 index 1878a2d46..000000000 --- a/source/core/types/ut_run.tps +++ /dev/null @@ -1,47 +0,0 @@ -create or replace type ut_run under ut_suite_item ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * The list of items (suites) to be invoked as part of this run - */ - project_name varchar2(4000), - items ut_suite_items, - run_paths ut_varchar2_list, - run_tags varchar2(4000), - 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 := null, - a_run_paths ut_varchar2_list := null, - a_coverage_options ut_coverage_options := 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 varchar2 := null - ) return self as result, - overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2), - overriding member function do_execute(self in out nocopy ut_run) return boolean, - overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false), - overriding member procedure calc_execution_result(self in out nocopy ut_run), - overriding member procedure mark_as_errored(self in out nocopy ut_run, a_error_stack_trace varchar2), - overriding member function get_error_stack_traces return ut_varchar2_list, - overriding member function get_serveroutputs return clob -) -/ diff --git a/source/core/types/ut_run_info.tpb b/source/core/types/ut_run_info.tpb deleted file mode 100644 index 6edc0f109..000000000 --- a/source/core/types/ut_run_info.tpb +++ /dev/null @@ -1,48 +0,0 @@ -create or replace type body ut_run_info as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 andTEST_GET_REPORTERS_LIST - limitations under the License. - */ - constructor function ut_run_info(self in out nocopy ut_run_info) return self as result is - l_ut_owner varchar2(250) := ut_utils.ut_owner; - begin - self.self_type := $$plsql_unit; - execute immediate - 'select /*+ no_parallel */ '||l_ut_owner||'.ut.version() from dual' - into self.ut_version; - - dbms_utility.db_version( self.db_version, self.db_compatibility ); - db_os_type := dbms_utility.port_string(); - - execute immediate - 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.product, x.version) from product_component_version x' - bulk collect into self.db_component_version; - - execute immediate - 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) - from nls_session_parameters x' - bulk collect into self.nls_session_params; - - execute immediate - 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_instance_parameters x' - bulk collect into self.nls_instance_params; - - execute immediate - 'select /*+ no_parallel */ '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_database_parameters x' - bulk collect into self.nls_db_params; - return; - end; -end; -/ diff --git a/source/core/types/ut_run_info.tps b/source/core/types/ut_run_info.tps deleted file mode 100644 index 4a3da691f..000000000 --- a/source/core/types/ut_run_info.tps +++ /dev/null @@ -1,28 +0,0 @@ -create or replace type ut_run_info under ut_event_item ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - ut_version varchar2(4000), - db_version varchar2(4000), - db_compatibility varchar2(4000), - db_os_type varchar2(4000), - db_component_version ut_key_value_pairs, - nls_session_params ut_key_value_pairs, - nls_instance_params ut_key_value_pairs, - nls_db_params ut_key_value_pairs, - constructor function ut_run_info(self in out nocopy ut_run_info) return self as result -); -/ diff --git a/source/core/types/ut_stack.tpb b/source/core/types/ut_stack.tpb deleted file mode 100644 index b5f4e8747..000000000 --- a/source/core/types/ut_stack.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_stack as - /* - utPLSQL - Version 3 - Copyright 2016 - 2023 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_stack( self in out nocopy ut_stack) return self as result is - begin - self.tokens := ut_varchar2_list(); - self.top := 0; - return; - end ut_stack; - - member function peek(self in out nocopy ut_stack) return varchar2 is - l_token varchar2(32767); - begin - if self.tokens.count =0 or self.tokens is null then - l_token := null; - else - l_token := self.tokens(self.tokens.last); - end if; - return l_token; - end; - - member procedure push(self in out nocopy ut_stack, a_token varchar2) is - begin - self.tokens.extend; - self.tokens(self.tokens.last) := a_token; - self.top := self.tokens.count; - end push; - - member procedure pop(self in out nocopy ut_stack,a_cnt in integer default 1) is - begin - self.tokens.trim(a_cnt); - self.top := self.tokens.count; - end pop; - - member function pop(self in out nocopy ut_stack) return varchar2 is - l_token varchar2(32767) := self.tokens(self.tokens.last); - begin - self.pop(); - return l_token; - end; -end; -/ - diff --git a/source/core/types/ut_stack.tps b/source/core/types/ut_stack.tps deleted file mode 100644 index 23112fdde..000000000 --- a/source/core/types/ut_stack.tps +++ /dev/null @@ -1,26 +0,0 @@ -create or replace type ut_stack as object ( - top integer, - tokens ut_varchar2_list, - /* - utPLSQL - Version 3 - Copyright 2016 - 2023 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_stack( self in out nocopy ut_stack) return self as result, - member function peek(self in out nocopy ut_stack) return varchar2, - member procedure push(self in out nocopy ut_stack, a_token varchar2), - member procedure pop(self in out nocopy ut_stack,a_cnt in integer default 1), - member function pop(self in out nocopy ut_stack) return varchar2 -) -/ \ No newline at end of file diff --git a/source/core/types/ut_suite.tpb b/source/core/types/ut_suite.tpb deleted file mode 100644 index e3a4687d8..000000000 --- a/source/core/types/ut_suite.tpb +++ /dev/null @@ -1,112 +0,0 @@ -create or replace type body ut_suite as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 ( - 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; - self.init(a_object_owner, a_object_name, a_object_name, a_line_no); - 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; - - overriding member function do_execute(self in out nocopy ut_suite) return boolean is - l_suite_savepoint varchar2(30); - l_no_errors boolean; - - procedure propagate_error(a_error_stack_trace varchar2) is - begin - for i in 1..self.items.count loop - self.items(i).mark_as_errored(a_error_stack_trace); - end loop; - end; - begin - ut_utils.debug_log('ut_suite.execute'); - - if self.get_disabled_flag() then - self.mark_as_skipped(a_skip_reason => self.disabled_reason); - else - self.start_time := current_timestamp; - ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self); - - l_suite_savepoint := self.create_savepoint_if_needed(); - - --includes listener calls for before and after actions - l_no_errors := true; - for i in 1 .. self.before_all_list.count loop - l_no_errors := self.before_all_list(i).do_execute(self); - if not l_no_errors then - propagate_error(self.before_all_list(i).get_error_stack_trace()); - exit; - end if; - end loop; - - if l_no_errors then - for i in 1 .. self.items.count loop - self.items(i).do_execute(); - end loop; - end if; - - for i in 1 .. after_all_list.count loop - l_no_errors := self.after_all_list(i).do_execute(self); - if not l_no_errors then - self.put_warning(self.after_all_list(i).get_error_stack_trace()); - end if; - end loop; - - self.rollback_to_savepoint(l_suite_savepoint); - - self.calc_execution_result(); - self.end_time := current_timestamp; - ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self); - end if; - - return l_no_errors; - end; - - overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list is - l_stack_traces ut_varchar2_list := ut_varchar2_list(); - begin - for i in 1 .. before_all_list.count loop - ut_utils.append_to_list(l_stack_traces, self.before_all_list(i).get_error_stack_trace()); - end loop; - for i in 1 .. after_all_list.count loop - ut_utils.append_to_list(l_stack_traces, self.after_all_list(i).get_error_stack_trace()); - end loop; - return l_stack_traces; - end; - - overriding member function get_serveroutputs return clob is - l_outputs clob; - begin - for i in 1 .. before_all_list.count loop - ut_utils.append_to_clob(l_outputs, self.before_all_list(i).serveroutput); - end loop; - for i in 1 .. after_all_list.count loop - ut_utils.append_to_clob(l_outputs, self.after_all_list(i).serveroutput); - end loop; - return l_outputs; - end; - -end; -/ diff --git a/source/core/types/ut_suite.tps b/source/core/types/ut_suite.tps deleted file mode 100644 index ff7f3e171..000000000 --- a/source/core/types/ut_suite.tps +++ /dev/null @@ -1,37 +0,0 @@ -create or replace type ut_suite under ut_logical_suite ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * The procedure to be invoked before all of the items of the suite (executed once) - * Procedure exists within the package of the suite - */ - before_all_list ut_executables, - - /** - * The procedure to be invoked after all of the items of the suite (executed once) - * Procedure exists within the package of the 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, - 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, - overriding member function get_serveroutputs return clob -) not final -/ diff --git a/source/core/types/ut_suite_cache_row.tps b/source/core/types/ut_suite_cache_row.tps deleted file mode 100644 index c147a8757..000000000 --- a/source/core/types/ut_suite_cache_row.tps +++ /dev/null @@ -1,41 +0,0 @@ -create or replace type ut_suite_cache_row as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - id number(22,0), - self_type varchar2(250 byte), - path varchar2(1000 byte), - object_owner varchar2(250 byte), - object_name varchar2(250 byte), - name varchar2(250 byte), - line_no number, - parse_time timestamp (6), - description varchar2(4000 byte), - rollback_type number, - disabled_flag number, - disabled_reason varchar2(4000 byte), - warnings ut_varchar2_rows, - before_all_list ut_executables, - after_all_list ut_executables, - before_each_list ut_executables, - before_test_list ut_executables, - after_each_list ut_executables, - after_test_list ut_executables, - expected_error_codes ut_varchar2_rows, - tags ut_varchar2_rows, - item ut_executable_test -) -/ \ No newline at end of file diff --git a/source/core/types/ut_suite_cache_rows.tps b/source/core/types/ut_suite_cache_rows.tps deleted file mode 100644 index 9b6919df5..000000000 --- a/source/core/types/ut_suite_cache_rows.tps +++ /dev/null @@ -1,19 +0,0 @@ -create type ut_suite_cache_rows as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_suite_cache_row -/ \ No newline at end of file diff --git a/source/core/types/ut_suite_context.tpb b/source/core/types/ut_suite_context.tpb deleted file mode 100644 index be92e6fc9..000000000 --- a/source/core/types/ut_suite_context.tpb +++ /dev/null @@ -1,32 +0,0 @@ -create or replace type body ut_suite_context as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_context ( - self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer - ) return self as result is - begin - self.self_type := $$plsql_unit; - self.init(a_object_owner, a_object_name, a_context_name, a_line_no); - self.items := ut_suite_items(); - before_all_list := ut_executables(); - after_all_list := ut_executables(); - return; - end; - -end; -/ diff --git a/source/core/types/ut_suite_context.tps b/source/core/types/ut_suite_context.tps deleted file mode 100644 index 5e3d20f87..000000000 --- a/source/core/types/ut_suite_context.tps +++ /dev/null @@ -1,22 +0,0 @@ -create or replace type ut_suite_context under ut_suite ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_context ( - self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer - ) return self as result -) -/ diff --git a/source/core/types/ut_suite_item.tpb b/source/core/types/ut_suite_item.tpb deleted file mode 100644 index 648f10dd1..000000000 --- a/source/core/types/ut_suite_item.tpb +++ /dev/null @@ -1,125 +0,0 @@ -create or replace type body ut_suite_item as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer) is - begin - self.object_owner := a_object_owner; - self.object_name := lower(trim(a_object_name)); - self.name := lower(trim(a_name)); - self.results_count := ut_results_counter(); - self.warnings := ut_varchar2_rows(); - self.line_no := a_line_no; - self.transaction_invalidators := ut_varchar2_list(); - self.disabled_flag := ut_utils.boolean_to_int(false); - self.disabled_reason := null; - end; - - member function get_disabled_flag return boolean is - begin - return ut_utils.int_to_boolean(self.disabled_flag); - end; - - member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer, a_force boolean := false) is - begin - self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end; - end; - - member function get_rollback_type return integer is - begin - return nvl(self.rollback_type, ut_utils.gc_rollback_default); - end; - - final member procedure do_execute(self in out nocopy ut_suite_item) is - l_completed_without_errors boolean; - begin - l_completed_without_errors := self.do_execute(); - end; - - member function create_savepoint_if_needed return varchar2 is - l_savepoint varchar2(30); - begin - if get_rollback_type() = ut_utils.gc_rollback_auto then - l_savepoint := ut_utils.gen_savepoint_name(); - execute immediate 'savepoint ' || l_savepoint; - end if; - return l_savepoint; - end; - - member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2) is - 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 - 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 - l_transaction_invalidators := - lower( ut_utils.indent_lines( ut_utils.table_to_clob( self.get_transaction_invalidators() ), 2, true ) ); - if length(l_transaction_invalidators) > 3000 then - l_transaction_invalidators := substr(l_transaction_invalidators,1,3000)||'...'; - end if; - put_warning( - 'Unable to perform automatic rollback after test' - || case when self_type like '%SUITE' then ' suite' when self_type like '%CONTEXT' then ' context' end || '. ' - ||'An implicit or explicit commit/rollback occurred in procedures:'||chr(10) - ||l_transaction_invalidators||chr(10) - ||'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.' - ); - end; - - member function execution_time return number is - begin - return ut_utils.time_diff(start_time, end_time); - end; - - member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2) is - begin - self.warnings.extend; - self.warnings(self.warnings.last) := a_message; - self.results_count.increase_warning_count; - end; - - member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2, a_procedure_name varchar2, a_line_no integer) is - l_result varchar2(1000); - begin - l_result := self.object_owner || '.' || self.object_name ; - if a_procedure_name is not null then - l_result := l_result || '.' || a_procedure_name ; - end if; - put_warning( a_message || chr( 10 ) || 'at package "' || upper(l_result) || '", line ' || a_line_no ); - end; - - member function get_transaction_invalidators return ut_varchar2_list is - begin - return transaction_invalidators; - end; - - member procedure add_transaction_invalidator(self in out nocopy ut_suite_item, a_object_name varchar2) is - begin - if a_object_name not member of transaction_invalidators then - transaction_invalidators.extend(); - transaction_invalidators(transaction_invalidators.last) := a_object_name; - end if; - end; - -end; -/ diff --git a/source/core/types/ut_suite_item.tps b/source/core/types/ut_suite_item.tps deleted file mode 100644 index 8184f2a63..000000000 --- a/source/core/types/ut_suite_item.tps +++ /dev/null @@ -1,95 +0,0 @@ -create or replace type ut_suite_item force under ut_event_item ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * owner of the database object (package) - */ - object_owner varchar2(250 byte), - /** - * name of the database object (package) - */ - object_name varchar2(250 byte), - /** - * Name of the object (suite, sub-suite, test) - */ - name varchar2(250 byte), - /** - * Description fo the suite item (as given by the annotation) - */ - description varchar2(4000 byte), - - /** - * Full path of the invocation of the item (including the items name itself) - */ - path varchar2(1000 byte), - /** - * The type of the rollback behavior - */ - rollback_type integer(1), - /** - * Indicates if the test is to be disabled by execution - */ - disabled_flag integer(1), - /** - * Indicates reason whysa test is to be disabled by execution - */ - disabled_reason varchar2(4000), - /** - * Line no where annotation identifying this item is placed in package - */ - line_no integer, - /** - * Time when the suite item was last parsed from package source - */ - parse_time timestamp, - --execution result fields - start_time timestamp with time zone, - end_time timestamp with time zone, - result integer(1), - 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, a_skip_reason in varchar2), - member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer, a_force boolean := false), - member function get_rollback_type return integer, - member function create_savepoint_if_needed return varchar2, - member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2), - member function get_transaction_invalidators return ut_varchar2_list, - member procedure add_transaction_invalidator(self in out nocopy ut_suite_item, a_object_name varchar2), - /* - Returns execution time in seconds (with miliseconds) - */ - member function execution_time return number, - - not instantiable member function do_execute(self in out nocopy ut_suite_item) return boolean, - final member procedure do_execute(self in out nocopy ut_suite_item), - not instantiable member procedure calc_execution_result(self in out nocopy ut_suite_item), - not instantiable member procedure mark_as_errored(self in out nocopy ut_suite_item, a_error_stack_trace varchar2), - not instantiable member function get_error_stack_traces return ut_varchar2_list, - not instantiable member function get_serveroutputs return clob, - member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2), - member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2, a_procedure_name varchar2, a_line_no integer) -) -not final not instantiable -/ diff --git a/source/core/types/ut_suite_items.tps b/source/core/types/ut_suite_items.tps deleted file mode 100644 index 615283446..000000000 --- a/source/core/types/ut_suite_items.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_suite_items as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_suite_item -/ diff --git a/source/core/types/ut_test.tpb b/source/core/types/ut_test.tpb deleted file mode 100644 index 946f8990d..000000000 --- a/source/core/types/ut_test.tpb +++ /dev/null @@ -1,178 +0,0 @@ -create or replace type body ut_test as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_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_varchar2_rows := null, a_tags ut_varchar2_rows := null - ) return self as result is - begin - self.self_type := $$plsql_unit; - self.init(a_object_owner, a_object_name, a_name, a_line_no); - self.item := ut_executable_test(a_object_owner, a_object_name, a_name, ut_utils.gc_test_execute); - self.before_each_list := ut_executables(); - self.before_test_list := ut_executables(); - self.after_test_list := ut_executables(); - self.after_each_list := ut_executables(); - 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; - - overriding member procedure mark_as_skipped(self in out nocopy ut_test, a_skip_reason in varchar2) is - begin - ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); - self.start_time := current_timestamp; - self.result := ut_utils.gc_disabled; - self.disabled_reason := coalesce(a_skip_reason,self.disabled_reason); - ut_utils.debug_log('ut_test.execute - disabled'); - self.results_count.set_counter_values(self.result); - self.end_time := self.start_time; - ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self); - end; - - overriding member function do_execute(self in out nocopy ut_test) return boolean is - l_no_errors boolean; - l_savepoint varchar2(30); - begin - - ut_utils.debug_log('ut_test.execute'); - - if self.get_disabled_flag() then - mark_as_skipped(self.disabled_reason); - else - self.start_time := current_timestamp; - ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); - - l_savepoint := self.create_savepoint_if_needed(); - - --includes listener calls for before and after actions - l_no_errors := true; - for i in 1 .. self.before_each_list.count loop - l_no_errors := self.before_each_list(i).do_execute(self); - exit when not l_no_errors; - end loop; - - if l_no_errors then - for i in 1 .. self.before_test_list.count loop - l_no_errors := self.before_test_list(i).do_execute(self); - exit when not l_no_errors; - end loop; - - if l_no_errors then - -- execute the test - self.item.do_execute(self, self.expected_error_codes); - - end if; - -- perform cleanup regardless of the test or setup failure - for i in 1 .. self.after_test_list.count loop - self.after_test_list(i).do_execute(self); - end loop; - end if; - - for i in 1 .. self.after_each_list.count loop - self.after_each_list(i).do_execute(self); - end loop; - self.rollback_to_savepoint(l_savepoint); - - self.calc_execution_result(); - self.end_time := current_timestamp; - ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self); - end if; - return l_no_errors; - end; - - overriding member procedure calc_execution_result(self in out nocopy ut_test) is - l_warnings ut_varchar2_rows; - begin - if self.get_error_stack_traces().count = 0 then - self.result := ut_expectation_processor.get_status(); - else - self.result := ut_utils.gc_error; - end if; - --expectation results need to be part of test results - self.all_expectations := ut_expectation_processor.get_all_expectations(); - self.failed_expectations := ut_expectation_processor.get_failed_expectations(); - l_warnings := coalesce( ut_expectation_processor.get_warnings(), ut_varchar2_rows() ); - self.warnings := self.warnings multiset union all l_warnings; - self.results_count.increase_warning_count( cardinality(l_warnings) ); - self.results_count.set_counter_values(self.result); - ut_expectation_processor.clear_expectations(); - end; - - overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2) is - begin - ut_utils.debug_log('ut_test.fail'); - ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self); - self.start_time := current_timestamp; - self.parent_error_stack_trace := a_error_stack_trace; - self.calc_execution_result(); - self.end_time := self.start_time; - ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self); - end; - - overriding member function get_error_stack_traces(self ut_test) return ut_varchar2_list is - l_stack_traces ut_varchar2_list := ut_varchar2_list(); - begin - ut_utils.append_to_list(l_stack_traces, self.parent_error_stack_trace); - for i in 1 .. before_each_list.count loop - ut_utils.append_to_list(l_stack_traces, self.before_each_list(i).get_error_stack_trace()); - end loop; - for i in 1 .. before_test_list.count loop - ut_utils.append_to_list(l_stack_traces, self.before_test_list(i).get_error_stack_trace()); - end loop; - ut_utils.append_to_list(l_stack_traces, self.item.get_error_stack_trace()); - for i in 1 .. after_test_list.count loop - ut_utils.append_to_list(l_stack_traces, self.after_test_list(i).get_error_stack_trace()); - end loop; - for i in 1 .. after_each_list.count loop - ut_utils.append_to_list(l_stack_traces, self.after_each_list(i).get_error_stack_trace()); - end loop; - return l_stack_traces; - end; - overriding member function get_serveroutputs return clob is - l_outputs clob; - begin - for i in 1 .. before_each_list.count loop - ut_utils.append_to_clob(l_outputs, self.before_each_list(i).serveroutput); - end loop; - for i in 1 .. before_test_list.count loop - ut_utils.append_to_clob(l_outputs, self.before_test_list(i).serveroutput); - end loop; - ut_utils.append_to_clob(l_outputs, self.item.serveroutput ); - for i in 1 .. after_test_list.count loop - ut_utils.append_to_clob(l_outputs, self.after_test_list(i).serveroutput); - end loop; - for i in 1 .. after_each_list.count loop - ut_utils.append_to_clob(l_outputs, self.after_each_list(i).serveroutput); - 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 deleted file mode 100644 index dbba64961..000000000 --- a/source/core/types/ut_test.tps +++ /dev/null @@ -1,70 +0,0 @@ -create or replace type ut_test force under ut_suite_item ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /* - * Procedures to be invoked before invoking the test and before_test_list procedures. - */ - before_each_list ut_executables, - /** - * Procedures to be invoked before invoking the test - */ - before_test_list ut_executables, - /** - * The Test procedure to be executed - */ - item ut_executable_test, - /** - * Procedures to be invoked after invoking the test - */ - after_test_list ut_executables, - /* - * Procedures to be invoked after invoking the test and after_test_list procedures. - */ - after_each_list ut_executables, - /** - * The list of all expectations results as well as database errors encountered while invoking - * the test procedure and the before_test/after_test blocks - */ - all_expectations ut_expectation_results, - - /** - * The list of failed expectations results as well as database errors encountered while invoking - * the test procedure and the before_test/after_test blocks - */ - failed_expectations ut_expectation_results, - /** - * Holds information about error stacktrace from parent execution (suite) - * Will get populated on exceptions in before-all calls - */ - parent_error_stack_trace varchar2(4000), - /** - *Holds the expected error codes list when the user use the annotation throws - */ - expected_error_codes ut_varchar2_rows, - 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_varchar2_rows := null, a_tags ut_varchar2_rows := null - ) return self as result, - overriding member procedure mark_as_skipped(self in out nocopy ut_test, a_skip_reason in varchar2), - 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, - 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 deleted file mode 100644 index f0b5df509..000000000 --- a/source/core/types/ut_varchar2_list.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_varchar2_list as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 varchar2(32767) -/ diff --git a/source/core/types/ut_varchar2_rows.tps b/source/core/types/ut_varchar2_rows.tps deleted file mode 100644 index e7fa29c29..000000000 --- a/source/core/types/ut_varchar2_rows.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_varchar2_rows as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 varchar2(4000 byte) -/ diff --git a/source/core/ut_dbms_output_cache.sql b/source/core/ut_dbms_output_cache.sql deleted file mode 100644 index e61b403c8..000000000 --- a/source/core/ut_dbms_output_cache.sql +++ /dev/null @@ -1,38 +0,0 @@ -/* -utPLSQL - Version 3 -Copyright 2016 - 2021 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 -*/ -declare - l_tab_exist number; -begin - select /*+ no_parallel */ count(*) into l_tab_exist from - (select table_name from all_tables where table_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA') - union all - select synonym_name from all_synonyms where synonym_name = 'UT_DBMS_OUTPUT_CACHE' and owner = sys_context('USERENV','CURRENT_SCHEMA')); - if l_tab_exist = 0 then - - execute immediate q'[create global temporary table ut_dbms_output_cache - ( - seq_no number(20,0) not null, - text varchar2(4000), - constraint ut_dbms_output_cache_pk primary key(seq_no) - ) on commit preserve rows - ]'; - - end if; -end; -/ diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb deleted file mode 100644 index c165a9ee5..000000000 --- a/source/core/ut_expectation_processor.pkb +++ /dev/null @@ -1,239 +0,0 @@ -create or replace package body ut_expectation_processor as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - type tt_nls_params is table of nls_session_parameters%rowtype; - - g_session_params tt_nls_params; - - g_expectations_called ut_expectation_results := ut_expectation_results(); - - g_warnings ut_varchar2_rows := ut_varchar2_rows(); - - g_nulls_are_equal boolean_not_null := gc_default_nulls_are_equal; - - g_package_invalidated boolean := false; - - function nulls_are_equal return boolean is - begin - return g_nulls_are_equal; - end; - - procedure nulls_are_equal(a_setting boolean_not_null) is - begin - g_nulls_are_equal := a_setting; - end; - - function get_status return integer is - l_result integer := ut_utils.gc_success; - begin - ut_utils.debug_log('ut_expectation_processor.get_status'); - - for i in 1 .. g_expectations_called.count loop - l_result := greatest(l_result, g_expectations_called(i).status); - exit when l_result = ut_utils.gc_error; - end loop; - return l_result; - end get_status; - - procedure clear_expectations is - begin - ut_utils.debug_log('ut_expectation_processor.clear_expectations'); - g_expectations_called.delete; - g_warnings.delete; - end; - - function get_all_expectations return ut_expectation_results is - begin - ut_utils.debug_log('ut_expectation_processor.get_all_expectations: g_expectations_called.count='||g_expectations_called.count); - return g_expectations_called; - end get_all_expectations; - - function get_failed_expectations return ut_expectation_results is - l_expectations_results ut_expectation_results := ut_expectation_results(); - begin - ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: g_expectations_called.count='||g_expectations_called.count); - for i in 1 .. g_expectations_called.count loop - if g_expectations_called(i).status > ut_utils.gc_success then - l_expectations_results.extend; - l_expectations_results(l_expectations_results.last) := g_expectations_called(i); - end if; - end loop; - ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: l_expectations_results.count='||l_expectations_results.count); - return l_expectations_results; - end get_failed_expectations; - - procedure add_expectation_result(a_expectation_result ut_expectation_result) is - l_results ut_varchar2_list; - begin - if ut_session_context.is_ut_run then - ut_event_manager.trigger_event(ut_event_manager.gc_debug, a_expectation_result); - g_expectations_called.extend; - g_expectations_called(g_expectations_called.last) := a_expectation_result; - else - l_results := a_expectation_result.get_result_lines(); - dbms_output.put_line( upper( ut_utils.test_result_to_char( a_expectation_result.status ) ) || ''); - for i in 1 .. l_results.count loop - dbms_output.put_line( ' ' || l_results(i) ); - end loop; - if a_expectation_result.caller_info is not null then - dbms_output.put_line( ut_utils.indent_lines( a_expectation_result.caller_info, 2, true) ); - end if; - end if; - end; - - procedure report_failure(a_message in varchar2) is - 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 - select /*+ no_parallel */ nsp.parameter, nsp.value - bulk collect into l_session_params - from nls_session_parameters nsp - where parameter - in ( 'NLS_DATE_FORMAT', 'NLS_TIMESTAMP_FORMAT', 'NLS_TIMESTAMP_TZ_FORMAT') - order by 1; - - return l_session_params; - end; - - procedure set_xml_nls_params is - insuf_privs exception; - pragma exception_init(insuf_privs, -1031); - begin - g_session_params := get_session_parameters(); - - begin - execute immediate q'[alter session set events '19119 trace name context forever, level 0x8']'; - exception - when insuf_privs then NULL; - end; - - execute immediate 'alter session set nls_timestamp_format = '''||ut_utils.gc_timestamp_format||''''; - execute immediate 'alter session set nls_timestamp_tz_format = '''||ut_utils.gc_timestamp_tz_format||''''; - end; - - procedure reset_nls_params is - insuf_privs exception; - pragma exception_init(insuf_privs, -1031); - begin - begin - execute immediate q'[alter session set events '19119 trace name context off']'; - exception - when insuf_privs then NULL; - end; - - if g_session_params is not null then - for i in 1 .. g_session_params.count loop - execute immediate 'alter session set '||g_session_params(i).parameter||' = '''||g_session_params(i).value||''''; - end loop; - end if; - - end; - - function who_called_expectation(a_call_stack varchar2) return varchar2 is - l_caller_stack_line varchar2(4000); - l_call_stack varchar2(4000); - l_line_no integer; - l_owner varchar2(1000); - l_object_name varchar2(1000); - l_result varchar2(4000); - -- in 12.2 format_call_stack reportes not only package name, but also the procedure name - -- when 11g and 12c reports only package name - function cut_header_and_expectations( a_stack varchar2 ) return varchar2 is - begin - return regexp_substr( a_stack, '(.*\.(UT_EQUAL|UT_BE_WITHIN[[:alnum:]$#_]*|UT_EXPECTATION[[:alnum:]$#_]*|UT|UTASSERT2?)(\.[[:alnum:]$#_]+)?\s+)+((.|\s)*)', 1, 1, 'm', 4); - end; - function cut_address_columns( a_stack varchar2 ) return varchar2 is - begin - return regexp_replace( a_stack, '^(0x)?[[:digit:]abcdef]+\s+', '', 1, 0, 'mi' ); - end; - function cut_framework_stack( a_stack varchar2 ) return varchar2 is - begin - return regexp_replace( - a_stack, - '[0-9]+\s+anonymous\s+block\s+[0-9]+\s+package\s+body\s+sys\.dbms_sql(\.execute)?\s+[0-9]+\s+[[:alnum:]_$# ]+\.ut_executable.*', - '', - 1, 1, 'mni' - ); - end; - function format_stack( a_stack varchar2 ) return varchar2 is - begin - return regexp_replace( - a_stack, - '([0-9]+)\s+(.* )?((anonymous block)|(([[:alnum:]$#_]+\.[[:alnum:]$#_]+(\.([[:alnum:]$#_])+)?)))', - 'at "\3", line \1', 1, 0, 'i' - ); - end; - begin - l_call_stack := cut_header_and_expectations( a_call_stack ); - l_call_stack := cut_address_columns( l_call_stack ); - l_call_stack := cut_framework_stack( l_call_stack ); - l_call_stack := format_stack( l_call_stack ); - l_caller_stack_line := regexp_substr(l_call_stack,'^(.*)'); - if l_caller_stack_line like '%.%' then - l_line_no := to_number( regexp_substr( l_caller_stack_line, ', line (\d+)', subexpression => 1 ) ); - l_owner := regexp_substr( l_caller_stack_line, 'at "([[:alnum:]$#_]+)\.(([[:alnum:]$#_]+)(\.([[:alnum:]$#_]+))?)", line (\d+)', subexpression => 1 ); - l_object_name := regexp_substr( l_caller_stack_line, 'at "([[:alnum:]$#_]+)\.(([[:alnum:]$#_]+)(\.([[:alnum:]$#_]+))?)", line (\d+)', subexpression => 3 ); - l_result := - l_caller_stack_line || ' ' || rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10)) - || replace( l_call_stack, l_caller_stack_line ); - else - l_result := l_call_stack; - end if; - return rtrim(l_result,chr(10)); - end; - - procedure add_warning(a_messsage varchar2) is - begin - g_warnings.extend; - g_warnings(g_warnings.last) := a_messsage; - end; - - procedure add_depreciation_warning(a_deprecated_syntax varchar2, a_new_syntax varchar2) is - begin - add_warning( - ut_utils.build_depreciation_warning( a_deprecated_syntax, a_new_syntax ) || chr(10) - || ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack()) - ); - end; - - function get_warnings return ut_varchar2_rows is - begin - return g_warnings; - end; - - function invalidation_exception_found return boolean is - begin - return g_package_invalidated; - end; - - procedure set_invalidation_exception is - begin - g_package_invalidated := true; - end; - - procedure reset_invalidation_exception is - begin - g_package_invalidated := false; - end; - -end; -/ diff --git a/source/core/ut_expectation_processor.pks b/source/core/ut_expectation_processor.pks deleted file mode 100644 index dd9187526..000000000 --- a/source/core/ut_expectation_processor.pks +++ /dev/null @@ -1,62 +0,0 @@ -create or replace package ut_expectation_processor authid current_user as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_default_nulls_are_equal constant boolean := true; - - subtype boolean_not_null is boolean not null; - - function nulls_are_equal return boolean; - - procedure nulls_are_equal(a_setting boolean_not_null); - - function get_status return integer; - - procedure clear_expectations; - - function get_all_expectations return ut_expectation_results; - - function get_failed_expectations return ut_expectation_results; - - 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; - - -- function is looking at call stack - -- and tries to figure out at which line of code - -- in a unit test, the expectation was called - -- if found, it returns a text: - -- at: owner.name:line "source code line text" - -- The text is to be consumed by expectation result - function who_called_expectation(a_call_stack varchar2) return varchar2; - - procedure add_warning(a_messsage varchar2); - - procedure add_depreciation_warning(a_deprecated_syntax varchar2, a_new_syntax varchar2); - - function get_warnings return ut_varchar2_rows; - - function invalidation_exception_found return boolean; - procedure set_invalidation_exception; - procedure reset_invalidation_exception; - -end; -/ diff --git a/source/core/ut_file_mapper.pkb b/source/core/ut_file_mapper.pkb deleted file mode 100644 index 425360533..000000000 --- a/source/core/ut_file_mapper.pkb +++ /dev/null @@ -1,122 +0,0 @@ -create or replace package body ut_file_mapper is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - type tt_key_values is table of varchar2(4000) index by varchar2(4000); - - /** - * Private functions - */ - - function to_hash_table(a_key_value_tab ut_key_value_pairs) return tt_key_values is - l_result tt_key_values; - begin - if a_key_value_tab is not null then - for i in 1 .. a_key_value_tab.count loop - l_result(upper(a_key_value_tab(i).key)) := a_key_value_tab(i).value; - end loop; - end if; - return l_result; - end; - - /** - * Public functions - */ - function default_file_to_obj_type_map return ut_key_value_pairs is - begin - return ut_key_value_pairs( - ut_key_value_pair('fnc', 'FUNCTION'), - ut_key_value_pair('prc', 'PROCEDURE'), - ut_key_value_pair('tpb', 'TYPE BODY'), - ut_key_value_pair('pkb', 'PACKAGE BODY'), - ut_key_value_pair('bdy', 'PACKAGE BODY'), - ut_key_value_pair('trg', 'TRIGGER') - ); - end; - - function build_file_mappings( - a_file_paths ut_varchar2_list, - a_file_to_object_type_mapping ut_key_value_pairs := null, - a_regex_pattern varchar2 := null, - a_object_owner_subexpression positive := null, - a_object_name_subexpression positive := null, - a_object_type_subexpression positive := null - ) return ut_file_mappings is - begin - return build_file_mappings( - null, a_file_paths, a_file_to_object_type_mapping, a_regex_pattern, - a_object_owner_subexpression, a_object_name_subexpression, a_object_type_subexpression - ); - end; - - function build_file_mappings( - a_object_owner varchar2, - a_file_paths ut_varchar2_list, - a_file_to_object_type_mapping ut_key_value_pairs := null, - a_regex_pattern varchar2 := null, - a_object_owner_subexpression positive := null, - a_object_name_subexpression positive := null, - a_object_type_subexpression positive := null - ) return ut_file_mappings is - l_file_to_object_type_mapping ut_key_value_pairs := coalesce(a_file_to_object_type_mapping, default_file_to_obj_type_map()); - l_regex_pattern varchar2(4000) := coalesce(a_regex_pattern, gc_file_mapping_regex); - l_object_owner_subexpression positive := coalesce(a_object_owner_subexpression, gc_regex_owner_subexpression); - l_object_name_subexpression positive := coalesce(a_object_name_subexpression, gc_regex_name_subexpression); - l_object_type_subexpression positive := coalesce(a_object_type_subexpression, gc_regex_type_subexpression); - - l_key_values tt_key_values; - l_mappings ut_file_mappings; - l_mapping ut_file_mapping; - l_object_type_key varchar2(4000); - l_object_type varchar2(4000); - l_object_owner varchar2(4000); - l_file_path varchar2(32767); - begin - if a_file_paths is not null then - l_key_values := to_hash_table(l_file_to_object_type_mapping); - l_mappings := ut_file_mappings(); - - for i in 1 .. a_file_paths.count loop - l_file_path := replace(a_file_paths(i),'\','/'); - l_object_type_key := upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_type_subexpression)); - if l_key_values.exists(l_object_type_key) then - l_object_type := upper(l_key_values(l_object_type_key)); - else - l_object_type := null; - end if; - - l_object_owner := coalesce( - upper(a_object_owner), - upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_owner_subexpression)), - sys_context('USERENV', 'CURRENT_SCHEMA')); - - l_mapping := ut_file_mapping( - file_name => a_file_paths(i), - object_owner => l_object_owner, - object_name => upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_name_subexpression)), - object_type => l_object_type - ); - l_mappings.extend(); - l_mappings(l_mappings.last) := l_mapping; - end loop; - end if; - - return l_mappings; - end; - -end; -/ diff --git a/source/core/ut_file_mapper.pks b/source/core/ut_file_mapper.pks deleted file mode 100644 index adc4c983f..000000000 --- a/source/core/ut_file_mapper.pks +++ /dev/null @@ -1,47 +0,0 @@ -create or replace package ut_file_mapper authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_file_mapping_regex constant varchar2(100) := '/(((\w|[$#])+)\.)?((\w|[$#])+)\.(\w{3})$'; - gc_regex_owner_subexpression constant positive := 2; - gc_regex_name_subexpression constant positive := 4; - gc_regex_type_subexpression constant positive := 6; - - function default_file_to_obj_type_map return ut_key_value_pairs; - - function build_file_mappings( - a_file_paths ut_varchar2_list, - a_file_to_object_type_mapping ut_key_value_pairs := null, - a_regex_pattern varchar2 := null, - a_object_owner_subexpression positive := null, - a_object_name_subexpression positive := null, - a_object_type_subexpression positive := null - ) return ut_file_mappings; - - function build_file_mappings( - a_object_owner varchar2, - a_file_paths ut_varchar2_list, - a_file_to_object_type_mapping ut_key_value_pairs := null, - a_regex_pattern varchar2 := null, - a_object_owner_subexpression positive := null, - a_object_name_subexpression positive := null, - a_object_type_subexpression positive := null - ) return ut_file_mappings; - - -end; -/ diff --git a/source/core/ut_metadata.pkb b/source/core/ut_metadata.pkb deleted file mode 100644 index 360b7b97d..000000000 --- a/source/core/ut_metadata.pkb +++ /dev/null @@ -1,335 +0,0 @@ -create or replace package body ut_metadata as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - type t_cache is table of all_source.text%type; - g_source_cache t_cache; - g_cached_object varchar2(500); - ------------------------------ - --public definitions - function form_name(a_owner_name varchar2, a_object varchar2, a_subprogram varchar2 default null) return varchar2 is - l_name varchar2(200); - begin - l_name := trim(a_object); - if trim(a_owner_name) is not null then - l_name := trim(a_owner_name) || '.' || l_name; - end if; - if trim(a_subprogram) is not null then - l_name := l_name || '.' || trim(a_subprogram); - end if; - return l_name; - end form_name; - - function package_valid(a_owner_name varchar2, a_package_name in varchar2) return boolean as - l_cnt number; - l_view_name varchar2(200) := get_objects_view_name; - begin - - execute immediate q'[select /*+ no_parallel */ count(*) - from ]'||l_view_name||q'[ - 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 - return false; - end; - - function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2) - return boolean as - l_cnt number; - l_view_name varchar2(200) := get_dba_view('dba_procedures'); - begin - execute immediate - 'select /*+ no_parallel */ count(*) from '||l_view_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; - exception - when others then - return false; - end; - - function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2 is - l_view_name varchar2(128) := get_source_view_name(); - l_line all_source.text%type; - c_key constant varchar2(500) := a_owner || '.' || a_object_name; - begin - if not nvl(c_key = g_cached_object, false) then - g_cached_object := c_key; - execute immediate - 'select /*+ no_parallel */ trim(text) text - from '||l_view_name||q'[ s - where s.owner = :a_owner - and s.name = :a_object_name - /*skip the declarations, consider only definitions*/ - and s.type not in ('PACKAGE', 'TYPE') - order by line]' - bulk collect into g_source_cache - using a_owner, a_object_name; - end if; - - if g_source_cache.exists(a_line_no) then - l_line := g_source_cache(a_line_no); - end if; - return l_line; - end; - - procedure reset_source_definition_cache is - begin - g_source_cache := null; - g_cached_object := null; - end; - - function get_dba_view(a_dba_view_name varchar2) return varchar2 is - l_result varchar2(128) := lower(a_dba_view_name); - begin - if not is_object_visible(a_dba_view_name) then - l_result := replace(l_result,'dba_','all_'); - end if; - return l_result; - end; - - function get_source_view_name return varchar2 is - begin - return get_dba_view('dba_source'); - end; - - - function get_objects_view_name return varchar2 is - begin - return get_dba_view('dba_objects'); - end; - - function user_has_execute_any_proc return boolean is - l_has_execute_any varchar2(1); - begin - select /*+ no_parallel */ decode( count( 1 ), 0, 'N', 'Y' ) - into l_has_execute_any - from dual - where - exists( - select 1 - from - role_sys_privs - join session_roles - using ( role ) - where privilege = 'EXECUTE ANY PROCEDURE' - ) or - exists( - select 1 - from user_sys_privs - where privilege = 'EXECUTE ANY PROCEDURE' - ); - return l_has_execute_any = 'Y'; - end; - - function is_object_visible(a_object_name varchar2) return boolean is - l_invalid_object_name exception; - pragma exception_init(l_invalid_object_name,-44002); - begin - return dbms_assert.sql_object_name(a_object_name) is not null; - exception - when l_invalid_object_name then - return false; - end; - - function package_exists_in_cur_schema(a_object_name varchar2) return boolean is - l_cnt number; - c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA'); - begin - select /*+ no_parallel */ count(*) - into l_cnt - from all_objects t - where t.object_name = a_object_name - and t.object_type = 'PACKAGE' - and t.owner = c_current_schema; - return l_cnt > 0; - end; - - function is_collection (a_anytype_code in integer) return boolean is - begin - return coalesce(a_anytype_code in (dbms_types.typecode_varray,dbms_types.typecode_table,dbms_types.typecode_namedcollection),false); - end; - - function is_collection (a_owner varchar2, a_type_name varchar2) return boolean is - begin - return is_collection( - get_anytype_members_info( - get_user_defined_type(a_owner, a_type_name) - ).type_code - ); - end; - - function get_attr_elem_info( a_anytype anytype, a_pos pls_integer := null ) - return t_anytype_elem_info_rec is - l_result t_anytype_elem_info_rec; - begin - if a_anytype is not null then - l_result.type_code := a_anytype.getattreleminfo( - pos => a_pos, - prec => l_result.precision, - scale => l_result.scale, - len => l_result.length, - csid => l_result.char_set_id, - csfrm => l_result.char_set_frm, - attr_elt_type => l_result.attr_elt_type, - aname => l_result.attribute_name - ); - end if; - return l_result; - end; - - function get_anytype_members_info( a_anytype anytype ) - return t_anytype_members_rec is - l_result t_anytype_members_rec; - begin - if a_anytype is not null then - l_result.type_code := a_anytype.getinfo( - prec => l_result.precision, - scale => l_result.scale, - len => l_result.length, - csid => l_result.char_set_id, - csfrm => l_result.char_set_frm, - schema_name => l_result.schema_name, - type_name => l_result.type_name, - version => l_result.version, - numelems => l_result.elements_count - ); - end if; - return l_result; - end; - - function get_user_defined_type(a_owner varchar2, a_type_name varchar2) return anytype is - l_anytype anytype; - not_found exception; - pragma exception_init(not_found,-22303); - begin - if a_type_name is not null then - begin - if ut_metadata.is_object_visible('GETANYTYPEFROMPERSISTENT') then - execute immediate 'begin :l_anytype := getanytypefrompersistent( :a_owner, :a_type_name ); end;' - using out l_anytype, in nvl(a_owner,sys_context('userenv','current_schema')), in a_type_name; - else - execute immediate 'begin :l_anytype := anytype.getpersistent( :a_owner, :a_type_name ); end;' - using out l_anytype, in nvl(a_owner,sys_context('userenv','current_schema')), in a_type_name; - end if; - exception - when not_found then - null; - end; - end if; - return l_anytype; - end; - - function get_collection_element(a_anydata in anydata) return varchar2 - is - l_anytype anytype; - l_nested_type t_anytype_members_rec; - l_elements_rec t_anytype_elem_info_rec; - l_type_code integer; - begin - l_type_code := a_anydata.gettype(l_anytype); - if is_collection(l_type_code) then - l_elements_rec := get_attr_elem_info(l_anytype); - if l_elements_rec.attr_elt_type is null then - l_nested_type := get_anytype_members_info(l_anytype); - else - l_nested_type := get_anytype_members_info(l_elements_rec.attr_elt_type); - end if; - end if; - return l_nested_type.schema_name || '.' ||l_nested_type.type_name; - end; - - function has_collection_members (a_anydata in anydata) return boolean is - l_anytype anytype; - l_elements_rec t_anytype_elem_info_rec; - l_type_code integer; - begin - l_type_code := a_anydata.gettype(l_anytype); - l_elements_rec := get_attr_elem_info(l_anytype); - return l_elements_rec.attr_elt_type is not null; - end; - - function get_anydata_typename(a_data_value anydata) return varchar2 - is - begin - return case when a_data_value is not null then lower(a_data_value.gettypename()) else 'undefined' end; - end; - - 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_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'||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; - else - l_result := 1; - end if; - return l_result; - end; - - function get_object_name(a_full_object_name in varchar2) return varchar2 is - l_result varchar2(250); - begin - l_result := regexp_substr( - a_full_object_name, - '^([[:alnum:]$#_]+|".*?")\.([[:alnum:]$#_]+|".*?")', subexpression => 2 - ); - if not l_result like '"%"' then - l_result := upper(l_result); - end if; - return ut_utils.qualified_sql_name(l_result); - end; - - function get_anydata_compound_type(a_data_value anydata) return varchar2 is - l_result varchar2(30); - l_type anytype; - l_type_code integer; - begin - if a_data_value is not null then - l_type_code := a_data_value.gettype(l_type); - if l_type_code in (dbms_types.typecode_table, dbms_types.typecode_varray, dbms_types.typecode_namedcollection, - dbms_types.typecode_object) then - if l_type_code = dbms_types.typecode_object then - l_result := 'object'; - else - l_result := 'collection'; - end if; - end if; - end if; - return l_result; - end; - -end; -/ diff --git a/source/core/ut_metadata.pks b/source/core/ut_metadata.pks deleted file mode 100644 index 27bfa5d30..000000000 --- a/source/core/ut_metadata.pks +++ /dev/null @@ -1,169 +0,0 @@ -create or replace package ut_metadata authid current_user as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Common package for all code that reads from the system tables. - */ - - type t_anytype_members_rec is record ( - type_code pls_integer, - schema_name varchar2(128), - type_name varchar2(128), - length pls_integer, - elements_count pls_integer, - version varchar2(32767), - precision pls_integer, - scale pls_integer, - char_set_id pls_integer, - char_set_frm pls_integer - ); - - type t_anytype_elem_info_rec is record ( - type_code pls_integer, - attribute_name varchar2(260), - length pls_integer, - version varchar2(32767), - precision pls_integer, - scale pls_integer, - char_set_id pls_integer, - char_set_frm pls_integer, - attr_elt_type anytype - ); - - /** - * Forms correct object/subprogram name to call as owner.object[.subprogram] - * - */ - function form_name(a_owner_name varchar2, a_object varchar2, a_subprogram varchar2 default null) return varchar2; - - /** - * Check if package exists and is in a VALID state - * - */ - function package_valid(a_owner_name varchar2, a_package_name in varchar2) return boolean; - - /** - * Check if package exists and is VALID and contains the given procedure. - * - */ - function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2) - return boolean; - - /** - * Return the text of the source line for a given object (body). It excludes package spec and type spec - */ - function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2; - - - /** - * Invalidates package-level cache for source. - * Caching is used to improve performance of function get_source_definition_line - */ - procedure reset_source_definition_cache; - - /** - * Returns dba_... view name if it is accessible, otherwise it returns all_... view - * @param a_dba_view_name the name of dba view requested - */ - function get_dba_view(a_dba_view_name varchar2) return varchar2; - - /** - * Returns dba_source if accessible otherwise returns all_source - */ - function get_source_view_name return varchar2; - - /** - * Returns dba_objects if accessible otherwise returns all_objects - */ - function get_objects_view_name return varchar2; - - /** - * Returns true if object is accessible to current user - * @param a_object_name fully qualified object name (with schema name) - */ - function is_object_visible(a_object_name varchar2) return boolean; - - /** - * Returns true if current user has execute any procedure privilege - * The check is performed by checking if user can execute ut_utils package - */ - function user_has_execute_any_proc return boolean; - - /** - * Returns true if given object is a package and it exists in current schema - * @param a_object_name the name of the object to be checked - */ - function package_exists_in_cur_schema(a_object_name varchar2) return boolean; - - /** - * Returns true if given typecode is a collection typecode - */ - function is_collection(a_anytype_code in integer) return boolean; - - /** - * Returns true if given object is a collection - */ - function is_collection(a_owner varchar2, a_type_name varchar2) return boolean; - - /** - * Returns a descriptor of anytype - */ - function get_anytype_members_info( a_anytype anytype ) return t_anytype_members_rec; - - /** - * Returns a descriptor of anytype attribute - */ - function get_attr_elem_info( a_anytype anytype, a_pos pls_integer := null ) return t_anytype_elem_info_rec; - - /** - * Returns ANYTYPE descriptor of an object type - */ - function get_user_defined_type(a_owner varchar2, a_type_name varchar2) return anytype; - - /** - * Return fully qualified name of the object from collection, if not collection returns null - */ - function get_collection_element(a_anydata in anydata) return varchar2; - - /** - * Check if collection got elements - */ - function has_collection_members (a_anydata in anydata) return boolean; - - /** - * Get typename from anydata - */ - function get_anydata_typename(a_data_value anydata) return varchar2; - - /** - * Is anydata object/collection is null - */ - function is_anytype_null(a_value in anydata, a_compound_type in varchar2) return number; - - /** - * Get object name from fully qualified name e.g ut3.test -> test - */ - function get_object_name(a_full_object_name in varchar2) return varchar2; - - /** - * Based on anydata decide if its a object or collection - */ - function get_anydata_compound_type(a_data_value anydata) return varchar2; - -end ut_metadata; -/ diff --git a/source/core/ut_savepoint_seq.sql b/source/core/ut_savepoint_seq.sql deleted file mode 100644 index 5b0cda35e..000000000 --- a/source/core/ut_savepoint_seq.sql +++ /dev/null @@ -1,15 +0,0 @@ -create sequence ut_savepoint_seq - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - start with 1 cache 20 minvalue 1 maxvalue 99999999999999999 cycle; \ No newline at end of file diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb deleted file mode 100644 index ebb113370..000000000 --- a/source/core/ut_suite_builder.pkb +++ /dev/null @@ -1,894 +0,0 @@ -create or replace package body ut_suite_builder is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - subtype t_annotation_text is varchar2(4000); - subtype t_annotation_name is varchar2(4000); - subtype t_object_name is varchar2(500); - subtype t_annotation_position is binary_integer; - - 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'; - gc_beforeall constant t_annotation_name := ut_utils.gc_before_all; - gc_beforeeach constant t_annotation_name := ut_utils.gc_before_each; - gc_beforetest constant t_annotation_name := ut_utils.gc_before_test; - gc_afterall constant t_annotation_name := ut_utils.gc_after_all; - gc_aftereach constant t_annotation_name := ut_utils.gc_after_each; - gc_aftertest constant t_annotation_name := ut_utils.gc_after_test; - gc_throws constant t_annotation_name := 'throws'; - gc_rollback constant t_annotation_name := 'rollback'; - gc_context constant t_annotation_name := 'context'; - gc_name constant t_annotation_name := 'name'; - gc_endcontext constant t_annotation_name := 'endcontext'; - - type tt_annotations is table of t_annotation_name; - - gc_supported_annotations constant tt_annotations - := tt_annotations( - gc_suite, - gc_suitepath, - gc_tags, - gc_test, - gc_disabled, - gc_displayname, - gc_beforeall, - gc_beforeeach, - gc_beforetest, - gc_afterall, - gc_aftereach, - gc_aftertest, - gc_throws, - gc_rollback, - gc_context, - gc_name, - gc_endcontext - ); - - type tt_executables is table of ut_executables index by t_annotation_position; - - type t_annotation is record( - name t_annotation_name, - text t_annotation_text, - procedure_name t_object_name - ); - - type tt_annotations_by_line is table of t_annotation index by t_annotation_position; - - --list of annotation texts for a given annotation indexed by annotation position: - --This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example - -- --%beforetest(some) - -- --%beforetest(other) - -- --%test(some test with two before test procedures) - -- procedure some_test ... - -- when you'd like to have two beforetest procedures executed in a single test - type tt_annotation_texts is table of t_annotation_text index by t_annotation_position; - - type tt_annotations_by_name is table of tt_annotation_texts index by t_annotation_name; - - type tt_annotations_by_proc is table of tt_annotations_by_name index by t_object_name; - - type t_annotations_info is record ( - owner t_object_name, - name t_object_name, - parse_time timestamp, - by_line tt_annotations_by_line, - by_proc tt_annotations_by_proc, - by_name tt_annotations_by_name - ); - - procedure delete_annotations_range( - a_annotations in out nocopy t_annotations_info, - a_start_pos t_annotation_position, - a_end_pos t_annotation_position - ) is - l_pos t_annotation_position := a_start_pos; - l_annotation t_annotation; - begin - while l_pos is not null and l_pos <= a_end_pos loop - l_annotation := a_annotations.by_line(l_pos); - if l_annotation.procedure_name is not null and a_annotations.by_proc.exists(l_annotation.procedure_name) then - a_annotations.by_proc.delete(l_annotation.procedure_name); - elsif a_annotations.by_name.exists(l_annotation.name) then - a_annotations.by_name(l_annotation.name).delete(l_pos); - if a_annotations.by_name(l_annotation.name).count = 0 then - a_annotations.by_name.delete(l_annotation.name); - end if; - end if; - l_pos := a_annotations.by_line.next( l_pos ); - end loop; - a_annotations.by_line.delete(a_start_pos, a_end_pos); - end; - - - procedure add_items_to_list(a_list in out nocopy ut_suite_items, a_items ut_suite_items) is - begin - for i in 1 .. a_items.count loop - a_list.extend(); - a_list(a_list.last) := a_items(i); - end loop; - end; - - ----------------------------------------------- - -- Processing annotations - ----------------------------------------------- - - procedure add_annotation_ignored_warning( - a_suite in out nocopy ut_suite_item, - a_annotation t_annotation_name, - a_message varchar2, - a_line_no binary_integer, - a_procedure_name t_object_name := null - ) is - begin - a_suite.put_warning( - replace(a_message,'%%%','"--%'||a_annotation||'"')|| ' Annotation ignored.', - a_procedure_name, - a_line_no - ); - end; - - function get_rollback_type(a_rollback_type_name varchar2) return ut_utils.t_rollback_type is - l_rollback_type ut_utils.t_rollback_type; - begin - l_rollback_type := - case lower(a_rollback_type_name) - when 'manual' then ut_utils.gc_rollback_manual - when 'auto' then ut_utils.gc_rollback_auto - end; - return l_rollback_type; - end; - - procedure add_to_throws_numbers_list( - a_suite in out nocopy ut_suite, - a_list in out nocopy ut_varchar2_rows, - a_procedure_name t_object_name, - a_throws_ann_text tt_annotation_texts - ) is - l_annotation_pos binary_integer; - - begin - l_annotation_pos := a_throws_ann_text.first; - while l_annotation_pos is not null loop - if a_throws_ann_text(l_annotation_pos) is null then - a_suite.put_warning( - '"--%throws" annotation requires a parameter. Annotation ignored.', - a_procedure_name, - l_annotation_pos - ); - else - ut_utils.append_to_list( - a_list, - ut_utils.convert_collection( ut_utils.trim_list_elements ( ut_utils.string_to_table( a_throws_ann_text(l_annotation_pos), ',' ) ) ) - ); - end if; - 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_tags_list ut_varchar2_list := ut_varchar2_list(); - l_tag_items 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.', - a_procedure_name, - l_annotation_pos - ); - else - l_tag_items := ut_utils.trim_list_elements(ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')); - if l_tag_items is not empty then - for i in 1 .. l_tag_items.count loop - if regexp_like(l_tag_items(i),'^[^-](\S)+$') then - l_tags_list.extend(); - l_tags_list(l_tags_list.last) := l_tag_items(i); - else - a_suite.put_warning( - 'Invalid value "'||l_tag_items(i)||'" for "--%tags" annotation. See documentation for details on valid tag values. Annotation value ignored.', - a_procedure_name, - l_annotation_pos - ); - end if; - end loop; - end if; - 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 convert to rows - a_list := ut_utils.convert_collection( ut_utils.filter_list(set(l_tags_list),ut_utils.gc_word_no_space) ); - end; - - procedure set_seq_no( - a_list in out nocopy ut_executables - ) is - begin - if a_list is not null then - for i in 1 .. a_list.count loop - a_list(i).seq_no := i; - end loop; - end if; - end; - - function convert_list( - a_list tt_executables - ) return ut_executables is - l_result ut_executables := ut_executables(); - l_pos t_annotation_position := a_list.first; - begin - while l_pos is not null loop - for i in 1 .. a_list(l_pos).count loop - l_result.extend; - l_result(l_result.last) := a_list(l_pos)(i); - end loop; - l_pos := a_list.next(l_pos); - end loop; - return l_result; - end; - - function add_executables( - a_owner t_object_name, - a_package_name t_object_name, - a_annotation_texts tt_annotation_texts, - a_event_name ut_event_manager.t_event_name - ) return tt_executables is - l_executables ut_executables; - l_result tt_executables; - l_annotation_pos binary_integer; - l_procedures_list ut_varchar2_list; - l_procedures_pos binary_integer; - l_components_list ut_varchar2_list; - begin - l_annotation_pos := a_annotation_texts.first; - while l_annotation_pos is not null loop - l_procedures_list := - ut_utils.filter_list( - ut_utils.trim_list_elements( - ut_utils.string_to_table(a_annotation_texts(l_annotation_pos), ',') - ) - , '[[:alpha:]]+' - ); - - l_procedures_pos := l_procedures_list.first; - l_executables := ut_executables(); - while l_procedures_pos is not null loop - l_components_list := ut_utils.string_to_table(l_procedures_list(l_procedures_pos), '.'); - - l_executables.extend; - l_executables(l_executables.last) := - case(l_components_list.count()) - when 1 then - ut_executable(a_owner, a_package_name, l_components_list(1), a_event_name) - when 2 then - ut_executable(a_owner,l_components_list(1), l_components_list(2), a_event_name) - when 3 then - ut_executable(l_components_list(1), l_components_list(2), l_components_list(3), a_event_name) - else - null - end; - l_procedures_pos := l_procedures_list.next(l_procedures_pos); - end loop; - l_result(l_annotation_pos) := l_executables; - l_annotation_pos := a_annotation_texts.next(l_annotation_pos); - end loop; - return l_result; - end; - - procedure warning_on_duplicate_annot( - a_suite in out nocopy ut_suite_item, - a_annotations tt_annotations_by_name, - a_for_annotation varchar2, - a_procedure_name t_object_name := null - ) is - l_line_no binary_integer; - begin - if a_annotations.exists(a_for_annotation) and a_annotations(a_for_annotation).count > 1 then - --start from second occurrence of annotation - l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first ); - while l_line_no is not null loop - add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name ); - l_line_no := a_annotations(a_for_annotation).next( l_line_no ); - end loop; - end if; - end; - - procedure warning_bad_annot_combination( - a_suite in out nocopy ut_suite_item, - a_procedure_name t_object_name, - a_proc_annotations tt_annotations_by_name, - a_for_annotation varchar2, - a_invalid_annotations ut_varchar2_list - ) is - l_annotation_name t_annotation_name; - l_line_no binary_integer; - begin - if a_proc_annotations.exists(a_for_annotation) then - l_annotation_name := a_proc_annotations.first; - while l_annotation_name is not null loop - if l_annotation_name member of a_invalid_annotations then - l_line_no := a_proc_annotations(l_annotation_name).first; - while l_line_no is not null loop - add_annotation_ignored_warning( - a_suite, l_annotation_name, 'Annotation %%% cannot be used with "--%'|| a_for_annotation || '".', - l_line_no, a_procedure_name - ); - l_line_no := a_proc_annotations(l_annotation_name).next(l_line_no); - end loop; - end if; - l_annotation_name := a_proc_annotations.next(l_annotation_name); - end loop; - end if; - end; - - procedure add_test( - a_suite in out nocopy ut_suite, - a_suite_items in out nocopy ut_suite_items, - a_procedure_name t_object_name, - a_annotations t_annotations_info - ) is - l_test ut_test; - l_annotation_texts tt_annotation_texts; - l_proc_annotations tt_annotations_by_name := a_annotations.by_proc(a_procedure_name); - begin - - if not l_proc_annotations.exists(gc_test) then - return; - end if; - warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_test, a_procedure_name); - warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_displayname, a_procedure_name); - warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_rollback, a_procedure_name); - warning_bad_annot_combination( - a_suite, a_procedure_name, l_proc_annotations, gc_test, - ut_varchar2_list(gc_beforeeach, gc_aftereach, gc_beforeall, gc_afterall) - ); - - l_test := ut_test(a_suite.object_owner, a_suite.object_name, a_procedure_name, l_proc_annotations( gc_test).first); - l_test.parse_time := a_annotations.parse_time; - - if l_proc_annotations.exists( gc_displayname) then - l_annotation_texts := l_proc_annotations( gc_displayname); - --take the last definition if more than one was provided - l_test.description := l_annotation_texts(l_annotation_texts.first); - --TODO if more than one - warning - else - l_test.description := l_proc_annotations(gc_test)(l_proc_annotations(gc_test).first); - end if; - l_test.path := a_suite.path ||'.'||a_procedure_name; - - if l_proc_annotations.exists(gc_rollback) then - l_annotation_texts := l_proc_annotations(gc_rollback); - l_test.rollback_type := get_rollback_type(l_annotation_texts(l_annotation_texts.first)); - if l_test.rollback_type is null then - add_annotation_ignored_warning( - a_suite, gc_rollback, 'Annotation %%% must be provided with one of values: "auto" or "manual".', - l_annotation_texts.first, a_procedure_name - ); - end if; - end if; - - if l_proc_annotations.exists( gc_beforetest) then - l_test.before_test_list := convert_list( - add_executables( l_test.object_owner, l_test.object_name, l_proc_annotations( gc_beforetest ), gc_beforetest ) - ); - set_seq_no(l_test.before_test_list); - end if; - if l_proc_annotations.exists( gc_aftertest) then - l_test.after_test_list := convert_list( - add_executables( l_test.object_owner, l_test.object_name, l_proc_annotations( gc_aftertest ), gc_aftertest ) - ); - 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)); - - if l_proc_annotations.exists(gc_disabled) then - l_annotation_texts := l_proc_annotations( gc_disabled); - --take the last definition if more than one was provided - l_test.disabled_reason := l_annotation_texts(l_annotation_texts.first); - end if; - - a_suite_items.extend; - a_suite_items( a_suite_items.last ) := l_test; - - end; - - procedure propagate_before_after_each( - a_suite_items in out nocopy ut_suite_items, - a_before_each_list tt_executables, - a_after_each_list tt_executables - ) is - l_test ut_test; - l_context ut_logical_suite; - begin - if a_suite_items is not null then - for i in 1 .. a_suite_items.count loop - if a_suite_items(i) is of (ut_test) then - l_test := treat( a_suite_items(i) as ut_test); - l_test.before_each_list := convert_list(a_before_each_list) multiset union all l_test.before_each_list; - set_seq_no(l_test.before_each_list); - l_test.after_each_list := l_test.after_each_list multiset union all convert_list(a_after_each_list); - set_seq_no(l_test.after_each_list); - a_suite_items(i) := l_test; - elsif a_suite_items(i) is of (ut_logical_suite) then - l_context := treat(a_suite_items(i) as ut_logical_suite); - propagate_before_after_each( l_context.items, a_before_each_list, a_after_each_list); - a_suite_items(i) := l_context; - end if; - end loop; - end if; - end; - - procedure process_before_after_annot( - a_list in out nocopy tt_executables, - a_annotation_name t_annotation_name, - a_procedure_name t_object_name, - a_proc_annotations tt_annotations_by_name, - a_suite in out nocopy ut_suite - ) is - begin - if a_proc_annotations.exists(a_annotation_name) and not a_proc_annotations.exists(gc_test) then - a_list( a_proc_annotations(a_annotation_name).first ) := ut_executables(ut_executable(a_suite.object_owner, a_suite.object_name, a_procedure_name, a_annotation_name)); - warning_on_duplicate_annot(a_suite, a_proc_annotations, a_annotation_name, a_procedure_name); - --TODO add warning if annotation has text - text ignored - end if; - end; - - procedure get_annotated_procedures( - a_proc_annotations t_annotations_info, - a_suite in out nocopy ut_suite, - a_suite_items in out nocopy ut_suite_items, - a_before_each_list in out nocopy tt_executables, - a_after_each_list in out nocopy tt_executables, - a_before_all_list in out nocopy tt_executables, - a_after_all_list in out nocopy tt_executables - ) is - l_procedure_name t_object_name; - begin - l_procedure_name := a_proc_annotations.by_proc.first; - while l_procedure_name is not null loop - add_test( a_suite, a_suite_items, l_procedure_name, a_proc_annotations ); - process_before_after_annot(a_before_each_list, gc_beforeeach, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite); - process_before_after_annot(a_after_each_list, gc_aftereach, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite); - process_before_after_annot(a_before_all_list, gc_beforeall, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite); - process_before_after_annot(a_after_all_list, gc_afterall, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite); - l_procedure_name := a_proc_annotations.by_proc.next( l_procedure_name ); - end loop; - end; - - procedure build_suitepath( - a_suite in out nocopy ut_suite, - a_annotations t_annotations_info - ) is - l_annotation_text t_annotation_text; - begin - if a_annotations.by_name.exists(gc_suitepath) then - l_annotation_text := trim(a_annotations.by_name(gc_suitepath)(a_annotations.by_name(gc_suitepath).first)); - if l_annotation_text is not null then - if regexp_like(l_annotation_text,'^((\w|[$#])+\.)*(\w|[$#])+$') then - a_suite.path := l_annotation_text||'.'||a_suite.object_name; - else - add_annotation_ignored_warning( - a_suite, gc_suitepath||'('||l_annotation_text||')', - 'Invalid path value in annotation %%%.', a_annotations.by_name(gc_suitepath).first - ); - end if; - else - add_annotation_ignored_warning( - a_suite, gc_suitepath, '%%% annotation requires a non-empty parameter value.', - a_annotations.by_name(gc_suitepath).first - ); - end if; - warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_suitepath); - end if; - a_suite.path := lower(coalesce(a_suite.path, a_suite.object_name)); - end; - - procedure add_tests_to_items( - a_suite in out nocopy ut_suite, - a_annotations t_annotations_info, - a_suite_items in out nocopy ut_suite_items - ) is - l_before_each_list tt_executables; - l_after_each_list tt_executables; - l_before_all_list tt_executables; - l_after_all_list tt_executables; - l_rollback_type ut_utils.t_rollback_type; - l_annotation_text t_annotation_text; - begin - if a_annotations.by_name.exists(gc_displayname) then - l_annotation_text := trim(a_annotations.by_name(gc_displayname)(a_annotations.by_name(gc_displayname).first)); - if l_annotation_text is not null then - a_suite.description := l_annotation_text; - else - add_annotation_ignored_warning( - a_suite, gc_displayname, '%%% annotation requires a non-empty parameter value.', - a_annotations.by_name(gc_displayname).first - ); - end if; - warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_displayname); - end if; - - if a_annotations.by_name.exists(gc_rollback) then - l_rollback_type := get_rollback_type(a_annotations.by_name(gc_rollback)(a_annotations.by_name(gc_rollback).first)); - if l_rollback_type is null then - add_annotation_ignored_warning( - a_suite, gc_rollback, '%%% annotation requires one of values as parameter: "auto" or "manual".', - a_annotations.by_name(gc_rollback).first - ); - end if; - warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_rollback); - end if; - if a_annotations.by_name.exists(gc_beforeall) then - l_before_all_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_beforeall), gc_beforeall ); - end if; - if a_annotations.by_name.exists(gc_afterall) then - l_after_all_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_afterall), gc_afterall ); - end if; - - if a_annotations.by_name.exists(gc_beforeeach) then - l_before_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_beforeeach), gc_beforeeach ); - end if; - 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)); - if a_annotations.by_name.exists(gc_disabled) then - a_suite.disabled_reason := a_annotations.by_name(gc_disabled)(a_annotations.by_name(gc_disabled).first); - end if; - - --process procedure annotations for suite - get_annotated_procedures(a_annotations, a_suite, a_suite_items, l_before_each_list, l_after_each_list, l_before_all_list, l_after_all_list); - - a_suite.set_rollback_type(l_rollback_type); - propagate_before_after_each( a_suite_items, l_before_each_list, l_after_each_list); - a_suite.before_all_list := convert_list(l_before_all_list); - set_seq_no(a_suite.before_all_list); - a_suite.after_all_list := convert_list(l_after_all_list); - set_seq_no(a_suite.after_all_list); - end; - - function get_next_annotation_of_type( - a_start_position t_annotation_position, - a_annotation_type varchar2, - a_package_annotations in tt_annotations_by_name - ) return t_annotation_position is - l_result t_annotation_position; - begin - if a_package_annotations.exists(a_annotation_type) then - l_result := a_package_annotations(a_annotation_type).first; - while l_result <= a_start_position loop - l_result := a_package_annotations(a_annotation_type).next(l_result); - end loop; - end if; - return l_result; - end; - - function get_endcontext_position( - a_context_ann_pos t_annotation_position, - a_package_annotations in tt_annotations_by_line - ) return t_annotation_position is - l_result t_annotation_position; - l_open_count integer := 1; - l_idx t_annotation_position := a_package_annotations.next(a_context_ann_pos); - begin - while l_open_count > 0 and l_idx is not null loop - if ( a_package_annotations(l_idx).name = gc_context ) then - l_open_count := l_open_count+1; - elsif ( a_package_annotations(l_idx).name = gc_endcontext ) then - l_open_count := l_open_count-1; - l_result := l_idx; - end if; - l_idx := a_package_annotations.next(l_idx); - end loop; - if ( l_open_count > 0 ) then - l_result := null; - end if; - return l_result; - end; - - function has_nested_context( - a_context_ann_pos t_annotation_position, - a_package_annotations in tt_annotations_by_name - ) return boolean is - l_next_endcontext_pos t_annotation_position := 0; - l_next_context_pos t_annotation_position := 0; - begin - if ( a_package_annotations.exists(gc_endcontext) and a_package_annotations.exists(gc_context)) then - l_next_endcontext_pos := get_next_annotation_of_type(a_context_ann_pos, gc_endcontext, a_package_annotations); - l_next_context_pos := a_package_annotations(gc_context).next(a_context_ann_pos); - end if; - return ( l_next_context_pos < l_next_endcontext_pos ); - end; - - function get_annotations_in_context( - a_annotations t_annotations_info, - a_context_pos t_annotation_position, - a_end_context_pos t_annotation_position - ) return t_annotations_info is - l_result t_annotations_info; - l_position t_annotation_position; - l_procedure_name t_object_name; - l_annotation_name t_annotation_name; - l_annotation_text t_annotation_text; - begin - l_position := a_context_pos; - l_result.owner := a_annotations.owner; - l_result.name := a_annotations.name; - l_result.parse_time := a_annotations.parse_time; - while l_position is not null and l_position <= a_end_context_pos loop - l_result.by_line(l_position) := a_annotations.by_line(l_position); - l_procedure_name := l_result.by_line(l_position).procedure_name; - l_annotation_name := l_result.by_line(l_position).name; - l_annotation_text := l_result.by_line(l_position).text; - if l_procedure_name is not null then - l_result.by_proc(l_procedure_name)(l_annotation_name)(l_position) := l_annotation_text; - else - l_result.by_name(l_annotation_name)(l_position) := l_annotation_text; - end if; - l_position := a_annotations.by_line.next(l_position); - end loop; - return l_result; - end; - - procedure get_context_items( - a_parent in out nocopy ut_suite, - a_annotations in out nocopy t_annotations_info, - a_suite_items out nocopy ut_suite_items, - a_parent_context_pos in integer := 0, - a_parent_end_context_pos in integer default null - ) is - l_context_pos t_annotation_position; - l_next_context_pos t_annotation_position; - l_end_context_pos t_annotation_position; - l_ctx_annotations t_annotations_info; - l_context ut_suite_context; - l_context_no binary_integer := 1; - l_context_items ut_suite_items; - type tt_context_names is table of boolean index by t_object_name; - l_used_context_names tt_context_names; - l_context_name t_object_name; - l_default_context_name t_object_name; - function get_context_name( - a_parent in out nocopy ut_suite, - a_start_position binary_integer - ) return varchar2 is - l_result t_annotation_name; - l_found boolean; - l_end_position binary_integer; - l_annotation_pos binary_integer; - l_context_names tt_annotation_texts; - begin - if a_annotations.by_name.exists(gc_name) then - l_context_names := a_annotations.by_name( gc_name ); - -- Maximum end-position to look for %name annotation is either the next %context or the next %endcontext annotation - l_end_position := - least( - coalesce( get_next_annotation_of_type(a_start_position, gc_endcontext, a_annotations.by_name), a_annotations.by_line.last ), - coalesce( get_next_annotation_of_type(a_start_position, gc_context, a_annotations.by_name), a_annotations.by_line.last ) - ); - l_annotation_pos := l_context_names.first; - - while l_annotation_pos is not null loop - if l_annotation_pos > a_start_position and l_annotation_pos < l_end_position then - if l_found then - add_annotation_ignored_warning(a_parent, gc_name,'Duplicate annotation %%%.', l_annotation_pos); - else - l_result := l_context_names(l_annotation_pos); - end if; - l_found := true; - end if; - l_annotation_pos := l_context_names.next(l_annotation_pos); - end loop; - end if; - return l_result; - end; - begin - a_suite_items := ut_suite_items(); - if not a_annotations.by_name.exists(gc_context) then - return; - end if; - - l_context_pos := a_annotations.by_name( gc_context).next(a_parent_context_pos); - - while l_context_pos is not null loop - l_default_context_name := 'nested_context_#'||l_context_no; - l_context_name := null; - l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_line ); - l_next_context_pos := a_annotations.by_name(gc_context).next(l_context_pos); - l_context_name := get_context_name(a_parent, l_context_pos); - if not regexp_like( l_context_name, '^(\w|[$#])+$' ) or l_context_name is null then - if not regexp_like( l_context_name, '^(\w|[$#])+$' ) then - a_parent.put_warning( - 'Invalid value "'||l_context_name||'" for context name.' || - ' Context name ignored and fallback to auto-name "'||l_default_context_name||'" ', - null, - l_context_pos - ); - end if; - l_context_name := l_default_context_name; - end if; - if l_used_context_names.exists(l_context_name) then - add_annotation_ignored_warning( - a_parent, gc_name, - 'Context name "'||l_context_name||'" already used in this scope. Name must be unique.' || - ' Using fallback name '||l_default_context_name||'.', l_context_pos ); - l_context_name := l_default_context_name; - end if; - l_used_context_names(l_context_name) := true; - - l_context := ut_suite_context(a_parent.object_owner, a_parent.object_name, l_context_name, l_context_pos ); - l_context.path := a_parent.path||'.'||l_context_name; - l_context.description := coalesce( a_annotations.by_line( l_context_pos ).text, l_context_name ); - l_context.parse_time := a_annotations.parse_time; - - --if nested context found - if has_nested_context(l_context_pos, a_annotations.by_name) then - get_context_items( l_context, a_annotations, l_context_items, l_context_pos, l_end_context_pos ); - else - l_context_items := ut_suite_items(); - end if; - - if l_end_context_pos is null then - a_parent.put_warning( - 'Missing "--%endcontext" annotation for a "--%context" annotation. The end of package is considered end of context.', - null, - l_context_pos - ); - l_end_context_pos := a_annotations.by_line.last; - end if; - - --create a sub-set of annotations to process as sub-suite (context) - l_ctx_annotations := get_annotations_in_context( a_annotations, l_context_pos, l_end_context_pos); - - warning_on_duplicate_annot( l_context, l_ctx_annotations.by_name, gc_context ); - - add_tests_to_items( l_context, l_ctx_annotations, l_context_items ); - add_items_to_list(a_suite_items, l_context_items); - a_suite_items.extend; - a_suite_items(a_suite_items.last) := l_context; - -- remove annotations within context after processing them - delete_annotations_range(a_annotations, l_context_pos, l_end_context_pos); - - exit when not a_annotations.by_name.exists( gc_context); - - l_context_pos := a_annotations.by_name( gc_context).next( l_context_pos); - -- don't go on when the next context is outside the parent's context boundaries - if (a_parent_end_context_pos <= l_context_pos ) then - l_context_pos := null; - end if; - l_context_no := l_context_no + 1; - end loop; - end; - - procedure warning_on_extra_endcontext( - a_suite in out nocopy ut_suite, - a_package_ann_index tt_annotations_by_name - ) is - l_annotation_pos t_annotation_position; - begin - if a_package_ann_index.exists(gc_endcontext) then - l_annotation_pos := a_package_ann_index(gc_endcontext).first; - while l_annotation_pos is not null loop - add_annotation_ignored_warning( - a_suite, gc_endcontext, 'Extra %%% annotation found. Cannot find corresponding "--%context".', - l_annotation_pos - ); - l_annotation_pos := a_package_ann_index(gc_endcontext).next(l_annotation_pos); - end loop; - end if; - end; - - procedure warning_on_unknown_annotations( - a_suite in out nocopy ut_suite_item, - a_annotations tt_annotations_by_line - ) is - l_line_no t_annotation_position := a_annotations.first; - begin - while l_line_no is not null loop - if a_annotations(l_line_no).name not member of (gc_supported_annotations) then - add_annotation_ignored_warning( - a_suite, - a_annotations(l_line_no).name, - 'Unsupported annotation %%%.', - l_line_no, - a_annotations(l_line_no).procedure_name - ); - end if; - l_line_no := a_annotations.next(l_line_no); - end loop; - end; - - function convert_package_annotations(a_object ut_annotated_object) return t_annotations_info is - l_result t_annotations_info; - l_annotation t_annotation; - l_annotation_no binary_integer; - l_annotation_pos binary_integer; - begin - l_result.owner := a_object.object_owner; - l_result.name := lower(trim(a_object.object_name)); - l_result.parse_time := a_object.parse_time; - l_annotation_no := a_object.annotations.first; - while l_annotation_no is not null loop - l_annotation_pos := a_object.annotations(l_annotation_no).position; - l_annotation.name := a_object.annotations(l_annotation_no).name; - l_annotation.text := a_object.annotations(l_annotation_no).text; - l_annotation.procedure_name := lower(trim(a_object.annotations(l_annotation_no).subobject_name)); - l_result.by_line( l_annotation_pos) := l_annotation; - if l_annotation.procedure_name is null then - l_result.by_name( l_annotation.name)( l_annotation_pos) := l_annotation.text; - else - l_result.by_proc(l_annotation.procedure_name)(l_annotation.name)(l_annotation_pos) := l_annotation.text; - end if; - l_annotation_no := a_object.annotations.next(l_annotation_no); - end loop; - return l_result; - end; - - procedure create_suite_item_list( a_annotated_object ut_annotated_object, a_suite_items out nocopy ut_suite_items ) is - l_annotations t_annotations_info; - l_annotation_pos t_annotation_position; - l_suite ut_suite; - begin - l_annotations := convert_package_annotations( a_annotated_object ); - - if l_annotations.by_name.exists(gc_suite) then - l_annotation_pos := l_annotations.by_name(gc_suite).first; - l_suite := ut_suite(l_annotations.owner, l_annotations.name, l_annotation_pos); - l_suite.description := l_annotations.by_name( gc_suite)( l_annotation_pos); - l_suite.parse_time := l_annotations.parse_time; - warning_on_unknown_annotations(l_suite, l_annotations.by_line); - - warning_on_duplicate_annot( l_suite, l_annotations.by_name, gc_suite ); - - build_suitepath( l_suite, l_annotations ); - get_context_items( l_suite, l_annotations, a_suite_items ); - --create suite tests and add - add_tests_to_items( l_suite, l_annotations, a_suite_items ); - - --by this time all contexts were consumed and l_annotations should not have any context/endcontext annotation in it. - warning_on_extra_endcontext( l_suite, l_annotations.by_name ); - - a_suite_items.extend; - a_suite_items( a_suite_items.last) := l_suite; - end if; - end; - -end ut_suite_builder; -/ diff --git a/source/core/ut_suite_builder.pks b/source/core/ut_suite_builder.pks deleted file mode 100644 index 352601a6d..000000000 --- a/source/core/ut_suite_builder.pks +++ /dev/null @@ -1,32 +0,0 @@ -create or replace package ut_suite_builder authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Responsible for converting annotations into unit test suites - */ - - /** - * Creates a list of suite items for an annotated object - */ - procedure create_suite_item_list( - a_annotated_object ut_annotated_object, - a_suite_items out nocopy ut_suite_items - ); - -end ut_suite_builder; -/ diff --git a/source/core/ut_suite_cache.sql b/source/core/ut_suite_cache.sql deleted file mode 100644 index 182caabd0..000000000 --- a/source/core/ut_suite_cache.sql +++ /dev/null @@ -1,38 +0,0 @@ -create table ut_suite_cache - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - of ut_suite_cache_row - nested table warnings store as ut_suite_cache_warnings - nested table before_all_list store as ut_suite_cache_before_all - nested table after_all_list store as ut_suite_cache_after_all - nested table before_each_list store as ut_suite_cache_before_each - 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_throws - nested table tags store as ut_suite_cache_tags return as locator -/ - -alter table ut_suite_cache modify (object_owner not null, path not null, self_type not null, object_name not null, name not null, parse_time not null) -/ -alter table ut_suite_cache add constraint ut_suite_cache_pk primary key (id) -/ -alter table ut_suite_cache add constraint ut_suite_cache_uk1 unique (object_owner, path) -/ -alter table ut_suite_cache add constraint ut_suite_cache_uk2 unique (object_owner, object_name, line_no) -/ - -alter table ut_suite_cache add constraint ut_suite_cache_schema_fk foreign key (object_owner, object_name) -references ut_suite_cache_package(object_owner, object_name) on delete cascade -/ diff --git a/source/core/ut_suite_cache_manager.pkb b/source/core/ut_suite_cache_manager.pkb deleted file mode 100644 index e5fdae7ac..000000000 --- a/source/core/ut_suite_cache_manager.pkb +++ /dev/null @@ -1,502 +0,0 @@ -create or replace package body ut_suite_cache_manager is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /* - * Private code - */ - cursor c_get_bulk_cache_suite(cp_suite_items in ut_suite_cache_rows) is - with - suite_items as ( - select /*+ cardinality(c 500) */ value(c) as obj - from table(cp_suite_items) c), - suitepaths as ( - select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath, - c.obj.path as path, - c.obj.object_owner as object_owner - from suite_items c - where c.obj.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 ut_executables) as x, - cast(null as ut_varchar2_rows) as y, - cast(null as ut_executable_test) as z - from suitepath_part p - where p.path - not in (select s.path from suitepaths s) - ), - logical_suites as ( - select ut_suite_cache_row( - null, - s.self_type, s.path, s.object_owner, s.object_name, - s.object_name, null, null, null, null, 0,null, - ut_varchar2_rows(), - s.x, s.x, s.x, s.x, s.x, s.x, - s.y, null, s.z - ) as obj - from logical_suite_data s - ) - select /*+ no_parallel */ obj from suite_items - union all - select /*+ no_parallel */ obj from logical_suites; - - function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is - l_result ut_varchar2_rows; - l_data ut_annotation_objs_cache_info; - begin - l_data := ut_annotation_cache_manager.get_cached_objects_list(a_object_owner, 'PACKAGE'); - - select /*+ no_parallel */ i.object_name - bulk collect into l_result - from ut_suite_cache_package i - where not exists ( - select 1 from table(l_data) o - where o.object_owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = 'PACKAGE' - ) - and i.object_owner = a_object_owner; - return l_result; - end; - - function group_paths_by_schema(a_paths ut_varchar2_list) return ut_path_items is - c_package_path_regex constant varchar2(100) := '^([[:alnum:]$#_]+)(\.([[:alnum:]$#_\*]+))?(\.([[:alnum:]$#_\*]+))?$'; - l_results ut_path_items := ut_path_items(); - l_path_item ut_path_item; - i pls_integer; - begin - i := a_paths.first; - while (i is not null) loop - l_results.extend; - if a_paths(i) like '%:%' then - l_path_item := ut_path_item(schema_name => upper(regexp_substr(a_paths(i),'^[^.:]+')), - suite_path => ltrim(regexp_substr(a_paths(i),'[.:].*$'),':')); - l_results(l_results.last) := l_path_item; - else - l_path_item := ut_path_item(schema_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 1), - object_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 3), - procedure_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 5)); - l_results(l_results.last) := l_path_item; - end if; - i := a_paths.next(i); - end loop; - - return l_results; - end; - - /* - First SQL queries for objects where procedure is null or its only wildcard. - We split that due to fact that we can use func min to combine rows. - - Second union is responsible expanding paths where the procedure filter is given - We cannot select min here as filter can cover only half of tests within - package. Even if the filter doesnt return anything we still capture a proc filter - name for error reporting later on. - - Third SQL cover scenario where a suitapath only is populated and wildcard is given - - Fourth SQL cover scenario where suitepath is populated with no filters - */ - function expand_paths(a_schema_paths ut_path_items) return ut_path_items is - l_schema_paths ut_path_items:= ut_path_items(); - begin - with - schema_paths as ( - select * from table(a_schema_paths) - ), - paths_for_object as ( - select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name, - null as procedure_name - from schema_paths sp left outer join ut_suite_cache c - on ( c.object_owner = upper(sp.schema_name) - and c.object_name like replace(upper(sp.object_name),'*','%')) - where sp.suite_path is null and sp.object_name is not null - and ( sp.procedure_name is null or sp.procedure_name = '*') - group by sp.schema_name,nvl(c.object_name,sp.object_name) - ), - paths_for_procedures as ( - select /*+ no_parallel */ path as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name, - nvl(c.name,sp.procedure_name) as procedure_name - from schema_paths sp left outer join ut_suite_cache c - on ( c.object_owner = upper(sp.schema_name) - and c.object_name like replace(upper(sp.object_name),'*','%') - and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name)) - where sp.suite_path is null and sp.object_name is not null - and (sp.procedure_name is not null and sp.procedure_name != '*') - ), - paths_for_suite_path_with_ast as ( - select /*+ no_parallel */ nvl(c.path,sp.suite_path) as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name - from schema_paths sp left outer join ut_suite_cache c on - ( c.object_owner = upper(sp.schema_name) - --and c.path like replace(sp.suite_path,'*','%')) - and regexp_like(c.path,'^'||replace(sp.suite_path,'*','[[:alnum:]$#_]*'))) - where sp.suite_path is not null and instr(sp.suite_path,'*') > 0 - ), - straigth_suite_paths as ( - select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name - from schema_paths sp - where - (sp.suite_path is not null and instr(sp.suite_path,'*') = 0) - or - (sp.suite_path is null and sp.object_name is null) - ), - all_suitepaths_together as ( - select * from paths_for_object - union all - select * from paths_for_procedures - union all - select * from paths_for_suite_path_with_ast - union all - select * from straigth_suite_paths - ) - select ut_path_item(schema_name,object_name,procedure_name,suite_path) - bulk collect into l_schema_paths - from - (select schema_name,object_name,procedure_name,suite_path, - row_number() over ( partition by schema_name,object_name,procedure_name,suite_path order by 1) as r_num - from all_suitepaths_together) - where r_num = 1 ; - return l_schema_paths; - end; - - /* - Get a suite items rows that matching our criteria like - path,object_name etc. - We need to consider also an wildcard character on our procedures and object - names. - Were the path is populated we need to make sure we dont return duplicates - as the wildcard can produce multiple results from same path and - parents and child for each can be same resulting in duplicates - */ - function get_suite_items ( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows is - l_suite_items ut_suite_cache_rows := ut_suite_cache_rows(); - begin - select obj bulk collect into l_suite_items - from ( - select /*+ cardinality(c 500) */ value(c) as obj,row_number() over ( partition by path,object_owner order by path,object_owner asc) as r_num - from ut_suite_cache c, - table(a_schema_paths) sp - where c.object_owner = upper(sp.schema_name) - and ((sp.suite_path is not null and sp.suite_path||'.' like c.path||'.%' /*all parents and self*/ - or - ( - c.path||'.' like sp.suite_path||'.%' /*all children and self*/ - and c.object_name like nvl(upper(sp.object_name),c.object_name) - and c.name like nvl(upper(sp.procedure_name),c.name) - )) - or - ( sp.suite_path is null - and c.object_name = nvl(upper(sp.object_name),c.object_name) - and c.name = nvl(upper(sp.procedure_name),c.name)))) where r_num =1; - return l_suite_items; - end; - - /* - We will sort a suites in hierarchical structure. - Sorting from bottom to top so when we consolidate - we will go in proper order. - For random seed we will add an extra sort that can be null. - The object owner is irrelevant on joing via path as we already - resolved a list of test we want to use so as long they share a suitepath - they are correct. - */ - procedure sort_and_randomize_tests( - a_suite_rows in out ut_suite_cache_rows, - a_random_seed positive := null) - is - l_suite_rows ut_suite_cache_rows; - begin - with - extract_parent_child as ( - select s.path, substr(s.path,1,instr(s.path,'.',-1,1)-1) as parent_path,s.object_owner, - case when a_random_seed is null then s.line_no end line_no, - case when a_random_seed is not null then ut_utils.hash_suite_path(s.path, a_random_seed) end random_seed - from table(a_suite_rows) s), - t1(path,parent_path,object_owner,line_no,random_seed) as ( - --Anchor member - select s.path, parent_path,s.object_owner,s.line_no,random_seed - from extract_parent_child s - where parent_path is null - union all - --Recursive member - select t2.path, t2.parent_path,t2.object_owner,t2.line_no,t2.random_seed - from t1,extract_parent_child t2 - where t2.parent_path = t1.path - and t2.object_owner = t1.object_owner) - search depth first by line_no desc,random_seed desc nulls last set order1 - select value(i) as obj - bulk collect into l_suite_rows - from t1 c - join table(a_suite_rows) i on i.object_owner = c.object_owner and i.path = c.path - order by order1 desc; - - a_suite_rows := l_suite_rows; - end; - - /* - * Public code - */ - - function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is - begin - return expand_paths(group_paths_by_schema(a_paths)); - end; - - function get_cached_suite_rows( - a_suites_filtered ut_suite_cache_rows - ) return ut_suite_cache_rows is - l_results ut_suite_cache_rows := ut_suite_cache_rows(); - begin - - open c_get_bulk_cache_suite(a_suites_filtered); - fetch c_get_bulk_cache_suite bulk collect into l_results; - close c_get_bulk_cache_suite; - - return l_results; - end; - - function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is - l_cache_parse_time timestamp; - begin - select /*+ no_parallel */ min(t.parse_time) - into l_cache_parse_time - from ut_suite_cache_schema t - where object_owner = upper(a_schema_name); - return l_cache_parse_time; - end; - - procedure save_object_cache( - a_object_owner varchar2, - a_object_name varchar2, - a_parse_time timestamp, - a_suite_items ut_suite_items - ) is - pragma autonomous_transaction; - l_cached_parse_time timestamp; - l_object_owner varchar2(250) := upper(a_object_owner); - l_object_name varchar2(250) := upper(a_object_name); - begin - if a_suite_items is null or a_suite_items.count = 0 then - - delete from ut_suite_cache t - where t.object_owner = l_object_owner - and t.object_name = l_object_name; - - delete from ut_suite_cache_package t - where t.object_owner = l_object_owner - and t.object_name = l_object_name; - - else - - select /*+ no_parallel */ min(parse_time) - into l_cached_parse_time - from ut_suite_cache_package t - where t.object_name = l_object_name - and t.object_owner = l_object_owner; - - if a_parse_time > l_cached_parse_time or l_cached_parse_time is null then - - update /*+ no_parallel */ ut_suite_cache_schema t - set t.parse_time = greatest(t.parse_time,a_parse_time) - where object_owner = l_object_owner; - - if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_suite_cache_schema - (object_owner, parse_time) - values (l_object_owner, a_parse_time); - end if; - - update /*+ no_parallel */ ut_suite_cache_package t - set t.parse_time = a_parse_time - where t.object_owner = l_object_owner - and t.object_name = l_object_name; - - if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_suite_cache_package - (object_owner, object_name, parse_time) - values (l_object_owner, l_object_name, a_parse_time ); - end if; - - delete from ut_suite_cache t - where t.object_owner = l_object_owner - and t.object_name = l_object_name; - - insert /*+ no_parallel */ into ut_suite_cache t - ( - id, self_type, path, object_owner, object_name, name, - line_no, parse_time, description, - rollback_type, disabled_flag,disabled_reason, warnings, - before_all_list, after_all_list, - before_each_list, after_each_list, - before_test_list, after_test_list, - expected_error_codes, tags, - item - ) - with suites as ( - select treat(value(x) as ut_suite) i - from table(a_suite_items) x - where x.self_type in( 'UT_SUITE', 'UT_SUITE_CONTEXT' ) ) - select /*+ no_parallel */ ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path, - upper(s.i.object_owner) as object_owner, upper(s.i.object_name) as object_name, upper(s.i.name) as name, - s.i.line_no as line_no, s.i.parse_time as parse_time, s.i.description as description, - s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag,s.i.disabled_reason as disabled_reason, s.i.warnings as warnings, - 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, s.i.tags tags, - null item - from suites s; - - insert /*+ no_parallel */ into ut_suite_cache t - ( - id, self_type, path, object_owner, object_name, name, - line_no, parse_time, description, - rollback_type, disabled_flag,disabled_reason, warnings, - before_all_list, after_all_list, - before_each_list, after_each_list, - before_test_list, after_test_list, - expected_error_codes, tags, - item - ) - with tests as ( - select treat(value(x) as ut_test) t - from table ( a_suite_items ) x - where x.self_type in ( 'UT_TEST' ) ) - select /*+ no_parallel */ ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path, - upper(s.t.object_owner) as object_owner, upper(s.t.object_name) as object_name, upper(s.t.name) as name, - s.t.line_no as line_no, s.t.parse_time as parse_time, s.t.description as description, - s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.disabled_reason as disabled_reason, s.t.warnings as warnings, - 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.tags as test_tags, - s.t.item as item - from tests s; - - end if; - end if; - commit; - end; - - procedure remove_missing_objs_from_cache(a_schema_name varchar2) is - l_objects ut_varchar2_rows; - pragma autonomous_transaction; - begin - l_objects := get_missing_cache_objects(a_schema_name); - - if l_objects is not empty then - delete /*+ no_parallel */ from ut_suite_cache i - where i.object_owner = a_schema_name - and i.object_name in ( select /*+ no_parallel */ column_value from table (l_objects) ); - - delete /*+ no_parallel */ from ut_suite_cache_package i - where i.object_owner = a_schema_name - and i.object_name in ( select /*+ no_parallel */ column_value from table (l_objects) ); - end if; - - commit; - end; - - function get_cached_suite_info( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows is - begin - return get_cached_suite_rows(get_suite_items(a_schema_paths)); - end; - - function get_suite_items_info( - a_suite_cache_items ut_suite_cache_rows - ) return ut_suite_items_info is - l_results ut_suite_items_info; - begin - select /*+ no_parallel */ ut_suite_item_info( - c.object_owner, c.object_name, c.name, - c.description, c.self_type, c.line_no, - c.path, c.disabled_flag, c.disabled_reason, c.tags - ) - bulk collect into l_results - from table(a_suite_cache_items) c; - return l_results; - end; - - function get_cached_packages( - a_schema_names ut_varchar2_rows - ) return ut_object_names is - l_results ut_object_names; - begin - select /*+ no_parallel */ ut_object_name( c.object_owner, c.object_name ) - bulk collect into l_results - from ut_suite_cache_package c - join table ( a_schema_names ) s - on c.object_owner = upper(s.column_value); - return l_results; - end; - - function suite_item_exists( - a_owner_name varchar2, - a_package_name varchar2, - a_procedure_name varchar2 - ) return boolean is - l_count integer; - begin - if a_procedure_name is not null then - select /*+ no_parallel */ count( 1 ) into l_count from dual - where exists( - select 1 - from ut_suite_cache c - where c.object_owner = a_owner_name - and c.object_name = a_package_name - and c.name = a_procedure_name - ); - elsif a_package_name is not null then - select /*+ no_parallel */ count( 1 ) into l_count from dual - where exists( - select 1 - from ut_suite_cache c - where c.object_owner = a_owner_name - and c.object_name = a_package_name - ); - else - select /*+ no_parallel */ count( 1 ) into l_count from dual - where exists( - select 1 - from ut_suite_cache c - where c.object_owner = a_owner_name - ); - end if; - - return l_count > 0; - end; - -end; -/ diff --git a/source/core/ut_suite_cache_manager.pks b/source/core/ut_suite_cache_manager.pks deleted file mode 100644 index 81b1e0136..000000000 --- a/source/core/ut_suite_cache_manager.pks +++ /dev/null @@ -1,101 +0,0 @@ -create or replace package ut_suite_cache_manager authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Responsible for storing and retrieving suite data from cache - */ - - /* - * Saves suite items for individual package in suite cache - */ - procedure save_object_cache( - a_object_owner varchar2, - a_object_name varchar2, - a_parse_time timestamp, - a_suite_items ut_suite_items - ); - - /* - * Returns time when schema was last saved in cache - */ - function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache; - - /* - * Removes packages that are no longer annotated from cache - */ - procedure remove_missing_objs_from_cache(a_schema_name varchar2); - - /* - * We will sort a suites in hierarchical structure. - * Sorting from bottom to top so when we consolidate - * we will go in proper order. - */ - procedure sort_and_randomize_tests( - a_suite_rows in out ut_suite_cache_rows, - a_random_seed positive := null); - - /* - * Retrieves suite items data from cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally for building suites at runtime. - */ - function get_cached_suite_rows( - a_suites_filtered ut_suite_cache_rows - ) return ut_suite_cache_rows; - - function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items; - - /* - * Retrieves suite item info rows from cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally for building suites info. - */ - function get_cached_suite_info( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows; - - function get_suite_items_info( - a_suite_cache_items ut_suite_cache_rows - ) return ut_suite_items_info; - - function get_suite_items ( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows; - - /* - * Retrieves list of cached suite packages. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally. - */ - function get_cached_packages( - a_schema_names ut_varchar2_rows - ) return ut_object_names; - - /* - * Returns true if given suite item exists in cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally. - */ - function suite_item_exists( - a_owner_name varchar2, - a_package_name varchar2, - a_procedure_name varchar2 - ) return boolean; - -end ut_suite_cache_manager; -/ diff --git a/source/core/ut_suite_cache_package.sql b/source/core/ut_suite_cache_package.sql deleted file mode 100644 index 7a146ff83..000000000 --- a/source/core/ut_suite_cache_package.sql +++ /dev/null @@ -1,23 +0,0 @@ -create table ut_suite_cache_package ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_name varchar2(250) not null, - parse_time timestamp not null, - constraint ut_suite_cache_package_pk primary key(object_owner, object_name), - constraint ut_suite_cache_package_fk foreign key (object_owner) references ut_suite_cache_schema(object_owner) on delete cascade -) organization index -/ - - diff --git a/source/core/ut_suite_cache_schema.sql b/source/core/ut_suite_cache_schema.sql deleted file mode 100644 index 636816e65..000000000 --- a/source/core/ut_suite_cache_schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -create table ut_suite_cache_schema ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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, - parse_time timestamp not null, - constraint ut_suite_cache_schema_pk primary key(object_owner) -) organization index -/ - diff --git a/source/core/ut_suite_cache_seq.sql b/source/core/ut_suite_cache_seq.sql deleted file mode 100644 index e1e560286..000000000 --- a/source/core/ut_suite_cache_seq.sql +++ /dev/null @@ -1,16 +0,0 @@ -create sequence ut_suite_cache_seq - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ -cache 100; - diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb deleted file mode 100644 index c418de638..000000000 --- a/source/core/ut_suite_manager.pkb +++ /dev/null @@ -1,629 +0,0 @@ -create or replace package body ut_suite_manager is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: '; - cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows()); - type tt_cached_suites is table of c_cached_suites_cursor%rowtype; - type t_cached_suites_cursor is ref cursor return c_cached_suites_cursor%rowtype; - type t_item_levels is table of ut_suite_items index by binary_integer; - ------------------ - - procedure validate_paths(a_paths in ut_varchar2_list) is - l_path varchar2(32767); - begin - if a_paths is null or a_paths.count = 0 then - raise_application_error(ut_utils.gc_path_list_is_empty, 'Path list is empty'); - else - for i in 1 .. a_paths.count loop - l_path := a_paths(i); - if l_path is null or not ( - regexp_like(l_path, '^[[:alnum:]$#_\*]+(\.[[:alnum:]$#_\*]+){0,2}$') or regexp_like(l_path, '^([[:alnum:]$#_]+)?:[[:alnum:]$#_\*]+(\.[[:alnum:]$#_\*]+)*$')) then - raise_application_error(ut_utils.gc_invalid_path_format, 'Invalid path format: ' || nvl(l_path, 'NULL')); - end if; - end loop; - end if; - end; - - function trim_and_lower_paths( a_paths ut_varchar2_list) return ut_varchar2_list is - l_paths_temp ut_varchar2_list := ut_varchar2_list(); - begin - l_paths_temp.extend(a_paths.count); - for i in 1 .. a_paths.count loop - l_paths_temp(i) := trim(lower(a_paths(i))); - end loop; - return l_paths_temp; - end; - - function resolve_schema_names(a_paths in out nocopy ut_varchar2_list) return ut_varchar2_rows is - l_schema varchar2(4000); - l_object varchar2(4000); - l_schema_names ut_varchar2_rows := ut_varchar2_rows(); - c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA'); - begin - a_paths := set( trim_and_lower_paths( a_paths) ); - - validate_paths(a_paths); - - for i in 1 .. a_paths.count loop - --if path is suite-path - if regexp_like(a_paths(i), '^([[:alnum:]$#_]+)?:') then - --get schema name / path - l_schema := regexp_substr(a_paths(i), '^([[:alnum:]$#_]+)?:',subexpression => 1); - -- transform ":path1[.path2]" to "schema:path1[.path2]" - if l_schema is not null then - l_schema := sys.dbms_assert.schema_name(upper(l_schema)); - else - a_paths(i) := c_current_schema || a_paths(i); - l_schema := c_current_schema; - end if; - else - -- get schema name / object.[procedure] name - -- When path is one of: schema or schema.package[.object] or package[.object] - -- transform it back to schema[.package[.object]] - -- Object name or procedure is allowed to have filter char - -- However this is not allowed on schema - begin - l_object := regexp_substr(a_paths(i), '^[[:alnum:]$#_\*]+'); - l_schema := sys.dbms_assert.schema_name(upper(l_object)); - exception - when sys.dbms_assert.invalid_schema_name then - if l_object like '%*%' or ut_metadata.package_exists_in_cur_schema(upper(l_object)) then - a_paths(i) := c_current_schema || '.' || a_paths(i); - l_schema := c_current_schema; - else - raise; - end if; - end; - end if; - l_schema_names.extend; - l_schema_names(l_schema_names.last) := l_schema; - end loop; - - return l_schema_names; - end; - - procedure resolve_schema_names(a_paths in out nocopy ut_varchar2_list) is - l_schema_names ut_varchar2_rows; - begin - l_schema_names := resolve_schema_names(a_paths); - end; - - function sort_by_seq_no( - a_list ut_executables - ) return ut_executables is - l_results ut_executables := ut_executables(); - begin - if a_list is not null then - l_results.extend(a_list.count); - for i in 1 .. a_list.count loop - l_results(a_list(i).seq_no) := a_list(i); - end loop; - end if; - return l_results; - end; - - procedure reverse_list_order( - a_list in out nocopy ut_suite_items - ) is - l_start_idx pls_integer; - l_end_idx pls_integer; - l_item ut_suite_item; - begin - l_start_idx := a_list.first; - l_end_idx := a_list.last; - while l_start_idx < l_end_idx loop - l_item := a_list(l_start_idx); - a_list(l_start_idx) := a_list(l_end_idx); - a_list(l_end_idx) := l_item; - l_end_idx := a_list.prior(l_end_idx); - l_start_idx := a_list.next(l_start_idx); - end loop; - end; - - function get_logical_suite( - a_rows tt_cached_suites, - a_idx pls_integer, - a_level pls_integer, - a_prev_level pls_integer, - a_items_at_level t_item_levels - ) return ut_suite_item is - l_result ut_suite_item; - begin - case a_rows( a_idx ).self_type - when 'UT_SUITE' then - l_result := - case when a_prev_level > a_level then - ut_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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), - 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), tags => a_rows(a_idx).tags - ) - else - ut_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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(), - 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), tags => a_rows(a_idx).tags - ) - end; - when 'UT_SUITE_CONTEXT' then - l_result := - case when a_prev_level > a_level then - ut_suite_context( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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), - 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), tags => a_rows(a_idx).tags - ) - else - ut_suite_context( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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(), - 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), tags => a_rows(a_idx).tags - ) - end; - when 'UT_LOGICAL_SUITE' then - l_result := - case when a_prev_level > a_level then - ut_logical_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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), tags => null - ) - else - ut_logical_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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(), tags => null - ) - end; - when 'UT_TEST' then - l_result := - ut_test( - self_type => a_rows(a_idx).self_type, - object_owner => a_rows(a_idx).object_owner, object_name => lower(a_rows(a_idx).object_name), - name => lower(a_rows(a_idx).name), description => a_rows(a_idx).description, path => a_rows(a_idx).path, - rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - 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(), - before_each_list => sort_by_seq_no(a_rows(a_idx).before_each_list), before_test_list => sort_by_seq_no(a_rows(a_idx).before_test_list), - 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, - tags => a_rows(a_idx).tags - ); - end case; - l_result.results_count.warnings_count := l_result.warnings.count; - return l_result; - end; - - procedure reconstruct_from_cache( - a_suites in out nocopy ut_suite_items, - a_suite_data_cursor sys_refcursor - ) is - c_bulk_limit constant pls_integer := 1000; - l_items_at_level t_item_levels; - l_rows tt_cached_suites; - l_level pls_integer; - l_prev_level pls_integer; - l_idx integer; - begin - loop - fetch a_suite_data_cursor bulk collect into l_rows limit c_bulk_limit; - - l_idx := l_rows.first; - while l_idx is not null loop - l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1; - if l_level > 1 then - if not l_items_at_level.exists(l_level) then - l_items_at_level(l_level) := ut_suite_items(); - end if; - l_items_at_level(l_level).extend; - pragma inline(get_logical_suite, 'YES'); - l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); - else - a_suites.extend; - pragma inline(get_logical_suite, 'YES'); - a_suites(a_suites.last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); - end if; - if l_prev_level > l_level then - l_items_at_level(l_prev_level).delete; - end if; - l_prev_level := l_level; - l_idx := l_rows.next(l_idx); - end loop; - exit when a_suite_data_cursor%NOTFOUND; - end loop; - - reverse_list_order( a_suites ); - - for i in 1 .. a_suites.count loop - a_suites( i ).set_rollback_type( a_suites( i ).get_rollback_type ); - end loop; - close a_suite_data_cursor; - end reconstruct_from_cache; - - function get_filtered_cursor( - a_unfiltered_rows in ut_suite_cache_rows, - a_skip_all_objects boolean := false - ) - return ut_suite_cache_rows is - l_result ut_suite_cache_rows := ut_suite_cache_rows(); - begin - if ut_metadata.user_has_execute_any_proc() or a_skip_all_objects then - l_result := a_unfiltered_rows; - else - select obj bulk collect into l_result - from ( - select /*+ no_parallel */ value(c) as obj from table(a_unfiltered_rows) c - where sys_context( 'userenv', 'current_user' ) = upper(c.object_owner) - union all - select /*+ no_parallel */ value(c) as obj from table(a_unfiltered_rows) c - where sys_context( 'userenv', 'current_user' ) != upper(c.object_owner) - and ( exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - ) - or c.self_type = 'UT_LOGICAL_SUITE')); - end if; - return l_result; - end; - - procedure reconcile_paths_and_suites( - a_schema_paths ut_path_items, - a_filtered_rows ut_suite_cache_rows - ) is - begin - for i in ( select /*+ no_parallel */ sp.schema_name,sp.object_name,sp.procedure_name, - sp.suite_path,sc.path - from table(a_schema_paths) sp left outer join - table(a_filtered_rows) sc on - (( upper(sp.schema_name) = upper(sc.object_owner) and upper(sp.object_name) = upper(sc.object_name) - and nvl(upper(sp.procedure_name),sc.name) = sc.name ) - or (sc.path = sp.suite_path)) - where sc.path is null) - loop - if i.suite_path is not null then - raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||i.schema_name||':'||i.suite_path|| '.'); - elsif i.procedure_name is not null then - raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||i.schema_name||'.'||i.object_name|| '.'||i.procedure_name||' does not exist'); - elsif i.object_name is not null then - raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||i.schema_name||'.'||i.object_name|| ' does not exist'); - end if; - end loop; - end; - - function get_cached_suite_data( - a_schema_paths ut_path_items, - a_random_seed positive, - a_tags varchar2 := null, - a_skip_all_objects boolean := false - ) return t_cached_suites_cursor is - l_unfiltered_rows ut_suite_cache_rows; - l_tag_filter_applied ut_suite_cache_rows; - l_filtered_rows ut_suite_cache_rows; - l_result t_cached_suites_cursor; - begin - l_unfiltered_rows := ut_suite_cache_manager.get_suite_items(a_schema_paths); - - l_tag_filter_applied := ut_suite_tag_filter.apply(l_unfiltered_rows,a_tags); - l_filtered_rows := get_filtered_cursor(ut_suite_cache_manager.get_cached_suite_rows(l_tag_filter_applied),a_skip_all_objects); - reconcile_paths_and_suites(a_schema_paths,l_filtered_rows); - - ut_suite_cache_manager.sort_and_randomize_tests(l_filtered_rows,a_random_seed); - - open l_result for - select * from table(l_filtered_rows); - return l_result; - end; - - function can_skip_all_objects_scan( - a_owner_name varchar2 - ) return boolean is - begin - return sys_context( 'userenv', 'current_user' ) = upper(a_owner_name) or ut_metadata.user_has_execute_any_proc(); - end; - - procedure build_and_cache_suites( - a_owner_name varchar2, - a_annotated_objects sys_refcursor - ) is - l_annotated_objects ut_annotated_objects; - l_suite_items ut_suite_items; - - l_bad_suitepath_obj ut_varchar2_list := ut_varchar2_list(); - 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; - - for i in 1 .. l_annotated_objects.count loop - begin - ut_suite_builder.create_suite_item_list( l_annotated_objects( i ), l_suite_items ); - exception - when ex_string_too_small then - ut_utils.append_to_list(l_bad_suitepath_obj,a_owner_name||'.'||l_annotated_objects( i ).object_name); - end; - ut_suite_cache_manager.save_object_cache( - a_owner_name, - l_annotated_objects( i ).object_name, - l_annotated_objects( i ).parse_time, - l_suite_items - ); - end loop; - exit when a_annotated_objects%notfound; - end loop; - close a_annotated_objects; - - --Check for any invalid suitepath objects - if l_bad_suitepath_obj.count > 0 then - raise_application_error( - ut_utils.gc_value_too_large, - 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 - ) is - l_annotations_cursor sys_refcursor; - l_suite_cache_time timestamp; - l_owner_name varchar2(128) := upper(a_owner_name); - begin - ut_event_manager.trigger_event('refresh_cache - start'); - l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(l_owner_name); - l_annotations_cursor := ut_annotation_manager.get_annotated_objects( - l_owner_name, 'PACKAGE', l_suite_cache_time - ); - - build_and_cache_suites(l_owner_name, l_annotations_cursor); - - if can_skip_all_objects_scan(l_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then - ut_suite_cache_manager.remove_missing_objs_from_cache( l_owner_name ); - end if; - - ut_event_manager.trigger_event('refresh_cache - end'); - end; - - procedure add_suites_for_paths( - a_schema_paths ut_path_items, - a_suites in out nocopy ut_suite_items, - a_random_seed positive, - a_tags varchar2 := null - ) is - begin - reconstruct_from_cache( - a_suites, - get_cached_suite_data( - a_schema_paths, - a_random_seed, - a_tags - ) - ); - end; - - ----------------------------------------------- - ----------------------------------------------- - ------------- Public definitions ------------- - - function build_suites_from_annotations( - a_owner_name varchar2, - a_annotated_objects sys_refcursor, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false - ) return ut_suite_items is - l_suites ut_suite_items := ut_suite_items(); - l_schema_paths ut_path_items; - begin - build_and_cache_suites(a_owner_name, a_annotated_objects); - l_schema_paths := ut_path_items(ut_path_item(a_owner_name,a_object_name,a_procedure_name,a_path)); - reconstruct_from_cache( - l_suites, - get_cached_suite_data( - l_schema_paths, - null, - null, - a_skip_all_objects - ) - ); - return l_suites; - end; - - function get_schema_ut_packages(a_schema_names ut_varchar2_rows, a_schema_name_expr varchar2) return ut_object_names is - l_schema_names ut_varchar2_rows := a_schema_names; - begin - if a_schema_name_expr is not null then - select username - bulk collect into l_schema_names - from all_users - where regexp_like(username,a_schema_name_expr,'i'); - end if; - - for i in 1 .. l_schema_names.count loop - refresh_cache(l_schema_names(i)); - end loop; - - return ut_suite_cache_manager.get_cached_packages( l_schema_names ); - end; - - function get_schema_names(a_paths ut_varchar2_list) return ut_varchar2_rows is - l_paths ut_varchar2_list; - begin - l_paths := a_paths; - return resolve_schema_names(l_paths); - end; - - 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 ut_varchar2_list, - a_suites out nocopy ut_suite_items, - a_random_seed positive := null, - a_tags varchar2 := null - ) is - l_paths ut_varchar2_list := a_paths; - l_schema_names ut_varchar2_rows; - l_schema_paths ut_path_items; - l_schema varchar2(4000); - 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 - l_schema_names := resolve_schema_names(l_paths); - - --refresh cache - l_schema := l_schema_names.first; - while l_schema is not null loop - refresh_cache(upper(l_schema_names(l_schema))); - l_schema := l_schema_names.next(l_schema); - end loop; - - l_schema_paths := ut_suite_cache_manager.get_schema_paths(l_paths); - - --We will get a single list of paths rather than loop by loop. - add_suites_for_paths( - l_schema_paths, - a_suites, - a_random_seed, - a_tags - ); - - --propagate rollback type to suite items after organizing suites into hierarchy - for i in 1 .. a_suites.count loop - a_suites(i).set_rollback_type( a_suites(i).get_rollback_type() ); - end loop; - - ut_event_manager.trigger_event('configure_execution_by_path - end'); - end configure_execution_by_path; - - function get_suites_info( - a_paths ut_varchar2_list - ) return sys_refcursor is - l_result sys_refcursor; - l_all_suite_info ut_suite_items_info; - l_schema_names ut_varchar2_rows; - l_schema_paths ut_path_items; - l_paths ut_varchar2_list := a_paths; - l_schema varchar2(4000); - l_unfiltered_rows ut_suite_cache_rows; - l_filtered_rows ut_suite_cache_rows; - - begin - l_schema_names := resolve_schema_names(l_paths); - --refresh cache - l_schema := l_schema_names.first; - while l_schema is not null loop - refresh_cache(upper(l_schema_names(l_schema))); - l_schema := l_schema_names.next(l_schema); - end loop; - l_schema_paths := ut_suite_cache_manager.get_schema_paths(l_paths); - l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_info(l_schema_paths); - l_filtered_rows := get_filtered_cursor(l_unfiltered_rows); - l_all_suite_info := ut_suite_cache_manager.get_suite_items_info(l_filtered_rows); - open l_result for - select /*+ no_parallel */ value(c) - from table(l_all_suite_info) c - order by c.object_owner, c.object_name, c.item_line_no; - - return l_result; - end; - - function suite_item_exists( - a_owner_name varchar2, - a_package_name varchar2 := null, - a_procedure_name varchar2 := null - ) return boolean is - l_count integer := 1; - l_item_exists boolean; - l_owner_name varchar2(250) := upper(a_owner_name); - l_package_name varchar2(250) := upper(a_package_name); - l_procedure_name varchar2(250) := upper(a_procedure_name); - begin - - refresh_cache(l_owner_name); - l_item_exists := ut_suite_cache_manager.suite_item_exists( l_owner_name, l_package_name, l_procedure_name ); - if not can_skip_all_objects_scan( l_owner_name ) and l_package_name is not null then - select /*+ no_parallel */ count(1) - into l_count - from dual c - where exists - ( select 1 - from all_objects a - where a.object_name = l_package_name - and a.owner = l_owner_name - and a.object_type = 'PACKAGE' - ); - end if; - - return l_count > 0 and l_item_exists; - end; - -end ut_suite_manager; -/ diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks deleted file mode 100644 index 07539139a..000000000 --- a/source/core/ut_suite_manager.pks +++ /dev/null @@ -1,106 +0,0 @@ -create or replace package ut_suite_manager authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Resposible for building hierarhy of sutes from individual suites created by suite_builder - */ - - /** - * @private - * - * Returns a list of Unit Test packages that exist in a given database schema - * IMPORTANT! The returned list is not filtered by user privileges. - * To be used internally only. - * - * @param a_schema_names list of schemas to return the information for - * @return array containing unit test schema and object names - */ - function get_schema_ut_packages(a_schema_names ut_varchar2_rows, a_schema_name_expr varchar2) return ut_object_names; - - /** - * Builds a hierarchical suites based on given suite-paths - * - * @param a_paths list of suite-paths or procedure names or package names or schema names - * @return array containing root suites-ready to be executed - * - */ - --TODO:Zerknij czy mozna wywalic - 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 - * - * @param a_paths list of suite-paths or procedure names or package names or schema names - * @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, - a_random_seed in positive := null, - a_tags in varchar2 := null - ); - - /** - * Cleanup paths by removing leading/trailing whitespace and making paths lowercase - * Get list of schema names from execution paths. - */ - function get_schema_names(a_paths ut_varchar2_list) return ut_varchar2_rows; - - - /** - * Constructs a list of suites based on the list of annotations passed - * the suites are stored in cache - */ - function build_suites_from_annotations( - a_owner_name varchar2, - a_annotated_objects sys_refcursor, - a_path varchar2 := null, - a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false - ) return ut_suite_items; - - - /** - * Returns a ref cursor containing information about unit test suites and the tests contained in them - * - * @param a_paths list of paths to be resolved and return a suites. - */ - function get_suites_info( - a_paths ut_varchar2_list - ) return sys_refcursor; - - /** - * Returns true if given suite item exists - * - * @param a_owner owner of items to retrieve - * @param a_package_name name of suite package (optional) - * @param a_procedure_name name of suite item (optional) - * @param a_item_type suite_item type (optional) - * @return ut_suite_items_info table of objects - */ - function suite_item_exists( - a_owner_name varchar2, - a_package_name varchar2 := null, - a_procedure_name varchar2 := null - ) return boolean; - - -end ut_suite_manager; -/ diff --git a/source/core/ut_suite_tag_filter.pkb b/source/core/ut_suite_tag_filter.pkb deleted file mode 100644 index 2d9436301..000000000 --- a/source/core/ut_suite_tag_filter.pkb +++ /dev/null @@ -1,295 +0,0 @@ -create or replace package body ut_suite_tag_filter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2023 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. - */ - - /** - * Constants use in postfix and infix transformations - */ - gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!'); - gc_unary_operators constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator - gc_binary_operators constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator - gc_reserved_tag_words constant ut_varchar2_list := ut_varchar2_list('none','any'); - gc_tags_column_name constant varchar2(250) := 'tags'; - gc_exception_msg constant varchar2(200) := 'Invalid tag expression'; - - type t_precedence_table is table of number index by varchar2(1); - g_precedence t_precedence_table; - - function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list is - l_tags_tokens ut_varchar2_list := ut_varchar2_list(); - begin - --Tokenize a string into operators and tags - select regexp_substr(a_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts - bulk collect into l_tags_tokens - from dual connect by regexp_substr (a_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null; - - return l_tags_tokens; - end; - - /* - To support a legact tag notation - , = OR - - = NOT - we will perform a replace of that characters into - new notation. - | = OR - & = AND - ! = NOT - */ - function replace_legacy_tag_notation(a_tags varchar2 - ) return varchar2 is - l_tags ut_varchar2_list := ut_utils.string_to_table(a_tags,','); - l_tags_include varchar2(4000); - l_tags_exclude varchar2(4000); - l_return_tag varchar2(4000); - begin - if instr(a_tags,',') > 0 or instr(a_tags,'-') > 0 then - - select '('||listagg( t.column_value,'|') - within group( order by column_value)||')' - into l_tags_include - from table(l_tags) t - where t.column_value not like '-%'; - - select '('||listagg( replace(t.column_value,'-','!'),' & ') - within group( order by column_value)||')' - into l_tags_exclude - from table(l_tags) t - where t.column_value like '-%'; - - - l_return_tag:= - case - when l_tags_include <> '()' and l_tags_exclude <> '()' - then l_tags_include || ' & ' || l_tags_exclude - when l_tags_include <> '()' - then l_tags_include - when l_tags_exclude <> '()' - then l_tags_exclude - end; - else - l_return_tag := a_tags; - end if; - return l_return_tag; - end; - - /* - https://stackoverflow.com/questions/29634992/shunting-yard-validate-expression - */ - function shunt_logical_expression(a_tags in ut_varchar2_list) return ut_varchar2_list is - l_operator_stack ut_stack := ut_stack(); - l_rnp_tokens ut_varchar2_list := ut_varchar2_list(); - l_token varchar2(32767); - l_expect_operand boolean := true; - l_expect_operator boolean := false; - l_idx pls_integer; - begin - l_idx := a_tags.first; - --Exuecute modified shunting algorithm - WHILE (l_idx is not null) loop - l_token := a_tags(l_idx); - if (l_token member of gc_operators and l_token member of gc_binary_operators) then - if not(l_expect_operator) then - raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); - end if; - while l_operator_stack.top > 0 and (g_precedence(l_operator_stack.peek) > g_precedence(l_token)) loop - l_rnp_tokens.extend; - l_rnp_tokens(l_rnp_tokens.last) := l_operator_stack.pop; - end loop; - l_operator_stack.push(a_tags(l_idx)); - l_expect_operand := true; - l_expect_operator:= false; - elsif (l_token member of gc_operators and l_token member of gc_unary_operators) then - if not(l_expect_operand) then - raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); - end if; - l_operator_stack.push(a_tags(l_idx)); - l_expect_operand := true; - l_expect_operator:= false; - elsif l_token = '(' then - if not(l_expect_operand) then - raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); - end if; - l_operator_stack.push(a_tags(l_idx)); - l_expect_operand := true; - l_expect_operator:= false; - elsif l_token = ')' then - if not(l_expect_operator) then - raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); - end if; - while l_operator_stack.peek <> '(' loop - l_rnp_tokens.extend; - l_rnp_tokens(l_rnp_tokens.last) := l_operator_stack.pop; - end loop; - l_operator_stack.pop; --Pop the open bracket and discard it - l_expect_operand := false; - l_expect_operator:= true; - else - if not(l_expect_operand) then - raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); - end if; - l_rnp_tokens.extend; - l_rnp_tokens(l_rnp_tokens.last) :=l_token; - l_expect_operator := true; - l_expect_operand := false; - end if; - - l_idx := a_tags.next(l_idx); - end loop; - - while l_operator_stack.peek is not null loop - if l_operator_stack.peek in ('(',')') then - raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); - end if; - l_rnp_tokens.extend; - l_rnp_tokens(l_rnp_tokens.last):=l_operator_stack.pop; - end loop; - - return l_rnp_tokens; - end shunt_logical_expression; - - function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2) - return varchar2 is - l_infix_stack ut_stack := ut_stack(); - l_right_side varchar2(32767); - l_left_side varchar2(32767); - l_infix_exp varchar2(32767); - l_member_token varchar2(20) := ' member of '||a_tags_column_name; - l_idx pls_integer; - begin - l_idx := a_postfix_exp.first; - while ( l_idx is not null) loop - --If the token we got is a none or any keyword - if a_postfix_exp(l_idx) member of gc_reserved_tag_words then - - l_infix_stack.push( - case - when a_postfix_exp(l_idx) = 'none' then '('||a_tags_column_name||' is empty or '||a_tags_column_name||' is null)' - else a_tags_column_name||' is not empty' - end - ); - --If token is operand but also single tag - elsif regexp_count(a_postfix_exp(l_idx),'[!()|&]') = 0 then - l_infix_stack.push(q'[']'||a_postfix_exp(l_idx)||q'[']'||l_member_token); - --If token is unary operator not - elsif a_postfix_exp(l_idx) member of gc_unary_operators then - l_right_side := l_infix_stack.pop; - l_infix_exp := a_postfix_exp(l_idx)||'('||l_right_side||')'; - l_infix_stack.push(l_infix_exp); - --If token is binary operator - elsif a_postfix_exp(l_idx) member of gc_binary_operators then - l_right_side := l_infix_stack.pop; - l_left_side := l_infix_stack.pop; - l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')'; - l_infix_stack.push(l_infix_exp); - end if; - l_idx := a_postfix_exp.next(l_idx); - end loop; - - return l_infix_stack.pop; - end conv_postfix_to_infix_sql; - - function create_where_filter(a_tags varchar2 - ) return varchar2 is - l_tags varchar2(4000); - begin - l_tags := replace(replace_legacy_tag_notation(a_tags),' '); - l_tags := conv_postfix_to_infix_sql(shunt_logical_expression(tokenize_tags_string(l_tags)),gc_tags_column_name); - l_tags := replace(l_tags, '|',' or '); - l_tags := replace(l_tags ,'&',' and '); - l_tags := replace(l_tags ,'!','not'); - return l_tags; - end; - - - /* - Having a base set of suites we will do a further filter down if there are - any tags defined. - */ - function get_tags_suites ( - a_suite_items ut_suite_cache_rows, - a_tags varchar2 - ) return ut_suite_cache_rows is - l_suite_tags ut_suite_cache_rows := ut_suite_cache_rows(); - l_sql varchar2(32000); - l_tags varchar2(4000):= create_where_filter(a_tags); - begin - l_sql := - q'[ -with - suites_mv as ( - select c.id,value(c) as obj,c.path as path,c.self_type,c.object_owner,c.tags as ]'||gc_tags_column_name||q'[ - from table(:suite_items) c - ), - suites_matching_expr as ( - select c.id,c.path as path,c.self_type,c.object_owner,c.tags - from suites_mv c - where c.self_type in ('UT_SUITE','UT_CONTEXT') - and ]'||l_tags||q'[ - ), - tests_matching_expr as ( - select c.id,c.path as path,c.self_type,c.object_owner,c.tags as ]'||gc_tags_column_name||q'[ - from suites_mv c where c.self_type in ('UT_TEST') - and ]'||l_tags||q'[ - ), - tests_with_tags_inh_from_suite as ( - select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags as ]'||gc_tags_column_name||q'[ ,c.object_owner - from suites_mv c join suites_matching_expr t - on (c.path||'.' like t.path || '.%' /*all descendants and self*/ and c.object_owner = t.object_owner) - ), - tests_with_tags_prom_to_suite as ( - select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags as ]'||gc_tags_column_name||q'[ ,c.object_owner - from suites_mv c join tests_matching_expr t - on (t.path||'.' like c.path || '.%' /*all ancestors and self*/ and c.object_owner = t.object_owner) - ) - select obj from suites_mv c, - (select id,row_number() over (partition by id order by id) r_num from - (select id - from tests_with_tags_prom_to_suite tst - where ]'||l_tags||q'[ - union all - select id from tests_with_tags_inh_from_suite tst - where ]'||l_tags||q'[ - ) - ) t where c.id = t.id and r_num = 1 ]'; - execute immediate l_sql bulk collect into l_suite_tags using a_suite_items; - return l_suite_tags; - end; - - function apply( - a_unfiltered_rows ut_suite_cache_rows, - a_tags varchar2 := null - ) return ut_suite_cache_rows is - l_suite_items ut_suite_cache_rows := a_unfiltered_rows; - begin - if length(a_tags) > 0 then - l_suite_items := get_tags_suites(l_suite_items,a_tags); - end if; - - return l_suite_items; - end; - -begin - --Define operators precedence - g_precedence('!'):=4; - g_precedence('&'):=3; - g_precedence('|'):=2; - g_precedence(')'):=1; - g_precedence('('):=1; - -end ut_suite_tag_filter; -/ diff --git a/source/core/ut_suite_tag_filter.pks b/source/core/ut_suite_tag_filter.pks deleted file mode 100644 index e824ae275..000000000 --- a/source/core/ut_suite_tag_filter.pks +++ /dev/null @@ -1,55 +0,0 @@ -create or replace package ut_suite_tag_filter authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2023 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. - */ - - /** - * Package that will filter suites by tags - * - */ - - /* - * Return table of tokens character by character - */ - function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list; - - /* - * Function that uses Dijkstra algorithm to parse mathematical and logical expression - * and return a list of elements in Reverse Polish Notation ( postfix ) - * As part of execution it will validate expression. - */ - function shunt_logical_expression(a_tags in ut_varchar2_list) return ut_varchar2_list; - - /* - * Function that converts postfix notation into infix and creating a string of sql filter - * that checking a tags collections for tags according to posted logic. - */ - function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2) - return varchar2; - - /* - * Generates a part where clause sql - */ - function create_where_filter(a_tags varchar2) - return varchar2; - - function apply( - a_unfiltered_rows ut_suite_cache_rows, - a_tags varchar2 := null - ) return ut_suite_cache_rows; - -end ut_suite_tag_filter; -/ diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb deleted file mode 100644 index 81d47221b..000000000 --- a/source/core/ut_utils.pkb +++ /dev/null @@ -1,1028 +0,0 @@ -create or replace package body ut_utils is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Constants regex used to validate XML name - */ - gc_invalid_first_xml_char constant varchar2(50) := '[^_[:alpha:]]'; - gc_invalid_xml_char constant varchar2(50) := '[^_[:alnum:]\.-]'; - gc_full_valid_xml_name constant varchar2(50) := '^([[:alpha:]])([_[:alnum:]\.-])*$'; - gc_owner_hash constant integer(11) := dbms_utility.get_hash_value( ut_owner(), 0, power(2,31)-1); - - - 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; - end; - - function test_result_to_char(a_test_result integer) return varchar2 as - l_result varchar2(20); - begin - if a_test_result = gc_success then - l_result := gc_success_char; - elsif a_test_result = gc_failure then - l_result := gc_failure_char; - elsif a_test_result = gc_error then - l_result := gc_error_char; - elsif a_test_result = gc_disabled then - l_result := gc_disabled_char; - else - l_result := 'Unknown(' || coalesce(to_char(a_test_result),'NULL') || ')'; - end if ; - return l_result; - end test_result_to_char; - - - function to_test_result(a_test boolean) return integer is - l_result integer; - begin - if a_test then - l_result := gc_success; - else - l_result := gc_failure; - end if; - return l_result; - end; - - function gen_savepoint_name return varchar2 is - begin - return 's'||gc_owner_hash||trim(to_char(ut_savepoint_seq.nextval,'00000000000000000')); - end; - - procedure debug_log(a_message varchar2) is - begin - $if $$ut_trace $then - dbms_output.put_line(a_message); - $else - null; - $end - end; - - procedure debug_log(a_message clob) is - l_varchars ut_varchar2_list; - begin - $if $$ut_trace $then - l_varchars := clob_to_table(a_message); - for i in 1..l_varchars.count loop - dbms_output.put_line(l_varchars(i)); - end loop; - $else - null; - $end - end; - - function to_string( - a_value varchar2, - a_quote_char varchar2 := '''', - a_max_output_len in number := gc_max_output_string_length - ) return varchar2 is - l_result varchar2(32767); - c_length constant integer := coalesce( lengthb( a_value ), 0 ); - c_max_input_string_length constant integer := a_max_output_len - coalesce( lengthb( a_quote_char ) * 2, 0 ); - c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len; - begin - if c_length = 0 then - l_result := gc_null_string; - elsif c_length <= c_max_input_string_length then - l_result := surround_with(a_value, a_quote_char); - else - l_result := surround_with(substr(a_value, 1, c_overflow_substr_len ), a_quote_char) || gc_more_data_string; - end if ; - return l_result; - end; - - function to_string( - a_value clob, - a_quote_char varchar2 := '''', - a_max_output_len in number := gc_max_output_string_length - ) return varchar2 is - l_result varchar2(32767); - c_length constant integer := coalesce(ut_utils.lengthb_clob(a_value), 0); - c_max_input_string_length constant integer := a_max_output_len - coalesce( lengthb( a_quote_char ) * 2, 0 ); - c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len; - begin - if a_value is null then - l_result := gc_null_string; - elsif c_length = 0 then - l_result := gc_empty_string; - elsif c_length <= c_max_input_string_length then - l_result := surround_with(a_value,a_quote_char); - else - l_result := surround_with(dbms_lob.substr(a_value, c_overflow_substr_len), a_quote_char) || gc_more_data_string; - end if; - return l_result; - end; - - function to_string( - a_value blob, - a_quote_char varchar2 := '''', - a_max_output_len in number := gc_max_output_string_length - ) return varchar2 is - l_result varchar2(32767); - c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0); - c_max_input_string_length constant integer := a_max_output_len - coalesce( lengthb( a_quote_char ) * 2, 0 ); - c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len; - begin - if a_value is null then - l_result := gc_null_string; - elsif c_length = 0 then - l_result := gc_empty_string; - elsif c_length <= c_max_input_string_length then - l_result := surround_with(rawtohex(a_value),a_quote_char); - else - l_result := to_string( rawtohex(dbms_lob.substr(a_value, c_overflow_substr_len)) ); - end if ; - return l_result; - end; - - function to_string(a_value boolean) return varchar2 is - begin - return case a_value when true then 'TRUE' when false then 'FALSE' else gc_null_string end; - end; - - function to_string(a_value number) return varchar2 is - begin - return coalesce(to_char(a_value,gc_number_format), gc_null_string); - end; - - function to_string(a_value date) return varchar2 is - begin - return coalesce(to_char(a_value,gc_date_format), gc_null_string); - end; - - function to_string(a_value timestamp_unconstrained) return varchar2 is - begin - return coalesce(to_char(a_value,gc_timestamp_format), gc_null_string); - end; - - function to_string(a_value timestamp_tz_unconstrained) return varchar2 is - begin - return coalesce(to_char(a_value,gc_timestamp_tz_format), gc_null_string); - end; - - function to_string(a_value timestamp_ltz_unconstrained) return varchar2 is - begin - return coalesce(to_char(a_value,gc_timestamp_format), gc_null_string); - end; - - function to_string(a_value yminterval_unconstrained) return varchar2 IS - begin - return coalesce(to_char(a_value), gc_null_string); - end; - - function to_string(a_value dsinterval_unconstrained) return varchar2 IS - begin - return coalesce(to_char(a_value), gc_null_string); - end; - - - function boolean_to_int(a_value boolean) return integer is - begin - return case a_value when true then 1 when false then 0 end; - end; - - function int_to_boolean(a_value integer) return boolean is - begin - return case a_value when 1 then true when 0 then false end; - end; - - function string_to_table(a_string varchar2, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list is - l_offset integer := 1; - l_delimiter_position integer; - l_skip_leading_delimiter boolean := coalesce(a_skip_leading_delimiter = 'Y',false); - l_result ut_varchar2_list := ut_varchar2_list(); - begin - if a_string is null then - return l_result; - end if; - if a_delimiter is null then - return ut_varchar2_list(a_string); - end if; - - loop - l_delimiter_position := instr(a_string, a_delimiter, l_offset); - if not (l_delimiter_position = 1 and l_skip_leading_delimiter) then - l_result.extend; - if l_delimiter_position > 0 then - l_result(l_result.last) := substr(a_string, l_offset, l_delimiter_position - l_offset); - else - l_result(l_result.last) := substr(a_string, l_offset); - end if; - end if; - exit when l_delimiter_position = 0; - l_offset := l_delimiter_position + 1; - end loop; - return l_result; - end; - - function string_table_to_table(a_list ut_varchar2_list, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list is - l_result ut_varchar2_list; - begin - if a_delimiter is null then - l_result := a_list; - elsif a_list is not empty then - for i in 1 .. a_list.count loop - ut_utils.append_to_list(l_result, ut_utils.string_to_table(a_list(i), a_delimiter, a_skip_leading_delimiter) ); - end loop; - end if; - return l_result; - end; - - function clob_to_table(a_clob clob, a_max_amount integer := 8191, a_delimiter varchar2:= chr(10)) return ut_varchar2_list is - l_offset integer := 1; - l_length integer := dbms_lob.getlength(a_clob); - l_amount integer; - l_buffer varchar2(32767); - l_last_line varchar2(32767); - l_string_results ut_varchar2_list; - l_results ut_varchar2_list := ut_varchar2_list(); - l_has_last_line boolean; - l_skip_leading_delimiter varchar2(1) := 'N'; - 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); - 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 ); - for i in 1 .. l_string_results.count loop - --if a split of lines was not done or not at the last line - if l_string_results.count = 1 or i < l_string_results.count then - l_results.extend; - l_results(l_results.last) := l_string_results(i); - end if; - end loop; - - --check if we need to append the last line to the next element - if l_string_results.count = 1 then - l_has_last_line := false; - l_last_line := null; - elsif l_string_results.count > 1 then - l_has_last_line := true; - l_last_line := l_string_results(l_string_results.count); - end if; - - l_skip_leading_delimiter := 'Y'; - end loop; - if l_has_last_line then - l_results.extend; - l_results(l_results.last) := l_last_line; - end if; - return l_results; - end; - - function table_to_clob(a_text_table ut_varchar2_list, 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_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); - begin - for i in 1 .. l_table_rows loop - if i < l_table_rows then - append_to_clob(l_result, a_integer_table(i)||a_delimiter); - else - append_to_clob(l_result, a_integer_table(i)); - end if; - end loop; - return l_result; - end; - - function time_diff(a_start_time timestamp with time zone, a_end_time timestamp with time zone) return number is - begin - return - extract(day from(a_end_time - a_start_time)) * 24 * 60 * 60 + - extract(hour from(a_end_time - a_start_time)) * 60 * 60 + - extract(minute from(a_end_time - a_start_time)) * 60 + - extract(second from(a_end_time - a_start_time)); - end; - - function indent_lines(a_text varchar2, a_indent_size integer := 4, a_include_first_line boolean := false) return varchar2 is - begin - if a_include_first_line then - return rtrim(lpad( ' ', a_indent_size ) || replace( a_text, chr(10), chr(10) || lpad( ' ', a_indent_size ) )); - else - return rtrim(replace( a_text, chr(10), chr(10) || lpad( ' ', a_indent_size ) )); - end if; - end; - - function get_utplsql_objects_list return ut_object_names is - l_result ut_object_names; - begin - select /*+ no_parallel */ distinct ut_object_name(sys_context('userenv','current_user'), o.object_name) - bulk collect into l_result - from user_objects o - where o.object_name = 'UT' or object_name like 'UT\_%' escape '\' - and o.object_type <> 'SYNONYM'; - return l_result; - end; - - procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_item varchar2) is - begin - if a_item is not null then - if a_list is null then - a_list := ut_varchar2_list(); - end if; - a_list.extend; - a_list(a_list.last) := a_item; - end if; - end append_to_list; - - procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_items ut_varchar2_rows) is - begin - if a_items is not null then - if a_list is null then - a_list := ut_varchar2_rows(); - end if; - for i in 1 .. a_items.count loop - a_list.extend; - a_list(a_list.last) := a_items(i); - end loop; - end if; - end; - - procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_items ut_varchar2_list) is - begin - if a_items is not null then - if a_list is null then - a_list := ut_varchar2_list(); - end if; - for i in 1 .. a_items.count loop - a_list.extend; - a_list(a_list.last) := a_items(i); - end loop; - end if; - end; - - procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item clob) is - begin - append_to_list( - a_list, - convert_collection( - clob_to_table( a_item, ut_utils.gc_max_storage_varchar2_len ) - ) - ); - end; - - procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item varchar2) is - begin - if a_item is not null then - if a_list is null then - a_list := ut_varchar2_rows(); - end if; - if lengthb(a_item) > gc_max_storage_varchar2_len then - append_to_list( - a_list, - ut_utils.convert_collection( - ut_utils.clob_to_table( a_item, gc_max_storage_varchar2_len ) - ) - ); - else - a_list.extend; - a_list(a_list.last) := a_item; - end if; - end if; - end append_to_list; - - procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, a_delimiter varchar2:= chr(10)) is - begin - if a_clob_table is not null and cardinality(a_clob_table) > 0 then - if a_src_clob is null then - dbms_lob.createtemporary(a_src_clob, true); - end if; - for i in 1 .. a_clob_table.count loop - dbms_lob.append(a_src_clob,a_clob_table(i)); - if i < a_clob_table.count then - append_to_clob(a_src_clob,a_delimiter); - end if; - end loop; - end if; - end; - - procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data clob) is - begin - if a_new_data is not null and dbms_lob.getlength(a_new_data) > 0 then - if a_src_clob is null then - dbms_lob.createtemporary(a_src_clob, true); - end if; - dbms_lob.append(a_src_clob, a_new_data); - end if; - end; - - procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data varchar2) is - begin - if a_new_data is not null then - if a_src_clob is null then - dbms_lob.createtemporary(a_src_clob, true); - end if; - dbms_lob.writeappend(a_src_clob, dbms_lob.getlength(a_new_data), a_new_data); - end if; - end; - - function convert_collection(a_collection ut_varchar2_list) return ut_varchar2_rows is - l_result ut_varchar2_rows; - begin - if a_collection is not null then - l_result := ut_varchar2_rows(); - for i in 1 .. a_collection.count loop - l_result.extend(); - l_result(i) := substrb(a_collection(i),1,gc_max_storage_varchar2_len); - end loop; - end if; - return l_result; - end; - - function to_xpath(a_list varchar2, a_ancestors varchar2 := '/*/') return varchar2 is - l_xpath varchar2(32767) := a_list; - begin - l_xpath := to_xpath( clob_to_table(a_clob=>a_list, a_delimiter=>','), a_ancestors); - return l_xpath; - end; - - function to_xpath(a_list ut_varchar2_list, a_ancestors varchar2 := '/*/') return varchar2 is - l_xpath varchar2(32767); - l_item varchar2(32767); - l_iter integer; - begin - if a_list is not null then - l_iter := a_list.first; - while l_iter is not null loop - l_item := trim(a_list(l_iter)); - if l_item is not null then - if l_item like '%,%' then - l_xpath := l_xpath || to_xpath( l_item, a_ancestors ) || '|'; - elsif l_item like '/%' then - l_xpath := l_xpath || l_item || '|'; - else - l_xpath := l_xpath || a_ancestors || l_item || '|'; - end if; - end if; - l_iter := a_list.next(l_iter); - end loop; - l_xpath := rtrim(l_xpath,',|'); - end if; - return l_xpath; - end; - - function to_version(a_version_no varchar2) return t_version is - l_result t_version; - c_version_part_regex constant varchar2(20) := '[0-9]+'; - begin - - if regexp_like(a_version_no,'v?([0-9]+(\.|$)){1,4}') then - l_result.major := regexp_substr(a_version_no, c_version_part_regex, 1, 1); - l_result.minor := regexp_substr(a_version_no, c_version_part_regex, 1, 2); - l_result.bugfix := regexp_substr(a_version_no, c_version_part_regex, 1, 3); - l_result.build := regexp_substr(a_version_no, c_version_part_regex, 1, 4); - else - raise_application_error(gc_invalid_version_no, 'Version string "'||a_version_no||'" is not a valid version'); - end if; - return l_result; - end; - - procedure save_dbms_output_to_cache is - l_status number; - l_line varchar2(32767); - l_offset integer := 0; - l_lines ut_varchar2_rows := ut_varchar2_rows(); - c_lines_limit constant integer := 100; - pragma autonomous_transaction; - - procedure flush_lines(a_lines ut_varchar2_rows, a_offset integer) is - begin - if a_lines is not empty then - insert /*+ no_parallel */ into ut_dbms_output_cache (seq_no,text) - select /*+ no_parallel */ rownum+a_offset, column_value - from table(a_lines); - end if; - end; - begin - loop - dbms_output.get_line(line => l_line, status => l_status); - exit when l_status = 1; - l_lines := l_lines multiset union all ut_utils.convert_collection(ut_utils.clob_to_table(l_line||chr(7),4000)); - if l_lines.count > c_lines_limit then - flush_lines(l_lines, l_offset); - l_offset := l_offset + l_lines.count; - l_lines.delete; - end if; - end loop; - flush_lines(l_lines, l_offset); - commit; - end; - - procedure read_cache_to_dbms_output is - l_lines_data sys_refcursor; - l_lines ut_varchar2_rows; - c_lines_limit constant integer := 10000; - pragma autonomous_transaction; - begin - open l_lines_data for select /*+ no_parallel */ text from ut_dbms_output_cache order by seq_no; - loop - fetch l_lines_data bulk collect into l_lines limit c_lines_limit; - for i in 1 .. l_lines.count loop - if substr(l_lines(i),-1) = chr(7) then - dbms_output.put_line(rtrim(l_lines(i),chr(7))); - else - dbms_output.put(l_lines(i)); - end if; - end loop; - exit when l_lines_data%notfound; - end loop; - close l_lines_data; - execute immediate 'truncate table ut_dbms_output_cache'; - commit; - end; - - function ut_owner return varchar2 is - begin - return qualified_sql_name( sys_context('userenv','current_schema') ); - end; - - function scale_cardinality(a_cardinality natural) return natural is - begin - 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 - begin - return 'The syntax: "'||a_old_syntax||'" is deprecated.' ||chr(10)|| - 'Please use the new syntax: "'||a_new_syntax||'".' ||chr(10)|| - 'The deprecated syntax will not be supported in future releases.'; - end; - - function to_xml_number_format(a_value number) return varchar2 is - begin - return to_char(a_value, gc_number_format, 'NLS_NUMERIC_CHARACTERS=''. '''); - end; - - function get_xml_header(a_encoding varchar2) return varchar2 is - begin - return - ''; - end; - - function trim_list_elements(a_list ut_varchar2_list, a_regexp_to_trim varchar2 default '[:space:]') return ut_varchar2_list is - l_trimmed_list ut_varchar2_list; - l_index integer; - begin - if a_list is not null then - l_trimmed_list := ut_varchar2_list(); - l_index := a_list.first; - - while (l_index is not null) loop - l_trimmed_list.extend; - l_trimmed_list(l_trimmed_list.count) := regexp_replace(a_list(l_index), '(^['||a_regexp_to_trim||']*)|(['||a_regexp_to_trim||']*$)'); - l_index := a_list.next(l_index); - end loop; - end if; - - return l_trimmed_list; - end; - - function filter_list(a_list in ut_varchar2_list, a_regexp_filter in varchar2) return ut_varchar2_list is - l_filtered_list ut_varchar2_list; - l_index integer; - begin - 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; - l_filtered_list(l_filtered_list.count) := a_list(l_index); - end if; - l_index := a_list.next(l_index); - end loop; - end if; - - return l_filtered_list; - end; - - function xmlgen_escaped_string(a_string in varchar2) return varchar2 is - l_result varchar2(4000) := a_string; - l_sql varchar2(32767) := q'!select /*+ no_parallel */ q'[!'||a_string||q'!]' as "!'||a_string||'" from dual'; - begin - if a_string is not null then - select /*+ no_parallel */ extract(dbms_xmlgen.getxmltype(l_sql),'/*/*/*').getRootElement() - into l_result - from dual; - end if; - return l_result; - end; - - function replace_multiline_comments(a_source clob) return clob is - l_result clob; - l_ml_comment_start binary_integer := 1; - l_comment_start binary_integer := 1; - l_text_start binary_integer := 1; - l_escaped_text_start binary_integer := 1; - l_escaped_text_end_char varchar2(1 char); - l_end binary_integer := 1; - l_ml_comment clob; - l_newlines_count binary_integer; - l_offset binary_integer := 1; - l_length binary_integer := coalesce(dbms_lob.getlength(a_source), 0); - begin - l_ml_comment_start := instr(a_source,'/*'); - l_comment_start := instr(a_source,'--'); - l_text_start := instr(a_source,''''); - l_escaped_text_start := instr(a_source,q'[q']'); - while l_offset > 0 and l_ml_comment_start > 0 loop - - if l_ml_comment_start > 0 and (l_ml_comment_start < l_comment_start or l_comment_start = 0) - and (l_ml_comment_start < l_text_start or l_text_start = 0)and (l_ml_comment_start < l_escaped_text_start or l_escaped_text_start = 0) - then - l_end := instr(a_source,'*/',l_ml_comment_start+2); - append_to_clob(l_result, dbms_lob.substr(a_source, l_ml_comment_start-l_offset, l_offset)); - if l_end > 0 then - l_ml_comment := substr(a_source, l_ml_comment_start, l_end-l_ml_comment_start); - l_newlines_count := length( l_ml_comment ) - length( translate( l_ml_comment, 'a'||chr(10), 'a') ); - if l_newlines_count > 0 then - append_to_clob(l_result, lpad( chr(10), l_newlines_count, chr(10) ) ); - end if; - l_end := l_end + 2; - end if; - else - - if l_comment_start > 0 and (l_comment_start < l_ml_comment_start or l_ml_comment_start = 0) - and (l_comment_start < l_text_start or l_text_start = 0) and (l_comment_start < l_escaped_text_start or l_escaped_text_start = 0) - then - l_end := instr(a_source,chr(10),l_comment_start+2); - if l_end > 0 then - l_end := l_end + 1; - end if; - elsif l_text_start > 0 and (l_text_start < l_ml_comment_start or l_ml_comment_start = 0) - and (l_text_start < l_comment_start or l_comment_start = 0) and (l_text_start < l_escaped_text_start or l_escaped_text_start = 0) - then - l_end := instr(a_source,q'[']',l_text_start+1); - - --skip double quotes while searching for end of quoted text - while l_end > 0 and l_end = instr(a_source,q'['']',l_text_start+1) loop - l_end := instr(a_source,q'[']',l_end+1); - end loop; - if l_end > 0 then - l_end := l_end + 1; - end if; - - elsif l_escaped_text_start > 0 and (l_escaped_text_start < l_ml_comment_start or l_ml_comment_start = 0) - and (l_escaped_text_start < l_comment_start or l_comment_start = 0) and (l_escaped_text_start < l_text_start or l_text_start = 0) - then - --translate char "[" from the start of quoted text "q'[someting]'" into "]" - l_escaped_text_end_char := translate( substr(a_source, l_escaped_text_start + 2, 1), '[{(<', ']})>'); - l_end := instr(a_source,l_escaped_text_end_char||'''',l_escaped_text_start + 3 ); - if l_end > 0 then - l_end := l_end + 2; - end if; - end if; - - if l_end = 0 then - append_to_clob(l_result, substr(a_source, l_offset, l_length-l_offset)); - else - append_to_clob(l_result, substr(a_source, l_offset, l_end-l_offset)); - end if; - end if; - l_offset := l_end; - if l_offset >= l_ml_comment_start then - l_ml_comment_start := instr(a_source,'/*',l_offset); - end if; - if l_offset >= l_comment_start then - l_comment_start := instr(a_source,'--',l_offset); - end if; - if l_offset >= l_text_start then - l_text_start := instr(a_source,'''',l_offset); - end if; - if l_offset >= l_escaped_text_start then - l_escaped_text_start := instr(a_source,q'[q']',l_offset); - end if; - end loop; - append_to_clob(l_result, substr(a_source, l_end)); - return l_result; - end; - - function get_child_reporters(a_for_reporters ut_reporters_info := null) return ut_reporters_info is - l_for_reporters ut_reporters_info := a_for_reporters; - l_results ut_reporters_info; - begin - if l_for_reporters is null then - l_for_reporters := ut_reporters_info(ut_reporter_info('UT_REPORTER_BASE','N','N','N')); - end if; - - select /*+ no_parallel cardinality(f 10) */ - ut_reporter_info( - object_name => t.type_name, - is_output_reporter => - case - when f.is_output_reporter = 'Y' or t.type_name = 'UT_OUTPUT_REPORTER_BASE' - then 'Y' else 'N' - end, - is_instantiable => case when t.instantiable = 'YES' then 'Y' else 'N' end, - is_final => case when t.final = 'YES' then 'Y' else 'N' end - ) - bulk collect into l_results - from user_types t - join (select * from table(l_for_reporters) where is_final = 'N' ) f - on f.object_name = supertype_name; - - 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_ - * See the section of Oracle documentation called: Escape of Characters in Generated XML Data - * 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 - */ - 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 /*+ no_parallel */ 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 ); - l_result := to_clob(gc_cdata_start_tag) - || replace( a_clob, gc_cdata_end_tag, gc_cdata_end_tag_wrap ) - || to_clob(gc_cdata_end_tag); - 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; - - function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is - begin - --We cannot run hash on null - return case when a_data is null then null else dbms_crypto.hash(a_data, a_hash_type) end; - end; - - function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is - begin - --We cannot run hash on null - return case when a_data is null then null else dbms_crypto.hash(a_data, a_hash_type) end; - 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 || - ut_utils.get_hash( to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ) ); - 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; - - function qualified_sql_name(a_name varchar2) return varchar2 is - begin - return - case - when a_name is not null - then sys.dbms_assert.qualified_sql_name(a_name) - end; - end; - - function interval_to_text(a_interval dsinterval_unconstrained) return varchar2 is - l_day varchar2(100) := extract(day from a_interval); - l_hour varchar2(100) := extract(hour from a_interval); - l_minute varchar2(100) := extract(minute from a_interval); - l_second varchar2(100) := extract(second from a_interval); - l_result varchar2(32767); - begin - l_result := case - when l_day = 1 then l_day ||' day' - when l_day > 1 then l_day ||' days' - end || - case - when l_hour = 1 then ' '|| l_hour ||' hour' - when l_hour > 1 then ' '|| l_hour ||' hours' - end || - case - when l_minute = 1 then ' '||l_minute ||' minute' - when l_minute > 1 then ' '||l_minute ||' minutes' - end || - case - when l_second > 1 then ' '||l_second ||' seconds' - when l_second = 1 then ' '||l_second ||' second' - when l_second > 0 then ' '||l_second ||' seconds' - end; - l_result := - case - when a_interval is null then 'NULL' - when l_result is null then '0 seconds' - else ltrim(l_result,' ') - end; - - return l_result; - end; - - function interval_to_text(a_interval yminterval_unconstrained) return varchar2 is - l_year varchar2(4) := extract(year from a_interval); - l_month varchar2(20) := extract(month from a_interval); - l_result varchar2(32767); - begin - l_result := case - when l_year = 1 then l_year ||' year' - when l_year > 1 then l_year ||' years' - end || - case - when l_month > 1 then ' '||l_month ||' months' - when l_month = 1 then ' '||l_month ||' month' - end; - l_result := - case - when a_interval is null then 'NULL' - when l_result is null then '0 months' - else ltrim(l_result,' ') - end; - - return l_result; - end; - - - /* - * Inspired by - * https://stackoverflow.com/a/48782891 - */ - function lengthb_clob( a_clob clob) return integer is - l_blob blob; - l_desc_offset PLS_INTEGER := 1; - l_src_offset PLS_INTEGER := 1; - l_lang PLS_INTEGER := 0; - l_warning PLS_INTEGER := 0; - l_result integer; - begin - if a_clob = empty_clob() then - l_result := 0; - elsif a_clob is not null then - dbms_lob.createtemporary(l_blob,true); - dbms_lob.converttoblob - ( l_blob - , a_clob - , dbms_lob.getlength(a_clob) - , l_desc_offset - , l_src_offset - , dbms_lob.default_csid - , l_lang - , l_warning - ); - l_result := length(l_blob); - dbms_lob.freetemporary(l_blob); - end if; - return l_result; - end; - -end ut_utils; -/ diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks deleted file mode 100644 index 9615c7b4d..000000000 --- a/source/core/ut_utils.pks +++ /dev/null @@ -1,486 +0,0 @@ -create or replace package ut_utils authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Common utilities and constants used throughout utPLSQL framework - * - */ - - gc_version constant varchar2(50) := 'v3.1.14.4342-develop'; - - subtype t_executable_type is varchar2(30); - gc_before_all constant t_executable_type := 'beforeall'; - gc_before_each constant t_executable_type := 'beforeeach'; - gc_before_test constant t_executable_type := 'beforetest'; - gc_test_execute constant t_executable_type := 'test'; - gc_after_test constant t_executable_type := 'aftertest'; - gc_after_each constant t_executable_type := 'aftereach'; - gc_after_all constant t_executable_type := 'afterall'; - - /* Constants: Test Results */ - subtype t_test_result is binary_integer range 0 .. 3; - gc_disabled constant t_test_result := 0; -- test/suite was disabled - gc_success constant t_test_result := 1; -- test passed - gc_failure constant t_test_result := 2; -- one or more expectations failed - gc_error constant t_test_result := 3; -- exception was raised - - gc_disabled_char constant varchar2(8) := 'Disabled'; -- test/suite was disabled - gc_success_char constant varchar2(7) := 'Success'; -- test passed - 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 - */ - subtype t_rollback_type is binary_integer range 0 .. 1; - gc_rollback_auto constant t_rollback_type := 0; -- rollback after each test and suite - gc_rollback_manual constant t_rollback_type := 1; -- leave transaction control manual - gc_rollback_default constant t_rollback_type := gc_rollback_auto; - - ex_unsupported_rollback_type exception; - gc_unsupported_rollback_type constant pls_integer := -20200; - pragma exception_init(ex_unsupported_rollback_type, -20200); - - ex_path_list_is_empty exception; - gc_path_list_is_empty constant pls_integer := -20201; - pragma exception_init(ex_path_list_is_empty, -20201); - - ex_invalid_path_format exception; - gc_invalid_path_format constant pls_integer := -20202; - pragma exception_init(ex_invalid_path_format, -20202); - - ex_suite_package_not_found exception; - gc_suite_package_not_found constant pls_integer := -20204; - pragma exception_init(ex_suite_package_not_found, -20204); - - -- Reporting event time not supported - ex_invalid_rep_event_time exception; - gc_invalid_rep_event_time constant pls_integer := -20210; - pragma exception_init(ex_invalid_rep_event_time, -20210); - - -- Reporting event name not supported - ex_invalid_rep_event_name exception; - gc_invalid_rep_event_name constant pls_integer := -20211; - pragma exception_init(ex_invalid_rep_event_name, -20211); - - -- Any of tests failed - ex_some_tests_failed exception; - gc_some_tests_failed constant pls_integer := -20213; - pragma exception_init(ex_some_tests_failed, -20213); - - -- Version number provided is not in valid format - ex_invalid_version_no exception; - gc_invalid_version_no constant pls_integer := -20214; - pragma exception_init(ex_invalid_version_no, -20214); - - -- Version number provided is not in valid format - ex_out_buffer_timeout exception; - gc_out_buffer_timeout constant pls_integer := -20215; - pragma exception_init(ex_out_buffer_timeout, -20215); - - ex_invalid_package exception; - gc_invalid_package constant pls_integer := -6550; - pragma exception_init(ex_invalid_package, -6550); - - ex_failure_for_all exception; - gc_failure_for_all constant pls_integer := -24381; - pragma exception_init (ex_failure_for_all, -24381); - - ex_dml_for_all exception; - gc_dml_for_all constant pls_integer := -20216; - pragma exception_init (ex_dml_for_all, -20216); - - ex_value_too_large exception; - 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); - - ex_invalid_tag_expression exception; - gc_invalid_tag_expression constant pls_integer := -20219; - pragma exception_init (ex_invalid_tag_expression, -20219); - - gc_max_storage_varchar2_len constant integer := 4000; - gc_max_output_string_length constant integer := 4000; - gc_more_data_string constant varchar2(5) := '[...]'; - gc_more_data_string_len constant integer := length( gc_more_data_string ); - gc_number_format constant varchar2(100) := 'TM9'; - gc_date_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ss'; - gc_timestamp_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ssxff'; - gc_timestamp_tz_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ssxff tzh:tzm'; - gc_null_string constant varchar2(4) := 'NULL'; - gc_empty_string constant varchar2(5) := 'EMPTY'; - - gc_bc_fetch_limit constant integer := 1000; - gc_diff_max_rows constant integer := 20; - - gc_max_objects_fetch_limit constant integer := 1000000; - - /** - * Regexp to validate tag - */ - gc_word_no_space constant varchar2(50) := '^(\w|\S)+$'; - - type t_version is record( - major natural, - minor natural, - bugfix natural, - build natural - ); - - type t_clob_tab is table of clob; - - /** - * Converts test results into strings - * - * @param a_test_result numeric representation of test result - * - * @return a string representation of a test_result. - */ - function test_result_to_char(a_test_result integer) return varchar2; - - function to_test_result(a_test boolean) return integer; - - /** - * Generates a unique name for a savepoint - * Uses sys_guid, as timestamp gives only miliseconds on Windows and is not unique - * Issue: #506 for details on the implementation approach - */ - function gen_savepoint_name return varchar2; - - procedure debug_log(a_message varchar2); - - procedure debug_log(a_message clob); - - function to_string( - a_value varchar2, - a_quote_char varchar2 := '''', - a_max_output_len in number := gc_max_output_string_length - ) return varchar2; - - function to_string( - a_value clob, - a_quote_char varchar2 := '''', - a_max_output_len in number := gc_max_output_string_length - ) return varchar2; - - function to_string( - a_value blob, - a_quote_char varchar2 := '''', - a_max_output_len in number := gc_max_output_string_length - ) return varchar2; - - function to_string(a_value boolean) return varchar2; - - function to_string(a_value number) return varchar2; - - function to_string(a_value date) return varchar2; - - function to_string(a_value timestamp_unconstrained) return varchar2; - - function to_string(a_value timestamp_tz_unconstrained) return varchar2; - - function to_string(a_value timestamp_ltz_unconstrained) return varchar2; - - function to_string(a_value yminterval_unconstrained) return varchar2; - - function to_string(a_value dsinterval_unconstrained) return varchar2; - - function boolean_to_int(a_value boolean) return integer; - - function int_to_boolean(a_value integer) return boolean; - - /** - * - * Splits a given string into table of string by delimiter. - * The delimiter gets removed. - * If null a_string passed, empty table is returned. - * If null a_delimiter passed, a_string is returned as element of result table. - * If null a_skip_leading_delimiter, it defaults to 'N' - * If no occurrence of a_delimiter found in a_text then text is returned as a single row of the table. - * If no text between delimiters found then an empty row is returned, example: - * string_to_table( 'a,,b', ',' ) gives table ut_varchar2_list( 'a', null, 'b' ); - * - * @param a_string the text to be split. - * @param a_delimiter the delimiter character or string - * @param a_skip_leading_delimiter determines if the leading delimiter should be ignored, used by clob_to_table - * - * @return table of varchar2 values - */ - function string_to_table(a_string varchar2, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list; - - /** - * - * Splits each string in table of string into a table of string using specified delimiter. - * The delimiter gets removed. - * If null a_delimiter passed, a_list is returned as-is. - * If null a_list passed, empty table is returned. - * If null a_skip_leading_delimiter, it defaults to 'N' - * If no occurrence of a_delimiter found in a_text then text is returned as a single row of the table. - * If no text between delimiters found then an empty row is returned, example: - * string_table_to_table( a_list => ut_varchar2_list('x','y',null,'a,,b'), a_delimiter=>',' ) gives table ut_varchar2_list( 'x', 'y', null, 'a', null, 'b' ); - * - * @param a_list the table of texts to be split. - * @param a_delimiter the delimiter character or string - * @param a_skip_leading_delimiter determines if the leading delimiter should be ignored, used by clob_to_table - * - * @return table of varchar2 values - */ - function string_table_to_table(a_list ut_varchar2_list, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list; - - /** - * Splits a given string into table of string by delimiter. - * Default value of a_max_amount is 8191 because of code can contains multibyte character. - * The delimiter gets removed. - * If null a_clob passed, empty table is returned. - * If null a_delimiter passed, a_string is returned as element of result table. - * If null a_skip_leading_delimiter, it defaults to 'N' - * If no occurrence of a_delimiter found in a_text then text is returned as a single row of the table. - * If split text is longer than a_max_amount it gets split into pieces of a_max_amount. - * If no text between delimiters found then an empty row is returned, example: - * clob_to_table( 'a,,b', ',' ) gives table ut_varchar2_list( 'a', null, 'b' ); - * - * @param a_clob the text to be split. - * @param a_delimiter the delimiter character or string (default chr(10) ) - * @param a_max_amount the maximum length of returned string (default 8191) - * @return table of varchar2 values - */ - 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; - - /** - * Returns time difference in seconds (with miliseconds) between given timestamps - */ - function time_diff(a_start_time timestamp with time zone, a_end_time timestamp with time zone) return number; - - /** - * Returns a text indented with spaces except the first line. - */ - function indent_lines(a_text varchar2, a_indent_size integer := 4, a_include_first_line boolean := false) return varchar2; - - - /** - * Returns a list of object that are part of utPLSQL framework - */ - function get_utplsql_objects_list return ut_object_names; - - /** - * Append a item to the end of ut_varchar2_list - */ - procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_item varchar2); - - /** - * Append a item to the end of ut_varchar2_rows - */ - procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item varchar2); - - /** - * Append a item to the end of ut_varchar2_rows - */ - procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item clob); - - /** - * Append a list of items to the end of ut_varchar2_rows - */ - procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_items ut_varchar2_rows); - - /** - * Append a list of items to the end of ut_varchar2_list - */ - procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_items ut_varchar2_list); - - procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, a_delimiter varchar2 := chr(10)); - - procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data clob); - - procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data varchar2); - - function convert_collection(a_collection ut_varchar2_list) return ut_varchar2_rows; - - function to_xpath(a_list varchar2, a_ancestors varchar2 := '/*/') return varchar2; - - function to_xpath(a_list ut_varchar2_list, a_ancestors varchar2 := '/*/') return varchar2; - - /** - * Converts version string into version record - * - * @param a_version_no string representation of version in format vX.X.X.X where X is a positive integer - * @return t_version record with up to four positive numbers containing version - * @throws 20214 if passed version string is not matching version pattern - */ - function to_version(a_version_no varchar2) return t_version; - - - /** - * Saves data from dbms_output buffer into a global temporary table (cache) - * used to store dbms_output buffer captured before the run - * - */ - procedure save_dbms_output_to_cache; - - /** - * Reads data from global temporary table (cache) abd puts it back into dbms_output - * used to recover dbms_output buffer data after a run is complete - * - */ - procedure read_cache_to_dbms_output; - - - /** - * Function is used to reference to utPLSQL owned objects in dynamic sql statements executed from packages with invoker rights - * - * @return the name of the utPSQL schema owner - */ - function ut_owner return varchar2; - - - /** - * Used in dynamic sql select statements to maintain balance between - * number of hard-parses and optimiser accurancy for cardinality of collections - * - * - * @return 3, for inputs of: 1-9; 33 for input of 10 - 99; 333 for (100 - 999) - */ - function scale_cardinality(a_cardinality natural) return natural; - - function build_depreciation_warning(a_old_syntax varchar2, a_new_syntax varchar2) return varchar2; - - /** - * Returns number as string. The value is represented as decimal according to XML standard: - * https://www.w3.org/TR/xmlschema-2/#decimal - */ - function to_xml_number_format(a_value number) return varchar2; - - - /** - * Returns xml header. If a_encoding is not null, header will include encoding attribute with provided value - */ - function get_xml_header(a_encoding varchar2) return varchar2; - - - /** - * Takes a collection of type ut_varchar2_list and it trims the characters passed as arguments for every element - */ - function trim_list_elements(a_list IN ut_varchar2_list, a_regexp_to_trim in varchar2 default '[:space:]') return ut_varchar2_list; - - /** - * Takes a collection of type ut_varchar2_list and it only returns the elements which meets the regular expression - */ - function filter_list(a_list IN ut_varchar2_list, a_regexp_filter in varchar2) return ut_varchar2_list; - - -- Generates XMLGEN escaped string - function xmlgen_escaped_string(a_string in varchar2) return varchar2; - - /** - * Replaces multi-line comments in given source-code with empty lines - */ - function replace_multiline_comments(a_source clob) return clob; - - /** - * 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; - - - subtype t_hash is raw(128); - - /* - * Wrapper function for calling dbms_crypto.hash - */ - function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; - - /* - * Wrapper function for calling dbms_crypto.hash - */ - function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; - - /* - * 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; - - /* - * Verifies that the input string is a qualified SQL name using sys.dbms_assert.qualified_sql_name - * If null value passed returns null - */ - function qualified_sql_name(a_name varchar2) return varchar2; - - /* - * Return value of interval in plain english - */ - function interval_to_text(a_interval dsinterval_unconstrained) return varchar2; - - /* - * Return value of interval in plain english - */ - function interval_to_text(a_interval yminterval_unconstrained) return varchar2; - - /* - * Return length of CLOB in bytes. Null for NULL - */ - function lengthb_clob( a_clob clob) return integer; - -end ut_utils; -/ diff --git a/source/create_grants.sql b/source/create_grants.sql deleted file mode 100644 index 2cdea9970..000000000 --- a/source/create_grants.sql +++ /dev/null @@ -1,145 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - -Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework -*/ - -@@define_ut3_owner_param.sql - -column 2 new_value 2 noprint -select null as "2" from dual where 1=0; -spool params.sql.tmp -select - case - when '&&2' is null then q'[ACCEPT ut3_user CHAR DEFAULT 'PUBLIC' PROMPT 'Provide schema which should be granted access to the utPLSQL v3 framework (PUBLIC): ']' - else 'define ut3_user=&&2' - end -from dual; - -spool off -set termout on -@params.sql.tmp -set termout off -/* cleanup temporary sql files */ ---try running on windows -$ del params.sql.tmp ---try running on linux/unix -! rm params.sql.tmp -set termout on - -set echo off -set feedback on -set heading off -set verify off - -prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user - -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -alter session set current_schema = &&ut3_owner; - ---public API -grant execute on &&ut3_owner..ut to &ut3_user; -grant execute on &&ut3_owner..ut_runner 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; -grant execute on &&ut3_owner..ut_suite_items_info to &ut3_user; -grant execute on &&ut3_owner..ut_suite_item_info to &ut3_user; -grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user; -grant execute on &&ut3_owner..ut_run_info to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_options to &ut3_user; - ---generic types -grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; -grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user; -grant execute on &&ut3_owner..ut_integer_list to &ut3_user; -grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user; -grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user; - ---expectations -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; - ---matchers -grant execute on &&ut3_owner..ut_matcher 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; -grant execute on &&ut3_owner..ut_be_false to &ut3_user; -grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user; -grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user; -grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user; -grant execute on &&ut3_owner..ut_be_less_than to &ut3_user; -grant execute on &&ut3_owner..ut_be_like to &ut3_user; -grant execute on &&ut3_owner..ut_be_not_null to &ut3_user; -grant execute on &&ut3_owner..ut_be_null to &ut3_user; -grant execute on &&ut3_owner..ut_be_true to &ut3_user; -grant execute on &&ut3_owner..ut_be_within to &ut3_user; -grant execute on &&ut3_owner..ut_be_within_pct to &ut3_user; -grant execute on &&ut3_owner..ut_contain to &ut3_user; -grant execute on &&ut3_owner..ut_equal to &ut3_user; -grant execute on &&ut3_owner..ut_have_count to &ut3_user; -grant execute on &&ut3_owner..ut_match to &ut3_user; - ---reporters - test results -grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_realtime_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_tap_reporter to &ut3_user; ---reporters - coverage -grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user; ---reporters - debug -grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user; - ---reporters - base types -grant execute on &&ut3_owner..ut_reporters to &ut3_user; -grant execute on &&ut3_owner..ut_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user; -grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user; - ---outputs -grant execute on &&ut3_owner..ut_output_buffer_base 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_output_bulk_buffer to &ut3_user; - ---needed internally for selecting from annotation objects within packages that use invoker rights -grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user; - ---other grants -grant execute on &&ut3_owner..ut_executables to &ut3_user; -grant execute on &&ut3_owner..ut_executable_test to &ut3_user; -grant execute on &&ut3_owner..ut_suite_cache_row to &ut3_user; -grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user; - -grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user; -grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user; -grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user; -grant select on &&ut3_owner..ut_coverage_runs to &ut3_user; -grant execute on &&ut3_owner..ut_matcher_options to &ut3_user; -grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user; - diff --git a/source/create_synonyms.sql b/source/create_synonyms.sql deleted file mode 100644 index d839e11b7..000000000 --- a/source/create_synonyms.sql +++ /dev/null @@ -1,138 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - -Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework -*/ - -@@define_ut3_owner_param.sql - -column 2 new_value 2 noprint -select null as "2" from dual where 1=0; -spool params.sql.tmp -select - case - when '&&2' is null then q'[ACCEPT ut3_user CHAR DEFAULT 'PUBLIC' PROMPT 'Provide schema which should own synonyms for the utPLSQL v3 framework (PUBLIC): ']' - else 'define ut3_user=&&2.' - end -from dual; -spool off -set termout on -@params.sql.tmp -set termout off - -spool params.sql.tmp -select - case - when upper('&&ut3_user') = 'PUBLIC' then q'[define action_type='or replace public' - ]'||q'[define ut3_user='' - ]'||q'[define grantee='PUBLIC']' - else q'[define action_type='or replace' - ]'||q'[define grantee='&&ut3_user'] - ]'||q'[define ut3_user='&&ut3_user..']' - end -from dual; - -spool off -set termout on -@params.sql.tmp -set termout off -/* cleanup temporary sql files */ ---try running on windows -$ del params.sql.tmp ---try running on linux/unix -! rm params.sql.tmp -set termout on - -set echo off -set feedback on -set heading off -set verify off - -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -alter session set current_schema = &&ut3_owner; - -prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&grantee - ---public API -create &action_type. synonym &ut3_user.ut for &&ut3_owner..ut; -create &action_type. synonym &ut3_user.ut_runner for &&ut3_owner..ut_runner; -create &action_type. synonym &ut3_user.ut_file_mappings for &&ut3_owner..ut_file_mappings; -create &action_type. synonym &ut3_user.ut_file_mapping for &&ut3_owner..ut_file_mapping; -create &action_type. synonym &ut3_user.ut_file_mapper for &&ut3_owner..ut_file_mapper; -create &action_type. synonym &ut3_user.ut_suite_items_info for &&ut3_owner..ut_suite_items_info; -create &action_type. synonym &ut3_user.ut_suite_item_info for &&ut3_owner..ut_suite_item_info; -create &action_type. synonym &ut3_user.ut_run_info for &&ut3_owner..ut_run_info; -create &action_type. synonym &ut3_user.ut_coverage_options for &&ut3_owner..ut_coverage_options; - ---generic types -create &action_type. synonym &ut3_user.ut_varchar2_list for &&ut3_owner..ut_varchar2_list; -create &action_type. synonym &ut3_user.ut_varchar2_rows for &&ut3_owner..ut_varchar2_rows; -create &action_type. synonym &ut3_user.ut_integer_list for &&ut3_owner..ut_integer_list; -create &action_type. synonym &ut3_user.ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; -create &action_type. synonym &ut3_user.ut_key_value_pair for &&ut3_owner..ut_key_value_pair; - ---expectations -create &action_type. synonym &ut3_user.ut_expectation for &&ut3_owner..ut_expectation; -create &action_type. synonym &ut3_user.ut_expectation_compound for &&ut3_owner..ut_expectation_compound; -create &action_type. synonym &ut3_user.ut_expectation_json for &&ut3_owner..ut_expectation_json; - ---matchers -create &action_type. synonym &ut3_user.ut_matcher for &&ut3_owner..ut_matcher; -create &action_type. synonym &ut3_user.be_between for &&ut3_owner..be_between; -create &action_type. synonym &ut3_user.be_empty for &&ut3_owner..be_empty; -create &action_type. synonym &ut3_user.be_false for &&ut3_owner..be_false; -create &action_type. synonym &ut3_user.be_greater_or_equal for &&ut3_owner..be_greater_or_equal; -create &action_type. synonym &ut3_user.be_greater_than for &&ut3_owner..be_greater_than; -create &action_type. synonym &ut3_user.be_less_or_equal for &&ut3_owner..be_less_or_equal; -create &action_type. synonym &ut3_user.be_less_than for &&ut3_owner..be_less_than; -create &action_type. synonym &ut3_user.be_like for &&ut3_owner..be_like; -create &action_type. synonym &ut3_user.be_not_null for &&ut3_owner..be_not_null; -create &action_type. synonym &ut3_user.be_null for &&ut3_owner..be_null; -create &action_type. synonym &ut3_user.be_true for &&ut3_owner..be_true; -create &action_type. synonym &ut3_user.be_within for &&ut3_owner..be_within; -create &action_type. synonym &ut3_user.be_within_pct for &&ut3_owner..be_within_pct; -create &action_type. synonym &ut3_user.contain for &&ut3_owner..contain; -create &action_type. synonym &ut3_user.equal for &&ut3_owner..equal; -create &action_type. synonym &ut3_user.have_count for &&ut3_owner..have_count; -create &action_type. synonym &ut3_user.match for &&ut3_owner..match; - ---reporters - test results -create &action_type. synonym &ut3_user.ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter; -create &action_type. synonym &ut3_user.ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter; -create &action_type. synonym &ut3_user.ut_junit_reporter for &&ut3_owner..ut_junit_reporter; -create &action_type. synonym &ut3_user.ut_tfs_junit_reporter for &&ut3_owner..ut_tfs_junit_reporter; -create &action_type. synonym &ut3_user.ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; -create &action_type. synonym &ut3_user.ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; -create &action_type. synonym &ut3_user.ut_realtime_reporter for &&ut3_owner..ut_realtime_reporter; -create &action_type. synonym &ut3_user.ut_tap_reporter for &&ut3_owner..ut_tap_reporter; ---reporters - coverage -create &action_type. synonym &ut3_user.ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; -create &action_type. synonym &ut3_user.ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; -create &action_type. synonym &ut3_user.ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; -create &action_type. synonym &ut3_user.ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; ---reporters - debug -create &action_type. synonym &ut3_user.ut_debug_reporter for &&ut3_owner..ut_debug_reporter; ---reporters - base types -create &action_type. synonym &ut3_user.ut_reporters for &&ut3_owner..ut_reporters; -create &action_type. synonym &ut3_user.ut_reporter_base for &&ut3_owner..ut_reporter_base; -create &action_type. synonym &ut3_user.ut_output_reporter_base for &&ut3_owner..ut_output_reporter_base; - ---other synonyms -create &action_type. synonym &ut3_user.dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks; -create &action_type. synonym &ut3_user.dbmspcc_runs for &&ut3_owner..dbmspcc_runs; -create &action_type. synonym &ut3_user.dbmspcc_units for &&ut3_owner..dbmspcc_units; diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql deleted file mode 100644 index 050162d72..000000000 --- a/source/create_synonyms_and_grants_for_public.sql +++ /dev/null @@ -1,23 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - -Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework -*/ - -@@define_ut3_owner_param.sql - -@@create_grants.sql '&&ut3_owner' 'PUBLIC' -@@create_synonyms.sql '&&ut3_owner' 'PUBLIC' diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql deleted file mode 100644 index 83e594884..000000000 --- a/source/create_user_grants.sql +++ /dev/null @@ -1,20 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - -Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework -*/ - -@@create_grants.sql diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql deleted file mode 100644 index a1e7a6acc..000000000 --- a/source/create_user_synonyms.sql +++ /dev/null @@ -1,20 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - -Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework -*/ - -@@create_synonyms.sql diff --git a/source/create_utplsql_owner.sql b/source/create_utplsql_owner.sql deleted file mode 100644 index d7e4f3040..000000000 --- a/source/create_utplsql_owner.sql +++ /dev/null @@ -1,43 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. -*/ -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback -set echo off -set feedback off -set heading off -set verify off - -define ut3_owner_schema = &1 -define ut3_password = &2 -define ut3_tablespace = &3 - -prompt Creating utPLSQL user &&ut3_owner_schema - -create user &ut3_owner_schema 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_owner_schema; - -grant execute on dbms_lock to &ut3_owner_schema; -grant execute on dbms_crypto to &ut3_owner_schema; -grant execute on dbms_lob to &ut3_owner_schema; -grant execute on dbms_xmlgen to &ut3_owner_schema; -grant execute on dbms_sql to &ut3_owner_schema; -grant execute on dbms_random to &ut3_owner_schema; - - -grant alter session to &ut3_owner_schema; - diff --git a/source/define_ut3_owner_param.sql b/source/define_ut3_owner_param.sql deleted file mode 100644 index 259b49712..000000000 --- a/source/define_ut3_owner_param.sql +++ /dev/null @@ -1,52 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 serveroutput on size unlimited format truncated -whenever oserror continue - -set heading off -set linesize 1000 -set pagesize 0 - -set verify off -set define on - -set termout off -set timing off -set feedback off - -column line_separator new_value line_separator noprint -select '--------------------------------------------------------------' as line_separator from dual; - -column 1 new_value 1 noprint -select null as "1" from dual where 1=0; -spool params.sql.tmp -select - case - when '&&1' is null then q'[ACCEPT ut3_owner CHAR DEFAULT 'UT3' PROMPT 'Provide schema for the utPLSQL v3 (UT3)']' - else 'define ut3_owner=&&1' - end -from dual; -spool off -set termout on -@params.sql.tmp -set termout off -/* cleanup temporary sql files */ ---try running on windows -$ del params.sql.tmp ---try running on linux/unix -! rm params.sql.tmp -set termout on diff --git a/source/dummy.sql b/source/dummy.sql deleted file mode 100644 index 36d9f8778..000000000 --- a/source/dummy.sql +++ /dev/null @@ -1 +0,0 @@ -whenever sqlerror exit failure rollback diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql deleted file mode 100644 index c10e8d2e8..000000000 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ /dev/null @@ -1,26 +0,0 @@ -create global temporary table ut_compound_data_diff_tmp( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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), - act_data_id raw(32), - exp_data_id raw(32), - act_item_data xmltype, - exp_item_data xmltype, - item_no integer, - duplicate_no integer, - constraint ut_compound_data_diff_tmp_uk1 unique (diff_id,duplicate_no,item_no), - constraint ut_compound_data_diff_tmp_chk check( - item_no is not null - ) -) on commit delete rows; diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb deleted file mode 100644 index 875ec760a..000000000 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ /dev/null @@ -1,853 +0,0 @@ -create or replace package body ut_compound_data_helper is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - 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'[ - with exp as ( - select - ucd.*, - {:duplicate_number:} "UT3$_Dup#No" - from ( - select - ucd."UT3$_Item#Data" - ,x.data_id "UT3$_Data#Id" - ,ucd."UT3$_Position#" + x.item_no "UT3$_Item#No" - {:columns:} - from ut_compound_data_tmp x, - xmltable('/ROWSET/ROW' passing x.item_data columns - "UT3$_Item#Data" xmltype path '*' - ,"UT3$_Position#" for ordinality - {:xml_to_columns:} ) ucd - where x.data_id = :exp_guid - ) ucd - ) - , act as ( - select - ucd.*, - {:duplicate_number:} "UT3$_Dup#No" - from ( - select - ucd."UT3$_Item#Data" - ,x.data_id "UT3$_Data#Id" - ,ucd."UT3$_Position#" + x.item_no "UT3$_Item#No" - {:columns:} - from ut_compound_data_tmp x, - xmltable('/ROWSET/ROW' passing x.item_data columns - "UT3$_Item#Data" xmltype path '*' - ,"UT3$_Position#" for ordinality - {:xml_to_columns:} ) ucd - where x.data_id = :act_guid - ) ucd - ) - select /*+ no_parallel */ - a."UT3$_Item#Data" as act_item_data, - a."UT3$_Data#Id" act_data_id, - e."UT3$_Item#Data" as exp_item_data, - e."UT3$_Data#Id" exp_data_id, - {:item_no:} as item_no, - nvl(e."UT3$_Dup#No",a."UT3$_Dup#No") dup_no - from act a {:join_type:} exp e on ( {:join_condition:} ) - where {:where_condition:}]'; - - 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 is - l_results tt_column_diffs; - begin - execute immediate q'[with - expected_cols as ( - 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 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 - ), - joined_cols as ( - select e.*,a.*]' - || case when a_order_enforced then ', - row_number() over(partition by case when a.act_col_pos + e.exp_col_pos is not null then 1 end order by a.act_col_pos) a_pos_nn, - row_number() over(partition by case when a.act_col_pos + e.exp_col_pos is not null then 1 end order by e.exp_col_pos) e_pos_nn' - else - null - end ||q'[ - from expected_cols e - full outer join actual_cols a - on e.exp_column_name = a.act_column_name - ) - select /*+ no_parallel */ case - when exp_col_pos is null and act_col_pos is not null then '+' - when exp_col_pos is not null and act_col_pos is null then '-' - when exp_col_type_compare != act_col_type_compare then 't' - else 'p' - end as diff_type, - exp_column_name, exp_col_type, exp_col_pos, - act_column_name, act_col_type, act_col_pos - from joined_cols - --column is unexpected (extra) or missing - where act_col_pos is null or exp_col_pos is null - --column type is not matching (except CHAR/VARCHAR2) - or act_col_type_compare != exp_col_type_compare]' - || case when a_order_enforced then q'[ - --column position is not matching (both when excluded extra/missing columns as well as when they are included) - or (a_pos_nn != e_pos_nn and exp_col_pos != act_col_pos)]' - end ||q'[ - order by exp_col_pos, act_col_pos]' - bulk collect into l_results using a_expected, a_actual; - return l_results; - end; - - function generate_not_equal_stmt( - a_data_info ut_cursor_column, a_pk_table ut_varchar2_list - ) return varchar2 - is - l_pk_tab ut_varchar2_list := coalesce(a_pk_table,ut_varchar2_list()); - l_index integer; - l_sql_stmt varchar2(32767); - l_exists boolean := false; - begin - l_index := l_pk_tab.first; - if l_pk_tab.count > 0 then - loop - if a_data_info.access_path = l_pk_tab(l_index) then - l_exists := true; - end if; - exit when l_index = l_pk_tab.count or (a_data_info.access_path = l_pk_tab(l_index)); - l_index := a_pk_table.next(l_index); - end loop; - end if; - if not(l_exists) then - l_sql_stmt := ' (decode(a.'||a_data_info.transformed_name||','||' e.'||a_data_info.transformed_name||',1,0) = 0)'; - end if; - return l_sql_stmt; - end; - - function generate_join_by_stmt( - a_data_info ut_cursor_column, a_pk_table ut_varchar2_list - ) return varchar2 - is - l_pk_tab ut_varchar2_list := coalesce(a_pk_table,ut_varchar2_list()); - l_index integer; - l_sql_stmt varchar2(32767); - begin - if l_pk_tab.count <> 0 then - l_index:= l_pk_tab.first; - loop - if l_pk_tab(l_index) in (a_data_info.access_path, a_data_info.parent_name) then - --When then table is nested and join is on whole table - l_sql_stmt := l_sql_stmt ||' a.'||a_data_info.transformed_name||q'[ = ]'||' e.'||a_data_info.transformed_name; - end if; - exit when (a_data_info.access_path = l_pk_tab(l_index)) or l_index = l_pk_tab.count; - l_index := l_pk_tab.next(l_index); - end loop; - end if; - return l_sql_stmt; - end; - - function generate_equal_sql(a_col_name in varchar2) return varchar2 is - begin - return ' decode(a.'||a_col_name||','||' e.'||a_col_name||',1,0) = 1 '; - end; - - function generate_partition_stmt( - a_data_info ut_cursor_column, a_pk_table in ut_varchar2_list, a_alias varchar2 := 'ucd.' - ) return varchar2 - is - l_index integer; - l_sql_stmt varchar2(32767); - begin - if a_pk_table is not empty then - l_index:= a_pk_table.first; - loop - if a_pk_table(l_index) in (a_data_info.access_path, a_data_info.parent_name) then - --When then table is nested and join is on whole table - l_sql_stmt := l_sql_stmt ||a_alias||a_data_info.transformed_name; - end if; - exit when (a_data_info.access_path = a_pk_table(l_index)) or l_index = a_pk_table.count; - l_index := a_pk_table.next(l_index); - end loop; - else - l_sql_stmt := a_alias||a_data_info.transformed_name; - end if; - return l_sql_stmt; - end; - - function generate_select_stmt(a_data_info ut_cursor_column, a_alias varchar2 := 'ucd.') - return varchar2 - is - l_alias varchar2(10) := a_alias; - l_col_syntax varchar2(4000); - begin - if a_data_info.is_sql_diffable = 0 then - l_col_syntax := 'ut_utils.get_hash('||l_alias||a_data_info.transformed_name||'.getClobVal()) as '||a_data_info.transformed_name ; - elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type = 'DATE' then - l_col_syntax := 'to_date('||l_alias||a_data_info.transformed_name||') as '|| a_data_info.transformed_name; - elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP') then - l_col_syntax := 'to_timestamp('||l_alias||a_data_info.transformed_name||','''||ut_utils.gc_timestamp_format||''') as '|| a_data_info.transformed_name; - elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP WITH TIME ZONE') then - l_col_syntax := 'to_timestamp_tz('||l_alias||a_data_info.transformed_name||','''||ut_utils.gc_timestamp_tz_format||''') as '|| a_data_info.transformed_name; - elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP WITH LOCAL TIME ZONE') then - l_col_syntax := ' cast( to_timestamp_tz('||l_alias||a_data_info.transformed_name||','''||ut_utils.gc_timestamp_tz_format||''') AS TIMESTAMP WITH LOCAL TIME ZONE) as '|| a_data_info.transformed_name; - else - l_col_syntax := l_alias||a_data_info.transformed_name||' as '|| a_data_info.transformed_name; - end if; - return l_col_syntax; - end; - - function generate_xmltab_stmt(a_data_info ut_cursor_column) return varchar2 is - l_col_type varchar2(4000); - begin - if a_data_info.is_sql_diffable = 0 then - l_col_type := 'XMLTYPE'; - 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 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 - ||case when a_data_info.column_len is not null - then '('||a_data_info.column_len||')' - else null - end; - end if; - return a_data_info.transformed_name||' '||l_col_type||q'[ PATH ']'||a_data_info.access_path||q'[']'; - end; - - procedure gen_sql_pieces_out_of_cursor( - a_data_info ut_cursor_column_tab, - a_pk_table ut_varchar2_list, - a_unordered boolean, - a_xml_stmt out nocopy clob, - a_select_stmt out nocopy clob, - a_partition_stmt out nocopy clob, - a_join_by_stmt out nocopy clob, - a_not_equal_stmt out nocopy clob - ) is - l_partition_tmp clob; - l_xmltab_list ut_varchar2_list := ut_varchar2_list(); - l_select_list ut_varchar2_list := ut_varchar2_list(); - l_partition_list ut_varchar2_list := ut_varchar2_list(); - l_equal_list ut_varchar2_list := ut_varchar2_list(); - l_join_by_list ut_varchar2_list := ut_varchar2_list(); - l_not_equal_list ut_varchar2_list := ut_varchar2_list(); - - procedure add_element_to_list(a_list in out ut_varchar2_list, a_list_element in varchar2) - is - begin - if a_list_element is not null then - a_list.extend; - a_list(a_list.last) := a_list_element; - end if; - end; - - begin - if a_data_info is not empty then - for i in 1..a_data_info.count loop - if a_data_info(i).has_nested_col = 0 and a_data_info(i).column_type <> 'OBJECT' then - --Get XMLTABLE column list - add_element_to_list(l_xmltab_list,generate_xmltab_stmt(a_data_info(i))); - --Get Select statment list of columns - add_element_to_list(l_select_list, generate_select_stmt(a_data_info(i))); - --Get columns by which we partition - add_element_to_list(l_partition_list,generate_partition_stmt(a_data_info(i), a_pk_table)); - --Get equal statement - add_element_to_list(l_equal_list,generate_equal_sql(a_data_info(i).transformed_name)); - --Generate join by stmt - add_element_to_list(l_join_by_list,generate_join_by_stmt(a_data_info(i), a_pk_table)); - --Generate not equal stmt - add_element_to_list(l_not_equal_list,generate_not_equal_stmt(a_data_info(i), a_pk_table)); - end if; - end loop; - - a_xml_stmt := nullif(','||ut_utils.table_to_clob(l_xmltab_list, ' , '),','); - a_select_stmt := nullif(','||ut_utils.table_to_clob(l_select_list, ' , '),','); - l_partition_tmp := ut_utils.table_to_clob(l_partition_list, ' , '); - ut_utils.append_to_clob(a_partition_stmt,' row_number() over (partition by '||l_partition_tmp||' order by '||l_partition_tmp||' ) '); - - if a_pk_table.count > 0 then - -- If key defined do the join or these and where on diffrences as well as on duplicate number when rows are same. - a_join_by_stmt := ' e."UT3$_Dup#No" = a."UT3$_Dup#No" and '||ut_utils.table_to_clob(l_join_by_list, ' and '); - elsif a_unordered then - -- If no key defined do the join on all columns - a_join_by_stmt := ' e."UT3$_Dup#No" = a."UT3$_Dup#No" and '||ut_utils.table_to_clob(l_equal_list, ' and '); - else - -- Else join on rownumber - a_join_by_stmt := 'a."UT3$_Item#No" = e."UT3$_Item#No" '; - end if; - a_not_equal_stmt := ut_utils.table_to_clob(l_not_equal_list, ' or '); - else - --Partition by piece when no data - ut_utils.append_to_clob(a_partition_stmt,' 1 '); - a_join_by_stmt := 'a."UT3$_Item#No" = e."UT3$_Item#No" '; - end if; - end; - - function gen_compare_sql( - a_other ut_data_value_refcursor, - a_join_by_list ut_varchar2_list, - a_unordered boolean, - a_inclusion_type boolean, - a_is_negated boolean - ) return clob is - l_compare_sql clob; - l_xmltable_stmt clob; - l_select_stmt clob; - l_partition_stmt clob; - l_join_on_stmt clob; - l_not_equal_stmt clob; - l_where_stmt clob; - l_join_by_list ut_varchar2_list; - - function get_join_type(a_inclusion_compare in boolean,a_negated in boolean) return varchar2 is - begin - return - case - when a_inclusion_compare and not(a_negated) then ' right outer join ' - when a_inclusion_compare and a_negated then ' inner join ' - else ' full outer join ' - end; - end; - - function get_item_no(a_unordered boolean) return varchar2 is - begin - return - case - when a_unordered then 'row_number() over ( order by nvl(e."UT3$_Item#No",a."UT3$_Item#No"))' - else 'nvl(e."UT3$_Item#No",a."UT3$_Item#No") ' - end; - 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, l_join_by_list, a_unordered, - l_xmltable_stmt, l_select_stmt, l_partition_stmt, l_join_on_stmt, - l_not_equal_stmt - ); - - l_compare_sql := replace(l_compare_sql,'{:duplicate_number:}',l_partition_stmt); - l_compare_sql := replace(l_compare_sql,'{:columns:}',l_select_stmt); - l_compare_sql := replace(l_compare_sql,'{:xml_to_columns:}',l_xmltable_stmt); - l_compare_sql := replace(l_compare_sql,'{:item_no:}',get_item_no(a_unordered)); - 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 ((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 - if a_inclusion_type then - ut_utils.append_to_clob(l_where_stmt,case when a_is_negated then ' 1 = 1 ' else ' ( a."UT3$_Data#Id" is null ) ' end); - else - ut_utils.append_to_clob(l_where_stmt,' (a."UT3$_Data#Id" is null or e."UT3$_Data#Id" is null) '); - end if; - - l_compare_sql := replace(l_compare_sql,'{:where_condition:}',l_where_stmt); - return l_compare_sql; - end; - - function get_column_extract_path(a_cursor_info ut_cursor_column_tab) return ut_varchar2_list is - l_column_list ut_varchar2_list := ut_varchar2_list(); - begin - for i in 1..a_cursor_info.count loop - --This avoids extracting single columns from nested objects. - --as we can go down to any level but we will lose visibility of parent. - if a_cursor_info(i).hierarchy_level = 1 then - l_column_list.extend; - l_column_list(l_column_list.last) := a_cursor_info(i).access_path; - end if; - end loop; - return l_column_list; - end; - - function get_rows_diff_by_sql( - a_act_cursor_info ut_cursor_column_tab, a_exp_cursor_info ut_cursor_column_tab, - a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, - a_join_by_list ut_varchar2_list, a_unordered boolean, a_enforce_column_order boolean := false, - a_extract_path varchar2 - ) return tt_row_diffs is - l_act_extract_xpath varchar2(32767):= ut_utils.to_xpath(get_column_extract_path(a_act_cursor_info)); - l_exp_extract_xpath varchar2(32767):= ut_utils.to_xpath(get_column_extract_path(a_exp_cursor_info)); - l_join_xpath varchar2(32767) := ut_utils.to_xpath(a_join_by_list); - l_results tt_row_diffs; - l_sql varchar2(32767); - l_column_order varchar2(100); - begin - if a_enforce_column_order then - l_column_order := 'col_no'; - else - l_column_order := 'col_name'; - end if; - l_sql := q'[ - with - exp_cols as ( - select - i.exp_item_data, i.exp_data_id, i.item_no rn, rownum col_no, i.diff_id, - s.column_value col, s.column_value.getRootElement() col_name, - nvl( s.column_value.getclobval(), empty_clob() ) col_val - from ( - select - ucd.exp_data_id, extract( ucd.exp_item_data, :column_path ) exp_item_data, - ucd.item_no, ucd.diff_id - from ut_compound_data_diff_tmp ucd - where ucd.diff_id = :diff_id - and ucd.exp_data_id = :self_guid - ) i, - table( xmlsequence( extract( i.exp_item_data, :extract_path ) ) ) s - ), - act_cols as ( - select - i.act_item_data, i.act_data_id, i.item_no rn, rownum col_no, i.diff_id, - s.column_value col, s.column_value.getRootElement() col_name, - nvl( s.column_value.getclobval(), empty_clob() ) col_val - from ( - select - ucd.act_data_id, extract( ucd.act_item_data, :column_path ) act_item_data, - ucd.item_no, ucd.diff_id - from ut_compound_data_diff_tmp ucd - where ucd.diff_id = :diff_id - and ucd.act_data_id = :other_guid - ) i, - table( xmlsequence( extract( i.act_item_data, :extract_path ) ) ) s - ), - data_diff as ( - select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value, col_name, diff_id - from ( - select nvl(exp.rn, act.rn) rn, - exp.diff_id diff_id, - xmlagg(exp.col order by exp.col_no) exp_item, - xmlagg(act.col order by nvl(exp.col_no, act.col_no)) act_item, - max(nvl(exp.col_name,act.col_name)) col_name - from exp_cols exp - join act_cols act - on exp.rn = act.rn and exp.col_name = act.col_name - where dbms_lob.compare(exp.col_val, act.col_val) != 0 - group by nvl(exp.rn, act.rn), exp.diff_id - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) - ), - unordered_diff as ( - select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value, col_name, diff_id - from ( - select nvl(exp.rn, act.rn) rn, - exp.diff_id diff_id, - xmlagg(exp.col order by exp.col_name) exp_item, - xmlagg(act.col order by act.col_name) act_item, - max(nvl(exp.col_name,act.col_name)) col_name - from exp_cols exp - join act_cols act - on exp.rn = act.rn and exp.col_name = act.col_name - where dbms_lob.compare(exp.col_val, act.col_val) != 0 - group by nvl(exp.rn, act.rn), exp.diff_id - ) - unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) - ) - select /*+ no_parallel */ rn, diff_type, diffed_row, pk_value - from ( - select rn, diff_type, diffed_row, pk_value, - case when diff_type = 'Actual:' then 1 else 2 end rnk, - 1 final_order, - col_name - from ( ]' - || case when a_unordered then q'[ - select /*+ no_unnest */ - u.rn, u.diff_type, u.diffed_row, - replace( - extract( case when i.exp_data_id is null then i.act_item_data else i.exp_item_data end, :join_by ).getclobval(), - chr(10) - ) pk_value, - u.col_name - from data_diff u - join ut_compound_data_diff_tmp i - on i.diff_id = u.diff_id - and i.item_no = u.rn]' - else q'[ - select rn, diff_type, diffed_row, pk_value, col_name - from data_diff - where :join_by is null ]' - end ||q'[ - ) - union all - select - item_no as rn, - case when exp_data_id is null then 'Extra:' else 'Missing:' end as diff_type, - xmlserialize( - content ( - extract( (case when exp_data_id is null then act_item_data else exp_item_data end),'/*/*') - ) no indent - ) diffed_row, - nvl2( - :join_by, - replace( - extract( case when exp_data_id is null then act_item_data else exp_item_data end, :join_by ).getclobval(), - chr(10) - ), - null - ) pk_value, - case when exp_data_id is null then 1 else 2 end rnk, - 2 final_order, - null col_name - from ut_compound_data_diff_tmp i - where diff_id = :diff_id - and act_data_id is null or exp_data_id is null - ) - order by final_order,]' - ||case when a_enforce_column_order or (not(a_enforce_column_order) and not(a_unordered)) then - q'[ - case when final_order = 1 then rn else rnk end, - case when final_order = 1 then rnk else rn end - ]' - when a_unordered then - q'[ - case when final_order = 1 then col_name else to_char(rnk) end, - case when final_order = 1 then to_char(rn) else col_name end, - case when final_order = 1 then to_char(rnk) else col_name end - ]' - end; - execute immediate l_sql - bulk collect into l_results - using l_exp_extract_xpath, a_diff_id, a_expected_dataset_guid, a_extract_path, - l_act_extract_xpath, a_diff_id, a_actual_dataset_guid, a_extract_path, - l_join_xpath, l_join_xpath, l_join_xpath, a_diff_id; - return l_results; - end; - - function get_fixed_size_hash(a_string varchar2, a_base integer :=0,a_size integer := 9999999) return number is - begin - return dbms_utility.get_hash_value(a_string,a_base,a_size); - end; - - procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw) is - begin - forall idx in 1..a_diff_tab.count save exceptions - insert /*+ no_parallel */ into ut_compound_data_diff_tmp - ( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no, duplicate_no ) - values - (a_diff_id, - xmlelement( name "ROW", a_diff_tab(idx).act_item_data), a_diff_tab(idx).act_data_id, - xmlelement( name "ROW", a_diff_tab(idx).exp_item_data), a_diff_tab(idx).exp_data_id, - a_diff_tab(idx).item_no, a_diff_tab(idx).dup_no); - exception - when ut_utils.ex_failure_for_all then - raise_application_error(ut_utils.gc_dml_for_all,'Failure to insert a diff tmp data.'); - end; - - procedure set_rows_diff(a_rows_diff integer) is - begin - g_diff_count := a_rows_diff; - end; - - procedure cleanup_diff is - begin - g_diff_count := 0; - delete from ut_compound_data_diff_tmp; - delete from ut_json_data_diff_tmp; - end; - - function get_rows_diff_count return integer is - begin - return g_diff_count; - end; - - function is_sql_compare_allowed(a_type_name varchar2) - return boolean is - l_assert boolean; - begin - --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 - l_assert := false; - else - l_assert := true; - end if; - return l_assert; - end; - - function get_column_type_desc(a_type_code in integer, a_dbms_sql_desc in boolean) - return varchar2 is - begin - return - case - when a_dbms_sql_desc then g_type_name_map(a_type_code) - else g_anytype_name_map(a_type_code) - end; - end; - - function get_compare_cursor(a_diff_cursor_text in clob,a_self_id raw, a_other_id raw) return sys_refcursor is - l_diff_cursor sys_refcursor; - begin - 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)||chr(10)|| - 'Check the query and data for errors.'; - end; - - procedure save_cursor_data_for_diff(a_data_id raw, a_set_id integer, a_xml xmltype) is - begin - insert /*+ no_parallel */ into ut_compound_data_tmp (data_id, item_no, item_data) values (a_data_id, a_set_id, a_xml); - end; - - function get_row_data_as_xml(a_data_id raw, a_max_rows integer) return ut_utils.t_clob_tab is - l_results ut_utils.t_clob_tab; - begin - select /*+ no_parallel */ xmlserialize( content ucd.item_data no indent) - bulk collect into l_results - from ut_compound_data_tmp tmp - ,xmltable ( '/ROWSET' passing tmp.item_data - columns item_data xmltype PATH '*' - ) ucd - where tmp.data_id = a_data_id - and rownum <= a_max_rows; - - return l_results; - 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 /*+ no_parallel */ 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 /*+ no_parallel */ 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_diff_id raw) return tt_json_diff_type_tab is - l_diffs_summary tt_json_diff_type_tab := tt_json_diff_type_tab(); - begin - select /*+ no_parallel */ d.difference_type,count(1) - bulk collect into l_diffs_summary - from ut_json_data_diff_tmp d - where diff_id = a_diff_id - 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 /*+ no_parallel */ 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; - - function get_json_object(a_json_t json) return json_element_t is - l_obj json_element_t; - begin - $if dbms_db_version.version >= 21 $then - l_obj := case when a_json_t is null then cast (null as json_element_t ) else json_element_t.parse(json_query(a_json_t, '$' returning clob)) end; - $end - return l_obj; - end; - -begin - g_anytype_name_map(dbms_types.typecode_date) := 'DATE'; - g_anytype_name_map(dbms_types.typecode_number) := 'NUMBER'; - g_anytype_name_map(3 /*INTEGER in object type*/) := 'NUMBER'; - g_anytype_name_map(dbms_types.typecode_raw) := 'RAW'; - g_anytype_name_map(dbms_types.typecode_char) := 'CHAR'; - g_anytype_name_map(dbms_types.typecode_varchar2) := 'VARCHAR2'; - g_anytype_name_map(dbms_types.typecode_varchar) := 'VARCHAR'; - g_anytype_name_map(dbms_types.typecode_blob) := 'BLOB'; - g_anytype_name_map(dbms_types.typecode_bfile) := 'BFILE'; - g_anytype_name_map(dbms_types.typecode_clob) := 'CLOB'; - g_anytype_name_map(dbms_types.typecode_timestamp) := 'TIMESTAMP'; - g_anytype_name_map(dbms_types.typecode_timestamp_tz) := 'TIMESTAMP WITH TIME ZONE'; - g_anytype_name_map(dbms_types.typecode_timestamp_ltz) := 'TIMESTAMP WITH LOCAL TIME ZONE'; - g_anytype_name_map(dbms_types.typecode_interval_ym) := 'INTERVAL YEAR TO MONTH'; - g_anytype_name_map(dbms_types.typecode_interval_ds) := 'INTERVAL DAY TO SECOND'; - g_anytype_name_map(dbms_types.typecode_bfloat) := 'BINARY_FLOAT'; - g_anytype_name_map(dbms_types.typecode_bdouble) := 'BINARY_DOUBLE'; - g_anytype_name_map(dbms_types.typecode_urowid) := 'UROWID'; - g_anytype_name_map(dbms_types.typecode_varray) := 'VARRRAY'; - g_anytype_name_map(dbms_types.typecode_table) := 'TABLE'; - g_anytype_name_map(dbms_types.typecode_namedcollection) := 'NAMEDCOLLECTION'; - g_anytype_name_map(dbms_types.typecode_object) := 'OBJECT'; - - g_type_name_map( dbms_sql.binary_bouble_type ) := 'BINARY_DOUBLE'; - g_type_name_map( dbms_sql.bfile_type ) := 'BFILE'; - g_type_name_map( dbms_sql.binary_float_type ) := 'BINARY_FLOAT'; - g_type_name_map( dbms_sql.blob_type ) := 'BLOB'; - g_type_name_map( dbms_sql.long_raw_type ) := 'LONG RAW'; - g_type_name_map( dbms_sql.char_type ) := 'CHAR'; - g_type_name_map( dbms_sql.clob_type ) := 'CLOB'; - g_type_name_map( dbms_sql.long_type ) := 'LONG'; - g_type_name_map( dbms_sql.date_type ) := 'DATE'; - g_type_name_map( dbms_sql.interval_day_to_second_type ) := 'INTERVAL DAY TO SECOND'; - g_type_name_map( dbms_sql.interval_year_to_month_type ) := 'INTERVAL YEAR TO MONTH'; - g_type_name_map( dbms_sql.raw_type ) := 'RAW'; - g_type_name_map( dbms_sql.timestamp_type ) := 'TIMESTAMP'; - g_type_name_map( dbms_sql.timestamp_with_tz_type ) := 'TIMESTAMP WITH TIME ZONE'; - g_type_name_map( dbms_sql.timestamp_with_local_tz_type ) := 'TIMESTAMP WITH LOCAL TIME ZONE'; - g_type_name_map( dbms_sql.varchar2_type ) := 'VARCHAR2'; - g_type_name_map( dbms_sql.number_type ) := 'NUMBER'; - g_type_name_map( dbms_sql.rowid_type ) := 'ROWID'; - 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 deleted file mode 100644 index 451cd9bac..000000000 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ /dev/null @@ -1,140 +0,0 @@ -create or replace package ut_compound_data_helper authid definer is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_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), - expected_type varchar2(250), - expected_pos integer, - actual_name varchar2(250), - actual_type varchar2(250), - actual_pos integer - ); - - type tt_column_diffs is table of t_column_diffs; - - type t_row_diffs is record( - rn integer, - diff_type varchar2(250), - diffed_row clob, - pk_value varchar2(4000) - ); - - type tt_row_diffs is table of t_row_diffs; - - type t_diff_rec is record ( - act_item_data xmltype, - act_data_id raw(32), - exp_item_data xmltype, - exp_data_id raw(32), - item_no number, - dup_no number - ); - - 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; - - function get_rows_diff_by_sql( - a_act_cursor_info ut_cursor_column_tab,a_exp_cursor_info ut_cursor_column_tab, - a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw, - a_join_by_list ut_varchar2_list, a_unordered boolean, a_enforce_column_order boolean := false, - a_extract_path varchar2 - ) return tt_row_diffs; - - function get_fixed_size_hash(a_string varchar2, a_base integer :=0,a_size integer :=9999999) return number; - - function gen_compare_sql( - a_other ut_data_value_refcursor, - a_join_by_list ut_varchar2_list, - a_unordered boolean, - a_inclusion_type boolean, - a_is_negated boolean - ) return clob; - - procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw); - - procedure set_rows_diff(a_rows_diff integer); - - procedure cleanup_diff; - - function get_rows_diff_count return integer; - - function is_sql_compare_allowed(a_type_name varchar2) return boolean; - - function get_column_type_desc(a_type_code in integer, a_dbms_sql_desc in boolean) return varchar2; - - 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; - - procedure save_cursor_data_for_diff(a_data_id raw, a_set_id integer, a_xml xmltype); - - function get_row_data_as_xml(a_data_id raw, a_max_rows integer) return ut_utils.t_clob_tab; - - /* - * 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_diff_id raw) return tt_json_diff_type_tab; - - function get_json_object(a_json_t json) return json_element_t; - -end; -/ diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql deleted file mode 100644 index 1bfa77fca..000000000 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ /dev/null @@ -1,23 +0,0 @@ -create global temporary table ut_compound_data_tmp( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_id raw(32), - item_no integer, - item_data xmltype, - item_hash raw(128), - pk_hash raw(128), - duplicate_no integer, - constraint ut_cmp_data_tmp_hash_pk unique (data_id, item_no, duplicate_no) -) on commit delete rows; ---xmltype column item_data store as binary xml; \ No newline at end of file diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb deleted file mode 100644 index 2c52ff8fa..000000000 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ /dev/null @@ -1,63 +0,0 @@ -create or replace type body ut_compound_data_value as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 function get_elements_count_info return varchar2 is - begin - return case when elements_count is null then ' [ null ]' else ' [ count = '||elements_count||' ]' end; - end; - - overriding member function get_object_info return varchar2 is - begin - return self.data_type||get_elements_count_info(); - 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_diffable return boolean is - begin - return true; - end; - - overriding member function is_multi_line return boolean is - begin - return not self.is_null(); - end; - - overriding member function to_string return varchar2 is - l_result clob; - l_result_string varchar2(32767); - begin - if not self.is_null() then - dbms_lob.createtemporary(l_result, true); - ut_utils.append_to_clob(l_result,'Data:'||chr(10)); - ut_utils.append_to_clob( - l_result, - ut_compound_data_helper.get_row_data_as_xml( self.data_id, ut_utils.gc_diff_max_rows ) - ); - - l_result_string := ut_utils.to_string(l_result,null); - dbms_lob.freetemporary(l_result); - end if; - return l_result_string; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps deleted file mode 100644 index c14dadceb..000000000 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ /dev/null @@ -1,50 +0,0 @@ -create or replace type ut_compound_data_value force under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * Holds information about ref cursor to be processed by expectation - */ - - - /** - * Determines if the cursor is null - */ - is_data_null integer, - - /** - * Holds the number of elements in the compound data value (cursor/collection) - */ - elements_count integer, - - /** - * Holds unique id for retrieving the data from ut_compound_data_tmp temp table - */ - data_id raw(16), - - /** - * Holds name for the type of compound - */ - compound_type varchar2(50), - - member function get_elements_count_info return varchar2, - overriding member function get_object_info return varchar2, - overriding member function is_null return boolean, - overriding member function is_diffable return boolean, - overriding member function to_string return varchar2, - overriding member function is_multi_line return boolean -) not final not instantiable -/ diff --git a/source/expectations/data_values/ut_cursor_column.tpb b/source/expectations/data_values/ut_cursor_column.tpb deleted file mode 100644 index a9fb6b0f4..000000000 --- a/source/expectations/data_values/ut_cursor_column.tpb +++ /dev/null @@ -1,74 +0,0 @@ -create or replace type body ut_cursor_column as - - 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 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_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2 - self.column_name := case when a_col_name is null and a_collection = 1 then - self.column_type_name - else TRIM( BOTH '''' FROM a_col_name) - end; --name of the column, however in nested object for collection name is not defined in cursor. - 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.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 - --Transformed name needs to be build on full access path to avoid ambiguity when there is 3 or more levels of nesting. - self.transformed_name := case when length(self.xml_valid_name) > 30 then - '"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"' - when self.parent_name is null then - '"'||self.xml_valid_name||'"' - else - '"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"' - 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 - when lower(self.column_type) = 'user_defined_type' then - 0 - -- Due to bug in 11g/12.1 collection fails on varchar 4000+ - when (lower(self.column_type) in ('varchar2','char')) and (self.column_len > 4000) then - 0 - else - ut_utils.boolean_to_int(ut_compound_data_helper.is_sql_compare_allowed(self.column_type)) - end; --can we directly compare or do we need to hash value - self.is_collection := a_collection; - self.has_nested_col := case when lower(self.column_type) = 'user_defined_type' and self.is_collection = 0 then 1 else 0 end; - end; - - 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_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,a_col_precision,a_col_scale); - return; - end; - - constructor function ut_cursor_column( self in out nocopy ut_cursor_column) return self as result is - begin - return; - end; -end; -/ diff --git a/source/expectations/data_values/ut_cursor_column.tps b/source/expectations/data_values/ut_cursor_column.tps deleted file mode 100644 index 77bf78f01..000000000 --- a/source/expectations/data_values/ut_cursor_column.tps +++ /dev/null @@ -1,52 +0,0 @@ -create or replace type ut_cursor_column authid current_user as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - 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(2000), - hierarchy_level number, - column_position number, - 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_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_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 deleted file mode 100644 index 106023d96..000000000 --- a/source/expectations/data_values/ut_cursor_column_tab.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_cursor_column_tab as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_cursor_column -/ \ No newline at end of file diff --git a/source/expectations/data_values/ut_cursor_details.tpb b/source/expectations/data_values/ut_cursor_details.tpb deleted file mode 100644 index b823ff944..000000000 --- a/source/expectations/data_values/ut_cursor_details.tpb +++ /dev/null @@ -1,260 +0,0 @@ -create or replace type body ut_cursor_details as - - member function equals( a_other ut_cursor_details, a_match_options ut_matcher_options ) return boolean is - l_diffs integer; - begin - select /*+ no_parallel */ count(1) into l_diffs - from table(self.cursor_columns_info) a - full outer join table(a_other.cursor_columns_info) e - on decode(a.parent_name,e.parent_name,1,0)= 1 - and a.column_name = e.column_name - and replace(a.column_type,'VARCHAR2','CHAR') = replace(e.column_type,'VARCHAR2','CHAR') - and ( a.column_position = e.column_position or a_match_options.columns_are_unordered_flag = 1 ) - where a.column_name is null or e.column_name is null; - return l_diffs = 0; - end; - - member procedure desc_compound_data( - self in out nocopy ut_cursor_details, a_compound_data anytype, - a_parent_name in varchar2, a_level in integer, a_access_path in varchar2 - ) is - l_idx pls_integer := 1; - l_elements_info ut_metadata.t_anytype_members_rec; - l_element_info ut_metadata.t_anytype_elem_info_rec; - l_is_collection boolean; - begin - l_elements_info := ut_metadata.get_anytype_members_info( a_compound_data ); - l_is_collection := ut_metadata.is_collection(l_elements_info.type_code); - if l_elements_info.elements_count is null then - l_element_info := ut_metadata.get_attr_elem_info( a_compound_data ); - self.cursor_columns_info.extend; - self.cursor_columns_info(cursor_columns_info.last) := - ut_cursor_column( - l_elements_info.type_name, - l_elements_info.schema_name, - null, - l_elements_info.length, - a_parent_name, - a_level, - 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, - l_elements_info.precision, - l_elements_info.scale - ); - if l_element_info.attr_elt_type is not null then - desc_compound_data( - l_element_info.attr_elt_type, l_elements_info.type_name, - a_level + 1, a_access_path || '/' || l_elements_info.type_name - ); - end if; - else - while l_idx <= l_elements_info.elements_count loop - l_element_info := ut_metadata.get_attr_elem_info( a_compound_data, l_idx ); - - self.cursor_columns_info.extend; - self.cursor_columns_info(cursor_columns_info.last) := - ut_cursor_column( - l_element_info.attribute_name, - l_elements_info.schema_name, - null, - l_element_info.length, - a_parent_name, - a_level, - 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, - l_elements_info.precision, - l_elements_info.scale - ); - if l_element_info.attr_elt_type is not null then - desc_compound_data( - l_element_info.attr_elt_type, l_element_info.attribute_name, - a_level + 1, a_access_path || '/' || l_element_info.attribute_name - ); - end if; - l_idx := l_idx + 1; - end loop; - end if; - end; - - constructor function ut_cursor_details(self in out nocopy ut_cursor_details) return self as result is - begin - self.cursor_columns_info := ut_cursor_column_tab(); - return; - end; - - constructor function ut_cursor_details( - self in out nocopy ut_cursor_details, - a_cursor_number in number - ) return self as result is - l_columns_count pls_integer; - $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then - l_columns_desc dbms_sql.desc_tab3; - $else - l_columns_desc dbms_sql.desc_tab4; - $end - l_is_collection boolean; - 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); - - /** - * Due to a bug with object being part of cursor in ANYDATA scenario - * oracle fails to revert number to cursor. We ar using dbms_sql.close cursor to close it - * to avoid leaving open cursors behind. - * a_cursor := dbms_sql.to_refcursor(l_cursor_number); - **/ - for pos in 1 .. l_columns_count loop - l_is_collection := ut_metadata.is_collection( l_columns_desc(pos).col_schema_name, l_columns_desc(pos).col_type_name ); - self.cursor_columns_info.extend; - self.cursor_columns_info(self.cursor_columns_info.last) := - ut_cursor_column( - l_columns_desc(pos).col_name, - l_columns_desc(pos).col_schema_name, - l_columns_desc(pos).col_type_name, - l_columns_desc(pos).col_max_len, - null, - l_hierarchy_level, - 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, - 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 - desc_compound_data( - ut_metadata.get_user_defined_type( l_columns_desc(pos).col_schema_name, l_columns_desc(pos).col_type_name ), - l_columns_desc(pos).col_name, - l_hierarchy_level + 1, - l_columns_desc(pos).col_name - ); - end if; - end loop; - return; - end; - - member function contains_collection return boolean is - l_collection_elements number; - begin - select /*+ no_parallel */ count(1) into l_collection_elements - from table(cursor_columns_info) c - where c.is_collection = 1 and rownum = 1; - return l_collection_elements > 0; - end; - - 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 /*+ no_parallel */ 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.filter_path,'^/?'||fl.column_value||'($|/.*)' ) - ) - order by fl.column_value; - return l_result; - end; - - 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 - - --limit columns to those on the include items minus exclude items - if a_match_options.include.items.count > 0 then - -- if include - exclude = 0 then keep all columns - if a_match_options.include.items != a_match_options.exclude.items then - with included_columns as ( - select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names - from table(a_match_options.include.items) - minus - select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names - from table(a_match_options.exclude.items) - ) - select /*+ no_parallel */ value(x) - 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.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 ( - select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names - from table(a_match_options.exclude.items) - ) - select /*+ no_parallel */ value(x) - 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.filter_path,'^/?'||f.col_names||'($|/.*)' ) - ); - end if; - - --Rewrite column order after columns been excluded - for i in ( - select /*+ no_parallel */ 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; - - member function get_xml_children(a_parent_name varchar2 := null) return xmltype is - l_result xmltype; - begin - select /*+ no_parallel */ xmlagg(xmlelement(evalname t.column_name,t.column_type_name)) - into l_result - 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 /*+ no_parallel */ 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 deleted file mode 100644 index e7f9405eb..000000000 --- a/source/expectations/data_values/ut_cursor_details.tps +++ /dev/null @@ -1,41 +0,0 @@ -create or replace type ut_cursor_details authid current_user as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - 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 - ) return self as result, - member function equals(a_other ut_cursor_details, a_match_options ut_matcher_options) return boolean, - member procedure desc_compound_data( - self in out nocopy ut_cursor_details, - a_compound_data anytype, - a_parent_name in varchar2, - 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 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_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 deleted file mode 100644 index 6b1763dd0..000000000 --- a/source/expectations/data_values/ut_data_value.tpb +++ /dev/null @@ -1,67 +0,0 @@ -create or replace type body ut_data_value as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - order member function compare(a_other ut_data_value) return integer is - begin - return compare_implementation(a_other); - end; - - member function is_diffable return boolean is - begin - return false; - end; - - member function is_empty return boolean is - begin - raise value_error; - end; - - member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2 is - begin - return null; - end; - - member function is_multi_line return boolean is - begin - return false; - end; - - member function get_object_info return varchar2 is - begin - return self.data_type; - end; - - final member function to_string_report(a_add_new_line_for_multi_line boolean := false, a_with_object_info boolean := true) return varchar2 is - l_result varchar2(32767); - l_info varchar2(32767); - begin - if a_with_object_info then - l_info := '('||get_object_info()||')'; - end if; - if self.is_multi_line() then - l_result := - l_info || chr(10) || ut_utils.indent_lines( rtrim(self.to_string(),chr(10)), a_include_first_line =>true ); - if a_add_new_line_for_multi_line then - l_result := l_result || chr(10); - end if; - else - l_result := self.to_string() || ' ' || l_info; - end if; - return l_result; - end; -end; -/ diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps deleted file mode 100644 index beda3d911..000000000 --- a/source/expectations/data_values/ut_data_value.tps +++ /dev/null @@ -1,32 +0,0 @@ -create or replace type ut_data_value force authid current_user as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_type varchar2(250 char), - data_type_plsql varchar2(250 char), - self_type varchar2(250 char), - not instantiable member function is_null return boolean, - not instantiable member function to_string return varchar2, - member function get_object_info return varchar2, - member function is_multi_line return boolean, - final member function to_string_report(a_add_new_line_for_multi_line boolean := false, a_with_object_info boolean := true) return varchar2, - order member function compare( a_other ut_data_value ) return integer, - member function is_diffable return boolean, - member function is_empty return boolean, - member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2, - not instantiable member function compare_implementation( a_other ut_data_value ) return integer -) not final not instantiable -/ diff --git a/source/expectations/data_values/ut_data_value_anydata.tpb b/source/expectations/data_values/ut_data_value_anydata.tpb deleted file mode 100644 index f6fbdc840..000000000 --- a/source/expectations/data_values/ut_data_value_anydata.tpb +++ /dev/null @@ -1,142 +0,0 @@ -create or replace type body ut_data_value_anydata as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - overriding member function get_object_info return varchar2 is - begin - return self.data_type || case when self.compound_type = 'collection' then self.get_elements_count_info() end; - end; - - member function get_extract_path(a_data_value anydata) return varchar2 is - l_path varchar2(10); - begin - if self.compound_type = 'object' then - l_path := '/*/*'; - else - case when ut_metadata.has_collection_members(a_data_value) then - l_path := '/*/*'; - else - l_path := '/*'; - end case; - end if; - return l_path; - end; - - member function get_cursor_sql_from_anydata(a_data_value anydata) return varchar2 is - l_cursor_sql varchar2(32767); - begin - l_cursor_sql := ' - declare - l_data '||self.data_type||'; - l_value anydata := :a_value; - l_status integer; - l_tmp_refcursor sys_refcursor; - begin - l_status := l_value.get'||self.compound_type||'(l_data); '|| - case when self.compound_type = 'collection' then - q'[ open :l_tmp_refcursor for select /*+ no_parallel */ value(x) as "]'|| - ut_metadata.get_object_name(ut_metadata.get_collection_element(a_data_value))|| - q'[" from table(l_data) x;]' - else - q'[ open :l_tmp_refcursor for select /*+ no_parallel */ l_data as "]'||ut_metadata.get_object_name(self.data_type)|| - q'[" from dual;]' - end || - 'end;'; - return l_cursor_sql; - end; - - member procedure init(self in out nocopy ut_data_value_anydata, a_value anydata) is - l_refcursor sys_refcursor; - cursor_not_open exception; - l_cursor_number number; - l_anydata_sql varchar2(32767); - begin - self.data_type := ut_metadata.get_anydata_typename(a_value); - self.compound_type := get_instance(a_value); - self.is_data_null := ut_metadata.is_anytype_null(a_value,self.compound_type); - self.data_id := sys_guid(); - self.self_type := $$plsql_unit; - self.cursor_details := ut_cursor_details(); - - ut_compound_data_helper.cleanup_diff; - - if not self.is_null() then - self.extract_path := get_extract_path(a_value); - l_anydata_sql := get_cursor_sql_from_anydata(a_value); - execute immediate l_anydata_sql using in a_value, in out l_refcursor; - if l_refcursor%isopen then - 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; - end if; - end if; - exception - when cursor_not_open then - raise_application_error(-20155, 'Cursor is not open'); - when others then - if l_refcursor%isopen then - close l_refcursor; - end if; - raise; - end; - - member function get_instance(a_data_value anydata) return varchar2 is - l_result varchar2(30); - begin - l_result := ut_metadata.get_anydata_compound_type(a_data_value); - if l_result not in ('object','collection') then - raise_application_error(-20000, 'Data type '||a_data_value.gettypename||' in ANYDATA is not supported by utPLSQL'); - end if; - return l_result; - end; - - constructor function ut_data_value_anydata(self in out nocopy ut_data_value_anydata, a_value anydata) return self as result - is - begin - init(a_value); - return; - end; - - overriding member function compare_implementation( - a_other ut_data_value, - a_match_options ut_matcher_options, - a_inclusion_compare boolean := false, - a_is_negated boolean := false - ) return integer is - l_result integer := 0; - begin - if not a_other is of (ut_data_value_anydata) then - raise value_error; - end if; - l_result := l_result + (self as ut_data_value_refcursor).compare_implementation(a_other,a_match_options,a_inclusion_compare,a_is_negated); - return l_result; - end; - - overriding member function is_empty return boolean is - begin - if self.compound_type = 'collection' then - return self.elements_count = 0; - else - raise value_error; - end if; - end; -end; -/ diff --git a/source/expectations/data_values/ut_data_value_anydata.tps b/source/expectations/data_values/ut_data_value_anydata.tps deleted file mode 100644 index 60dba5515..000000000 --- a/source/expectations/data_values/ut_data_value_anydata.tps +++ /dev/null @@ -1,33 +0,0 @@ -create or replace type ut_data_value_anydata under ut_data_value_refcursor( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - overriding member function get_object_info return varchar2, - member function get_extract_path(a_data_value anydata) return varchar2, - member function get_cursor_sql_from_anydata(a_data_value anydata) return varchar2, - member procedure init(self in out nocopy ut_data_value_anydata, a_value anydata), - member function get_instance(a_data_value anydata) return varchar2, - constructor function ut_data_value_anydata(self in out nocopy ut_data_value_anydata, a_value anydata) return self as result, - overriding member function compare_implementation( - a_other ut_data_value, - a_match_options ut_matcher_options, - a_inclusion_compare boolean := false, - a_is_negated boolean := false - ) return integer, - overriding member function is_empty return boolean -) -/ diff --git a/source/expectations/data_values/ut_data_value_blob.tpb b/source/expectations/data_values/ut_data_value_blob.tpb deleted file mode 100644 index e145a8d4f..000000000 --- a/source/expectations/data_values/ut_data_value_blob.tpb +++ /dev/null @@ -1,63 +0,0 @@ -create or replace type body ut_data_value_blob as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_blob(self in out nocopy ut_data_value_blob, a_value blob) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'blob'; - self.data_type_plsql := 'blob'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function is_empty return boolean is - l_result boolean := false; - begin - if self.data_value is not null and dbms_lob.compare( self.data_value, empty_blob()) = 0 then - l_result := true; - end if; - return l_result; - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_blob; - begin - if a_other is of (ut_data_value_blob) then - l_other := treat(a_other as ut_data_value_blob); - l_result := dbms_lob.compare( self.data_value, l_other.data_value); - end if; - return l_result; - end; - - overriding member function is_multi_line return boolean is - begin - return not self.is_null() and dbms_lob.getlength(self.data_value) > 100; - end; -end; -/ diff --git a/source/expectations/data_values/ut_data_value_blob.tps b/source/expectations/data_values/ut_data_value_blob.tps deleted file mode 100644 index 6df3f3273..000000000 --- a/source/expectations/data_values/ut_data_value_blob.tps +++ /dev/null @@ -1,26 +0,0 @@ -create or replace type ut_data_value_blob under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 blob, - constructor function ut_data_value_blob(self in out nocopy ut_data_value_blob, a_value blob) 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 is_multi_line return boolean, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_boolean.tpb b/source/expectations/data_values/ut_data_value_boolean.tpb deleted file mode 100644 index 867c3c19c..000000000 --- a/source/expectations/data_values/ut_data_value_boolean.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_data_value_boolean as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_boolean(self in out nocopy ut_data_value_boolean, a_value boolean) return self as result is - begin - self.data_value := ut_utils.boolean_to_int(a_value); - self.self_type := $$plsql_unit; - self.data_type := 'boolean'; - self.data_type_plsql := 'boolean'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(ut_utils.int_to_boolean(self.data_value)); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_other ut_data_value_boolean; - l_result integer; - begin - if a_other is of (ut_data_value_boolean) then - l_other := treat(a_other as ut_data_value_boolean); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_boolean.tps b/source/expectations/data_values/ut_data_value_boolean.tps deleted file mode 100644 index e25b6e0fd..000000000 --- a/source/expectations/data_values/ut_data_value_boolean.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_boolean under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 number(1,0), --holds int representation of boolean - constructor function ut_data_value_boolean(self in out nocopy ut_data_value_boolean, a_value boolean) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_clob.tpb b/source/expectations/data_values/ut_data_value_clob.tpb deleted file mode 100644 index f8a53a035..000000000 --- a/source/expectations/data_values/ut_data_value_clob.tpb +++ /dev/null @@ -1,64 +0,0 @@ -create or replace type body ut_data_value_clob as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_clob(self in out nocopy ut_data_value_clob, a_value clob) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'clob'; - self.data_type_plsql := 'clob'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function is_empty return boolean is - l_result boolean := false; - begin - if self.data_value is not null and dbms_lob.compare( self.data_value, empty_clob()) = 0 then - l_result := true; - end if; - return l_result; - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_clob; - begin - if a_other is of (ut_data_value_clob) then - l_other := treat(a_other as ut_data_value_clob); - l_result := dbms_lob.compare( self.data_value, l_other.data_value); - end if; - return l_result; - end; - - overriding member function is_multi_line return boolean is - begin - return not self.is_null() and (dbms_lob.getlength(self.data_value) > 100 or dbms_lob.instr(self.data_value,chr(10)) > 0); - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_clob.tps b/source/expectations/data_values/ut_data_value_clob.tps deleted file mode 100644 index 6869798d1..000000000 --- a/source/expectations/data_values/ut_data_value_clob.tps +++ /dev/null @@ -1,26 +0,0 @@ -create or replace type ut_data_value_clob under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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, - constructor function ut_data_value_clob(self in out nocopy ut_data_value_clob, a_value clob) 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 is_multi_line return boolean, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_date.tpb b/source/expectations/data_values/ut_data_value_date.tpb deleted file mode 100644 index 20424d193..000000000 --- a/source/expectations/data_values/ut_data_value_date.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_data_value_date as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_date(self in out nocopy ut_data_value_date, a_value date) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'date'; - self.data_type_plsql := 'date'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_date; - begin - if a_other is of (ut_data_value_date) then - l_other := treat(a_other as ut_data_value_date); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_date.tps b/source/expectations/data_values/ut_data_value_date.tps deleted file mode 100644 index f64a577e0..000000000 --- a/source/expectations/data_values/ut_data_value_date.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_date under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 date, - constructor function ut_data_value_date(self in out nocopy ut_data_value_date, a_value date) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tpb b/source/expectations/data_values/ut_data_value_dsinterval.tpb deleted file mode 100644 index 026d4970f..000000000 --- a/source/expectations/data_values/ut_data_value_dsinterval.tpb +++ /dev/null @@ -1,56 +0,0 @@ -create or replace type body ut_data_value_dsinterval as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_dsinterval(self in out nocopy ut_data_value_dsinterval, a_value dsinterval_unconstrained) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'interval day to second'; - self.data_type_plsql := 'dsinterval_unconstrained'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.interval_to_text(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_dsinterval; - begin - if a_other is of (ut_data_value_dsinterval) then - l_other := treat(a_other as ut_data_value_dsinterval); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tps b/source/expectations/data_values/ut_data_value_dsinterval.tps deleted file mode 100644 index 6f5cb708c..000000000 --- a/source/expectations/data_values/ut_data_value_dsinterval.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_dsinterval under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 interval day(9) to second(9), - constructor function ut_data_value_dsinterval(self in out nocopy ut_data_value_dsinterval, a_value dsinterval_unconstrained) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_json.tpb b/source/expectations/data_values/ut_data_value_json.tpb deleted file mode 100644 index b703af181..000000000 --- a/source/expectations/data_values/ut_data_value_json.tpb +++ /dev/null @@ -1,174 +0,0 @@ -create or replace type body ut_data_value_json as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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; - - constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json) return self as result is - l_value json_element_t := ut_compound_data_helper.get_json_object(a_value); - begin - init(l_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_utils.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_id raw) 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_id); - 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_utils.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_diff_id)||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; - - if l_result != empty_clob() then - l_result_string := chr(10) || 'Diff:' || ut_utils.to_string(l_result,null); - end if; - 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_utils.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_utils.get_hash(self.data_id||l_other.data_id); - l_result := - case - when ut_compound_data_helper.insert_json_diffs( - l_diff_id, l_other.json_tree.json_tree_info, self.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 deleted file mode 100644 index 3b77e54eb..000000000 --- a/source/expectations/data_values/ut_data_value_json.tps +++ /dev/null @@ -1,33 +0,0 @@ -create or replace type ut_data_value_json under ut_compound_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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, - constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json) 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 deleted file mode 100644 index 382e6e9aa..000000000 --- a/source/expectations/data_values/ut_data_value_number.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_data_value_number as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_number(self in out nocopy ut_data_value_number, a_value number) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'number'; - self.data_type_plsql := 'number'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_number; - begin - if a_other is of (ut_data_value_number) then - l_other := treat(a_other as ut_data_value_number); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_number.tps b/source/expectations/data_values/ut_data_value_number.tps deleted file mode 100644 index 86d68f356..000000000 --- a/source/expectations/data_values/ut_data_value_number.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_number under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 number, - constructor function ut_data_value_number(self in out nocopy ut_data_value_number, a_value number) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb deleted file mode 100644 index a4f0cf7a0..000000000 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ /dev/null @@ -1,396 +0,0 @@ -create or replace type body ut_data_value_refcursor as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) - return self as result is - begin - init(a_value); - return; - end; - - member procedure extract_cursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) - is - c_bulk_rows constant integer := 10000; - l_cursor sys_refcursor := a_value; - l_ctx number; - l_xml xmltype; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_set_id integer := 0; - l_elements_count number := 0; - begin - -- We use DBMS_XMLGEN in order to: - -- 1) be able to process data in bulks (set of rows) - -- 2) be able to influence the ROWSET/ROW tags - -- 3) be able to influence the way NULL values are handled (empty TAG) - -- 4) be able to influence the way TIMESTAMP is formatted. - -- Due to Oracle feature/bug, it is not possible to change the DATE formatting of cursor data - -- AFTER the cursor was opened. - -- The only solution for this is to change NLS settings before opening the cursor. - -- - -- This would work fine if we could use DBMS_XMLGEN.restartQuery. - -- The restartQuery fails however if PLSQL variables of TIMESTAMP/INTERVAL or CLOB/BLOB are used. - ut_expectation_processor.set_xml_nls_params(); - l_ctx := dbms_xmlgen.newContext(l_cursor); - 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); - 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); - end if; - return l_result_string; - 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_refcursor; - l_self ut_data_value_refcursor := self; - l_column_diffs ut_compound_data_helper.tt_column_diffs; - - l_other_cols ut_cursor_column_tab; - l_self_cols ut_cursor_column_tab; - - l_act_missing_pk ut_varchar2_list := ut_varchar2_list(); - l_exp_missing_pk ut_varchar2_list := ut_varchar2_list(); - - c_max_rows integer := ut_utils.gc_diff_max_rows; - l_diff_id ut_utils.t_hash; - l_diff_row_count integer; - l_row_diffs ut_compound_data_helper.tt_row_diffs; - l_message varchar2(32767); - - function get_col_diff_text(a_col ut_compound_data_helper.t_column_diffs) return varchar2 is - begin - return - case a_col.diff_type - when '-' then - ' Column <'||a_col.expected_name||'> [data-type: '||a_col.expected_type||'] is missing. Expected column position: '||a_col.expected_pos||'.' - when '+' then - ' Column <'||a_col.actual_name||'> [position: '||a_col.actual_pos||', data-type: '||a_col.actual_type||'] is not expected in results.' - when 't' then - ' Column <'||a_col.actual_name||'> data-type is invalid. Expected: '||a_col.expected_type||',' ||' actual: '||a_col.actual_type||'.' - when 'p' then - ' Column <'||a_col.actual_name||'> is misplaced. Expected position: '||a_col.expected_pos||',' ||' actual position: '||a_col.actual_pos||'.' - end; - end; - - function remove_incomparable_cols( - a_cursor_details ut_cursor_column_tab, a_column_diffs ut_compound_data_helper.tt_column_diffs - ) return ut_cursor_column_tab is - l_missing_cols ut_varchar2_list := ut_varchar2_list(); - l_result ut_cursor_column_tab; - begin - for i in 1 .. a_column_diffs.count loop - if a_column_diffs(i).diff_type in ('-','+') then - l_missing_cols.extend; - l_missing_cols(l_missing_cols.last) := coalesce(a_column_diffs(i).expected_name, a_column_diffs(i).actual_name); - end if; - end loop; - select /*+ no_parallel */ value(i) bulk collect into l_result - from table(a_cursor_details) i - where i.access_path not in ( - select c.column_value - from table(l_missing_cols) c - ); - return l_result; - end; - - function get_diff_message (a_row_diff ut_compound_data_helper.t_row_diffs, a_is_unordered boolean) return varchar2 is - begin - if a_is_unordered then - if a_row_diff.pk_value is not null then - return ' PK '||a_row_diff.pk_value||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; - else - return rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; - end if; - else - return ' Row No. '||a_row_diff.rn||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row; - end if; - end; - - begin - if not a_other is of (ut_data_value_refcursor) then - raise value_error; - end if; - l_other := treat(a_other as ut_data_value_refcursor); - l_other.cursor_details.filter_columns(a_match_options); - l_self.cursor_details.filter_columns(a_match_options); - - l_other_cols := l_other.cursor_details.cursor_columns_info; - l_self_cols := l_self.cursor_details.cursor_columns_info; - - dbms_lob.createtemporary(l_result,true); - --diff columns - if not l_self.is_null and not l_other.is_null then - l_column_diffs := ut_compound_data_helper.get_columns_diff( - l_self.cursor_details.cursor_columns_info, - l_other.cursor_details.cursor_columns_info, - a_match_options.ordered_columns() - ); - - if l_column_diffs is not empty then - ut_utils.append_to_clob(l_result,chr(10) || 'Columns:' || chr(10)); - l_other_cols := remove_incomparable_cols( l_other_cols, l_column_diffs ); - l_self_cols := remove_incomparable_cols( l_self_cols, l_column_diffs ); - for i in 1 .. l_column_diffs.count loop - l_results.extend; - l_results(l_results.last) := get_col_diff_text(l_column_diffs(i)); - end loop; - ut_utils.append_to_clob(l_result, l_results); - end if; - end if; - - --check for missing pk - if a_match_options.join_by.items.count > 0 then - l_act_missing_pk := l_other.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items ); - l_exp_missing_pk := l_self.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items ); - end if; - - --diff rows and row elements if the pk is not missing - if l_act_missing_pk.count + l_exp_missing_pk.count = 0 then - l_diff_id := ut_utils.get_hash( l_self.data_id || l_other.data_id ); - - -- First tell how many rows are different - l_diff_row_count := ut_compound_data_helper.get_rows_diff_count; - 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, - 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' - || case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end - ||' ]'||chr(10)|| case when l_row_diffs.count = 0 then ' All rows are different as the columns are not matching.' else null end; - ut_utils.append_to_clob( l_result, l_message ); - l_results := ut_utils.t_clob_tab(); - for i in 1 .. l_row_diffs.count loop - l_results.extend; - l_results(l_results.last) := get_diff_message(l_row_diffs(i),a_match_options.unordered); - end loop; - ut_utils.append_to_clob(l_result,l_results); - elsif l_column_diffs is not empty then - l_message:= chr(10)||'Rows: [ all different ]'||chr(10)||' All rows are different as the columns position is not matching.'; - ut_utils.append_to_clob( l_result, l_message ); - end if; - else - ut_utils.append_to_clob(l_result,chr(10) || 'Unable to join sets:' || chr(10)); - - for i in 1 .. l_exp_missing_pk.count loop - ut_utils.append_to_clob(l_result, ' Join key '||l_exp_missing_pk(i)||' does not exists in expected'||chr(10)); - end loop; - - for i in 1 .. l_act_missing_pk.count loop - ut_utils.append_to_clob(l_result, ' Join key '||l_act_missing_pk(i)||' does not exists in actual'||chr(10)); - end loop; - - if l_self.cursor_details.contains_collection() or l_other.cursor_details.contains_collection() then - ut_utils.append_to_clob(l_result,' Please make sure that your join clause is not refferring to collection element'|| chr(10)); - end if; - - end if; - if l_result != empty_clob() then - l_result_string := chr(10) || 'Diff:' || ut_utils.to_string(l_result,null); - end if; - dbms_lob.freetemporary(l_result); - return l_result_string; - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - begin - return compare_implementation( a_other, null ); - end; - - member function compare_implementation( - a_other ut_data_value, - a_match_options ut_matcher_options, - a_inclusion_compare boolean := false, - a_is_negated boolean := false - ) return integer is - l_result integer := 0; - l_self ut_data_value_refcursor := self; - l_other ut_data_value_refcursor; - l_diff_cursor_text clob; - - function compare_data( - a_self ut_data_value_refcursor, - a_other ut_data_value_refcursor, - a_diff_cursor_text clob - ) return integer is - l_diff_id ut_utils.t_hash; - l_result integer; - --We will start with number od differences being displayed. - l_cursor sys_refcursor; - l_diff_tab ut_compound_data_helper.t_diff_tab; - l_diif_rowcount integer :=0; - begin - l_diff_id := ut_utils.get_hash(a_self.data_id||a_other.data_id); - - begin - 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; - exception when others then - if l_cursor%isopen then - close l_cursor; - end if; - raise; - end; - - ut_compound_data_helper.insert_diffs_result( l_diff_tab, l_diff_id ); - --fetch rows for count only - loop - exit when l_diff_tab.count = 0; - l_diif_rowcount := l_diif_rowcount + l_diff_tab.count; - fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_bc_fetch_limit; - end loop; - - ut_compound_data_helper.set_rows_diff(l_diif_rowcount); - - --result is OK only if both are same - if l_diif_rowcount = 0 and a_self.is_null = a_other.is_null then - l_result := 0; - else - l_result := 1; - end if; - close l_cursor; - return l_result; - end; - begin - if not a_other is of (ut_data_value_refcursor) then - raise value_error; - end if; - - l_other := treat(a_other as ut_data_value_refcursor); - l_other.cursor_details.filter_columns( a_match_options ); - l_self.cursor_details.filter_columns( a_match_options ); - - if a_match_options.join_by.items.count > 0 then - l_result := - l_self.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items ).count - + l_other.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items ).count; - end if; - - if l_result = 0 then - if not l_self.is_null() and not l_other.is_null() and not l_self.cursor_details.equals( l_other.cursor_details, a_match_options ) then - l_result := 1; - end if; - l_diff_cursor_text := ut_compound_data_helper.gen_compare_sql( - l_other, - a_match_options.join_by.items, - a_match_options.unordered(), - a_inclusion_compare, - a_is_negated - ); - l_result := l_result + compare_data( l_self, l_other, l_diff_cursor_text ); - end if; - return l_result; - end; - - overriding member function is_empty return boolean is - begin - return self.elements_count = 0; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_refcursor.tps b/source/expectations/data_values/ut_data_value_refcursor.tps deleted file mode 100644 index 594695e32..000000000 --- a/source/expectations/data_values/ut_data_value_refcursor.tps +++ /dev/null @@ -1,52 +0,0 @@ -create or replace type ut_data_value_refcursor under ut_compound_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * Holds information about ref cursor to be processed by expectation - */ - - - /** - * Determines if the cursor is null - */ - is_cursor_null integer, - - /* - *columns info - */ - cursor_details ut_cursor_details, - - /* - * extract path of elements, important for collectiosn and objects - */ - extract_path varchar2(10), - - constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result, - member procedure extract_cursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), - member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor), - 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, - a_inclusion_compare boolean := false, - a_is_negated boolean := false - ) return integer, - overriding member function is_empty return boolean -) not final -/ diff --git a/source/expectations/data_values/ut_data_value_timestamp.tpb b/source/expectations/data_values/ut_data_value_timestamp.tpb deleted file mode 100644 index 318f799a3..000000000 --- a/source/expectations/data_values/ut_data_value_timestamp.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_data_value_timestamp as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_timestamp(self in out nocopy ut_data_value_timestamp, a_value timestamp_unconstrained) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'timestamp'; - self.data_type_plsql := 'timestamp_unconstrained'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_timestamp; - begin - if a_other is of (ut_data_value_timestamp) then - l_other := treat(a_other as ut_data_value_timestamp); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_timestamp.tps b/source/expectations/data_values/ut_data_value_timestamp.tps deleted file mode 100644 index c047e3c79..000000000 --- a/source/expectations/data_values/ut_data_value_timestamp.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_timestamp under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 timestamp(9), - constructor function ut_data_value_timestamp(self in out nocopy ut_data_value_timestamp, a_value timestamp_unconstrained) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb b/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb deleted file mode 100644 index 6127de5f1..000000000 --- a/source/expectations/data_values/ut_data_value_timestamp_ltz.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_data_value_timestamp_ltz as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_timestamp_ltz(self in out nocopy ut_data_value_timestamp_ltz, a_value timestamp_ltz_unconstrained) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'timestamp with local time zone'; - self.data_type_plsql := 'timestamp_ltz_unconstrained'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_timestamp_ltz; - begin - if a_other is of (ut_data_value_timestamp_ltz) then - l_other := treat(a_other as ut_data_value_timestamp_ltz); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_timestamp_ltz.tps b/source/expectations/data_values/ut_data_value_timestamp_ltz.tps deleted file mode 100644 index 7bb296bc9..000000000 --- a/source/expectations/data_values/ut_data_value_timestamp_ltz.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_timestamp_ltz under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 timestamp(9) with local time zone, - constructor function ut_data_value_timestamp_ltz(self in out nocopy ut_data_value_timestamp_ltz, a_value timestamp_ltz_unconstrained) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_timestamp_tz.tpb b/source/expectations/data_values/ut_data_value_timestamp_tz.tpb deleted file mode 100644 index d5d5cdd13..000000000 --- a/source/expectations/data_values/ut_data_value_timestamp_tz.tpb +++ /dev/null @@ -1,58 +0,0 @@ -create or replace type body ut_data_value_timestamp_tz as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_timestamp_tz(self in out nocopy ut_data_value_timestamp_tz, a_value timestamp_tz_unconstrained) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'timestamp with time zone'; - self.data_type_plsql := 'timestamp_tz_unconstrained'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_timestamp_tz; - begin - if a_other is of (ut_data_value_timestamp_tz) then - l_other := treat(a_other as ut_data_value_timestamp_tz); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_timestamp_tz.tps b/source/expectations/data_values/ut_data_value_timestamp_tz.tps deleted file mode 100644 index 01cf11124..000000000 --- a/source/expectations/data_values/ut_data_value_timestamp_tz.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_timestamp_tz under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 timestamp(9) with time zone, - constructor function ut_data_value_timestamp_tz(self in out nocopy ut_data_value_timestamp_tz, a_value timestamp_tz_unconstrained) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_varchar2.tpb b/source/expectations/data_values/ut_data_value_varchar2.tpb deleted file mode 100644 index d04398697..000000000 --- a/source/expectations/data_values/ut_data_value_varchar2.tpb +++ /dev/null @@ -1,63 +0,0 @@ -create or replace type body ut_data_value_varchar2 as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_varchar2(self in out nocopy ut_data_value_varchar2, a_value varchar2) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'varchar2'; - self.data_type_plsql := 'varchar2(32767)'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_varchar2; - begin - if a_other is of (ut_data_value_varchar2) then - l_other := treat(a_other as ut_data_value_varchar2); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - else - raise value_error; - end if; - return l_result; - end; - - overriding member function is_multi_line return boolean is - begin - return not self.is_null() and (length(self.data_value) > 100 or instr(self.data_value,chr(10)) > 0); - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_varchar2.tps b/source/expectations/data_values/ut_data_value_varchar2.tps deleted file mode 100644 index 3fbeb378b..000000000 --- a/source/expectations/data_values/ut_data_value_varchar2.tps +++ /dev/null @@ -1,25 +0,0 @@ -create or replace type ut_data_value_varchar2 under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 varchar2(32767 char), - constructor function ut_data_value_varchar2(self in out nocopy ut_data_value_varchar2, a_value varchar2) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function is_multi_line return boolean, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_xmltype.tpb b/source/expectations/data_values/ut_data_value_xmltype.tpb deleted file mode 100644 index 4b21a8937..000000000 --- a/source/expectations/data_values/ut_data_value_xmltype.tpb +++ /dev/null @@ -1,51 +0,0 @@ -create or replace type body ut_data_value_xmltype as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_xmltype(self in out nocopy ut_data_value_xmltype, a_value xmltype) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'xmltype'; - self.data_type_plsql := 'xmltype'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.to_string(self.data_value.getClobVal()); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_xmltype; - begin - if a_other is of (ut_data_value_xmltype) then - l_other := treat(a_other as ut_data_value_xmltype); - l_result := dbms_lob.compare(self.data_value.getClobVal(),l_other.data_value.getClobVal()); - end if; - - return l_result; - end; - -end; -/ diff --git a/source/expectations/data_values/ut_data_value_xmltype.tps b/source/expectations/data_values/ut_data_value_xmltype.tps deleted file mode 100644 index 9ba738b88..000000000 --- a/source/expectations/data_values/ut_data_value_xmltype.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_xmltype under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 xmltype, - constructor function ut_data_value_xmltype(self in out nocopy ut_data_value_xmltype, a_value xmltype) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_data_value_yminterval.tpb b/source/expectations/data_values/ut_data_value_yminterval.tpb deleted file mode 100644 index a3a1e7a2f..000000000 --- a/source/expectations/data_values/ut_data_value_yminterval.tpb +++ /dev/null @@ -1,55 +0,0 @@ -create or replace type body ut_data_value_yminterval as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_data_value_yminterval(self in out nocopy ut_data_value_yminterval, a_value yminterval_unconstrained) return self as result is - begin - self.data_value := a_value; - self.self_type := $$plsql_unit; - self.data_type := 'interval year to month'; - self.data_type_plsql := 'yminterval_unconstrained'; - return; - end; - - overriding member function is_null return boolean is - begin - return (self.data_value is null); - end; - - overriding member function to_string return varchar2 is - begin - return ut_utils.interval_to_text(self.data_value); - end; - - overriding member function compare_implementation(a_other ut_data_value) return integer is - l_result integer; - l_other ut_data_value_yminterval; - begin - if a_other is of (ut_data_value_yminterval) then - l_other := treat(a_other as ut_data_value_yminterval); - if self.data_value = l_other.data_value then - l_result := 0; - elsif self.data_value > l_other.data_value then - l_result := 1; - elsif self.data_value < l_other.data_value then - l_result := -1; - end if; - end if; - return l_result; - end; -end; -/ diff --git a/source/expectations/data_values/ut_data_value_yminterval.tps b/source/expectations/data_values/ut_data_value_yminterval.tps deleted file mode 100644 index c9ad2e776..000000000 --- a/source/expectations/data_values/ut_data_value_yminterval.tps +++ /dev/null @@ -1,24 +0,0 @@ -create or replace type ut_data_value_yminterval under ut_data_value( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 interval year(9) to month, - constructor function ut_data_value_yminterval(self in out nocopy ut_data_value_yminterval, a_value yminterval_unconstrained) return self as result, - overriding member function is_null return boolean, - overriding member function to_string return varchar2, - overriding member function compare_implementation(a_other ut_data_value) return integer -) -/ diff --git a/source/expectations/data_values/ut_json_data_diff_tmp.sql b/source/expectations/data_values/ut_json_data_diff_tmp.sql deleted file mode 100644 index 5ff3440d8..000000000 --- a/source/expectations/data_values/ut_json_data_diff_tmp.sql +++ /dev/null @@ -1,27 +0,0 @@ -create global temporary table ut_json_data_diff_tmp( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 delete rows; diff --git a/source/expectations/data_values/ut_json_leaf.tpb b/source/expectations/data_values/ut_json_leaf.tpb deleted file mode 100644 index 83f1009ef..000000000 --- a/source/expectations/data_values/ut_json_leaf.tpb +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 8aa8afd6a..000000000 --- a/source/expectations/data_values/ut_json_leaf.tps +++ /dev/null @@ -1,42 +0,0 @@ -create or replace type ut_json_leaf authid current_user as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 deleted file mode 100644 index 395ab5d9e..000000000 --- a/source/expectations/data_values/ut_json_leaf_tab.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_json_leaf_tab as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 deleted file mode 100644 index a333ea71c..000000000 --- a/source/expectations/data_values/ut_json_tree_details.tpb +++ /dev/null @@ -1,207 +0,0 @@ -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 deleted file mode 100644 index 20ac2fdcc..000000000 --- a/source/expectations/data_values/ut_json_tree_details.tps +++ /dev/null @@ -1,54 +0,0 @@ -create or replace type ut_json_tree_details force as object ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 deleted file mode 100644 index d1068f109..000000000 --- a/source/expectations/data_values/ut_key_anyval_pair.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_key_anyval_pair force as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - key varchar2(4000), - value ut_data_value -) not final -/ diff --git a/source/expectations/data_values/ut_key_anyval_pairs.tps b/source/expectations/data_values/ut_key_anyval_pairs.tps deleted file mode 100644 index 7e10bf50f..000000000 --- a/source/expectations/data_values/ut_key_anyval_pairs.tps +++ /dev/null @@ -1,19 +0,0 @@ -create or replace type ut_key_anyval_pairs as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_key_anyval_pair -/ diff --git a/source/expectations/data_values/ut_key_anyvalues.tpb b/source/expectations/data_values/ut_key_anyvalues.tpb deleted file mode 100644 index d30d8a841..000000000 --- a/source/expectations/data_values/ut_key_anyvalues.tpb +++ /dev/null @@ -1,90 +0,0 @@ -create or replace type body ut_key_anyvalues as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_key_anyvalues(self in out nocopy ut_key_anyvalues) return self as result is - begin - self.self_type := $$plsql_unit; - self.pairs := ut_key_anyval_pairs(); - return; - end; - member function put(a_item ut_key_anyval_pair) return ut_key_anyvalues is - l_result ut_key_anyvalues := self; - begin - l_result.pairs.extend(); - l_result.pairs(l_result.pairs.last) := a_item; - return l_result; - end; - member function put(a_key varchar2, a_value anydata) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_anydata(a_value))); - end; - - member function put(a_key varchar2, a_value blob) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_blob(a_value))); - end; - - member function put(a_key varchar2, a_value boolean) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_boolean(a_value))); - end; - - member function put(a_key varchar2, a_value clob) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_clob(a_value))); - end; - - member function put(a_key varchar2, a_value date) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_date(a_value))); - end; - - member function put(a_key varchar2, a_value number) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_number(a_value))); - end; - member function put(a_key varchar2, a_value timestamp_unconstrained) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_timestamp(a_value))); - end; - - member function put(a_key varchar2, a_value timestamp_ltz_unconstrained) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_timestamp_ltz(a_value))); - end; - - member function put(a_key varchar2, a_value timestamp_tz_unconstrained) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_timestamp_tz(a_value))); - end; - - member function put(a_key varchar2, a_value varchar2) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_varchar2(a_value))); - end; - - member function put(a_key varchar2, a_value yminterval_unconstrained) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_yminterval(a_value))); - end; - - member function put(a_key varchar2, a_value dsinterval_unconstrained) return ut_key_anyvalues is - begin - return put(ut_key_anyval_pair(a_key, ut_data_value_dsinterval(a_value))); - end; -end; -/ diff --git a/source/expectations/data_values/ut_key_anyvalues.tps b/source/expectations/data_values/ut_key_anyvalues.tps deleted file mode 100644 index 8c672bd00..000000000 --- a/source/expectations/data_values/ut_key_anyvalues.tps +++ /dev/null @@ -1,34 +0,0 @@ -create or replace type ut_key_anyvalues under ut_event_item ( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - pairs ut_key_anyval_pairs, - constructor function ut_key_anyvalues(self in out nocopy ut_key_anyvalues) return self as result, - member function put(a_item ut_key_anyval_pair) return ut_key_anyvalues, - member function put(a_key varchar2, a_value anydata) return ut_key_anyvalues, - member function put(a_key varchar2, a_value blob) return ut_key_anyvalues, - member function put(a_key varchar2, a_value boolean) return ut_key_anyvalues, - member function put(a_key varchar2, a_value clob) return ut_key_anyvalues, - member function put(a_key varchar2, a_value date) return ut_key_anyvalues, - member function put(a_key varchar2, a_value number) return ut_key_anyvalues, - member function put(a_key varchar2, a_value timestamp_unconstrained) return ut_key_anyvalues, - member function put(a_key varchar2, a_value timestamp_ltz_unconstrained) return ut_key_anyvalues, - member function put(a_key varchar2, a_value timestamp_tz_unconstrained) return ut_key_anyvalues, - member function put(a_key varchar2, a_value varchar2) return ut_key_anyvalues, - member function put(a_key varchar2, a_value yminterval_unconstrained) return ut_key_anyvalues, - member function put(a_key varchar2, a_value dsinterval_unconstrained) return ut_key_anyvalues -) -/ diff --git a/source/expectations/json_objects_specs.sql b/source/expectations/json_objects_specs.sql deleted file mode 100644 index a5d936afb..000000000 --- a/source/expectations/json_objects_specs.sql +++ /dev/null @@ -1,74 +0,0 @@ -BEGIN - null; - $if dbms_db_version.version < 21 $then - dbms_output.put_line('Installing json structures specs for native json.'); - execute immediate q'[create or replace TYPE JSON FORCE AUTHID CURRENT_USER AS OBJECT( - dummyobjt NUMBER -) NOT FINAL NOT INSTANTIABLE;]'; - $end - $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then - 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 deleted file mode 100644 index 6aea96f55..000000000 --- a/source/expectations/matchers/ut_be_between.tpb +++ /dev/null @@ -1,109 +0,0 @@ -create or replace type body ut_be_between is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_between, a_lower_bound ut_data_value, a_upper_bound ut_data_value) is - begin - self.self_type := $$plsql_unit; - self.lower_bound := a_lower_bound; - self.upper_bound := a_upper_bound; - end; - - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound date, a_upper_bound date) - return self as result is - begin - init(ut_data_value_date(a_lower_bound), ut_data_value_date(a_upper_bound)); - return; - end; - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound number, a_upper_bound number) - return self as result is - begin - init(ut_data_value_number(a_lower_bound), ut_data_value_number(a_upper_bound)); - return; - end; - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound varchar2, a_upper_bound varchar2) - return self as result is - begin - init(ut_data_value_varchar2(a_lower_bound), ut_data_value_varchar2(a_upper_bound)); - return; - end; - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) - return self as result is - begin - init(ut_data_value_timestamp(a_lower_bound), ut_data_value_timestamp(a_upper_bound)); - return; - end; - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) - return self as result is - begin - init(ut_data_value_timestamp_tz(a_lower_bound), ut_data_value_timestamp_tz(a_upper_bound)); - return; - end; - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) - return self as result is - begin - init(ut_data_value_timestamp_ltz(a_lower_bound), ut_data_value_timestamp_ltz(a_upper_bound)); - return; - end; - - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) - return self as result is - begin - init(ut_data_value_yminterval(a_lower_bound), ut_data_value_yminterval(a_upper_bound)); - return; - end; - - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) - return self as result is - begin - init(ut_data_value_dsinterval(a_lower_bound), ut_data_value_dsinterval(a_upper_bound)); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_between, a_actual ut_data_value) return boolean is - l_lower_result boolean; - l_upper_result boolean; - l_result boolean; - begin - if self.lower_bound.data_type = a_actual.data_type then - l_lower_result := a_actual >= self.lower_bound; - l_upper_result := a_actual <= self.upper_bound; - if l_lower_result is not null and l_upper_result is not null then - l_result := l_lower_result and l_upper_result; - end if; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message(a_actual) - || ': '|| self.lower_bound.to_string_report(true,false) - || ' and ' || self.upper_bound.to_string_report(a_with_object_info => false); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) - || ': '|| self.lower_bound.to_string_report(true,false) - || ' and ' || self.upper_bound.to_string_report(a_with_object_info => false); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_between.tps b/source/expectations/matchers/ut_be_between.tps deleted file mode 100644 index 9e984085b..000000000 --- a/source/expectations/matchers/ut_be_between.tps +++ /dev/null @@ -1,41 +0,0 @@ -create or replace type ut_be_between under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - lower_bound ut_data_value, - upper_bound ut_data_value, - member procedure init(self in out nocopy ut_be_between, a_lower_bound ut_data_value, a_upper_bound ut_data_value), - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound date, a_upper_bound date) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound number, a_upper_bound number) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound varchar2, a_upper_bound varchar2) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) - return self as result, - constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) - return self as result, - overriding member function run_matcher(self in out nocopy ut_be_between, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_be_empty.tpb b/source/expectations/matchers/ut_be_empty.tpb deleted file mode 100644 index e5e02f6b2..000000000 --- a/source/expectations/matchers/ut_be_empty.tpb +++ /dev/null @@ -1,40 +0,0 @@ -create or replace type body ut_be_empty as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_empty) is - begin - self.self_type := $$plsql_unit; - end; - - constructor function ut_be_empty(self in out nocopy ut_be_empty) return self as result is - begin - init(); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is - l_result boolean; - begin - return a_actual.is_empty(); - exception - when value_error then - return (self as ut_matcher).run_matcher(a_actual); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_empty.tps b/source/expectations/matchers/ut_be_empty.tps deleted file mode 100644 index 9e9f899d0..000000000 --- a/source/expectations/matchers/ut_be_empty.tps +++ /dev/null @@ -1,22 +0,0 @@ -create or replace type ut_be_empty under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_empty), - constructor function ut_be_empty(self in out nocopy ut_be_empty) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean -) -/ diff --git a/source/expectations/matchers/ut_be_false.tpb b/source/expectations/matchers/ut_be_false.tpb deleted file mode 100644 index 4cc88600a..000000000 --- a/source/expectations/matchers/ut_be_false.tpb +++ /dev/null @@ -1,37 +0,0 @@ -create or replace type body ut_be_false as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_false(self in out nocopy ut_be_false) return self as result is - begin - self.self_type := $$plsql_unit; - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_false, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if a_actual is of (ut_data_value_boolean) then - l_result := not ut_utils.int_to_boolean(treat(a_actual as ut_data_value_boolean).data_value); - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_false.tps b/source/expectations/matchers/ut_be_false.tps deleted file mode 100644 index ede510719..000000000 --- a/source/expectations/matchers/ut_be_false.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_be_false under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_false(self in out nocopy ut_be_false) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_false, a_actual ut_data_value) return boolean -) -/ diff --git a/source/expectations/matchers/ut_be_greater_or_equal.tpb b/source/expectations/matchers/ut_be_greater_or_equal.tpb deleted file mode 100644 index 1c2a19c09..000000000 --- a/source/expectations/matchers/ut_be_greater_or_equal.tpb +++ /dev/null @@ -1,89 +0,0 @@ -create or replace type body ut_be_greater_or_equal AS - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_greater_or_equal, a_expected ut_data_value) is - begin - self.self_type := $$plsql_unit; - self.expected := a_expected; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected date) return self as result is - begin - init(ut_data_value_date(a_expected)); - return; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected NUMBER) return self as result is - begin - init(ut_data_value_number(a_expected)); - return; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_unconstrained) return self as result is - begin - init(ut_data_value_timestamp(a_expected)); - return; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_tz_unconstrained) return self as result is - begin - init(ut_data_value_timestamp_tz(a_expected)); - return; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_ltz_unconstrained) return self as result is - begin - init(ut_data_value_timestamp_ltz(a_expected)); - return; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected yminterval_unconstrained) return self as RESULT IS - begin - init(ut_data_value_yminterval(a_expected)); - return; - end; - - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected dsinterval_unconstrained) return self as RESULT IS - begin - init(ut_data_value_dsinterval(a_expected)); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_greater_or_equal, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - l_result := a_actual >= self.expected; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report(); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_greater_or_equal.tps b/source/expectations/matchers/ut_be_greater_or_equal.tps deleted file mode 100644 index b3ab54ff1..000000000 --- a/source/expectations/matchers/ut_be_greater_or_equal.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_be_greater_or_equal under ut_comparison_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_greater_or_equal, a_expected ut_data_value), - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected date) return self as result, - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected number) return self as result, - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_unconstrained) return self as result, - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_tz_unconstrained) return self as result, - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_ltz_unconstrained) return self as result, - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected yminterval_unconstrained) return self as result, - constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected dsinterval_unconstrained) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_greater_or_equal, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_be_greater_than.tpb b/source/expectations/matchers/ut_be_greater_than.tpb deleted file mode 100644 index 9cce79119..000000000 --- a/source/expectations/matchers/ut_be_greater_than.tpb +++ /dev/null @@ -1,89 +0,0 @@ -create or replace type body ut_be_greater_than AS - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_greater_than, a_expected ut_data_value) is - begin - self.self_type := $$plsql_unit; - self.expected := a_expected; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected date) return self as result is - begin - init(ut_data_value_date(a_expected)); - return; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected NUMBER) return self as result is - begin - init(ut_data_value_number(a_expected)); - return; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_unconstrained) return self as result is - begin - init(ut_data_value_timestamp(a_expected)); - return; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_tz_unconstrained) return self as result is - begin - init(ut_data_value_timestamp_tz(a_expected)); - return; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_ltz_unconstrained) return self as result is - begin - init(ut_data_value_timestamp_ltz(a_expected)); - return; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected yminterval_unconstrained) return self as RESULT IS - begin - init(ut_data_value_yminterval(a_expected)); - return; - end; - - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected dsinterval_unconstrained) return self as RESULT IS - begin - init(ut_data_value_dsinterval(a_expected)); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_greater_than, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - l_result := a_actual > self.expected; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report(); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_greater_than.tps b/source/expectations/matchers/ut_be_greater_than.tps deleted file mode 100644 index a5a44692d..000000000 --- a/source/expectations/matchers/ut_be_greater_than.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_be_greater_than under ut_comparison_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_greater_than, a_expected ut_data_value), - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected date) return self as result, - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected number) return self as result, - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_unconstrained) return self as result, - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_tz_unconstrained) return self as result, - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_ltz_unconstrained) return self as result, - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected yminterval_unconstrained) return self as result, - constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected dsinterval_unconstrained) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_greater_than, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_be_less_or_equal.tpb b/source/expectations/matchers/ut_be_less_or_equal.tpb deleted file mode 100644 index 6acec1dda..000000000 --- a/source/expectations/matchers/ut_be_less_or_equal.tpb +++ /dev/null @@ -1,89 +0,0 @@ -create or replace type body ut_be_less_or_equal AS - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_less_or_equal, a_expected ut_data_value) is - begin - self.self_type := $$plsql_unit; - self.expected := a_expected; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected date) return self as result is - begin - init(ut_data_value_date(a_expected)); - return; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected NUMBER) return self as result is - begin - init(ut_data_value_number(a_expected)); - return; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_unconstrained) return self as result is - begin - init(ut_data_value_timestamp(a_expected)); - return; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_tz_unconstrained) return self as result is - begin - init(ut_data_value_timestamp_tz(a_expected)); - return; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_ltz_unconstrained) return self as result is - begin - init(ut_data_value_timestamp_ltz(a_expected)); - return; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected yminterval_unconstrained) return self as RESULT IS - begin - init(ut_data_value_yminterval(a_expected)); - return; - end; - - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected dsinterval_unconstrained) return self as RESULT IS - begin - init(ut_data_value_dsinterval(a_expected)); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_less_or_equal, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - l_result := a_actual <= self.expected; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report(); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_less_or_equal.tps b/source/expectations/matchers/ut_be_less_or_equal.tps deleted file mode 100644 index 118611a41..000000000 --- a/source/expectations/matchers/ut_be_less_or_equal.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_be_less_or_equal under ut_comparison_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_less_or_equal, a_expected ut_data_value), - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected date) return self as result, - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected number) return self as result, - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_unconstrained) return self as result, - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_tz_unconstrained) return self as result, - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_ltz_unconstrained) return self as result, - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected yminterval_unconstrained) return self as result, - constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected dsinterval_unconstrained) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_less_or_equal, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_be_less_than.tpb b/source/expectations/matchers/ut_be_less_than.tpb deleted file mode 100644 index 7608e4917..000000000 --- a/source/expectations/matchers/ut_be_less_than.tpb +++ /dev/null @@ -1,94 +0,0 @@ -create or replace type body ut_be_less_than as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_less_than, a_expected ut_data_value) is - begin - self.self_type := $$plsql_unit; - self.expected := a_expected; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected date) return self as result is - begin - init(ut_data_value_date(a_expected)); - return; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected number) return self as result is - begin - init(ut_data_value_number(a_expected)); - return; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_unconstrained) - return self as result is - begin - init(ut_data_value_timestamp(a_expected)); - return; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_tz_unconstrained) - return self as result is - begin - init(ut_data_value_timestamp_tz(a_expected)); - return; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_ltz_unconstrained) - return self as result is - begin - init(ut_data_value_timestamp_ltz(a_expected)); - return; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected yminterval_unconstrained) - return self as result is - begin - init(ut_data_value_yminterval(a_expected)); - return; - end; - - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected dsinterval_unconstrained) - return self as result is - begin - init(ut_data_value_dsinterval(a_expected)); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_less_than, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - l_result := a_actual < self.expected; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report(); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_less_than.tps b/source/expectations/matchers/ut_be_less_than.tps deleted file mode 100644 index b652de789..000000000 --- a/source/expectations/matchers/ut_be_less_than.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_be_less_than under ut_comparison_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_less_than, a_expected ut_data_value), - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected date) return self as result, - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected number) return self as result, - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_unconstrained) return self as result, - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_tz_unconstrained) return self as result, - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_ltz_unconstrained) return self as result, - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected yminterval_unconstrained) return self as result, - constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected dsinterval_unconstrained) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_less_than, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_be_like.tpb b/source/expectations/matchers/ut_be_like.tpb deleted file mode 100644 index 6865c2942..000000000 --- a/source/expectations/matchers/ut_be_like.tpb +++ /dev/null @@ -1,75 +0,0 @@ -create or replace type body ut_be_like as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_like(self in out nocopy ut_be_like, a_mask in varchar2, a_escape_char in varchar2 := null) return self as result is - begin - self.self_type := $$plsql_unit; - self.mask := a_mask; - self.escape_char := a_escape_char; - return; - end ut_be_like; - - overriding member function run_matcher(self in out nocopy ut_be_like, a_actual ut_data_value) return boolean is - l_value clob; - l_result boolean; - begin - if a_actual is of (ut_data_value_varchar2, ut_data_value_clob) then - - if a_actual is of (ut_data_value_varchar2) then - l_value := treat(a_actual as ut_data_value_varchar2).data_value; - else - l_value := treat(a_actual as ut_data_value_clob).data_value; - end if; - - if escape_char is not null then - l_result := l_value like mask escape escape_char; - else - l_result := l_value like mask; - end if; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end run_matcher; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - l_result := (self as ut_matcher).failure_message(a_actual); - if self.escape_char is not null then - l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(true, false) || ', escape ''' || self.escape_char ||''''; - else - l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(false, false); - end if; - return l_result; - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - l_result := (self as ut_matcher).failure_message_when_negated(a_actual); - if self.escape_char is not null then - l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(true, false) || ', escape ''' || self.escape_char ||''''; - else - l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(false, false); - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_like.tps b/source/expectations/matchers/ut_be_like.tps deleted file mode 100644 index dae93a1d9..000000000 --- a/source/expectations/matchers/ut_be_like.tps +++ /dev/null @@ -1,25 +0,0 @@ -create or replace type ut_be_like under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - mask varchar2(4000), - escape_char varchar2(1), - constructor function ut_be_like(self in out nocopy ut_be_like, a_mask in varchar2, a_escape_char in varchar2 := null) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_like, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_be_not_null.tpb b/source/expectations/matchers/ut_be_not_null.tpb deleted file mode 100644 index 194e2ea32..000000000 --- a/source/expectations/matchers/ut_be_not_null.tpb +++ /dev/null @@ -1,31 +0,0 @@ -create or replace type body ut_be_not_null as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_not_null(self in out nocopy ut_be_not_null) return self as result is - begin - self.self_type := $$plsql_unit; - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_not_null, a_actual ut_data_value) return boolean is - begin - return not a_actual.is_null; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_not_null.tps b/source/expectations/matchers/ut_be_not_null.tps deleted file mode 100644 index 196aac9fb..000000000 --- a/source/expectations/matchers/ut_be_not_null.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_be_not_null under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_not_null(self in out nocopy ut_be_not_null) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_not_null, a_actual ut_data_value) return boolean -) -/ diff --git a/source/expectations/matchers/ut_be_null.tpb b/source/expectations/matchers/ut_be_null.tpb deleted file mode 100644 index 8c672791b..000000000 --- a/source/expectations/matchers/ut_be_null.tpb +++ /dev/null @@ -1,31 +0,0 @@ -create or replace type body ut_be_null as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_null(self in out nocopy ut_be_null) return self as result is - begin - self.self_type := $$plsql_unit; - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_null, a_actual ut_data_value) return boolean is - begin - return a_actual.is_null; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_null.tps b/source/expectations/matchers/ut_be_null.tps deleted file mode 100644 index 3b2d6ac84..000000000 --- a/source/expectations/matchers/ut_be_null.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_be_null under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_null(self in out nocopy ut_be_null) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_null, a_actual ut_data_value) return boolean -) -/ diff --git a/source/expectations/matchers/ut_be_true.tpb b/source/expectations/matchers/ut_be_true.tpb deleted file mode 100644 index fe78b4e22..000000000 --- a/source/expectations/matchers/ut_be_true.tpb +++ /dev/null @@ -1,37 +0,0 @@ -create or replace type body ut_be_true as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_true(self in out nocopy ut_be_true) return self as result is - begin - self.self_type := $$plsql_unit; - return; - end; - - overriding member function run_matcher(self in out nocopy ut_be_true, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if a_actual is of (ut_data_value_boolean) then - l_result := ut_utils.int_to_boolean( treat(a_actual as ut_data_value_boolean).data_value); - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_true.tps b/source/expectations/matchers/ut_be_true.tps deleted file mode 100644 index 8b5491e39..000000000 --- a/source/expectations/matchers/ut_be_true.tps +++ /dev/null @@ -1,21 +0,0 @@ -create or replace type ut_be_true under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_be_true(self in out nocopy ut_be_true) return self as result, - overriding member function run_matcher(self in out nocopy ut_be_true, a_actual ut_data_value) return boolean -) -/ diff --git a/source/expectations/matchers/ut_be_within.tpb b/source/expectations/matchers/ut_be_within.tpb deleted file mode 100644 index e2aa792d0..000000000 --- a/source/expectations/matchers/ut_be_within.tpb +++ /dev/null @@ -1,137 +0,0 @@ -create or replace type body ut_be_within 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_be_within(self in out nocopy ut_be_within, a_distance_from_expected number) return self as result is - begin - self.init(ut_data_value_number(a_distance_from_expected), $$plsql_unit); - return; - end; - - constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained) return self as result is - begin - self.init(ut_data_value_dsinterval(a_distance_from_expected), $$plsql_unit); - return; - end; - - constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained) return self as result is - begin - self.init(ut_data_value_yminterval(a_distance_from_expected), $$plsql_unit); - return; - end; - - member procedure of_(self in ut_be_within, a_expected date) is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_date(a_expected); - if l_result.is_negated_flag = 1 then - l_result.expectation.not_to(l_result); - else - l_result.expectation.to_(l_result); - end if; - end; - - member function of_(self in ut_be_within, a_expected date) return ut_be_within is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_date(a_expected); - return l_result; - end; - - member procedure of_(self in ut_be_within, a_expected timestamp_unconstrained) is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_timestamp(a_expected); - if l_result.is_negated_flag = 1 then - l_result.expectation.not_to(l_result); - else - l_result.expectation.to_(l_result); - end if; - end; - - member function of_(self in ut_be_within, a_expected timestamp_unconstrained) return ut_be_within is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_timestamp(a_expected); - return l_result; - end; - - member procedure of_(self in ut_be_within, a_expected timestamp_tz_unconstrained) is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_timestamp_tz(a_expected); - if l_result.is_negated_flag = 1 then - l_result.expectation.not_to(l_result); - else - l_result.expectation.to_(l_result); - end if; - end; - - member function of_(self in ut_be_within, a_expected timestamp_tz_unconstrained) return ut_be_within is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_timestamp_tz(a_expected); - return l_result; - end; - - member procedure of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained) is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_timestamp_ltz(a_expected); - if l_result.is_negated_flag = 1 then - l_result.expectation.not_to(l_result); - else - l_result.expectation.to_(l_result); - end if; - end; - - member function of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained) return ut_be_within is - l_result ut_be_within := self; - begin - l_result.expected := ut_data_value_timestamp_ltz(a_expected); - return l_result; - end; - - overriding member function run_matcher(self in out nocopy ut_be_within, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type - and ( - self.expected is of (ut_data_value_date, ut_data_value_timestamp, ut_data_value_timestamp_tz, ut_data_value_timestamp_ltz) - and self.distance_from_expected is of (ut_data_value_yminterval, ut_data_value_dsinterval) - or self.expected is of (ut_data_value_number) and self.distance_from_expected is of (ut_data_value_number) - ) - then - l_result := ut_be_within_helper.values_within_abs_distance( a_actual, self.expected, self.distance_from_expected) ; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message(a_actual) || ' '||self.distance_from_expected.to_string ||' of '|| expected.to_string_report(); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ' '||self.distance_from_expected.to_string ||' of '|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_within.tps b/source/expectations/matchers/ut_be_within.tps deleted file mode 100644 index 576f9ff37..000000000 --- a/source/expectations/matchers/ut_be_within.tps +++ /dev/null @@ -1,36 +0,0 @@ -create or replace type ut_be_within force under ut_be_within_pct( - /* - 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_be_within(self in out nocopy ut_be_within, a_distance_from_expected number) return self as result, - constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected dsinterval_unconstrained) return self as result, - constructor function ut_be_within(self in out nocopy ut_be_within, a_distance_from_expected yminterval_unconstrained) return self as result, - member procedure of_(self in ut_be_within, a_expected date), - member function of_(self in ut_be_within, a_expected date) return ut_be_within, - member procedure of_(self in ut_be_within, a_expected timestamp_unconstrained), - member function of_(self in ut_be_within, a_expected timestamp_unconstrained) return ut_be_within, - member procedure of_(self in ut_be_within, a_expected timestamp_tz_unconstrained ), - member function of_(self in ut_be_within, a_expected timestamp_tz_unconstrained) return ut_be_within, - member procedure of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained), - member function of_(self in ut_be_within, a_expected timestamp_ltz_unconstrained) return ut_be_within, - overriding member function run_matcher(self in out nocopy ut_be_within, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -not final -/ diff --git a/source/expectations/matchers/ut_be_within_helper.pkb b/source/expectations/matchers/ut_be_within_helper.pkb deleted file mode 100644 index 5dd82baa2..000000000 --- a/source/expectations/matchers/ut_be_within_helper.pkb +++ /dev/null @@ -1,55 +0,0 @@ -create or replace package body ut_be_within_helper 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. - */ - - function values_within_abs_distance( - a_actual ut_data_value, a_expected ut_data_value, a_distance ut_data_value - ) return boolean is - l_result integer; - l_YM_conversion varchar2(50) := case when a_distance is of (ut_data_value_yminterval) then ' year to month ' end; - l_formula varchar2(4000); - l_code varchar2(4000); - begin - l_formula := - case - when a_actual is of (ut_data_value_date) - then '( cast(greatest(l_actual, l_expected) as timestamp) - cast(least(l_actual, l_expected) as timestamp) ) '||l_YM_conversion||' <= l_distance' - else '( greatest(l_actual, l_expected) - least(l_actual, l_expected) ) '||l_YM_conversion||' <= l_distance' - end; - l_code := - q'[ - declare - l_actual ]'||dbms_assert.simple_sql_name(a_actual.data_type_plsql)|| q'[ := treat(:a_actual as ]'||dbms_assert.simple_sql_name(a_actual.self_type)||q'[).data_value; - l_expected ]'||dbms_assert.simple_sql_name(a_expected.data_type_plsql)||q'[ := treat(:a_expected as ]'||dbms_assert.simple_sql_name(a_expected.self_type)||q'[).data_value; - l_distance ]'||dbms_assert.simple_sql_name(a_distance.data_type_plsql)||q'[ := treat(:a_distance as ]'||dbms_assert.simple_sql_name(a_distance.self_type)||q'[).data_value; - begin - :result := - case - when - ]'||l_formula||q'[ - then 1 - else 0 - end; - end; - ]'; - execute immediate l_code - using a_actual, a_expected, a_distance, out l_result; - return l_result > 0; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_within_helper.pks b/source/expectations/matchers/ut_be_within_helper.pks deleted file mode 100644 index 41737cc8f..000000000 --- a/source/expectations/matchers/ut_be_within_helper.pks +++ /dev/null @@ -1,24 +0,0 @@ -create or replace package ut_be_within_helper authid definer 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. - */ - - function values_within_abs_distance( - a_actual ut_data_value, a_expected ut_data_value, a_distance ut_data_value - ) return boolean; - -end; -/ diff --git a/source/expectations/matchers/ut_be_within_pct.tpb b/source/expectations/matchers/ut_be_within_pct.tpb deleted file mode 100644 index 8b280ffff..000000000 --- a/source/expectations/matchers/ut_be_within_pct.tpb +++ /dev/null @@ -1,84 +0,0 @@ -create or replace type body ut_be_within_pct 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_be_within_pct(self in out nocopy ut_be_within_pct, a_pct_of_expected number) return self as result is - begin - self.init(ut_data_value_number(a_pct_of_expected), $$plsql_unit); - return; - end; - - member procedure init(self in out nocopy ut_be_within_pct, a_distance_from_expected ut_data_value, self_type varchar2) is - begin - self.distance_from_expected := a_distance_from_expected; - self.self_type := self_type; - end; - - member procedure of_(self in ut_be_within_pct, a_expected number) is - l_result ut_be_within_pct := self; - begin - l_result.expected := ut_data_value_number(a_expected); - if l_result.is_negated_flag = 1 then - l_result.expectation.not_to(l_result); - else - l_result.expectation.to_(l_result); - end if; - end; - - member function of_(self in ut_be_within_pct, a_expected number) return ut_be_within_pct is - l_result ut_be_within_pct := self; - begin - l_result.expected := ut_data_value_number(a_expected); - return l_result; - end; - - overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - if self.expected is of (ut_data_value_number) then - l_result := - abs(treat(self.distance_from_expected as ut_data_value_number).data_value) * treat(self.expected as ut_data_value_number).data_value - >= abs( ( treat(self.expected as ut_data_value_number).data_value - treat(a_actual as ut_data_value_number).data_value ) * 100 ); - end if; - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return rtrim( (self as ut_matcher).failure_message(a_actual), 'pct' ) || self.distance_from_expected.to_string ||' % of '|| expected.to_string_report(); - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return rtrim( (self as ut_matcher).failure_message_when_negated(a_actual), 'pct' ) || self.distance_from_expected.to_string ||' % of '|| expected.to_string_report(); - end; - - overriding member function error_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - if ut_utils.int_to_boolean(self.is_errored) then - l_result := 'Matcher '''||self.name()||''' cannot be used to compare Actual ('||a_actual.data_type||') with Expected ('||expected.data_type||') using distance ('||self.distance_from_expected.data_type||').'; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_be_within_pct.tps b/source/expectations/matchers/ut_be_within_pct.tps deleted file mode 100644 index 499e9a2d8..000000000 --- a/source/expectations/matchers/ut_be_within_pct.tps +++ /dev/null @@ -1,35 +0,0 @@ -create or replace type ut_be_within_pct force under ut_comparison_matcher( - /* - 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. - */ - - - /** - * Holds information about mather options - */ - distance_from_expected ut_data_value, - - constructor function ut_be_within_pct(self in out nocopy ut_be_within_pct, a_pct_of_expected number) return self as result, - member procedure init(self in out nocopy ut_be_within_pct, a_distance_from_expected ut_data_value, self_type varchar2), - member procedure of_(self in ut_be_within_pct, a_expected number), - member function of_(self in ut_be_within_pct, a_expected number) return ut_be_within_pct, - overriding member function run_matcher(self in out nocopy ut_be_within_pct, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2, - overriding member function error_message(a_actual ut_data_value) return varchar2 -) -not final -/ diff --git a/source/expectations/matchers/ut_comparison_matcher.tpb b/source/expectations/matchers/ut_comparison_matcher.tpb deleted file mode 100644 index 20ed35927..000000000 --- a/source/expectations/matchers/ut_comparison_matcher.tpb +++ /dev/null @@ -1,29 +0,0 @@ -create or replace type body ut_comparison_matcher as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - overriding member function error_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - if ut_utils.int_to_boolean(self.is_errored) then - l_result := 'Actual ('||a_actual.data_type||') cannot be compared to Expected ('||expected.data_type||') using matcher '''||self.name()||'''.'; - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_comparison_matcher.tps b/source/expectations/matchers/ut_comparison_matcher.tps deleted file mode 100644 index 68ecb4462..000000000 --- a/source/expectations/matchers/ut_comparison_matcher.tps +++ /dev/null @@ -1,22 +0,0 @@ -create or replace type ut_comparison_matcher under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - expected ut_data_value, - overriding member function error_message(a_actual ut_data_value) return varchar2 -) not final not instantiable -/ diff --git a/source/expectations/matchers/ut_contain.tpb b/source/expectations/matchers/ut_contain.tpb deleted file mode 100644 index c9691f731..000000000 --- a/source/expectations/matchers/ut_contain.tpb +++ /dev/null @@ -1,74 +0,0 @@ -create or replace type body ut_contain as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_contain(self in out nocopy ut_contain, a_expected sys_refcursor) return self as result is - begin - self.init(ut_data_value_refcursor(a_expected), null, $$plsql_unit); - self.options.unordered(); - return; - end; - - constructor function ut_contain(self in out nocopy ut_contain, a_expected anydata) return self as result is - begin - self.init(ut_data_value_anydata(a_expected), null, $$plsql_unit); - self.options.unordered(); - return; - end; - - overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - l_result := - ( 0 - = treat( self.expected as ut_data_value_refcursor ) - .compare_implementation( a_actual, self.options, true, self.is_negated() ) - ); - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is - begin - self.negated(); - return run_matcher(a_actual); - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then - l_result := - 'Actual: '||a_actual.get_object_info()||self.description()||': '||self.expected.get_object_info() - || treat(expected as ut_data_value_refcursor).diff( a_actual, self.options ); - else - l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report(); - end if; - return l_result; - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ':'|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_contain.tps b/source/expectations/matchers/ut_contain.tps deleted file mode 100644 index e572edf62..000000000 --- a/source/expectations/matchers/ut_contain.tps +++ /dev/null @@ -1,33 +0,0 @@ -create or replace type ut_contain under ut_equal( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Due to nature of inclusion compare the not is bit diffrente than standard. - * Result is false when even one element belongs which can cause overlap. - * e.g. set can fail at same time not_include and include. By that we mean - * that false include not necessary mean true not include. - */ - - constructor function ut_contain(self in out nocopy ut_contain, a_expected sys_refcursor) return self as result, - constructor function ut_contain(self in out nocopy ut_contain, a_expected anydata) return self as result, - overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean, - overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_equal.tpb b/source/expectations/matchers/ut_equal.tpb deleted file mode 100644 index d514e34d0..000000000 --- a/source/expectations/matchers/ut_equal.tpb +++ /dev/null @@ -1,331 +0,0 @@ -create or replace type body ut_equal as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_equal, a_expected ut_data_value, a_nulls_are_equal boolean, a_self_type varchar2 := null) is - begin - self.expected := a_expected; - self.options := ut_matcher_options( a_nulls_are_equal ); - self.self_type := nvl( a_self_type, $$plsql_unit ); - end; - - member function equal_with_nulls(a_assert_result boolean, a_actual ut_data_value) return boolean is - begin - ut_utils.debug_log('ut_equal.equal_with_nulls :' || ut_utils.to_test_result(a_assert_result) || ':'); - return ( a_assert_result or ( self.expected.is_null() and a_actual.is_null() and options.nulls_are_equal ) ); - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_anydata(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result is - l_deprecated integer; - begin - ut_expectation_processor.add_depreciation_warning( - 'equal( a_expected anydata, a_exclude varchar2 )', - 'equal( a_expected anydata ).exclude( a_exclude varchar2 )' - ); - init(ut_data_value_anydata(a_expected), a_nulls_are_equal); - self.options.exclude.add_items(a_exclude); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is - begin - ut_expectation_processor.add_depreciation_warning( - 'equal( a_expected anydata, a_exclude ut_varchar2_list )', - 'equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )' - ); - init(ut_data_value_anydata(a_expected), a_nulls_are_equal); - self.options.exclude.add_items(a_exclude); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected blob, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_blob(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected boolean, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_boolean(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected clob, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_clob(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected date, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_date(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected number, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_number(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_refcursor(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result is - begin - ut_expectation_processor.add_depreciation_warning( - 'equal( a_expected sys_refcursor, a_exclude varchar2 )', - 'equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )' - ); - init(ut_data_value_refcursor(a_expected), a_nulls_are_equal); - self.options.exclude.add_items(a_exclude); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is - begin - ut_expectation_processor.add_depreciation_warning( - 'equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )', - 'equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )' - ); - init(ut_data_value_refcursor(a_expected), a_nulls_are_equal); - self.options.exclude.add_items(a_exclude); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_timestamp(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_timestamp_tz(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_timestamp_ltz(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected varchar2, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_varchar2(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_yminterval(a_expected), a_nulls_are_equal); - return; - end; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) return self as result is - begin - init(ut_data_value_dsinterval(a_expected), a_nulls_are_equal); - 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; - - constructor function ut_equal(self in out nocopy ut_equal, a_expected json, 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 - l_result.options.include.add_items(a_items); - return l_result; - end; - - member function include(a_items ut_varchar2_list) return ut_equal is - l_result ut_equal := self; - begin - l_result.options.include.add_items(a_items); - return l_result; - end; - - member procedure include(self in ut_equal, a_items varchar2) is - begin - include( ut_varchar2_list( a_items ) ); - end; - - member procedure include(self in ut_equal, a_items ut_varchar2_list) is - l_result ut_equal := self; - begin - l_result.options.include.add_items(a_items); - l_result.expectation.to_(l_result ); - end; - - member function exclude(a_items varchar2) return ut_equal is - l_result ut_equal := self; - begin - l_result.options.exclude.add_items(a_items); - return l_result; - end; - - member function exclude(a_items ut_varchar2_list) return ut_equal is - l_result ut_equal := self; - begin - l_result.options.exclude.add_items(a_items); - return l_result; - end; - - member procedure exclude(self in ut_equal, a_items varchar2) is - begin - exclude( ut_varchar2_list( a_items ) ); - end; - - member procedure exclude(self in ut_equal, a_items ut_varchar2_list) is - l_result ut_equal := self; - begin - l_result.options.exclude.add_items(a_items); - l_result.expectation.to_(l_result ); - end; - - member function unordered return ut_equal is - l_result ut_equal := self; - begin - l_result.options.unordered(); - return l_result; - end; - - member procedure unordered(self in ut_equal) is - l_result ut_equal := self; - begin - l_result.options.unordered(); - l_result.expectation.to_(l_result ); - end; - - member function join_by(a_columns varchar2) return ut_equal is - l_result ut_equal := self; - begin - l_result.options.unordered(); - l_result.options.join_by.add_items(a_columns); - return l_result; - end; - - member function join_by(a_columns ut_varchar2_list) return ut_equal is - l_result ut_equal := self; - begin - l_result.options.unordered(); - l_result.options.join_by.add_items(a_columns); - return l_result; - end; - - member procedure join_by(self in ut_equal, a_columns varchar2) is - begin - join_by( ut_varchar2_list( a_columns ) ); - end; - - member procedure join_by(self in ut_equal, a_columns ut_varchar2_list) is - l_result ut_equal := self; - begin - l_result.options.unordered(); - l_result.options.join_by.add_items(a_columns); - l_result.expectation.to_(l_result ); - end; - - member function unordered_columns return ut_equal is - l_result ut_equal := self; - begin - l_result.options.unordered_columns(); - return l_result; - end; - - member procedure unordered_columns(self in ut_equal) is - l_result ut_equal := self; - begin - l_result.options.unordered_columns(); - l_result.expectation.to_(l_result ); - end; - - member function uc return ut_equal is - begin - return unordered_columns; - end; - - member procedure uc(self in ut_equal) is - begin - unordered_columns; - end; - - overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if self.expected.data_type = a_actual.data_type then - if self.expected is of (ut_data_value_anydata) then - l_result := 0 = treat(self.expected as ut_data_value_anydata).compare_implementation( a_actual, options ); - elsif self.expected is of (ut_data_value_refcursor) then - l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation( a_actual, options ); - else - l_result := equal_with_nulls((self.expected = a_actual), a_actual); - end if; - l_result := equal_with_nulls( l_result, a_actual ); - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then - l_result := - 'Actual: '||a_actual.get_object_info()||self.description()||': '||self.expected.get_object_info() - ||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 - expected.diff( a_actual, options ) - end; - else - l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report(); - end if; - return l_result; - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report(); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_equal.tps b/source/expectations/matchers/ut_equal.tps deleted file mode 100644 index e48b797ed..000000000 --- a/source/expectations/matchers/ut_equal.tps +++ /dev/null @@ -1,69 +0,0 @@ -create or replace type ut_equal force under ut_comparison_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - - /** - * Holds information about mather options - */ - options ut_matcher_options, - - member procedure init(self in out nocopy ut_equal, a_expected ut_data_value, a_nulls_are_equal boolean, a_self_type varchar2 := null), - member function equal_with_nulls( self in ut_equal, a_assert_result boolean, a_actual ut_data_value) return boolean, - constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected blob, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected boolean, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected clob, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected date, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected number, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) return self as result, - constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) return self as result, - 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, - constructor function ut_equal(self in out nocopy ut_equal, a_expected json, 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 procedure include(self in ut_equal, a_items varchar2), - member procedure include(self in ut_equal, a_items ut_varchar2_list), - member function exclude(a_items varchar2) return ut_equal, - member function exclude(a_items ut_varchar2_list) return ut_equal, - member procedure exclude(self in ut_equal, a_items varchar2), - member procedure exclude(self in ut_equal, a_items ut_varchar2_list), - member function unordered return ut_equal, - member procedure unordered(self in ut_equal), - member function join_by(a_columns varchar2) return ut_equal, - member function join_by(a_columns ut_varchar2_list) return ut_equal, - member procedure join_by(self in ut_equal, a_columns varchar2), - member procedure join_by(self in ut_equal, a_columns ut_varchar2_list), - overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2, - member function unordered_columns return ut_equal, - member procedure unordered_columns(self in ut_equal), - member function uc return ut_equal, - member procedure uc(self in ut_equal) -) -not final -/ diff --git a/source/expectations/matchers/ut_have_count.tpb b/source/expectations/matchers/ut_have_count.tpb deleted file mode 100644 index 457cd6272..000000000 --- a/source/expectations/matchers/ut_have_count.tpb +++ /dev/null @@ -1,54 +0,0 @@ -create or replace type body ut_have_count as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_have_count(self in out nocopy ut_have_count, a_expected integer) return self as result is - begin - self.self_type := $$plsql_unit; - self.expected := a_expected; - return; - end; - - overriding member function run_matcher(self in out nocopy ut_have_count, a_actual ut_data_value) return boolean is - l_result boolean; - 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; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - begin - 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: ' || 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 deleted file mode 100644 index d48dc44c8..000000000 --- a/source/expectations/matchers/ut_have_count.tps +++ /dev/null @@ -1,26 +0,0 @@ -create or replace type ut_have_count under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - expected integer, - - constructor function ut_have_count(self in out nocopy ut_have_count, a_expected integer) return self as result, - overriding member function run_matcher(self in out nocopy ut_have_count, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_match.tpb b/source/expectations/matchers/ut_match.tpb deleted file mode 100644 index 3c7a71402..000000000 --- a/source/expectations/matchers/ut_match.tpb +++ /dev/null @@ -1,65 +0,0 @@ -create or replace type body ut_match as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_match(self in out nocopy ut_match, a_pattern in varchar2, a_modifiers in varchar2 default null) return self as result is - begin - self.self_type := $$plsql_unit; - self.pattern := a_pattern; - self.modifiers := a_modifiers; - return; - end; - - overriding member function run_matcher(self in out nocopy ut_match, a_actual ut_data_value) return boolean is - l_result boolean; - begin - if a_actual is of (ut_data_value_varchar2) then - l_result := regexp_like(treat(a_actual as ut_data_value_varchar2).data_value, pattern, modifiers); - elsif a_actual is of (ut_data_value_clob) then - l_result := regexp_like(treat(a_actual as ut_data_value_clob).data_value, pattern, modifiers); - else - l_result := (self as ut_matcher).run_matcher(a_actual); - end if; - return l_result; - end; - - overriding member function failure_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - l_result := (self as ut_matcher).failure_message(a_actual); - if self.modifiers is not null then - l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(true, false) || ', modifiers ''' || self.modifiers ||''''; - else - l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(false, false); - end if; - return l_result; - end; - - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - l_result := (self as ut_matcher).failure_message_when_negated(a_actual); - if self.modifiers is not null then - l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(true, false) || ', modifiers ''' || self.modifiers ||''''; - else - l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(false, false); - end if; - return l_result; - end; - -end; -/ diff --git a/source/expectations/matchers/ut_match.tps b/source/expectations/matchers/ut_match.tps deleted file mode 100644 index ee51a4c28..000000000 --- a/source/expectations/matchers/ut_match.tps +++ /dev/null @@ -1,25 +0,0 @@ -create or replace type ut_match under ut_matcher( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - pattern varchar2(4000), - modifiers varchar2(4000), - constructor function ut_match(self in out nocopy ut_match, a_pattern in varchar2, a_modifiers in varchar2 default null) return self as result, - overriding member function run_matcher(self in out nocopy ut_match, a_actual ut_data_value) return boolean, - overriding member function failure_message(a_actual ut_data_value) return varchar2, - overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 -) -/ diff --git a/source/expectations/matchers/ut_matcher.tpb b/source/expectations/matchers/ut_matcher.tpb deleted file mode 100644 index 6b5b98465..000000000 --- a/source/expectations/matchers/ut_matcher.tpb +++ /dev/null @@ -1,83 +0,0 @@ -create or replace type body ut_matcher as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 function run_matcher(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean is - begin - ut_utils.debug_log('Failure - ut_matcher.run_matcher'||'(a_actual '||a_actual.data_type||')'); - self.is_errored := ut_utils.boolean_to_int(true); - return null; - end; - - member function run_matcher_negated(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean is - begin - return not run_matcher(a_actual); - end; - - member function name return varchar2 is - begin - return replace(ltrim(lower(self.self_type),'ut_'),'_',' '); - end; - - member function description return varchar2 is - begin - return ' was expected to '||name(); - end; - - member function description_when_negated return varchar2 is - begin - return ' was expected not to '||name(); - end; - - member function error_message(a_actual ut_data_value) return varchar2 is - l_result varchar2(32767); - begin - if ut_utils.int_to_boolean(self.is_errored) then - l_result := 'The matcher '''||name()||''' cannot be used with data type ('||a_actual.data_type||').'; - end if; - return l_result; - end; - - member function failure_message(a_actual ut_data_value) return varchar2 is - begin - return 'Actual: ' || a_actual.to_string_report(true) || description(); - end; - - member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is - begin - return 'Actual: ' || a_actual.to_string_report(true) || description_when_negated(); - end; - - member procedure negated is - begin - is_negated_flag := ut_utils.boolean_to_int(true); - end; - - member function negated return ut_matcher is - l_result ut_matcher := self; - begin - l_result.negated(); - return l_result; - end; - - member function is_negated return boolean is - begin - return coalesce(ut_utils.int_to_boolean(is_negated_flag), false); - end; - -end; -/ diff --git a/source/expectations/matchers/ut_matcher.tps b/source/expectations/matchers/ut_matcher.tps deleted file mode 100644 index a034e4ed2..000000000 --- a/source/expectations/matchers/ut_matcher.tps +++ /dev/null @@ -1,43 +0,0 @@ -create or replace type ut_matcher under ut_matcher_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - is_errored integer, - is_negated_flag number(1,0), - expectation ut_expectation_base, - /* - function: run_matcher - - A superclass function that executes the matcher. - This is actually a fallback function, that should be called by subtype when there is a data type mismatch. - The subtype should override this function and return: - - true for success of a matcher, - - false for faulure of a matcher, - - null when result cannot be determined (type mismatch or exception) - */ - member function run_matcher(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean, - member function run_matcher_negated(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean, - member function name return varchar2, - member function description return varchar2, - member function description_when_negated return varchar2, - member function error_message(a_actual ut_data_value) return varchar2, - member function failure_message(a_actual ut_data_value) return varchar2, - member function failure_message_when_negated(a_actual ut_data_value) return varchar2, - member procedure negated, - member function negated return ut_matcher, - member function is_negated return boolean -) not final not instantiable -/ diff --git a/source/expectations/matchers/ut_matcher_base.tps b/source/expectations/matchers/ut_matcher_base.tps deleted file mode 100644 index ef7fd98a2..000000000 --- a/source/expectations/matchers/ut_matcher_base.tps +++ /dev/null @@ -1,5 +0,0 @@ -create or replace type ut_matcher_base force authid current_user as object( - self_type varchar2(250) -) -not final not instantiable -/ diff --git a/source/expectations/matchers/ut_matcher_options.tpb b/source/expectations/matchers/ut_matcher_options.tpb deleted file mode 100644 index 8730c204b..000000000 --- a/source/expectations/matchers/ut_matcher_options.tpb +++ /dev/null @@ -1,60 +0,0 @@ -create or replace type body ut_matcher_options as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_matcher_options(self in out nocopy ut_matcher_options, a_nulls_are_equal in boolean := null) return self as result is - begin - nulls_are_equal_flag := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_expectation_processor.nulls_are_equal()) ); - is_unordered := ut_utils.boolean_to_int(false); - columns_are_unordered_flag := ut_utils.boolean_to_int(false); - include := ut_matcher_options_items(); - exclude := ut_matcher_options_items(); - join_by := ut_matcher_options_items(); - return; - end; - - member procedure nulls_are_equal(self in out nocopy ut_matcher_options) is - begin - self.nulls_are_equal_flag := ut_utils.boolean_to_int(true); - end; - - member function nulls_are_equal return boolean is - begin - return ut_utils.int_to_boolean(self.nulls_are_equal_flag); - end; - - member procedure unordered_columns(self in out nocopy ut_matcher_options) is - begin - columns_are_unordered_flag := ut_utils.boolean_to_int(true); - end; - - member function ordered_columns return boolean is - begin - return not ut_utils.int_to_boolean(columns_are_unordered_flag); - end; - - member procedure unordered(self in out nocopy ut_matcher_options) is - begin - is_unordered := ut_utils.boolean_to_int(true); - end; - - member function unordered return boolean is - begin - return ut_utils.int_to_boolean(is_unordered); - end; -end; -/ diff --git a/source/expectations/matchers/ut_matcher_options.tps b/source/expectations/matchers/ut_matcher_options.tps deleted file mode 100644 index 276cad2ec..000000000 --- a/source/expectations/matchers/ut_matcher_options.tps +++ /dev/null @@ -1,57 +0,0 @@ -create or replace type ut_matcher_options authid current_user as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Flag indicating that columns order is to be ignored - */ - columns_are_unordered_flag number(1,0), - - /** - * Flag indicating that rows/items order is to be ignored - */ - is_unordered number(1,0), - - /** - * Flag determining how to react to null values - */ - nulls_are_equal_flag number(1,0), - - /** - * Holds (list of columns/attributes) to exclude when comparing compound types - */ - exclude ut_matcher_options_items, - - /** - * Holds (list of columns/attributes) to incude when comparing compound types - */ - include ut_matcher_options_items, - - /** - * Holds list of columns to be used as a join PK on sys_refcursor comparision - */ - join_by ut_matcher_options_items, - - constructor function ut_matcher_options(self in out nocopy ut_matcher_options, a_nulls_are_equal in boolean := null) return self as result, - member procedure nulls_are_equal(self in out nocopy ut_matcher_options), - member function nulls_are_equal return boolean, - member procedure unordered_columns(self in out nocopy ut_matcher_options), - member function ordered_columns return boolean, - member procedure unordered(self in out nocopy ut_matcher_options), - member function unordered return boolean -) -/ diff --git a/source/expectations/matchers/ut_matcher_options_items.tpb b/source/expectations/matchers/ut_matcher_options_items.tpb deleted file mode 100644 index 92da588ce..000000000 --- a/source/expectations/matchers/ut_matcher_options_items.tpb +++ /dev/null @@ -1,56 +0,0 @@ -create or replace type body ut_matcher_options_items is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_matcher_options_items(self in out nocopy ut_matcher_options_items) return self as result is - begin - items := ut_varchar2_list(); - return; - end; - - member procedure add_items(self in out nocopy ut_matcher_options_items, a_items varchar2) is - begin - items := - items - multiset union all - ut_utils.filter_list( - ut_utils.trim_list_elements( - ut_utils.string_to_table( replace( a_items , '|', ',' ), ',' ) - ) - , '.+' - ); - end; - - member procedure add_items(self in out nocopy ut_matcher_options_items, a_items ut_varchar2_list) is - l_idx binary_integer; - begin - if a_items is not null then - l_idx := a_items.first; - while l_idx is not null loop - add_items( a_items(l_idx) ); - l_idx := a_items.next(l_idx); - end loop; - end if; - end; - - member function to_xpath return varchar2 is - begin - return ut_utils.to_xpath(items); - end; - -end; -/ \ No newline at end of file diff --git a/source/expectations/matchers/ut_matcher_options_items.tps b/source/expectations/matchers/ut_matcher_options_items.tps deleted file mode 100644 index 53787070d..000000000 --- a/source/expectations/matchers/ut_matcher_options_items.tps +++ /dev/null @@ -1,29 +0,0 @@ -create or replace type ut_matcher_options_items authid current_user as object( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Attributes / columns list - */ - items ut_varchar2_list, - - constructor function ut_matcher_options_items(self in out nocopy ut_matcher_options_items) return self as result, - member procedure add_items(self in out nocopy ut_matcher_options_items, a_items varchar2), - member procedure add_items(self in out nocopy ut_matcher_options_items, a_items ut_varchar2_list), - member function to_xpath return varchar2 -) -/ diff --git a/source/expectations/ut_expectation.tpb b/source/expectations/ut_expectation.tpb deleted file mode 100644 index 309759d48..000000000 --- a/source/expectations/ut_expectation.tpb +++ /dev/null @@ -1,768 +0,0 @@ -create or replace type body ut_expectation as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 to_be_null(self in ut_expectation) is - begin - self.to_( ut_be_null() ); - end; - - member procedure to_be_not_null(self in ut_expectation) is - begin - self.to_( ut_be_not_null() ); - end; - - member procedure not_to_be_null(self in ut_expectation) is - begin - self.not_to( ut_be_null() ); - end; - - member procedure not_to_be_not_null(self in ut_expectation) is - begin - self.not_to( ut_be_not_null() ); - end; - - member procedure to_be_true(self in ut_expectation) is - begin - self.to_( ut_be_true() ); - end; - - member procedure to_be_false(self in ut_expectation) is - begin - self.to_( ut_be_false() ); - end; - - member procedure not_to_be_true(self in ut_expectation) is - begin - self.not_to( ut_be_true() ); - end; - - member procedure not_to_be_false(self in ut_expectation) is - begin - self.not_to( ut_be_false() ); - end; - - member procedure to_be_empty(self in ut_expectation) is - begin - self.to_( ut_be_empty() ); - end; - - member procedure not_to_be_empty(self in ut_expectation) is - begin - self.not_to( ut_be_empty() ); - end; - - member procedure to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_warning( - ut_utils.build_depreciation_warning( - 'to_equal( a_expected anydata, a_exclude varchar2 )', - 'to_equal( a_expected anydata ).exclude( a_exclude varchar2 )' - ) - ); - self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_warning( - ut_utils.build_depreciation_warning( - 'to_equal( a_expected anydata, a_exclude ut_varchar2_list )', - 'to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )' - ) - ); - self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_depreciation_warning( - 'to_equal( a_expected sys_refcursor, a_exclude varchar2 )', - 'to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )' - ); - self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_depreciation_warning( - 'to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )', - 'to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )' - ); - self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.to_( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is - begin - 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 to_equal(self in ut_expectation, a_expected json, 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 - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_depreciation_warning( - 'not_to_equal( a_expected anydata, a_exclude varchar2 )', - 'not_to_equal( a_expected anydata ).exclude( a_exclude varchar2 )' - ); - self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_depreciation_warning( - 'not_to_equal( a_expected anydata, a_exclude ut_varchar2_list )', - 'not_to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )' - ); - self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_depreciation_warning( - 'not_to_equal( a_expected sys_refcursor, a_exclude varchar2 )', - 'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )' - ); - self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is - begin - ut_expectation_processor.add_depreciation_warning( - 'not_to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )', - 'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )' - ); - self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is - begin - self.not_to( ut_equal(a_expected, a_nulls_are_equal) ); - end; - - member procedure not_to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is - begin - 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 - self.to_( ut_be_like(a_mask, a_escape_char) ); - end; - - - member procedure to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null) is - begin - self.to_( ut_match(a_pattern, a_modifiers) ); - end; - - - member procedure not_to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 := null) is - begin - self.not_to( ut_be_like(a_mask, a_escape_char) ); - end; - - - member procedure not_to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null) is - begin - self.not_to( ut_match(a_pattern, a_modifiers) ); - end; - - - member procedure to_be_between(self in ut_expectation, a_lower_bound date, a_upper_bound date) is - begin - self.to_( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) is - begin - self.to_( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound number, a_upper_bound number) is - begin - self.to_( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) is - begin - self.to_( ut_be_between(a_lower_bound, a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) is - begin - self.to_( ut_be_between(a_lower_bound, a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) is - begin - self.to_( ut_be_between(a_lower_bound, a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound varchar2, a_upper_bound varchar2) is - begin - self.to_( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure to_be_between(self in ut_expectation, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) is - begin - self.to_( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected date) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected number) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.to_( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected date) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected number) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - member procedure to_be_greater_than(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.to_( ut_be_greater_than (a_expected) ); - end; - - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected date) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected number) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.to_( ut_be_less_or_equal (a_expected) ); - end; - - - member procedure to_be_less_than(self in ut_expectation, a_expected date) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - member procedure to_be_less_than(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - member procedure to_be_less_than(self in ut_expectation, a_expected number) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - member procedure to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.to_( ut_be_less_than (a_expected) ); - end; - - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound date, a_upper_bound date) is - begin - self.not_to( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) is - begin - self.not_to( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound number, a_upper_bound number) is - begin - self.not_to( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) is - begin - self.not_to( ut_be_between(a_lower_bound, a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) is - begin - self.not_to( ut_be_between(a_lower_bound, a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) is - begin - self.not_to( ut_be_between(a_lower_bound, a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound varchar2, a_upper_bound varchar2) is - begin - self.not_to( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) is - begin - self.not_to( ut_be_between(a_lower_bound,a_upper_bound) ); - end; - - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected date) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected number) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.not_to( ut_be_greater_or_equal (a_expected) ); - end; - - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected date) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected number) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.not_to( ut_be_greater_than (a_expected) ); - end; - - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected date) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected number) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.not_to( ut_be_less_or_equal (a_expected) ); - end; - - - member procedure not_to_be_less_than(self in ut_expectation, a_expected date) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure not_to_be_less_than(self in ut_expectation, a_expected dsinterval_unconstrained) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure not_to_be_less_than(self in ut_expectation, a_expected number) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure not_to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained) is - begin - self.not_to( ut_be_less_than (a_expected) ); - end; - - member procedure to_contain(self in ut_expectation, a_expected sys_refcursor) is - begin - self.to_( ut_contain(a_expected) ); - end; - - member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is - begin - self.not_to( ut_contain(a_expected)); - end; - - member procedure to_contain(self in ut_expectation, a_expected anydata) is - begin - self.to_( ut_contain(a_expected) ); - end; - - member procedure not_to_contain(self in ut_expectation, a_expected anydata) is - begin - self.not_to( ut_contain(a_expected)); - end; - - member function to_be_within(a_dist number) return ut_be_within is - l_result ut_be_within; - begin - l_result := ut_be_within(a_dist); - l_result.expectation := self; - return l_result; - end; - - member function to_be_within(a_dist dsinterval_unconstrained) return ut_be_within is - l_result ut_be_within; - begin - l_result := ut_be_within(a_dist); - l_result.expectation := self; - return l_result; - end; - - member function to_be_within(a_dist yminterval_unconstrained) return ut_be_within is - l_result ut_be_within; - begin - l_result := ut_be_within(a_dist); - l_result.expectation := self; - return l_result; - end; - - member function to_be_within_pct(a_dist number) return ut_be_within_pct is - l_result ut_be_within_pct; - begin - l_result := ut_be_within_pct(a_dist); - l_result.expectation := self; - return l_result; - end; - - member function not_to_be_within(a_dist number) return ut_be_within is - l_result ut_be_within; - begin - l_result := treat( ut_be_within(a_dist).negated() as ut_be_within); - l_result.expectation := self; - return l_result; - end; - - member function not_to_be_within(a_dist dsinterval_unconstrained) return ut_be_within is - l_result ut_be_within; - begin - l_result := treat( ut_be_within(a_dist).negated() as ut_be_within); - l_result.expectation := self; - return l_result; - end; - - member function not_to_be_within(a_dist yminterval_unconstrained) return ut_be_within is - l_result ut_be_within; - begin - l_result := treat( ut_be_within(a_dist).negated() as ut_be_within); - l_result.expectation := self; - return l_result; - end; - - member function not_to_be_within_pct(a_dist number) return ut_be_within_pct is - l_result ut_be_within_pct; - begin - l_result := treat( ut_be_within_pct(a_dist).negated() as ut_be_within_pct); - l_result.expectation := self; - return l_result; - end; - -end; -/ - diff --git a/source/expectations/ut_expectation.tps b/source/expectations/ut_expectation.tps deleted file mode 100644 index 30fe985d3..000000000 --- a/source/expectations/ut_expectation.tps +++ /dev/null @@ -1,178 +0,0 @@ -create or replace type ut_expectation force under ut_expectation_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - --shortcuts - member procedure to_be_null(self in ut_expectation), - member procedure to_be_not_null(self in ut_expectation), - member procedure not_to_be_null(self in ut_expectation), - member procedure not_to_be_not_null(self in ut_expectation), - - member procedure to_be_true(self in ut_expectation), - member procedure to_be_false(self in ut_expectation), - member procedure not_to_be_true(self in ut_expectation), - member procedure not_to_be_false(self in ut_expectation), - - member procedure to_be_empty(self in ut_expectation), - member procedure not_to_be_empty(self in ut_expectation), - - -- this is done to provide strong type comparison. other comporators should be implemented in the type-specific classes - member procedure to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null), - member procedure to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null), - 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 to_equal(self in ut_expectation, a_expected json, 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), - member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null), - member procedure not_to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null), - 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), - - member procedure to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 := null), - - member procedure not_to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 := null), - - member procedure not_to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 := null), - - member procedure to_be_between(self in ut_expectation, a_lower_bound date, a_upper_bound date), - member procedure to_be_between(self in ut_expectation, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained), - member procedure to_be_between(self in ut_expectation, a_lower_bound number, a_upper_bound number), - member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained), - member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained), - member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained), - member procedure to_be_between(self in ut_expectation, a_lower_bound varchar2, a_upper_bound varchar2), - member procedure to_be_between(self in ut_expectation, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained), - - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected date), - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected number), - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure to_be_greater_or_equal(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure to_be_greater_than(self in ut_expectation, a_expected date), - member procedure to_be_greater_than(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure to_be_greater_than(self in ut_expectation, a_expected number), - member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure to_be_greater_than(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure to_be_less_or_equal(self in ut_expectation, a_expected date), - member procedure to_be_less_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure to_be_less_or_equal(self in ut_expectation, a_expected number), - member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure to_be_less_or_equal(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure to_be_less_than(self in ut_expectation, a_expected date), - member procedure to_be_less_than(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure to_be_less_than(self in ut_expectation, a_expected number), - member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure not_to_be_between(self in ut_expectation, a_lower_bound date, a_upper_bound date), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound number, a_upper_bound number), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound varchar2, a_upper_bound varchar2), - member procedure not_to_be_between(self in ut_expectation, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained), - - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected date), - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected number), - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure not_to_be_greater_than(self in ut_expectation, a_expected date), - member procedure not_to_be_greater_than(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure not_to_be_greater_than(self in ut_expectation, a_expected number), - member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure not_to_be_greater_than(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected date), - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected number), - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure not_to_be_less_than(self in ut_expectation, a_expected date), - member procedure not_to_be_less_than(self in ut_expectation, a_expected dsinterval_unconstrained), - member procedure not_to_be_less_than(self in ut_expectation, a_expected number), - member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained), - member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained), - member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained), - member procedure not_to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained), - - member procedure to_contain(self in ut_expectation, a_expected sys_refcursor), - member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor), - member procedure to_contain(self in ut_expectation, a_expected anydata), - member procedure not_to_contain(self in ut_expectation, a_expected anydata), - - member function to_be_within(a_dist number) return ut_be_within, - member function to_be_within(a_dist dsinterval_unconstrained) return ut_be_within, - member function to_be_within(a_dist yminterval_unconstrained) return ut_be_within, - member function to_be_within_pct(a_dist number) return ut_be_within_pct, - member function not_to_be_within(a_dist number) return ut_be_within, - member function not_to_be_within(a_dist dsinterval_unconstrained) return ut_be_within, - member function not_to_be_within(a_dist yminterval_unconstrained) return ut_be_within, - member function not_to_be_within_pct(a_dist number) return ut_be_within_pct -) -not final -/ diff --git a/source/expectations/ut_expectation_base.tpb b/source/expectations/ut_expectation_base.tpb deleted file mode 100644 index 20b3e7a95..000000000 --- a/source/expectations/ut_expectation_base.tpb +++ /dev/null @@ -1,44 +0,0 @@ -create or replace type body ut_expectation_base 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 to_(self in ut_expectation_base, a_matcher ut_matcher_base) is - l_expectation_result boolean; - l_matcher ut_matcher := treat(a_matcher as ut_matcher); - l_message varchar2(32767); - begin - if l_matcher.is_negated() then - self.not_to( a_matcher ); - else - l_expectation_result := l_matcher.run_matcher( self.actual_data ); - l_expectation_result := coalesce(l_expectation_result,false); - l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message( self.actual_data ) ); - ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) ); - end if; - end; - - member procedure not_to(self in ut_expectation_base, a_matcher ut_matcher_base) is - l_expectation_result boolean; - l_matcher ut_matcher := treat(a_matcher as ut_matcher); - l_message varchar2(32767); - begin - l_expectation_result := coalesce( l_matcher.run_matcher_negated( self.actual_data ), false ); - - l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) ); - ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) ); - end; -end; -/ diff --git a/source/expectations/ut_expectation_base.tps b/source/expectations/ut_expectation_base.tps deleted file mode 100644 index a542d26ea..000000000 --- a/source/expectations/ut_expectation_base.tps +++ /dev/null @@ -1,25 +0,0 @@ -create or replace type ut_expectation_base 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. - */ - actual_data ut_data_value, - description varchar2(4000 char), - - --base matcher executors - member procedure to_(self in ut_expectation_base, a_matcher ut_matcher_base), - member procedure not_to(self in ut_expectation_base, a_matcher ut_matcher_base) -) not final not instantiable -/ diff --git a/source/expectations/ut_expectation_compound.tpb b/source/expectations/ut_expectation_compound.tpb deleted file mode 100644 index 6fc2e2647..000000000 --- a/source/expectations/ut_expectation_compound.tpb +++ /dev/null @@ -1,102 +0,0 @@ -create or replace type body ut_expectation_compound as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_compound(self in out nocopy ut_expectation_compound, 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_have_count(self in ut_expectation_compound, a_expected integer) is - begin - self.to_( ut_have_count(a_expected) ); - end; - - member procedure not_to_have_count(self in ut_expectation_compound, a_expected integer) is - begin - self.not_to( ut_have_count(a_expected) ); - end; - - - member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal is - l_result ut_equal; - begin - l_result := ut_equal(a_expected, a_nulls_are_equal); - l_result.expectation := self; - return l_result; - end; - - member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal is - l_result ut_matcher; - begin - l_result := ut_equal(a_expected, a_nulls_are_equal).negated(); - l_result.expectation := self; - return treat(l_result as ut_equal); - end; - - member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal is - l_result ut_equal; - begin - l_result := ut_equal(a_expected, a_nulls_are_equal); - l_result.expectation := self; - return l_result; - end; - - member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal is - l_result ut_matcher; - begin - l_result := ut_equal(a_expected, a_nulls_are_equal).negated(); - l_result.expectation := self; - return treat(l_result as ut_equal); - end; - - member function to_contain(a_expected sys_refcursor) return ut_contain is - l_result ut_contain; - begin - l_result := ut_contain(a_expected); - l_result.expectation := self; - return l_result; - end; - - member function not_to_contain(a_expected sys_refcursor) return ut_contain is - l_result ut_matcher; - begin - l_result := ut_contain(a_expected).negated(); - l_result.expectation := self; - return treat(l_result as ut_contain); - end; - - member function to_contain(a_expected anydata) return ut_contain is - l_result ut_contain; - begin - l_result := ut_contain(a_expected); - l_result.expectation := self; - return l_result; - end; - - member function not_to_contain(a_expected anydata) return ut_contain is - l_result ut_matcher; - begin - l_result := ut_contain(a_expected).negated(); - l_result.expectation := self; - return treat(l_result as ut_contain); - end; - -end; -/ diff --git a/source/expectations/ut_expectation_compound.tps b/source/expectations/ut_expectation_compound.tps deleted file mode 100644 index 46da23fea..000000000 --- a/source/expectations/ut_expectation_compound.tps +++ /dev/null @@ -1,36 +0,0 @@ -create or replace type ut_expectation_compound under ut_expectation( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_compound(self in out nocopy ut_expectation_compound, a_actual_data ut_data_value, a_description varchar2) return self as result, - - member procedure to_have_count(self in ut_expectation_compound, a_expected integer), - member procedure not_to_have_count(self in ut_expectation_compound, a_expected integer), - - member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal, - member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_equal, - member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal, - member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_equal, - member function to_contain(a_expected sys_refcursor) return ut_contain, - member function not_to_contain(a_expected sys_refcursor) return ut_contain, - member function to_contain(a_expected anydata) return ut_contain, - member function not_to_contain(a_expected anydata) return ut_contain -) -/ - - diff --git a/source/expectations/ut_expectation_json.tpb b/source/expectations/ut_expectation_json.tpb deleted file mode 100644 index b71e8ea83..000000000 --- a/source/expectations/ut_expectation_json.tpb +++ /dev/null @@ -1,51 +0,0 @@ -create or replace type body ut_expectation_json as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 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 deleted file mode 100644 index 561c5d11f..000000000 --- a/source/expectations/ut_expectation_json.tps +++ /dev/null @@ -1,27 +0,0 @@ -create or replace type ut_expectation_json under ut_expectation( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 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) -) -/ \ No newline at end of file diff --git a/source/install.sql b/source/install.sql deleted file mode 100644 index 22ce75365..000000000 --- a/source/install.sql +++ /dev/null @@ -1,411 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 - -spool install.log - -prompt &&line_separator -prompt Installing utPLSQL v3 framework into &&ut3_owner schema -prompt &&line_separator - -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -prompt Switching current schema to &&ut3_owner -prompt &&line_separator -alter session set current_schema = &&ut3_owner; - -@@check_object_grants.sql -@@check_sys_grants.sql "'CREATE TYPE','CREATE VIEW','CREATE SYNONYM','CREATE SEQUENCE','CREATE PROCEDURE','CREATE TABLE', 'CREATE CONTEXT'" ---set define off - -create or replace context &&ut3_owner._info using &&ut3_owner..ut_session_context; - ---dbms_output buffer cache table -@@install_component.sql 'core/ut_dbms_output_cache.sql' - ---common utilities -@@install_component.sql 'core/types/ut_varchar2_list.tps' -@@install_component.sql 'core/types/ut_varchar2_rows.tps' -@@install_component.sql 'core/types/ut_integer_list.tps' -@@install_component.sql 'core/types/ut_object_name.tps' -@@install_component.sql 'core/types/ut_object_name.tpb' -@@install_component.sql 'core/types/ut_object_names.tps' -@@install_component.sql 'core/types/ut_key_value_pair.tps' -@@install_component.sql 'core/types/ut_key_value_pairs.tps' -@@install_component.sql 'core/types/ut_reporter_info.tps' -@@install_component.sql 'core/types/ut_reporters_info.tps' -@@install_component.sql 'core/types/ut_stack.tps' -@@install_component.sql 'core/types/ut_stack.tpb' -@@install_component.sql 'core/ut_utils.pks' -@@install_component.sql 'core/ut_metadata.pks' -@@install_component.sql 'core/ut_savepoint_seq.sql' -@@install_component.sql 'core/ut_utils.pkb' -@@install_component.sql 'core/ut_metadata.pkb' -@@install_component.sql 'reporters/ut_ansiconsole_helper.pks' -@@install_component.sql 'reporters/ut_ansiconsole_helper.pkb' - -@@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' - ---event manager objects -@@install_component.sql 'core/events/ut_event_item.tps' -@@install_component.sql 'core/events/ut_event_listener.tps' -@@install_component.sql 'core/events/ut_event_manager.pks' -@@install_component.sql 'core/events/ut_event_manager.pkb' - ---core types -@@install_component.sql 'core/types/ut_run_info.tps' -@@install_component.sql 'core/types/ut_run_info.tpb' -@@install_component.sql 'core/types/ut_expectation_result.tps' -@@install_component.sql 'core/types/ut_expectation_results.tps' -@@install_component.sql 'core/types/ut_results_counter.tps' -@@install_component.sql 'core/types/ut_suite_item.tps' -@@install_component.sql 'core/types/ut_suite_items.tps' -@@install_component.sql 'core/types/ut_executable.tps' -@@install_component.sql 'core/types/ut_executables.tps' -@@install_component.sql 'core/types/ut_executable_test.tps' -@@install_component.sql 'core/types/ut_test.tps' -@@install_component.sql 'core/types/ut_logical_suite.tps' -@@install_component.sql 'core/types/ut_suite.tps' -@@install_component.sql 'core/types/ut_suite_context.tps' -@@install_component.sql 'core/types/ut_file_mapping.tps' -@@install_component.sql 'core/types/ut_file_mappings.tps' -@@install_component.sql 'core/types/ut_coverage_options.tps' -@@install_component.sql 'core/types/ut_run.tps' -@@install_component.sql 'core/types/ut_reporter_base.tps' -@@install_component.sql 'core/types/ut_reporters.tps' -@@install_component.sql 'core/types/ut_path_item.tps' -@@install_component.sql 'core/types/ut_path_items.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' -@@install_component.sql 'expectations/data_values/ut_key_anyval_pair.tps' -@@install_component.sql 'expectations/data_values/ut_key_anyval_pairs.tps' -@@install_component.sql 'expectations/data_values/ut_key_anyvalues.tps' - ---session_context -@@install_component.sql 'core/session_context/ut_session_context.pks' -@@install_component.sql 'core/session_context/ut_session_context.pkb' -@@install_component.sql 'core/session_context/ut_session_info.tps' -@@install_component.sql 'core/session_context/ut_session_info.tpb' - ---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' -@@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/output_buffers/ut_output_bulk_buffer.tps' -@@install_component.sql 'core/output_buffers/ut_output_bulk_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' -@@install_component.sql 'core/annotations/ut_annotated_objects.tps' -@@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' -@@install_component.sql 'core/annotations/ut_annotation_cache_manager.pkb' -@@install_component.sql 'core/annotations/ut_annotation_parser.pks' -@@install_component.sql 'core/annotations/ut_annotation_parser.pkb' -@@install_component.sql 'core/annotations/ut_annotation_manager.pks' -@@install_component.sql 'core/annotations/ut_annotation_manager.pkb' - ---suite builder -@@install_component.sql 'core/types/ut_suite_cache_row.tps' -@@install_component.sql 'core/types/ut_suite_cache_rows.tps' -@@install_component.sql 'core/ut_suite_cache_schema.sql' -@@install_component.sql 'core/ut_suite_cache_package.sql' -@@install_component.sql 'core/ut_suite_cache_seq.sql' -@@install_component.sql 'core/ut_suite_cache.sql' - -@@install_component.sql 'core/ut_suite_tag_filter.pks' -@@install_component.sql 'core/ut_suite_tag_filter.pkb' -@@install_component.sql 'core/ut_suite_cache_manager.pks' -@@install_component.sql 'core/ut_suite_cache_manager.pkb' -@@install_component.sql 'core/ut_suite_builder.pks' -@@install_component.sql 'core/ut_suite_builder.pkb' ---suite manager -@@install_component.sql 'core/ut_suite_manager.pks' -@@install_component.sql 'core/ut_suite_manager.pkb' - ---expectations execution state interface -@@install_component.sql 'core/ut_expectation_processor.pks' -@@install_component.sql 'core/ut_expectation_processor.pkb' - -prompt Installing PLSQL profiler objects into &&ut3_owner schema -@@core/coverage/proftab.sql - -prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema -@@core/coverage/dbms_plssqlcode.sql - -@@install_component.sql 'core/ut_file_mapper.pks' -@@install_component.sql 'core/ut_file_mapper.pkb' - - ---gathering coverage -@@install_component.sql 'core/coverage/ut_coverage_sources_tmp.sql' -@@install_component.sql 'core/coverage/ut_coverage_runs.sql' -@@install_component.sql 'core/coverage/ut_coverage_helper.pks' -@@install_component.sql 'core/coverage/ut_coverage_helper_block.pks' -@@install_component.sql 'core/coverage/ut_coverage_helper_profiler.pks' -@@install_component.sql 'core/coverage/ut_coverage.pks' -@@install_component.sql 'core/coverage/ut_coverage_block.pks' -@@install_component.sql 'core/coverage/ut_coverage_profiler.pks' -@@install_component.sql 'core/coverage/ut_coverage_reporter_base.tps' -@@install_component.sql 'core/coverage/ut_coverage_helper.pkb' -@@install_component.sql 'core/coverage/ut_coverage_helper_block.pkb' -@@install_component.sql 'core/coverage/ut_coverage_helper_profiler.pkb' -@@install_component.sql 'core/coverage/ut_coverage.pkb' -@@install_component.sql 'core/coverage/ut_coverage_block.pkb' -@@install_component.sql 'core/coverage/ut_coverage_profiler.pkb' -@@install_component.sql 'core/coverage/ut_coverage_reporter_base.tpb' - ---core type bodies -@@install_component.sql 'core/types/ut_results_counter.tpb' -@@install_component.sql 'core/types/ut_suite_item.tpb' -@@install_component.sql 'core/types/ut_test.tpb' -@@install_component.sql 'core/types/ut_logical_suite.tpb' -@@install_component.sql 'core/types/ut_suite.tpb' -@@install_component.sql 'core/types/ut_suite_context.tpb' -@@install_component.sql 'core/types/ut_coverage_options.tpb' -@@install_component.sql 'core/types/ut_run.tpb' -@@install_component.sql 'core/types/ut_expectation_result.tpb' -@@install_component.sql 'core/types/ut_reporter_base.tpb' -@@install_component.sql 'core/types/ut_output_reporter_base.tpb' -@@install_component.sql 'core/types/ut_file_mapping.tpb' -@@install_component.sql 'core/types/ut_executable.tpb' -@@install_component.sql 'core/types/ut_executable_test.tpb' -@@install_component.sql 'core/types/ut_console_reporter_base.tps' -@@install_component.sql 'core/types/ut_console_reporter_base.tpb' -@@install_component.sql 'core/types/ut_path_item.tpb' - ---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_blob.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_boolean.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_clob.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_date.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_dsinterval.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_number.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_refcursor.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_anydata.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_timestamp.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_timestamp_tz.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_timestamp_ltz.tps' -@@install_component.sql 'expectations/data_values/ut_data_value_varchar2.tps' -@@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_base.tps' -@@install_component.sql 'expectations/ut_expectation_base.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_within_pct.tps' -@@install_component.sql 'expectations/matchers/ut_be_within.tps' -@@install_component.sql 'expectations/matchers/ut_be_within_helper.pks' -@@install_component.sql 'expectations/ut_expectation.tps' -@@install_component.sql 'expectations/matchers/ut_be_false.tps' -@@install_component.sql 'expectations/matchers/ut_be_greater_or_equal.tps' -@@install_component.sql 'expectations/matchers/ut_be_greater_than.tps' -@@install_component.sql 'expectations/matchers/ut_be_less_or_equal.tps' -@@install_component.sql 'expectations/matchers/ut_be_less_than.tps' -@@install_component.sql 'expectations/matchers/ut_be_like.tps' -@@install_component.sql 'expectations/matchers/ut_be_not_null.tps' -@@install_component.sql 'expectations/matchers/ut_be_null.tps' -@@install_component.sql 'expectations/matchers/ut_be_true.tps' -@@install_component.sql 'expectations/matchers/ut_equal.tps' -@@install_component.sql 'expectations/matchers/ut_contain.tps' -@@install_component.sql 'expectations/matchers/ut_have_count.tps' -@@install_component.sql 'expectations/matchers/ut_be_between.tps' -@@install_component.sql 'expectations/matchers/ut_be_empty.tps' -@@install_component.sql 'expectations/matchers/ut_match.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' -@@install_component.sql 'expectations/data_values/ut_data_value.tpb' -@@install_component.sql 'expectations/data_values/ut_compound_data_value.tpb' -@@install_component.sql 'expectations/data_values/ut_compound_data_helper.pkb' -@@install_component.sql 'expectations/data_values/ut_data_value_blob.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_boolean.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_clob.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_date.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_dsinterval.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_number.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_refcursor.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_anydata.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_timestamp.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_timestamp_tz.tpb' -@@install_component.sql 'expectations/data_values/ut_data_value_timestamp_ltz.tpb' -@@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' -@@install_component.sql 'expectations/matchers/ut_be_greater_or_equal.tpb' -@@install_component.sql 'expectations/matchers/ut_be_greater_than.tpb' -@@install_component.sql 'expectations/matchers/ut_be_less_or_equal.tpb' -@@install_component.sql 'expectations/matchers/ut_be_less_than.tpb' -@@install_component.sql 'expectations/matchers/ut_be_like.tpb' -@@install_component.sql 'expectations/matchers/ut_be_not_null.tpb' -@@install_component.sql 'expectations/matchers/ut_be_null.tpb' -@@install_component.sql 'expectations/matchers/ut_be_true.tpb' -@@install_component.sql 'expectations/matchers/ut_equal.tpb' -@@install_component.sql 'expectations/matchers/ut_be_within_pct.tpb' -@@install_component.sql 'expectations/matchers/ut_be_within.tpb' -@@install_component.sql 'expectations/matchers/ut_be_within_helper.pkb' -@@install_component.sql 'expectations/matchers/ut_contain.tpb' -@@install_component.sql 'expectations/matchers/ut_have_count.tpb' -@@install_component.sql 'expectations/matchers/ut_be_between.tpb' -@@install_component.sql 'expectations/matchers/ut_be_empty.tpb' -@@install_component.sql 'expectations/matchers/ut_match.tpb' -@@install_component.sql 'expectations/ut_expectation_base.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 -@@install_component.sql 'reporters/ut_documentation_reporter.tps' -@@install_component.sql 'reporters/ut_documentation_reporter.tpb' - ---plugin interface API for running utPLSQL -@@install_component.sql 'api/ut_runner.pks' -@@install_component.sql 'api/ut_runner.pkb' - ---developer interface for expectations and running utPLSQL -@@install_component.sql 'api/ut.pks' -@@install_component.sql 'api/ut.pkb' - ---additional reporters -@@install_component.sql 'reporters/ut_debug_reporter.tps' -@@install_component.sql 'reporters/ut_debug_reporter.tpb' -@@install_component.sql 'reporters/ut_teamcity_reporter.tps' -@@install_component.sql 'reporters/ut_teamcity_reporter_helper.pks' -@@install_component.sql 'reporters/ut_teamcity_reporter_helper.pkb' -@@install_component.sql 'reporters/ut_teamcity_reporter.tpb' -@@install_component.sql 'reporters/ut_junit_reporter.tps' -@@install_component.sql 'reporters/ut_junit_reporter.tpb' -@@install_component.sql 'reporters/ut_tfs_junit_reporter.tps' -@@install_component.sql 'reporters/ut_tfs_junit_reporter.tpb' -@@install_component.sql 'reporters/ut_xunit_reporter.tps' -@@install_component.sql 'reporters/ut_xunit_reporter.tpb' -@@install_component.sql 'reporters/ut_sonar_test_reporter.tps' -@@install_component.sql 'reporters/ut_sonar_test_reporter.tpb' -@@install_component.sql 'reporters/ut_tap_reporter.tps' -@@install_component.sql 'reporters/ut_tap_reporter.tpb' - -@@install_component.sql 'reporters/ut_coverage_html_reporter.tps' -@@install_component.sql 'reporters/ut_coverage_report_html_helper.pks' -@@install_component.sql 'reporters/ut_coverage_report_html_helper.pkb' -@@install_component.sql 'reporters/ut_coverage_html_reporter.tpb' -@@install_component.sql 'reporters/ut_coverage_sonar_reporter.tps' -@@install_component.sql 'reporters/ut_coverage_sonar_reporter.tpb' -@@install_component.sql 'reporters/ut_coveralls_reporter.tps' -@@install_component.sql 'reporters/ut_coveralls_reporter.tpb' -@@install_component.sql 'reporters/ut_coverage_cobertura_reporter.tps' -@@install_component.sql 'reporters/ut_coverage_cobertura_reporter.tpb' -@@install_component.sql 'reporters/ut_realtime_reporter.tps' -@@install_component.sql 'reporters/ut_realtime_reporter.tpb' - -@@install_component.sql 'api/be_between.syn' -@@install_component.sql 'api/be_empty.syn' -@@install_component.sql 'api/be_false.syn' -@@install_component.sql 'api/be_greater_or_equal.syn' -@@install_component.sql 'api/be_greater_than.syn' -@@install_component.sql 'api/be_less_or_equal.syn' -@@install_component.sql 'api/be_less_than.syn' -@@install_component.sql 'api/be_like.syn' -@@install_component.sql 'api/be_not_null.syn' -@@install_component.sql 'api/be_null.syn' -@@install_component.sql 'api/be_true.syn' -@@install_component.sql 'api/be_within_pct.syn' -@@install_component.sql 'api/be_within.syn' -@@install_component.sql 'api/equal.syn' -@@install_component.sql 'api/have_count.syn' -@@install_component.sql 'api/match.syn' -@@install_component.sql 'api/contain.syn' - -set linesize 200 -set define on -column text format a100 -column error_count noprint new_value error_count - -prompt Validating installation -prompt &&line_separator -set heading on -select type, name, sequence, line, position, text, count(1) over() error_count - from all_errors - where owner = upper('&&ut3_owner') - and name not like 'BIN$%' --not recycled - and (name = 'UT' or name like 'UT\_%' escape '\') - -- 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'); - dbms_output.put_line('&&line_separator'); - end if; -end; -/ - -spool off diff --git a/source/install_above_12_1.sql b/source/install_above_12_1.sql deleted file mode 100644 index 69e47ce9a..000000000 --- a/source/install_above_12_1.sql +++ /dev/null @@ -1,27 +0,0 @@ -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release >= 2 - or dbms_db_version.version > 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ - -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - -set heading off -set feedback off -exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1))); -@@&&SCRIPT_NAME -exec dbms_output.put_line('&&line_separator'); - - - diff --git a/source/install_component.sql b/source/install_component.sql deleted file mode 100644 index 373c85c54..000000000 --- a/source/install_component.sql +++ /dev/null @@ -1,23 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 heading off -set feedback off -exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1))); -@@&&1 -show errors -exec dbms_output.put_line('&&line_separator'); - diff --git a/source/install_ddl_trigger.sql b/source/install_ddl_trigger.sql deleted file mode 100644 index bc147c2be..000000000 --- a/source/install_ddl_trigger.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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'" - -grant administer database trigger to &&ut3_owner; -@@install_component.sql 'core/annotations/ut_trigger_annotation_parsing.trg' -revoke administer database trigger from &&ut3_owner; diff --git a/source/install_headless.sql b/source/install_headless.sql deleted file mode 100644 index 183262675..000000000 --- a/source/install_headless.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 - -exit diff --git a/source/install_headless_with_trigger.sql b/source/install_headless_with_trigger.sql deleted file mode 100644 index 76ae48ccb..000000000 --- a/source/install_headless_with_trigger.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 &&ut3_owner - -exit diff --git a/source/license.txt b/source/license.txt new file mode 100644 index 000000000..8f5b408d9 --- /dev/null +++ b/source/license.txt @@ -0,0 +1,281 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 + Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/source/reporters/ut_ansiconsole_helper.pkb b/source/reporters/ut_ansiconsole_helper.pkb deleted file mode 100644 index 53e6bc6aa..000000000 --- a/source/reporters/ut_ansiconsole_helper.pkb +++ /dev/null @@ -1,60 +0,0 @@ -create or replace package body ut_ansiconsole_helper as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_red constant varchar2(7) := chr(27) || '[31m'; - gc_green constant varchar2(7) := chr(27) || '[32m'; - gc_yellow constant varchar2(7) := chr(27) || '[33m'; - gc_cyan constant varchar2(7) := chr(27) || '[36m'; - gc_reset constant varchar2(7) := chr(27) || '[0m'; - g_enabled boolean := false; - - procedure color_enabled(a_enabled boolean) is - begin - g_enabled := a_enabled; - end; - - function add_color(a_text varchar2, a_color varchar2 := gc_reset) return varchar2 is - begin - if g_enabled and a_text is not null then - return a_color||a_text||gc_reset; - else - return a_text; - end if; - end; - - function red(a_text varchar2) return varchar2 is - begin - return add_color(a_text, gc_red); - end; - - function green(a_text varchar2) return varchar2 is - begin - return add_color(a_text, gc_green); - end; - - function yellow(a_text varchar2) return varchar2 is - begin - return add_color(a_text, gc_yellow); - end; - - function cyan(a_text varchar2) return varchar2 is - begin - return add_color(a_text, gc_cyan); - end; - -end; -/ diff --git a/source/reporters/ut_ansiconsole_helper.pks b/source/reporters/ut_ansiconsole_helper.pks deleted file mode 100644 index 217d36a49..000000000 --- a/source/reporters/ut_ansiconsole_helper.pks +++ /dev/null @@ -1,28 +0,0 @@ -create or replace package ut_ansiconsole_helper as - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - procedure color_enabled(a_enabled boolean); - - function red(a_text varchar2) return varchar2; - - function green(a_text varchar2) return varchar2; - - function yellow(a_text varchar2) return varchar2; - - function cyan(a_text varchar2) return varchar2; -end; -/ diff --git a/source/reporters/ut_coverage_cobertura_reporter.tpb b/source/reporters/ut_coverage_cobertura_reporter.tpb deleted file mode 100644 index d833ac0aa..000000000 --- a/source/reporters/ut_coverage_cobertura_reporter.tpb +++ /dev/null @@ -1,191 +0,0 @@ -create or replace type body ut_coverage_cobertura_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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,ut_output_bulk_buffer()); - 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_line_rate(a_lines_covered in integer, a_lines_hit in integer) return varchar2 is - begin - return to_char(round((case a_lines_covered when 0 then 0 else a_lines_covered/a_lines_hit end), 17), rpad('FM0.0',20,'9') , 'NLS_NUMERIC_CHARACTERS=''. '''); - end; - - procedure get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage, - a_lines_result in out nocopy clob, a_lines_hits out number, a_lines_total out number) is - l_file_part varchar2(32767); - l_result clob; - l_line_no binary_integer; - l_pct integer; - l_lines_hits integer := 0; - l_lines_total integer := 0; - 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; - l_lines_hits:=0; - l_lines_total:= a_unit_coverage.total_lines; - 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_lines_hits:= l_lines_hits+1; - 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); - l_lines_total := l_lines_total + 1; - end loop; - end if; - a_lines_result := l_result; - a_lines_hits :=l_lines_hits; - a_lines_total := l_lines_total; - 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_lines_xml clob; - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_object_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_classes_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; - l_lines_valid integer := a_coverage_data.covered_lines + a_coverage_data.uncovered_lines; - l_line_hits integer; - l_line_total integer; - 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; - dbms_lob.createtemporary(l_lines_xml, true); - get_lines_xml(a_coverage_data.objects(l_unit),l_lines_xml,l_line_hits,l_line_total); - - 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, ''); - ut_utils.append_to_list( l_result,l_lines_xml); - dbms_lob.freetemporary(l_lines_xml); - - 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_classes_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 deleted file mode 100644 index 1292e60fb..000000000 --- a/source/reporters/ut_coverage_cobertura_reporter.tps +++ /dev/null @@ -1,28 +0,0 @@ -create or replace type ut_coverage_cobertura_reporter under ut_coverage_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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, - - overriding member procedure after_calling_run(self in out nocopy ut_coverage_cobertura_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -/ - diff --git a/source/reporters/ut_coverage_html_reporter.tpb b/source/reporters/ut_coverage_html_reporter.tpb deleted file mode 100644 index b1f9f6651..000000000 --- a/source/reporters/ut_coverage_html_reporter.tpb +++ /dev/null @@ -1,56 +0,0 @@ -create or replace type body ut_coverage_html_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_html_reporter( - self in out nocopy ut_coverage_html_reporter, - a_project_name varchar2 := null, - a_html_report_assets_path varchar2 := null - ) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - self.project_name := a_project_name; - assets_path := nvl(a_html_report_assets_path, ut_coverage_report_html_helper.get_default_html_assets_path()); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_coverage_html_reporter, a_run in ut_run) as - l_coverage_data ut_coverage.t_coverage; - begin - ut_coverage.coverage_stop(); - l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options); - - self.print_text_lines( - ut_coverage_report_html_helper.get_index( - a_coverage_data => l_coverage_data, - a_assets_path => self.assets_path, - a_project_name => self.project_name, - a_charset => a_run.client_character_set - ) - ); - end; - - - overriding member function get_description return varchar2 as - begin - return 'Generates a HTML coverage report with summary and line by line information on code coverage.' || chr(10) || - 'Based on open-source simplecov-html coverage reporter for Ruby.' || chr(10) || - 'Includes source code in the report.'; - end; - -end; -/ diff --git a/source/reporters/ut_coverage_html_reporter.tps b/source/reporters/ut_coverage_html_reporter.tps deleted file mode 100644 index 42f2fd4e3..000000000 --- a/source/reporters/ut_coverage_html_reporter.tps +++ /dev/null @@ -1,30 +0,0 @@ -create or replace type ut_coverage_html_reporter under ut_coverage_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - project_name varchar2(4000), - assets_path varchar2(4000), - constructor function ut_coverage_html_reporter( - self in out nocopy ut_coverage_html_reporter, - a_project_name varchar2 := null, - a_html_report_assets_path varchar2 := null - ) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_coverage_html_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -/ diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb deleted file mode 100644 index f7e0b5ed0..000000000 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ /dev/null @@ -1,360 +0,0 @@ -create or replace package body ut_coverage_report_html_helper is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_green_coverage_pct constant integer := 90; - gc_yellow_coverage_pct constant integer := 80; - - gc_green_css constant varchar2(10) := 'green'; - gc_yellow_css constant varchar2(10) := 'yellow'; - gc_red_css constant varchar2(10) := 'red'; - - gc_missed constant varchar2(7) := 'missed'; - gc_skipped constant varchar2(7) := 'skipped'; - gc_disabled constant varchar2(7) := 'never'; - gc_covered constant varchar2(7) := 'covered'; - gc_partcovered constant varchar2(7) := 'partcov'; - - function get_default_html_assets_path return varchar2 deterministic is - c_assets_path constant varchar2(200) := 'https://utplsql.github.io/utPLSQL-coverage-html/assets/'; - begin - return c_assets_path; - end; - - function coverage_css_class(a_covered_pct number) return varchar2 is - l_result varchar2(10); - begin - if a_covered_pct > gc_green_coverage_pct then - l_result := gc_green_css; - elsif a_covered_pct > gc_yellow_coverage_pct then - l_result := gc_yellow_css; - else - l_result := gc_red_css; - end if; - return l_result; - end; - - function line_status(a_executions in ut_coverage.t_line_executions) return varchar2 is - l_result varchar2(10); - begin - if a_executions.executions > 0 then - if NVL(a_executions.partcove,0) = 0 then - l_result := gc_covered; - else - l_result := gc_partcovered; - end if; - elsif a_executions.executions = 0 then - l_result := gc_missed; - else - l_result := gc_disabled; - end if; - return l_result; - end; - - function executions_per_line(a_executions number, a_lines integer) return integer is - begin - return nvl(a_executions / nullif(a_lines, 0), 0); - end; - - function line_hits_css_class(a_line_hist number) return varchar2 is - l_result varchar2(10); - begin - if a_line_hist > 1 then - l_result := gc_green_css; - elsif a_line_hist = 1 then - l_result := gc_yellow_css; - else - l_result := gc_red_css; - end if; - return l_result; - end; - - function coverage_pct(a_covered_lines integer, a_uncovered_lines integer) return number is - begin - return ROUND(nvl(a_covered_lines / nullif(a_covered_lines + a_uncovered_lines, 0), 0) * 100, 2); - end; - - function object_id(a_object_full_name varchar2) return varchar2 is - begin - return rawtohex(dbms_crypto.hash(src => utl_raw.cast_to_raw(a_object_full_name), typ => dbms_crypto.hash_md5)); - end; - - function link_to_source_file(a_object_full_name varchar2) return varchar2 is - begin - return '' || a_object_full_name || ''; - end; - - - - - function get_details_file_content( - a_object_id varchar2, - a_unit ut_object_name, - a_unit_coverage ut_coverage.t_unit_coverage - ) return ut_varchar2_rows is - - function get_block_file_attributes(a_coverage_unit ut_coverage.t_unit_coverage) return varchar2 is - l_result varchar2(32767); - begin - if (a_coverage_unit.partcovered_lines is not null) AND (a_coverage_unit.partcovered_lines > 0) then - l_result := ' (including '|| a_coverage_unit.partcovered_lines ||' lines partially covered )'; - else - l_result := null; - end if; - return l_result; - end; - - function get_common_file_attributes(a_coverage_unit ut_coverage.t_unit_coverage) return varchar2 is - l_attributes varchar2(32767); - begin - l_attributes := '
' ||(a_coverage_unit.covered_lines + a_coverage_unit.uncovered_lines) - ||' relevant lines. ' || '' || a_coverage_unit.covered_lines - ||' lines covered' - || get_block_file_attributes(a_coverage_unit) - || ' and ' || a_coverage_unit.uncovered_lines ||' lines missed'; - return l_attributes; - end; - - function build_details_file_content(a_object_id varchar2, a_object_full_name varchar2, a_source_code ut_varchar2_list, a_coverage_unit ut_coverage.t_unit_coverage) - return ut_varchar2_rows is - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_coverage_pct number(5, 2); - l_hits varchar2(30); - l_blocks varchar2(30); - l_line_text varchar2(32767); - e_buffer_too_small exception; - pragma exception_init ( e_buffer_too_small, -19011 ); - begin - - l_coverage_pct := coverage_pct(a_coverage_unit.covered_lines, a_coverage_unit.uncovered_lines); - - l_file_part := '

' || - dbms_xmlgen.convert(a_object_full_name) || '

' - || l_coverage_pct || ' % lines covered

' - ||get_common_file_attributes(a_coverage_unit) ||'
    '; - ut_utils.append_to_list(l_result, l_file_part); - - for line_no in 1 .. a_source_code.count loop - begin - l_line_text := dbms_xmlgen.convert(a_source_code(line_no)); - exception - when e_buffer_too_small then - l_line_text := dbms_xmlgen.convert(to_clob(a_source_code(line_no))); - end; - if not a_coverage_unit.lines.exists(line_no) then - l_file_part := ' -
  1. - ' || l_line_text || - '
  2. '; - else - l_hits := to_char(a_coverage_unit.lines(line_no).executions); - if nvl(a_coverage_unit.lines(line_no).covered_blocks,0) < nvl(a_coverage_unit.lines(line_no).no_blocks,0) - and nvl(a_coverage_unit.lines(line_no).partcove,0) = 1 then - l_blocks := to_char(a_coverage_unit.lines(line_no).covered_blocks) || chr(47)|| - to_char(a_coverage_unit.lines(line_no).no_blocks); - else - l_blocks := null; - end if; - - l_file_part := ' -
  3. '; - if a_coverage_unit.lines(line_no).executions > 0 then - - l_file_part := l_file_part || - case when l_blocks is not null - then ' - ' ||dbms_xmlgen.convert(l_blocks) || - '' - else - null - end - || ' - ' || dbms_xmlgen.convert(l_hits) || - ''; - end if; - l_file_part := l_file_part || ' - ' || l_line_text || - '
  4. '; - end if; - ut_utils.append_to_list(l_result, l_file_part); - end loop; - - l_file_part := '
'; - ut_utils.append_to_list(l_result, l_file_part); - return l_result; - end; - begin - return build_details_file_content( - a_object_id, - a_unit.identity, - ut_coverage_helper.get_tmp_table_object_lines(a_unit.owner, a_unit.name), - a_unit_coverage - ); - end; - - function get_block_list_attributes(a_coverage_unit ut_coverage.t_coverage) return varchar2 is - l_result varchar2(32767); - begin - if (a_coverage_unit.partcovered_lines is not null) AND (a_coverage_unit.partcovered_lines > 0) then - l_result := ' (including '|| a_coverage_unit.partcovered_lines ||' lines partially covered )'; - else - l_result := null; - end if; - return l_result; - end; - - function file_list(a_title varchar2, a_coverage ut_coverage.t_coverage) return ut_varchar2_rows is - l_file_part varchar2(32767); - l_title varchar2(100) := 'All files'; - l_coverage_pct number(5, 2); - l_result ut_varchar2_rows; - l_id varchar2(50) := object_id(a_title); - l_unit_coverage ut_coverage.t_unit_coverage; - l_unit ut_coverage.t_object_name; - begin - l_coverage_pct := coverage_pct(a_coverage.covered_lines, a_coverage.uncovered_lines); - - l_file_part := '
' || '

' || l_title || - '' || ' (' || - l_coverage_pct || '%' || ' lines covered'|| - ' at ' || - '' || - executions_per_line(a_coverage.executions, a_coverage.uncovered_lines + a_coverage.covered_lines) - || ' hits/line)

' || '' || '
' || - a_coverage.objects.count || ' files in total.
' || '' || - (a_coverage.uncovered_lines + a_coverage.covered_lines) - || ' relevant lines. ' || '' || a_coverage.covered_lines || - ' lines covered'|| get_block_list_attributes(a_coverage) - ||' and ' || a_coverage.uncovered_lines || ' lines missed.'|| - '' || '' || - '' || - ''; - ut_utils.append_to_list( l_result, l_file_part ); - l_unit := a_coverage.objects.first; - loop - exit when l_unit is null; - l_unit_coverage := a_coverage.objects(l_unit); - l_coverage_pct := coverage_pct(l_unit_coverage.covered_lines, l_unit_coverage.uncovered_lines); - - l_file_part := chr(10) || '' || '' || '' || '' || '' || '' || - ''; - ut_utils.append_to_list( l_result, l_file_part ); - l_unit := a_coverage.objects.next(l_unit); - end loop; - l_file_part := '
File% coveredLinesRelevant LinesLines coveredLines missed' - ||'Avg. Hits / Line
' || link_to_source_file(dbms_xmlgen.convert(l_unit)) || - '' || l_coverage_pct || - ' %' || l_unit_coverage.total_lines || '' || - (l_unit_coverage.covered_lines + l_unit_coverage.uncovered_lines) || '' || - l_unit_coverage.covered_lines || '' || l_unit_coverage.uncovered_lines || '' || to_char(executions_per_line(l_unit_coverage.executions - ,l_unit_coverage.uncovered_lines + l_unit_coverage.covered_lines)) - || '
'; - ut_utils.append_to_list( l_result, l_file_part ); - return l_result; - end; - - /* - * public definitions - */ - function get_index( - a_coverage_data ut_coverage.t_coverage, - a_assets_path varchar2, - a_project_name varchar2 := null, - a_command_line varchar2 := null, - a_charset varchar2 := null - ) return ut_varchar2_rows is - - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_title varchar2(250); - l_coverage_pct number(5, 2); - l_time_str varchar2(50); - l_using varchar2(1000); - l_unit ut_coverage.t_object_name; - l_charset varchar2(1000); - begin - l_charset := coalesce(upper(a_charset),'UTF-8'); - l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines); - - l_time_str := to_char(sysdate,'yyyy-mm-dd"T"hh24:mi:ss'); - l_using := case - when a_command_line is not null then - '
using ' || dbms_xmlgen.convert(a_command_line) - end; - l_title := case - when a_project_name is null then - 'Code coverage' - else - dbms_xmlgen.convert(a_project_name) || ' code coverage' - end; - --TODO - build main file containing total run data and per schema data - l_file_part := '' || '' || l_title || - '' || '' || - '' || - '' || - '' || '' || '' || - '
loading
' || - '
'; - - ut_utils.append_to_list(l_result, l_file_part); - return l_result; - end; - -end; -/ diff --git a/source/reporters/ut_coverage_report_html_helper.pks b/source/reporters/ut_coverage_report_html_helper.pks deleted file mode 100644 index 42a59c123..000000000 --- a/source/reporters/ut_coverage_report_html_helper.pks +++ /dev/null @@ -1,43 +0,0 @@ -create or replace package ut_coverage_report_html_helper authid current_user is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - function get_default_html_assets_path return varchar2 deterministic; - - function coverage_pct(a_covered_lines integer, a_uncovered_lines integer) return number; - - function coverage_css_class(a_covered_pct number) return varchar2; - - function line_status(a_executions in ut_coverage.t_line_executions) return varchar2; - - function link_to_source_file(a_object_full_name varchar2) return varchar2; - - function object_id(a_object_full_name varchar2) return varchar2; - - function executions_per_line(a_executions number, a_lines integer) return integer; - - function line_hits_css_class(a_line_hist number) return varchar2; - - function get_index( - a_coverage_data ut_coverage.t_coverage, - a_assets_path varchar2, - a_project_name varchar2 := null, - a_command_line varchar2 := null, - a_charset varchar2 := null - ) return ut_varchar2_rows; - -end; -/ diff --git a/source/reporters/ut_coverage_sonar_reporter.tpb b/source/reporters/ut_coverage_sonar_reporter.tpb deleted file mode 100644 index 1861a9be3..000000000 --- a/source/reporters/ut_coverage_sonar_reporter.tpb +++ /dev/null @@ -1,112 +0,0 @@ -create or replace type body ut_coverage_sonar_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_sonar_reporter( - self in out nocopy ut_coverage_sonar_reporter - ) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - - overriding member procedure after_calling_run(self in out nocopy ut_coverage_sonar_reporter, a_run in ut_run) as - - function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return ut_varchar2_rows is - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_line_no binary_integer; - begin - 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_list(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 := ''; - else - l_file_part := ''; - end if; - ut_utils.append_to_list(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_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_object_name; - c_coverage_header constant varchar2(30) := ''; - c_file_footer constant varchar2(30) := ''; - c_coverage_footer constant varchar2(30) := ''; - 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_header); - l_unit := a_coverage_data.objects.first; - while l_unit is not null loop - 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_file_footer); - - l_unit := a_coverage_data.objects.next(l_unit); - end loop; - ut_utils.append_to_list(l_result, c_coverage_footer); - return l_result; - end; - - begin --- execute immediate 'alter session set statistics_level=all'; --- dbms_hprof.start_profiling( --- location => 'PLSHPROF_DIR' --- , filename => 'profiler_utPLSQL_run_on_'||$$plsql_unit||'_'||rawtohex(self.id)||'.txt' --- ); --- - ut_coverage.coverage_stop(); - - self.print_text_lines( - get_coverage_xml( - ut_coverage.get_coverage_data(a_run.coverage_options), - a_run - ) - ); --- dbms_hprof.stop_profiling; - end; - - overriding member function get_description return varchar2 as - begin - return 'Generates a XML coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for [SonarQube](https://www.sonarqube.org/) to report coverage.' || chr(10) || - 'XML format returned conforms with the Sonar specification: https://docs.sonarqube.org/latest/analysis/generic-test/'; - end; - -end; -/ diff --git a/source/reporters/ut_coverage_sonar_reporter.tps b/source/reporters/ut_coverage_sonar_reporter.tps deleted file mode 100644 index 715bdefd2..000000000 --- a/source/reporters/ut_coverage_sonar_reporter.tps +++ /dev/null @@ -1,31 +0,0 @@ -create or replace type ut_coverage_sonar_reporter under ut_coverage_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Builds a coverage XML report that follows rules described in - * https://docs.sonarqube.org/latest/analysis/generic-test/ - */ - constructor function ut_coverage_sonar_reporter( - self in out nocopy ut_coverage_sonar_reporter - ) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_coverage_sonar_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -/ diff --git a/source/reporters/ut_coveralls_reporter.tpb b/source/reporters/ut_coveralls_reporter.tpb deleted file mode 100644 index 14672303e..000000000 --- a/source/reporters/ut_coveralls_reporter.tpb +++ /dev/null @@ -1,104 +0,0 @@ -create or replace type body ut_coveralls_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_coveralls_reporter( - self in out nocopy ut_coveralls_reporter - ) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run) as - - function get_lines_json(a_unit_coverage ut_coverage.t_unit_coverage) return ut_varchar2_rows is - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_last_line_no binary_integer; - c_coverage_header constant varchar2(30) := '"coverage": ['; - c_null constant varchar2(4) := 'null'; - begin - ut_utils.append_to_list(l_result, c_coverage_header); - - l_last_line_no := a_unit_coverage.lines.last; - if l_last_line_no is null then - ut_utils.append_to_list( - l_result - , rpad( to_clob( '0' ), ( a_unit_coverage.total_lines * 3 ) - 2, ','||chr(10)||'0' ) - ); - else - for line_no in 1 .. l_last_line_no loop - if a_unit_coverage.lines.exists(line_no) then - l_file_part := to_char(a_unit_coverage.lines(line_no).executions); - else - l_file_part := c_null; - end if; - if line_no < l_last_line_no then - l_file_part := l_file_part ||','; - end if; - ut_utils.append_to_list(l_result, l_file_part); - end loop; - end if; - ut_utils.append_to_list(l_result, ']'); - return l_result; - end; - - function get_coverage_json( - a_coverage_data ut_coverage.t_coverage - ) return ut_varchar2_rows is - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_object_name; - c_coverage_header constant varchar2(30) := '{"source_files":['; - c_coverage_footer constant varchar2(30) := ']}'||chr(10)||' '; - begin - ut_utils.append_to_list(l_result, c_coverage_header); - l_unit := a_coverage_data.objects.first; - while l_unit is not null loop - ut_utils.append_to_list(l_result, '{ "name": "'||l_unit||'",'); - - ut_utils.append_to_list(l_result,get_lines_json(a_coverage_data.objects(l_unit))); - - ut_utils.append_to_list(l_result, '}'); - - l_unit := a_coverage_data.objects.next(l_unit); - if l_unit is not null then - ut_utils.append_to_list(l_result, ','); - end if; - end loop; - ut_utils.append_to_list(l_result, c_coverage_footer); - return l_result; - end; - begin - ut_coverage.coverage_stop(); - - self.print_text_lines( - get_coverage_json( - ut_coverage.get_coverage_data(a_run.coverage_options) - ) - ); - end; - - overriding member function get_description return varchar2 as - begin - return 'Generates a JSON coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for [Coveralls](https://coveralls.io/).' || chr(10) || - 'JSON format conforms with specification: https://docs.coveralls.io/api-introduction'; - end; - -end; -/ diff --git a/source/reporters/ut_coveralls_reporter.tps b/source/reporters/ut_coveralls_reporter.tps deleted file mode 100644 index 74363b751..000000000 --- a/source/reporters/ut_coveralls_reporter.tps +++ /dev/null @@ -1,31 +0,0 @@ -create or replace type ut_coveralls_reporter under ut_coverage_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Builds a coverage XML report that follows rules described in - * https://docs.coveralls.io/api-introduction - */ - constructor function ut_coveralls_reporter( - self in out nocopy ut_coveralls_reporter - ) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -/ diff --git a/source/reporters/ut_debug_reporter.tpb b/source/reporters/ut_debug_reporter.tpb deleted file mode 100644 index 879725172..000000000 --- a/source/reporters/ut_debug_reporter.tpb +++ /dev/null @@ -1,79 +0,0 @@ -create or replace type body ut_debug_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_debug_reporter(self in out nocopy ut_debug_reporter) return self as result is - begin - self.init($$plsql_unit,ut_output_clob_table_buffer()); - self.start_time := current_timestamp(); - self.event_time := current_timestamp(); - return; - end; - - overriding member function get_supported_events return ut_varchar2_list is - begin - return ut_varchar2_list(ut_event_manager.gc_all); - end; - - overriding member procedure on_event( self in out nocopy ut_debug_reporter, a_event_name varchar2, a_event_item ut_event_item) is - c_time constant timestamp := current_timestamp(); - c_time_from_start constant interval day(0) to second(6) := (c_time - self.start_time); - c_time_from_prev constant interval day(0) to second(6) := (c_time - self.event_time); - l_stack varchar2(32767) := dbms_utility.format_call_stack(); - begin - l_stack := regexp_replace( - substr( l_stack, instr( l_stack, chr(10), 1, 6 ) +1 ), - '[0-9abcdefx]+ +([0-9]+) +(package |type )?(body )?(.*)','at "\4", line \1'); - - if a_event_name = ut_event_manager.gc_initialize then - self.on_initialize(null); - self.print_text('', ut_event_manager.gc_debug); - end if; - self.print_text('', ut_event_manager.gc_debug); - self.print_text( - ' ' || ut_utils.to_string(c_time) || '' || chr(10) - || ' ' || c_time_from_start || '' || chr(10) - || ' ' || c_time_from_prev || '' || chr(10) - || ' ' || a_event_name || '', - ut_event_manager.gc_debug - ); - self.print_text( ' ' || l_stack || '', ut_event_manager.gc_debug); - if a_event_item is not null then - self.print_text_lines( - ut_utils.convert_collection( - ut_utils.clob_to_table( event_item_to_clob(a_event_item), ut_utils.gc_max_storage_varchar2_len ) - ), - ut_event_manager.gc_debug - ); - end if; - self.print_text('', ut_event_manager.gc_debug); - if a_event_name = ut_event_manager.gc_finalize then - self.print_text('', ut_event_manager.gc_debug); - self.on_finalize(null); - end if; - self.event_time := current_timestamp(); - end; - - member function event_item_to_clob(a_event_item ut_event_item) return clob is - l_clob clob; - begin - select /*+ no_parallel */ xmlserialize( content deletexml(xmltype(a_event_item),'/*/ITEMS|/*/ALL_EXPECTATIONS|/*/FAILED_EXPECTATIONS') as clob indent size = 2 ) into l_clob from dual; - return l_clob; - end; - -end; -/ \ No newline at end of file diff --git a/source/reporters/ut_debug_reporter.tps b/source/reporters/ut_debug_reporter.tps deleted file mode 100644 index 2123f19cc..000000000 --- a/source/reporters/ut_debug_reporter.tps +++ /dev/null @@ -1,34 +0,0 @@ -create or replace type ut_debug_reporter under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - start_time timestamp, - event_time timestamp, - constructor function ut_debug_reporter(self in out nocopy ut_debug_reporter) return self as result, - /** - * Returns the list of events that are supported by particular implementation of the reporter - */ - overriding member function get_supported_events return ut_varchar2_list, - - /** - * Delegates execution of event into individual reporting procedures - */ - overriding member procedure on_event( self in out nocopy ut_debug_reporter, a_event_name varchar2, a_event_item ut_event_item), - - member function event_item_to_clob(a_event_item ut_event_item) return clob - -) -/ \ No newline at end of file diff --git a/source/reporters/ut_documentation_reporter.tpb b/source/reporters/ut_documentation_reporter.tpb deleted file mode 100644 index e8c0a4e31..000000000 --- a/source/reporters/ut_documentation_reporter.tpb +++ /dev/null @@ -1,229 +0,0 @@ -create or replace type body ut_documentation_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_documentation_reporter(self in out nocopy ut_documentation_reporter) return self as result is - begin - self.init($$plsql_unit); - self.lvl := 0; - self.failed_test_running_count := 0; - return; - end; - - member function tab(self in ut_documentation_reporter) return varchar2 is - begin - return rpad(' ', self.lvl * 2); - end tab; - - overriding member procedure print_clob(self in out nocopy ut_documentation_reporter, a_clob clob, a_item_type varchar2 := null) is - l_lines ut_varchar2_list; - l_out_lines ut_varchar2_rows := ut_varchar2_rows(); - begin - if a_clob is not null and dbms_lob.getlength(a_clob) > 0 then - l_lines := ut_utils.clob_to_table(a_clob, ut_utils.gc_max_storage_varchar2_len - length(nvl(tab(),0))); - for i in 1 .. l_lines.count loop - if l_lines(i) is not null then - ut_utils.append_to_list(l_out_lines, tab() || l_lines(i) ); - end if; - end loop; - (self as ut_output_reporter_base).print_text_lines(l_out_lines, a_item_type); - end if; - end; - - overriding member procedure print_text(self in out nocopy ut_documentation_reporter, a_text varchar2, a_item_type varchar2 := null) is - l_lines ut_varchar2_list; - begin - if a_text is not null then - l_lines := ut_utils.string_to_table(a_text); - for i in 1 .. l_lines.count loop - (self as ut_output_reporter_base).print_text(tab || l_lines(i), a_item_type); - end loop; - end if; - end; - - overriding member procedure before_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as - begin - self.print_text(coalesce(a_suite.description, a_suite.name)); - lvl := lvl + 1; - end; - - overriding member procedure after_calling_test(self in out nocopy ut_documentation_reporter, a_test ut_test) as - l_message varchar2(4000); - - begin - l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]'; - --if test failed, then add it to the failures list, print failure with number - if a_test.result = ut_utils.gc_disabled then - self.print_yellow_text(l_message || ' (DISABLED'|| - case when a_test.disabled_reason is not null - then ' - '||a_test.disabled_reason - else null - end || ')'); - elsif a_test.result = ut_utils.gc_success then - self.print_green_text(l_message); - elsif a_test.result > ut_utils.gc_success then - failed_test_running_count := failed_test_running_count + 1; - self.print_red_text(l_message || ' (FAILED - ' || failed_test_running_count || ')'); - end if; - - -- reproduce the output from before/after procedures and the test - self.print_clob(a_test.get_serveroutputs); - end; - - overriding member procedure after_calling_before_all(self in out nocopy ut_documentation_reporter, a_executable in ut_executable) is - begin - if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then - self.print_clob(a_executable.serveroutput); - end if; - end; - - overriding member procedure after_calling_after_all(self in out nocopy ut_documentation_reporter, a_executable in ut_executable) is - begin - if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then - self.print_clob(a_executable.serveroutput); - end if; - end; - - overriding member procedure after_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as - begin - lvl := lvl - 1; - if lvl = 0 then - self.print_text(' '); - end if; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_documentation_reporter, a_run in ut_run) as - l_summary_text varchar2(4000); - l_warning_index pls_integer := 0; - -- make all warning indexes uniformly indented - c_warnings_lpad constant integer := length(to_char(a_run.results_count.warnings_count)); - - procedure print_failure_for_expectation(a_expectation ut_expectation_result) is - l_lines ut_varchar2_list; - begin - l_lines := a_expectation.get_result_lines(); - for i in 1 .. l_lines.count loop - self.print_red_text(l_lines(i)); - end loop; - self.print_cyan_text(a_expectation.caller_info); - self.print_text(' '); - end; - - procedure print_failures_for_test(a_test ut_test, a_failure_no in out nocopy integer) is - begin - if a_test.result > ut_utils.gc_success then - a_failure_no := a_failure_no + 1; - self.print_text(lpad(a_failure_no, length(failed_test_running_count) + 2, ' ') || ') ' || - nvl(a_test.name, a_test.item.form_name)); - self.lvl := self.lvl + 3; - - self.print_red_text(ut_utils.table_to_clob(a_test.get_error_stack_traces())); - - for j in 1 .. a_test.failed_expectations.count loop - print_failure_for_expectation(a_test.failed_expectations(j)); - end loop; - - self.lvl := self.lvl - 3; - end if; - end; - - procedure print_failures_from_suite(a_suite ut_logical_suite, a_failure_no in out nocopy integer) is - begin - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_logical_suite) then - print_failures_from_suite(treat(a_suite.items(i) as ut_logical_suite), a_failure_no); - elsif a_suite.items(i) is of(ut_test) then - print_failures_for_test(treat(a_suite.items(i) as ut_test), a_failure_no); - end if; - end loop; - end; - - procedure print_failures_details(a_run in ut_run) is - l_failure_no integer := 0; - begin - if a_run.results_count.failure_count > 0 or a_run.results_count.errored_count > 0 then - - self.print_text('Failures:'); - self.print_text(' '); - for i in 1 .. a_run.items.count loop - print_failures_from_suite(treat(a_run.items(i) as ut_logical_suite), l_failure_no); - end loop; - end if; - end; - - procedure print_item_warnings(a_item in ut_suite_item) is - l_items ut_suite_items; - begin - if a_item is of (ut_logical_suite) then - l_items := treat(a_item as ut_logical_suite).items; - for i in 1 .. l_items.count loop - print_item_warnings(l_items(i)); - end loop; - end if; - - if a_item.warnings is not null and a_item.warnings.count > 0 then - for i in 1 .. a_item.warnings.count loop - l_warning_index := l_warning_index + 1; - self.print_text(' ' || lpad(l_warning_index, c_warnings_lpad) || ') ' || a_item.path); - self.lvl := self.lvl + 3; - self.print_red_text(a_item.warnings(i)); - self.lvl := self.lvl - 3; - end loop; - self.print_text(' '); - end if; - end; - - procedure print_warnings(a_run in ut_run) is - begin - if a_run.results_count.warnings_count > 0 then - self.print_text(' '); - self.print_text('Warnings:'); - self.print_text(' '); - for i in 1 .. a_run.items.count loop - print_item_warnings(treat(a_run.items(i) as ut_suite_item)); - end loop; - end if; - end; - - begin - print_failures_details(a_run); - print_warnings(a_run); - self.print_text('Finished in ' || ut_utils.interval_to_text(numtodsinterval(a_run.execution_time,'second')) ); - - l_summary_text := - a_run.results_count.total_count || ' tests, ' - || a_run.results_count.failure_count || ' failed, ' || a_run.results_count.errored_count || ' errored, ' - || a_run.results_count.disabled_count ||' disabled, ' || a_run.results_count.warnings_count || ' warning(s)'; - if a_run.results_count.failure_count + a_run.results_count.errored_count + a_run.results_count.warnings_count > 0 then - self.print_red_text(l_summary_text); - 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; - - overriding member function get_description return varchar2 as - begin - return 'A textual pretty-print of unit test results (usually use for console output)'; - end; - -end; -/ diff --git a/source/reporters/ut_documentation_reporter.tps b/source/reporters/ut_documentation_reporter.tps deleted file mode 100644 index 422225117..000000000 --- a/source/reporters/ut_documentation_reporter.tps +++ /dev/null @@ -1,36 +0,0 @@ -create or replace type ut_documentation_reporter under ut_console_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - lvl integer, - failed_test_running_count integer, - constructor function ut_documentation_reporter(self in out nocopy ut_documentation_reporter) return self as result, - member function tab(self in ut_documentation_reporter) return varchar2, - - overriding member procedure print_clob(self in out nocopy ut_documentation_reporter, a_clob clob, a_item_type varchar2 := null), - overriding member procedure print_text(self in out nocopy ut_documentation_reporter, a_text varchar2, a_item_type varchar2 := null), - overriding member procedure before_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite), - overriding member procedure after_calling_test(self in out nocopy ut_documentation_reporter, a_test ut_test), - overriding member procedure after_calling_after_all (self in out nocopy ut_documentation_reporter, a_executable in ut_executable), - overriding member procedure after_calling_before_all (self in out nocopy ut_documentation_reporter, a_executable in ut_executable), - overriding member procedure after_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite), - overriding member procedure after_calling_run(self in out nocopy ut_documentation_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 - -) -not final -/ diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb deleted file mode 100644 index 3bceb52a4..000000000 --- a/source/reporters/ut_junit_reporter.tpb +++ /dev/null @@ -1,163 +0,0 @@ -create or replace type body ut_junit_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_junit_reporter(self in out nocopy ut_junit_reporter) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_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_path(a_path_with_name varchar2, a_name varchar2) return varchar2 is - begin - return regexp_substr(a_path_with_name, '(.*)\.' ||a_name||'$',subexpression=>1); - end; - - procedure print_test_elements(a_test ut_test) is - l_results ut_varchar2_rows := ut_varchar2_rows(); - l_output clob; - begin - ut_utils.append_to_list( - l_results, - '' - ); - if a_test.result = ut_utils.gc_disabled then - if a_test.disabled_reason is not null then - ut_utils.append_to_list( l_results, '' ); - ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.disabled_reason ) ); - ut_utils.append_to_list( l_results, '' ); - else - ut_utils.append_to_list( l_results, '' ); - end if; - 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, 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, ''); - 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; - - 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, ut_utils.to_cdata( a_test.get_serveroutputs() ) ); - ut_utils.append_to_list( l_results, '' ); - else - ut_utils.append_to_list( l_results, ''); - end if; - ut_utils.append_to_list( l_results, ''); - ut_utils.append_to_list( l_results, ''); - - self.print_text_lines(l_results); - end; - - procedure print_suite_elements(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is - 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(); - l_results ut_varchar2_rows := ut_varchar2_rows(); - l_data clob; - 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. - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_test) then - l_tests.extend; - l_tests(l_tests.last) := treat(a_suite.items(i) as ut_test); - elsif a_suite.items(i) is of(ut_logical_suite) then - print_suite_elements(treat(a_suite.items(i) as ut_logical_suite), a_suite_id); - end if; - end loop; - - -- Now when all testsuite are printed do the testcases. - for i in 1 .. l_tests.count loop - print_test_elements(treat(l_tests(i) as ut_test)); - end loop; - - if a_suite is of(ut_suite) then - l_suite := treat(a_suite as ut_suite); - - l_data := l_suite.get_serveroutputs(); - if l_data is not null then - ut_utils.append_to_list( l_results, ''); - 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, ''); - 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.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; - end if; - ut_utils.append_to_list( l_results, ''); - - self.print_text_lines(l_results); - end; - - begin - l_suite_id := 0; - self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); - self.print_text(''); - for i in 1 .. a_run.items.count loop - print_suite_elements(treat(a_run.items(i) as ut_logical_suite), l_suite_id); - end loop; - self.print_text(''); - end; - - member function get_common_item_attributes(a_item ut_suite_item) return varchar2 is - begin - return '" name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name)) - || '" time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '" '; - end; - - member function get_common_suite_attributes(a_item ut_suite_item) return varchar2 is - begin - return ' disabled="' || a_item.results_count.disabled_count - || '" errors="' || a_item.results_count.errored_count - || '" failures="' || a_item.results_count.failure_count - || get_common_item_attributes(a_item); - end; - - overriding member function get_description return varchar2 as - begin - return 'Provides outcomes in a format conforming with JUnit 4 and above as defined in: https://gist.github.com/kuzuha/232902acab1344d6b578'; - end; - -end; -/ diff --git a/source/reporters/ut_junit_reporter.tps b/source/reporters/ut_junit_reporter.tps deleted file mode 100644 index 6cdaff1b9..000000000 --- a/source/reporters/ut_junit_reporter.tps +++ /dev/null @@ -1,32 +0,0 @@ -create or replace type ut_junit_reporter force under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * The XUnit reporter. - * Provides outcomes in a format conforming with JUnit4 as defined in: - * https://gist.github.com/kuzuha/232902acab1344d6b578 - */ - constructor function ut_junit_reporter(self in out nocopy ut_junit_reporter) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_junit_reporter, a_run in ut_run), - member function get_common_suite_attributes(a_item ut_suite_item) return varchar2, - member function get_common_item_attributes(a_item ut_suite_item) return varchar2, - - overriding member function get_description return varchar2 -) -not final -/ diff --git a/source/reporters/ut_realtime_reporter.tpb b/source/reporters/ut_realtime_reporter.tpb deleted file mode 100644 index 9c2af57ec..000000000 --- a/source/reporters/ut_realtime_reporter.tpb +++ /dev/null @@ -1,288 +0,0 @@ -create or replace type body ut_realtime_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_realtime_reporter( - self in out nocopy ut_realtime_reporter - ) return self as result is - begin - self.init($$plsql_unit,ut_output_clob_table_buffer()); - total_number_of_tests := 0; - current_test_number := 0; - current_indent := 0; - print_buffer := ut_varchar2_rows(); - return; - end; - - overriding member procedure before_calling_run( - self in out nocopy ut_realtime_reporter, - a_run in ut_run - ) is - procedure print_test_elements( - a_test in ut_test - ) is - begin - total_number_of_tests := total_number_of_tests + 1; - self.print_start_node('test', 'id', a_test.path); - self.print_node('executableType', a_test.item.executable_type); - self.print_node('ownerName', a_test.item.owner_name); - self.print_node('objectName', a_test.item.object_name); - self.print_node('procedureName', a_test.item.procedure_name); - self.print_node('disabled', case when a_test.get_disabled_flag() then 'true' else 'false' end); - self.print_node('disabledReason', a_test.disabled_reason); - self.print_node('name', a_test.name); - self.print_node('description', a_test.description); - self.print_node('testNumber', to_char(total_number_of_tests)); - self.print_end_node('test'); - end print_test_elements; - - procedure print_suite_elements( - a_suite in ut_logical_suite - ) is - begin - self.print_start_node('suite', 'id', a_suite.path); - self.print_node('name', a_suite.name); - self.print_node('description', a_suite.description); - <> - self.print_start_node('items'); - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_test) then - print_test_elements(treat(a_suite.items(i) as ut_test)); - elsif a_suite.items(i) is of(ut_logical_suite) then - print_suite_elements(treat(a_suite.items(i) as ut_logical_suite)); - end if; - end loop suite_elements; - self.print_end_node('items'); - self.print_end_node('suite'); - end print_suite_elements; - begin - xml_header := ut_utils.get_xml_header(a_run.client_character_set); - self.print_xml_fragment(xml_header); - self.print_start_node('event', 'type', 'pre-run'); - self.print_start_node('items'); - <> - for i in 1 .. a_run.items.count loop - print_suite_elements(treat(a_run.items(i) as ut_logical_suite)); - end loop items; - self.print_end_node('items'); - self.print_node('totalNumberOfTests', to_char(total_number_of_tests)); - self.print_end_node('event'); - self.flush_print_buffer('pre-run'); - end before_calling_run; - - overriding member procedure after_calling_run( - self in out nocopy ut_realtime_reporter, - a_run in ut_run - ) is - begin - self.print_xml_fragment(xml_header); - self.print_start_node('event', 'type', 'post-run'); - self.print_start_node('run'); - self.print_node('startTime', to_char(a_run.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6')); - self.print_node('endTime', to_char(a_run.end_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6')); - self.print_node('executionTime', ut_utils.to_xml_number_format(a_run.execution_time())); - self.print_start_node('counter'); - self.print_node('disabled', to_char(a_run.results_count.disabled_count)); - self.print_node('success', to_char(a_run.results_count.success_count)); - self.print_node('failure', to_char(a_run.results_count.failure_count)); - self.print_node('error', to_char(a_run.results_count.errored_count)); - self.print_node('warning', to_char(a_run.results_count.warnings_count)); - self.print_end_node('counter'); - self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_run.get_error_stack_traces(), chr(10)||chr(10))); - self.print_cdata_node('serverOutput', a_run.get_serveroutputs()); - self.print_end_node('run'); - self.print_end_node('event'); - self.flush_print_buffer('post-run'); - end after_calling_run; - - overriding member procedure before_calling_suite( - self in out nocopy ut_realtime_reporter, - a_suite in ut_logical_suite - ) is - begin - self.print_xml_fragment(xml_header); - self.print_start_node('event', 'type', 'pre-suite'); - self.print_start_node('suite', 'id', a_suite.path); - self.print_end_node('suite'); - self.print_end_node('event'); - self.flush_print_buffer('pre-suite'); - end before_calling_suite; - - overriding member procedure after_calling_suite( - self in out nocopy ut_realtime_reporter, - a_suite in ut_logical_suite - ) is - begin - self.print_xml_fragment(xml_header); - self.print_start_node('event', 'type', 'post-suite'); - self.print_start_node('suite', 'id', a_suite.path); - self.print_node('startTime', to_char(a_suite.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6')); - self.print_node('endTime', to_char(a_suite.end_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6')); - self.print_node('executionTime', ut_utils.to_xml_number_format(a_suite.execution_time())); - self.print_start_node('counter'); - self.print_node('disabled', to_char(a_suite.results_count.disabled_count)); - self.print_node('success', to_char(a_suite.results_count.success_count)); - self.print_node('failure', to_char(a_suite.results_count.failure_count)); - self.print_node('error', to_char(a_suite.results_count.errored_count)); - self.print_node('warning', to_char(a_suite.results_count.warnings_count)); - self.print_end_node('counter'); - self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_suite.get_error_stack_traces(), chr(10)||chr(10))); - self.print_cdata_node('serverOutput', a_suite.get_serveroutputs()); - self.print_cdata_node('warnings', ut_utils.table_to_clob(a_suite.warnings, chr(10)||chr(10))); - self.print_end_node('suite'); - self.print_end_node('event'); - self.flush_print_buffer('post-suite'); - end after_calling_suite; - - overriding member procedure before_calling_test( - self in out nocopy ut_realtime_reporter, - a_test in ut_test - ) is - begin - current_test_number := current_test_number + 1; - self.print_xml_fragment(xml_header); - self.print_start_node('event', 'type', 'pre-test'); - self.print_start_node('test', 'id', a_test.path); - self.print_node('testNumber', to_char(current_test_number)); - self.print_node('totalNumberOfTests', to_char(total_number_of_tests)); - self.print_end_node('test'); - self.print_end_node('event'); - self.flush_print_buffer('pre-test'); - end before_calling_test; - - overriding member procedure after_calling_test( - self in out nocopy ut_realtime_reporter, - a_test in ut_test - ) is - begin - self.print_xml_fragment(xml_header); - self.print_start_node('event', 'type', 'post-test'); - self.print_start_node('test', 'id', a_test.path); - self.print_node('testNumber', to_char(current_test_number)); - self.print_node('totalNumberOfTests', to_char(total_number_of_tests)); - self.print_node('startTime', to_char(a_test.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6')); - self.print_node('endTime', to_char(a_test.end_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6')); - self.print_node('executionTime', ut_utils.to_xml_number_format(a_test.execution_time())); - self.print_start_node('counter'); - self.print_node('disabled', to_char(a_test.results_count.disabled_count)); - self.print_node('success', to_char(a_test.results_count.success_count)); - self.print_node('failure', to_char(a_test.results_count.failure_count)); - self.print_node('error', to_char(a_test.results_count.errored_count)); - self.print_node('warning', to_char(a_test.results_count.warnings_count)); - self.print_end_node('counter'); - self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_test.get_error_stack_traces(), chr(10)||chr(10))); - self.print_cdata_node('serverOutput', a_test.get_serveroutputs()); - if a_test.failed_expectations.count > 0 then - self.print_start_node('failedExpectations'); - <> - for i in 1 .. a_test.failed_expectations.count loop - self.print_start_node('expectation'); - self.print_node('description', a_test.failed_expectations(i).description); - self.print_cdata_node('message', a_test.failed_expectations(i).message); - self.print_cdata_node('caller', a_test.failed_expectations(i).caller_info); - self.print_end_node('expectation'); - end loop expectations; - self.print_end_node('failedExpectations'); - end if; - self.print_cdata_node('warnings', ut_utils.table_to_clob(a_test.warnings, chr(10)||chr(10))); - self.print_end_node('test'); - self.print_end_node('event'); - self.flush_print_buffer('post-test'); - end after_calling_test; - - overriding member function get_description return varchar2 is - begin - return 'Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details.'; - end get_description; - - member procedure print_start_node( - self in out nocopy ut_realtime_reporter, - a_node_name in varchar2, - a_attr_name in varchar2 default null, - a_attr_value in varchar2 default null - ) is - begin - self.print_xml_fragment( - '<' || a_node_name - || case - when a_attr_name is not null and a_attr_value is not null then - ' ' || a_attr_name || '="' || dbms_xmlgen.convert(a_attr_value) || '"' - end - || '>', - 0, 1 - ); - end print_start_node; - - member procedure print_end_node( - self in out nocopy ut_realtime_reporter, - a_name in varchar2 - ) is - begin - self.print_xml_fragment('', -1); - end print_end_node; - - member procedure print_node( - self in out nocopy ut_realtime_reporter, - a_name in varchar2, - a_content in clob - ) is - begin - if a_content is not null then - self.print_xml_fragment('<' || a_name || '>' || dbms_xmlgen.convert(a_content) || ''); - end if; - end print_node; - - member procedure print_cdata_node( - self in out nocopy ut_realtime_reporter, - a_name in varchar2, - a_content in clob - ) is - begin - if a_content is not null then - self.print_xml_fragment('<' || a_name || '>' || ut_utils.to_cdata(a_content) || ''); - end if; - end print_cdata_node; - - member procedure print_xml_fragment( - self in out nocopy ut_realtime_reporter, - a_fragment in clob, - a_indent_summand_before in integer default 0, - a_indent_summand_after in integer default 0 - ) is - begin - current_indent := current_indent + a_indent_summand_before; - ut_utils.append_to_list(print_buffer, lpad(' ', 2 * current_indent) || a_fragment); - current_indent := current_indent + a_indent_summand_after; - end print_xml_fragment; - - member procedure flush_print_buffer( - self in out nocopy ut_realtime_reporter, - a_item_type in varchar2 - ) is - l_doc clob; - l_rows integer := print_buffer.count; - begin - for i in 1 .. l_rows loop - ut_utils.append_to_clob(l_doc, print_buffer(i)); - ut_utils.append_to_clob(l_doc, chr(10)); - end loop; - self.print_clob(l_doc, a_item_type); - print_buffer.delete; - end flush_print_buffer; - -end; -/ diff --git a/source/reporters/ut_realtime_reporter.tps b/source/reporters/ut_realtime_reporter.tps deleted file mode 100644 index 0501006e4..000000000 --- a/source/reporters/ut_realtime_reporter.tps +++ /dev/null @@ -1,163 +0,0 @@ -create or replace type ut_realtime_reporter force under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - /** - * Cached XML header to be used for every XML document - */ - xml_header varchar2(4000), - - /** - * Total number of all tests in the run (incl. disabled tests). - */ - total_number_of_tests integer, - - /** - * Currently executed test number. - */ - current_test_number integer, - - /** - * Current indentation in logical tabs. - */ - current_indent integer, - - /** - * Buffers lines to be printed. - */ - print_buffer ut_varchar2_rows, - - /** - * The realtime reporter. - * Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details. - */ - constructor function ut_realtime_reporter( - self in out nocopy ut_realtime_reporter - ) return self as result, - - /** - * Provides meta data of complete run in advance. - */ - overriding member procedure before_calling_run( - self in out nocopy ut_realtime_reporter, - a_run in ut_run - ), - - /** - * Provides meta data of a completed run. - */ - overriding member procedure after_calling_run( - self in out nocopy ut_realtime_reporter, - a_run in ut_run - ), - - /** - * Indicates the start of a test suite execution. - */ - overriding member procedure before_calling_suite( - self in out nocopy ut_realtime_reporter, - a_suite in ut_logical_suite - ), - - /** - * Provides meta data of completed test suite. - */ - overriding member procedure after_calling_suite( - self in out nocopy ut_realtime_reporter, - a_suite in ut_logical_suite - ), - - /** - * Indicates the start of a test. - */ - overriding member procedure before_calling_test( - self in out nocopy ut_realtime_reporter, - a_test in ut_test - ), - - /** - * Provides meta data of a completed test. - */ - overriding member procedure after_calling_test( - self in out nocopy ut_realtime_reporter, - a_test in ut_test - ), - - /** - * Provides the description of this reporter. - */ - overriding member function get_description return varchar2, - - /** - * Prints the start tag of a XML node with an optional attribute. - */ - member procedure print_start_node( - self in out nocopy ut_realtime_reporter, - a_node_name in varchar2, - a_attr_name in varchar2 default null, - a_attr_value in varchar2 default null - ), - - /** - * Prints the end tag of a XML node. - */ - member procedure print_end_node( - self in out nocopy ut_realtime_reporter, - a_name in varchar2 - ), - - /** - * Prints a child node with content. Special characters are encoded. - */ - member procedure print_node( - self in out nocopy ut_realtime_reporter, - a_name in varchar2, - a_content in clob - ), - - /** - * Prints a child node with content. Content is passed 1:1 using CDATA. - */ - member procedure print_cdata_node( - self in out nocopy ut_realtime_reporter, - a_name in varchar2, - a_content in clob - ), - - /** - * Prints a line of the resulting XML document using the current indentation. - * a_indent_summand_before is added before printing a line. - * a_indent_summand_after is added after printing a line. - * All output is produced through this function. - */ - member procedure print_xml_fragment( - self in out nocopy ut_realtime_reporter, - a_fragment in clob, - a_indent_summand_before in integer default 0, - a_indent_summand_after in integer default 0 - ), - - /** - * Flushes the local print buffer to the output buffer. - */ - member procedure flush_print_buffer( - self in out nocopy ut_realtime_reporter, - a_item_type in varchar2 - ) -) -not final -/ diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb deleted file mode 100644 index 7c46879d2..000000000 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ /dev/null @@ -1,115 +0,0 @@ -create or replace type body ut_sonar_test_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_sonar_test_reporter( - self in out nocopy ut_sonar_test_reporter - ) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_sonar_test_reporter, a_run in ut_run) is - - function map_package_to_file(a_suite ut_suite, a_file_mappings ut_file_mappings) return varchar2 is - l_file_name varchar2(4000); - begin - if a_file_mappings is not null then - for i in 1 .. a_file_mappings.count loop - if upper(a_file_mappings(i).object_name) = upper(a_suite.object_name) - and upper(a_file_mappings(i).object_owner) = upper(a_suite.object_owner) - and a_file_mappings(i).object_type = 'PACKAGE BODY' then - l_file_name := a_file_mappings(i).file_name; - exit; - end if; - end loop; - end if; - return coalesce(l_file_name, a_suite.path); - end; - - procedure print_test_results(a_test ut_test) is - 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.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, ''); - 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, ''); - - self.print_text_lines(l_results); - end; - - procedure print_suite_results(a_suite ut_logical_suite, a_file_mappings ut_file_mappings) is - begin - - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_logical_suite) and a_suite.items(i) is not of(ut_suite_context) then - print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_file_mappings); - end if; - end loop; - - if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then - self.print_text(''); - end if; - - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_suite_context) then - print_suite_results(treat(a_suite.items(i) as ut_suite_context), a_file_mappings); - end if; - end loop; - - if a_suite is of(ut_suite) then - 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; - end if; - - if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then - self.print_text(''); - end if; - end; - - begin - self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); - self.print_text(''); - for i in 1 .. a_run.items.count loop - print_suite_results(treat(a_run.items(i) as ut_logical_suite), a_run.test_file_mappings); - end loop; - - self.print_text(''); - end; - - overriding member function get_description return varchar2 as - begin - return 'Generates a XML report providing detailed information on test execution.' || chr(10) || - 'Designed for [SonarQube](https://www.sonarqube.org/) to report test execution.' || chr(10) || - 'XML format returned conforms with the Sonar specification: https://docs.sonarqube.org/latest/analysis/generic-test/'; - end; - -end; -/ diff --git a/source/reporters/ut_sonar_test_reporter.tps b/source/reporters/ut_sonar_test_reporter.tps deleted file mode 100644 index ac3b16bd1..000000000 --- a/source/reporters/ut_sonar_test_reporter.tps +++ /dev/null @@ -1,28 +0,0 @@ -create or replace type ut_sonar_test_reporter under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_sonar_test_reporter( - self in out nocopy ut_sonar_test_reporter - ) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_sonar_test_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -not final -/ diff --git a/source/reporters/ut_tap_reporter.tpb b/source/reporters/ut_tap_reporter.tpb deleted file mode 100644 index ff095a369..000000000 --- a/source/reporters/ut_tap_reporter.tpb +++ /dev/null @@ -1,124 +0,0 @@ -create or replace type body ut_tap_reporter is - - - constructor function ut_tap_reporter(self in out nocopy ut_tap_reporter) return self as result is - begin - self.init($$plsql_unit); - self.lvl := 0; - return; - end ut_tap_reporter; - - member procedure print_comment(self in out nocopy ut_tap_reporter, a_comment clob) as - begin - self.print_clob(regexp_replace(a_comment, '^', '# ', 1, 0, 'm')); - end print_comment; - - member function escape_special_chars(self in out nocopy ut_tap_reporter, a_string_to_escape clob) return clob as - begin - return regexp_replace(a_string_to_escape, '([\\#])', '\\\1'); - end escape_special_chars; - - overriding member procedure before_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite) as - begin - self.print_text('# Subtest: ' || self.escape_special_chars(coalesce(a_suite.description, a_suite.name))); - lvl := lvl + 2; - self.print_text('1..' || a_suite.items.count); - end before_calling_suite; - - - overriding member procedure after_calling_test(self in out nocopy ut_tap_reporter, a_test ut_test) as - l_message varchar2(4000); - l_test_name varchar2(4000) := self.escape_special_chars(coalesce(a_test.description, a_test.name)); - - procedure print_failed_expectation(a_test ut_test) is - l_lines ut_varchar2_list; - l_failed boolean; - begin - if a_test.get_error_stack_traces().count = 0 then - -- If no error occurred, print failed expectation - l_lines := a_test.all_expectations(a_test.all_expectations.last).get_result_lines(); - l_failed := a_test.all_expectations(a_test.all_expectations.last).status >= ut_utils.gc_success; - if l_failed then - self.print_text('message: ''' || l_lines(1) || ''''); - self.print_text('severity: fail'); - end if; - else - -- Print multi-line YAML-String with implicit newline characters - self.print_text('message: |'); - self.lvl := self.lvl + 1; - self.print_text(ut_utils.table_to_clob(a_test.get_error_stack_traces())); - self.lvl := self.lvl - 1; - self.print_text('severity: error'); - end if; - end print_failed_expectation; - - begin - - if a_test.result = ut_utils.gc_disabled then - self.print_text('ok - ' || l_test_name || ' # SKIP'|| - case when a_test.disabled_reason is not null - then ': '|| self.escape_special_chars(a_test.disabled_reason) - else null - end ); - elsif a_test.result = ut_utils.gc_success then - self.print_text('ok - ' || l_test_name); - elsif a_test.result > ut_utils.gc_success then - if self.lvl = 0 then - self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || l_test_name); - else - self.print_text('not ok - ' || l_test_name); - end if; - self.lvl := self.lvl + 1; - self.print_text('---'); - print_failed_expectation(a_test); - self.print_text('...'); - self.lvl := self.lvl - 1; - end if; - - self.print_comment(a_test.get_serveroutputs); - - end after_calling_test; - - overriding member procedure after_calling_before_all(self in out nocopy ut_tap_reporter, a_executable in ut_executable) is - begin - if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then - self.print_comment(a_executable.serveroutput); - end if; - end after_calling_before_all; - - overriding member procedure after_calling_after_all(self in out nocopy ut_tap_reporter, a_executable in ut_executable) is - begin - if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then - self.print_comment(a_executable.serveroutput); - end if; - end after_calling_after_all; - - overriding member procedure after_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite) as - l_suite_name varchar2(4000) := coalesce(a_suite.description, a_suite.name); - begin - lvl := lvl - 2; - if lvl = 0 then - if a_suite.result = ut_utils.gc_success or a_suite.result = ut_utils.gc_disabled then - self.print_text('ok - ' || self.escape_special_chars(l_suite_name)); - elsif a_suite.result > ut_utils.gc_success then - self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || self.escape_special_chars(l_suite_name)); - end if; - - self.print_text(' '); - end if; - - end after_calling_suite; - - overriding member procedure before_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as - begin - self.print_text('TAP version 14'); - self.print_text('1..' || a_run.items.count); - self.print_text(' '); - end before_calling_run; - - overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as - begin - self.lvl := 0; - end; -end; -/ diff --git a/source/reporters/ut_tap_reporter.tps b/source/reporters/ut_tap_reporter.tps deleted file mode 100644 index bed809059..000000000 --- a/source/reporters/ut_tap_reporter.tps +++ /dev/null @@ -1,18 +0,0 @@ -create or replace type ut_tap_reporter under ut_documentation_reporter( - - constructor function ut_tap_reporter(self in out nocopy ut_tap_reporter) return self as result, - member procedure print_comment(self in out nocopy ut_tap_reporter, a_comment clob), - member function escape_special_chars(self in out nocopy ut_tap_reporter, a_string_to_escape clob) return clob, - overriding member procedure before_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite), - - overriding member procedure after_calling_test(self in out nocopy ut_tap_reporter, a_test ut_test), - - overriding member procedure after_calling_before_all (self in out nocopy ut_tap_reporter, a_executable in ut_executable), - overriding member procedure after_calling_after_all (self in out nocopy ut_tap_reporter, a_executable in ut_executable), - overriding member procedure before_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run), - overriding member procedure after_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite), - overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) - -) -not final -/ diff --git a/source/reporters/ut_teamcity_reporter.tpb b/source/reporters/ut_teamcity_reporter.tpb deleted file mode 100644 index e05dc994f..000000000 --- a/source/reporters/ut_teamcity_reporter.tpb +++ /dev/null @@ -1,159 +0,0 @@ -create or replace type body ut_teamcity_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_teamcity_reporter(self in out nocopy ut_teamcity_reporter) return self as result is - begin - self.init($$plsql_unit); - return; - end; - - overriding member procedure before_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is - begin - self.print_text( - ut_teamcity_reporter_helper.test_suite_started( - a_suite_name => nvl(replace(trim(a_suite.description),'.'),a_suite.path) - ) - ); - end; - - overriding member procedure after_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is - begin - self.print_text( - ut_teamcity_reporter_helper.test_suite_finished( - a_suite_name => nvl(replace(trim(a_suite.description),'.'),a_suite.path) - ) - ); - end; - - overriding member procedure before_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is - l_test_full_name varchar2(4000); - begin - - l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' || - lower(a_test.item.procedure_name); - - self.print_text( - ut_teamcity_reporter_helper.test_started( - a_test_name => l_test_full_name, - a_capture_standard_output => true - ) - ); - - end; - - overriding member procedure after_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is - l_results ut_varchar2_rows := ut_varchar2_rows(); - l_test_full_name varchar2(4000); - l_std_err_msg varchar2(32767); - function add_error_message( a_message varchar2, a_message_name varchar2) return varchar2 is - begin - return - case - when a_message is not null - then a_message_name || chr(10) || a_message || chr(10) - end; - end; - function add_error_messages(a_executables ut_executables, a_message_name varchar2) return varchar2 is - l_message varchar2(32767); - l_idx binary_integer; - begin - l_idx := a_executables.first; - while l_idx is not null loop - l_message := l_message || add_error_message( a_executables(l_idx).get_error_stack_trace(), a_message_name ); - l_idx := a_executables.next(l_idx); - end loop; - return l_message; - end; - begin - l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' || - lower(a_test.item.procedure_name); - - if a_test.result = ut_utils.gc_disabled then - ut_utils.append_to_list( l_results, ut_teamcity_reporter_helper.test_disabled(l_test_full_name,a_test.disabled_reason)); - else - - ut_utils.append_to_list( l_results, a_test.get_serveroutputs()); - - if a_test.result = ut_utils.gc_error then - l_std_err_msg := l_std_err_msg || add_error_messages(a_test.before_each_list, 'Before each exception:'); - l_std_err_msg := l_std_err_msg || add_error_messages(a_test.before_test_list, 'Before test exception:'); - l_std_err_msg := l_std_err_msg || add_error_message(a_test.item.get_error_stack_trace(), 'Test exception:'); - l_std_err_msg := l_std_err_msg || add_error_messages(a_test.after_test_list, 'After test exception:'); - l_std_err_msg := l_std_err_msg || add_error_messages(a_test.after_each_list, 'After each exception:'); - - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_std_err( - a_test_name => l_test_full_name, - a_out => trim(l_std_err_msg) - ) - ); - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_failed( - a_test_name => l_test_full_name, - a_msg => 'Error occured', - a_details => trim(l_std_err_msg) - ) - ); - for i in 1 .. a_test.failed_expectations.count loop - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_failed( - a_test_name => l_test_full_name, - a_msg => a_test.failed_expectations(i).description, - a_details => a_test.failed_expectations(i).message ) - ); - end loop; - elsif a_test.failed_expectations is not null and a_test.failed_expectations.count > 0 then - for i in 1 .. a_test.failed_expectations.count loop - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_failed( - a_test_name => l_test_full_name, - a_msg => a_test.failed_expectations(i).description, - a_details => a_test.failed_expectations(i).message ) - ); - end loop; - elsif a_test.result = ut_utils.gc_failure then - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_failed( - a_test_name => l_test_full_name, - a_msg => 'Test failed' - ) - ); - end if; - - ut_utils.append_to_list( - l_results, - ut_teamcity_reporter_helper.test_finished(l_test_full_name, trunc(a_test.execution_time * 1e3)) - ); - - end if; - self.print_text_lines(l_results); - end; - - overriding member function get_description return varchar2 as - begin - return 'Provides the TeamCity (a CI server by jetbrains) reporting-format that allows tracking of progress of a CI step/task as it executes.' || chr(10) || - 'https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity'; - end; - -end; -/ diff --git a/source/reporters/ut_teamcity_reporter.tps b/source/reporters/ut_teamcity_reporter.tps deleted file mode 100644 index e03fa3643..000000000 --- a/source/reporters/ut_teamcity_reporter.tps +++ /dev/null @@ -1,31 +0,0 @@ -create or replace type ut_teamcity_reporter under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_teamcity_reporter(self in out nocopy ut_teamcity_reporter) return self as result, - - overriding member procedure before_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite), - - overriding member procedure after_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite), - - overriding member procedure before_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test), - - overriding member procedure after_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test), - - overriding member function get_description return varchar2 -) -not final -/ diff --git a/source/reporters/ut_teamcity_reporter_helper.pkb b/source/reporters/ut_teamcity_reporter_helper.pkb deleted file mode 100644 index 1633d10aa..000000000 --- a/source/reporters/ut_teamcity_reporter_helper.pkb +++ /dev/null @@ -1,126 +0,0 @@ -create or replace package body ut_teamcity_reporter_helper is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - subtype t_prop_index is varchar2(2000 char); - type t_props is table of varchar2(32767) index by t_prop_index; - - function escape_value(a_value in varchar2) return varchar2 is - begin - return translate(regexp_replace(a_value, q'/(\'|\||\[|\]|/' || chr(13) || '|' || chr(10) || ')', '|\1'),chr(13)||chr(10),'rn'); - end; - - function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is - l_message varchar2(32767); - l_index t_prop_index; - l_value varchar2(32767); - l_max_len binary_integer := 2000; - begin - l_message := '##teamcity[' || a_command || ' timestamp=''' || - regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FF3TZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || ''''; - - l_index := a_props.first; - while l_index is not null loop - if a_props(l_index) is not null then - l_value := escape_value(a_props(l_index)); - if length(l_value) > l_max_len then - l_value := substr(l_value,1,l_max_len-7)||escape_value('[...]'); - end if; - l_message := l_message || ' ' || l_index || '=''' || l_value || ''''; - end if; - l_index := a_props.next(l_index); - end loop; - l_message := l_message || ']'; - return l_message; - - end message; - - function test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_suite_name; - l_props('flowId') := a_flow_id; - return message('testSuiteStarted', l_props); - end; - function test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_suite_name; - l_props('flowId') := a_flow_id; - return message('testSuiteFinished', l_props); - end; - - function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_test_name; - l_props('captureStandardOutput') := case a_capture_standard_output - when true then - 'true' - when false then - 'false' - end; - l_props('flowId') := a_flow_id; - return message('testStarted', l_props); - end; - - function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_test_name; - l_props('duration') := a_test_duration_milisec; - l_props('flowId') := a_flow_id; - return message('testFinished', l_props); - end; - - function test_disabled(a_test_name varchar2,a_msg varchar2 default null, a_flow_id varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_test_name; - if a_msg is not null then - l_props('message') := a_msg; - end if; - l_props('flowId') := a_flow_id; - return message('testIgnored', l_props); - end; - function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_test_name; - l_props('message') := a_msg; - l_props('details') := a_details; - l_props('flowId') := a_flow_id; - - if a_actual is not null and a_expected is not null then - l_props('actual') := a_actual; - l_props('expected') := a_expected; - end if; - - return message('testFailed', l_props); - end; - - function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2 is - l_props t_props; - begin - l_props('name') := a_test_name; - l_props('out') := a_out; - l_props('flowId') := a_flow_id; - return message('testStdErr', l_props); - end; - -end ut_teamcity_reporter_helper; -/ diff --git a/source/reporters/ut_teamcity_reporter_helper.pks b/source/reporters/ut_teamcity_reporter_helper.pks deleted file mode 100644 index d7fa86cdc..000000000 --- a/source/reporters/ut_teamcity_reporter_helper.pks +++ /dev/null @@ -1,29 +0,0 @@ -create or replace package ut_teamcity_reporter_helper is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - - function test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2; - function test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2; - - function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2; - function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2; - function test_disabled(a_test_name varchar2,a_msg varchar2 default null, a_flow_id varchar2 default null) return varchar2; - function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2; - function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2; - -end ut_teamcity_reporter_helper; -/ diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb deleted file mode 100644 index 5e36aad17..000000000 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ /dev/null @@ -1,180 +0,0 @@ -create or replace type body ut_tfs_junit_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_tfs_junit_reporter(self in out nocopy ut_tfs_junit_reporter) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_tfs_junit_reporter, a_run in ut_run) is - begin - junit_version_one(a_run); - end; - - member procedure junit_version_one(self in out nocopy ut_tfs_junit_reporter,a_run in ut_run) is - l_suite_id integer := 0; - - function get_common_suite_attributes(a_item ut_suite_item) return varchar2 is - begin - return ' errors="' ||a_item.results_count.errored_count || '"' || - ' failures="' || a_item.results_count.failure_count || - '" name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name)) || '"' || - ' time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '" '|| - ' timestamp="' || to_char(sysdate,'RRRR-MM-DD"T"HH24:MI:SS') || '" '|| - ' hostname="' || sys_context('USERENV','HOST') || '" '; - end; - - function get_common_testcase_attributes(a_item ut_suite_item) return varchar2 is - begin - return ' name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name)) || '"' || - ' time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '"'; - end; - - function get_path(a_path_with_name varchar2, a_name varchar2) return varchar2 is - begin - return regexp_substr(a_path_with_name, '(.*)\.' ||a_name||'$',subexpression=>1); - end; - - function add_test_results(a_test ut_test) return ut_varchar2_rows is - l_results ut_varchar2_rows := ut_varchar2_rows(); - begin - ut_utils.append_to_list( l_results,''); - - /* - According to specs : - - A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. - e.g., via an assertEquals - - An errored test is one that had an unanticipated problem. - e.g., an unchecked throwable; or a problem with the implementation of the test. - */ - - 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.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_disabled then - if a_test.disabled_reason is not null then - ut_utils.append_to_list( l_results, ''); - else - ut_utils.append_to_list( l_results, '' ); - end if; - elsif a_test.result = ut_utils.gc_failure then - ut_utils.append_to_list( l_results, ''); - 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, ''); - - return l_results; - end; - - procedure print_suite_results(a_suite ut_logical_suite, a_suite_id in out nocopy integer, a_nested_tests in out nocopy ut_varchar2_rows) is - l_tests_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_results ut_varchar2_rows := ut_varchar2_rows(); - l_suite ut_suite; - l_outputs clob; - l_errors ut_varchar2_list; - l_tests ut_varchar2_list; - begin - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_suite_context) then - print_suite_results(treat(a_suite.items(i) as ut_suite_context), a_suite_id, a_nested_tests); - elsif a_suite.items(i) is of(ut_suite) then - print_suite_results(treat(a_suite.items(i) as ut_suite), a_suite_id, a_nested_tests); - elsif a_suite.items(i) is of(ut_logical_suite) then - print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_suite_id, a_nested_tests); - end if; - end loop; - --Due to fact tha TFS and junit5 accepts only flat structure we have to report in suite level only. - if a_suite is of(ut_suite_context) then - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_test) then - ut_utils.append_to_list( a_nested_tests,(add_test_results(treat(a_suite.items(i) as ut_test)))); - end if; - end loop; - elsif a_suite is of(ut_suite) then - for i in 1 .. a_suite.items.count loop - if a_suite.items(i) is of(ut_test) then - ut_utils.append_to_list( a_nested_tests,(add_test_results(treat(a_suite.items(i) as ut_test)))); - end if; - end loop; - --TFS doesnt report on empty test suites, however all we want to make sure is that we dont pring parents suites - -- showing test count but not tests. - if (a_nested_tests.count > 0 and l_tests_count > 0) or (a_nested_tests.count = 0 and l_tests_count = 0) then - a_suite_id := a_suite_id + 1; - ut_utils.append_to_list( l_results,''); - ut_utils.append_to_list( l_results,''); - ut_utils.append_to_list(l_results,a_nested_tests); - 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.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); - --We have resolved a context and we now reset value. - a_nested_tests := ut_varchar2_rows(); - end if; - end if; - end; - - procedure get_suite_results(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is - l_nested_tests ut_varchar2_rows:= ut_varchar2_rows(); - begin - print_suite_results(a_suite, l_suite_id,l_nested_tests); - end; - - begin - l_suite_id := 0; - self.print_text(ut_utils.get_xml_header(a_run.client_character_set)); - self.print_text(''); - for i in 1 .. a_run.items.count loop - get_suite_results(treat(a_run.items(i) as ut_logical_suite), l_suite_id); - end loop; - self.print_text(''); - end; - - overriding member function get_description return varchar2 as - begin - return 'Provides outcomes in a format conforming with JUnit version for TFS / VSTS. - As defined by specs :https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts - Version is based on windy road junit https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd.'; - end; - -end; -/ diff --git a/source/reporters/ut_tfs_junit_reporter.tps b/source/reporters/ut_tfs_junit_reporter.tps deleted file mode 100644 index 61cbc3fd8..000000000 --- a/source/reporters/ut_tfs_junit_reporter.tps +++ /dev/null @@ -1,34 +0,0 @@ -create or replace type ut_tfs_junit_reporter under ut_output_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * The JUnit reporter for publishing results in TFS/VSTS - * Provides outcomes in a format conforming with specs as defined in: - * https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts - */ - - constructor function ut_tfs_junit_reporter( - self in out nocopy ut_tfs_junit_reporter - ) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_tfs_junit_reporter, a_run in ut_run), - member procedure junit_version_one(self in out nocopy ut_tfs_junit_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -not final -/ diff --git a/source/reporters/ut_xunit_reporter.tpb b/source/reporters/ut_xunit_reporter.tpb deleted file mode 100644 index 4612fb640..000000000 --- a/source/reporters/ut_xunit_reporter.tpb +++ /dev/null @@ -1,32 +0,0 @@ -create or replace type body ut_xunit_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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_xunit_reporter(self in out nocopy ut_xunit_reporter) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - overriding member function get_description return varchar2 as - begin - return 'Depracated reporter. Please use Junit. - Provides outcomes in a format conforming with JUnit 4 and above as defined in: https://gist.github.com/kuzuha/232902acab1344d6b578'; - end; - -end; -/ diff --git a/source/reporters/ut_xunit_reporter.tps b/source/reporters/ut_xunit_reporter.tps deleted file mode 100644 index 6c530fee4..000000000 --- a/source/reporters/ut_xunit_reporter.tps +++ /dev/null @@ -1,28 +0,0 @@ -create or replace type ut_xunit_reporter under ut_junit_reporter( - /* - utPLSQL - Version 3 - Copyright 2016 - 2021 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. - */ - /** - * The XUnit reporter. - * Provides outcomes in a format conforming with JUnit4 as defined in: - * https://gist.github.com/kuzuha/232902acab1344d6b578 - */ - constructor function ut_xunit_reporter(self in out nocopy ut_xunit_reporter) return self as result, - - overriding member function get_description return varchar2 -) -not final -/ diff --git a/source/set_install_params.sql b/source/set_install_params.sql deleted file mode 100644 index 34a23dc93..000000000 --- a/source/set_install_params.sql +++ /dev/null @@ -1,34 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 deleted file mode 100644 index ced7b8dc4..000000000 --- a/source/uninstall.sql +++ /dev/null @@ -1,42 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 - -set feedback on - -spool uninstall.log - -prompt &&line_separator -prompt Uninstalling UTPLSQL v3 framework -prompt &&line_separator - -alter session set current_schema = &&ut3_owner; - -@@uninstall_objects.sql - -@@uninstall_synonyms.sql - -begin - dbms_output.put_line('&&line_separator'); - dbms_output.put_line('Uninstall complete'); - dbms_output.put_line('&&line_separator'); -end; -/ - -spool off - -exit; diff --git a/source/uninstall_all.sql b/source/uninstall_all.sql deleted file mode 100644 index cfaaaa29f..000000000 --- a/source/uninstall_all.sql +++ /dev/null @@ -1,45 +0,0 @@ -/* - utPLSQL - Version 3 - Copyright 2016 - 2021 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 - -set feedback on - -spool uninstall.log - -prompt &&line_separator -prompt Uninstalling UTPLSQL v3 framework -prompt &&line_separator - -alter session set current_schema = &&ut3_owner; - -@@uninstall_objects.sql - -@@uninstall_coverage_tables.sql - -@@uninstall_synonyms.sql - -begin - dbms_output.put_line('&&line_separator'); - dbms_output.put_line('Uninstall complete'); - dbms_output.put_line('&&line_separator'); -end; -/ - -spool off - -exit; - diff --git a/source/uninstall_coverage_tables.sql b/source/uninstall_coverage_tables.sql deleted file mode 100644 index 890aa7090..000000000 --- a/source/uninstall_coverage_tables.sql +++ /dev/null @@ -1,33 +0,0 @@ -set echo off -set feedback off -begin - for to_be_dopped in ( - select table_name - from all_tables - where table_name in ( - 'PLSQL_PROFILER_RUNS','PLSQL_PROFILER_UNITS','PLSQL_PROFILER_DATA', - 'DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS' - ) - and owner = sys_context( 'USERENV', 'CURRENT_SCHEMA' ) - ) - loop - execute immediate 'drop table '||to_be_dopped.table_name||' cascade constraints purge'; - dbms_output.put_line('Table '||to_be_dopped.table_name||' dropped'); - end loop; -end; -/ - -declare - l_seq_exist number; -begin - select count(*) into l_seq_exist - from all_sequences - where sequence_name = 'PLSQL_PROFILER_RUNNUMBER' - and sequence_owner = sys_context('USERENV','CURRENT_SCHEMA'); - if l_seq_exist = 1 then - execute immediate 'drop sequence plsql_profiler_runnumber'; - dbms_output.put_line('Sequence PLSQL_PROFILER_RUNNUMBER dropped'); - end if; -end; -/ - diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql deleted file mode 100644 index dde9a824f..000000000 --- a/source/uninstall_objects.sql +++ /dev/null @@ -1,429 +0,0 @@ -set echo off -declare - procedure drop_if_exists(a_object_type varchar2, a_object_name varchar2) is - l_count integer; - begin - select count(1) - into l_count - from all_objects - where owner = sys_context('USERENV','CURRENT_SCHEMA') - and object_type = a_object_type - and object_name = a_object_name; - if l_count > 0 then - execute immediate 'drop '||a_object_type||' '||a_object_name; - dbms_output.put_line(initcap(a_object_type)||' '||a_object_name||' dropped.'); - else - dbms_output.put_line(initcap(a_object_type)||' '||a_object_name||' was not dropped, '||lower(a_object_type)||' does not exist.'); - end if; - end; -begin - drop_if_exists('TRIGGER', 'UT_TRIGGER_ANNOTATION_PARSING'); - drop_if_exists('SYNONYM','UT3_TRIGGER_ALIVE'); -end; -/ -set echo on - -drop synonym be_between; - -drop synonym have_count; - -drop synonym match; - -drop synonym contain; - -drop synonym be_false; - -drop synonym be_empty; - -drop synonym be_greater_or_equal; - -drop synonym be_greater_than; - -drop synonym be_less_or_equal; - -drop synonym be_less_than; - -drop synonym be_like; - -drop synonym be_not_null; - -drop synonym be_null; - -drop synonym be_true; - -drop synonym equal; - -drop synonym be_within; - -drop synonym be_within_pct; - -drop type ut_coveralls_reporter force; - -drop type ut_coverage_sonar_reporter force; - -drop type ut_coverage_cobertura_reporter force; - -drop package ut_coverage_report_html_helper; - -drop type ut_coverage_html_reporter force; - -drop type ut_sonar_test_reporter force; - -drop type ut_realtime_reporter force; - -drop package ut_coverage; - -drop package ut_coverage_helper; - -drop table ut_coverage_sources_tmp purge; - -drop table ut_coverage_runs purge; - -drop package ut_teamcity_reporter_helper; - -drop package ut_runner; - -drop type ut_suite_items_info force; - -drop type ut_suite_item_info force; - -drop type ut_path_items force; - -drop type ut_path_item force; - -drop package ut_suite_manager; - -drop package ut_suite_builder; - -drop package ut_suite_tag_filter; - -drop package ut_suite_cache_manager; - -drop table ut_suite_cache purge; - -drop type ut_suite_cache_rows force; - -drop type ut_suite_cache_row force; - -drop sequence ut_suite_cache_seq; - -drop table ut_suite_cache_package purge; - -drop table ut_suite_cache_schema purge; - -drop package ut; - -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; - -drop type ut_match force; - -drop type ut_be_between force; - -drop type ut_contain force; - -drop type ut_equal force; - -drop type ut_be_true force; - -drop type ut_be_null force; - -drop type ut_be_not_null force; - -drop type ut_be_like force; - -drop type ut_be_greater_or_equal force; - -drop type ut_be_empty force; - -drop type ut_be_greater_than force; - -drop type ut_be_less_or_equal force; - -drop type ut_be_less_than force; - -drop type ut_be_false force; - -drop type ut_be_within_pct force; - -drop type ut_be_within force; - -drop package ut_be_within_helper; - -drop type ut_comparison_matcher force; - -drop type ut_matcher force; - -drop type ut_expectation_base force; - -drop type ut_matcher_base force; - -drop type ut_data_value_yminterval force; - -drop type ut_data_value_varchar2 force; - -drop type ut_data_value_timestamp_tz force; - -drop type ut_data_value_timestamp_ltz force; - -drop type ut_data_value_timestamp force; - -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; - -drop type ut_data_value_clob force; - -drop type ut_data_value_boolean force; - -drop type ut_data_value_blob force; - -drop type ut_data_value_anydata force; - -drop type ut_data_value_xmltype force; - -drop type ut_data_value force; - -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 purge; - -drop table ut_compound_data_diff_tmp purge; - -drop table ut_json_data_diff_tmp purge; - -drop package ut_annotation_manager; - -drop package ut_annotation_parser; - -drop package ut_annotation_cache_manager; - -drop table ut_annotation_cache cascade constraints purge; - -drop table ut_annotation_cache_info cascade constraints purge; - -drop table ut_annotation_cache_schema cascade constraints purge; - -drop sequence ut_annotation_cache_seq; - -drop type ut_annotation_objs_cache_info force; - -drop type ut_annotation_obj_cache_info force; - -drop type ut_annotated_objects force; - -drop type ut_annotated_object force; - -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 - null; - $if dbms_db_version.version < 21 $then - begin execute immediate 'drop type json force'; exception when others then null; end; - $end - $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then - begin execute immediate 'drop type json_element_t force'; exception when others then null; end; - begin execute immediate 'drop type json_object_t force'; exception when others then null; end; - begin execute immediate 'drop type json_array_t force'; exception when others then null; end; - begin execute immediate 'drop type json_key_list force'; exception when others then null; end; - $end -end; -/ - -drop package ut_utils; - -drop type ut_stack force; - -drop sequence ut_savepoint_seq; - -drop type ut_documentation_reporter force; - -drop type ut_debug_reporter force; - -drop type ut_teamcity_reporter force; - -drop type ut_xunit_reporter force; - -drop type ut_junit_reporter force; - -drop type ut_tfs_junit_reporter force; - -drop type ut_event_listener force; - -drop type ut_output_reporter_base force; - -drop type ut_coverage_reporter_base force; - -drop type ut_reporters force; - -drop type ut_reporter_base force; - -drop type ut_run force; - -drop type ut_coverage_options force; - -drop type ut_file_mappings force; - -drop type ut_file_mapping force; - -drop type ut_suite_context force; - -drop type ut_suite force; - -drop type ut_logical_suite force; - -drop type ut_test force; - -drop type ut_console_reporter_base force; - -drop type ut_executable_test force; - -drop type ut_executables force; - -drop type ut_executable force; - -drop type ut_suite_items force; - -drop type ut_suite_item force; - -drop type ut_output_table_buffer force; - -drop type ut_output_clob_table_buffer force; - -drop type ut_output_bulk_buffer force; - -drop type ut_output_buffer_base force; - -drop table ut_output_buffer_tmp purge; - -drop sequence ut_output_buffer_tmp_seq; - -drop table ut_output_clob_buffer_tmp purge; - -drop sequence ut_output_clob_buffer_tmp_seq; - -drop table ut_output_buffer_info_tmp purge; - -drop package ut_session_context; - -drop type ut_session_info force; - -drop type ut_output_data_rows force; - -drop type ut_output_data_row force; - -drop type ut_results_counter force; - -drop type ut_run_info force; - -drop type ut_expectation_results force; - -drop type ut_expectation_result force; - -drop package ut_event_manager; - -drop type ut_event_item force; - -drop type ut_reporters_info force; - -drop type ut_reporter_info force; - -drop type ut_key_anyval_pair force; - -drop type ut_key_anyval_pairs force; - -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; - -drop type ut_integer_list force; - -drop type ut_varchar2_list force; - -drop type ut_varchar2_rows force; - -drop package ut_coverage_profiler; - -drop package ut_compound_data_helper; - -drop package ut_coverage_helper_profiler; - -drop type ut_have_count; - -drop type ut_compound_data_value; - -set echo off -set feedback off -declare - i integer := 0; -begin - dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner')); - for pkg in ( - select object_name, owner - from all_objects - where 1 = 1 - and owner = upper('&&ut3_owner') - and object_type = 'PACKAGE' - and object_name in ('UT_COVERAGE_HELPER_BLOCK','UT_COVERAGE_BLOCK')) - loop - - begin - - execute immediate 'drop package ' || pkg.owner || '.' || pkg.object_name; - dbms_output.put_line('Dropped '|| pkg.object_name); - i := i + 1; - - exception - when others then - dbms_output.put_line('FAILED to drop ' || pkg.object_name); - end; - - end loop; - - dbms_output.put_line('&&line_separator'); - dbms_output.put_line(i || ' packages dropped'); -end; -/ diff --git a/source/uninstall_synonyms.sql b/source/uninstall_synonyms.sql deleted file mode 100644 index 2c96c03a4..000000000 --- a/source/uninstall_synonyms.sql +++ /dev/null @@ -1,64 +0,0 @@ -set echo off -set feedback off -declare - i integer := 0; -begin - dbms_output.put_line('Dropping synonyms pointing to non-existing objects in schema '||upper('&&ut3_owner')); - for syn in ( - select - case when owner = 'PUBLIC' - then 'public synonym ' - else 'synonym ' || owner || '.' end || synonym_name as syn_name, - table_owner||'.'||table_name as for_object - from all_synonyms s - where table_owner = upper('&&ut3_owner') and table_owner != owner - and not exists (select 1 from all_objects o where o.owner = s.table_owner and o.object_name = s.table_name) - ) - loop - begin - execute immediate 'drop '||syn.syn_name; - dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); - i := i + 1; - exception - when others then - dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); - end; - end loop; - dbms_output.put_line('&&line_separator'); - dbms_output.put_line(i||' synonyms dropped'); -end; -/ - -declare - i integer := 0; -begin - dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner')); - for syn in ( - select - case when owner = 'PUBLIC' then 'public synonym ' - else 'synonym ' || owner || '.' - end || synonym_name as syn_name, - table_owner || '.' || table_name as for_object - from all_synonyms s - where 1 = 1 - and table_owner = upper('&&ut3_owner') - and synonym_name in ('DBMSPCC_BLOCKS','DBMSPCC_RUNS','DBMSPCC_UNITS') - ) - loop - - begin - - execute immediate 'drop '||syn.syn_name; - dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object); - i := i + 1; - - exception - when others then - dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object); - end; - - end loop; - dbms_output.put_line('&&line_separator'); - dbms_output.put_line(i||' synonyms dropped'); -end; -/ diff --git a/source/ut_argument.tab b/source/ut_argument.tab new file mode 100644 index 000000000..5c6d8ba39 --- /dev/null +++ b/source/ut_argument.tab @@ -0,0 +1,14 @@ +CREATE TABLE ut_argument ( + id INTEGER , + testcase_id INTEGER, + name VARCHAR2(200), + assertion_id INTEGER, + CONSTRAINT ut_argument_pk PRIMARY KEY (id) +); + +ALTER table ut_argument add CONSTRAINT ut_argument_testcase_fk + FOREIGN KEY (testcase_id) REFERENCES ut_testcase; + +ALTER table ut_argument add CONSTRAINT ut_argument_assertion_fk + FOREIGN KEY (assertion_id) REFERENCES ut_assertion; + diff --git a/source/ut_assert.pkb b/source/ut_assert.pkb new file mode 100644 index 000000000..6f0278984 --- /dev/null +++ b/source/ut_assert.pkb @@ -0,0 +1,653 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utassert +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/11/16 09:46:48 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + g_showresults BOOLEAN := FALSE; + + PROCEDURE this ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + register_in IN BOOLEAN := TRUE -- 2.0.1 + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.this ( + l_outcome, + msg_in, + check_this_in, + null_ok_in, + raise_exc_in, + register_in + ); + END; + + PROCEDURE eval ( + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value_name_in IN utAssert2.value_name_tt, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eval ( + l_outcome, + msg_in, + using_in, + value_name_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eval ( + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value1_in IN VARCHAR2, + value2_in IN VARCHAR2, + name1_in IN VARCHAR2 := NULL, + name2_in IN VARCHAR2 := NULL, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + value_name utAssert2.value_name_tt; + BEGIN + value_name(1).value := value1_in; + value_name(1).name := name1_in; + value_name(2).value := value2_in; + value_name(2).name := name2_in; + + utassert2.eval ( + l_outcome, + msg_in, + using_in, + value_name, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eq ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eq ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eq ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + against_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eq ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eq ( + msg_in IN VARCHAR2, + check_this_in IN DATE, + against_this_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + truncate_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eq ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + null_ok_in, + raise_exc_in, + truncate_in + ); + END; + + PROCEDURE eqtable ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqtable ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + check_where_in, + against_where_in, + raise_exc_in + ); + END; + + PROCEDURE eqtabcount ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqtabcount ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + check_where_in, + against_where_in, + raise_exc_in + ); + END; + + PROCEDURE eqquery ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqquery ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + raise_exc_in + ); + END; + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqqueryvalue ( + l_outcome, + msg_in, + check_query_in, + against_value_in, + null_ok_in, + raise_exc_in + ); + END; + + -- Check a query against a single DATE value + PROCEDURE eqqueryvalue ( + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqqueryvalue ( + l_outcome, + msg_in, + check_query_in, + against_value_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eqqueryvalue ( + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN NUMBER, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqqueryvalue ( + l_outcome, + msg_in, + check_query_in, + against_value_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eqcursor ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + -- User passes in names of two packaged cursors. + -- Have to loop through each row and compare! + -- How do I compare the contents of two records + -- which have been defined dynamically? + IS + BEGIN + utreport.pl ('utAssert.eqCursor is not yet implemented!'); + END; + + PROCEDURE eqfile ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + check_this_dir_in IN VARCHAR2, + against_this_in IN VARCHAR2, + against_this_dir_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqfile ( + l_outcome, + msg_in, + check_this_in, + check_this_dir_in, + against_this_in, + against_this_dir_in, + raise_exc_in + ); + END; + + PROCEDURE eqpipe ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_nth_in IN VARCHAR2 := NULL, + against_nth_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqpipe ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + raise_exc_in + ); + END; + + PROCEDURE eqcoll ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqcoll ( + l_outcome, + msg_in, + check_this_in, + against_this_in, + eqfunc_in, + check_startrow_in, + check_endrow_in, + against_startrow_in, + against_endrow_in, + match_rownum_in, + null_ok_in, + raise_exc_in + ); + END; + + /* API based access to collections */ + PROCEDURE eqcollapi ( + msg_in IN VARCHAR2, + check_this_pkg_in IN VARCHAR2, + against_this_pkg_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + countfunc_in IN VARCHAR2 := 'COUNT', + firstrowfunc_in IN VARCHAR2 := 'FIRST', + lastrowfunc_in IN VARCHAR2 := 'LAST', + nextrowfunc_in IN VARCHAR2 := 'NEXT', + getvalfunc_in IN VARCHAR2 := 'NTHVAL', + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqcollapi ( + l_outcome, + msg_in, + check_this_pkg_in, + against_this_pkg_in, + eqfunc_in, + countfunc_in, + firstrowfunc_in, + lastrowfunc_in, + nextrowfunc_in, + getvalfunc_in, + check_startrow_in, + check_endrow_in, + against_startrow_in, + against_endrow_in, + match_rownum_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE isnotnull ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.isnotnull (l_outcome, msg_in, check_this_in, raise_exc_in); + END; + + PROCEDURE isnull ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.isnull (l_outcome, msg_in, check_this_in, raise_exc_in); + END; + + PROCEDURE isnotnull ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.isnotnull (l_outcome, msg_in, check_this_in, raise_exc_in); + END; + + PROCEDURE isnull ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.isnull (l_outcome, msg_in, check_this_in, raise_exc_in); + END; + + --Check a given call throws a named exception + PROCEDURE throws ( + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.throws (l_outcome, msg_in, check_call_in, against_exc_in); + END; + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE throws ( + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.throws (l_outcome, msg_in, check_call_in, against_exc_in); + END; + + PROCEDURE showresults + IS + BEGIN + g_showresults := TRUE; + END; + + PROCEDURE noshowresults + IS + BEGIN + g_showresults := FALSE; + END; + + FUNCTION showing_results + RETURN BOOLEAN + IS + BEGIN + RETURN g_showresults; + END; + +/* START username:studious Date:01/11/2002 Task_id:42690 +Description: Checking whether object exists */ + + PROCEDURE objExists ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + )IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.objExists ( + l_outcome, + msg_in, + check_this_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE objnotExists ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + )IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.objnotExists ( + l_outcome, + msg_in, + check_this_in, + null_ok_in, + raise_exc_in + ); + END; +/* END username:studious Task_id:42690*/ + + /* START chrisrimmer 42694 */ + FUNCTION previous_passed + RETURN BOOLEAN + IS + BEGIN + RETURN utAssert2.previous_passed; + END; + + FUNCTION previous_failed + RETURN BOOLEAN + IS + BEGIN + RETURN utAssert2.previous_failed; + END; + /* END chrisrimmer 42694 */ + + /* START chrisrimmer 42696 */ + PROCEDURE eqoutput ( + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN DBMS_OUTPUT.CHARARR, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqoutput( + l_outcome, + msg_in, + check_this_in, + against_this_in, + ignore_case_in, + ignore_whitespace_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eqoutput ( + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN VARCHAR2, + line_delimiter_in IN CHAR := NULL, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eqoutput( + l_outcome, + msg_in, + check_this_in, + against_this_in, + line_delimiter_in, + ignore_case_in, + ignore_whitespace_in, + null_ok_in, + raise_exc_in + ); + END; + /* END chrisrimmer 42696 */ + + /* START VENKY11 45789 */ + + PROCEDURE eq_refc_table( + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + table_name IN VARCHAR2 ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eq_refc_table(l_outcome,p_msg_nm,proc_name,params,cursor_position,table_name); + END; + + PROCEDURE eq_refc_query( + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + qry IN VARCHAR2 ) + IS + l_outcome ut_outcome.id%TYPE; + BEGIN + utassert2.eq_refc_query(l_outcome,p_msg_nm,proc_name,params,cursor_position,qry); + END; + + /* END VENKY11 45789 */ + +END utassert; +/ diff --git a/source/ut_assert.pks b/source/ut_assert.pks new file mode 100644 index 000000000..e271ce1f9 --- /dev/null +++ b/source/ut_assert.pks @@ -0,0 +1,323 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utassert &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + test_failure EXCEPTION; + /* On Error behaviors */ + c_continue CONSTANT CHAR (1) := 'c'; + c_stop CONSTANT CHAR (1) := 's'; + + PROCEDURE this ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + register_in IN BOOLEAN := TRUE -- 2.0.1 + ); + + /* + 2.0.8 General evaluation program. + */ + PROCEDURE eval ( + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value_name_in IN utAssert2.value_name_tt, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eval ( + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value1_in IN VARCHAR2, + value2_in IN VARCHAR2, + name1_in IN VARCHAR2 := NULL, + name2_in IN VARCHAR2 := NULL, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + msg_in IN VARCHAR2, + check_this_in IN DATE, + against_this_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + truncate_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + against_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqtable ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqtabcount ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqquery ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Check a query against a single DATE value + PROCEDURE eqqueryvalue ( + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Check a query against a single NUMERIC value + PROCEDURE eqqueryvalue ( + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN NUMBER, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Not currently implemented + PROCEDURE eqcursor ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqfile ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + check_this_dir_in IN VARCHAR2, + against_this_in IN VARCHAR2, + against_this_dir_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqpipe ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_nth_in IN VARCHAR2 := NULL, + against_nth_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* Direct access to collections */ + PROCEDURE eqcoll ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, /* pkg1.coll */ + against_this_in IN VARCHAR2, /* pkg2.coll */ + eqfunc_in IN VARCHAR2 := NULL, + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* API based access to collections */ + PROCEDURE eqcollapi ( + msg_in IN VARCHAR2, + check_this_pkg_in IN VARCHAR2, + against_this_pkg_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + countfunc_in IN VARCHAR2 := 'COUNT', + firstrowfunc_in IN VARCHAR2 := 'FIRST', + lastrowfunc_in IN VARCHAR2 := 'LAST', + nextrowfunc_in IN VARCHAR2 := 'NEXT', + getvalfunc_in IN VARCHAR2 := 'NTHVAL', + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnotnull ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnull ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- 1.5.2 + PROCEDURE isnotnull ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnull ( + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + --Check a given call throws a named exception + PROCEDURE throws ( + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ); + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE throws ( + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ); + + PROCEDURE showresults; + + PROCEDURE noshowresults; + + FUNCTION showing_results + RETURN BOOLEAN; + +/* START username:STUDIOUS Date:01/11/2002 Task_id:42690 +Description: Checking whether object exists*/ + + PROCEDURE objExists ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + +PROCEDURE objnotExists ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); +/* END username:STUDIOUS Task_id:42690*/ + + /* START chrisrimmer 42694 */ + FUNCTION previous_passed + RETURN BOOLEAN; + + FUNCTION previous_failed + RETURN BOOLEAN; + /* END chrisrimmer 42694 */ + + /* START chrisrimmer 42696 */ + PROCEDURE eqoutput ( + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN DBMS_OUTPUT.CHARARR, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqoutput ( + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN VARCHAR2, + line_delimiter_in IN CHAR := NULL, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + /* END chrisrimmer 42696 */ + + /* START VENKY11 45789 */ + PROCEDURE eq_refc_table( + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + table_name IN VARCHAR2 ); + + PROCEDURE eq_refc_query( + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + qry IN VARCHAR2 ); + + /* END VENKY11 45789 */ + + +END utassert; +/ diff --git a/source/ut_assert2.pkb b/source/ut_assert2.pkb new file mode 100644 index 000000000..3ccb65c94 --- /dev/null +++ b/source/ut_assert2.pkb @@ -0,0 +1,3658 @@ +CREATE OR REPLACE PACKAGE BODY utassert2 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2004/11/16 09:46:48 chrisrimmer +Changed to new version detection system. + +Revision 1.4 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.3 2003/07/11 14:32:52 chrisrimmer +Added 'throws' bugfix from Ivan Desjardins + +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + /* START chrisrimmer 42694 */ + g_previous_pass BOOLEAN; + /* END chrisrimmer 42694 */ + + g_showresults BOOLEAN := FALSE ; + c_not_placeholder CONSTANT VARCHAR2 (10) + := '#$NOT$#'; + + FUNCTION id (name_in IN ut_assertion.NAME%TYPE) + RETURN ut_assertion.id%TYPE + IS + retval ut_assertion.id%TYPE; + BEGIN + SELECT id + INTO retval + FROM ut_assertion + WHERE NAME = UPPER (name_in); + + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION NAME (id_in IN ut_assertion.id%TYPE) + RETURN ut_assertion.NAME%TYPE + IS + retval ut_assertion.NAME%TYPE; + BEGIN + SELECT NAME + INTO retval + FROM ut_assertion + WHERE id = id_in; + + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION replace_not_placeholder ( + stg_in IN VARCHAR2, + success_in IN BOOLEAN + ) + RETURN VARCHAR2 + IS + BEGIN + IF success_in + THEN + RETURN REPLACE ( + stg_in, + c_not_placeholder, + NULL + ); + ELSE + RETURN REPLACE ( + stg_in, + c_not_placeholder, + ' not ' + ); + END IF; + END; + + PROCEDURE this ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE , + register_in IN BOOLEAN := TRUE + ) + IS + l_failure BOOLEAN + := NOT check_this_in + OR ( check_this_in IS NULL + AND NOT null_ok_in + ); + BEGIN + /* START chrisrimmer 42694 */ + g_previous_pass := NOT l_failure; + + /* END chrisrimmer 42694 */ + + IF utplsql2.tracing + THEN + utreport.pl ( + 'utPLSQL TRACE on Assert: ' + || msg_in + ); + utreport.pl ('Results:'); + utreport.pl (l_failure); + END IF; + + -- Report results failure and success + + utresult2.report ( + outcome_in, + l_failure, + utplsql.currcase.pkg || '.' || utplsql.currcase.name || ': ' || msg_in, + /* 2.0.10.2 Idea from Alistair Bayley msg_in */ + register_in, + showing_results + ); + + IF raise_exc_in + AND l_failure + THEN + RAISE test_failure; + END IF; + END; + + -- Support success and failure messages + PROCEDURE this ( + outcome_in IN ut_outcome.id%TYPE, + success_msg_in IN VARCHAR2, + failure_msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE , + register_in IN BOOLEAN := TRUE + ) + IS + l_failure BOOLEAN + := NOT check_this_in + OR ( check_this_in IS NULL + AND NOT null_ok_in + ); + BEGIN + IF l_failure + THEN + this ( + outcome_in, + failure_msg_in, + check_this_in, + null_ok_in, + raise_exc_in, + register_in + ); + ELSE + this ( + outcome_in, + success_msg_in, + check_this_in, + null_ok_in, + raise_exc_in, + register_in + ); + END IF; + END; + + FUNCTION expected ( + type_in IN VARCHAR2, + msg_in IN VARCHAR2, + value_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN ( type_in + || ' "' + || msg_in + || '" Result: "' + || value_in + || '"' + ); + END; + + FUNCTION file_descrip ( + file_in IN VARCHAR2, + dir_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN file_in + || '" located in "' + || dir_in; + END; + + FUNCTION message_expected ( + type_in IN VARCHAR2, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN ( type_in + || ' "' + || msg_in + || '" Expected "' + || against_this_in + || '" and got "' + || check_this_in + || '"' + ); + END; + + FUNCTION message ( + type_in IN VARCHAR2, + msg_in IN VARCHAR2, + value_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN ( type_in + || ' "' + || msg_in + || '" Result: ' + || value_in + ); + END; + + -- Convert outcome name to ID. + PROCEDURE get_id ( + outcome_in IN ut_outcome.NAME%TYPE, + outcome_out OUT ut_outcome.id%TYPE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + l_id := utoutcome.id (outcome_in); + + IF l_id IS NULL + THEN + IF utplsql2.tracing + THEN + utreport.pl ( + 'Outcome ' + || outcome_in + || ' is not defined.' + ); + END IF; + + utrerror.oc_report ( + run_in=> utplsql2.runnum, + outcome_in=> NULL, + errcode_in=> utrerror.undefined_outcome, + errtext_in=> 'Outcome "' + || outcome_in + || '" is not defined.' + ); + ELSE + outcome_out := l_id; + END IF; + END; + + -- 2.0.8 General evaluation mechanism + PROCEDURE eval ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value_name_in IN value_name_tt, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + eval_result CHAR (1); + eval_block utplsql.maxvc2_t; -- Clear issues of size limitation! + value_name_str utplsql.maxvc2_t; + eval_description utplsql.maxvc2_t; + parse_error EXCEPTION; + BEGIN + IF utplsql2.tracing + THEN + -- Optional trace of assertion call. + --utreport.pl (); + NULL; + END IF; + + FOR indx IN + value_name_in.FIRST .. value_name_in.LAST + LOOP + value_name_str := + value_name_str + || ' ' + || NVL ( + value_name_in (indx).NAME, + 'P' + || indx + ) + || ' = ' + || value_name_in (indx).VALUE; + END LOOP; + + eval_description := 'Evaluation of "' + || using_in + || '" with' + || value_name_str; + eval_block := + 'DECLARE + b_result BOOLEAN; + BEGIN + b_result := ' + || using_in + || '; + IF b_result THEN :result := ''' + || utplsql.c_yes + || '''; ' + || 'ELSIF NOT b_result THEN :result := ''' + || utplsql.c_no + || '''; ' + || 'ELSE :result := NULL; + END IF; + END;'; + + BEGIN + DBMS_SQL.parse ( + cur, + eval_block, + DBMS_SQL.native + ); + EXCEPTION + WHEN OTHERS + THEN + -- Report the parse error! + IF DBMS_SQL.is_open (cur) + THEN + DBMS_SQL.close_cursor (cur); + END IF; + + this ( + outcome_in=> outcome_in, + success_msg_in=> NULL, + failure_msg_in=> 'Error ' + || SQLCODE + || ' parsing ' + || eval_block, + check_this_in=> FALSE , + null_ok_in=> null_ok_in, + raise_exc_in=> raise_exc_in + ); + RAISE parse_error; + END; + + FOR indx IN + value_name_in.FIRST .. value_name_in.LAST + LOOP + DBMS_SQL.bind_variable ( + cur, + NVL ( + value_name_in (indx).NAME, + 'P' + || indx + ), + value_name_in (indx).VALUE + ); + END LOOP; + + DBMS_SQL.bind_variable (cur, 'result', 'a'); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value ( + cur, + 'result', + eval_result + ); + DBMS_SQL.close_cursor (cur); + this ( + outcome_in=> outcome_in, + success_msg_in=> eval_description + || ' evaluated to TRUE', + failure_msg_in=> eval_description + || ' evaluated to FALSE', + check_this_in=> utplsql.vc2bool ( + eval_result + ), + null_ok_in=> null_ok_in, + raise_exc_in=> raise_exc_in + ); + EXCEPTION + WHEN parse_error + THEN + IF raise_exc_in + THEN + RAISE; + ELSE + NULL; + END IF; + WHEN OTHERS + THEN + IF DBMS_SQL.is_open (cur) + THEN + DBMS_SQL.close_cursor (cur); + END IF; + + -- Likely the block got too large! + this ( + outcome_in=> outcome_in, + success_msg_in=> NULL, + failure_msg_in=> 'Error in ' + || eval_description + || ' SQLERRM: ' + || SQLERRM, + check_this_in=> FALSE , + null_ok_in=> null_ok_in, + raise_exc_in=> raise_exc_in + ); + END; + + PROCEDURE eval ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value_name_in IN value_name_tt, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eval ( + l_id, + msg_in, + using_in, + value_name_in, + null_ok_in, + raise_exc_in + ); + END; + + /* + Template Assertion program + + PROCEDURE ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + IF utplsql2.tracing + THEN + -- Optional trace of assertion call. + utreport.pl (); + END IF; + + this ( + outcome_in => outcome_in, + success_msg_in => + , + failure_msg_in => + , + check_this_in => + , + null_ok_in => FALSE, + raise_exc_in => raise_exc_in + ); + END; + + You might find the message_expected private program useful in + constructing your message. Also the replace_not_placeholder and + c_not_placeholder may come in handy if you want to use the this + assertion program that accepts just a single message, as many + of the original assertion programs do. + + */ + + PROCEDURE eq ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + IF utplsql2.tracing + THEN + utreport.pl ( + 'EQ Compare "' + || check_this_in + || '" to "' + || against_this_in + || '"' + ); + END IF; + + this ( + outcome_in=> outcome_in, + msg_in=> message_expected ( + 'EQ', + msg_in, + check_this_in, + against_this_in + ), + check_this_in=> (NVL ( + check_this_in = + against_this_in, + FALSE + ) + ) + OR ( check_this_in IS NULL + AND against_this_in IS NULL + AND null_ok_in + ), + null_ok_in=> FALSE , + raise_exc_in=> raise_exc_in + ); + END; + + FUNCTION b2v (bool_in IN BOOLEAN) + RETURN VARCHAR2 + IS + BEGIN + IF bool_in + THEN + RETURN 'TRUE'; + ELSIF NOT bool_in + THEN + RETURN 'FALSE'; + ELSE + RETURN 'NULL'; + END IF; + END; + + PROCEDURE eq ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + against_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + IF utplsql2.tracing + THEN + utreport.pl ( + 'Compare "' + || b2v (check_this_in) + || '" to "' + || b2v (against_this_in) + || '"' + ); + END IF; + + this ( + outcome_in, + message_expected ( + 'EQ', + msg_in, + utplsql.bool2vc (check_this_in), + utplsql.bool2vc (against_this_in) + ), + (check_this_in = against_this_in) + OR ( check_this_in IS NULL + AND against_this_in IS NULL + AND null_ok_in + ), + FALSE , + raise_exc_in + ); + END; + + PROCEDURE eq ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DATE, + against_this_in IN DATE, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE , + truncate_in IN BOOLEAN := FALSE + ) + IS + c_format CONSTANT VARCHAR2 (30) + := 'MONTH DD, YYYY HH24MISS'; + v_check VARCHAR2 (100); + v_against VARCHAR2 (100); + BEGIN + IF truncate_in + THEN + v_check := TO_CHAR ( + TRUNC (check_this_in), + c_format + ); + v_against := + TO_CHAR ( + TRUNC (against_this_in), + c_format + ); + ELSE + v_check := + TO_CHAR (check_this_in, c_format); + v_against := + TO_CHAR (against_this_in, c_format); + END IF; + + IF utplsql2.tracing + THEN + utreport.pl ( + 'Compare "' + || v_check + || '" to "' + || v_against + || '"' + ); + END IF; + + this ( + outcome_in, + message_expected ( + 'EQ', + msg_in, + TO_CHAR ( + check_this_in, + 'MON-DD-YYYY HH:MI:SS' + ), + TO_CHAR ( + against_this_in, + 'MON-DD-YYYY HH:MI:SS' + ) + ), + (check_this_in = against_this_in) + OR ( check_this_in IS NULL + AND against_this_in IS NULL + AND null_ok_in + ), + FALSE , + raise_exc_in + ); + END; + + PROCEDURE ieqminus ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + query1_in IN VARCHAR2, + query2_in IN VARCHAR2, + minus_desc_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + &end_lt_8_1 + ival PLS_INTEGER; + /* 2.0.8 suggested replacement below by Chris Rimmer +to avoid duplicate column name issues +:= 'DECLARE + CURSOR cur IS (' +|| query1_in +|| ' MINUS ' +|| query2_in +|| ') +UNION +(' +|| query2_in +|| ' MINUS ' +|| query1_in +|| '); */ + v_block VARCHAR2 (32767) + := 'DECLARE + CURSOR cur IS + SELECT 1 + FROM DUAL + WHERE EXISTS ((' + ||' ( ' || query1_in ||' ) ' + || ' MINUS ' + ||' ( ' || query2_in ||' ) ' + || ') + UNION + (' + ||' ( ' || query2_in ||' ) ' + || ' MINUS ' + ||' ( ' || query1_in ||' ) ' + || ')); + rec cur%ROWTYPE; + BEGIN + OPEN cur; + FETCH cur INTO rec; + IF cur%FOUND + THEN + :retval := 1; + ELSE + :retval := 0; + END IF; + CLOSE cur; + END;'; + BEGIN + &start_ge_8_1 + EXECUTE IMMEDIATE v_block USING OUT ival; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + v_block, + DBMS_SQL.native + ); + DBMS_SQL.bind_variable ( + cur, + ':retval', + ival + ); + -- 1.5.6 + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value ( + cur, + 'retval', + ival + ); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + this ( + outcome_in, + replace_not_placeholder ( + msg_in, + ival = 0 + ), + ival = 0, + FALSE , + raise_exc_in + ); + EXCEPTION + WHEN OTHERS + THEN + &start_lt_8_1 + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + + this ( + outcome_in, + replace_not_placeholder ( + msg_in + || ' SQL Failure: ' + || SQLERRM, + SQLCODE = 0 + ), + SQLCODE = 0, + FALSE , + raise_exc_in + ); + END; + + PROCEDURE eqtable ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + CURSOR info_cur ( + sch_in IN VARCHAR2, + tab_in IN VARCHAR2 + ) + IS + SELECT t.column_name + FROM all_tab_columns t + WHERE t.owner = sch_in + AND t.table_name = tab_in + ORDER BY column_id; + + FUNCTION collist (tab IN VARCHAR2) + RETURN VARCHAR2 + IS + l_schema VARCHAR2 (100); + l_table VARCHAR2 (100); + l_dot PLS_INTEGER + := INSTR (tab, '.'); + retval VARCHAR2 (32767); + BEGIN + IF l_dot = 0 + THEN + l_schema := USER; + l_table := UPPER (tab); + ELSE + l_schema := UPPER ( + SUBSTR ( + tab, + 1, + l_dot + - 1 + ) + ); + l_table := + UPPER (SUBSTR (tab, l_dot + + 1)); + END IF; + + FOR rec IN info_cur (l_schema, l_table) + LOOP + retval := + retval + || ',' + || rec.column_name; + END LOOP; + + RETURN LTRIM (retval, ','); + END; + BEGIN + ieqminus ( + outcome_in, + message ( + 'EQTABLE', + msg_in, + 'Contents of "' + || check_this_in + || utplsql.ifelse ( + check_where_in IS NULL, + '"', + '" WHERE ' + || check_where_in + ) + || ' does ' + || c_not_placeholder -- utplsql.ifelse (NOT l_failure, NULL, ' not ') + || 'match "' + || against_this_in + || utplsql.ifelse ( + against_where_in IS NULL, + '"', + '" WHERE ' + || against_where_in + ) + ), + 'SELECT T1.*, COUNT(*) FROM ' + || check_this_in + || ' T1 WHERE ' + || NVL (check_where_in, '1=1') + || ' GROUP BY ' + || collist (check_this_in), + 'SELECT T2.*, COUNT(*) FROM ' + || against_this_in + || ' T2 WHERE ' + || NVL (against_where_in, '1=1') + || ' GROUP BY ' + || collist (against_this_in), + 'Table Equality', + raise_exc_in + ); + END; + + PROCEDURE eqtabcount ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + ival PLS_INTEGER; + BEGIN + ieqminus ( + outcome_in, + message ( + 'EQTABCOUNT', + msg_in, + 'Row count of "' + || check_this_in + || utplsql.ifelse ( + check_where_in IS NULL, + '"', + '" WHERE ' + || check_where_in + ) + || ' does ' + || c_not_placeholder -- utplsql.ifelse (NOT l_failure, NULL, ' not ') + || 'match that of "' + || against_this_in + || utplsql.ifelse ( + against_where_in IS NULL, + '"', + '" WHERE ' + || against_where_in + ) + ), + 'SELECT COUNT(*) FROM ' + || check_this_in + || ' WHERE ' + || NVL (check_where_in, '1=1'), + 'SELECT COUNT(*) FROM ' + || against_this_in + || ' WHERE ' + || NVL (against_where_in, '1=1'), + 'Table Count Equality', + raise_exc_in + ); + END; + + PROCEDURE eqquery ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + -- User passes in two SELECT statements. Use NDS to minus them. + ival PLS_INTEGER; + BEGIN + ieqminus ( + outcome_in, + message ( + 'EQQUERY', + msg_in, + 'Result set for "' + || check_this_in + || ' does ' + || c_not_placeholder -- utplsql.ifelse (NOT l_failure, NULL, ' not ') + || 'match that of "' + || against_this_in + || '"' + ), + check_this_in, + against_this_in, + 'Query Equality', + raise_exc_in + ); + END; + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_value VARCHAR2 (2000); + l_success BOOLEAN; + + &start_ge_8_1 + TYPE cv_t IS REF CURSOR; + + cv cv_t; + &start_ge_8_1 + &start_lt_8_1 + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + fdbk PLS_INTEGER; + &end_lt_8_1 + + BEGIN + IF utplsql2.tracing + THEN + utreport.pl ( + 'V EQQueryValue Compare "' + || check_query_in + || '" to "' + || against_value_in + || '"' + ); + END IF; + + &start_ge_8_1 + OPEN cv FOR check_query_in; + FETCH cv INTO l_value; + CLOSE cv; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + check_query_in, + DBMS_SQL.native + ); + DBMS_SQL.define_column (cur, 1, 'a', 2000); + fdbk := DBMS_SQL.execute_and_fetch (cur); + DBMS_SQL.column_value (cur, 1, l_value); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + l_success := + (l_value = against_value_in) + OR ( l_value IS NULL + AND against_value_in IS NULL + AND null_ok_in + ); + this ( + outcome_in, + message ( + 'EQQUERYVALUE', + msg_in, + 'Query "' + || check_query_in + || '" returned value "' + || l_value + || '" that does ' + || utplsql.ifelse ( + l_success, + NULL, + ' not ' + ) + || 'match "' + || against_value_in + || '"' + ), + l_success, + FALSE , + raise_exc_in + ); + /* For now ignore this condition. + How do we handle two assertions inside a single assertion call? + utAssert2.this (outcome_in, msg_in => || + msg_in || + ''' || ''; Got multiple values'', + check_this_in => FALSE, + raise_exc_in => ' || + b2v (raise_exc_in) || + '); + */ + END; + + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN DATE, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_value DATE; + l_success BOOLEAN; + + &start_ge_8_1 + TYPE cv_t IS REF CURSOR; + + cv cv_t; + &start_ge_8_1 + &start_lt_8_1 + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + fdbk PLS_INTEGER; + &end_lt_8_1 + + BEGIN + IF utplsql2.tracing + THEN + utreport.pl ( + 'D EQQueryValue Compare "' + || check_query_in + || '" to "' + || against_value_in + || '"' + ); + END IF; + + &start_ge_8_1 + OPEN cv FOR check_query_in; + FETCH cv INTO l_value; + CLOSE cv; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + check_query_in, + DBMS_SQL.native + ); + DBMS_SQL.define_column (cur, 1, l_value); + fdbk := DBMS_SQL.execute_and_fetch (cur); + DBMS_SQL.column_value (cur, 1, l_value); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + l_success := + (l_value = against_value_in) + OR ( l_value IS NULL + AND against_value_in IS NULL + AND null_ok_in + ); + this ( + outcome_in, + message ( + 'EQQUERYVALUE', + msg_in, + 'Query "' + || check_query_in + || '" returned value "' + || TO_CHAR ( + l_value, + 'DD-MON-YYYY HH24:MI:SS' + ) + || '" that does ' + || utplsql.ifelse ( + l_success, + NULL, + ' not ' + ) + || 'match "' + || TO_CHAR ( + against_value_in, + 'DD-MON-YYYY HH24:MI:SS' + ) + || '"' + ), + l_success, + FALSE , + raise_exc_in, + TRUE + ); + /* For now ignore this condition. + How do we handle two assertions inside a single assertion call? + utAssert2.this (outcome_in, msg_in => || + msg_in || + ''' || ''; Got multiple values'', + check_this_in => FALSE, + raise_exc_in => ' || + b2v (raise_exc_in) || + '); + */ + END; + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN NUMBER, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_value NUMBER; + l_success BOOLEAN; + + &start_ge_8_1 + + TYPE cv_t IS REF CURSOR; + + cv cv_t; + &start_ge_8_1 + &start_lt_8_1 + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + fdbk PLS_INTEGER; + &end_lt_8_1 + + BEGIN + IF utplsql2.tracing + THEN + utreport.pl ( + 'N EQQueryValue Compare "' + || check_query_in + || '" to "' + || against_value_in + || '"' + ); + END IF; + + &start_ge_8_1 + OPEN cv FOR check_query_in; + FETCH cv INTO l_value; + CLOSE cv; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + check_query_in, + DBMS_SQL.native + ); + DBMS_SQL.define_column (cur, 1, 1); + fdbk := DBMS_SQL.execute_and_fetch (cur); + DBMS_SQL.column_value (cur, 1, l_value); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + l_success := + (l_value = against_value_in) + OR ( l_value IS NULL + AND against_value_in IS NULL + AND null_ok_in + ); + this ( + outcome_in, + message ( + 'EQQUERYVALUE', + msg_in, + 'Query "' + || check_query_in + || '" returned value "' + || l_value + || '" that does ' + || utplsql.ifelse ( + l_success, + NULL, + ' not ' + ) + || 'match "' + || against_value_in + || '"' + ), + l_success, + FALSE , + raise_exc_in, + TRUE + ); + /* For now ignore this condition. + How do we handle two assertions inside a single assertion call? + utAssert2.this (outcome_in, msg_in => || + msg_in || + ''' || ''; Got multiple values'', + check_this_in => FALSE, + raise_exc_in => ' || + b2v (raise_exc_in) || + '); + */ + END; + + PROCEDURE eqcursor ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + -- User passes in names of two packaged cursors. + -- Have to loop through each row and compare! + -- How do I compare the contents of two records + -- which have been defined dynamically? + IS + BEGIN + utreport.pl ( + 'utAssert.eqCursor is not yet implemented!' + ); + END; + + PROCEDURE eqfile ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + check_this_dir_in IN VARCHAR2, + against_this_in IN VARCHAR2, + against_this_dir_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + checkid UTL_FILE.file_type; + againstid UTL_FILE.file_type; + samefiles BOOLEAN := TRUE ; + checkline VARCHAR2 (32767); + diffline VARCHAR2 (32767); + againstline VARCHAR2 (32767); + check_eof BOOLEAN; + against_eof BOOLEAN; + diffline_set BOOLEAN; + nth_line PLS_INTEGER := 1; + cant_open_check_file EXCEPTION; + cant_open_against_file EXCEPTION; + + PROCEDURE cleanup ( + val IN BOOLEAN, + line_in IN VARCHAR2 := NULL, + line_set_in IN BOOLEAN := FALSE , + linenum_in IN PLS_INTEGER := NULL, + msg_in IN VARCHAR2 + ) + IS + BEGIN + UTL_FILE.fclose (checkid); + UTL_FILE.fclose (againstid); + this ( + outcome_in, + message ( + 'EQFILE', + msg_in, + utplsql.ifelse ( + line_set_in, + ' Line ' + || linenum_in + || ' of ', + NULL + ) + || 'File "' + || file_descrip ( + check_this_in, + check_this_dir_in + ) + || '" does ' + || utplsql.ifelse ( + val, + NULL, + ' not ' + ) + || 'match "' + || file_descrip ( + against_this_in, + against_this_dir_in + ) + || '".' + ), + val, + FALSE , + raise_exc_in, + TRUE + ); + END; + BEGIN + -- Compare contents of two files. + BEGIN + checkid := + UTL_FILE.fopen ( + check_this_dir_in, + check_this_in, + 'R' &start_ge_8_1, max_linesize => 32767 &start_ge_8_1 + ); + EXCEPTION + WHEN OTHERS + THEN + RAISE cant_open_check_file; + END; + + BEGIN + againstid := + UTL_FILE.fopen ( + NVL ( + against_this_dir_in, + check_this_dir_in + ), + against_this_in, + 'R' + &start_ge_8_1, max_linesize => 32767 &start_ge_8_1 + ); + EXCEPTION + WHEN OTHERS + THEN + RAISE cant_open_against_file; + END; + + LOOP + BEGIN + UTL_FILE.get_line ( + checkid, + checkline + ); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + check_eof := TRUE ; + END; + + BEGIN + UTL_FILE.get_line ( + againstid, + againstline + ); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + against_eof := TRUE ; + END; + + IF ( check_eof + AND against_eof + ) + THEN + samefiles := TRUE ; + EXIT; + ELSIF (checkline != againstline) + THEN + diffline := checkline; + diffline_set := TRUE ; + samefiles := FALSE ; + EXIT; + ELSIF ( check_eof + OR against_eof + ) + THEN + samefiles := FALSE ; + EXIT; + END IF; + + IF samefiles + THEN + nth_line := nth_line + + 1; + END IF; + END LOOP; + + cleanup ( + samefiles, + diffline, + diffline_set, + nth_line, + msg_in + ); + EXCEPTION + WHEN cant_open_check_file + THEN + cleanup ( + FALSE , + msg_in=> 'Unable to open ' + || file_descrip ( + check_this_in, + check_this_dir_in + ) + ); + WHEN cant_open_against_file + THEN + cleanup ( + FALSE , + msg_in=> 'Unable to open ' + || file_descrip ( + against_this_in, + NVL ( + against_this_dir_in, + check_this_dir_in + ) + ) + ); + WHEN OTHERS + THEN + cleanup (FALSE , msg_in => msg_in); + END; + + PROCEDURE compare_pipe_tabs ( + tab1 utpipe.msg_tbltype, + tab2 utpipe.msg_tbltype, + same_out IN OUT BOOLEAN + ) + IS + indx PLS_INTEGER := tab1.FIRST; + BEGIN + LOOP + EXIT WHEN indx IS NULL; + + BEGIN + IF tab1 (indx).item_type = 9 + THEN + same_out := tab1 (indx).mvc2 = + tab2 (indx).mvc2; + ELSIF tab1 (indx).item_type = 6 + THEN + same_out := tab1 (indx).mnum = + tab2 (indx).mnum; + ELSIF tab1 (indx).item_type = 12 + THEN + same_out := tab1 (indx).mdt = + tab2 (indx).mdt; + ELSIF tab1 (indx).item_type = 11 + THEN + same_out := tab1 (indx).mrid = + tab2 (indx).mrid; + ELSIF tab1 (indx).item_type = 23 + THEN + same_out := tab1 (indx).mraw = + tab2 (indx).mraw; + END IF; + EXCEPTION + WHEN OTHERS + THEN + same_out := FALSE ; + END; + + EXIT WHEN NOT same_out; + indx := tab1.NEXT (indx); + END LOOP; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + same_out := FALSE ; + END; + + PROCEDURE eqpipe ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + check_tab utpipe.msg_tbltype; + against_tab utpipe.msg_tbltype; + check_status PLS_INTEGER; + against_status PLS_INTEGER; + same_message BOOLEAN := FALSE ; + msgset BOOLEAN; + msgnum PLS_INTEGER; + nthmsg PLS_INTEGER := 1; + BEGIN + -- Compare contents of two pipes. + LOOP + utpipe.receive_and_unpack ( + check_this_in, + check_tab, + check_status + ); + utpipe.receive_and_unpack ( + against_this_in, + against_tab, + against_status + ); + + IF ( check_status = 0 + AND against_status = 0 + ) + THEN + compare_pipe_tabs ( + check_tab, + against_tab, + same_message + ); + + IF NOT same_message + THEN + msgset := TRUE ; + msgnum := nthmsg; + EXIT; + END IF; + + EXIT WHEN NOT same_message; + ELSIF ( check_status = 1 + AND against_status = 1 + ) -- time out + THEN + same_message := TRUE ; + EXIT; + ELSE + same_message := FALSE ; + EXIT; + END IF; + + nthmsg := nthmsg + + 1; + END LOOP; + + this ( + outcome_in, + message ( + 'EQPIPE', + msg_in, + utplsql.ifelse ( + msgset, + ' Message ' + || msgnum + || ' of ', + NULL + ) + || 'Pipe "' + || check_this_in + || '" does ' + || utplsql.ifelse ( + same_message, + NULL, + ' not ' + ) + || 'match "' + || against_this_in + || '".' + ), + same_message, + FALSE , + raise_exc_in, + TRUE + ); + END; + + FUNCTION numfromstr (str IN VARCHAR2) + RETURN NUMBER + IS + sqlstr VARCHAR2 (1000) + := 'begin :val := ' + || str + || '; end;'; + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + &end_lt_8_1 + retval NUMBER; + BEGIN + &start_ge_8_1 + EXECUTE IMMEDIATE sqlstr USING OUT retval; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + sqlstr, + DBMS_SQL.native + ); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value (cur, 'val', retval); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + RETURN retval; + EXCEPTION + WHEN OTHERS + THEN + &start_lt_8_1 + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + RAISE; + END; + + PROCEDURE validatecoll ( + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + valid_out IN OUT BOOLEAN, + msg_out OUT VARCHAR2, + countproc_in IN VARCHAR2 + := 'COUNT', + firstrowproc_in IN VARCHAR2 + := 'FIRST', + lastrowproc_in IN VARCHAR2 + := 'LAST', + check_startrow_in IN PLS_INTEGER + := NULL, + check_endrow_in IN PLS_INTEGER + := NULL, + against_startrow_in IN PLS_INTEGER + := NULL, + against_endrow_in IN PLS_INTEGER + := NULL, + match_rownum_in IN BOOLEAN + := FALSE , + null_ok_in IN BOOLEAN + := TRUE , + raise_exc_in IN BOOLEAN + := FALSE , + null_and_valid IN OUT BOOLEAN + ) + IS + dynblock VARCHAR2 (32767); + v_matchrow CHAR (1) := 'N'; + badc PLS_INTEGER; + bada PLS_INTEGER; + badtext VARCHAR2 (32767); + eqcheck VARCHAR2 (32767); + BEGIN + valid_out := TRUE ; + null_and_valid := FALSE ; + + IF numfromstr ( + check_this_in + || '.' + || countproc_in + ) = 0 + AND numfromstr ( + against_this_in + || '.' + || countproc_in + ) = 0 + THEN + IF NOT null_ok_in + THEN + valid_out := FALSE ; + msg_out := 'Invalid NULL collections'; + ELSE + /* Empty and valid collections. We are done... */ + null_and_valid := TRUE ; + END IF; + END IF; + + IF valid_out + AND NOT null_and_valid + THEN + IF match_rownum_in + THEN + valid_out := + NVL ( + numfromstr ( + check_this_in + || '.' + || firstrowproc_in + ) = + numfromstr ( + against_this_in + || '.' + || firstrowproc_in + ), + FALSE + ); + + IF NOT valid_out + THEN + msg_out := + 'Different starting rows in ' + || check_this_in + || ' and ' + || against_this_in; + ELSE + valid_out := + NVL ( + numfromstr ( + check_this_in + || '.' + || lastrowproc_in + ) != + numfromstr ( + against_this_in + || '.' + || lastrowproc_in + ), + FALSE + ); + + IF NOT valid_out + THEN + msg_out := + 'Different ending rows in ' + || check_this_in + || ' and ' + || against_this_in; + END IF; + END IF; + END IF; + + IF valid_out + THEN + valid_out := + NVL ( + numfromstr ( + check_this_in + || '.' + || countproc_in + ) = + numfromstr ( + against_this_in + || '.' + || countproc_in + ), + FALSE + ); + + IF NOT valid_out + THEN + msg_out := + 'Different number of rows in ' + || check_this_in + || ' and ' + || against_this_in; + END IF; + END IF; + END IF; + END; + + FUNCTION dyncollstr ( + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + eqfunc_in IN VARCHAR2, + countproc_in IN VARCHAR2, + firstrowproc_in IN VARCHAR2, + lastrowproc_in IN VARCHAR2, + nextrowproc_in IN VARCHAR2, + getvalfunc_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + eqcheck VARCHAR2 (32767); + v_check VARCHAR2 (100) := check_this_in; + v_against VARCHAR2 (100) + := against_this_in; + BEGIN + IF getvalfunc_in IS NOT NULL + THEN + v_check := + v_check + || '.' + || getvalfunc_in; + v_against := + v_against + || '.' + || getvalfunc_in; + END IF; + + IF eqfunc_in IS NULL + THEN + eqcheck := '(' + || v_check + || '(cindx) = ' + || v_against + || ' (aindx)) OR ' + || '(' + || v_check + || '(cindx) IS NULL AND ' + || v_against + || ' (aindx) IS NULL)'; + ELSE + eqcheck := eqfunc_in + || '(' + || v_check + || '(cindx), ' + || v_against + || '(aindx))'; + END IF; + + RETURN ( 'DECLARE + cindx PLS_INTEGER; + aindx PLS_INTEGER; + cend PLS_INTEGER := NVL (:cendit, ' + || check_this_in + || '.' + || lastrowproc_in + || '); + aend PLS_INTEGER := NVL (:aendit, ' + || against_this_in + || '.' + || lastrowproc_in + || '); + different_collections exception; + + PROCEDURE setfailure ( + str IN VARCHAR2, + badc IN PLS_INTEGER, + bada IN PLS_INTEGER, + raiseexc IN BOOLEAN := TRUE) + IS + BEGIN + :badcindx := badc; + :badaindx := bada; + :badreason := str; + IF raiseexc THEN RAISE different_collections; END IF; + END; + BEGIN + cindx := NVL (:cstartit, ' + || check_this_in + || '.' + || firstrowproc_in + || '); + aindx := NVL (:astartit, ' + || against_this_in + || '.' + || firstrowproc_in + || '); + + LOOP + IF cindx IS NULL AND aindx IS NULL + THEN + EXIT; + + ELSIF cindx IS NULL and aindx IS NOT NULL + THEN + setfailure ( + ''Check index NULL, Against index NOT NULL'', cindx, aindx); + + ELSIF aindx IS NULL + THEN + setfailure ( + ''Check index NOT NULL, Against index NULL'', cindx, aindx); + END IF; + + IF :matchit = ''Y'' + AND cindx != aindx + THEN + setfailure (''Mismatched row numbers'', cindx, aindx); + END IF; + + BEGIN + IF ' + || eqcheck + || ' + THEN + NULL; + ELSE + setfailure (''Mismatched row values'', cindx, aindx); + END IF; + EXCEPTION + WHEN OTHERS + THEN + setfailure (''On EQ check: ' + || eqcheck + || ''' || '' '' || SQLERRM, cindx, aindx); + END; + + cindx := ' + || check_this_in + || '.' + || nextrowproc_in + || '(cindx); + aindx := ' + || against_this_in + || '.' + || nextrowproc_in + || '(aindx); + END LOOP; + EXCEPTION + WHEN OTHERS THEN + IF :badcindx IS NULL and :badaindx IS NULL + THEN setfailure (SQLERRM, cindx, aindx, FALSE); + END IF; + END;' + ); + END; + + FUNCTION collection_message ( + collapi_in IN BOOLEAN, + msg_in IN VARCHAR2, + chkcoll_in IN VARCHAR2, + chkrow_in IN INTEGER, + agcoll_in IN VARCHAR2, + agrow_in IN INTEGER, + success_in IN BOOLEAN + ) + RETURN VARCHAR2 + IS + assert_name VARCHAR2 (100) := 'EQCOLL'; + BEGIN + IF collapi_in + THEN + assert_name := 'EQCOLLAPI'; + END IF; + + RETURN message ( + assert_name, + msg_in, + utplsql.ifelse ( + success_in, + NULL, + ' Row ' + || NVL ( + TO_CHAR (agrow_in), + '*UNDEFINED*' + ) + || ' of ' + ) + || 'Collection "' + || agcoll_in + || '" does ' + || utplsql.ifelse ( + success_in, + NULL, + ' not ' + ) + || 'match ' + || utplsql.ifelse ( + success_in, + NULL, + ' Row ' + || NVL ( + TO_CHAR (chkrow_in), + '*UNDEFINED*' + ) + || ' of ' + ) + || chkcoll_in + || '".' + ); + END; + + PROCEDURE eqcoll ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + check_startrow_in IN PLS_INTEGER + := NULL, + check_endrow_in IN PLS_INTEGER + := NULL, + against_startrow_in IN PLS_INTEGER + := NULL, + against_endrow_in IN PLS_INTEGER + := NULL, + match_rownum_in IN BOOLEAN := FALSE , + null_ok_in IN BOOLEAN := TRUE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + dynblock VARCHAR2 (32767); + v_matchrow CHAR (1) := 'N'; + valid_interim BOOLEAN; + invalid_interim_msg VARCHAR2 (4000); + badc PLS_INTEGER; + bada PLS_INTEGER; + badtext VARCHAR2 (32767); + null_and_valid BOOLEAN := FALSE ; + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + &end_lt_8_1 + + BEGIN + validatecoll ( + msg_in, + check_this_in, + against_this_in, + valid_interim, + invalid_interim_msg, + 'COUNT', + 'FIRST', + 'LAST', + check_startrow_in, + check_endrow_in, + against_startrow_in, + against_endrow_in, + match_rownum_in, + null_ok_in, + raise_exc_in, + null_and_valid + ); + + IF NOT valid_interim + THEN + -- Failure on interim step. Flag and skip rest of processing + this ( + outcome_in, + collection_message ( + FALSE , + msg_in + || ' - ' + || invalid_interim_msg, + check_this_in, + NULL, + against_this_in, + NULL, + FALSE + ), + FALSE , + FALSE , + raise_exc_in, + TRUE + ); + ELSE + -- We have some data to compare. + IF NOT null_and_valid + THEN + IF match_rownum_in + THEN + v_matchrow := 'Y'; + END IF; + + dynblock := + dyncollstr ( + check_this_in, + against_this_in, + eqfunc_in, + 'COUNT', + 'FIRST', + 'LAST', + 'NEXT', + NULL + ); + &start_ge_8_1 + EXECUTE IMMEDIATE dynblock + USING IN check_endrow_in, + IN against_endrow_in, + IN OUT badc, + IN OUT bada, + IN OUT badtext, + IN check_startrow_in, + IN against_startrow_in, + IN v_matchrow; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + dynblock, + DBMS_SQL.native + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + check_endrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + against_endrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + check_startrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + against_startrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + v_matchrow + ); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value ( + cur, + 'badcindx', + badc + ); + DBMS_SQL.variable_value ( + cur, + 'badaindx', + bada + ); + DBMS_SQL.variable_value ( + cur, + 'badreason', + badtext + ); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + END IF; + + this ( + outcome_in, + collection_message ( + FALSE , + msg_in, + check_this_in, + badc, + against_this_in, + bada, + badc IS NULL + AND bada IS NULL + ), + badc IS NULL + AND bada IS NULL, + FALSE , + raise_exc_in, + TRUE + ); + END IF; + EXCEPTION + WHEN OTHERS + THEN --p.l (sqlerrm); + &start_lt_8_1 + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + this ( + outcome_in, + collection_message ( + FALSE , + msg_in + || ' SQLERROR: ' + || SQLERRM, + check_this_in, + badc, + against_this_in, + bada, + SQLCODE = 0 + ), + SQLCODE = 0, + FALSE , + raise_exc_in, + TRUE + ); + END; + + /* API based access to collections */ + PROCEDURE eqcollapi ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_pkg_in IN VARCHAR2, + against_this_pkg_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + countfunc_in IN VARCHAR2 := 'COUNT', + firstrowfunc_in IN VARCHAR2 := 'FIRST', + lastrowfunc_in IN VARCHAR2 := 'LAST', + nextrowfunc_in IN VARCHAR2 := 'NEXT', + getvalfunc_in IN VARCHAR2 + := 'NTHVAL', + check_startrow_in IN PLS_INTEGER + := NULL, + check_endrow_in IN PLS_INTEGER + := NULL, + against_startrow_in IN PLS_INTEGER + := NULL, + against_endrow_in IN PLS_INTEGER + := NULL, + match_rownum_in IN BOOLEAN := FALSE , + null_ok_in IN BOOLEAN := TRUE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + dynblock VARCHAR2 (32767); + v_matchrow CHAR (1) := 'N'; + badc PLS_INTEGER; + bada PLS_INTEGER; + badtext VARCHAR2 (32767); + valid_interim BOOLEAN; + invalid_interim_msg VARCHAR2 (4000); + null_and_valid BOOLEAN := FALSE ; + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + &end_lt_8_1 + + BEGIN + validatecoll ( + msg_in, + check_this_pkg_in, + against_this_pkg_in, + valid_interim, + invalid_interim_msg, + countfunc_in, + firstrowfunc_in, + lastrowfunc_in, + check_startrow_in, + check_endrow_in, + against_startrow_in, + against_endrow_in, + match_rownum_in, + null_ok_in, + raise_exc_in, + null_and_valid + ); + + IF null_and_valid + THEN + GOTO normal_termination; + END IF; + + IF match_rownum_in + THEN + v_matchrow := 'Y'; + END IF; + + dynblock := dyncollstr ( + check_this_pkg_in, + against_this_pkg_in, + eqfunc_in, + countfunc_in, + firstrowfunc_in, + lastrowfunc_in, + nextrowfunc_in, + getvalfunc_in + ); + &start_ge_8_1 + EXECUTE IMMEDIATE dynblock + USING IN check_endrow_in, + IN against_endrow_in, + IN OUT badc, + IN OUT bada, + IN OUT badtext, + IN check_startrow_in, + IN against_startrow_in, + IN v_matchrow; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + dynblock, + DBMS_SQL.native + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + check_endrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + against_endrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + check_startrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + against_startrow_in + ); + DBMS_SQL.bind_variable ( + cur, + 'cendit', + v_matchrow + ); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value ( + cur, + 'badcindx', + badc + ); + DBMS_SQL.variable_value ( + cur, + 'badaindx', + bada + ); + DBMS_SQL.variable_value ( + cur, + 'badreason', + badtext + ); + DBMS_SQL.close_cursor (cur); + + &end_lt_8_1 + + <> + this ( + outcome_in, + collection_message ( + TRUE , + msg_in, + check_this_pkg_in, + badc, + against_this_pkg_in, + bada, + badc IS NULL + AND bada IS NULL + ), + bada IS NULL + AND badc IS NULL, + FALSE , + raise_exc_in, + TRUE + ); + EXCEPTION + WHEN OTHERS + THEN --p.l (sqlerrm); + &start_lt_8_1 + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + this ( + outcome_in, + collection_message ( + TRUE , + msg_in + || ' SQLERROR: ' + || SQLERRM, + check_this_pkg_in, + badc, + against_this_pkg_in, + bada, + badc IS NULL + AND bada IS NULL + ), + SQLCODE = 0, + FALSE , + raise_exc_in, + TRUE + ); + END; + + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + this ( + outcome_in, + message_expected ( + 'ISNOTNULL', + msg_in, + check_this_in, + 'NOT NULL' + ), + check_this_in IS NOT NULL, + FALSE , + raise_exc_in + ); + END; + + PROCEDURE isnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + this ( + outcome_in, + message_expected ( + 'ISNULL', + msg_in, + check_this_in, + '' + ), + check_this_in IS NULL, + TRUE , + raise_exc_in + ); + END; + + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + this ( + outcome_in, + message_expected ( + 'ISNOTNULL', + msg_in, + utplsql.bool2vc (check_this_in), + 'NOT NULL' + ), + check_this_in IS NOT NULL, + FALSE , + raise_exc_in + ); + END; + + PROCEDURE isnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + this ( + outcome_in, + message_expected ( + 'ISNULL', + msg_in, + utplsql.bool2vc (check_this_in), + '' + ), + check_this_in IS NULL, + TRUE , + raise_exc_in + ); + END; + + --Check a given call throws a named exception + PROCEDURE raises ( + outcome_in IN ut_outcome.id%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ) + IS + expected_indicator PLS_INTEGER := 1000; + l_indicator PLS_INTEGER; + v_block VARCHAR2 (32767) + := 'BEGIN ' + || RTRIM (RTRIM (check_call_in), ';') + || '; + :indicator := 0; + EXCEPTION + WHEN ' + || against_exc_in + || ' THEN + :indicator := ' + || expected_indicator + || '; + WHEN OTHERS THEN :indicator := SQLCODE; + END;'; + &start_lt_8_1 + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + ret_val PLS_INTEGER; + &end_lt_8_1 + BEGIN + --Fire off the dynamic PL/SQL + &start_ge_8_1 + EXECUTE IMMEDIATE v_block USING OUT l_indicator; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + v_block, + DBMS_SQL.native + ); + DBMS_SQL.bind_variable (cur, 'indicator', 1); + ret_val := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value ( + cur, + 'indicator', + l_indicator + ); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + this ( + outcome_in, + message ( + 'RAISES', + msg_in, + 'Block "' + || check_call_in + || '"' + || utplsql.ifelse ( + NOT (NVL ( + l_indicator = + expected_indicator, + FALSE + ) + ), + ' does not raise', + ' raises ' + ) + || ' Exception "' + || against_exc_in + || utplsql.ifelse ( + l_indicator = + expected_indicator, + NULL, + '. Instead it raises SQLCODE = ' + || l_indicator + || '.' + ) + ), + l_indicator = expected_indicator + ); + END; + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE raises ( + outcome_in IN ut_outcome.id%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ) + IS + expected_indicator PLS_INTEGER := 1000; + l_indicator PLS_INTEGER; + v_block VARCHAR2 (32767) + := 'BEGIN ' + || RTRIM (RTRIM (check_call_in), ';') + || '; + :indicator := 0; + EXCEPTION + WHEN OTHERS + THEN IF SQLCODE = ' + || against_exc_in + || ' THEN :indicator := ' + || expected_indicator + || ';' + || ' ELSE :indicator := SQLCODE; END IF; + END;'; + &start_lt_8_1 + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + ret_val PLS_INTEGER; + &end_lt_8_1 + BEGIN + --Fire off the dynamic PL/SQL + &start_ge_8_1 + EXECUTE IMMEDIATE v_block USING OUT l_indicator; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + v_block, + DBMS_SQL.native + ); + DBMS_SQL.bind_variable (cur, 'indicator', 1); + ret_val := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.variable_value ( + cur, + 'indicator', + l_indicator + ); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + + this ( + outcome_in, + message ( + 'THROWS', + msg_in, + 'Block "' + || check_call_in + || '"' + || utplsql.ifelse ( + NOT (NVL ( + l_indicator = + expected_indicator, + FALSE + ) + ), + ' does not raise', + ' raises ' + ) + || ' Exception "' + || against_exc_in + || utplsql.ifelse ( + l_indicator = + expected_indicator, + NULL, + '. Instead it raises SQLCODE = ' + || l_indicator + || '.' + ) + ), + l_indicator = expected_indicator + ); + END; + + PROCEDURE throws ( + outcome_in IN ut_outcome.id%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ) + IS + BEGIN + raises ( + outcome_in, + msg_in, + check_call_in, + against_exc_in + ); + END; + + PROCEDURE throws ( + outcome_in IN ut_outcome.id%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ) + IS + BEGIN + raises ( + outcome_in, + msg_in, + check_call_in, + against_exc_in + ); + END; + + -- Same assertions, but using NAME not ID to identify the test case. + + PROCEDURE this ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE , + register_in IN BOOLEAN := TRUE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + this ( + l_id, + msg_in, + check_this_in, + null_ok_in, + raise_exc_in, + register_in + ); + END; + + PROCEDURE eq ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eq ( + l_id, + msg_in, + check_this_in, + against_this_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eq ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + against_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eq ( + l_id, + msg_in, + check_this_in, + against_this_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eq ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DATE, + against_this_in IN DATE, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE , + truncate_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eq ( + l_id, + msg_in, + check_this_in, + against_this_in, + null_ok_in, + raise_exc_in, + truncate_in + ); + END; + + PROCEDURE eqtable ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqtable ( + l_id, + msg_in, + check_this_in, + against_this_in, + check_where_in, + against_where_in, + raise_exc_in + ); + END; + + PROCEDURE eqtabcount ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqtabcount ( + l_id, + msg_in, + check_this_in, + against_this_in, + check_where_in, + against_where_in, + raise_exc_in + ); + END; + + PROCEDURE eqquery ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqquery ( + l_id, + msg_in, + check_this_in, + against_this_in, + raise_exc_in + ); + END; + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqqueryvalue ( + l_id, + msg_in, + check_query_in, + against_value_in, + raise_exc_in + ); + END; + + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN DATE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqqueryvalue ( + l_id, + msg_in, + check_query_in, + against_value_in, + raise_exc_in + ); + END; + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN NUMBER, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqqueryvalue ( + l_id, + msg_in, + check_query_in, + against_value_in, + raise_exc_in + ); + END; + + PROCEDURE eqcursor ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + -- User passes in names of two packaged cursors. + -- Have to loop through each row and compare! + -- How do I compare the contents of two records + -- which have been defined dynamically? + IS + BEGIN + utreport.pl ( + 'utAssert.eqCursor is not yet implemented!' + ); + END; + + PROCEDURE eqfile ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + check_this_dir_in IN VARCHAR2, + against_this_in IN VARCHAR2, + against_this_dir_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqfile ( + l_id, + msg_in, + check_this_in, + check_this_dir_in, + against_this_in, + against_this_dir_in, + raise_exc_in + ); + END; + + PROCEDURE eqpipe ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqpipe ( + l_id, + msg_in, + check_this_in, + against_this_in, + raise_exc_in + ); + END; + + PROCEDURE eqcoll ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + check_startrow_in IN PLS_INTEGER + := NULL, + check_endrow_in IN PLS_INTEGER + := NULL, + against_startrow_in IN PLS_INTEGER + := NULL, + against_endrow_in IN PLS_INTEGER + := NULL, + match_rownum_in IN BOOLEAN := FALSE , + null_ok_in IN BOOLEAN := TRUE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqcoll ( + l_id, + msg_in, + check_this_in, + against_this_in, + eqfunc_in, + check_startrow_in, + check_endrow_in, + against_startrow_in, + against_endrow_in, + match_rownum_in, + null_ok_in, + raise_exc_in + ); + END; + + /* API based access to collections */ + PROCEDURE eqcollapi ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_pkg_in IN VARCHAR2, + against_this_pkg_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + countfunc_in IN VARCHAR2 := 'COUNT', + firstrowfunc_in IN VARCHAR2 := 'FIRST', + lastrowfunc_in IN VARCHAR2 := 'LAST', + nextrowfunc_in IN VARCHAR2 := 'NEXT', + getvalfunc_in IN VARCHAR2 + := 'NTHVAL', + check_startrow_in IN PLS_INTEGER + := NULL, + check_endrow_in IN PLS_INTEGER + := NULL, + against_startrow_in IN PLS_INTEGER + := NULL, + against_endrow_in IN PLS_INTEGER + := NULL, + match_rownum_in IN BOOLEAN := FALSE , + null_ok_in IN BOOLEAN := TRUE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqcollapi ( + l_id, + msg_in, + check_this_pkg_in, + against_this_pkg_in, + eqfunc_in, + countfunc_in, + firstrowfunc_in, + lastrowfunc_in, + nextrowfunc_in, + getvalfunc_in, + check_startrow_in, + check_endrow_in, + against_startrow_in, + against_endrow_in, + match_rownum_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + isnotnull ( + l_id, + msg_in, + check_this_in, + raise_exc_in + ); + END; + + PROCEDURE isnull ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + isnull ( + l_id, + msg_in, + check_this_in, + raise_exc_in + ); + END; + + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + isnotnull ( + l_id, + msg_in, + check_this_in, + raise_exc_in + ); + END; + + PROCEDURE isnull ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + isnull ( + l_id, + msg_in, + check_this_in, + raise_exc_in + ); + END; + + --Check a given call throws a named exception + PROCEDURE raises ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + raises ( + l_id, + msg_in, + check_call_in, + against_exc_in + ); + END; + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE raises ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + raises ( + l_id, + msg_in, + check_call_in, + against_exc_in + ); + END; + + PROCEDURE throws ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ) + IS + BEGIN + raises ( + outcome_in, + msg_in, + check_call_in, + against_exc_in + ); + END; + + PROCEDURE throws ( + outcome_in IN ut_outcome.NAME%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ) + IS + BEGIN + raises ( + outcome_in, + msg_in, + check_call_in, + against_exc_in + ); + END; + + -- 2.0.7 + PROCEDURE fileexists ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + dir_in IN VARCHAR2, + file_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + checkid UTL_FILE.file_type; + + PROCEDURE cleanup ( + val IN BOOLEAN, + msg_in IN VARCHAR2 + ) + IS + BEGIN + UTL_FILE.fclose (checkid); + this ( + outcome_in, + message ( + 'FILEEXISTS', + msg_in, + 'File "' + || file_descrip (file_in, dir_in) + || '" could ' + || utplsql.ifelse ( + val, + NULL, + ' not ' + ) + || 'be opened for reading."' + ), + val, + FALSE , + raise_exc_in, + TRUE + ); + END; + BEGIN + checkid := + UTL_FILE.fopen ( + dir_in, + file_in, + 'R' &start_ge_8_1, max_linesize => 32767 &start_ge_8_1 + ); + cleanup (TRUE , msg_in); + EXCEPTION + WHEN OTHERS + THEN + cleanup (FALSE , msg_in); + END; + + PROCEDURE showresults + IS + BEGIN + g_showresults := TRUE ; + END; + + PROCEDURE noshowresults + IS + BEGIN + g_showresults := FALSE ; + END; + + FUNCTION showing_results + RETURN BOOLEAN + IS + BEGIN + RETURN g_showresults; + END; + + /* START username:studious Date:01/11/2002 Task_id:42690 + Description: Checking whether object exists */ + + FUNCTION find_obj (check_this_in IN VARCHAR2) + RETURN BOOLEAN + IS + v_st VARCHAR2 (20); + v_err VARCHAR2 (100); + v_schema VARCHAR2 (100); + v_obj_name VARCHAR2 (100); + v_point NUMBER + := INSTR (check_this_in, '.'); + v_state BOOLEAN := FALSE ; + v_val VARCHAR2 (30); + + CURSOR c_obj + IS + SELECT object_name + FROM all_objects + WHERE object_name = UPPER (v_obj_name) + AND owner = UPPER (v_schema); + BEGIN + IF v_point = 0 + THEN + v_schema := USER; + v_obj_name := check_this_in; + ELSE + v_schema := SUBSTR ( + check_this_in, + 0, + ( v_point + - 1 + ) + ); + v_obj_name := SUBSTR ( + check_this_in, + ( v_point + + 1 + ) + ); + END IF; + + OPEN c_obj; + FETCH c_obj INTO v_val; + + IF c_obj%FOUND + THEN + v_state := TRUE ; + ELSE + v_state := FALSE ; + END IF; + + CLOSE c_obj; + RETURN v_state; + EXCEPTION + WHEN OTHERS + THEN + RETURN FALSE ; + END; + + PROCEDURE objexists ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + IF utplsql2.tracing + THEN + -- Optional trace of assertion call. + utreport.pl ( + 'verfying that the object "' + || check_this_in + || '"exists' + ); + END IF; + + this ( + outcome_in, + message ( + msg_in, + check_this_in, + 'This object Exists' + ), + message ( + msg_in, + check_this_in, + 'This object does not Exist' + ), + find_obj (check_this_in), + null_ok_in, + raise_exc_in, + TRUE + ); + END; + + PROCEDURE objnotexists ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE , + raise_exc_in IN BOOLEAN := FALSE + ) + IS + BEGIN + IF utplsql2.tracing + THEN + -- Optional trace of assertion call. + utreport.pl ( + 'verifying that the object "' + || check_this_in + || '"does not exist' + ); + END IF; + + this ( + outcome_in, + message ( + msg_in, + check_this_in, + 'This object does not Exist' + ), + message ( + msg_in, + check_this_in, + 'This object Exists' + ), + NOT (find_obj (check_this_in)), + null_ok_in, + raise_exc_in, + TRUE + ); + END; +/* END username:studious Task_id:42690*/ + + /* START chrisrimmer 42694 */ + FUNCTION previous_passed + RETURN BOOLEAN + IS + BEGIN + RETURN g_previous_pass; + END; + + FUNCTION previous_failed + RETURN BOOLEAN + IS + BEGIN + RETURN NOT g_previous_pass; + END; +/* END chrisrimmer 42694 */ + + /* START chrisrimmer 42696 */ + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN DBMS_OUTPUT.CHARARR, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + v_check_index BINARY_INTEGER; + v_against_index BINARY_INTEGER; + v_message VARCHAR2(1000); + v_line1 VARCHAR2(1000); + v_line2 VARCHAR2(1000); + WHITESPACE CONSTANT CHAR(5) := '!' || CHR(9) || CHR(10) || CHR(13) || CHR(32) ; + NOWHITESPACE CONSTANT CHAR(1) := '!'; + + FUNCTION Preview_Line(line_in VARCHAR2) + RETURN VARCHAR2 + IS + BEGIN + IF LENGTH(line_in) <= 100 THEN + RETURN line_in; + ELSE + RETURN SUBSTR(line_in, 1, 97) || '...'; + END IF; + END; + + BEGIN + v_check_index := check_this_in.FIRST; + v_against_index := against_this_in.FIRST; + + WHILE v_check_index IS NOT NULL + AND v_against_index IS NOT NULL + AND v_message IS NULL + LOOP + + v_line1 := check_this_in(v_check_index); + v_line2 := against_this_in(v_against_index); + + IF ignore_case_in THEN + v_line1 := UPPER(v_line1); + v_line2 := UPPER(v_line2); + END IF; + + IF ignore_whitespace_in THEN + v_line1 := TRANSLATE(v_line1, WHITESPACE, NOWHITESPACE); + v_line2 := TRANSLATE(v_line2, WHITESPACE, NOWHITESPACE); + END IF; + + IF (NVL (v_line1 <> v_line2, NOT null_ok_in)) THEN + v_message := message_expected ( + 'EQOUTPUT', + msg_in, + Preview_Line(check_this_in(v_check_index)), + Preview_Line(against_this_in(v_against_index))) || + ' (Comparing line ' || v_check_index || + ' of tested collection against line ' || v_against_index || + ' of reference collection)'; + END IF; + + v_check_index := check_this_in.NEXT(v_check_index); + v_against_index := against_this_in.NEXT(v_against_index); + END LOOP; + + IF v_message IS NULL THEN + IF v_check_index IS NULL AND v_against_index IS NOT NULL THEN + v_message := message ( + 'EQOUTPUT', + msg_in , + 'Extra line found at end of reference collection: ' || + Preview_Line(against_this_in(v_against_index))); + ELSIF v_check_index IS NOT NULL AND v_against_index IS NULL THEN + v_message := message ( + 'EQOUTPUT', + msg_in , + 'Extra line found at end of tested collection: ' || + Preview_Line(check_this_in(v_check_index))); + END IF; + END IF; + + this(outcome_in, + NVL(v_message, message('EQOUTPUT', msg_in, 'Collections Match')), + v_message IS NULL, + FALSE, + raise_exc_in, + TRUE); + + END; + + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN DBMS_OUTPUT.CHARARR, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqoutput( + l_id, + msg_in, + check_this_in, + against_this_in, + ignore_case_in, + ignore_whitespace_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN VARCHAR2, + line_delimiter_in IN CHAR := NULL, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_buffer DBMS_OUTPUT.CHARARR; + l_against_this VARCHAR2(2000) := against_this_in; + l_delimiter_pos BINARY_INTEGER; + BEGIN + + IF line_delimiter_in IS NULL THEN + l_against_this := REPLACE(l_against_this, CHR(13) || CHR(10), CHR(10)); + END IF; + + WHILE l_against_this IS NOT NULL LOOP + l_delimiter_pos := INSTR(l_against_this, NVL(line_delimiter_in, CHR(10))); + IF l_delimiter_pos = 0 THEN + l_buffer(l_buffer.COUNT) := l_against_this; + l_against_this := NULL; + ELSE + l_buffer(l_buffer.COUNT) := SUBSTR(l_against_this, 1, l_delimiter_pos - 1); + l_against_this := SUBSTR(l_against_this, l_delimiter_pos + 1); + --Handle Case of delimiter at end + IF l_against_this IS NULL THEN + l_buffer(l_buffer.COUNT) := NULL; + END IF; + END IF; + END LOOP; + + eqoutput( + outcome_in, + msg_in, + check_this_in, + l_buffer, + ignore_case_in, + ignore_whitespace_in, + null_ok_in, + raise_exc_in + ); + END; + + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN VARCHAR2, + line_delimiter_in IN CHAR := NULL, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ) + IS + l_id ut_outcome.id%TYPE; + BEGIN + get_id (outcome_in, l_id); + eqoutput( + l_id, + msg_in, + check_this_in, + against_this_in, + line_delimiter_in, + ignore_case_in, + ignore_whitespace_in, + null_ok_in, + raise_exc_in + ); + END; + + /* END chrisrimmer 42696 */ + + /* START VENKY11 12345 */ + + PROCEDURE eq_refc_table( + outcome_in IN ut_outcome.id%TYPE, + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + table_name IN VARCHAR2 ) + IS + refc_table_name VARCHAR2(50); + BEGIN + refc_table_name := utplsql_util.prepare_and_fetch_rc(proc_name,params,cursor_position,1,table_name); + IF (refc_table_name IS NOT NULL) THEN + IF (utplsql.tracing) THEN + dbms_output.put_line('Doing eqtable '); + END IF; + --utassert2.eqtable(outcome_in,p_msg_nm,'UTPLSQL.'||refc_table_name,table_name); + utassert2.eqtable(outcome_in,p_msg_nm,refc_table_name,table_name); + END IF; + IF (utplsql.tracing) THEN + dbms_output.put_line('Table dropped '||refc_table_name); + END IF; + utplsql_util.execute_ddl('DROP TABLE '||refc_table_name); + END; + + PROCEDURE eq_refc_query( + outcome_in IN ut_outcome.id%TYPE, + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + qry IN VARCHAR2 ) + IS + refc_table_name VARCHAR2(50); + BEGIN + refc_table_name := utplsql_util.prepare_and_fetch_rc(proc_name,params,cursor_position,2,qry); + IF (refc_table_name IS NOT NULL) THEN + --utassert2.eqquery(outcome_in,p_msg_nm,'select * from '||'UTPLSQL.'||refc_table_name,qry); + utassert2.eqquery(outcome_in,p_msg_nm,'select * from '||refc_table_name,qry); + END IF; + IF (utplsql.tracing) THEN + dbms_output.put_line('Table dropped '||refc_table_name); + END IF; + utplsql_util.execute_ddl('DROP TABLE '||refc_table_name); + END; + +/* START VENKY11 12345 */ + + + +END utassert2; +/ + diff --git a/source/ut_assert2.pks b/source/ut_assert2.pks new file mode 100644 index 000000000..096422a5a --- /dev/null +++ b/source/ut_assert2.pks @@ -0,0 +1,621 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utassert2 +&start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + test_failure EXCEPTION; + /* On Error behaviors */ + c_continue CONSTANT CHAR (1) := 'c'; + c_stop CONSTANT CHAR (1) := 's'; + + TYPE value_name_rt IS RECORD ( + value VARCHAR2(32767), + name VARCHAR2(100)); + + TYPE value_name_tt IS TABLE OF value_name_rt INDEX BY BINARY_INTEGER; + + function id (name_in in ut_assertion.name%type) return ut_assertion.id%type; + function name (id_in in ut_assertion.id%type) return ut_assertion.name%type; + + PROCEDURE this ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + register_in IN BOOLEAN := TRUE + ); + + /* + 2.0.8 General evaluation program. + */ + PROCEDURE eval ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value_name_in IN value_name_tt, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eval ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + using_in IN VARCHAR2, -- The expression + value_name_in IN value_name_tt, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DATE, + against_this_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + truncate_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + against_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqtable ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqtabcount ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqquery ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Check a query against a single DATE value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN NUMBER, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Not currently implemented + PROCEDURE eqcursor ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqfile ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + check_this_dir_in IN VARCHAR2, + against_this_in IN VARCHAR2, + against_this_dir_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqpipe ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* Direct access to collections */ + PROCEDURE eqcoll ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, /* pkg1.coll */ + against_this_in IN VARCHAR2, /* pkg2.coll */ + eqfunc_in IN VARCHAR2 := NULL, + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* API based access to collections */ + PROCEDURE eqcollapi ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_pkg_in IN VARCHAR2, + against_this_pkg_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + countfunc_in IN VARCHAR2 := 'COUNT', + firstrowfunc_in IN VARCHAR2 := 'FIRST', + lastrowfunc_in IN VARCHAR2 := 'LAST', + nextrowfunc_in IN VARCHAR2 := 'NEXT', + getvalfunc_in IN VARCHAR2 := 'NTHVAL', + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- 1.5.2 + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnull ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ); + + --Check a given call throws a named exception + PROCEDURE throws ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ); + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE throws ( + outcome_in IN ut_outcome.id%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ); + + --Check a given call throws a named exception + PROCEDURE raises ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ); + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE raises ( + outcome_in IN ut_outcome.id%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ); + + -- Same assertions, but providing the assertion name, not ID. + PROCEDURE this ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + register_in IN BOOLEAN := TRUE + ); + + + PROCEDURE eq ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DATE, + against_this_in IN DATE, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE, + truncate_in IN BOOLEAN := FALSE + ); + + PROCEDURE eq ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + against_this_in IN BOOLEAN, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqtable ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqtabcount ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + check_where_in IN VARCHAR2 := NULL, + against_where_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqquery ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + --Check a query against a single VARCHAR2 value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Check a query against a single DATE value + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN DATE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqqueryvalue ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_query_in IN VARCHAR2, + against_value_in IN NUMBER, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- Not currently implemented + PROCEDURE eqcursor ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqfile ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + check_this_dir_in IN VARCHAR2, + against_this_in IN VARCHAR2, + against_this_dir_in IN VARCHAR2 := NULL, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqpipe ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + against_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* Direct access to collections */ + PROCEDURE eqcoll ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, /* pkg1.coll */ + against_this_in IN VARCHAR2, /* pkg2.coll */ + eqfunc_in IN VARCHAR2 := NULL, + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* API based access to collections */ + PROCEDURE eqcollapi ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_pkg_in IN VARCHAR2, + against_this_pkg_in IN VARCHAR2, + eqfunc_in IN VARCHAR2 := NULL, + countfunc_in IN VARCHAR2 := 'COUNT', + firstrowfunc_in IN VARCHAR2 := 'FIRST', + lastrowfunc_in IN VARCHAR2 := 'LAST', + nextrowfunc_in IN VARCHAR2 := 'NEXT', + getvalfunc_in IN VARCHAR2 := 'NTHVAL', + check_startrow_in IN PLS_INTEGER := NULL, + check_endrow_in IN PLS_INTEGER := NULL, + against_startrow_in IN PLS_INTEGER := NULL, + against_endrow_in IN PLS_INTEGER := NULL, + match_rownum_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnull ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + raise_exc_in IN BOOLEAN := FALSE + ); + + -- 1.5.2 + PROCEDURE isnotnull ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE isnull ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN BOOLEAN, + raise_exc_in IN BOOLEAN := FALSE + ); + + --Check a given call throws a named exception + PROCEDURE throws ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ); + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE throws ( + outcome_in IN ut_outcome.name%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ); + + --Check a given call throws a named exception + PROCEDURE raises ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN VARCHAR2 + ); + + --Check a given call throws an exception with a given SQLCODE + PROCEDURE raises ( + outcome_in IN ut_outcome.name%TYPE, + msg_in VARCHAR2, + check_call_in IN VARCHAR2, + against_exc_in IN NUMBER + ); + + PROCEDURE showresults; + + PROCEDURE noshowresults; + + FUNCTION showing_results + RETURN BOOLEAN; + + -- 2.0.7 + PROCEDURE fileExists( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + dir_in in varchar2, + file_in in varchar2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + /* START username:studious Date:01/11/2002 Task_id:42690 + Description: Checking object exist */ + + PROCEDURE objExists ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE objnotExists ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN VARCHAR2, + null_ok_in IN BOOLEAN := FALSE, + raise_exc_in IN BOOLEAN := FALSE + ); +/* END username:studious Task_id:42690*/ + + /* START chrisrimmer 42694 */ + FUNCTION previous_passed + RETURN BOOLEAN; + + FUNCTION previous_failed + RETURN BOOLEAN; + /* END chrisrimmer 42694 */ + + /* START chrisrimmer 42696 */ + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN DBMS_OUTPUT.CHARARR, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN DBMS_OUTPUT.CHARARR, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.id%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN VARCHAR2, + line_delimiter_in IN CHAR := NULL, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + + PROCEDURE eqoutput ( + outcome_in IN ut_outcome.name%TYPE, + msg_in IN VARCHAR2, + check_this_in IN DBMS_OUTPUT.CHARARR, + against_this_in IN VARCHAR2, + line_delimiter_in IN CHAR := NULL, + ignore_case_in IN BOOLEAN := FALSE, + ignore_whitespace_in IN BOOLEAN := FALSE, + null_ok_in IN BOOLEAN := TRUE, + raise_exc_in IN BOOLEAN := FALSE + ); + /* END chrisrimmer 42696 */ + + /* START VENKY11 12345 */ + + PROCEDURE eq_refc_table( + outcome_in IN ut_outcome.id%TYPE, + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + table_name IN VARCHAR2 ); + + PROCEDURE eq_refc_query( + outcome_in IN ut_outcome.id%TYPE, + p_msg_nm IN VARCHAR2, + proc_name IN VARCHAR2, + params IN utplsql_util.utplsql_params, + cursor_position IN PLS_INTEGER, + qry IN VARCHAR2 ); + + +/* END VENKY11 12345 */ + + +END utassert2; +/ diff --git a/source/ut_assertion.tab b/source/ut_assertion.tab new file mode 100644 index 000000000..146e9cefd --- /dev/null +++ b/source/ut_assertion.tab @@ -0,0 +1,147 @@ +-- Modification History: +-- studious:01/20/2002:Assertion for object existance + +CREATE TABLE ut_assertion ( + id INTEGER , + NAME VARCHAR2(100), -- MUST corresponds to utAssert2 program name + description VARCHAR2(1000), + /* Rest of columns, V1 compatibility; too generic to be useful. */ + use_msg CHAR(1) DEFAULT 'Y', + use_null_ok CHAR(1) DEFAULT 'Y', + use_raise_exc CHAR(1) DEFAULT 'Y', + use_check_this CHAR(1) DEFAULT 'Y', + check_this_label VARCHAR2(100) + DEFAULT 'Check this', + use_check_this_where CHAR(1) DEFAULT 'N', + check_this_where_label VARCHAR2(100) + DEFAULT 'Check this WHERE clause', + use_against_this CHAR(1) DEFAULT 'Y', + against_this_label VARCHAR2(100) + DEFAULT 'Against this', + use_against_this_where CHAR(1) DEFAULT 'N', + against_this_where_label VARCHAR2(100) + DEFAULT 'Against this WHERE clause', + use_check_this_dir CHAR(1) DEFAULT 'N', + check_this_dir_label VARCHAR2(100) + DEFAULT 'Location of "check this" file', + use_against_this_dir CHAR(1) DEFAULT 'N', + against_this_dir_label VARCHAR2(100) + DEFAULT 'Location of "against this" file', + CONSTRAINT ut_assertion_pk PRIMARY KEY (id) +); + +CREATE UNIQUE INDEX ut_assertion_idx1 ON + ut_assertion (NAME); + +BEGIN + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (1, 'THIS', + 'General Boolean expression evaluation'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (2, 'EQ', + 'Scalar equality'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (3, 'EQTABLE', + 'Database table/view equality'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (4, 'EQTABCOUNT', + 'Database table/view row count comparison'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (5, 'EQQUERY', + 'Query result set equality'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (6, 'EQQUERYVALUE', + 'Query return value comparison'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (7, 'EQFILE', + 'Operating system file equality'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (8, 'EQPIPE', + 'Database pipe equality'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (9, 'EQCOLL', + 'Collection equality - direct access'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (10, 'EQCOLLAPI', + 'Collection equality - API access'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (11, 'ISNOTNULL', + 'NOTNULL validation'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (12, 'ISNULL', + 'NULL validation'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (13, 'RAISES', + 'Raised exception validation'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (14, 'FILEEXISTS', + 'Confirm that specified file exists'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (15, 'EVALUATE', + 'General evaluation of specified expression'); + +-- START username:STUDIOUS Date:01/11/2002 Task_id:42690 +-- Description: Checking whether object exists + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (16, 'OBJEXISTS', + 'Confirm that specified Object exists'); + + INSERT INTO ut_assertion + (id, NAME, + description) + VALUES (17, 'OBJNOTEXISTS', + 'Confirm that specified Object does not exist'); + +-- END username:STUDIOUS Task_id:42690 + + COMMIT; +END; +/ + diff --git a/source/ut_assertion_seq.seq b/source/ut_assertion_seq.seq new file mode 100644 index 000000000..11a8ce337 --- /dev/null +++ b/source/ut_assertion_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_assertion_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_config.pkb b/source/ut_config.pkb new file mode 100644 index 000000000..a4d7af0c8 --- /dev/null +++ b/source/ut_config.pkb @@ -0,0 +1,763 @@ +CREATE OR REPLACE PACKAGE BODY utconfig +IS +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2004/11/23 14:56:47 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.4 2004/11/16 09:46:48 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + +------------------------------------------------------------------------------- +--Description +------------------------------------------------------------------------------- +--This package manages the ut_config table, which holds the configuration +--settings for different users. The configuration data to be used by utPLSQL +--by default is set by calling settester. Wherever a username is passed as NULL, +--it is assumed to be that user. This defaults initially to the current user. +------------------------------------------------------------------------------- + +---------------------------------------------------------------------------- +--This record holds the default configuration +---------------------------------------------------------------------------- + g_config ut_config%ROWTYPE := NULL; + +---------------------------------------------------------------------------- +-- Get the configuration record for a user from the table +---------------------------------------------------------------------------- + FUNCTION config (username_in IN VARCHAR2 := USER) + RETURN ut_config%ROWTYPE + IS + rec ut_config%ROWTYPE; + BEGIN + --Short cut for current user + IF username_in = tester + THEN + RETURN g_config; + END IF; + + BEGIN + --Try to pull in the record from the table + SELECT * + INTO rec + FROM ut_config + WHERE username = UPPER (username_in); + EXCEPTION + --If we failed to find the record + WHEN OTHERS + THEN + --Set the record to NULL + rec := NULL; + END; + + RETURN rec; + END; + +---------------------------------------------------------------------------- +--This sets the configuration record for a user in the table +---------------------------------------------------------------------------- + PROCEDURE setconfig ( + field_in IN VARCHAR2 + ,value_in VARCHAR2 + ,username_in IN VARCHAR2 := NULL + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + + --Local procedure to do dynamic SQL + PROCEDURE do_dml (statement_in IN VARCHAR2) + IS + &start_lt_8_1 cursor_handle INTEGER; &end_lt_8_1 + &start_lt_8_1 rows INTEGER; &end_lt_8_1 + BEGIN + --In 8i, just do it + &start_ge_8_1 EXECUTE IMMEDIATE statement_in; COMMIT; &end_ge_8_1 + + --Otherwise use DBMS_SQL + &start_lt_8_1 + --Open the cursor + cursor_handle := DBMS_SQL.open_cursor; + -- Parse the Statement + DBMS_SQL.parse (cursor_handle, statement_in, DBMS_SQL.native); + -- Execute the Statement + ROWS := DBMS_SQL.EXECUTE (cursor_handle); + -- Close the cursor + DBMS_SQL.close_cursor (cursor_handle); + EXCEPTION + WHEN OTHERS + THEN + DBMS_SQL.close_cursor (cursor_handle); + RAISE; + &end_lt_8_1 + END; + BEGIN + BEGIN + --Try to insert the record + do_dml ( 'INSERT INTO ut_config(username, ' + || field_in + || ')' + || 'VALUES (''' + || username_in + || ''', ''' + || value_in + || ''')' + ); + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + --Since it already exists, we'll update instead + do_dml ( 'UPDATE ut_config ' + || 'SET ' + || field_in + || ' = ''' + || value_in + || ''' ' + || 'WHERE username = ''' + || username_in + || ''' ' + ); + WHEN OTHERS + THEN + --Something else went wrong + UtOutputreporter.pl (SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RETURN; + END; + + &start_ge_8_1 COMMIT; &end_ge_8_1 + + --If it's the current user, force update of package record + IF username_in = tester + THEN + g_config := NULL; + settester (username_in); + END IF; + END; + +---------------------------------------------------------------------------- +--This loads the default configuration from the table +---------------------------------------------------------------------------- + PROCEDURE settester (username_in IN VARCHAR2 := USER) + IS + BEGIN + --Load the record + g_config := config (username_in); + --But set the username record if null + g_config.username := NVL (g_config.username, UPPER (username_in)); + END; + +---------------------------------------------------------------------------- +-- Get the user we use by default +---------------------------------------------------------------------------- + FUNCTION tester + RETURN VARCHAR2 + IS + BEGIN + RETURN g_config.username; + END; + +---------------------------------------------------------------------------- +-- Show the config for a user +---------------------------------------------------------------------------- + PROCEDURE showconfig (username_in IN VARCHAR2 := NULL) + IS + --The schema to show + v_user VARCHAR2 (32) := NVL (username_in, tester); + --This holds the configuration + rec ut_config%ROWTYPE; + BEGIN + --Get the configuration + rec := config (v_user); + --Now show it + utOutputReporter.pl ('============================================================='); + utOutputReporter.pl ('utPLSQL Configuration for ' || v_user); + utOutputReporter.pl (' Directory: ' || rec.DIRECTORY); + utOutputReporter.pl (' Autcompile? ' || rec.autocompile); + utOutputReporter.pl (' Manual test registration? ' || rec.registertest); + utOutputReporter.pl (' Prefix = ' || rec.prefix); + utOutputReporter.pl (' Default reporter = ' || rec.reporter); + utOutputReporter.pl (' ----- File Output settings:'); + utOutputReporter.pl (' Output directory: ' || rec.filedir); + utOutputReporter.pl (' User prefix = ' || rec.fileuserprefix); + utOutputReporter.pl (' Include progname? ' || rec.fileincprogname); + utOutputReporter.pl (' Date format = ' || rec.filedateformat); + utOutputReporter.pl (' File extension = ' || rec.fileextension); + utOutputReporter.pl (' ----- End File Output settings'); + utOutputReporter.pl ('============================================================='); + END; + +---------------------------------------------------------------------------- +-- Set the prefix for a user +---------------------------------------------------------------------------- + PROCEDURE setprefix (prefix_in IN VARCHAR2, username_in IN VARCHAR2 := NULL) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('prefix', prefix_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the prefix for a user +---------------------------------------------------------------------------- + FUNCTION prefix (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return prefix + RETURN NVL (rec.prefix, c_prefix); + END; + +---------------------------------------------------------------------------- +-- Set the delimiter for a user +---------------------------------------------------------------------------- + PROCEDURE setdelimiter ( + delimiter_in IN VARCHAR2 + ,username_in IN VARCHAR2 := NULL + ) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('delimiter', delimiter_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the delimiter for a user +---------------------------------------------------------------------------- + FUNCTION delimiter (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return prefix + RETURN NVL (rec.delimiter, c_delimiter); + END; + +---------------------------------------------------------------------------- +-- Set the source directory for a user +---------------------------------------------------------------------------- + PROCEDURE setdir (dir_in IN VARCHAR2, username_in IN VARCHAR2 := NULL) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('directory', dir_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the source directory for a user +---------------------------------------------------------------------------- + FUNCTION dir (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return directory + RETURN rec.DIRECTORY; + END; + +---------------------------------------------------------------------------- +-- Set the autocompile flag for a user +---------------------------------------------------------------------------- + PROCEDURE autocompile (onoff_in IN BOOLEAN, username_in IN VARCHAR2 := NULL) + IS + --Holds the flag as 'Y'/'N' + v_autocompile CHAR (1) := utplsql.bool2vc (onoff_in); + --Holds the user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('autocompile', v_autocompile, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the autocompile flag for a user +---------------------------------------------------------------------------- + FUNCTION autocompiling (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return autocompile, defaulting to TRUE if NULL + RETURN NVL (utplsql.vc2bool (rec.autocompile), TRUE); + END; + +---------------------------------------------------------------------------- +-- Set the manual registration flag for a user +---------------------------------------------------------------------------- + PROCEDURE registertest (onoff_in IN BOOLEAN, username_in IN VARCHAR2 + := NULL) + IS + --Holds the flag as 'Y'/'N' + v_registertest CHAR (1) := utplsql.bool2vc (onoff_in); + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('registertest', v_registertest, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the manual registration flag for a user +---------------------------------------------------------------------------- + FUNCTION registeringtest (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return registertest, defaulting to FALSE if NULL + RETURN NVL (utplsql.vc2bool (rec.registertest), FALSE); + END; + + -- Show failures only? + PROCEDURE showfailuresonly ( + onoff_in IN BOOLEAN + ,username_in IN VARCHAR2 := NULL + ) + IS + --Holds the flag as 'Y'/'N' + v_showfailuresonly CHAR (1) := utplsql.bool2vc (onoff_in); + --Holds the username in question + v_user VARCHAR2 (100) + := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('show_failures_only', v_showfailuresonly, v_user); + END; + + FUNCTION showingfailuresonly (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return show_failures_only, defaulting to FALSE if NULL + RETURN NVL (utplsql.vc2bool (rec.show_failures_only), FALSE); + END; + +-- RMM start +---------------------------------------------------------------------------- +-- Set the file directory for a user +---------------------------------------------------------------------------- + PROCEDURE setfiledir ( + dir_in IN VARCHAR2 := NULL + ,username_in IN VARCHAR2 := NULL + ) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('filedir', dir_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the file output directory for a user +---------------------------------------------------------------------------- + FUNCTION filedir (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return directory + RETURN rec.filedir; + END; + +---------------------------------------------------------------------------- +-- Set the default reporter for a user +---------------------------------------------------------------------------- + PROCEDURE setreporter ( + reporter_in IN VARCHAR2 + ,username_in IN VARCHAR2 := NULL + ) + IS + --Holds the user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('reporter', reporter_in, v_user); + Utreport.USE(reporter_in); + END; + +---------------------------------------------------------------------------- +-- Get the default reporter for a user +---------------------------------------------------------------------------- + FUNCTION getreporter (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return autocompile, defaulting to TRUE if NULL + RETURN rec.reporter; + END; + +---------------------------------------------------------------------------- +-- Set the file prefix for a user +---------------------------------------------------------------------------- + PROCEDURE setuserprefix ( + userprefix_in IN VARCHAR2 := NULL + ,username_in IN VARCHAR2 := NULL + ) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('fileuserprefix', userprefix_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the file prefix for a user +---------------------------------------------------------------------------- + FUNCTION userprefix (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return directory + RETURN rec.fileuserprefix; + END; + +---------------------------------------------------------------------------- +-- Set the include program name flag for a user +---------------------------------------------------------------------------- + PROCEDURE setincludeprogname ( + incname_in IN BOOLEAN := FALSE + ,username_in IN VARCHAR2 := NULL + ) + IS + --Holds the flag as 'Y'/'N' + v_incname CHAR (1) := utplsql.bool2vc (incname_in); + --Holds the user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('fileincprogname', v_incname, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the include program name flag for a user +---------------------------------------------------------------------------- + FUNCTION includeprogname (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return autocompile, defaulting to TRUE if NULL + RETURN NVL (utplsql.vc2bool (rec.fileincprogname), FALSE); + END; + +---------------------------------------------------------------------------- +-- Set the date format for a user +---------------------------------------------------------------------------- + PROCEDURE setdateformat ( + dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss' + ,username_in IN VARCHAR2 := NULL + ) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('filedateformat', dateformat_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the date format for a user +---------------------------------------------------------------------------- + FUNCTION DATEFORMAT (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return directory + RETURN rec.filedateformat; + END; + +---------------------------------------------------------------------------- +-- Set the file extension for a user +---------------------------------------------------------------------------- + PROCEDURE setfileextension ( + fileextension_in IN VARCHAR2 := '.UTF' + ,username_in IN VARCHAR2 := NULL + ) + IS + --The user to set + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Set the configuration + setconfig ('fileextension', fileextension_in, v_user); + END; + +---------------------------------------------------------------------------- +-- Get the file extension for a user +---------------------------------------------------------------------------- + FUNCTION fileextension (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2 + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + BEGIN + --Pull in the configuration + rec := config (v_user); + --Return directory + RETURN rec.fileextension; + END; + +---------------------------------------------------------------------------- +-- Set all of the file output columns for a user +---------------------------------------------------------------------------- + PROCEDURE setfileinfo ( + dir_in IN VARCHAR2 := NULL + ,userprefix_in IN VARCHAR2 := NULL + ,incname_in IN BOOLEAN := FALSE + ,dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss' + ,fileextension_in IN VARCHAR2 := '.UTF' + ,username_in IN VARCHAR2 := NULL + ) + IS + BEGIN + setfiledir (dir_in, username_in); + setuserprefix (userprefix_in, username_in); + setincludeprogname (incname_in, username_in); + setdateformat (dateformat_in, username_in); + setfileextension (fileextension_in, username_in); + END setfileinfo; + +---------------------------------------------------------------------------- +-- Get all of the file output columns for a user +---------------------------------------------------------------------------- + FUNCTION fileinfo (username_in IN VARCHAR2 := NULL) + RETURN rec_fileinfo + IS + --Holds the user's config record + rec ut_config%ROWTYPE; + --Holds the username in question + v_user VARCHAR2 (100) := NVL (UPPER (username_in), tester); + -- Holds the return value + fileinfo_rec rec_fileinfo; + BEGIN + --Pull in the configuration + rec := config (v_user); + --populate the record + fileinfo_rec.filedir := rec.filedir; + fileinfo_rec.fileuserprefix := rec.fileuserprefix; + fileinfo_rec.fileincprogname := rec.fileincprogname; + fileinfo_rec.filedateformat := rec.filedateformat; + fileinfo_rec.fileextension := rec.fileextension; + --Return the record + RETURN fileinfo_rec; + END fileinfo; + +-- RMM end + + PROCEDURE upd ( + username_in IN ut_config.username%TYPE + ,autocompile_in IN ut_config.autocompile%TYPE + ,prefix_in IN ut_config.prefix%TYPE + ,show_failures_only_in IN ut_config.show_failures_only%TYPE + ,directory_in IN ut_config.DIRECTORY%TYPE + ,filedir_in IN ut_config.filedir%TYPE + ,show_config_info_in IN ut_config.show_config_info%TYPE + ,editor_in IN ut_config.editor%TYPE + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + BEGIN + INSERT INTO ut_config + (username, autocompile, prefix + ,show_failures_only, DIRECTORY, filedir + ,show_config_info, editor + ) + VALUES (username_in, autocompile_in, prefix_in + ,show_failures_only_in, directory_in, filedir_in + ,show_config_info_in, editor_in + ); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Perform an update instead. + UPDATE ut_config + SET autocompile = autocompile_in + ,prefix = prefix_in + ,show_failures_only = show_failures_only_in + ,DIRECTORY = directory_in + ,filedir = filedir_in + ,show_config_info = show_config_info_in + WHERE username = username_in; + -- SF 20050922: Should have a commit; in the dup val exc header. + -- Otherwise, Oracle raises exception and rollsback. + &start_ge_8_1 COMMIT; & start_ge_8_1 + WHEN OTHERS + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + NULL; -- Present to assist in formatting + END; + + FUNCTION browser_contents ( + schema_in IN VARCHAR2 + ,name_like_in IN VARCHAR2 := '%' + ,type_like_in IN VARCHAR2 := '%' + ) + RETURN refcur_t + IS + retval refcur_t; + BEGIN + OPEN retval FOR + SELECT ao.owner, ao.object_name, ao.object_type, ao.created + ,ao.last_ddl_time, Utrutp.last_run_status ( + ao.owner, ao.object_name) status + FROM all_objects ao + WHERE ao.owner = UPPER (schema_in) + AND ao.owner NOT IN ('SYS', 'SYSTEM', 'PUBLIC') + AND object_name LIKE UPPER (name_like_in) + AND object_type LIKE UPPER (type_like_in) + AND object_type IN ('PACKAGE', 'FUNCTION', 'PROCEDURE', 'OBJECT TYPE'); + RETURN retval; + END browser_contents; + + FUNCTION source_for_program (schema_in IN VARCHAR2, NAME_IN IN VARCHAR2) + RETURN refcur_t + IS + retval refcur_t; + BEGIN + OPEN retval FOR + SELECT line, text + FROM all_source + WHERE owner = UPPER (schema_in) AND NAME = UPPER (NAME_IN); + RETURN retval; + END source_for_program; + + FUNCTION onerow (schema_in IN VARCHAR2) + RETURN refcur_t + IS + retval refcur_t; + BEGIN + OPEN retval FOR + SELECT autocompile, DIRECTORY, filedir, prefix, show_failures_only + ,show_config_info, editor + FROM ut_config + WHERE username = UPPER (schema_in); + END onerow; + + PROCEDURE get_onerow ( + schema_in IN VARCHAR2 + ,username_out OUT VARCHAR2 + ,autocompile_out OUT ut_config.autocompile%TYPE + ,prefix_out OUT ut_config.prefix%TYPE + ,show_failures_only_out OUT ut_config.show_failures_only%TYPE + ,directory_out OUT ut_config.DIRECTORY%TYPE + ,filedir_out OUT ut_config.filedir%TYPE + ,show_config_info_out OUT ut_config.show_config_info%TYPE + ,editor_out OUT ut_config.editor%TYPE + ) + IS + BEGIN + SELECT username, autocompile, DIRECTORY, filedir + ,prefix, show_failures_only, show_config_info + ,editor + INTO username_out, autocompile_out, directory_out, filedir_out + ,prefix_out, show_failures_only_out, show_config_info_out + ,editor_out + FROM ut_config + WHERE username = UPPER (schema_in); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + username_out := NULL; + END get_onerow; +BEGIN + --Initially, set the user as default tester + settester; +END; +/ diff --git a/source/ut_config.pks b/source/ut_config.pks new file mode 100644 index 000000000..346523bf7 --- /dev/null +++ b/source/ut_config.pks @@ -0,0 +1,276 @@ +CREATE OR REPLACE PACKAGE utconfig &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.3 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + +------------------------------------------------------------------------------- +--Description +------------------------------------------------------------------------------- +--This package manages the ut_config table, which holds the configuration +--settings for different users. The configuration data to be used by utPLSQL +--by default is set by calling settester. Wherever a username is passed as NULL, +--it is assumed to be that user. This defaults initially to the current user. +------------------------------------------------------------------------------- + + --The default prefix + c_prefix CONSTANT CHAR (3) := 'ut_'; + --The default delimiter + c_delimiter CONSTANT CHAR (2) := '##'; + + -- RMM start + -- Record definition used by fileinfo function + TYPE rec_fileinfo IS RECORD ( + filedir UT_CONFIG.filedir%TYPE + ,fileuserprefix UT_CONFIG.fileuserprefix%TYPE + ,fileincprogname UT_CONFIG.fileincprogname%TYPE + ,filedateformat UT_CONFIG.filedateformat%TYPE + ,fileextension UT_CONFIG.filedateformat%TYPE + ); + + -- RMM end + + TYPE refcur_t IS REF CURSOR; + + CURSOR browser_cur + IS + SELECT owner, object_name, object_type, created, last_ddl_time, status + FROM all_objects; + + cursor source_cur + IS + SELECT line, text FROM all_source; + + -- Set the user whose configuration we use by default + PROCEDURE settester (username_in IN VARCHAR2 := USER); + + -- Get the user we use by default + FUNCTION tester + RETURN VARCHAR2; + + -- Display the current configuration settings + PROCEDURE showconfig (username_in IN VARCHAR2 := NULL); + + -- Set the default prefix + PROCEDURE setprefix (prefix_in IN VARCHAR2, username_in IN VARCHAR2 := NULL); + + -- Get the default prefix + FUNCTION prefix (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- 2.0.7 Switch to delimiter for V2 + -- Set the default delimiter + PROCEDURE setdelimiter ( + delimiter_in IN VARCHAR2 + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the default delimiter + FUNCTION delimiter (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set location of source code + PROCEDURE setdir (dir_in IN VARCHAR2, username_in IN VARCHAR2 := NULL); + + -- Get location of source code + FUNCTION dir (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set autocompile flag + PROCEDURE autocompile (onoff_in IN BOOLEAN, username_in IN VARCHAR2 := NULL); + + -- Get autocompile flag + FUNCTION autocompiling (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN; + + -- Set manual registration flag + PROCEDURE registertest (onoff_in IN BOOLEAN, username_in IN VARCHAR2 + := NULL); + + -- Get manual registration flag + FUNCTION registeringtest (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN; + + /* start 2.0.10.1 additions */ + -- Show failures only? + PROCEDURE showfailuresonly ( + onoff_in IN BOOLEAN + ,username_in IN VARCHAR2 := NULL + ); + + FUNCTION showingfailuresonly (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN; + + /* end 2.0.10.1 additions */ + + -- Set the directory for file output + PROCEDURE setfiledir ( + dir_in IN VARCHAR2 := NULL + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the directory for file output + FUNCTION filedir (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set the default reporter + PROCEDURE setreporter ( + reporter_in IN VARCHAR2 + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the default reporter for a user + FUNCTION getreporter (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set the file prefix for a user + PROCEDURE setuserprefix ( + userprefix_in IN VARCHAR2 := NULL + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the file prefix for a user + FUNCTION userprefix (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set the include program name flag for a user + PROCEDURE setincludeprogname ( + incname_in IN BOOLEAN := FALSE + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the include program name flag for a user + FUNCTION includeprogname (username_in IN VARCHAR2 := NULL) + RETURN BOOLEAN; + + -- Set the date format for a user + PROCEDURE setdateformat ( + dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss' + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the date format for a user + FUNCTION DATEFORMAT (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set the file extension for a user + PROCEDURE setfileextension ( + fileextension_in IN VARCHAR2 := '.UTF' + ,username_in IN VARCHAR2 := NULL + ); + + -- Get the file extension for a user + FUNCTION fileextension (username_in IN VARCHAR2 := NULL) + RETURN VARCHAR2; + + -- Set all of the file output columns for a user + PROCEDURE setfileinfo ( + dir_in IN VARCHAR2 := NULL + ,userprefix_in IN VARCHAR2 := NULL + ,incname_in IN BOOLEAN := FALSE + ,dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss' + ,fileextension_in IN VARCHAR2 := '.UTF' + ,username_in IN VARCHAR2 := NULL + ); + + -- Get all of the file output columns for a user + FUNCTION fileinfo (username_in IN VARCHAR2 := NULL) + RETURN rec_fileinfo; + + -- RMM end + + -- 2.1.1: Single update and insert procedure + PROCEDURE upd ( + username_in IN ut_config.username%TYPE + ,autocompile_in IN ut_config.autocompile%TYPE + ,prefix_in IN ut_config.prefix%TYPE + ,show_failures_only_in IN ut_config.show_failures_only%TYPE + ,directory_in IN ut_config.DIRECTORY%TYPE + ,filedir_in IN ut_config.filedir%TYPE + ,show_config_info_in IN ut_config.show_config_info%TYPE + ,editor_in IN ut_config.editor%TYPE + ); + + /* The upd procedure does an insert if no row exists. + PROCEDURE add ( + username_in IN ut_config.username%TYPE, + AUTOCOMPILE_in IN ut_config.AUTOCOMPILE%TYPE := 'N', + prefix_in in ut_config.prefix%TYPE := c_prefix, + SHOW_FAILURES_ONLY_in in ut_config.SHOW_FAILURES_ONLY%TYPE := 'N', + directory_in IN ut_config.directory%TYPE := NULL, + FILEDIR_in in ut_config.FILEDIR%TYPE := NULL, + show_config_info_in in ut_config.show_config_info%TYPE := 'Y') ; + */ + FUNCTION browser_contents ( + schema_in IN VARCHAR2 + ,name_like_in IN VARCHAR2 := '%' + ,type_like_in IN VARCHAR2 := '%' + ) + RETURN refcur_t; + + /* + Sample usage: + + DECLARE + rc utconfig.refcur_t; + rec utconfig.browser_cur%ROWTYPE; + BEGIN + rc := utconfig.browser_contents (USER); + + LOOP + FETCH rc INTO rec; + EXIT WHEN rc%NOTFOUND; + p.l (rec.object_name); + END LOOP; + END; + */ + + FUNCTION source_for_program ( + schema_in IN VARCHAR2 + ,name_in IN VARCHAR2 + ) + RETURN refcur_t; + + FUNCTION onerow (schema_in IN VARCHAR2) + RETURN refcur_t; + + PROCEDURE get_onerow ( + schema_in IN VARCHAR2 + ,username_out OUT VARCHAR2 + ,autocompile_out OUT ut_config.autocompile%TYPE + ,prefix_out OUT ut_config.prefix%TYPE + ,show_failures_only_out OUT ut_config.show_failures_only%TYPE + ,directory_out OUT ut_config.DIRECTORY%TYPE + ,filedir_out OUT ut_config.filedir%TYPE + ,show_config_info_out OUT ut_config.show_config_info%TYPE + ,editor_out OUT ut_config.editor%TYPE + ); +END; +/ diff --git a/source/ut_config.tab b/source/ut_config.tab new file mode 100644 index 000000000..e235d1291 --- /dev/null +++ b/source/ut_config.tab @@ -0,0 +1,30 @@ +CREATE TABLE UT_CONFIG ( + username VARCHAR2(100), + autocompile CHAR(1) DEFAULT 'Y', /* V1 compatibility */ + registertest CHAR(1) DEFAULT 'N', /* V1 compatibility */ + DIRECTORY VARCHAR2(2000), /* V1 compatibility */ + naming_mode CHAR(2), /* either V1 or V2 */ + prefix VARCHAR2(100) /* V1 name construction */ , + CONSTRAINT ut_config_pk PRIMARY KEY (username) +); + +REM /* V2 name construction */ +ALTER TABLE UT_CONFIG ADD delimiter VARCHAR2(10) DEFAULT '##'; + +REM 2.0.10.1 Add show only failure results +ALTER TABLE UT_CONFIG ADD show_failures_only CHAR(1) DEFAULT 'N'; + +REM RMM start columns required for file output +ALTER TABLE UT_CONFIG ADD filedir VARCHAR2 (2000); +ALTER TABLE UT_CONFIG ADD fileuserprefix VARCHAR2 (100); +ALTER TABLE UT_CONFIG ADD fileincprogname VARCHAR2 (1) DEFAULT 'N'; +ALTER TABLE UT_CONFIG ADD filedateformat VARCHAR2 (100) DEFAULT 'yyyyddmmhh24miss'; +ALTER TABLE UT_CONFIG ADD fileextension VARCHAR2 (200) DEFAULT '.UTF'; +REM RMM columns required for file output + +REM 2.1.1 +ALTER TABLE UT_CONFIG ADD show_config_info VARCHAR2 (1) DEFAULT 'Y'; +ALTER TABLE UT_CONFIG ADD editor VARCHAR2 (1000); + +ALTER TABLE UT_CONFIG ADD reporter VARCHAR2(100); + diff --git a/source/ut_deterministic.tab b/source/ut_deterministic.tab new file mode 100644 index 000000000..094dfd7f7 --- /dev/null +++ b/source/ut_deterministic.tab @@ -0,0 +1,12 @@ +create table ut_deterministic ( + package varchar2(100), + overload integer, + name varchar2(100), + tcname varchar2(100), + message varchar2(2000), + arglist varchar2(2000), + result varchar2(2000), + assertion_type varchar2(20)); + +ALTER table ut_deterministic add CONSTRAINT ut_deterministic_pk + primary key (package, overload, name, tcname); diff --git a/source/ut_deterministic_arg.tab b/source/ut_deterministic_arg.tab new file mode 100644 index 000000000..603cfb0a0 --- /dev/null +++ b/source/ut_deterministic_arg.tab @@ -0,0 +1,10 @@ +create table ut_deterministic_arg ( + package varchar2(100), + overload integer, + name varchar2(100), + tcname varchar2(100), + seq integer, + arg_value varchar2(2000)); + +ALTER table ut_deterministic_arg add CONSTRAINT ut_deterministic_fk + FOREIGN KEY (package, overload, name, tcname) REFERENCES ut_deterministic; diff --git a/source/ut_eq.tab b/source/ut_eq.tab new file mode 100644 index 000000000..e8fd252aa --- /dev/null +++ b/source/ut_eq.tab @@ -0,0 +1,15 @@ +create table ut_eq ( +id integer , +outcome_id integer, +data_type integer, +check_v varchar2(2000), +against_v varchar2(2000), +check_d date , +against_d date , +check_n number , +against_n number , +check_b char(1) , +against_b char(1), + CONSTRAINT ut_eq_pk PRIMARY KEY (id) +); + diff --git a/source/ut_filereporter.pkb b/source/ut_filereporter.pkb new file mode 100644 index 000000000..c810dc65e --- /dev/null +++ b/source/ut_filereporter.pkb @@ -0,0 +1,241 @@ +CREATE OR REPLACE PACKAGE BODY Utfilereporter +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2004/11/16 09:46:48 chrisrimmer +Changed to new version detection system. + +Revision 1.1 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + + +************************************************************************/ + + g_fid UTL_FILE.FILE_TYPE := NULL; + + PROCEDURE record_error (str IN VARCHAR2) + IS + BEGIN + UtOutputReporter.pl('UTL_FILE error: ' || str); + Utfilereporter.CLOSE(bool_abort => TRUE); + END; + + PROCEDURE open_file(dir VARCHAR2, filename VARCHAR2, filemode VARCHAR2 := 'A') + IS + BEGIN + + IF g_fid.ID IS NOT NULL THEN + close_file; + END IF; + + g_fid := UTL_FILE.FOPEN (dir, filename, filemode); + + EXCEPTION + WHEN UTL_FILE.INVALID_PATH + THEN record_error ('invalid_path'); + RAISE; + WHEN UTL_FILE.INVALID_MODE + THEN record_error ('invalid_mode'); + RAISE; + WHEN UTL_FILE.INVALID_FILEHANDLE + THEN record_error ('invalid_filehandle'); + RAISE; + WHEN UTL_FILE.INVALID_OPERATION + THEN record_error ('invalid_operation'); + RAISE; + WHEN UTL_FILE.READ_ERROR + THEN record_error ('read_error'); + RAISE; + WHEN UTL_FILE.WRITE_ERROR + THEN record_error ('write_error'); + RAISE; + WHEN UTL_FILE.INTERNAL_ERROR + THEN record_error ('internal_error'); + RAISE; + END; + + PROCEDURE close_file + IS + BEGIN + + UTL_FILE.FCLOSE (g_fid); + g_fid.ID := NULL; + + EXCEPTION + WHEN UTL_FILE.INVALID_PATH + THEN record_error ('invalid_path'); + RAISE; + WHEN UTL_FILE.INVALID_MODE + THEN record_error ('invalid_mode'); + RAISE; + WHEN UTL_FILE.INVALID_FILEHANDLE + THEN record_error ('invalid_filehandle'); + RAISE; + WHEN UTL_FILE.INVALID_OPERATION + THEN record_error ('invalid_operation'); + RAISE; + WHEN UTL_FILE.READ_ERROR + THEN record_error ('read_error'); + RAISE; + WHEN UTL_FILE.WRITE_ERROR + THEN record_error ('write_error'); + RAISE; + WHEN UTL_FILE.INTERNAL_ERROR + THEN record_error ('internal_error'); + RAISE; + END; + + PROCEDURE OPEN + IS + + file_dir UT_CONFIG.filedir%TYPE; + userprefix UT_CONFIG.fileuserprefix%TYPE; + incprog UT_CONFIG.fileincprogname%TYPE; + extension UT_CONFIG.fileextension%TYPE; + + no_dir EXCEPTION; + + BEGIN + + -- Get the output file directory + file_dir := Utconfig.filedir (); + -- check if NULL + IF file_dir IS NULL THEN + -- try directory + file_dir := Utconfig.dir (); + -- check if NULL + IF file_dir IS NULL THEN + record_error('No directory specified for file output'); + RAISE no_dir; + END IF; + END IF; + + -- Get the userprefix from config + userprefix := Utconfig.userprefix(); + IF userprefix IS NULL THEN + -- use the current user if userprefix IS NULL + userprefix := USER; + END IF; + userprefix := userprefix ||'_'; + + -- get the file extension + extension := Utconfig.fileextension(); + + open_file (file_dir, userprefix || TO_CHAR(SYSDATE,Utconfig.dateformat)||extension); + + pl('-- '||TO_CHAR(SYSDATE,Utconfig.dateformat)); + + END; + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + utOutputReporter.before_results(run_id); + END; + + PROCEDURE show_failure + IS + BEGIN + utOutputReporter.show_failure; + END; + + PROCEDURE show_result + IS + BEGIN + utOutputReporter.show_result; + END; + + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + utOutputReporter.after_results(run_id); + END; + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + utOutputReporter.before_errors(run_id); + END; + + PROCEDURE show_error + IS + BEGIN + utOutputReporter.show_error; + END; + + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + utOutputReporter.after_errors(run_id); + END; + + PROCEDURE CLOSE(bool_abort BOOLEAN := FALSE) + IS + BEGIN + IF NOT bool_abort AND g_fid.ID IS NOT NULL THEN + pl('-- '||TO_CHAR(SYSDATE,Utconfig.dateformat)); + END IF; + + close_file; + END; + + PROCEDURE pl (str IN VARCHAR2) + IS + BEGIN + + IF g_fid.ID IS NULL THEN + utfilereporter.open; + END IF; + + -- write input to file + UTL_FILE.PUT_LINE (g_fid, str); + + EXCEPTION + WHEN UTL_FILE.INVALID_PATH + THEN record_error ('invalid_path'); + RAISE; + WHEN UTL_FILE.INVALID_MODE + THEN record_error ('invalid_mode'); + RAISE; + WHEN UTL_FILE.INVALID_FILEHANDLE + THEN record_error ('invalid_filehandle'); + RAISE; + WHEN UTL_FILE.INVALID_OPERATION + THEN record_error ('invalid_operation'); + RAISE; + WHEN UTL_FILE.READ_ERROR + THEN record_error ('read_error'); + RAISE; + WHEN UTL_FILE.WRITE_ERROR + THEN record_error ('write_error'); + RAISE; + WHEN UTL_FILE.INTERNAL_ERROR + THEN record_error ('internal_error'); + RAISE; + END pl; + +BEGIN + g_fid.ID := NULL; +END; +/ diff --git a/source/ut_filereporter.pks b/source/ut_filereporter.pks new file mode 100644 index 000000000..2ecc30a4a --- /dev/null +++ b/source/ut_filereporter.pks @@ -0,0 +1,39 @@ +CREATE OR REPLACE PACKAGE utfilereporter &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log + +************************************************************************/ + + --The procedures to use this as a reporter + PROCEDURE open; + PROCEDURE pl (str IN VARCHAR2); + PROCEDURE close(bool_abort BOOLEAN := FALSE); + + --Simpler versions to be used by other reporters + PROCEDURE open_file(dir VARCHAR2, filename VARCHAR2, filemode VARCHAR2 := 'A'); + PROCEDURE close_file; + +END; +/ diff --git a/source/ut_gen.pkb b/source/ut_gen.pkb new file mode 100644 index 000000000..efd30bd4e --- /dev/null +++ b/source/ut_gen.pkb @@ -0,0 +1,1454 @@ +CREATE OR REPLACE PACKAGE BODY utgen +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2005 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.6 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.5 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.4 2004/05/11 15:36:58 chrisrimmer +Added tweak to cursor from Steven F + +Revision 1.3 2004/05/11 15:33:56 chrisrimmer +Added 9.2 specific code from Mark Vilrokx + +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + g_pkgstring VARCHAR2 (32767); + g_currrow PLS_INTEGER := NULL; + g_firstbodyrow PLS_INTEGER := NULL; + + TYPE code_tt IS TABLE OF codeline_t + INDEX BY BINARY_INTEGER; + + pkgarray code_tt; + + -- 1.5.6 Generic string parser + TYPE item_tt IS TABLE OF VARCHAR2 (2000) + INDEX BY BINARY_INTEGER; + + PROCEDURE parse_string ( + string_in IN VARCHAR2 + , items_out IN OUT item_tt + , delim_in IN VARCHAR2 := ',' + ) + IS + v_item VARCHAR2 (32767); + v_loc PLS_INTEGER; + v_startloc PLS_INTEGER := 1; + + PROCEDURE add_item (item_in IN VARCHAR2) + IS + BEGIN + IF (item_in != delim_in OR item_in IS NULL) + THEN + items_out (NVL (items_out.LAST, 0) + 1) := item_in; + END IF; + END; + BEGIN + items_out.DELETE; + + LOOP + -- Find next delimiter + v_loc := INSTR (string_in, delim_in, v_startloc); + + IF v_loc = v_startloc -- Previous item is NULL + THEN + v_item := NULL; + ELSIF v_loc = 0 -- Rest of string is last item + THEN + v_item := SUBSTR (string_in, v_startloc); + ELSE + v_item := SUBSTR (string_in, v_startloc, v_loc - v_startloc); + END IF; + + add_item (v_item); + + IF v_loc = 0 + THEN + EXIT; + ELSE + add_item (delim_in); + v_startloc := v_loc + 1; + END IF; + END LOOP; + END parse_string; + + PROCEDURE get_nextline ( + file_in IN UTL_FILE.file_type + , line_out OUT VARCHAR2 + , eof_out OUT BOOLEAN + ) + IS + BEGIN + UTL_FILE.get_line (file_in, line_out); + eof_out := FALSE; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + line_out := NULL; + eof_out := TRUE; + END; + + -- 1.5.6: add this and rewrite isfunction + FUNCTION return_type ( + schema_in IN VARCHAR2 + , package_in IN VARCHAR2 + , program_in IN VARCHAR2 + , overload_in IN PLS_INTEGER := NULL + ) + RETURN VARCHAR2 + IS + retval all_arguments.data_type%TYPE; + BEGIN + SELECT data_type + INTO retval + FROM all_arguments + WHERE owner = NVL (UPPER (schema_in), USER) + AND ( package_name = UPPER (package_in) + OR (package_name IS NULL AND package_in IS NULL) + ) + AND object_name = UPPER (program_in) + AND ( overload = overload_in + OR (overload IS NULL AND overload_in IS NULL) + ) + AND argument_name IS NULL + AND POSITION = 0; + + IF retval LIKE 'PL/SQL%' + THEN + -- Change "PL/SQL BOOLEAN" to "BOOLEAN" and so on... + retval := SUBSTR (retval, 8); + ELSIF retval IN ('VARCHAR2', 'VARCHAR', 'CHAR') + THEN + -- Make it a legal string declaration. + retval := retval || '(2000)'; + END IF; + + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + WHEN OTHERS + THEN + RETURN NULL; + END; + + FUNCTION isfunction ( + schema_in IN VARCHAR2 + , package_in IN VARCHAR2 + , program_in IN VARCHAR2 + , overload_in IN PLS_INTEGER := NULL + ) + RETURN BOOLEAN + IS + BEGIN + RETURN (return_type (schema_in, package_in, program_in, overload_in) IS NOT NULL + ); + END; + + PROCEDURE testpkg ( + package_in IN VARCHAR2 + , grid_in IN grid_tt + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , delim_in IN VARCHAR2 := c_delim + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , only_if_in_grid_in IN BOOLEAN := FALSE + , override_file_in IN VARCHAR2 := NULL + ) + IS + fid UTL_FILE.file_type; + v_ispkg BOOLEAN := utplsql.ispackage (package_in, schema_in); + v_dir VARCHAR2 (2000) := NVL (dir_in, utconfig.dir); + v_pkg VARCHAR2 (100); + v_progprefix VARCHAR2 (100); + -- Used in queries against ALL_ARGUMENTS + v_objpackage VARCHAR2 (100); + v_objprogram VARCHAR2 (100); + l_grid grid_tt; + + CURSOR prog_cur (package_in IN VARCHAR2, program_in IN VARCHAR2) + IS &start_lt_9 + SELECT DISTINCT owner, package_name, object_name, overload, + object_name || overload + full_name + FROM all_arguments + WHERE owner = NVL (UPPER (schema_in), USER) + AND ( package_name = UPPER (package_in) + AND object_name LIKE + NVL (UPPER (program_in), '%') + ) + OR ( ( package_name IS NULL + -- 2.0.9.1 9i changes way package_name is set. + OR package_name = UPPER (program_in) + ) + AND package_in IS NULL + AND object_name = UPPER (program_in) + ); + &end_lt_9 + &start_ge_9 + SELECT owner, object_name package_name, procedure_name object_name, + DECODE ( + ROW_NUMBER () OVER (PARTITION BY procedure_name ORDER BY object_name), + 1, NULL, + ROW_NUMBER () OVER (PARTITION BY procedure_name ORDER BY object_name) + ) overload, + procedure_name + || DECODE ( + ROW_NUMBER () OVER (PARTITION BY procedure_name ORDER BY object_name), + 1, NULL, + ROW_NUMBER () OVER (PARTITION BY procedure_name ORDER BY object_name) + ) full_name + FROM all_procedures + WHERE owner = NVL (UPPER (schema_in), USER) + AND ( object_name = UPPER (package_in) + AND procedure_name LIKE + NVL (UPPER (program_in), '%') + ) + OR ( ( object_name IS NULL + -- 2.0.9.1 9i changes way package_name is set. + OR object_name = UPPER (program_in) + ) + AND package_in IS NULL + AND procedure_name = UPPER (program_in) + ); + &end_ge_9 + + CURSOR arg_cur ( + schema_in IN VARCHAR2 + , package_in IN VARCHAR2 + , program_in IN VARCHAR2 + , overload_in IN PLS_INTEGER + ) + IS + SELECT argument_name, data_type + FROM all_arguments + WHERE owner = schema_in + AND ( package_name = package_in + OR (package_name IS NULL AND package_in IS NULL) + ) + AND object_name = program_in + AND argument_name IS NOT NULL + AND ( overload = overload_in + OR (overload IS NULL AND overload_in IS NULL) + ) + ORDER BY POSITION; + + arg arg_cur%ROWTYPE; + noargs BOOLEAN; + + PROCEDURE setup (ext IN VARCHAR2 := NULL) + IS + BEGIN + IF output_type_in = c_screen + THEN + NULL; + ELSIF output_type_in = c_string + THEN + g_pkgstring := NULL; + ELSIF output_type_in = c_array + THEN + pkgarray.DELETE; + g_currrow := NULL; + g_firstbodyrow := NULL; + ELSIF output_type_in = c_file + THEN + utassert.this + ('Compile error: you must specify a directory with utConfig.setdir!' + , v_dir IS NOT NULL + , register_in => FALSE + ); + + IF utplsql.tracing + THEN + utreport.pl (v_dir || '-' || package_in || '.' || ext); + END IF; + + fid := + UTL_FILE.fopen (v_dir + , NVL (override_file_in + , NVL (prefix_in + , utconfig.prefix (schema_in) + ) + || package_in + || '.' + || ext + ) + , 'W' + , max_linesize => 32767 + ); + END IF; + END; + + PROCEDURE putline (str IN VARCHAR2) + IS + BEGIN + IF output_type_in = c_screen + THEN + utOutputReporter.pl(str); + ELSIF output_type_in = c_string + THEN + g_pkgstring := g_pkgstring || '|' || str; + ELSIF output_type_in = c_array + THEN + pkgarray (NVL (pkgarray.LAST, 0) + 1) := str; + ELSIF output_type_in = c_file + THEN + UTL_FILE.put_line (fid, str); + END IF; + END; + + PROCEDURE cleanup + IS + BEGIN + IF output_type_in = c_screen + THEN + NULL; + ELSIF output_type_in = c_string + THEN + g_pkgstring := LTRIM (g_pkgstring, '|'); + ELSIF output_type_in = c_file + THEN + UTL_FILE.fclose (fid); + END IF; + END; + + FUNCTION program_call ( -- 2.0.9.1 switch to whole record + rec IN prog_cur%ROWTYPE + , is_package IN BOOLEAN /* + package_in IN VARCHAR2, + program_in IN VARCHAR2 */ + ) + RETURN VARCHAR2 + IS + BEGIN + IF rec.package_name IS NOT NULL AND is_package + THEN + RETURN rec.package_name || '.' || rec.object_name; + ELSE + RETURN rec.object_name; + END IF; + END; + + PROCEDURE iputline ( + string_in IN VARCHAR2 + , indentby_in IN PLS_INTEGER := 3 + ) + IS + BEGIN + putline (LPAD (' ', indentby_in, ' ') || string_in); + END; + + PROCEDURE i6putline (string_in IN VARCHAR2) + IS + BEGIN + putline (LPAD (' ', 6, ' ') || string_in); + END; + + FUNCTION include_program ( + NAME_IN IN VARCHAR2 + , overload_in IN PLS_INTEGER + , curr_name_in IN VARCHAR2 + , curr_overload_in IN PLS_INTEGER + ) + RETURN BOOLEAN + IS + BEGIN + RETURN ( UPPER (NAME_IN) = curr_name_in + AND ( overload_in = curr_overload_in + OR (overload_in = 1 AND curr_overload_in IS NULL) + OR (overload_in IS NULL AND curr_overload_in IS NULL) + ) + ); + -- OR v_objprogram = '%'; + END; + + FUNCTION include_program (rec IN prog_cur%ROWTYPE, grid_in IN grid_tt) + RETURN BOOLEAN + IS + retval BOOLEAN := NOT only_if_in_grid_in; + grid_index PLS_INTEGER := grid_in.FIRST; + BEGIN + -- Does the program in rec appear at all in grid_in? + IF only_if_in_grid_in + THEN + LOOP + EXIT WHEN grid_index IS NULL; + + IF include_program (grid_in (grid_index).progname + , grid_in (grid_index).overload + , rec.object_name + , rec.overload + ) + THEN + retval := TRUE; + EXIT; + ELSE + grid_index := grid_in.NEXT (grid_index); + END IF; + END LOOP; + END IF; + + RETURN retval; + END; + + PROCEDURE generate_setup ( + prefix_in IN VARCHAR2 + , schema_in IN VARCHAR2 + , objpackage_in IN VARCHAR2 + , objprogram_in IN VARCHAR2 + ) + IS + BEGIN + iputline ('PROCEDURE ' || prefix_in || 'setup'); + iputline ('IS'); + iputline ('BEGIN'); + + IF utconfig.registeringtest (schema_in) + THEN + iputline (' -- For each program to test...'); + + FOR rec IN prog_cur (objpackage_in, objprogram_in) + LOOP + IF include_program (rec, grid_in) + THEN + iputline (' utPLSQL.addtest (''' || rec.full_name + || ''');' + ); + END IF; + END LOOP; + ELSE + iputline (' NULL;'); + END IF; + + iputline ('END;'); + iputline (''); + END; + + PROCEDURE generate_teardown (prefix_in IN VARCHAR2) + IS + BEGIN + iputline ('PROCEDURE ' || prefix_in || 'teardown'); + iputline ('IS'); + iputline ('BEGIN'); + iputline (' NULL;'); + iputline ('END;'); + END; + + FUNCTION is_expression (string_in IN VARCHAR2) + RETURN BOOLEAN + IS + BEGIN + RETURN SUBSTR (string_in, 1, 1) = c_asis; + END; + + -- NOK0205: manage null ok argument inclusion + PROCEDURE add_null_ok (grid_in IN grid_rt) + IS + BEGIN + IF grid_in.null_ok = 'Y' + THEN + i6putline (' ,null_ok_in => TRUE'); + ELSIF grid_in.null_ok = 'N' + THEN + i6putline (' ,null_ok_in => FALSE'); + END IF; + END add_null_ok; + + PROCEDURE generate_ut_procedure ( + prefix_in IN VARCHAR2 + , rec IN prog_cur%ROWTYPE + , + /*schema_in IN VARCHAR2, + objpackage_in IN VARCHAR2, + objprogram_in IN VARCHAR2,*/ + grid_in IN grid_tt + ) + IS + v_isfunction BOOLEAN; + v_datatype VARCHAR2 (100); + + FUNCTION data_value (value_in IN VARCHAR2, type_in IN VARCHAR2) + RETURN VARCHAR2 + IS + retval VARCHAR2 (2000) := value_in; + BEGIN + IF is_expression (value_in) + THEN + retval := SUBSTR (value_in, 2); + ELSIF value_in IS NULL OR UPPER (value_in) = 'NULL' + THEN + retval := 'NULL'; + ELSIF type_in LIKE '%CHAR%' + THEN + retval := '''' || value_in || ''''; + ELSIF type_in IN ('NUMBER', 'FLOAT') OR type_in LIKE '%INT%' + THEN + retval := value_in; + ELSIF type_in IN ('BOOLEAN', 'PL/SQL BOOLEAN') + THEN + retval := value_in; + ELSIF type_in LIKE '%DATE%' + THEN + retval := + 'TO_DATE (''' + || value_in + || ''', ''' + || date_format_in + || ''')'; + END IF; + + RETURN retval; + END; + + PROCEDURE generate_testcase ( + rec IN prog_cur%ROWTYPE + , isfunction_in IN BOOLEAN + , datatype_in IN VARCHAR2 + , grid_in IN grid_rt + ) + IS + l_entries item_tt; + + PROCEDURE putarg ( + arg_in IN arg_cur%ROWTYPE + , ntharg_in IN PLS_INTEGER + ) + IS + BEGIN + IF l_entries.COUNT > 0 + THEN + i6putline ( ' ' + || arg_in.argument_name + || ' => ' + || data_value (l_entries (ntharg_in) + , arg_in.data_type + ) + ); + ELSE + i6putline (' ' || arg_in.argument_name || ' => '''''); + END IF; + END; + + FUNCTION testname + RETURN VARCHAR2 + IS + BEGIN + IF grid_in.progname IS NOT NULL + THEN + RETURN ' for "' || grid_in.tcname || '"'; + ELSE + RETURN NULL; + END IF; + END; + BEGIN + i6putline (''); + i6putline ('-- Define "control" operation' || testname); + i6putline (' '); + + IF isfunction_in + THEN + i6putline ( 'against_this := ' + || data_value (grid_in.return_value, datatype_in) + || ';' + ); + END IF; + + i6putline (' '); + i6putline ('-- Execute test code' || testname); + i6putline (' '); + + OPEN arg_cur (rec.owner + , rec.package_name + , rec.object_name + , rec.overload + ); + + FETCH arg_cur + INTO arg; + + noargs := arg_cur%NOTFOUND; + + IF isfunction_in + THEN + i6putline ('check_this := '); + END IF; + + IF noargs + THEN + i6putline ( -- 2.0.9.1: use procedure, not explicit concat. + program_call (rec, v_ispkg) || ';'); + ELSE + i6putline (program_call (rec, v_ispkg) || ' ('); + + IF grid_in.arglist IS NOT NULL + THEN + parse_string (grid_in.arglist, l_entries, delim_in); + END IF; + + WHILE arg_cur%FOUND + LOOP + putarg (arg, arg_cur%ROWCOUNT); + + FETCH arg_cur + INTO arg; + + IF arg_cur%FOUND + THEN + i6putline (' ,'); + END IF; + END LOOP; + + iputline (' );'); + END IF; + + CLOSE arg_cur; + + i6putline (' '); + i6putline ('-- Assert success' || testname); + i6putline (' '); + + -- Here I should access information in ut_assertion table to dynamically + -- build the call to the utAssert procedure. For now, I will hard code + -- for EQ and ISNULL to demonstrate the possibilities. + IF v_isfunction + THEN + IF grid_in.assertion_type = 'EQ' + OR grid_in.assertion_type IS NULL + THEN + i6putline ('-- Compare the two values.'); + i6putline ('utAssert.eq ('); + i6putline ( ' ''' + || NVL (grid_in.MESSAGE + , 'Test of ' || rec.object_name + ) + || ''',' + ); + i6putline (' check_this,'); + i6putline (' against_this'); + add_null_ok (grid_in); + i6putline (' );'); + ELSIF grid_in.assertion_type = 'ISNULL' + THEN + i6putline ('-- Check for NULL return value.'); + i6putline ('utAssert.isNULL ('); + i6putline ( ' ''' + || NVL (grid_in.MESSAGE + , 'NULL Test for ' || rec.object_name + ) + || ''',' + ); + i6putline (' check_this'); + i6putline (' );'); + END IF; + ELSE + i6putline ('utAssert.this ('); + i6putline ( ' ''' + || NVL (grid_in.MESSAGE + , 'Test of ' || rec.object_name + ) + || ''',' + ); + i6putline (' '''''); + add_null_ok (grid_in); + i6putline (' );'); + END IF; + + i6putline (''); + i6putline ('-- End of test' || testname); + END; + + PROCEDURE generate_testcase ( + rec IN prog_cur%ROWTYPE + , isfunction_in IN BOOLEAN + , datatype_in IN VARCHAR2 + ) + IS + l_empty grid_rt; + BEGIN + generate_testcase (rec, isfunction_in, datatype_in, l_empty); + END; + BEGIN + v_isfunction := + isfunction (rec.owner + , rec.package_name + , rec.object_name + , rec.overload + ); + + IF v_isfunction + THEN + v_datatype := + return_type (rec.owner + , rec.package_name + , rec.object_name + , rec.overload + ); + END IF; + + iputline ('PROCEDURE ' || prefix_in || rec.full_name); + iputline ('IS'); + + IF v_isfunction + THEN + i6putline ('-- Verify and complete data types.'); + i6putline ('against_this ' || v_datatype || ';'); + i6putline ('check_this ' || v_datatype || ';'); + END IF; + + iputline ('BEGIN'); + + IF grid_in.COUNT = 0 + THEN + generate_testcase (rec, v_isfunction, v_datatype); + ELSE + FOR indx IN grid_in.FIRST .. grid_in.LAST + LOOP + generate_testcase (rec + , v_isfunction + , v_datatype + , grid_in (indx) + ); + END LOOP; + END IF; + + iputline ('END ' || v_progprefix || rec.full_name || ';'); + putline (''); + END; + + BEGIN /* MAIN TESTPKG */ + utassert.this ('Invalid target to generate a package: ' + || output_type_in + , output_type_in IN (c_string, c_screen, c_file, c_array) + , register_in => FALSE + ); + v_pkg := + utplsql.pkgname (package_in + , samepackage_in + , NVL (prefix_in, utconfig.prefix (schema_in)) + , v_ispkg + ); + v_progprefix := + utplsql.progname (NULL + , samepackage_in + , NVL (prefix_in, utconfig.prefix (schema_in)) + , v_ispkg + ); + + IF v_ispkg + THEN + v_objpackage := UPPER (package_in); + v_objprogram := UPPER (program_in); + ELSE + v_objpackage := NULL; + v_objprogram := UPPER (package_in); + END IF; + + setup ('pks'); + + -- Spit out the package spec + IF samepackage_in + THEN + putline ('-- START: place in specification of source package'); + ELSE + putline ('CREATE OR REPLACE PACKAGE ' || v_pkg); + putline ('IS'); + END IF; + + putline (' PROCEDURE ' || v_progprefix || 'setup;'); + putline (' PROCEDURE ' || v_progprefix || 'teardown;'); + putline (' '); + putline (' -- For each program to test...'); + + FOR rec IN prog_cur (v_objpackage, v_objprogram) + LOOP + IF include_program (rec, grid_in) + THEN + putline (' PROCEDURE ' || v_progprefix || rec.full_name || ';'); + END IF; + END LOOP; + + IF samepackage_in + THEN + putline ('-- END: place in specification of source package'); + ELSE + putline ('END ' || v_pkg || ';'); + putline ('/'); + END IF; + + -- Spit out the package body into a separate file + IF output_type_in = c_file + THEN + cleanup; + setup ('pkb'); + ELSIF output_type_in = c_array + THEN + g_firstbodyrow := pkgarray.LAST + 1; + END IF; + + IF samepackage_in + THEN + putline ('-- START: place in body of source package'); + ELSE + putline ('CREATE OR REPLACE PACKAGE BODY ' || v_pkg); + putline ('IS'); + END IF; + + generate_setup (v_progprefix, schema_in, v_objpackage, v_objprogram); + generate_teardown (v_progprefix); + putline (' -- For each program to test...'); + + FOR rec IN prog_cur (v_objpackage, v_objprogram) + LOOP + l_grid.DELETE; + + IF grid_in.COUNT > 0 + THEN + /* + Go through the grid, pulling out only those test case rows + for the current program and then populate the test case procedure + accordingly. + */ + FOR indx IN grid_in.FIRST .. grid_in.LAST + LOOP + -- should switch to passing in records. + IF include_program (grid_in (indx).progname + , grid_in (indx).overload + , rec.object_name + , rec.overload + ) + THEN + -- NOK0205g - assign to sequential rows, not same indx value + l_grid (l_grid.COUNT + 1) := grid_in (indx); + END IF; + END LOOP; + END IF; + + IF l_grid.COUNT > 0 OR NOT NVL (only_if_in_grid_in, FALSE) +-- IF l_grid.COUNT > 0 + THEN + generate_ut_procedure (v_progprefix, rec, /*schema_in, + rec.package_name, + rec.object_name,*/ + l_grid); + END IF; + END LOOP; + + IF samepackage_in + THEN + putline ('-- END: place in body of source package'); + ELSE + putline ('END ' || v_pkg || ';'); + putline ('/'); + END IF; + + cleanup; + END testpkg; + + PROCEDURE clean_up_file_io ( + prog_in IN VARCHAR2 + , file_in IN OUT UTL_FILE.file_type + , err_in IN VARCHAR2 := NULL + ) + IS + BEGIN + UTL_FILE.fclose (file_in); + + IF err_in IS NOT NULL + THEN + utreport.pl (prog_in || ' File IO failure: ' || err_in); + END IF; + END; + + PROCEDURE testpkg ( + package_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , override_file_in IN VARCHAR2 := NULL + ) + IS + l_grid grid_tt; + BEGIN + -- pass an empty grid to the engine. + testpkg (package_in + , l_grid + , program_in + , samepackage_in + , prefix_in + , schema_in + , output_type_in + , dir_in + , only_if_in_grid_in => FALSE + , override_file_in => override_file_in + ); + END; + + FUNCTION valid_entry (string_in IN VARCHAR2) + RETURN BOOLEAN + IS + BEGIN + RETURN string_in IS NOT NULL AND string_in NOT LIKE '#%'; + END; + + PROCEDURE testpkg_from_file ( + package_in IN VARCHAR2 + , gridfile_loc_in IN VARCHAR2 + , gridfile_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , field_delim_in IN VARCHAR2 := '|' + , arg_delim_in IN VARCHAR2 := c_delim + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , only_if_in_grid_in IN BOOLEAN := FALSE + , override_file_in IN VARCHAR2 := NULL + ) + IS + c_progname VARCHAR2 (30) := 'testpkg_from_file'; + fid UTL_FILE.file_type; + l_line VARCHAR2 (1000); + l_eof BOOLEAN; + l_entries item_tt; + l_grid grid_tt; + l_indx PLS_INTEGER; + BEGIN + fid := UTL_FILE.fopen (gridfile_loc_in, gridfile_in, 'R'); + + LOOP + get_nextline (fid, l_line, l_eof); + l_line := LTRIM (l_line); + EXIT WHEN l_eof; + + IF valid_entry (l_line) + THEN + parse_string (l_line, l_entries, field_delim_in); + l_indx := NVL (l_grid.LAST, 0) + 1; + l_grid (l_indx).progname := UPPER (l_entries (1)); + l_grid (l_indx).overload := l_entries (2); + l_grid (l_indx).tcname := l_entries (3); + l_grid (l_indx).MESSAGE := l_entries (4); + l_grid (l_indx).arglist := l_entries (5); + l_grid (l_indx).return_value := l_entries (6); + l_grid (l_indx).assertion_type := UPPER (l_entries (7)); + END IF; + END LOOP; + + clean_up_file_io (c_progname, fid); + testpkg (package_in + , l_grid + , program_in + , samepackage_in + , prefix_in + , schema_in + , output_type_in + , dir_in + , arg_delim_in + , date_format_in + , only_if_in_grid_in + , override_file_in => override_file_in + ); + EXCEPTION + WHEN UTL_FILE.invalid_path + THEN + clean_up_file_io (c_progname, fid, 'invalid_path'); + WHEN UTL_FILE.invalid_mode + THEN + clean_up_file_io (c_progname, fid, 'invalid_mode'); + WHEN UTL_FILE.invalid_filehandle + THEN + clean_up_file_io (c_progname, fid, 'invalid_filehandle'); + WHEN UTL_FILE.invalid_operation + THEN + clean_up_file_io (c_progname, fid, 'invalid_operation'); + WHEN UTL_FILE.read_error + THEN + clean_up_file_io (c_progname, fid, 'read_error'); + WHEN UTL_FILE.write_error + THEN + clean_up_file_io (c_progname, fid, 'write_error'); + WHEN UTL_FILE.internal_error + THEN + clean_up_file_io (c_progname, fid, 'internal_error'); + WHEN OTHERS + THEN + clean_up_file_io (c_progname, fid, SQLERRM); + END testpkg_from_file; + + PROCEDURE testpkg_from_string ( + package_in IN VARCHAR2 + , grid_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , line_delim_in IN VARCHAR := CHR (10) + , field_delim_in IN VARCHAR2 := '|' + , arg_delim_in IN VARCHAR2 := c_delim + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , only_if_in_grid_in IN BOOLEAN := FALSE + , override_file_in IN VARCHAR2 := NULL + ) + IS + c_progname VARCHAR2 (30) := 'testpkg_from_string'; + l_line VARCHAR2 (1000); + l_lines item_tt; + l_entries item_tt; + l_grid grid_tt; + l_indx PLS_INTEGER; + BEGIN + IF grid_in IS NOT NULL + THEN + parse_string (grid_in, l_lines, line_delim_in); + + FOR l_linenum IN l_lines.FIRST .. l_lines.LAST + LOOP + IF valid_entry (l_lines (l_linenum)) + THEN + parse_string (l_lines (l_linenum), l_entries, field_delim_in); + l_indx := NVL (l_grid.LAST, 0) + 1; + l_grid (l_indx).progname := UPPER (l_entries (1)); + l_grid (l_indx).overload := l_entries (2); + l_grid (l_indx).tcname := l_entries (3); + l_grid (l_indx).MESSAGE := l_entries (4); + l_grid (l_indx).arglist := l_entries (5); + l_grid (l_indx).return_value := l_entries (6); + l_grid (l_indx).assertion_type := UPPER (l_entries (7)); + -- NOK0205: grab value for last entry as well. + l_grid (l_indx).null_ok := UPPER (l_entries (8)); + END IF; + END LOOP; + + testpkg (package_in + , l_grid + , program_in + , samepackage_in + , prefix_in + , schema_in + , output_type_in + , dir_in + , arg_delim_in + , date_format_in + , only_if_in_grid_in + , override_file_in => override_file_in + ); + END IF; + END; + + PROCEDURE testpkg_from_string_od ( + package_in IN VARCHAR2 + , grid_in IN VARCHAR2 + , dir_in IN VARCHAR2 := NULL + , override_file_in IN VARCHAR2 := NULL + ) + IS + BEGIN + testpkg_from_string (package_in + , grid_in + , output_type_in => c_file + , dir_in => dir_in + , only_if_in_grid_in => TRUE + , override_file_in => override_file_in + ); + END; + + PROCEDURE clear_grid ( + owner_in IN ut_grid.owner%TYPE + , package_in IN ut_grid.PACKAGE%TYPE + ) + IS + BEGIN + DELETE FROM ut_grid + WHERE ut_grid.owner = UPPER (owner_in) + AND ut_grid.PACKAGE = UPPER (package_in); + END; + + PROCEDURE add_to_grid ( + owner_in IN ut_grid.owner%TYPE + , package_in IN ut_grid.PACKAGE%TYPE + , progname_in IN ut_grid.progname%TYPE + , overload_in IN ut_grid.overload%TYPE + , tcname_in IN ut_grid.tcname%TYPE + , message_in IN ut_grid.MESSAGE%TYPE + , arglist_in IN ut_grid.arglist%TYPE + , return_value_in IN ut_grid.return_value%TYPE + , assertion_type_in IN ut_grid.assertion_type%TYPE + ) + IS + BEGIN + INSERT INTO ut_grid + (owner, PACKAGE, progname, overload + , tcname, MESSAGE, arglist, return_value + , assertion_type + ) + VALUES (owner_in, package_in, progname_in, overload_in + , tcname_in, message_in, arglist_in, return_value_in + , assertion_type_in + ); + END add_to_grid; + + -- 2.0.10.1 From Patrick Barel +/* START Patch72 607131 */ + PROCEDURE testpkg_from_table ( + package_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , override_file_in IN VARCHAR2 := NULL + ) + IS + CURSOR c_ut_grid (p_package VARCHAR2, p_owner VARCHAR2) + IS + SELECT ut_grid.owner, ut_grid.progname, ut_grid.overload + , ut_grid.tcname, ut_grid.MESSAGE, ut_grid.arglist + , ut_grid.return_value, ut_grid.assertion_type + FROM ut_grid + WHERE ut_grid.owner = UPPER (p_owner) + AND ut_grid.PACKAGE = UPPER (p_package) + ORDER BY ut_grid.progname; + + lv_grid utgen.grid_tt; + rc_ut_grid c_ut_grid%ROWTYPE; + lv_index NUMBER := -1; + BEGIN + IF c_ut_grid%ISOPEN + THEN + CLOSE c_ut_grid; + END IF; -- c_ut_grid%IsOpen + + OPEN c_ut_grid (p_package => package_in + , p_owner => NVL (schema_in, USER) + ); + + FETCH c_ut_grid + INTO rc_ut_grid; + + WHILE c_ut_grid%FOUND + LOOP + lv_index := lv_index + 1; + lv_grid (lv_index).progname := rc_ut_grid.progname; + lv_grid (lv_index).overload := rc_ut_grid.overload; + lv_grid (lv_index).tcname := rc_ut_grid.tcname; + lv_grid (lv_index).MESSAGE := rc_ut_grid.MESSAGE; + lv_grid (lv_index).arglist := rc_ut_grid.arglist; + lv_grid (lv_index).return_value := rc_ut_grid.return_value; + lv_grid (lv_index).assertion_type := rc_ut_grid.assertion_type; + + FETCH c_ut_grid + INTO rc_ut_grid; + END LOOP; + + IF c_ut_grid%ISOPEN + THEN + CLOSE c_ut_grid; + END IF; -- c_ut_grid%IsOpen + + IF lv_index > -1 + THEN +/* utgen.testpkg ( + package_in => package_in, + grid_in => lv_grid, + date_format_in => date_format_in + ); +*/ +-- We have access to all parameters (either sent in or default). Why not use them? + utgen.testpkg + (package_in => package_in + /* SEF fix 10/9/2 lv_package*/ + , grid_in => lv_grid + , program_in => program_in + , samepackage_in => samepackage_in + , prefix_in => prefix_in + , schema_in => schema_in + , output_type_in => output_type_in + , dir_in => dir_in + , date_format_in => date_format_in + , override_file_in => override_file_in + ); + END IF; -- lv_index > -1 + END; + +/* END Patch72 607131 */ + FUNCTION pkgstring + RETURN VARCHAR2 + IS + BEGIN + RETURN g_pkgstring; + END; + + /* Returns data in order retrieved (ie, Nth row). */ + FUNCTION nthrow (nth IN PLS_INTEGER, direction IN SIGNTYPE := 1) + RETURN codeline_t + IS + v_nth PLS_INTEGER := 1; + v_row PLS_INTEGER; + retval codeline_t; + BEGIN + IF direction = 1 + THEN + v_row := pkgarray.FIRST; + ELSE + v_row := pkgarray.LAST; + END IF; + + /* Since no prep work was done, do a scan through table. */ + LOOP + EXIT WHEN v_row IS NULL; + + IF v_nth = nth + THEN + retval := pkgarray (v_row); + EXIT; + ELSE + v_nth := v_nth + 1; + + IF direction = 1 + THEN + v_row := pkgarray.NEXT (v_row); + ELSE + v_row := pkgarray.PRIOR (v_row); + END IF; + END IF; + END LOOP; + + RETURN retval; + END; + + FUNCTION firstrow + RETURN PLS_INTEGER + IS + BEGIN + RETURN pkgarray.FIRST; + END; + + FUNCTION lastrow + RETURN PLS_INTEGER + IS + BEGIN + RETURN pkgarray.LAST; + END; + + FUNCTION atfirstrow + RETURN BOOLEAN + IS + BEGIN + RETURN g_currrow = pkgarray.FIRST; + END; + + FUNCTION atlastrow + RETURN BOOLEAN + IS + BEGIN + RETURN g_currrow = pkgarray.LAST; + END; + + FUNCTION firstbodyrow + RETURN PLS_INTEGER + IS + BEGIN + RETURN g_firstbodyrow; + END; + + FUNCTION countrows + RETURN PLS_INTEGER + IS + BEGIN + RETURN pkgarray.COUNT; + END; + + PROCEDURE init_currrow + IS + BEGIN + IF g_currrow IS NULL + THEN + g_currrow := pkgarray.FIRST; + END IF; + END; + + PROCEDURE setrow (nth IN PLS_INTEGER) + IS + BEGIN + g_currrow := nth; + END; + + FUNCTION getrow + RETURN codeline_t + IS + BEGIN + init_currrow; + RETURN pkgarray (g_currrow); + END; + + PROCEDURE nextrow + IS + BEGIN + init_currrow; + g_currrow := pkgarray.NEXT (g_currrow); + END; + + PROCEDURE prevrow + IS + BEGIN + init_currrow; + g_currrow := pkgarray.PRIOR (g_currrow); + END; + + PROCEDURE showrows ( + startrow IN PLS_INTEGER := NULL + , endrow IN PLS_INTEGER := NULL + ) + IS + v_start PLS_INTEGER := NVL (startrow, 1); + v_end PLS_INTEGER := NVL (endrow, countrows); + BEGIN + FOR indx IN 1 .. countrows + LOOP + setrow (indx); + utreport.pl (getrow); + END LOOP; + END; + + -- TO COMPLETE: apply same output type flexibility + -- from testpkg to receq_compare. + PROCEDURE putline (str IN VARCHAR2) + IS + BEGIN + DBMS_OUTPUT.put_line (str); + END; + +-- 2.0.8 Implementation provided by Dan Spencer! + PROCEDURE receq_package ( + table_in IN VARCHAR2 + , pkg_in IN VARCHAR2 := NULL + , owner_in IN VARCHAR2 := NULL + ) + IS + v_pkg VARCHAR2 (30) + := NVL (pkg_in, SUBSTR ('receq_' || table_in, 1, 30)); + v_owner VARCHAR2 (30) := UPPER (NVL (owner_in, USER)); + v_table VARCHAR2 (30) := UPPER (table_in); + BEGIN + putline ('CREATE OR REPLACE PACKAGE ' || v_pkg || ' IS'); + + FOR tabs_rec IN (SELECT * + FROM all_tables + WHERE owner = v_owner AND table_name = v_table) + LOOP + putline ( 'FUNCTION eq(a ' + || tabs_rec.table_name + || '%ROWTYPE , b ' + || tabs_rec.table_name + || '%ROWTYPE ) RETURN BOOLEAN; ' + ); + END LOOP; + + putline (' END ' || v_pkg || ';'); + putline ('/'); + putline (' '); + putline ('CREATE OR REPLACE PACKAGE BODY ' || v_pkg || ' IS'); + + FOR tabs_rec IN (SELECT * + FROM all_tables + WHERE owner = v_owner AND table_name = v_table) + LOOP + putline ( 'FUNCTION eq( a ' + || tabs_rec.table_name + || '%ROWTYPE , ' + || 'b ' + || tabs_rec.table_name + || '%ROWTYPE ) ' + || 'RETURN BOOLEAN ' + ); + putline ('IS BEGIN '); + putline (' RETURN ('); + + FOR user_tab_columns_rec IN (SELECT * + FROM user_tab_columns + WHERE table_name = + tabs_rec.table_name + ORDER BY column_id) + LOOP + IF user_tab_columns_rec.column_id > 1 + THEN + putline (' AND '); + END IF; + + IF user_tab_columns_rec.data_type = 'CLOB' + THEN + putline ( '( ( a.' + || user_tab_columns_rec.column_name + || ' IS NULL AND b.' + || user_tab_columns_rec.column_name + || ' IS NULL ) OR DBMS_LOB.COMPARE( a.' + || user_tab_columns_rec.column_name + || ' , b.' + || user_tab_columns_rec.column_name + || ') = 0 )' + ); + ELSE + putline ( '( ( a.' + || user_tab_columns_rec.column_name + || ' IS NULL AND b.' + || user_tab_columns_rec.column_name + || ' IS NULL ) OR a.' + || user_tab_columns_rec.column_name + || ' = b.' + || user_tab_columns_rec.column_name + || ')' + ); + END IF; + END LOOP; + + putline ('); END eq;'); + END LOOP; + + putline (' END ' || v_pkg || ';'); + putline ('/'); + putline (' '); + END; +END; +/ diff --git a/source/ut_gen.pks b/source/ut_gen.pks new file mode 100644 index 000000000..9fd4a2fde --- /dev/null +++ b/source/ut_gen.pks @@ -0,0 +1,226 @@ +CREATE OR REPLACE PACKAGE utgen +&start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/11/23 14:56:47 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_screen CONSTANT PLS_INTEGER := 1; + c_string CONSTANT PLS_INTEGER := 2; + c_file CONSTANT PLS_INTEGER := 3; + c_array CONSTANT PLS_INTEGER := 4; + c_delim CONSTANT CHAR (1) := ';'; + c_comment CONSTANT CHAR (1) := '#'; + c_asis CONSTANT CHAR (1) := '!'; + + &start_ge_8_1 SUBTYPE codeline_t IS VARCHAR2(200); &end_ge_8_1 + + &start_lt_8_1 + v_codeline VARCHAR2 (200); + SUBTYPE codeline_t IS v_codeline%TYPE; + &end_lt_8_1 + + -- Each line in the grid represents a test case + -- + + TYPE grid_rt IS RECORD ( + progname VARCHAR2 (100) + , overload PLS_INTEGER + , tcname VARCHAR2 (100) + , MESSAGE VARCHAR2 (2000) + , arglist VARCHAR2 (2000) + , return_value VARCHAR2 (2000) + , assertion_type VARCHAR2 (100) + , null_ok VARCHAR2 (1) -- NOK0205: Y or N + ); + + TYPE grid_tt IS TABLE OF grid_rt + INDEX BY BINARY_INTEGER; + + PROCEDURE testpkg ( + package_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , override_file_in IN VARCHAR2 := NULL + ); + + PROCEDURE testpkg ( + package_in IN VARCHAR2 + , grid_in IN grid_tt + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , delim_in IN VARCHAR2 := c_delim + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , only_if_in_grid_in IN BOOLEAN := FALSE + , override_file_in IN VARCHAR2 := NULL + ); + + PROCEDURE testpkg_from_file ( + package_in IN VARCHAR2 + , gridfile_loc_in IN VARCHAR2 + , gridfile_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , field_delim_in IN VARCHAR2 := '|' + , arg_delim_in IN VARCHAR2 := c_delim + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , only_if_in_grid_in IN BOOLEAN := FALSE + , override_file_in IN VARCHAR2 := NULL + ); + + PROCEDURE testpkg_from_string ( + package_in IN VARCHAR2 + , grid_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , line_delim_in IN VARCHAR := CHR (10) + , field_delim_in IN VARCHAR2 := '|' + , arg_delim_in IN VARCHAR2 := c_delim + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , only_if_in_grid_in IN BOOLEAN := FALSE + , override_file_in IN VARCHAR2 := NULL + ); + + PROCEDURE testpkg_from_string_od ( + package_in IN VARCHAR2 + , grid_in IN VARCHAR2 + , dir_in IN VARCHAR2 := NULL + , override_file_in IN VARCHAR2 := NULL + ); + + -- Retrieve single string with generated package. + FUNCTION pkgstring + RETURN VARCHAR2; + + -- Retrieve individual lines of code in generated package + + FUNCTION nthrow (nth IN PLS_INTEGER, direction IN SIGNTYPE := 1) + RETURN codeline_t; + + FUNCTION countrows + RETURN PLS_INTEGER; + + FUNCTION firstrow + RETURN PLS_INTEGER; + + FUNCTION firstbodyrow + RETURN PLS_INTEGER; + + FUNCTION atfirstrow + RETURN BOOLEAN; + + FUNCTION lastrow + RETURN PLS_INTEGER; + + FUNCTION atlastrow + RETURN BOOLEAN; + + PROCEDURE setrow (nth IN PLS_INTEGER); + + FUNCTION getrow + RETURN codeline_t; + + PROCEDURE nextrow; + + PROCEDURE prevrow; + + PROCEDURE showrows ( + startrow IN PLS_INTEGER := NULL + , endrow IN PLS_INTEGER := NULL + ); + + FUNCTION isfunction ( + schema_in IN VARCHAR2 + , package_in IN VARCHAR2 + , program_in IN VARCHAR2 + , overload_in IN PLS_INTEGER := NULL + ) + RETURN BOOLEAN; + + -- 2.0.10.1 From Patrick Barel + PROCEDURE add_to_grid ( + owner_in IN ut_grid.owner%TYPE + , package_in IN ut_grid.PACKAGE%TYPE + , progname_in IN ut_grid.progname%TYPE + , overload_in IN ut_grid.overload%TYPE + , tcname_in IN ut_grid.tcname%TYPE + , message_in IN ut_grid.MESSAGE%TYPE + , arglist_in IN ut_grid.arglist%TYPE + , return_value_in IN ut_grid.return_value%TYPE + , assertion_type_in IN ut_grid.assertion_type%TYPE + ); + + PROCEDURE clear_grid ( + owner_in IN ut_grid.owner%TYPE + , package_in IN ut_grid.PACKAGE%TYPE + ); + + /* START Patch72 607131 */ + PROCEDURE testpkg_from_table ( + package_in IN VARCHAR2 + , program_in IN VARCHAR2 := '%' + , samepackage_in IN BOOLEAN := FALSE + , prefix_in IN VARCHAR2 := NULL + , schema_in IN VARCHAR2 := NULL + , output_type_in IN PLS_INTEGER := c_screen + , dir_in IN VARCHAR2 := NULL + , date_format_in IN VARCHAR2 := 'MM/DD/YYYY' + , override_file_in IN VARCHAR2 := NULL + ); +/* END Patch72 607131 */ + +/* -- 2.0.8 Implementation provided by Dan Spencer! + PROCEDURE receq_package ( + table_in IN VARCHAR2, + pkg_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL + ); +*/ +END; +/ diff --git a/source/ut_grid.tab b/source/ut_grid.tab new file mode 100644 index 000000000..fa44ee2ed --- /dev/null +++ b/source/ut_grid.tab @@ -0,0 +1,39 @@ +-- 09/2002 PBA initial version + +-- Patch72 607131 +-- Create table +create table UT_GRID +( + PACKAGE VARCHAR2(100), + PROGNAME VARCHAR2(100), + OVERLOAD NUMBER, + TCNAME VARCHAR2(100), + MESSAGE VARCHAR2(2000) not null, + ARGLIST VARCHAR2(2000), + RETURN_VALUE VARCHAR2(2000), + ASSERTION_TYPE VARCHAR2(100) +); +-- Add comments to the columns +comment on column UT_GRID.PACKAGE + is 'This is the name of the package to be tested.'; +comment on column UT_GRID.PROGNAME + is 'This is the name of the subprogram to be tested.'; +comment on column UT_GRID.OVERLOAD + is 'This is the version of the subprogram where overloaded versions exist. (You may have to look in the data dictionary to work this out).'; +comment on column UT_GRID.TCNAME + is 'The name of the test case.'; +comment on column UT_GRID.MESSAGE + is 'The message to be used in the assertion code.'; +comment on column UT_GRID.ARGLIST + is 'The list of arguments to be passed to the subprogram.'; +comment on column UT_GRID.RETURN_VALUE + is 'The return value to be checked against.'; +comment on column UT_GRID.ASSERTION_TYPE + is 'The type of assertion to be used. Currently this is ignored unless it contains ''EQ'' of ''ISNULL''.'; + +-- Create/Recreate primary, unique and foreign key constraints +alter table UT_GRID + add constraint UK_MESSAGE unique (MESSAGE); + +REM 2.1 +alter table ut_grid add owner varchar2(30); diff --git a/source/ut_htmlreporter.pkb b/source/ut_htmlreporter.pkb new file mode 100644 index 000000000..7f62071bb --- /dev/null +++ b/source/ut_htmlreporter.pkb @@ -0,0 +1,168 @@ +CREATE OR REPLACE PACKAGE BODY uthtmlreporter +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.1 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + + +************************************************************************/ + + + PROCEDURE open + IS + + file_dir UT_CONFIG.filedir%TYPE; + no_dir EXCEPTION; + + BEGIN + + -- Get the output file directory + file_dir := Utconfig.filedir (); + -- check if NULL + IF file_dir IS NULL THEN + Utoutputreporter.pl('UTL_FILE error: No directory specified for file output'); + Utfilereporter.CLOSE(bool_abort => TRUE); + RAISE no_dir; + END IF; + + utfilereporter.open_file (file_dir, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') || '.html', 'W'); + + pl('Test Results'); + + END; + + PROCEDURE close + IS + BEGIN + pl(''); + utfilereporter.close_file; + END; + + PROCEDURE pl (str VARCHAR2) + IS + BEGIN + utfilereporter.pl(str); + END; + + PROCEDURE pl_success + IS + BEGIN + pl('Success'); + END; + + PROCEDURE pl_failure + IS + BEGIN + pl('FAILURE'); + END; + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + pl('

'|| utplsql.currpkg || ': '); + IF utresult.success (run_id) THEN + pl_success; + ELSE + pl_failure; + END IF; + + pl('


Results:'); + pl(''); + + END; + + PROCEDURE show_failure + IS + BEGIN + pl(''); + END; + + PROCEDURE show_result + IS + BEGIN + pl (''); + END; + + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + pl('
StatusDescription
'); + pl_failure; + pl('' || utreport.outcome.description || '
'); + + IF utreport.outcome.status = 'SUCCESS' THEN + pl_success; + ELSE + pl_failure; + END IF; + + pl('' || utreport.outcome.description || '
'); + END; + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + pl('Errors:
'); + pl(''); + END; + + PROCEDURE show_error + IS + BEGIN + utreport.pl (''); + END; + + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + pl('
Error LevelError CodeDescription
' || utreport.error.errlevel || + '' || utreport.error.errcode || + '' || utreport.error.errtext || '
'); + END; + + + PROCEDURE before_suite_results( + suite_id ut_suite.id%TYPE + ) + IS + PROCEDURE showsuitebanner( + suite_id ut_suite.id%TYPE + ) + IS + BEGIN + pl('

SUITE "'|| utsuite.name_from_id(id_in => suite_id) || '": '); + IF utresult.suite_success(suite_id => suite_id) THEN + pl_success; + ELSE + pl_failure; + END IF; + pl('

'); + END showsuitebanner; + BEGIN + + showsuitebanner(suite_id => suite_id); + END before_suite_results; +END uthtmlreporter; +/ diff --git a/source/ut_htmlreporter.pks b/source/ut_htmlreporter.pks new file mode 100644 index 000000000..6fea03ad4 --- /dev/null +++ b/source/ut_htmlreporter.pks @@ -0,0 +1,47 @@ +CREATE OR REPLACE PACKAGE uthtmlreporter +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log + +************************************************************************/ + + PROCEDURE open; + PROCEDURE pl (str IN VARCHAR2); + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE); + PROCEDURE show_failure; + PROCEDURE show_result; + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE); + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE); + PROCEDURE show_error; + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE); + + PROCEDURE close; + PROCEDURE before_suite_results( + suite_id ut_suite.id%TYPE + ); + +END uthtmlreporter; +/ diff --git a/source/ut_i_do.sql b/source/ut_i_do.sql new file mode 100644 index 000000000..a7ebd5cf3 --- /dev/null +++ b/source/ut_i_do.sql @@ -0,0 +1,75 @@ +CLEAR SCREEN +SET TERMOUT OFF +SET ECHO OFF +SET VERIFY OFF +SET FEEDBACK OFF +SET TTITLE OFF +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED +SET DEFINE ON + +---------------------------------------------------- +-- ou installator +-- +-- parameter 1 values: +-- +-- install - UT full installation +-- recompile - Recompile UT code base +-- synonyms - Create public synonyms for UT +-- uninstall - Deinstall UT +---------------------------------------------------- + +DEFINE line1='-------------------------------------------------------------' +DEFINE line2='=============================================================' +DEFINE finished='. Finished' +DEFINE UT='utPLSQL' + +COLUMN col NOPRINT NEW_VALUE ut_owner +select USER col from dual; + + +COLUMN col NOPRINT NEW_VALUE next_script +select decode(LOWER('&1'),'install','ut_i_install', + 'recompile','ut_i_recompile', + 'compile','ut_i_recompile', + 'synonyms','ut_i_synonyms', + 'synonym','ut_i_synonyms', + 'uninstall','ut_i_uninstall', + 'deinstall','ut_i_uninstall', + 'ERROR') col from dual; + +COLUMN col NOPRINT NEW_VALUE txt_prompt +select decode('&next_script','ut_i_install','I N S T A L L A T I O N', + 'ut_i_recompile','R E C O M P I L A T I O N', + 'ut_i_synonyms','S Y N O N Y M S', + 'ut_i_uninstall','D E I N S T A L L A T I O N', + 'ERROR') col from dual; +------------------------------------------------------ + +SET TERMOUT ON + +PROMPT &line2 +PROMPT GNU General Public License for utPLSQL +PROMPT +PROMPT Copyright (C) 2000-2003 +PROMPT Steven Feuerstein and the utPLSQL Project +PROMPT (steven@stevenfeuerstein.com) +PROMPT +PROMPT This program is free software; you can redistribute it and/or modify +PROMPT it under the terms of the GNU General Public License as published by +PROMPT the Free Software Foundation; either version 2 of the License, or +PROMPT (at your option) any later version. +PROMPT +PROMPT This program is distributed in the hope that it will be useful, +PROMPT but WITHOUT ANY WARRANTY; without even the implied warranty of +PROMPT MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +PROMPT GNU General Public License for more details. +PROMPT +PROMPT You should have received a copy of the GNU General Public License +PROMPT along with this program (see license.txt); if not, write to the Free Software +PROMPT Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +PROMPT &line2 +PROMPT + +PROMPT [ &txt_prompt ] +@@ut_i_preprocess +@@&next_script diff --git a/source/ut_i_grants.sql b/source/ut_i_grants.sql new file mode 100644 index 000000000..296c7e9dc --- /dev/null +++ b/source/ut_i_grants.sql @@ -0,0 +1,40 @@ +SET TERMOUT OFF +SET VERIFY OFF +SET PAGESIZE 0 +SET FEEDBACK OFF +SET TRIMSPOOL ON + +SET DEFINE ON +TTITLE OFF +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED + +DEFINE uscript='ut_i_spool_temp.sql' + +SET TERMOUT ON +PROMPT &line1 +PROMPT GRANTS FOR &UT OBJECTS +PROMPT &line1 +SET TERMOUT OFF + +SPOOL &uscript + +select 'PROMPT Granting all on every object...' from dual; +select 'grant all on '||object_name||' to public;' +from all_objects +where owner='&ut_owner' and object_name like 'UT%' and + object_type in('TABLE','SEQUENCE','PACKAGE', 'VIEW'); +select 'PROMPT &finished' from dual; + +select 'PROMPT Granting execute on packages...' from dual; +select 'grant execute on '||object_name||' to public;' +from all_objects +where owner='&ut_owner' and object_name like 'UT%' and + object_type ='PACKAGE'; + +select 'PROMPT &finished' from dual; + +SPOOL OFF +SET TERMOUT ON + +@@&uscript + diff --git a/source/ut_i_install.sql b/source/ut_i_install.sql new file mode 100644 index 000000000..94830dd7b --- /dev/null +++ b/source/ut_i_install.sql @@ -0,0 +1,68 @@ +SET TERMOUT OFF +SET ECHO OFF +SET VERIFY OFF +SET FEEDBACK OFF +SET TTITLE OFF + +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED +SET DEFINE ON +SPOOL ut_i_install.log + +----------------------------------------------------TABLES +SET TERMOUT ON +PROMPT &line1 +PROMPT CREATING &UT TABLES +PROMPT &line1 + +DEFINE prompt_text='Creating &UT tables ' + +@@ut_i_tables + +----------------------------------------------------SEQUENCES +SET TERMOUT ON +PROMPT &line1 +PROMPT CREATING &UT SEQUENCES +PROMPT &line1 + +DEFINE prompt_text='Creating &UT sequence ' + +@@ut_i_sequences + +----------------------------------------------------VIEWS +SET TERMOUT ON +PROMPT &line1 +PROMPT CREATING &UT VIEWS +PROMPT &line1 + +DEFINE prompt_text='Creating &UT view ' + +@@ut_i_views + +----------------------------------------------------PACKAGE HEADERS +SET TERMOUT ON +PROMPT &line1 +PROMPT CREATING &UT PACKAGE HEADERS +PROMPT &line1 + +DEFINE prompt_text='Creating &UT package specification ' + +@@ut_i_packages + +----------------------------------------------------PACKAGE BODIES +SET TERMOUT ON +PROMPT &line1 +PROMPT CREATING &UT PACKAGE BODIES +PROMPT &line1 + +DEFINE prompt_text='Creating &UT package body ' + +@@ut_i_packages_b + +SET TERMOUT OFF +SPOOL OFF + +----------------------------------------------------GENERIC SCRIPTS + +@@ut_i_synonyms + +@@ut_i_grants diff --git a/source/ut_i_packages.sql b/source/ut_i_packages.sql new file mode 100644 index 000000000..697ff74ed --- /dev/null +++ b/source/ut_i_packages.sql @@ -0,0 +1,38 @@ +@@ut_i_run ut_config.pks +@@ut_i_run ut_plsql.pks +@@ut_i_run ut_report.pks +@@ut_i_run ut_outputreporter.pks +@@ut_i_run ut_filereporter.pks +@@ut_i_run ut_htmlreporter.pks +@@ut_i_run ut_result.pks +@@ut_i_run ut_plsql_util.pks +@@ut_i_run ut_assert2.pks +@@ut_i_run ut_assert.pks +@@ut_i_run ut_plsql2.pks +@@ut_i_run ut_result2.pks +@@ut_i_run ut_utp.pks +@@ut_i_run ut_testprep.pks +@@ut_i_run ut_unittest.pks +@@ut_i_run ut_testcase.pks +@@ut_i_run ut_outcome.pks +@@ut_i_run ut_suiteutp.pks +@@ut_i_run ut_suite.pks +@@ut_i_run ut_package.pks +@@ut_i_run ut_test.pks +@@ut_i_run ut_gen.pks +@@ut_i_run ut_rsuite.pks +@@ut_i_run ut_rutp.pks +@@ut_i_run ut_runittest.pks +@@ut_i_run ut_rtestcase.pks +@@ut_i_run ut_routcome.pks +@@ut_i_run ut_rerror.pks +@@ut_i_run ut_receq.pks +@@ut_i_run ut_output.pks +@@ut_i_run ut_filereporter.pks +@@ut_i_run ut_htmlreporter.pks +@@ut_i_run ut_outputreporter.pks +@@ut_i_run ut_report.pks +@@ut_i_run ut_pipe.pks + +@@ut_i_run ut_utoutput.pks +@@ut_i_run ut_utreport.pks diff --git a/source/ut_i_packages_b.sql b/source/ut_i_packages_b.sql new file mode 100644 index 000000000..86fb36d8e --- /dev/null +++ b/source/ut_i_packages_b.sql @@ -0,0 +1,38 @@ +@@ut_i_run ut_config.pkb +@@ut_i_run ut_plsql.pkb +@@ut_i_run ut_report.pkb +@@ut_i_run ut_outputreporter.pkb +@@ut_i_run ut_filereporter.pkb +@@ut_i_run ut_htmlreporter.pkb +@@ut_i_run ut_result.pkb +@@ut_i_run ut_plsql_util.pkb +@@ut_i_run ut_assert2.pkb +@@ut_i_run ut_assert.pkb +@@ut_i_run ut_plsql2.pkb +@@ut_i_run ut_result2.pkb +@@ut_i_run ut_utp.pkb +@@ut_i_run ut_testprep.pkb +@@ut_i_run ut_unittest.pkb +@@ut_i_run ut_testcase.pkb +@@ut_i_run ut_outcome.pkb +@@ut_i_run ut_suiteutp.pkb +@@ut_i_run ut_suite.pkb +@@ut_i_run ut_package.pkb +@@ut_i_run ut_test.pkb +@@ut_i_run ut_gen.pkb +@@ut_i_run ut_rsuite.pkb +@@ut_i_run ut_rutp.pkb +@@ut_i_run ut_runittest.pkb +@@ut_i_run ut_rtestcase.pkb +@@ut_i_run ut_routcome.pkb +@@ut_i_run ut_rerror.pkb +@@ut_i_run ut_receq.pkb +@@ut_i_run ut_output.pkb +@@ut_i_run ut_filereporter.pkb +@@ut_i_run ut_htmlreporter.pkb +@@ut_i_run ut_outputreporter.pkb +@@ut_i_run ut_report.pkb +@@ut_i_run ut_pipe.pkb + +@@ut_i_run ut_utoutput.pkb +@@ut_i_run ut_utreport.pkb diff --git a/source/ut_i_preprocess.sql b/source/ut_i_preprocess.sql new file mode 100644 index 000000000..f58778994 --- /dev/null +++ b/source/ut_i_preprocess.sql @@ -0,0 +1,63 @@ +COLUMN major NOPRINT NEW_VALUE major_v +COLUMN minor NOPRINT NEW_VALUE minor_v + +--Get the major and minor versions + +select major, SUBSTR(minor_version,1,instr(minor_version, '.')-1) minor +from +( + select major, substr(version, length(major)+2) minor_version + from + ( + SELECT SUBSTR(version,1,instr(version, '.')-1) major, version + FROM product_component_version p + WHERE UPPER(PRODUCT) LIKE 'ORACLE%' + OR UPPER(PRODUCT) LIKE 'PERSONAL ORACLE%' + ) +); + +--Flags for 9.x code + +COLUMN col NOPRINT NEW_VALUE start_ge_9 + +SELECT decode(greatest(8, &major_v), 8, '/* < v9 ', '/* >= v9 */') col +FROM dual; + +COLUMN col NOPRINT NEW_VALUE end_ge_9 + +SELECT decode(greatest(8, &major_v), 8, '< v9 */', '/* >= v9 */') col +FROM dual; + +COLUMN col NOPRINT NEW_VALUE start_lt_9 + +SELECT decode(greatest(8, &major_v), 8, '/* < v9 */', '/* >= v9 ') col +FROM dual; + +COLUMN col NOPRINT NEW_VALUE end_lt_9 + +SELECT decode(greatest(8, &major_v), 8, '/* < v9 */', ' >= v9 */') col +FROM dual; + +--Flags for 8.1 code + +COLUMN col NOPRINT NEW_VALUE start_ge_8_1 + +SELECT decode(greatest(8, &major_v+(&minor_v/10)), 8, '/* < v8.1 ', '/* >= v8.1 */') col +FROM dual; + +COLUMN col NOPRINT NEW_VALUE end_ge_8_1 + +SELECT decode(greatest(8, &major_v+(&minor_v/10)), 8, ' < v8.1 */', '/* >= v8.1 */') col +FROM dual; + +COLUMN col NOPRINT NEW_VALUE start_lt_8_1 + +SELECT decode(greatest(8, &major_v+(&minor_v/10)), 8, '/* < v8.1 */', '/* >= v8.1 ') col +FROM dual; + +COLUMN col NOPRINT NEW_VALUE end_lt_8_1 + +SELECT decode(greatest(8, &major_v+(&minor_v/10)), 8, '/* < v8.1 */', ' >= v8.1 */') col +FROM dual; + + diff --git a/source/ut_i_recompile.sql b/source/ut_i_recompile.sql new file mode 100644 index 000000000..2a8d63b19 --- /dev/null +++ b/source/ut_i_recompile.sql @@ -0,0 +1,31 @@ +SET TERMOUT OFF +SET VERIFY OFF +SET PAGESIZE 0 +SET FEEDBACK OFF +SET TRIMSPOOL ON + +SET DEFINE ON +TTITLE OFF +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED + +DEFINE uscript='ut_i_spool_temp.sql' + +SET TERMOUT ON +PROMPT &line1 +PROMPT RECOMPILING &UT OBJECTS +PROMPT &line1 +SET TERMOUT OFF + +SPOOL &uscript +select 'PROMPT Recompiling...' from dual; +select 'alter package '||object_name||' compile package;' +from all_objects +where owner='&ut_owner' and object_name like 'UT%' and + object_type=('PACKAGE') +order by created; +select 'PROMPT &finished' from dual; +SPOOL OFF +SET TERMOUT ON + +@@&uscript + diff --git a/source/ut_i_run.sql b/source/ut_i_run.sql new file mode 100644 index 000000000..b64c5696a --- /dev/null +++ b/source/ut_i_run.sql @@ -0,0 +1,12 @@ +SET TERMOUT OFF + +COLUMN col NOPRINT NEW_VALUE run_object +SELECT substr('&1',1,instr('&1','.')-1) col FROM dual; + +SET TERMOUT ON + +PROMPT &prompt_text &run_object +@@&1 +REM PROMPT &line1 + +SET TERMOUT OFF diff --git a/source/ut_i_sequences.sql b/source/ut_i_sequences.sql new file mode 100644 index 000000000..e8bafc906 --- /dev/null +++ b/source/ut_i_sequences.sql @@ -0,0 +1,12 @@ +@@ut_i_run ut_suite_seq.seq +@@ut_i_run ut_package_seq.seq +@@ut_i_run ut_utp_seq.seq +@@ut_i_run ut_test_seq.seq +@@ut_i_run ut_unittest_seq.seq +@@ut_i_run ut_testcase_seq.seq +@@ut_i_run ut_plsql_runnum_seq.seq +@@ut_i_run ut_assertion_seq.seq +@@ut_i_run ut_receq_seq.seq +@@ut_i_run ut_refcursor_results_seq.seq + + diff --git a/source/ut_i_synonyms.sql b/source/ut_i_synonyms.sql new file mode 100644 index 000000000..b6fb906c5 --- /dev/null +++ b/source/ut_i_synonyms.sql @@ -0,0 +1,37 @@ +SET TERMOUT OFF +SET VERIFY OFF +SET PAGESIZE 0 +SET FEEDBACK OFF +SET TRIMSPOOL ON + +spool off +SET DEFINE ON +TTITLE OFF +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED + +DEFINE uscript='ut_i_spool_temp.sql' + +SET TERMOUT ON +PROMPT &line1 +PROMPT CREATING SYNONYMS FOR &UT OBJECTS +PROMPT &line1 +SET TERMOUT OFF + +COLUMN col NOPRINT NEW_VALUE fine +select count(privilege) col from session_privs where privilege='CREATE PUBLIC SYNONYM'; + +SPOOL &uscript +select decode(&fine,0,'','PROMPT Creating synonyms ...') from dual; +select decode(&fine,0,'','create public synonym '||object_name||' for '||object_name||';') +from all_objects +where owner='&ut_owner' +and object_name like 'UT%' +and object_name not in ('UT_UTOUTPUT', 'UT_UTREPORT') +and object_type IN ('PACKAGE', 'TABLE', 'VIEW', 'SEQUENCE'); +select decode(&fine,0,'','PROMPT &finished') from dual; + +select decode(&fine,1,'','PROMPT Skipped - user has no rights to create public synonyms') from dual; +SPOOL OFF +SET TERMOUT ON + +@@&uscript diff --git a/source/ut_i_tables.sql b/source/ut_i_tables.sql new file mode 100644 index 000000000..f79a804af --- /dev/null +++ b/source/ut_i_tables.sql @@ -0,0 +1,23 @@ +@@ut_i_run ut_config.tab +@@ut_i_run ut_assertion.tab +@@ut_i_run ut_suite.tab +@@ut_i_run ut_utp.tab +@@ut_i_run ut_package.tab +@@ut_i_run ut_test.tab +@@ut_i_run ut_unittest.tab +@@ut_i_run ut_testcase.tab +@@ut_i_run ut_testprep.tab +@@ut_i_run ut_outcome.tab +@@ut_i_run ut_eq.tab +@@ut_i_run ut_suite_utp.tab +@@ut_i_run ut_argument.tab +@@ut_i_run utr_suite.tab +@@ut_i_run utr_utp.tab +@@ut_i_run utr_unittest.tab +@@ut_i_run utr_testcase.tab +@@ut_i_run utr_outcome.tab +@@ut_i_run utr_error.tab +@@ut_i_run ut_deterministic.tab +@@ut_i_run ut_deterministic_arg.tab +@@ut_i_run ut_receq.tab +@@ut_i_run ut_grid.tab diff --git a/source/ut_i_uninstall.sql b/source/ut_i_uninstall.sql new file mode 100644 index 000000000..a3ac5bb00 --- /dev/null +++ b/source/ut_i_uninstall.sql @@ -0,0 +1,179 @@ +SET TERMOUT OFF +SET VERIFY OFF +SET PAGESIZE 0 +SET FEEDBACK OFF +SET TRIMSPOOL ON + +SET DEFINE ON +TTITLE OFF +SET SERVEROUTPUT ON SIZE 1000000 FORMAT WRAPPED + +SET TERMOUT ON +PROMPT &line1 +PROMPT DROPPING &UT PACKAGES +PROMPT &line1 + +drop package UTASSERT2; +drop package UTASSERT; +drop package UTCONFIG; +drop package UTGEN; +drop package UTOUTCOME; +drop package UTOUTPUT; +drop package UTPACKAGE; +drop package UTPLSQL2; +drop package UTPLSQL; +drop package UTPLSQL_UTIL; +drop package UTRECEQ; +drop package UTRERROR; +drop package UTRESULT2; +drop package UTRESULT; +drop package UTROUTCOME; +drop package UTRSUITE; +drop package UTRTESTCASE; +drop package UTRUNITTEST; +drop package UTRUTP; +drop package UTSUITE; +drop package UTSUITEUTP; +drop package UTTEST; +drop package UTTESTCASE; +drop package UTTESTPREP; +drop package UTUNITTEST; +drop package UTUTP; +drop package UTFILEREPORTER; +drop package UTHTMLREPORTER; +drop package UTOUTPUTREPORTER; +drop package UTREPORT; +drop package UTPIPE; + +drop package UT_UTOUTPUT; +drop package UT_UTREPORT; + + +SET TERMOUT ON +PROMPT &line1 +PROMPT DROPPING &UT PUBLIC SYNONYMS +PROMPT &line1 + +drop public synonym UTASSERT2; +drop public synonym UTASSERT; +drop public synonym UTCONFIG; +drop public synonym UTGEN; +drop public synonym UTOUTCOME; +drop public synonym UTOUTPUT; +drop public synonym UTPACKAGE; +drop public synonym UTPLSQL2; +drop public synonym UTPLSQL; +drop public synonym UTPLSQL_UTIL; +drop public synonym UTRECEQ; +drop public synonym UTRERROR; +drop public synonym UTRESULT2; +drop public synonym UTRESULT; +drop public synonym UTROUTCOME; +drop public synonym UTRSUITE; +drop public synonym UTRTESTCASE; +drop public synonym UTRUNITTEST; +drop public synonym UTRUTP; +drop public synonym UTR_ERROR; +drop public synonym UTR_OUTCOME; +drop public synonym UTR_SUITE; +drop public synonym UTR_TESTCASE; +drop public synonym UTR_UNITTEST; +drop public synonym UTR_UTP; +drop public synonym UTSUITE; +drop public synonym UTSUITEUTP; +drop public synonym UTTEST; +drop public synonym UTTESTCASE; +drop public synonym UTTESTPREP; +drop public synonym UTUNITTEST; +drop public synonym UTUTP; +drop public synonym UTFILEREPORTER; +drop public synonym UTHTMLREPORTER; +drop public synonym UTOUTPUTREPORTER; +drop public synonym UTREPORT; +drop public synonym UTPIPE; +drop public synonym UT_ARGUMENT; +drop public synonym UT_ASSERTION; +drop public synonym UT_CONFIG; +drop public synonym UT_DETERMINISTIC; +drop public synonym UT_DETERMINISTIC_ARG; +drop public synonym UT_EQ; +drop public synonym UT_GRID; +drop public synonym UT_OUTCOME; +drop public synonym UT_PACKAGE; +drop public synonym UT_RECEQ; +drop public synonym UT_RECEQ_PKG; +drop public synonym UT_SUITE; +drop public synonym UT_SUITE_UTP; +drop public synonym UT_TEST; +drop public synonym UT_TESTCASE; +drop public synonym UT_TESTPREP; +drop public synonym UT_UNITTEST; +drop public synonym UT_UTP; +drop public synonym UTPLSQL_RUNNUM_SEQ; +drop public synonym UT_ASSERTION_SEQ; +drop public synonym UT_PACKAGE_SEQ; +drop public synonym UT_RECEQ_SEQ; +drop public synonym UT_REFCURSOR_RESULTS_SEQ; +drop public synonym UT_SUITE_SEQ; +drop public synonym UT_TESTCASE_SEQ; +drop public synonym UT_TEST_SEQ; +drop public synonym UT_UNITTEST_SEQ; +drop public synonym UT_UTP_SEQ; +drop public synonym UTV_LAST_RUN; +drop public synonym UTV_RESULT_FULL; + +SET TERMOUT ON +PROMPT &line1 +PROMPT DROPPING &UT SEQUENCES +PROMPT &line1 + +drop sequence UTPLSQL_RUNNUM_SEQ; +drop sequence UT_ASSERTION_SEQ; +drop sequence UT_PACKAGE_SEQ; +drop sequence UT_RECEQ_SEQ; +drop sequence UT_REFCURSOR_RESULTS_SEQ; +drop sequence UT_SUITE_SEQ; +drop sequence UT_TESTCASE_SEQ; +drop sequence UT_TEST_SEQ; +drop sequence UT_UNITTEST_SEQ; +drop sequence UT_UTP_SEQ; + +SET TERMOUT ON +PROMPT &line1 +PROMPT DROPPING &UT TABLES +PROMPT &line1 + +drop table UTR_ERROR cascade constraints; +drop table UTR_OUTCOME cascade constraints; +drop table UTR_SUITE cascade constraints; +drop table UTR_TESTCASE cascade constraints; +drop table UTR_UNITTEST cascade constraints; +drop table UTR_UTP cascade constraints; +drop table UT_ARGUMENT cascade constraints; +drop table UT_ASSERTION cascade constraints; +drop table UT_CONFIG cascade constraints; +drop table UT_DETERMINISTIC cascade constraints; +drop table UT_DETERMINISTIC_ARG cascade constraints; +drop table UT_EQ cascade constraints; +drop table UT_GRID cascade constraints; +drop table UT_OUTCOME cascade constraints; +drop table UT_PACKAGE cascade constraints; +drop table UT_RECEQ cascade constraints; +drop table UT_RECEQ_PKG cascade constraints; +drop table UT_SUITE cascade constraints; +drop table UT_SUITE_UTP cascade constraints; +drop table UT_TEST cascade constraints; +drop table UT_TESTCASE cascade constraints; +drop table UT_TESTPREP cascade constraints; +drop table UT_UNITTEST cascade constraints; +drop table UT_UTP cascade constraints; + + +SET TERMOUT ON +PROMPT &line1 +PROMPT DROPPING &UT VIEWS +PROMPT &line1 + +drop view UTV_RESULT_FULL; +drop view UTV_LAST_RUN; + diff --git a/source/ut_i_views.sql b/source/ut_i_views.sql new file mode 100644 index 000000000..594f0d3f5 --- /dev/null +++ b/source/ut_i_views.sql @@ -0,0 +1,2 @@ +@@ut_i_run utv_result_full.sql +@@ut_i_run utv_last_run.sql \ No newline at end of file diff --git a/source/ut_outcome.pkb b/source/ut_outcome.pkb new file mode 100644 index 000000000..0d66b278d --- /dev/null +++ b/source/ut_outcome.pkb @@ -0,0 +1,135 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utoutcome + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + +IS + FUNCTION name (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_outcome.name%TYPE + IS + retval ut_outcome.name%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_outcome + WHERE id = outcome_id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION id (name_in IN ut_outcome.name%TYPE) + RETURN ut_outcome.id%TYPE + IS + retval ut_outcome.id%TYPE; + BEGIN + SELECT id + INTO retval + FROM ut_outcome + WHERE name = name_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION onerow (name_in IN ut_outcome.name%TYPE) + RETURN ut_outcome%ROWTYPE + IS + retval ut_outcome%ROWTYPE; + empty_rec ut_outcome%ROWTYPE; + BEGIN + SELECT * + INTO retval + FROM ut_outcome + WHERE name = name_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN empty_rec; + END; + + FUNCTION onerow (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_outcome%ROWTYPE + IS + retval ut_outcome%ROWTYPE; + empty_rec ut_outcome%ROWTYPE; + BEGIN + SELECT * + INTO retval + FROM ut_outcome + WHERE id = outcome_id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN empty_rec; + END; + + FUNCTION utp (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_utp.id%TYPE + IS + CURSOR utp_cur + IS + SELECT ut.utp_id + FROM ut_outcome oc, ut_testcase tc, ut_unittest ut + WHERE tc.id = oc.testcase_id + AND tc.unittest_id = ut.id + AND oc.id = outcome_id_in; + + utp_rec utp_cur%ROWTYPE; + BEGIN + OPEN utp_cur; + FETCH utp_cur INTO utp_rec; + CLOSE utp_cur; + RETURN utp_rec.utp_id; + END; + + FUNCTION unittest (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_unittest.id%TYPE + IS + CURSOR unittest_cur + IS + SELECT tc.unittest_id + FROM ut_outcome oc, ut_testcase tc + WHERE tc.id = oc.testcase_id + AND oc.id = outcome_id_in; + + unittest_rec unittest_cur%ROWTYPE; + BEGIN + OPEN unittest_cur; + FETCH unittest_cur INTO unittest_rec; + CLOSE unittest_cur; + RETURN unittest_rec.unittest_id; + END; +END utoutcome; +/ diff --git a/source/ut_outcome.pks b/source/ut_outcome.pks new file mode 100644 index 000000000..9fdbb0c93 --- /dev/null +++ b/source/ut_outcome.pks @@ -0,0 +1,57 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utoutcome +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_name CONSTANT CHAR (7) := 'OUTCOME'; + c_abbrev CONSTANT CHAR (2) := 'OC'; + + FUNCTION name (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_outcome.name%TYPE; + + FUNCTION id (name_in IN ut_outcome.name%TYPE) + RETURN ut_outcome.id%TYPE; + + FUNCTION onerow (name_in IN ut_outcome.name%TYPE) + RETURN ut_outcome%ROWTYPE; + + FUNCTION onerow (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_outcome%ROWTYPE; + + FUNCTION utp (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_utp.id%TYPE; + + PRAGMA restrict_references (utp, WNDS, WNPS); + + FUNCTION unittest (outcome_id_in IN ut_outcome.id%TYPE) + RETURN ut_unittest.id%TYPE; + + PRAGMA restrict_references (unittest, WNDS, WNPS); +END utoutcome; +/ diff --git a/source/ut_outcome.tab b/source/ut_outcome.tab new file mode 100644 index 000000000..866c926a7 --- /dev/null +++ b/source/ut_outcome.tab @@ -0,0 +1,26 @@ +CREATE TABLE ut_outcome ( +id integer, +testcase_id integer, +seq integer, +name varchar2(200), +assertion_type varchar2(100), +action_level varchar2(10), -- V1 only; not used +null_ok char(1) default 'N', +raise_exception char(1) default 'N', +declarations varchar2 (2000), +setup varchar2 (2000), +teardown varchar2 (2000), +exceptions varchar2 (2000), + CONSTRAINT ut_outcome_pk PRIMARY KEY (id) +); + +REM 2.0.10.1 Add control and test fields to help specify testing characteristics + +ALTER TABLE ut_outcome ADD control_info VARCHAR2(2000); +ALTER TABLE ut_outcome ADD test_info VARCHAR2(2000); + +CREATE unique index ut_outcome_idx1 ON + ut_outcome (testcase_id, name); + +ALTER table ut_outcome add CONSTRAINT ut_outcome_testcase_fk + FOREIGN KEY (testcase_id) REFERENCES ut_testcase; \ No newline at end of file diff --git a/source/ut_output.pkb b/source/ut_output.pkb new file mode 100644 index 000000000..78b5de98c --- /dev/null +++ b/source/ut_output.pkb @@ -0,0 +1,173 @@ +CREATE OR REPLACE PACKAGE BODY utoutput +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +************************************************************************/ + + g_temp_buffer DBMS_OUTPUT.CHARARR; + g_save_buffer DBMS_OUTPUT.CHARARR; + g_save BOOLEAN := FALSE; + c_all_lines CONSTANT INTEGER := 1000000; + + FUNCTION saving RETURN BOOLEAN + IS + BEGIN + RETURN g_save; + END; + + PROCEDURE save + IS + BEGIN + g_save := TRUE; + END; + + PROCEDURE nosave + IS + BEGIN + g_save := FALSE; + END; + + --Pull lines into given buffer and optionally + --into the save buffer too. + FUNCTION extract ( + buffer_out OUT DBMS_OUTPUT.CHARARR, + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ) RETURN INTEGER + IS + l_lines INTEGER := NVL(max_lines_in, c_all_lines); + l_index BINARY_INTEGER; + BEGIN + buffer_out.DELETE; + + DBMS_OUTPUT.Get_Lines(buffer_out, l_lines); + + --Remove the extra empty lines + WHILE l_lines < buffer_out.COUNT LOOP + buffer_out.DELETE(buffer_out.LAST); + END LOOP; + + --Append to save buffer + IF save_in THEN + l_index := buffer_out.FIRST; + WHILE l_index IS NOT NULL LOOP + g_save_buffer(NVL(g_save_buffer.LAST,0) + 1) := buffer_out(l_index); + l_index := buffer_out.NEXT(l_index); + END LOOP; + END IF; + + RETURN l_lines; + END; + + --Get the output ignoring number of lines returned. + PROCEDURE extract ( + buffer_out OUT DBMS_OUTPUT.CHARARR, + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ) + IS + l_lines INTEGER; + BEGIN + l_lines := extract(buffer_out, max_lines_in, save_in); + END; + + --Get the output ignoring the data itself + FUNCTION extract ( + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ) RETURN INTEGER + IS + BEGIN + RETURN extract(g_temp_buffer, max_lines_in, save_in); + END; + + --Get the output ignoring number of lines returned + --and ignoring the data itself + PROCEDURE extract ( + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ) + IS + BEGIN + extract(g_temp_buffer, max_lines_in, save_in); + END; + + --Put a buffer back into DBMS_OUTPUT buffer. + PROCEDURE replace(buffer_inout IN OUT DBMS_OUTPUT.CHARARR) + IS + l_index BINARY_INTEGER; + BEGIN + l_index := buffer_inout.FIRST; + WHILE l_index IS NOT NULL LOOP + DBMS_OUTPUT.Put_Line(buffer_inout(l_index)); + l_index := buffer_inout.NEXT(l_index); + END LOOP; + buffer_inout.DELETE; + END; + + --Put the save buffer back into the DBMS_OUTPUT buffer + PROCEDURE replace + IS + BEGIN + replace(g_save_buffer); + END; + + --Pull out the next line from the DBMS_OUTPUT buffer + FUNCTION nextLine(raise_exc_in BOOLEAN := TRUE, save_in BOOLEAN := saving) RETURN VARCHAR2 + IS + l_lines INTEGER; + BEGIN + + l_lines := extract(buffer_out => g_temp_buffer, + max_lines_in => 1, + save_in => save_in); + + IF l_lines <> 1 THEN + + IF raise_exc_in THEN + RAISE EMPTY_OUTPUT_BUFFER; + ELSE + RETURN NULL; + END IF; + ELSE + RETURN g_temp_buffer(g_temp_buffer.FIRST); + END IF; + + END; + + --Simply count the number of lines in the DBMS_OUTPUT buffer + --but don't remove anything + FUNCTION count RETURN INTEGER + IS + l_lines INTEGER; + BEGIN + l_lines := extract(buffer_out => g_temp_buffer, + max_lines_in => c_all_lines, + save_in => FALSE); + replace(g_temp_buffer); + RETURN l_lines; + END; + +END utoutput; +/ diff --git a/source/ut_output.pks b/source/ut_output.pks new file mode 100644 index 000000000..e0245bacf --- /dev/null +++ b/source/ut_output.pks @@ -0,0 +1,69 @@ +CREATE OR REPLACE PACKAGE utoutput +&start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:46 chrisrimmer +Added Standard Headers + +************************************************************************/ + + EMPTY_OUTPUT_BUFFER EXCEPTION; + + FUNCTION saving RETURN BOOLEAN; + + PROCEDURE save; + + PROCEDURE nosave; + + PROCEDURE replace; + + FUNCTION extract ( + buffer_out OUT DBMS_OUTPUT.CHARARR, + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ) RETURN INTEGER; + + PROCEDURE extract ( + buffer_out OUT DBMS_OUTPUT.CHARARR, + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ); + + FUNCTION extract( + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ) RETURN INTEGER; + + PROCEDURE extract( + max_lines_in IN INTEGER := NULL, + save_in IN BOOLEAN := saving + ); + + FUNCTION nextLine(raise_exc_in BOOLEAN := TRUE, save_in BOOLEAN := saving) RETURN VARCHAR2; + + FUNCTION count RETURN INTEGER; + +END utoutput; +/ diff --git a/source/ut_outputreporter.pkb b/source/ut_outputreporter.pkb new file mode 100644 index 000000000..e9d57b413 --- /dev/null +++ b/source/ut_outputreporter.pkb @@ -0,0 +1,352 @@ +CREATE OR REPLACE PACKAGE BODY utoutputreporter +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.1 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + + +************************************************************************/ + + norows BOOLEAN; + + PROCEDURE open + IS + BEGIN + NULL; + END; + + PROCEDURE close + IS + BEGIN + NULL; + END; + + -- This is an interface to dbms_output.put_line that tries to + -- sensibly split long lines (which is useful if you want to + -- print large dynamic sql statements). From Alistair Bayley + PROCEDURE show ( + s VARCHAR2, + maxlinelenparm NUMBER := 255, + expand BOOLEAN := TRUE + ) + IS + output_buffer_overflow EXCEPTION; + PRAGMA EXCEPTION_INIT (output_buffer_overflow, -20000); + i NUMBER; + maxlinelen NUMBER + := GREATEST (1, LEAST (255, maxlinelenparm)); + + FUNCTION locatenewline (str VARCHAR2) + RETURN NUMBER + IS + i10 NUMBER; + i13 NUMBER; + BEGIN + i13 := NVL (INSTR (SUBSTR (str, 1, maxlinelen), CHR (13)), 0); + i10 := NVL (INSTR (SUBSTR (str, 1, maxlinelen), CHR (10)), 0); + + IF i13 = 0 + THEN + RETURN i10; + ELSIF i10 = 0 + THEN + RETURN i13; + ELSE + RETURN LEAST (i13, i10); + END IF; + END; + BEGIN + -- 2.1.2 if NULL, abort. + IF s IS NULL + THEN + DBMS_OUTPUT.put_line (s); + -- 2.1.2 PBA we should return here... + RETURN; + -- Simple case: s is short. + ELSIF LENGTH (s) <= maxlinelen + THEN + DBMS_OUTPUT.put_line (s); + RETURN; + END IF; + + -- OK, so it's long. Look for newline chars as a good place to split. + i := locatenewline (s); + + IF i > 0 + THEN -- cool, we can split at a newline + DBMS_OUTPUT.put_line (SUBSTR (s, 1, i - 1)); + show (SUBSTR (s, i + 1), maxlinelen, expand); + ELSE + -- No newlines. Look for a convenient space prior to the 255-char limit. + -- Search backwards from maxLineLen. + i := NVL (INSTR (SUBSTR (s, 1, maxlinelen), ' ', -1), 0); + + IF i > 0 + THEN + DBMS_OUTPUT.put_line (SUBSTR (s, 1, i - 1)); + show (SUBSTR (s, i + 1), maxlinelen, expand); + ELSE + -- No whitespace - split at max line length. + i := maxlinelen; + DBMS_OUTPUT.put_line (SUBSTR (s, 1, i)); + show (SUBSTR (s, i + 1), maxlinelen, expand); + END IF; + END IF; + EXCEPTION + WHEN output_buffer_overflow + THEN + IF NOT expand + THEN + RAISE; + ELSE + DBMS_OUTPUT.ENABLE (1000000); + -- set false so won't expand again + show (s, maxlinelen, FALSE); + END IF; + END; + + PROCEDURE showbanner ( + success_in IN BOOLEAN, + program_in IN VARCHAR2, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ) + IS + program_name_and_run_id VARCHAR2(2000); + BEGIN + IF success_in + THEN + utreport.pl ('. '); + utreport.pl ( + '> SSSS U U CCC CCC EEEEEEE SSSS SSSS ' + ); + utreport.pl ( + '> S S U U C C C C E S S S S ' + ); + utreport.pl ( + '> S U U C C C C E S S ' + ); + utreport.pl ( + '> S U U C C E S S ' + ); + utreport.pl ( + '> SSSS U U C C EEEE SSSS SSSS ' + ); + utreport.pl ( + '> S U U C C E S S ' + ); + utreport.pl ( + '> S U U C C C C E S S ' + ); + utreport.pl ( + '> S S U U C C C C E S S S S ' + ); + utreport.pl ( + '> SSSS UUU CCC CCC EEEEEEE SSSS SSSS ' + ); + ELSE + utreport.pl ('. '); + utreport.pl ( + '> FFFFFFF AA III L U U RRRRR EEEEEEE ' + ); + utreport.pl ( + '> F A A I L U U R R E ' + ); + utreport.pl ( + '> F A A I L U U R R E ' + ); + utreport.pl ( + '> F A A I L U U R R E ' + ); + utreport.pl ( + '> FFFF A A I L U U RRRRRR EEEE ' + ); + utreport.pl ( + '> F AAAAAAAA I L U U R R E ' + ); + utreport.pl ( + '> F A A I L U U R R E ' + ); + utreport.pl ( + '> F A A I L U U R R E ' + ); + utreport.pl ( + '> F A A III LLLLLLL UUU R R EEEEEEE ' + ); + END IF; + + utreport.pl ('. '); + program_name_and_run_id := '"'||NVL (program_in, 'Unnamed Test')||'"'; + IF run_id_in IS NOT NULL THEN + program_name_and_run_id := program_name_and_run_id ||' Run ID: ' || run_id_in; + END IF; + IF success_in + THEN + utreport.pl (' SUCCESS: ' || program_name_and_run_id); + ELSE + utreport.pl (' FAILURE: ' || program_name_and_run_id); + END IF; + utreport.pl ('. '); + END; + + PROCEDURE pl (str VARCHAR2) + IS + BEGIN + show(str); + END; + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE) + IS + v_packagename ut_package.name%TYPE; + v_owner ut_package.owner%TYPE; + BEGIN + IF run_id IS NULL THEN + v_packagename := utplsql.currpkg; + v_owner := utplsql.currpkgowner; + ELSE + v_packagename := utpackage.name_from_last_run_id(last_run_id_in => run_id); + v_owner := utpackage.owner_from_last_run_id(last_run_id_in => run_id); + END IF; + showbanner (utresult.success (run_id), v_owner||'.'||v_packagename, run_id); + utreport.pl ('> Individual Test Case Results:'); + utreport.pl ('>'); + norows := TRUE; + END; + + PROCEDURE show_failure + IS + BEGIN + utreport.pl (utreport.outcome.description); + utreport.pl ('>'); + norows := FALSE; + END; + + PROCEDURE show_result + IS + BEGIN + utreport.pl (utreport.outcome.status || ' - ' || utreport.outcome.description); + utreport.pl ('>'); + norows := FALSE; + END; + + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + IF norows AND utconfig.showingfailuresonly + THEN + utreport.pl ('> NO FAILURES FOUND'); + ELSIF norows + THEN + utreport.pl ('> NONE FOUND'); + END IF; + END; + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + utreport.pl ('>'); + utreport.pl ('> Errors recorded in utPLSQL Error Log:'); + utreport.pl ('>'); + norows := TRUE ; + END; + + PROCEDURE show_error + IS + BEGIN + norows := FALSE ; + utreport.pl (utreport.error.errlevel || ' - ' || utreport.error.errcode || ': ' || utreport.error.errtext); + END; + + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + IF norows + THEN + utreport.pl ('> NONE FOUND'); + END IF; + END; + + /* + proc: before_suite_results + Show suite overall result banner and suite run stats + + parameters: + suite_id - suite id + */ + PROCEDURE before_suite_results( + suite_id ut_suite.id%TYPE + ) + IS + PROCEDURE show_suite_stats( + suite_id ut_suite.id%TYPE + ) + IS + SuiteStats utresult.TSuiteStats; + BEGIN + SuiteStats := utresult.get_suite_stats(suite_id => suite_id); + utreport.pl('SUITE STATS: '||to_char(SuiteStats.succeededpackages)||' of '||to_char(SuiteStats.totalpackages)||' packages succeeded.'); + utreport.pl('SUITE STATS: '||to_char(SuiteStats.succeededasserts)||' of '||to_char(SuiteStats.totalasserts)||' individual test cases succeeded.'); + utreport.pl('.'); + END show_suite_stats; + + PROCEDURE showsuitebanner( + suite_id ut_suite.id%TYPE + ) + IS + BEGIN + IF utresult.suite_success(suite_id => suite_id) THEN + utreport.pl('.'); + utreport.pl('> SSSS U U III TTTTTTT EEEEEEE SSSS U U CCC CCC EEEEEEE SSSS SSSS '); + utreport.pl('> S S U U I T E S S U U C C C C E S S S S '); + utreport.pl('> S U U I T E S U U C C C C E S S '); + utreport.pl('> S U U I T E S U U C C E S S '); + utreport.pl('> SSSS U U I T EEEE SSSS U U C C EEEE SSSS SSSS '); + utreport.pl('> S U U I T E S U U C C E S S '); + utreport.pl('> S U U I T E S U U C C C C E S S '); + utreport.pl('> S S U U I T E S S U U C C C C E S S S S '); + utreport.pl('> SSSS UUU III T EEEEEEE SSSS UUU CCC CCC EEEEEEE SSSS SSSS '); + utreport.pl('.'); + utreport.pl('SUITE SUCCESS: "'||utsuite.name_from_id(id_in => suite_id)||'"'); + ELSE + utreport.pl('.'); + utreport.pl('> SSSS U U III TTTTTTT EEEEEEE FFFFFFF AA III L U U RRRRR EEEEEEE '); + utreport.pl('> S S U U I T E F A A I L U U R R E '); + utreport.pl('> S U U I T E F A A I L U U R R E '); + utreport.pl('> S U U I T E F A A I L U U R R E '); + utreport.pl('> SSSS U U I T EEEE FFFF A A I L U U RRRRRR EEEE '); + utreport.pl('> S U U I T E F AAAAAAAA I L U U R R E '); + utreport.pl('> S U U I T E F A A I L U U R R E '); + utreport.pl('> S S U U I T E F A A I L U U R R E '); + utreport.pl('> SSSS UUU III T EEEEEEE F A A III LLLLLLL UUU R R EEEEEEE '); + utreport.pl('.'); + utreport.pl('SUITE FAILURE: "'||utsuite.name_from_id(id_in => suite_id)||'"'); + END IF; + END showsuitebanner; + + BEGIN + showsuitebanner(suite_id => suite_id); + show_suite_stats(suite_id => suite_id); + END before_suite_results; +END; +/ diff --git a/source/ut_outputreporter.pks b/source/ut_outputreporter.pks new file mode 100644 index 000000000..d34ae10dd --- /dev/null +++ b/source/ut_outputreporter.pks @@ -0,0 +1,45 @@ +CREATE OR REPLACE PACKAGE utoutputreporter &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log + +************************************************************************/ + + PROCEDURE open; + PROCEDURE pl (str IN VARCHAR2); + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE); + PROCEDURE show_failure; + PROCEDURE show_result; + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE); + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE); + PROCEDURE show_error; + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE); + + PROCEDURE close; + PROCEDURE before_suite_results(suite_id ut_suite.id%TYPE); + +END; +/ diff --git a/source/ut_package.pkb b/source/ut_package.pkb new file mode 100644 index 000000000..8451c17d7 --- /dev/null +++ b/source/ut_package.pkb @@ -0,0 +1,432 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utpackage +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2004/11/23 14:56:47 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION name_from_id (id_in IN ut_package.id%TYPE) + RETURN ut_package.name%TYPE + IS + retval ut_package.name%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_package + WHERE id = id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + -- Need to add owner to param list and query + FUNCTION id_from_name (name_in IN ut_package.name%TYPE, + owner_in IN ut_package.owner%TYPE := NULL) + RETURN ut_package.id%TYPE + IS + retval ut_package.id%TYPE; + v_owner ut_package.owner%type := nvl(owner_in,USER); + BEGIN + SELECT id + INTO retval + FROM ut_package + WHERE name = UPPER (name_in) + AND owner=v_owner + AND SUITE_ID is null; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + /* + func: name_from_last_run_id + Return name of package using last run id. + Return null if there is no package with given last run id. + params: + last_run_id_in - last run id of package + */ + FUNCTION name_from_last_run_id (last_run_id_in IN ut_package.last_run_id%TYPE) + RETURN ut_package.name%TYPE + IS + retval ut_package.name%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_package + WHERE last_run_id = last_run_id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END name_from_last_run_id; + /* + func:owner_from_last_run_id + Return owner of package using last run id. + Return null if there is no package with given last run id. + params: + last_run_id_in - last run id of package + */ + FUNCTION owner_from_last_run_id (last_run_id_in IN ut_package.last_run_id%TYPE) + RETURN ut_package.owner%TYPE + IS + retval ut_package.owner%TYPE; + BEGIN + SELECT owner + INTO retval + FROM ut_package + WHERE last_run_id = last_run_id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END owner_from_last_run_id; + + PROCEDURE ADD ( + suite_in IN INTEGER, + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + dir_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL, + owner_in IN VARCHAR2 := NULL, + add_tests_in IN BOOLEAN := FALSE, + test_overloads_in IN BOOLEAN := FALSE + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_owner VARCHAR2 (30) := NVL (owner_in, USER); + v_id ut_package.id%TYPE; + v_same ut_package.samepackage%TYPE := utplsql.c_yes; + v_prefix ut_config.prefix%TYPE + := NVL (prefix_in, utconfig.prefix (owner_in)); + BEGIN + IF NOT (NVL (samepackage_in, FALSE)) + THEN + v_same := utplsql.c_no; + END IF; + + &start_ge_8_1 v_id := utplsql.seqval ('ut_package'); &end_ge_8_1 + &start_lt_8_1 SELECT ut_package_seq.NEXTVAL INTO v_id FROM dual; &end_lt_8_1 + + INSERT INTO ut_package + (id, suite_id, name, + owner, samepackage, prefix, dir, seq, + executions, failures) + VALUES (v_id, suite_in, UPPER (package_in), + UPPER (v_owner), v_same, v_prefix, dir_in, NVL (seq_in, 1), + 0, 0); + IF id_from_name( UPPER (package_in),owner_in) IS NULL + THEN + &start_ge_8_1 v_id := utplsql.seqval ('ut_package'); &end_ge_8_1 + &start_lt_8_1 SELECT ut_package_seq.NEXTVAL INTO v_id FROM dual; &end_lt_8_1 + + INSERT INTO ut_package + (id, suite_id, name, + owner, samepackage, prefix, dir, seq, + executions, failures) + VALUES (v_id, NULL, UPPER (package_in), + UPPER (v_owner), v_same, v_prefix, dir_in, NVL (seq_in, 1), + 0, 0); + + + &start_ge_8_1 COMMIT; &end_ge_8_1 + END IF; + IF add_tests_in + THEN + -- For each program in ALL_ARGUMENTS, add a test. + + &start_ge_8_1 + -- 8i NDS implementation + DECLARE + TYPE cv_t IS REF CURSOR; + + cv cv_t; + v_name VARCHAR2 (100); + v_query VARCHAR2 (32767); + v_suffix VARCHAR2 (100) := NULL; + BEGIN + IF test_overloads_in + THEN + v_suffix := ' || TO_CHAR(overload)'; + END IF; + + v_query := + 'SELECT DISTINCT object_name ' + || v_suffix + || ' name ' + || ' from all_arguments + where owner = :owner and package_name = :package'; + OPEN cv FOR v_query + USING NVL (UPPER (owner_in), USER), UPPER (package_in); + + LOOP + FETCH cv INTO v_name; + EXIT WHEN cv%NOTFOUND; + + IF utplsql.tracing + THEN + utreport.pl ( 'Adding test ' + || package_in + || '.' + || v_name); + END IF; + + uttest.ADD (v_id, v_name, 'Test ' + || v_name); + END LOOP; + + CLOSE cv; + END; + + &end_ge_8_1 + &start_lt_8_1 + -- 7.3 DBMS_SQL Implementation + DECLARE + cur PLS_INTEGER := DBMS_SQL.open_cursor; + fdbk PLS_INTEGER; + v_name VARCHAR2 (100); + v_query VARCHAR2 (32767); + v_suffix VARCHAR2 (100) := NULL; + BEGIN + IF test_overloads_in + THEN + v_suffix := ' || TO_CHAR(overload)'; + END IF; + + v_query := + 'SELECT DISTINCT object_name ' + || v_suffix + || ' name ' + || ' from all_arguments + where owner = :owner and package_name = :package'; + DBMS_SQL.parse (cur, v_query, DBMS_SQL.native); + DBMS_SQL.bind_variable (cur, 'owner', NVL (UPPER (owner_in), USER)); + DBMS_SQL.bind_variable (cur, 'package', UPPER (package_in)); + fdbk := DBMS_SQL.EXECUTE (cur); + + LOOP + EXIT WHEN DBMS_SQL.fetch_rows (cur) = 0; + DBMS_SQL.column_value (cur, 1, v_name); + + IF utplsql.tracing + THEN + utreport.pl ( 'Adding test ' + || package_in + || '.' + || v_name); + END IF; + + uttest.ADD (v_id, v_name, 'Test ' + || v_name); + END LOOP; + + DBMS_SQL.close_cursor (cur); + END; + &end_lt_8_1 + END IF; + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Update changeable columns. + UPDATE ut_package + SET samepackage = v_same, + prefix = v_prefix, + dir = dir_in + WHERE owner = UPPER (v_owner) + AND name = UPPER (package_in) + AND suite_id = suite_in; + &start_ge_8_1 COMMIT; &end_ge_8_1 + + WHEN OTHERS + THEN + utreport.pl ( 'Add package error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE ADD ( + suite_in IN VARCHAR2, + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + dir_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL, + owner_in IN VARCHAR2 := NULL, + add_tests_in IN BOOLEAN := FALSE, + test_overloads_in IN BOOLEAN := FALSE + ) + IS + BEGIN + ADD ( + utsuite.id_from_name (suite_in), + package_in, + samepackage_in, + prefix_in, + dir_in, + seq_in, + owner_in, + add_tests_in, + test_overloads_in + ); + END; + + PROCEDURE rem ( + suite_in IN INTEGER, + package_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + BEGIN + DELETE FROM ut_package + WHERE ( suite_id = UPPER (suite_in) + OR ( suite_id IS NULL + AND suite_in IS NULL + ) + ) + AND name = UPPER (package_in) + AND owner = NVL (UPPER (owner_in), USER); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Remove package error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE rem ( + suite_in IN VARCHAR2, + package_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL + ) + IS + BEGIN + rem (utsuite.id_from_name (suite_in), package_in, owner_in); + END; + + PROCEDURE upd ( + suite_id_in IN INTEGER, + package_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + owner_in IN VARCHAR2 := NULL + ) + IS + l_status VARCHAR2 (100) := utplsql.c_success; + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_failure PLS_INTEGER := 0; + + PROCEDURE do_upd + IS + BEGIN + UPDATE ut_package + SET last_status = l_status, + last_start = start_in, + last_end = end_in, + executions = NVL (executions, 0) + + 1, + failures = NVL (failures, 0) + + v_failure + ,last_run_id = utplsql2.runnum -- 2.0.9.1 + WHERE nvl(suite_id,0) = nvl(suite_id_in,0) + AND name = UPPER (package_in) + AND owner = NVL (UPPER (owner_in), USER); + END; + BEGIN + IF NOT successful_in + THEN + v_failure := 1; + l_status := utplsql.c_failure; + END IF; + + do_upd; + + IF SQL%ROWCOUNT = 0 + THEN + ADD ( + suite_id_in, + package_in, + samepackage_in=> FALSE, + prefix_in=> utconfig.prefix (owner_in), + dir_in=> NULL, + seq_in=> NULL, + owner_in=> owner_in, + add_tests_in=> FALSE, + test_overloads_in=> FALSE + ); + do_upd; + END IF; + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Update package error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE upd ( + suite_in IN VARCHAR2, + package_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + owner_in IN VARCHAR2 := NULL + ) + IS + BEGIN + upd ( + utsuite.id_from_name (suite_in), + package_in, + start_in, + end_in, + successful_in, + owner_in + ); + END; +END utpackage; +/ diff --git a/source/ut_package.pks b/source/ut_package.pks new file mode 100644 index 000000000..e374394e5 --- /dev/null +++ b/source/ut_package.pks @@ -0,0 +1,103 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utpackage -- &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_success CONSTANT VARCHAR2 (7) := 'SUCCESS'; + c_failure CONSTANT VARCHAR2 (7) := 'FAILURE'; + + FUNCTION name_from_id (id_in IN ut_package.id%TYPE) + RETURN ut_package.name%TYPE; + + FUNCTION id_from_name (name_in IN ut_package.name%TYPE, + owner_in IN ut_package.owner%TYPE := NULL) + RETURN ut_package.id%TYPE; + FUNCTION name_from_last_run_id( + last_run_id_in IN ut_package.last_run_id%TYPE + ) + RETURN ut_package.name%TYPE; + + FUNCTION owner_from_last_run_id (last_run_id_in IN ut_package.last_run_id%TYPE) + RETURN ut_package.owner%TYPE; + + PROCEDURE ADD ( + suite_in IN VARCHAR2, + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + dir_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL, + owner_in IN VARCHAR2 := NULL, + add_tests_in IN BOOLEAN := FALSE, + test_overloads_in IN BOOLEAN := FALSE + ); + + PROCEDURE rem ( + suite_in IN VARCHAR2, + package_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL + ); + + PROCEDURE upd ( + suite_in IN VARCHAR2, + package_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + owner_in IN VARCHAR2 := NULL + ); + + PROCEDURE ADD ( + suite_in IN INTEGER, + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + dir_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL, + owner_in IN VARCHAR2 := NULL, + add_tests_in IN BOOLEAN := FALSE, + test_overloads_in IN BOOLEAN := FALSE + ); + + PROCEDURE rem ( + suite_in IN INTEGER, + package_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL + ); + + PROCEDURE upd ( + suite_id_in IN INTEGER, + package_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + owner_in IN VARCHAR2 := NULL + ); +END utpackage; +/ diff --git a/source/ut_package.tab b/source/ut_package.tab new file mode 100644 index 000000000..55e788bff --- /dev/null +++ b/source/ut_package.tab @@ -0,0 +1,31 @@ +CREATE TABLE ut_package ( + id INTEGER , + suite_id INTEGER, + owner VARCHAR2(30), + name VARCHAR2(200), + description VARCHAR2(2000), + samepackage CHAR(1) DEFAULT 'N', + prefix VARCHAR2(100), + dir VARCHAR2(2000), + seq INTEGER, + executions INTEGER, + failures INTEGER, + last_status VARCHAR2(20), /* either SUCCESS or FAILURE */ + last_start DATE, + last_end DATE, + CONSTRAINT ut_package_pk PRIMARY KEY (id) +); + +REM 2.0.9.1 support cross ref to run, recommended by Dan Spencer + +alter table ut_package add (last_run_id number); + +CREATE unique index ut_package_idx1 ON + ut_package (suite_id, owner, name); + +--CREATE unique index ut_package_idx2 ON +-- ut_package (owner, name); + +ALTER table ut_package add CONSTRAINT ut_package_suite_fk + FOREIGN KEY (suite_id) REFERENCES ut_suite; + diff --git a/source/ut_package_seq.seq b/source/ut_package_seq.seq new file mode 100644 index 000000000..ff8c4d3b4 --- /dev/null +++ b/source/ut_package_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_package_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_pipe.pkb b/source/ut_pipe.pkb new file mode 100644 index 000000000..ea79ce522 --- /dev/null +++ b/source/ut_pipe.pkb @@ -0,0 +1,103 @@ +CREATE OR REPLACE PACKAGE BODY UTPIPE +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2004 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2004/11/23 15:02:18 chrisrimmer +Added missing preprocessor flags + +Revision 1.1 2004/11/23 14:56:47 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + + +************************************************************************/ + + PROCEDURE receive_and_unpack ( + pipe_in IN VARCHAR2, + msg_tbl_out OUT msg_tbltype, + pipe_status_out IN OUT PLS_INTEGER + ) + IS + invalid_item_type EXCEPTION; + null_msg_tbl msg_tbltype; + next_item INTEGER; + item_count INTEGER := 0; + BEGIN + pipe_status_out := + DBMS_PIPE.receive_message ( + pipe_in, + TIMEOUT=> 0 + ); + + IF pipe_status_out != 0 + THEN + RAISE invalid_item_type; + END IF; + + LOOP + next_item := DBMS_PIPE.next_item_type; + EXIT WHEN next_item = 0; + item_count := item_count + + 1; + msg_tbl_out (item_count).item_type := + next_item; + + IF next_item = 9 + THEN + DBMS_PIPE.unpack_message ( + msg_tbl_out (item_count).mvc2 + ); + ELSIF next_item = 6 + THEN + DBMS_PIPE.unpack_message ( + msg_tbl_out (item_count).mnum + ); + ELSIF next_item = 11 + THEN + DBMS_PIPE.unpack_message_rowid ( + msg_tbl_out (item_count).mrid + ); + ELSIF next_item = 12 + THEN + DBMS_PIPE.unpack_message ( + msg_tbl_out (item_count).mdt + ); + ELSIF next_item = 23 + THEN + DBMS_PIPE.unpack_message_raw ( + msg_tbl_out (item_count).mraw + ); + ELSE + RAISE invalid_item_type; + END IF; + + next_item := DBMS_PIPE.next_item_type; + END LOOP; + EXCEPTION + WHEN invalid_item_type + THEN + msg_tbl_out := null_msg_tbl; + END receive_and_unpack; + +END UTPIPE; +/ diff --git a/source/ut_pipe.pks b/source/ut_pipe.pks new file mode 100644 index 000000000..3c1cc340d --- /dev/null +++ b/source/ut_pipe.pks @@ -0,0 +1,56 @@ +CREATE OR REPLACE PACKAGE UTPIPE &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2004 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.1 2004/11/23 14:56:48 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + + +************************************************************************/ + + -- DBMS_PIPE functionality based on code provided by John Beresniewicz, + -- Savant Corp, in ORACLE BUILT-IN PACKAGES + + -- For pipe equality checking + TYPE msg_rectype IS RECORD ( + item_type INTEGER, + mvc2 VARCHAR2 (4093), + mdt DATE, + mnum NUMBER, + mrid ROWID, + mraw RAW (4093)); + + /* + || msg_tbltype tables can hold an ordered list of + || message items, thus any message can be captured + */ + TYPE msg_tbltype IS TABLE OF msg_rectype + INDEX BY BINARY_INTEGER; + + PROCEDURE receive_and_unpack(pipe_in IN VARCHAR2, + msg_tbl_out OUT msg_tbltype, + pipe_status_out IN OUT PLS_INTEGER); + +END UTPIPE; +/ diff --git a/source/ut_plsql.pkb b/source/ut_plsql.pkb new file mode 100644 index 000000000..196f0b641 --- /dev/null +++ b/source/ut_plsql.pkb @@ -0,0 +1,1412 @@ +/* Formatted on 2002/03/31 23:53 (Formatter Plus v4.5.2) */ +CREATE OR REPLACE PACKAGE BODY utplsql +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.7 2004/11/28 20:48:55 chrisrimmer +Incremented version number + +Revision 1.6 2004/11/23 14:56:48 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.5 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.4 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.3 2004/05/11 15:33:57 chrisrimmer +Added 9.2 specific code from Mark Vilrokx + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + g_trc BOOLEAN := FALSE; + g_version VARCHAR2 (100) := '2.3.1'; + + tests test_tt; + testpkg test_rt; + + FUNCTION vc2bool (vc IN VARCHAR2) + RETURN BOOLEAN + IS + BEGIN + IF vc = c_yes + THEN + RETURN TRUE; + ELSIF vc = c_no + THEN + RETURN FALSE; + ELSE + RETURN NULL; + END IF; + END; + + FUNCTION bool2vc (bool IN BOOLEAN) + RETURN VARCHAR2 + IS + BEGIN + IF bool + THEN + RETURN c_yes; + ELSIF NOT bool + THEN + RETURN c_no; + ELSE + RETURN 'NULL'; + END IF; + END; + + FUNCTION progexists ( + prog_in IN VARCHAR2, + sch_in IN VARCHAR2 + ) + RETURN BOOLEAN + IS + v_prog VARCHAR2 (1000) := prog_in; + /* variables to hold components of the name */ + sch VARCHAR2 (100); + part1 VARCHAR2 (100); + part2 VARCHAR2 (100); + dblink VARCHAR2 (100); + part1_type NUMBER; + object_number NUMBER; + BEGIN + IF sch_in IS NOT NULL + THEN + v_prog := sch_in + || '.' + || prog_in; + END IF; + + /* Break down the name into its components */ + DBMS_UTILITY.name_resolve ( + v_prog, + 1, + sch, + part1, + part2, + dblink, + part1_type, + object_number + ); + RETURN TRUE; + EXCEPTION + -- Josh Goldie: 2.0.10.3 handle failure for objects. + WHEN OTHERS + THEN + IF sch_in IS NOT NULL + THEN + RETURN progexists (prog_in, NULL); + ELSE + /* Begin changes to check if v_prog is an object */ + DECLARE + block VARCHAR2(100) := + 'DECLARE obj ' || v_prog || '; BEGIN NULL; END;'; + &start_lt_8_1 + cur PLS_INTEGER := DBMS_SQL.open_cursor; + fdbk PLS_INTEGER; + &end_lt_8_1 + BEGIN + &start_ge_8_1 + EXECUTE IMMEDIATE block; + &start_ge_8_1 + + &start_lt_8_1 + DBMS_SQL.parse ( + cur, + block, + DBMS_SQL.native + ); + + fdbk := DBMS_SQL.EXECUTE(cur); + + DBMS_SQL.close_cursor(cur); + &end_lt_8_1 + + RETURN TRUE; + EXCEPTION + WHEN OTHERS + THEN + &start_lt_8_1 + DBMS_SQL.close_cursor(cur); + &end_lt_8_1 + RETURN FALSE; + END; + /* End changes to check if v_prog is an object */ + END IF; + END; + + + FUNCTION ispackage ( + prog_in IN VARCHAR2, + sch_in IN VARCHAR2 + ) + RETURN BOOLEAN + IS + v_prog VARCHAR2 (1000) := prog_in; + /* variables to hold components of the name */ + sch VARCHAR2 (100); + part1 VARCHAR2 (100); + part2 VARCHAR2 (100); + dblink VARCHAR2 (100); + part1_type NUMBER; + object_number NUMBER; + BEGIN + IF sch_in IS NOT NULL + THEN + v_prog := sch_in + || '.' + || prog_in; + END IF; + + /* Break down the name into its components */ + DBMS_UTILITY.name_resolve ( + v_prog, + 1, + sch, + part1, + part2, + dblink, + part1_type, + object_number + ); + RETURN part1_type = 9; + EXCEPTION + WHEN OTHERS + THEN + IF sch_in IS NOT NULL + THEN + RETURN ispackage (prog_in, NULL); + ELSE + RETURN FALSE; + END IF; + END; + + -- End utility definitions + + PROCEDURE setcurrcase (indx_in IN PLS_INTEGER) + IS + BEGIN + currcase.pkg := testpkg.pkg; + currcase.prefix := testpkg.prefix; + currcase.NAME := tests (indx_in).NAME; + currcase.indx := indx_in; + END; + + FUNCTION pkgname ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2, + ispkg_in IN BOOLEAN, + owner_in IN VARCHAR2 := NULL + ) + RETURN VARCHAR2 + IS + retval VARCHAR2 (1000); + BEGIN + -- 2.0.9.1: revamp for owner/remote schema exec. + IF NOT ispkg_in + AND NOT samepackage_in -- 2.0.9.2 add second clause + THEN + retval := prefix_in + || package_in; + ELSIF samepackage_in + THEN + retval := package_in; + ELSE + retval := prefix_in + || package_in; + END IF; + + IF owner_in IS NOT NULL + THEN + -- 2.0.10.2: embed owner_in in double quotes to support + -- OS authentication + retval := '"' || owner_in || '"' + --retval := owner_in + || '.' + || retval; + END IF; + + RETURN retval; + END; + + /* 1.5.3 No longer in use + FUNCTION do_register + RETURN BOOLEAN + IS + BEGIN + RETURN (NVL (g_config.registertest, c_yes) != c_no); + END; + */ + + FUNCTION progname ( + program_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2, + ispkg_in IN BOOLEAN + ) + RETURN VARCHAR2 + IS + -- The default setting... + retval VARCHAR2 (1000) + := prefix_in + || program_in; + BEGIN + -- 1.3.5 If not using setup to register then prefix + -- is already a part of the name; no construction necessary. + IF NOT utconfig.registeringtest + THEN + IF UPPER (program_in) NOT IN + (c_setup, c_teardown) + THEN + retval := program_in; + END IF; + ELSIF NOT ispkg_in + THEN + retval := prefix_in + || program_in; + ELSIF samepackage_in + THEN + retval := prefix_in + || program_in; + ELSE + -- Ignore prefix only for separate test packages of packaged + -- functionality. + retval := program_in; + END IF; + + RETURN retval; + END; + + FUNCTION pkgname ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL + ) + RETURN VARCHAR2 + IS + BEGIN + utassert.this ( + 'Pkgname: the package record has not been set!', + testpkg.pkg IS NOT NULL, + register_in=> FALSE + ); + RETURN pkgname ( + package_in, + samepackage_in, + prefix_in, + testpkg.ispkg, + owner_in + ); + END; + + FUNCTION progname ( + program_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + BEGIN + utassert.this ( + 'Progname: the package record has not been set!', + testpkg.pkg IS NOT NULL, + register_in=> FALSE + ); + RETURN progname ( + program_in, + samepackage_in, + prefix_in, + testpkg.ispkg + ); + END; + + PROCEDURE runprog ( + name_in IN VARCHAR2, + propagate_in IN BOOLEAN := FALSE + ) + IS + v_pkg VARCHAR2 (100) + := pkgname ( + testpkg.pkg, + testpkg.samepkg, + testpkg.prefix, + testpkg.owner + ); + v_name VARCHAR2 (100) := name_in; + /* + 1.5.3 No longer needed; name is always already prefixed. + := progname (NAME_IN, testpkg.samepkg, testpkg.prefix); + */ + v_str VARCHAR2 (32767); + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + &end_lt_8_1 + BEGIN + IF tracing + THEN + utreport.pl ( 'Runprog of ' + || name_in); + utreport.pl ( + ' Package and program = ' + || v_pkg + || '.' + || v_name + ); + utreport.pl ( + ' Same package? ' + || bool2vc (testpkg.samepkg) + ); + utreport.pl ( + ' Is package? ' + || bool2vc (testpkg.ispkg) + ); + utreport.pl ( ' Prefix = ' + || testpkg.prefix); + END IF; + + v_str := 'BEGIN ' + || v_pkg + || '.' + || v_name + || '; END;'; + &start_ge_8_1 + EXECUTE IMMEDIATE v_str; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse (cur, v_str, DBMS_SQL.native); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_lt_8_1 + DBMS_SQL.close_cursor (cur); + + &end_lt_8_1 + + IF tracing + THEN + utreport.pl ( + 'Compile Error "' + || SQLERRM + || '" on: ' + ); + utreport.pl (v_str); + END IF; + + utassert.this ( + 'Unable to run ' + || v_pkg + || '.' + || v_name + || ': ' + || SQLERRM, + FALSE, + null_ok_in=> NULL, + raise_exc_in=> propagate_in, + register_in=> TRUE + ); + END; + + PROCEDURE runit ( + indx_in IN PLS_INTEGER, + per_method_setup_in IN BOOLEAN, + prefix_in IN VARCHAR2 + ) + IS + BEGIN + setcurrcase (indx_in); + + IF per_method_setup_in + THEN + runprog ( prefix_in + || c_setup, TRUE); + END IF; + + runprog (tests (indx_in).NAME, FALSE); + + IF per_method_setup_in + THEN + runprog ( + prefix_in + || c_teardown, + TRUE + ); + END IF; + END; + + PROCEDURE init_tests + IS + nulltest test_rt; + nullcase testcase_rt; + BEGIN + tests.DELETE; + currcase := nullcase; + testpkg := nulltest; + END; + + PROCEDURE init ( + prefix_in IN VARCHAR2 := NULL, + dir_in IN VARCHAR2 := NULL, + from_suite_in IN BOOLEAN := FALSE + ) + IS + BEGIN + init_tests; + + --Removed test for null as utConfig.prefix never returns null + IF prefix_in IS NOT NULL + AND prefix_in != utconfig.prefix + THEN + utconfig.setprefix (prefix_in); + END IF; + + IF dir_in IS NOT NULL + AND ( dir_in != utconfig.dir + OR utconfig.dir IS NULL + ) + /* 1.5.3 Check for null config directory as well */ + THEN + utconfig.setdir (dir_in); + END IF; + + utresult.init (from_suite_in); + + -- 2.0.1 compatibilty with utPLSQL2 + utplsql2.set_runnum; + + IF tracing + THEN + utreport.pl ('Initialized utPLSQL session...'); + END IF; + END; + + PROCEDURE COMPILE ( + file_in IN VARCHAR2, + dir_in IN VARCHAR2 + ) + IS + fid UTL_FILE.file_type; + v_dir VARCHAR2 (2000) + := NVL (dir_in, utconfig.dir); + lines DBMS_SQL.varchar2s; + cur PLS_INTEGER := DBMS_SQL.open_cursor; + + PROCEDURE recngo (str IN VARCHAR2) + IS + BEGIN + UTL_FILE.fclose (fid); + utreport.pl ( + 'Error compiling ' + || file_in + || ' located in "' + || v_dir + || '": ' + || str + ); + utreport.pl ( + ' Please make sure the directory for utPLSQL is set by calling ' + || 'utConfig.setdir.' + ); + utreport.pl ( + ' Your test package must reside in this directory.' + ); + + IF DBMS_SQL.is_open (cur) + THEN + DBMS_SQL.close_cursor (cur); + END IF; + END; + BEGIN + utrerror.assert ( + v_dir IS NOT NULL, + 'Compile error: you must specify a directory with utConfig.setdir!' + ); + fid := + UTL_FILE.fopen ( + v_dir, + file_in, + 'R' &start_ge_8_1 + , + max_linesize=> 32767 &end_ge_8_1 + ); + + LOOP + BEGIN + UTL_FILE.get_line ( + fid, + lines ( NVL (lines.LAST, 0) + + 1) + ); + -- 2.0.7: helps with compiling in Linux. + lines (lines.LAST) := + RTRIM ( + lines (lines.LAST), + ' ' + || CHR (13) + ); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + EXIT; + END; + END LOOP; + + /* Clean up termination character. */ + LOOP + IF lines (lines.LAST) = '/' + OR RTRIM (lines (lines.LAST)) IS NULL + THEN + lines.DELETE (lines.LAST); + ELSE + EXIT; + END IF; + END LOOP; + + UTL_FILE.fclose (fid); + + if tracing then + utreport.pl ('Compiling ' || lines (lines.first)); + end if; + + DBMS_SQL.parse ( + cur, + lines, + lines.FIRST, + lines.LAST, + TRUE, + DBMS_SQL.native + ); + DBMS_SQL.close_cursor (cur); + EXCEPTION + WHEN UTL_FILE.invalid_path + THEN + recngo ('invalid_path'); + WHEN UTL_FILE.invalid_mode + THEN + recngo ('invalid_mode'); + WHEN UTL_FILE.invalid_filehandle + THEN + recngo ('invalid_filehandle'); + WHEN UTL_FILE.invalid_operation + THEN + recngo ('invalid_operation'); + WHEN UTL_FILE.read_error + THEN + recngo ('read_error'); + WHEN UTL_FILE.write_error + THEN + recngo ('write_error'); + WHEN UTL_FILE.internal_error + THEN + recngo ('internal_error'); + WHEN OTHERS + THEN + recngo (SQLERRM); + END; + + /* Programs used in ut_PKG.setup */ + + PROCEDURE setpkg ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL, + subprogram_in IN VARCHAR2 := '%', + override_package_in IN VARCHAR2 + := NULL -- 2.0.9.2 + ) + IS + v_pkg VARCHAR2 (1000); + BEGIN + --testpkg.pkg := package_in; + -- 2.0.9.2 + testpkg.pkg := + NVL (override_package_in, package_in); + testpkg.owner := owner_in; -- 2.0.9.1 remote schema + testpkg.ispkg := + ispackage (package_in, owner_in); + + -- 2.0.9.2 If there is an override package, treat like samepackage + -- No addition of prefix, essentially + + IF override_package_in IS NOT NULL + THEN + testpkg.samepkg := TRUE; + ELSE + testpkg.samepkg := samepackage_in; + END IF; + + testpkg.prefix := + NVL ( + prefix_in, + utconfig.prefix (owner_in) + ); + v_pkg := pkgname ( + testpkg.pkg, + testpkg.samepkg, + testpkg.prefix, + testpkg.owner + ); + + -- 2.1.1 Initialize a ut_utp row/id + DECLARE + rec ut_utp%ROWTYPE; + BEGIN + IF ututp.EXISTS (testpkg.owner, testpkg.pkg) + THEN + rec := ututp.onerow (testpkg.owner, testpkg.pkg); + ELSE + ututp.ADD (testpkg.pkg, testpkg.owner, id_out => rec.ID); + END IF; + + utplsql2.set_current_utp (rec.ID); + utrutp.initiate(utplsql2.runnum,rec.id); + END; + + + IF tracing + THEN + utreport.pl ( 'Setpkg to ' + || testpkg.pkg); + utreport.pl ( + ' Package and program = ' + || v_pkg + ); + utreport.pl ( + ' Same package? ' + || bool2vc (testpkg.samepkg) + ); + utreport.pl ( + ' Is package? ' + || bool2vc (testpkg.ispkg) + ); + utreport.pl ( ' Prefix = ' + || testpkg.prefix); + END IF; + END; + + -- 2.0.8.2 Separate out population of test array + PROCEDURE populate_test_array ( + testpkg_in IN test_rt, + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL, + subprogram_in IN VARCHAR2 := '%' + ) + IS + v_pkg VARCHAR2 (1000) + := -- 2.0.9.1 No owner prefix. + pkgname ( + testpkg_in.pkg, + testpkg_in.samepkg, + testpkg_in.prefix + ); + BEGIN + -- 1.3.5 + IF NOT utconfig.registeringtest ( + NVL (UPPER (owner_in), USER) + ) + THEN + -- Populate test information from ALL_ARGUMENTS + FOR rec IN + &start_lt_9 + (SELECT DISTINCT object_name procedure_name + FROM all_arguments + WHERE owner = + NVL ( + UPPER ( + owner_in + ), + USER + ) + AND package_name = + UPPER (v_pkg) + AND object_name LIKE + UPPER ( + prefix_in + ) + || '%' + AND object_name LIKE + UPPER ( + prefix_in + || subprogram_in + ) + AND object_name NOT IN + (UPPER ( + prefix_in + || c_setup + ), + UPPER ( + prefix_in + || c_teardown + ) + ) ORDER BY procedure_name) + &end_lt_9 + &start_ge_9 + (SELECT procedure_name + FROM all_procedures + WHERE owner = NVL (UPPER (owner_in), USER) + AND object_name = UPPER (v_pkg) + AND procedure_name LIKE UPPER (prefix_in) + || '%' + AND procedure_name LIKE + UPPER ( prefix_in + || subprogram_in) + AND procedure_name NOT IN (UPPER ( + prefix_in + || c_setup + ), + UPPER ( + prefix_in + || c_teardown + ) + ) ORDER BY procedure_name) + &end_ge_9 + LOOP + addtest ( + testpkg_in.pkg, + rec.procedure_name, + prefix_in, + iterations_in=> 1, + override_in=> TRUE + ); + END LOOP; + END IF; + END; + + FUNCTION currpkg + RETURN VARCHAR2 + IS + BEGIN + RETURN testpkg.pkg; + END; + + /* + func: currpkgowner + Return Owner of current package. + */ + FUNCTION currpkgowner + RETURN VARCHAR2 + IS + BEGIN + RETURN testpkg.owner; + END; + + + PROCEDURE addtest ( + package_in IN VARCHAR2, + name_in IN VARCHAR2, + prefix_in IN VARCHAR2, + iterations_in IN PLS_INTEGER, + override_in IN BOOLEAN + ) + IS + indx PLS_INTEGER + := NVL (tests.LAST, 0) + + 1; + BEGIN + -- 1.3.5 Disable calls to addtest from setup. + IF utconfig.registeringtest + OR ( NOT utconfig.registeringtest + AND override_in + ) + THEN + IF tracing + THEN + utreport.pl ('Addtest'); + utreport.pl ( + ' Package and program = ' + || package_in + || '.' + || name_in + ); + utreport.pl ( + ' Same package? ' + || bool2vc (testpkg.samepkg) + ); + utreport.pl ( + ' Override? ' + || bool2vc (override_in) + ); + utreport.pl ( ' Prefix = ' + || prefix_in); + END IF; + + -- 1.5.3: program name always already has prefix! + tests (indx).pkg := package_in; + tests (indx).prefix := prefix_in; + tests (indx).NAME := name_in; + tests (indx).iterations := iterations_in; + END IF; + END; + + PROCEDURE addtest ( + name_in IN VARCHAR2, + prefix_in IN VARCHAR2 := NULL, + iterations_in IN PLS_INTEGER := 1, + override_in IN BOOLEAN := FALSE + ) + IS + indx PLS_INTEGER + := NVL (tests.LAST, 0) + + 1; + BEGIN + addtest ( + testpkg.pkg, + name_in, + prefix_in, + iterations_in, + override_in + ); + END; + + /* Test engine */ + + /* 1.5.3. autocompiling used instead + FUNCTION do_recompile (recomp IN BOOLEAN) + RETURN BOOLEAN + IS + BEGIN + RETURN ( recomp + AND (NVL (g_config.autocompile, c_yes) != c_no)); + END; + */ + + PROCEDURE test ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + recompile_in IN BOOLEAN := TRUE, + dir_in IN VARCHAR2 := NULL, + suite_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL, + reset_results_in IN BOOLEAN := TRUE, + from_suite_in IN BOOLEAN := FALSE, + subprogram_in IN VARCHAR2 := '%', + per_method_setup_in IN BOOLEAN := FALSE, -- 2.0.8 + override_package_in IN VARCHAR2 + := NULL -- 2.0.9.2 + ) + IS + indx PLS_INTEGER; + v_pkg VARCHAR2 (100); + -- 2.0.10.1: use dir in config + v_dir maxvc2_t := NVL (dir_in, utconfig.dir); + v_start DATE := SYSDATE; + v_prefix ut_config.prefix%TYPE + := NVL (prefix_in, utconfig.prefix (owner_in)); + v_per_method_setup BOOLEAN + := NVL (per_method_setup_in, FALSE); + + PROCEDURE cleanup ( + per_method_setup_in IN BOOLEAN + ) + IS + BEGIN + IF suite_in IS NULL THEN + utreport.open; + utresult.show; + END IF; + BEGIN + IF NOT per_method_setup_in + THEN + runprog ( + v_prefix + || c_teardown, + TRUE + ); + END IF; + EXCEPTION + WHEN OTHERS THEN + utassert.this ( + 'Unable to run ' + || v_prefix || c_teardown + || ': ' + || SQLERRM, + FALSE, + --same as in "runprog" call + null_ok_in=> NULL, + raise_exc_in=> TRUE, + register_in=> TRUE + ); + END; + + + utpackage.upd ( + suite_in, + package_in, + v_start, + SYSDATE, + utresult.success, + owner_in + ); + + -- 2.1.1 add recording of test in tables. + utrutp.terminate(utplsql2.runnum, utplsql2.current_utp); + + IF reset_results_in + THEN + init_tests; + END IF; + + IF suite_in IS NULL THEN + utreport.close; + END IF; + + END; + BEGIN + init (v_prefix, v_dir, from_suite_in); + + IF NOT progexists (package_in, owner_in) + THEN + utreport.pl ( + 'Program named "' + || package_in + || '" does not exist.' + ); + ELSE + setpkg ( + package_in, + samepackage_in, + v_prefix, + owner_in, + subprogram_in, + override_package_in + ); + --v_pkg := pkgname (package_in, samepackage_in, v_prefix, owner_in); + -- 2.0.9.2 Make sure record is used. + v_pkg := pkgname ( + testpkg.pkg, + testpkg.samepkg, + testpkg.prefix, + testpkg.owner + ); + + IF recompile_in + AND utconfig.autocompiling ( + owner_in + ) + THEN + IF tracing + THEN + utreport.pl ( + 'Recompiling ' + || v_pkg + || ' in ' + || v_dir + ); + END IF; + + utreceq.COMPILE (package_in); + + COMPILE ( + -- 2.0.9.1 Package name without OWNER + -- 2.0.9.2 Switch to use of record based info. + --pkgname (package_in, samepackage_in, v_prefix) + -- || '.pks', dir_in); + pkgname ( + testpkg.pkg, + testpkg.samepkg, + testpkg.prefix + ) + || '.pks', + v_dir + ); + COMPILE ( + -- 2.0.9.1 Package name without OWNER + -- 2.0.9.2 Switch to use of record based info. + --pkgname (package_in, samepackage_in, v_prefix) + -- || '.pks', dir_in); + pkgname ( + testpkg.pkg, + testpkg.samepkg, + testpkg.prefix + ) + || '.pkb', + v_dir + ); + END IF; + + IF NOT v_per_method_setup + THEN + runprog ( + v_prefix + || c_setup, + TRUE + ); + END IF; + + populate_test_array ( + testpkg, + package_in, + samepackage_in, + v_prefix, + owner_in, + subprogram_in + ); + indx := tests.FIRST; + + IF indx IS NULL + THEN + utreport.pl ('Warning!'); + utreport.pl ( + 'Warning...no tests were identified for execution!' + ); + utreport.pl ('Warning!'); + ELSE + LOOP + EXIT WHEN indx IS NULL; + runit ( + indx, + v_per_method_setup, + v_prefix + ); + indx := tests.NEXT (indx); + END LOOP; + END IF; + + cleanup (v_per_method_setup); + END IF; + EXCEPTION + WHEN OTHERS + THEN + utassert.this ( + 'utPLSQL.test failure: ' + || SQLERRM, + FALSE + ); + cleanup (FALSE); + END; + + PROCEDURE testsuite ( + suite_in IN VARCHAR2, + recompile_in IN BOOLEAN := TRUE, + reset_results_in IN BOOLEAN := TRUE, + per_method_setup_in IN BOOLEAN := FALSE, -- 2.0.8 + override_package_in IN BOOLEAN := FALSE + ) + IS + v_suite ut_suite.id%TYPE + := utsuite.id_from_name (suite_in); + v_success BOOLEAN := TRUE; + v_suite_start DATE := SYSDATE; + v_pkg_start DATE; + v_override VARCHAR2 (1000); + BEGIN + utreport.open; + BEGIN + IF v_suite IS NULL + THEN + utassert.this ( + 'Test suite with name "' + || suite_in + || '" does not exist.', + FALSE + ); + utresult.show; + ELSE + FOR rec IN (SELECT * + FROM ut_package + WHERE suite_id = v_suite + ORDER BY seq) + LOOP + v_pkg_start := SYSDATE; + + -- 2.0.9.2 Pass override request to individual test. + IF override_package_in + THEN + v_override := rec.NAME; + ELSE + v_override := NULL; + END IF; +-- 2.0.9.2 allow for continuation of tests if a single package fails +begin + test ( + rec.NAME, + vc2bool (rec.samepackage), + rec.prefix, + recompile_in, + rec.dir, + +-- v_suite, + suite_in, + rec.owner, + reset_results_in=> FALSE, + from_suite_in=> TRUE, + per_method_setup_in=> per_method_setup_in, + override_package_in=> v_override + ); + -- 3/4/02 trap exceptions and continue with next package. + EXCEPTION + WHEN OTHERS THEN + v_success := FALSE; + END; + IF utresult.failure + THEN + v_success := FALSE; + END IF; + END LOOP; + + utsuite.upd ( + v_suite, + v_suite_start, + SYSDATE, + v_success + ); + + utresult.showsuite(suite_id => v_suite); + + END IF; + + IF reset_results_in + THEN + init; + END IF; + utreport.close; + EXCEPTION + WHEN OTHERS THEN + utassert.this ( + 'utPLSQL.testsuite failure: ' + || SQLERRM, + FALSE + ); + utreport.close; + END; + END; + + /* Programs used in individual unit test programs. */ + + PROCEDURE setcase (case_in IN VARCHAR2) + IS + BEGIN + NULL; + END; + + PROCEDURE setdata ( + dir_in IN VARCHAR2, + file_in IN VARCHAR2, + delim_in IN VARCHAR2 := ',' + ) + IS + BEGIN + NULL; + END; + + PROCEDURE passdata ( + data_in IN VARCHAR2, + delim_in IN VARCHAR2 := ',' + ) + IS + BEGIN + NULL; + END; + + PROCEDURE trc + IS + BEGIN + g_trc := TRUE; + END; + + PROCEDURE notrc + IS + BEGIN + g_trc := FALSE; + END; + + FUNCTION tracing + RETURN BOOLEAN + IS + BEGIN + RETURN g_trc; + END; + + FUNCTION version + RETURN VARCHAR2 + IS + BEGIN + RETURN g_version; + END; + + FUNCTION seqval (tab_in IN VARCHAR2) + RETURN PLS_INTEGER + IS + sqlstr VARCHAR2 (200) + := 'SELECT ' + || tab_in + || '_seq.NEXTVAL FROM dual'; + fdbk PLS_INTEGER; + retval PLS_INTEGER; + BEGIN + &start_ge_8_1 + EXECUTE IMMEDIATE sqlstr + INTO retval; + + &start_ge_8_1 + &start_lt_8_1 + DECLARE + fdbk PLS_INTEGER; + cur PLS_INTEGER + := DBMS_SQL.open_cursor; + BEGIN + DBMS_SQL.parse ( + cur, + sqlstr, + DBMS_SQL.native + ); + DBMS_SQL.define_column (cur, 1, retval); + fdbk := DBMS_SQL.execute_and_fetch (cur); + DBMS_SQL.column_value (cur, 1, retval); + DBMS_SQL.close_cursor (cur); + EXCEPTION + WHEN OTHERS + THEN + DBMS_SQL.close_cursor (cur); + RAISE; + END; + + &end_lt_8_1 + RETURN retval; + END; + + FUNCTION ifelse ( + bool_in IN BOOLEAN, + tval_in IN BOOLEAN, + fval_in IN BOOLEAN + ) + RETURN BOOLEAN + IS + BEGIN + IF bool_in + THEN + RETURN tval_in; + ELSE + RETURN fval_in; + END IF; + END; + + FUNCTION ifelse ( + bool_in IN BOOLEAN, + tval_in IN DATE, + fval_in IN DATE + ) + RETURN DATE + IS + BEGIN + IF bool_in + THEN + RETURN tval_in; + ELSE + RETURN fval_in; + END IF; + END; + + FUNCTION ifelse ( + bool_in IN BOOLEAN, + tval_in IN NUMBER, + fval_in IN NUMBER + ) + RETURN NUMBER + IS + BEGIN + IF bool_in + THEN + RETURN tval_in; + ELSE + RETURN fval_in; + END IF; + END; + + FUNCTION ifelse ( + bool_in IN BOOLEAN, + tval_in IN VARCHAR2, + fval_in IN VARCHAR2 + ) + RETURN VARCHAR2 + IS + BEGIN + IF bool_in + THEN + RETURN tval_in; + ELSE + RETURN fval_in; + END IF; + END; + + -- 2.0.9.2: run a test package directly + PROCEDURE run ( + testpackage_in IN VARCHAR2, + prefix_in IN VARCHAR2 := NULL, + suite_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL, + reset_results_in IN BOOLEAN := TRUE, + from_suite_in IN BOOLEAN := FALSE, + subprogram_in IN VARCHAR2 := '%', + per_method_setup_in IN BOOLEAN := FALSE + ) + IS + BEGIN + test ( + package_in=> testpackage_in, + samepackage_in=> FALSE, + prefix_in=> prefix_in, + recompile_in=> FALSE, + dir_in=> NULL, + suite_in=> suite_in, + owner_in=> owner_in, + reset_results_in=> reset_results_in, + from_suite_in=> from_suite_in, + subprogram_in=> subprogram_in, + per_method_setup_in=> per_method_setup_in, -- 2.0.8 + override_package_in=> testpackage_in + ); + END; + + PROCEDURE runsuite ( + suite_in IN VARCHAR2, + reset_results_in IN BOOLEAN := TRUE, + per_method_setup_in IN BOOLEAN := FALSE + ) + IS + BEGIN + testsuite ( + suite_in=> suite_in, + recompile_in=> FALSE, + reset_results_in=> reset_results_in, + per_method_setup_in=> per_method_setup_in, -- 2.0.8 + override_package_in=> TRUE + ); + END; +END; +/ diff --git a/source/ut_plsql.pks b/source/ut_plsql.pks new file mode 100644 index 000000000..8a9af28e4 --- /dev/null +++ b/source/ut_plsql.pks @@ -0,0 +1,250 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utplsql &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_success CONSTANT VARCHAR2 (7) := 'SUCCESS'; + c_failure CONSTANT VARCHAR2 (7) := 'FAILURE'; + c_yes CONSTANT CHAR (1) := 'Y'; + c_no CONSTANT CHAR (1) := 'N'; + c_setup CONSTANT CHAR (5) := 'SETUP'; + c_teardown CONSTANT CHAR (8) := 'TEARDOWN'; + c_enabled CONSTANT CHAR (7) := 'ENABLED'; + c_disabled CONSTANT CHAR (8) := 'DISABLED'; + &start_lt_8_1 + dbmaxvc2 VARCHAR2 (2000); + &end_lt_8_1 + &start_ge_8_1 + dbmaxvc2 VARCHAR2 (4000); + + &end_ge_8_1 + SUBTYPE dbmaxvc2_t IS dbmaxvc2%TYPE; + + maxvc2 VARCHAR2 (32767); + + SUBTYPE maxvc2_t IS maxvc2%TYPE; + + namevc2 VARCHAR2 (100); + + SUBTYPE name_t IS namevc2%TYPE; + + TYPE test_rt IS RECORD ( + pkg VARCHAR2 (100), + owner VARCHAR2(100), -- 2.0.9.1 support remote schema execution + ispkg BOOLEAN, + samepkg BOOLEAN, + prefix VARCHAR2 (100), + iterations PLS_INTEGER); + + TYPE testcase_rt IS RECORD ( + pkg VARCHAR2 (100), + prefix VARCHAR2 (100), + name VARCHAR2 (100), + indx PLS_INTEGER, + iterations PLS_INTEGER); + + TYPE test_tt IS TABLE OF testcase_rt + INDEX BY BINARY_INTEGER; + + currcase testcase_rt; + + /* Utility programs */ + FUNCTION vc2bool (vc IN VARCHAR2) + RETURN BOOLEAN; + + FUNCTION bool2vc (bool IN BOOLEAN) + RETURN VARCHAR2; + + FUNCTION ispackage (prog_in IN VARCHAR2, sch_in IN VARCHAR2) + RETURN BOOLEAN; + + /* Single package test engine. */ + + PROCEDURE test ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL, + recompile_in IN BOOLEAN := TRUE, + dir_in IN VARCHAR2 := NULL, + suite_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL, + reset_results_in IN BOOLEAN := TRUE, + from_suite_in IN BOOLEAN := FALSE, + subprogram_in in varchar2 := '%', + per_method_setup_in in boolean := FALSE, -- 2.0.8 + override_package_in IN varchar2 := NULL -- 2.0.9.2 + -- If recompiling, then always looks for + -- .pks and .pkb files + ); + + PROCEDURE testsuite ( + suite_in IN VARCHAR2, + recompile_in IN BOOLEAN := TRUE, + reset_results_in IN BOOLEAN := TRUE, + per_method_setup_in in boolean := FALSE, -- 2.0.8 + override_package_in IN BOOLEAN := FALSE + -- If recompiling, then always looks for + -- .pks and .pkb files + ); + + /* Single package test engine. */ + -- 2.0.9.2: run a test package directly + PROCEDURE run ( + testpackage_in IN VARCHAR2, + prefix_in IN VARCHAR2 := NULL, + suite_in IN VARCHAR2 := NULL, + owner_in IN VARCHAR2 := NULL, + reset_results_in IN BOOLEAN := TRUE, + from_suite_in IN BOOLEAN := FALSE, + subprogram_in in varchar2 := '%', + per_method_setup_in in boolean := FALSE + ); + + PROCEDURE runsuite ( + suite_in IN VARCHAR2, + reset_results_in IN BOOLEAN := TRUE, + per_method_setup_in in boolean := FALSE + ); + + /* Programs used in ut_PKG.setup */ + + /* 1.3.2: Hide setpkg. Modifies global package state + and is no longer needed by customer. + + PROCEDURE setpkg ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN := FALSE, + prefix_in IN VARCHAR2 := NULL + ); + */ + + FUNCTION currpkg + RETURN VARCHAR2; + + FUNCTION currpkgowner + RETURN VARCHAR2; + + PROCEDURE addtest ( + package_in IN VARCHAR2, + name_in IN VARCHAR2, + prefix_in IN VARCHAR2, + iterations_in IN PLS_INTEGER, + override_in IN BOOLEAN + ); + + PROCEDURE addtest ( + name_in IN VARCHAR2, + prefix_in IN VARCHAR2 := NULL, + iterations_in IN PLS_INTEGER := 1, + override_in IN BOOLEAN := FALSE + ); + + -- Not currently used. + PROCEDURE setcase (case_in IN VARCHAR2); + + -- Not currently used. + PROCEDURE setdata ( + dir_in IN VARCHAR2, + file_in IN VARCHAR2, + delim_in IN VARCHAR2 := ',' + ); + + -- Not currently used. + PROCEDURE passdata (data_in IN VARCHAR2, delim_in IN VARCHAR2 := ','); + + -- Utility programs + + PROCEDURE trc; + + PROCEDURE notrc; + + FUNCTION tracing + RETURN BOOLEAN; + + FUNCTION version + RETURN VARCHAR2; + + FUNCTION seqval (tab_in IN VARCHAR2) + RETURN PLS_INTEGER; + + -- Constructs name of package and program based on factors + -- such as same package or test package, prefix, etc. + FUNCTION pkgname ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2, + ispkg_in IN BOOLEAN, + owner_in IN VARCHAR2 := NULL + ) + RETURN VARCHAR2; + + FUNCTION progname ( + program_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2, + ispkg_in IN BOOLEAN + ) + RETURN VARCHAR2; + + FUNCTION pkgname ( + package_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL + ) + RETURN VARCHAR2; + + FUNCTION progname ( + program_in IN VARCHAR2, + samepackage_in IN BOOLEAN, + prefix_in IN VARCHAR2 + ) + RETURN VARCHAR2; + + FUNCTION ifelse (bool_in IN BOOLEAN, tval_in IN BOOLEAN, fval_in IN BOOLEAN) + RETURN BOOLEAN; + + FUNCTION ifelse (bool_in IN BOOLEAN, tval_in IN DATE, fval_in IN DATE) + RETURN DATE; + + FUNCTION ifelse (bool_in IN BOOLEAN, tval_in IN NUMBER, fval_in IN NUMBER) + RETURN NUMBER; + + FUNCTION ifelse ( + bool_in IN BOOLEAN, + tval_in IN VARCHAR2, + fval_in IN VARCHAR2 + ) + RETURN VARCHAR2; +END; +/ + diff --git a/source/ut_plsql2.pkb b/source/ut_plsql2.pkb new file mode 100644 index 000000000..b894bd1e6 --- /dev/null +++ b/source/ut_plsql2.pkb @@ -0,0 +1,478 @@ +/* Formatted on 2001/10/15 08:45 (Formatter Plus v4.5.2) */ +CREATE OR REPLACE PACKAGE BODY utplsql2 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2004/11/23 14:56:48 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + g_trc BOOLEAN := FALSE; + g_current current_test_rt; + + -- Global state information + FUNCTION runnum + RETURN utr_outcome.run_id%TYPE + IS + BEGIN + RETURN g_current.run_id; + END; + + + -- 2.0.9.1: tc_run_id logic + PROCEDURE set_runnum + IS + BEGIN + SELECT utplsql_runnum_seq.NEXTVAL + INTO g_current.run_id + FROM DUAL; + g_current.tc_run_id := 1; + END; + + FUNCTION tc_runnum + RETURN PLS_INTEGER + IS + BEGIN + RETURN g_current.tc_run_id; + END; + + PROCEDURE move_ahead_tc_runnum + IS + BEGIN + g_current.tc_run_id := g_current.tc_run_id + 1; + END; + + FUNCTION current_suite + RETURN ut_suite.id%TYPE + IS + BEGIN + RETURN g_current.suite_id; + END; + + PROCEDURE set_current_suite (suite_in IN ut_suite.id%TYPE) + IS + BEGIN + g_current.suite_id := suite_in; + END; + + FUNCTION current_utp + RETURN ut_utp.id%TYPE + IS + BEGIN + RETURN g_current.utp_id; + END; + + PROCEDURE set_current_utp (utp_in IN ut_utp.id%TYPE) + IS + BEGIN + g_current.utp_id := utp_in; + END; + + FUNCTION current_unittest + RETURN ut_unittest.id%TYPE + IS + BEGIN + RETURN g_current.unittest_id; + END; + + PROCEDURE set_current_unittest ( + unittest_in IN ut_unittest.id%TYPE + ) + IS + BEGIN + g_current.unittest_id := unittest_in; + END; + + FUNCTION current_testcase + RETURN ut_testcase.id%TYPE + IS + BEGIN + RETURN g_current.testcase_id; + END; + + PROCEDURE set_current_testcase ( + testcase_in IN ut_testcase.id%TYPE + ) + IS + BEGIN + g_current.testcase_id := testcase_in; + END; + + FUNCTION current_outcome + RETURN ut_outcome.id%TYPE + IS + BEGIN + RETURN g_current.outcome_id; + END; + + PROCEDURE set_current_outcome ( + outcome_in IN ut_outcome.id%TYPE + ) + IS + BEGIN + g_current.outcome_id := outcome_in; + END; + + PROCEDURE runprog ( + procedure_in IN VARCHAR2, + utp_id_in IN ut_utp.id%TYPE := NULL, + unittest_id_in IN ut_unittest.id%TYPE := NULL, + propagate_in IN BOOLEAN := FALSE, + exceptions_in IN VARCHAR2 := NULL + ) + IS + v_name VARCHAR2 (100) := procedure_in; + v_str VARCHAR2 (32767); + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER := DBMS_SQL.open_cursor; + &end_lt_8_1 + BEGIN + IF tracing + THEN + utreport.pl ( 'Runprog of ' + || procedure_in); + END IF; + + v_str := 'BEGIN ' + || procedure_in + || ';' + || utplsql.ifelse ( + exceptions_in IS NULL, + NULL, + RTRIM ( + 'EXCEPTION ' + || exceptions_in, + ';' + ) + || ';' + ) + || ' END;'; + &start_ge_8_1 + EXECUTE IMMEDIATE v_str; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse (cur, v_str, DBMS_SQL.native); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_lt_8_1 + DBMS_SQL.close_cursor (cur); + + &end_lt_8_1 + + IF tracing + THEN + utreport.pl ( + 'Procedure execution Error "' + || SQLERRM + || '" on: ' + ); + utreport.pl (v_str); + END IF; + + IF unittest_id_in IS NOT NULL + THEN + utrerror.ut_report ( + utplsql2.runnum, + unittest_id_in, + utrerror.cannot_run_program, + 'Procedure named "' + || procedure_in + || '" could not be executed.', + SQLERRM + ); + ELSE + utrerror.utp_report ( + utplsql2.runnum, + utp_id_in, + utrerror.cannot_run_program, + 'Procedure named "' + || procedure_in + || '" could not be executed.', + SQLERRM + ); + END IF; + /* + utassert.this ( + 'Unable to run ' + || procedure_in + || ': ' + || SQLERRM, + FALSE, + null_ok_in=> NULL, + raise_exc_in=> propagate_in, + register_in=> TRUE + ); + */ + END; + + PROCEDURE run_utp_setup (utp_in IN ut_utp%ROWTYPE, + package_level_in in boolean := TRUE) + IS + l_program VARCHAR2 (100) + := ututp.setup_procedure (utp_in); + -- V1 uttestprep.setup_program (utp_in) + BEGIN + IF l_program IS NOT NULL and + (package_level_in OR utp_in.per_method_setup = utplsql.c_yes) + THEN + runprog ( + l_program, + utp_in.id, + exceptions_in=> utp_in.EXCEPTIONS + ); + END IF; + END; + + PROCEDURE run_utp_teardown (utp_in IN ut_utp%ROWTYPE, + package_level_in in boolean := TRUE) + IS + l_program VARCHAR2 (100) + := ututp.teardown_procedure (utp_in); + -- V1 uttestprep.teardown_program (utp_in); + BEGIN + IF l_program IS NOT NULL and + (package_level_in OR utp_in.per_method_setup = utplsql.c_yes) + THEN + runprog ( + l_program, + utp_in.id, + exceptions_in=> utp_in.EXCEPTIONS + ); + END IF; + END; + + PROCEDURE run_unittest ( + utp_in IN ut_utp%ROWTYPE, + ut_in IN ut_unittest%ROWTYPE + ) + IS + BEGIN + utrunittest.initiate (utplsql2.runnum, ut_in.id); + + -- 2.0.8.1: Add support for unit test level setup/teardown + + run_utp_setup (utp_in, package_level_in => FALSE); + + runprog ( + utunittest.full_name (utp_in, ut_in), + utp_in.id, + ut_in.id, + exceptions_in=> utp_in.EXCEPTIONS + ); + + run_utp_teardown (utp_in, package_level_in => FALSE); + + utrunittest.terminate (utplsql2.runnum, ut_in.id); + END; + + PROCEDURE test ( + utp_rec IN ut_utp%ROWTYPE, + show_results_in IN BOOLEAN := TRUE, + program_in IN VARCHAR2 := NULL, + naming_mode_in IN VARCHAR2 := v2_naming_mode + ) + IS + CURSOR unit_tests_cur (id_in IN ut_utp.id%TYPE) + IS + SELECT * + FROM ut_unittest + WHERE utp_id = id_in + AND status = utplsql.c_enabled + ORDER BY seq; + + PROCEDURE cleanup (utp_in IN ut_utp%ROWTYPE) + IS + BEGIN + IF utp_in.id IS NOT NULL + THEN + run_utp_teardown (utp_in); + utrutp.terminate (utplsql2.runnum, utp_in.id); + END IF; + + IF show_results_in + THEN + utresult.show (utplsql2.runnum); + END IF; + + COMMIT; + END; + BEGIN + IF utp_rec.id IS NULL + THEN + utrerror.utp_report ( + utplsql2.runnum, + NULL, + utrerror.no_utp_for_program, + 'Program named "' + || program_in + || '" does not have a UTP defined for it.' + ); + ELSE + utrutp.initiate (utplsql2.runnum, utp_rec.id); + run_utp_setup (utp_rec); + + -- Get the information on this program from the ut_utp table. + FOR ut_rec IN unit_tests_cur (utp_rec.id) + LOOP + IF tracing + THEN + utreport.pl ( + 'Unit testing: ' + || ut_rec.program_name + ); + END IF; + + run_unittest (utp_rec, ut_rec); + + END LOOP; + END IF; + + cleanup (utp_rec); + EXCEPTION + WHEN OTHERS + THEN + utrerror.utp_report ( + utplsql2.runnum, + utp_rec.id, + SQLCODE, + SQLERRM, + raiseexc=> FALSE + ); + cleanup (utp_rec); + END; + + PROCEDURE test ( + program_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL, + show_results_in IN BOOLEAN := TRUE, + naming_mode_in IN VARCHAR2 := v2_naming_mode + ) + IS + utp_rec ut_utp%ROWTYPE; + BEGIN + set_runnum; + utp_rec := ututp.onerow (owner_in, program_in); + test ( + utp_rec, + show_results_in, + program_in, + naming_mode_in + ); + END; + + PROCEDURE testsuite ( + suite_in IN VARCHAR2, + show_results_in IN BOOLEAN := TRUE, + naming_mode_in IN VARCHAR2 := v2_naming_mode + ) + IS + v_suite ut_suite.id%TYPE; + v_success BOOLEAN := TRUE; + v_suite_start DATE := SYSDATE; + v_pkg_start DATE; + suite_rec ut_suite%ROWTYPE; + + CURSOR utps_cur (suite_in IN ut_suite.id%TYPE) + IS + SELECT ut_utp.* + FROM ut_utp, ut_suite_utp + WHERE suite_id = suite_in + AND ut_utp.id = ut_suite_utp.utp_id; + BEGIN + set_runnum; + suite_rec := utsuite.onerow (suite_in); + + IF suite_rec.id IS NULL + THEN + utrerror.suite_report ( + utplsql2.runnum, + NULL, + utrerror.undefined_suite, + 'Suite named "' + || suite_in + || '" is not defined.' + ); + ELSE + utrsuite.initiate (utplsql2.runnum, suite_rec.id); + + -- Get the information on this program from the ut_utp table. + FOR utp_rec IN utps_cur (suite_rec.id) + LOOP + test ( + utp_rec, + show_results_in=> show_results_in, + naming_mode_in=> naming_mode_in + ); + END LOOP; + + utrsuite.terminate (utplsql2.runnum, suite_rec.id); + END IF; + EXCEPTION + WHEN OTHERS + THEN + utrerror.suite_report ( + utplsql2.runnum, + suite_rec.id, + SQLCODE, + SQLERRM, + raiseexc=> FALSE + ); + END; + + PROCEDURE trc + IS + BEGIN + g_trc := TRUE; + END; + + PROCEDURE notrc + IS + BEGIN + g_trc := FALSE; + END; + + FUNCTION tracing + RETURN BOOLEAN + IS + BEGIN + RETURN g_trc; + END; +END utplsql2; +/ + diff --git a/source/ut_plsql2.pks b/source/ut_plsql2.pks new file mode 100644 index 000000000..3d7d11ab8 --- /dev/null +++ b/source/ut_plsql2.pks @@ -0,0 +1,105 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utplsql2 &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + +V2_naming_mode constant char(2) := 'V1'; +V1_naming_mode constant char(2) := 'V2'; + + -- Define and access "current test state" information + + TYPE current_test_rt IS RECORD ( + run_id utr_outcome.run_id%TYPE, + tc_run_id PLS_INTEGER, -- 2.0.9.1 + suite_id ut_suite.id%TYPE, + utp_id ut_utp.id%TYPE, + unittest_id ut_unittest.id%TYPE, + testcase_id ut_testcase.id%TYPE, + outcome_id ut_outcome.id%TYPE); + + FUNCTION runnum + RETURN utr_outcome.run_id%TYPE; + --2.0.9.2 + PRAGMA RESTRICT_REFERENCES (runnum, WNDS); + + PROCEDURE set_runnum; + + FUNCTION tc_runnum + RETURN PLS_INTEGER; + + PROCEDURE move_ahead_tc_runnum; + + FUNCTION current_suite + RETURN ut_suite.id%TYPE; + + PROCEDURE set_current_suite (suite_in IN ut_suite.id%TYPE); + + FUNCTION current_utp + RETURN ut_utp.id%TYPE; + + PROCEDURE set_current_utp (utp_in IN ut_utp.id%TYPE); + + FUNCTION current_unittest + RETURN ut_unittest.id%TYPE; + + PROCEDURE set_current_unittest (unittest_in IN ut_unittest.id%TYPE); + + FUNCTION current_testcase + RETURN ut_testcase.id%TYPE; + + PROCEDURE set_current_testcase (testcase_in IN ut_testcase.id%TYPE); + + FUNCTION current_outcome + RETURN ut_outcome.id%TYPE; + + PROCEDURE set_current_outcome (outcome_in IN ut_outcome.id%TYPE); + + PROCEDURE test ( + program_in IN VARCHAR2, + owner_in IN VARCHAR2 := NULL, + show_results_in IN BOOLEAN := TRUE, + naming_mode_in IN VARCHAR2 := V2_naming_mode + ); + + PROCEDURE testsuite ( + suite_in IN VARCHAR2, + show_results_in IN BOOLEAN := TRUE, + naming_mode_in IN VARCHAR2 := V2_naming_mode + ); + + -- Utility programs + + PROCEDURE trc; + + PROCEDURE notrc; + + FUNCTION tracing + RETURN BOOLEAN; +END utplsql2; +/ diff --git a/source/ut_plsql_runnum_seq.seq b/source/ut_plsql_runnum_seq.seq new file mode 100644 index 000000000..5dd2cf485 --- /dev/null +++ b/source/ut_plsql_runnum_seq.seq @@ -0,0 +1 @@ +CREATE sequence utplsql_runnum_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_plsql_util.pkb b/source/ut_plsql_util.pkb new file mode 100644 index 000000000..dd6d95186 --- /dev/null +++ b/source/ut_plsql_util.pkb @@ -0,0 +1,1624 @@ +CREATE OR REPLACE PACKAGE BODY utplsql_util + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2003/11/21 16:28:44 chrisrimmer +Fixed the commented out preprocessor flags, pointed out by Frank Puechl +in bug 846639 + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + +AS + ver_no VARCHAR2 (10) := '1.0.0'; + + TYPE param_rec IS RECORD ( + col_name VARCHAR2 (50), + col_type PLS_INTEGER, + col_len PLS_INTEGER, + col_mode PLS_INTEGER + ); + + TYPE params_tab IS TABLE OF param_rec + INDEX BY BINARY_INTEGER; + + par_in PLS_INTEGER := 1; + par_inout PLS_INTEGER := 2; + par_out PLS_INTEGER := 3; + param_prefix VARCHAR2 (10) := 'ut_'; + + FUNCTION get_version + RETURN VARCHAR2 + IS + BEGIN + RETURN (ver_no); + END; + + FUNCTION get_par_alias (par_type VARCHAR) + RETURN VARCHAR2 + IS + BEGIN + IF (par_type = 'VARCHAR') + THEN + RETURN ('vchar'); + ELSIF (par_type = 'NUMBER') + THEN + RETURN ('num'); + ELSIF (par_type = 'DATE') + THEN + RETURN ('date'); + ELSIF (par_type = 'REF CURSOR') + THEN + RETURN ('refc'); + ELSIF (par_type = 'CHAR') + THEN + RETURN ('chr'); + ELSE + RETURN ('oth'); + END IF; + END; + + PROCEDURE add_params ( + params IN OUT utplsql_params, + par_pos PLS_INTEGER, + par_type VARCHAR2, + par_sql_type VARCHAR2, + par_inout PLS_INTEGER, + par_val VARCHAR2 + ) + IS + idx PLS_INTEGER; + BEGIN + idx := params.COUNT + 1; + params (idx).par_name := param_prefix + || get_par_alias (par_type) + || '_' + || TO_CHAR (par_pos); + params (idx).par_pos := par_pos; + params (idx).par_type := par_type; + params (idx).par_sql_type := par_sql_type; + params (idx).par_inout := par_inout; + params (idx).par_val := par_val; + END; + + PROCEDURE reg_in_param ( + par_pos PLS_INTEGER, + par_val VARCHAR2, + params IN OUT utplsql_params + ) + IS + BEGIN + add_params (params, par_pos, 'VARCHAR2', 'VARCHAR2', par_in, par_val); + END; + + PROCEDURE reg_in_param ( + par_pos PLS_INTEGER, + par_val NUMBER, + params IN OUT utplsql_params + ) + IS + BEGIN + add_params ( + params, + par_pos, + 'NUMBER', + 'NUMBER', + par_in, + TO_CHAR (par_val) + ); + END; + + PROCEDURE reg_in_array ( + par_pos IN PLS_INTEGER, + array_name IN VARCHAR2, + array_vals IN varchar_array, + params IN OUT utplsql_params + ) + IS + idx PLS_INTEGER; + BEGIN + add_params (params, par_pos, 'ARRAY', array_name, par_in, NULL); + idx := array_holder.COUNT + 1; + + FOR i IN 1 .. array_vals.COUNT + LOOP + array_holder (idx).array_pos := par_pos; + array_holder (idx).array_val := array_vals (i); + idx := idx + 1; + END LOOP; + END; + + PROCEDURE reg_in_param ( + par_pos PLS_INTEGER, + par_val DATE, + params IN OUT utplsql_params + ) + IS + BEGIN + add_params ( + params, + par_pos, + 'DATE', + 'DATE', + par_in, + TO_CHAR (par_val, 'DD-MON-YYYY:HH24:MI:SS') + ); + END; + + PROCEDURE reg_inout_param ( + par_pos PLS_INTEGER, + par_val VARCHAR2, + params IN OUT utplsql_params + ) + IS + BEGIN + add_params (params, par_pos, 'VARCHAR2', 'VARCHAR2', par_inout, par_val); + END; + + PROCEDURE reg_inout_param ( + par_pos PLS_INTEGER, + par_val NUMBER, + params IN OUT utplsql_params + ) + IS + BEGIN + add_params ( + params, + par_pos, + 'NUMBER', + 'NUMBER', + par_inout, + TO_CHAR (par_val) + ); + END; + + PROCEDURE reg_inout_param ( + par_pos PLS_INTEGER, + par_val DATE, + params IN OUT utplsql_params + ) + IS + BEGIN + add_params ( + params, + par_pos, + 'DATE', + 'DATE', + par_inout, + TO_CHAR (par_val, 'DD-MON-YYYY:HH24:MI:SS') + ); + END; + + PROCEDURE reg_out_param ( + par_pos PLS_INTEGER, + par_type VARCHAR2, + params IN OUT utplsql_params + ) + IS + int_par_type VARCHAR2 (10); + BEGIN + IF (par_type = 'NUMBER') + THEN + int_par_type := 'NUMBER'; + ELSIF (par_type = 'VARCHAR') + THEN + int_par_type := 'VARCHAR2'; + ELSIF (par_type = 'CHAR') + THEN + int_par_type := 'VARCHAR2'; + ELSIF (par_type = 'REFCURSOR') + THEN + int_par_type := 'REFC'; + ELSE + int_par_type := par_type; + END IF; + + add_params (params, par_pos, int_par_type, int_par_type, par_out, NULL); + END; + + FUNCTION strtoken (s_str IN OUT VARCHAR2, token VARCHAR2) + RETURN VARCHAR2 + IS + pos PLS_INTEGER; + tmpstr VARCHAR2 (4000); + BEGIN + pos := NVL (INSTR (s_str, token), 0); + + IF (pos = 0) + THEN + pos := LENGTH (s_str); + END IF; + + tmpstr := SUBSTR (s_str, 1, pos); + s_str := SUBSTR (s_str, pos); + RETURN (tmpstr); + END; + + PROCEDURE get_table_for_str ( + p_arr OUT v30_table, + p_string VARCHAR2, + delim VARCHAR2 := ',', + enclose_str VARCHAR2 DEFAULT NULL + ) + IS + pos INTEGER := 1; + v_idx INTEGER := 1; + tmp_str VARCHAR2 (4000); + BEGIN + IF p_string IS NULL + THEN + RETURN; + END IF; + + tmp_str := p_string; + + LOOP + EXIT WHEN (pos = 0); + pos := INSTR (tmp_str, delim); + + IF (pos = 0) + THEN + p_arr (v_idx) := enclose_str || tmp_str || enclose_str; + ELSE + p_arr (v_idx) := enclose_str + || SUBSTR (tmp_str, 1, pos - 1) + || enclose_str; + v_idx := v_idx + 1; + tmp_str := SUBSTR (tmp_str, pos + 1); + END IF; + END LOOP; + END; + + FUNCTION describe_proc (vproc_name VARCHAR2, params OUT params_tab) + RETURN VARCHAR2 + IS + outstr VARCHAR2 (3000) := NULL; + seperator VARCHAR2 (10) := NULL; + v_overload DBMS_DESCRIBE.number_table; + v_position DBMS_DESCRIBE.number_table; + v_level DBMS_DESCRIBE.number_table; + v_argumentname DBMS_DESCRIBE.varchar2_table; + v_datatype DBMS_DESCRIBE.number_table; + v_defaultvalue DBMS_DESCRIBE.number_table; + v_inout DBMS_DESCRIBE.number_table; + v_length DBMS_DESCRIBE.number_table; + v_precision DBMS_DESCRIBE.number_table; + v_scale DBMS_DESCRIBE.number_table; + v_radix DBMS_DESCRIBE.number_table; + v_spare DBMS_DESCRIBE.number_table; + v_argcounter PLS_INTEGER := 1; + curr_level PLS_INTEGER := 1; + prev_level PLS_INTEGER := 1; + tab_open BOOLEAN := FALSE ; + rec_open BOOLEAN := FALSE ; + pos PLS_INTEGER; + + PROCEDURE add_param (str VARCHAR2) + IS + vtable v30_table; + BEGIN + get_table_for_str (vtable, str, ':'); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ( + 'Parsed=' + || vtable (1) + || ',' + || vtable (2) + || ',' + || vtable (3) + || ',' + || vtable (4) + ); + END IF; + + params (pos).col_name := vtable (1); + params (pos).col_type := vtable (2); + params (pos).col_len := vtable (3); + params (pos).col_mode := vtable (4); + pos := pos + 1; + END; + BEGIN + DBMS_DESCRIBE.describe_procedure ( + vproc_name, + NULL, + NULL, + v_overload, + v_position, + v_level, + v_argumentname, + v_datatype, + v_defaultvalue, + v_inout, + v_length, + v_precision, + v_scale, + v_radix, + v_spare + ); + v_argcounter := 1; + + IF (v_position (1) = 0) + THEN + outstr := 'FUNCTION'; + ELSE + outstr := 'PROCEDURE'; + END IF; + + pos := 1; + + LOOP + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ( + 'Desc()=' + || v_argumentname (v_argcounter) + || ',' + || TO_CHAR (v_datatype (v_argcounter)) + ); + END IF; + + curr_level := v_level (v_argcounter); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ( + 'Currlevel=' + || TO_CHAR (curr_level) + || ',Prevlevel=' + || TO_CHAR (prev_level) + ); + END IF; + + IF (curr_level <= prev_level) + THEN + IF (rec_open) + THEN + add_param ('RECORDEND:0:0:0'); + rec_open := FALSE ; + ELSIF (tab_open) + THEN + add_param ('TABLEEND:0:0:0'); + tab_open := FALSE ; + END IF; + END IF; + + IF (v_datatype (v_argcounter) = 250) + THEN /* Record */ + rec_open := TRUE ; + add_param ( + 'RECORDBEGIN:' + || TO_CHAR (v_datatype (v_argcounter)) + || ':' + || TO_CHAR (v_length (v_argcounter)) + || ':' + || TO_CHAR (v_inout (v_argcounter)) + ); + seperator := ','; + ELSIF (v_datatype (v_argcounter) = 251) + THEN /* PLSQL Table */ + tab_open := TRUE ; + add_param ( + 'TABLEOPEN:' + || TO_CHAR (v_datatype (v_argcounter)) + || ':' + || TO_CHAR (v_length (v_argcounter)) + || ':' + || TO_CHAR (v_inout (v_argcounter)) + ); + ELSIF (v_datatype (v_argcounter) = 102) + THEN /* REF CURSOR */ + add_param ( + 'CURSOR:' + || TO_CHAR (v_datatype (v_argcounter)) + || ':' + || TO_CHAR (v_length (v_argcounter)) + || ':' + || TO_CHAR (v_inout (v_argcounter)) + ); + ELSE + add_param ( + NVL (v_argumentname (v_argcounter), 'UNKNOWN') + || ':' + || TO_CHAR (v_datatype (v_argcounter)) + || ':' + || TO_CHAR (v_length (v_argcounter)) + || ':' + || TO_CHAR (v_inout (v_argcounter)) + ); + END IF; + + v_argcounter := v_argcounter + 1; + seperator := ','; + END LOOP; + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done DBMS_DESCRIBE'); + END IF; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + IF (rec_open) + THEN + add_param ('RECORDEND:0:0:0'); + rec_open := FALSE ; + ELSIF (tab_open) + THEN + add_param ('TABLEEND:0:0:0'); + tab_open := FALSE ; + END IF; + + RETURN (outstr); + WHEN OTHERS + THEN + RAISE; + END; + + PROCEDURE print_metadata (metadata sqldata_tab) + IS + BEGIN + FOR i IN 1 .. NVL (metadata.COUNT, 0) + LOOP + DBMS_OUTPUT.put_line ( + 'Name=' + || metadata (i).col_name + || ',Type=' + || TO_CHAR (metadata (i).col_type) + || ',Len=' + || TO_CHAR (metadata (i).col_len) + ); + END LOOP; + END; + + PROCEDURE get_metadata_for_cursor ( + proc_name VARCHAR2, + metadata OUT sqldata_tab + ) + IS + params params_tab; + proc_type VARCHAR2 (10); + idx PLS_INTEGER := 1; + pos PLS_INTEGER := 1; + BEGIN + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Start Describe Proc'); + END IF; + + proc_type := describe_proc (proc_name, params); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('End Describe Proc'); + END IF; + + --print_metadata(params); + LOOP + EXIT WHEN (params (pos).col_name = 'CURSOR'); + pos := pos + 1; + END LOOP; + + pos := pos + 2; + + LOOP + EXIT WHEN (params (pos).col_name = 'RECORDEND'); + metadata (idx).col_name := params (pos).col_name; + metadata (idx).col_type := params (pos).col_type; + metadata (idx).col_len := params (pos).col_len; + idx := idx + 1; + pos := pos + 1; + END LOOP; + END; + + PROCEDURE get_metadata_for_query ( + query_txt VARCHAR2, + metadata OUT sqldata_tab + ) + IS + cols DBMS_SQL.desc_tab; + ncols PLS_INTEGER; + cur INTEGER := DBMS_SQL.open_cursor; + BEGIN + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Query=' || query_txt); + END IF; + + DBMS_SQL.parse (cur, query_txt, DBMS_SQL.native); + DBMS_SQL.describe_columns (cur, ncols, cols); + + FOR i IN 1 .. cols.COUNT + LOOP + metadata (i).col_name := cols (i).col_name; + metadata (i).col_type := cols (i).col_type; + metadata (i).col_len := cols (i).col_max_len; + END LOOP; + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done get_metadata_for_query'); + END IF; + END; + + PROCEDURE get_metadata_for_table ( + table_name VARCHAR2, + metadata OUT sqldata_tab + ) + IS + BEGIN + get_metadata_for_query ('select * from ' || table_name, metadata); + END; + + PROCEDURE get_metadata_for_proc ( + proc_name VARCHAR2, + POSITION INTEGER, + data_type OUT VARCHAR2, + metadata OUT sqldata_tab + ) + IS + outstr VARCHAR2 (3000) := NULL; + seperator VARCHAR2 (10) := NULL; + v_overload DBMS_DESCRIBE.number_table; + v_position DBMS_DESCRIBE.number_table; + v_level DBMS_DESCRIBE.number_table; + v_argumentname DBMS_DESCRIBE.varchar2_table; + v_datatype DBMS_DESCRIBE.number_table; + v_defaultvalue DBMS_DESCRIBE.number_table; + v_inout DBMS_DESCRIBE.number_table; + v_length DBMS_DESCRIBE.number_table; + v_precision DBMS_DESCRIBE.number_table; + v_scale DBMS_DESCRIBE.number_table; + v_radix DBMS_DESCRIBE.number_table; + v_spare DBMS_DESCRIBE.number_table; + v_argcounter PLS_INTEGER := 1; + curr_level PLS_INTEGER := 1; + prev_level PLS_INTEGER := 1; + tab_open BOOLEAN := FALSE ; + rec_open BOOLEAN := FALSE ; + pos PLS_INTEGER; + idx PLS_INTEGER := 1; + recs_copied PLS_INTEGER; + + FUNCTION get_datatype (l_type INTEGER) + RETURN VARCHAR2 + IS + r_type VARCHAR2 (20); + BEGIN + -- Need to add more data types + SELECT DECODE ( + l_type, + 1, 'VARCHAR2', + 2, 'NUMBER', + 12, 'DATE', + 96, 'CHAR', + 102, 'REF CURSOR', + 250, 'RECORD', + 251, 'PLSQL TABLE', + 'UNKNOWN' + ) + INTO r_type + FROM DUAL; + + RETURN (r_type); + END; + + PROCEDURE copy_metadata (l_idx INTEGER) + IS + m_idx INTEGER; + BEGIN + m_idx := metadata.COUNT + 1; + metadata (m_idx).col_name := v_argumentname (l_idx); + metadata (m_idx).col_type := v_datatype (l_idx); + metadata (m_idx).col_len := v_length (l_idx); + END; + + FUNCTION copy_level (l_idx INTEGER) + RETURN INTEGER + IS + l_counter PLS_INTEGER := 1; + l_level PLS_INTEGER; + BEGIN + l_level := v_level (l_idx); + l_counter := l_idx; + + LOOP + EXIT WHEN ( (l_counter > v_argumentname.COUNT) + OR l_level <> v_level (l_counter) + ); + copy_metadata (l_counter); + l_counter := l_counter + 1; + END LOOP; + + RETURN (l_counter - l_idx); + END; + BEGIN + DBMS_DESCRIBE.describe_procedure ( + proc_name, + NULL, + NULL, + v_overload, + v_position, + v_level, + v_argumentname, + v_datatype, + v_defaultvalue, + v_inout, + v_length, + v_precision, + v_scale, + v_radix, + v_spare + ); + + IF (v_position.COUNT = 0) + THEN + data_type := 'NOTFOUND'; + RETURN; + END IF; + + idx := 1; + + LOOP + EXIT WHEN ( ((v_level (idx) = 0) AND (POSITION = v_position (idx))) + OR (idx = v_position.COUNT) + ); + idx := idx + 1; + END LOOP; + + IF (idx = v_position.COUNT) + THEN + IF (POSITION = v_position (idx)) + THEN + data_type := get_datatype (v_datatype (idx)); + + IF (data_type <> 'REF CURSOR') + THEN -- Weak ref cursor + copy_metadata (idx); + END IF; + ELSE + data_type := 'NOTFOUND'; + END IF; + + RETURN; + END IF; + + data_type := get_datatype (v_datatype (idx)); + + --dbms_output.put_line('data_type = '||data_type||','||'Pos='||TO_CHAR(idx)); + + IF (data_type = 'REF CURSOR') + THEN + IF (v_level (idx + 1) > v_level (idx)) + THEN -- Strong ref cursor + idx := idx + 2; + recs_copied := copy_level (idx); + idx := idx + recs_copied; + END IF; + ELSIF (data_type = 'PLSQL TABLE') + THEN + IF (v_level (idx + 1) > v_level (idx)) + THEN + IF (v_datatype (idx + 1) = 250) + THEN -- RECORD + idx := idx + 2; -- PLSQL TABLE OF RECORD (user defined) + ELSE + idx := idx + 1; -- PLSQL TABLE OF SINGLE COLUMN + END IF; + + recs_copied := copy_level (idx); + idx := idx + recs_copied; + ELSE + copy_metadata (idx); + END IF; + ELSIF (data_type = 'RECORD') + THEN + IF (v_level (idx + 1) > v_level (idx)) + THEN -- I think always true. + idx := idx + 1; + recs_copied := copy_level (idx); + idx := idx + recs_copied; + ELSE -- I guess it should never come here + copy_metadata (idx); + END IF; + ELSE + data_type := get_datatype (v_datatype (idx)); + copy_metadata (idx); + END IF; + END; + + PROCEDURE test_get_metadata_for_cursor (proc_name VARCHAR2) + IS + metadata sqldata_tab; + BEGIN + get_metadata_for_cursor (proc_name, metadata); + + IF (utplsql.tracing) + THEN + print_metadata (metadata); + END IF; + END; + + FUNCTION get_colnamesstr (metadata sqldata_tab) + RETURN VARCHAR2 + IS + cnt PLS_INTEGER; + str VARCHAR2 (32000); + BEGIN + cnt := metadata.COUNT; + + FOR i IN 1 .. cnt + LOOP + str := str || metadata (i).col_name || ','; + END LOOP; + + RETURN (SUBSTR (str, 1, LENGTH (str) - 1)); + END; + + FUNCTION get_coltypesstr (metadata sqldata_tab) + RETURN VARCHAR2 + IS + cnt PLS_INTEGER; + str VARCHAR2 (2000); + BEGIN + cnt := metadata.COUNT; + + FOR i IN 1 .. cnt + LOOP + str := str || TO_CHAR (metadata (i).col_type) || ','; + END LOOP; + + RETURN (SUBSTR (str, 1, LENGTH (str) - 1)); + END; + + FUNCTION get_coltype_syntax (col_type PLS_INTEGER, col_len PLS_INTEGER) + RETURN VARCHAR2 + IS + BEGIN + IF (col_type = 1) + THEN + RETURN ('VARCHAR2(' || TO_CHAR (col_len) || ')'); + ELSIF (col_type = 2) + THEN + RETURN ('NUMBER'); + ELSIF (col_type = 12) + THEN + RETURN ('DATE'); + ELSIF (col_type = 96) + THEN + RETURN ('CHAR(' || TO_CHAR (col_len) || ')'); + END IF; + END; + + FUNCTION get_coltype_syntax (col_type VARCHAR2, col_len PLS_INTEGER) + RETURN VARCHAR2 + IS + BEGIN + IF (col_type = 'VARCHAR2') + THEN + RETURN ('VARCHAR2(' || TO_CHAR (col_len) || ')'); + ELSIF (col_type = 'NUMBER') + THEN + RETURN ('NUMBER'); + ELSIF (col_type = 'DATE') + THEN + RETURN ('DATE'); + ELSIF (col_type = 'CHAR') + THEN + RETURN ('CHAR(' || TO_CHAR (col_len) || ')'); + ELSIF (col_type = 'REFC') + THEN + RETURN ('REFC'); + ELSE + RETURN (col_type); + END IF; + END; + + PROCEDURE PRINT (str VARCHAR2) + IS + len PLS_INTEGER; + BEGIN + len := LENGTH (str); + + FOR i IN 1 .. len + LOOP + DBMS_OUTPUT.put_line (SUBSTR (str, (i - 1) * 255, 255)); + END LOOP; + + IF ((len * 255) > LENGTH (str)) + THEN + DBMS_OUTPUT.put_line (SUBSTR (str, len * 255)); + END IF; + END; + + FUNCTION get_proc_name (p_proc_nm VARCHAR2) + RETURN VARCHAR2 + IS + BEGIN + RETURN (SUBSTR (p_proc_nm, 1, INSTR (p_proc_nm, '(') - 1)); + END; + + FUNCTION get_val_for_table ( + table_name VARCHAR2, + col_name VARCHAR2, + col_val OUT VARCHAR2, + col_type OUT NUMBER + ) + RETURN NUMBER + IS + cur PLS_INTEGER := DBMS_SQL.open_cursor; + cols DBMS_SQL.desc_tab; + ncols PLS_INTEGER; + idx PLS_INTEGER := 0; + tvarchar VARCHAR2 (4000); + tchar CHAR (4000); + tdate DATE; + tnumber NUMBER; + stmt VARCHAR2 (200); + vresult PLS_INTEGER; + BEGIN + stmt := 'select * from ' || table_name; + DBMS_SQL.parse (cur, stmt, DBMS_SQL.native); + DBMS_SQL.describe_columns (cur, ncols, cols); + + FOR i IN 1 .. cols.COUNT + LOOP + IF (cols (i).col_type = 1) + THEN + DBMS_SQL.define_column (cur, i, tvarchar, cols (i).col_max_len); + ELSIF (cols (i).col_type = 2) + THEN + DBMS_SQL.define_column (cur, i, tnumber); + ELSIF (cols (i).col_type = 12) + THEN + DBMS_SQL.define_column (cur, i, tdate); + ELSIF (cols (i).col_type = 96) + THEN + DBMS_SQL.define_column (cur, i, tchar, cols (i).col_max_len); + ELSE + raise_application_error (-20000, 'UNSUPPORTED COLUMN TYPE'); + END IF; + + IF (cols (i).col_name = col_name) + THEN + idx := i; + END IF; + END LOOP; + + IF (idx = 0) + THEN + RETURN (-1); + END IF; + + vresult := DBMS_SQL.EXECUTE (cur); + + IF (DBMS_SQL.fetch_rows (cur) = 0) + THEN + RETURN (1); + END IF; + + IF (cols (idx).col_type = 1) + THEN + DBMS_SQL.column_value (cur, idx, tvarchar); + col_val := tvarchar; + ELSIF (cols (idx).col_type = 2) + THEN + DBMS_SQL.column_value (cur, idx, tnumber); + col_val := TO_CHAR (tnumber); + ELSIF (cols (idx).col_type = 12) + THEN + DBMS_SQL.column_value (cur, idx, tdate); + col_val := TO_CHAR (tdate, 'DD-MON-YYYY:HH24:MI:SS'); + ELSIF (cols (idx).col_type = 96) + THEN + DBMS_SQL.column_value (cur, idx, tchar); + col_val := tchar; + END IF; + + col_type := cols (idx).col_type; + DBMS_SQL.close_cursor (cur); + RETURN (0); + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END; + + FUNCTION get_table_name + RETURN VARCHAR2 + IS + tmp_seq NUMBER; + curr_user VARCHAR2 (20); + BEGIN + SELECT SYS_CONTEXT ('USERENV', 'CURRENT_USER') + INTO curr_user + FROM DUAL; + + SELECT ut_refcursor_results_seq.NEXTVAL + INTO tmp_seq + FROM DUAL; + + --RETURN('utplsql_temp_'||tmp_seq); + RETURN (curr_user || '.' || 'UTPLSQL_TEMP_' || tmp_seq); + END; + + PROCEDURE execute_ddl (stmt VARCHAR2) + IS + &start_lt_8_1 + fdbk PLS_INTEGER; + cur PLS_INTEGER := DBMS_SQL.open_cursor; + &end_lt_8_1 + BEGIN + &start_ge_8_1 + EXECUTE IMMEDIATE stmt; + &start_ge_8_1 + &start_lt_8_1 + DBMS_SQL.parse (cur, stmt, DBMS_SQL.native); + fdbk := DBMS_SQL.EXECUTE (cur); + DBMS_SQL.close_cursor (cur); + &end_lt_8_1 + EXCEPTION + WHEN OTHERS + THEN + RAISE; + END; + + FUNCTION get_create_ddl ( + metadata utplsql_util.sqldata_tab, + table_name VARCHAR2, + owner_name VARCHAR2 DEFAULT NULL + ) + RETURN VARCHAR2 + IS + ddl_stmt VARCHAR2 (5000); + cnt PLS_INTEGER; + BEGIN + IF (NVL (metadata.COUNT, 0) = 0) + THEN + RETURN (NULL); + END IF; + + --ddl_stmt := 'create table '||NVL(owner_name,'UTPLSQL')||'.'||table_name||' ( '; + ddl_stmt := 'create table ' || table_name || ' ( '; + + FOR i IN 1 .. metadata.COUNT + LOOP + ddl_stmt := ddl_stmt + || metadata (i).col_name + || ' ' + || utplsql_util.get_coltype_syntax ( + metadata (i).col_type, + metadata (i).col_len + ) + || ','; + END LOOP; + + ddl_stmt := SUBSTR (ddl_stmt, 1, LENGTH (ddl_stmt) - 1) || ')'; + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Current user = ' || USER); + utplsql_util.PRINT (ddl_stmt); + END IF; + + RETURN (ddl_stmt); + END; + + PROCEDURE prepare_cursor_1 ( + stmt IN OUT VARCHAR2, + table_name VARCHAR2, + call_proc_name VARCHAR2, + metadata utplsql_util.sqldata_tab + ) + IS + col_str VARCHAR2 (200); + BEGIN + IF (NVL (metadata.COUNT, 0) = 0) + THEN + RETURN; + END IF; + + stmt := + 'declare + p_result_id PLS_INTEGER; + p_rec_nm PLS_INTEGER := 0; + TYPE refc is ref cursor; + rc refc;'; + + FOR i IN 1 .. metadata.COUNT + LOOP + stmt := stmt + || metadata (i).col_name + || ' ' + || utplsql_util.get_coltype_syntax ( + metadata (i).col_type, + metadata (i).col_len + ) + || ';' + || CHR (10); + END LOOP; + + col_str := utplsql_util.get_colnamesstr (metadata); + stmt := + stmt + || 'BEGIN + rc := ' + || call_proc_name + || '; + LOOP + FETCH rc INTO ' + || col_str + || '; + EXIT WHEN rc%NOTFOUND; + p_rec_nm := p_rec_nm + 1; + INSERT INTO ' + || table_name + || ' (' + || col_str + || ')' + || ' values (' + || col_str + || ');' + || ' + END LOOP; + CLOSE rc; + END;'; + + IF (utplsql.tracing) + THEN + utplsql_util.PRINT (stmt); + END IF; + END; + + FUNCTION get_par_for_decl (params utplsql_params) + RETURN VARCHAR2 + IS + decl VARCHAR2 (1000); + BEGIN + FOR i IN 1 .. params.COUNT + LOOP + decl := decl + || params (i).par_name + || ' ' + || utplsql_util.get_coltype_syntax ( + params (i).par_sql_type, + 1000 + ) + || ';' + || CHR (10); + END LOOP; + + RETURN (decl); + END; + + FUNCTION get_param_valstr (params utplsql_params, POSITION PLS_INTEGER) + RETURN VARCHAR2 + IS + BEGIN + IF (params (POSITION).par_type = 'DATE') + THEN + RETURN ( 'TO_DATE(''' + || params (POSITION).par_val + || ''',''DD-MON-YYYY:HH24:MI:SS'')' + ); + ELSE + RETURN ('''' || params (POSITION).par_val || ''''); + END IF; + END; + + FUNCTION get_param_valstr_from_array ( + params utplsql_params, + POSITION PLS_INTEGER, + array_pos PLS_INTEGER + ) + RETURN VARCHAR2 + IS + BEGIN + IF (params (POSITION).par_type = 'DATE') + THEN + RETURN ( 'TO_DATE(''' + || array_holder (array_pos).array_val + || ''',''DD-MON-YYYY:HH24:MI:SS'')' + ); + ELSE + RETURN ('''' || array_holder (array_pos).array_val || ''''); + END IF; + END; + + PROCEDURE print_utplsql_params (params utplsql_params) + IS + BEGIN + FOR i IN 1 .. params.COUNT + LOOP + DBMS_OUTPUT.put_line ( + 'Name=' + || params (i).par_name + || ',type=' + || params (i).par_type + || ',mode=' + || TO_CHAR (params (i).par_inout) + || ',pos=' + || TO_CHAR (params (i).par_pos) + || ',val=' + || params (i).par_val + ); + END LOOP; + END; + + PROCEDURE init_array_holder + IS + BEGIN + array_holder.DELETE; + END; + + PROCEDURE print_array_holder + IS + BEGIN + DBMS_OUTPUT.put_line ('Printing array holder'); + + FOR i IN 1 .. array_holder.COUNT + LOOP + DBMS_OUTPUT.put_line ('pos=' || TO_CHAR (array_holder (i).array_pos)); + PRINT ('Val=' || array_holder (i).array_val); + END LOOP; + END; + + FUNCTION get_index_for_array (pos INTEGER) + RETURN INTEGER + IS + idx PLS_INTEGER := 1; + BEGIN + LOOP + EXIT WHEN (array_holder (idx).array_pos = pos); + idx := idx + 1; + END LOOP; + + RETURN (idx); + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN (-1); + END; + + FUNCTION get_par_for_assign (params utplsql_params) + RETURN VARCHAR2 + IS + assign VARCHAR2 (1000); + array_idx PLS_INTEGER; + idx PLS_INTEGER := 1; + BEGIN + IF (utplsql.tracing) + THEN + print_array_holder; + END IF; + + FOR i IN 1 .. params.COUNT + LOOP + IF (params (i).par_inout != par_out) + THEN + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ( + 'In get_par_for_assign<' || params (i).par_type || '>' + ); + END IF; + + IF (params (i).par_type != 'ARRAY') + THEN + assign := assign + || params (i).par_name + || ' := ' + || get_param_valstr (params, i) + || ';' + || CHR (10); + ELSE + array_idx := get_index_for_array (params (i).par_pos); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('start index =' || TO_CHAR ( + array_idx + )); + END IF; + + LOOP + BEGIN + EXIT WHEN array_holder (array_idx).array_pos != + params (i).par_pos; + assign := assign + || params (i).par_name + || '(' + || TO_CHAR (idx) + || ') := ' + || get_param_valstr_from_array ( + params, + i, + array_idx + ) + || ';' + || CHR (10); + array_idx := array_idx + 1; + idx := idx + 1; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + EXIT; + END; + END LOOP; + END IF; + END IF; + END LOOP; + + RETURN (assign); + END; + + FUNCTION get_par_for_call (params utplsql_params, proc_name VARCHAR2) + RETURN VARCHAR2 + IS + call_str VARCHAR2 (1000); + start_idx PLS_INTEGER; + BEGIN + IF (params (1).par_pos = 0) + THEN + call_str := params (1).par_name || ' := ' || proc_name || '('; + start_idx := 2; + ELSE + call_str := proc_name || '('; + start_idx := 1; + END IF; + + FOR i IN start_idx .. params.COUNT + LOOP + IF (i != start_idx) + THEN + call_str := call_str || ',' || params (i).par_name; + ELSE + call_str := call_str || params (i).par_name; + END IF; + END LOOP; + + call_str := call_str || ')'; + RETURN (call_str); + END; + + PROCEDURE get_single_param ( + params utplsql_params, + POSITION PLS_INTEGER, + single_param IN OUT params_rec + ) + IS + idx PLS_INTEGER; + BEGIN + IF (POSITION != 0) + THEN + IF (params (1).par_pos = 0) + THEN + idx := POSITION + 1; + ELSE + idx := POSITION; + END IF; + ELSE + idx := POSITION + 1; + END IF; + + single_param.par_name := params (idx).par_name; + single_param.par_type := params (idx).par_type; + single_param.par_val := params (idx).par_val; + single_param.par_inout := params (idx).par_inout; + END; + + PROCEDURE prepare_cursor_100 ( + stmt IN OUT VARCHAR2, + table_name VARCHAR2, + call_proc_name VARCHAR2, + POSITION PLS_INTEGER, + metadata utplsql_util.sqldata_tab, + params utplsql_params + ) + IS + col_str VARCHAR2 (32000); + single_param params_rec; + BEGIN + IF (NVL (metadata.COUNT, 0) = 0) + THEN + RETURN; + END IF; + + stmt := + 'declare + p_result_id PLS_INTEGER; + p_rec_nm PLS_INTEGER := 0; + TYPE refc is ref cursor; + rc refc;'; + + FOR i IN 1 .. metadata.COUNT + LOOP + stmt := stmt + || metadata (i).col_name + || ' ' + || utplsql_util.get_coltype_syntax ( + metadata (i).col_type, + metadata (i).col_len + ) + || ';' + || CHR (10); + END LOOP; + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done ref cursor column declarations'); + END IF; + + stmt := stmt || get_par_for_decl (params); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done params declarations'); + END IF; + + get_single_param (params, POSITION, single_param); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done get_single_param'); + END IF; + + col_str := utplsql_util.get_colnamesstr (metadata); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done get_colnamesstr'); + END IF; + + stmt := + stmt + || 'BEGIN + ' + || get_par_for_assign (params) + || ' + ' + || get_par_for_call (params, call_proc_name) + || '; + LOOP + FETCH ' + || single_param.par_name + || ' INTO ' + || col_str + || '; + EXIT WHEN ' + || single_param.par_name + || '%NOTFOUND; + p_rec_nm := p_rec_nm + 1; + INSERT INTO ' + || table_name + || ' (' + || col_str + || ')' + || ' values (' + || col_str + || ');' + || ' + END LOOP; + CLOSE ' + || single_param.par_name + || '; + END;'; + + IF (utplsql.tracing) + THEN + utplsql_util.PRINT (stmt); + END IF; + + init_array_holder; + END; + + FUNCTION prepare_and_fetch_rc (proc_name VARCHAR2) + RETURN VARCHAR2 + IS + vproc_nm VARCHAR2 (50); + metadata utplsql_util.sqldata_tab; + stmt VARCHAR2 (32000); + table_name VARCHAR2 (20); + BEGIN + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Call=' || proc_name); + END IF; + + vproc_nm := utplsql_util.get_proc_name (proc_name); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Proc Name=' || vproc_nm); + END IF; + + utplsql_util.get_metadata_for_cursor (vproc_nm, metadata); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Metadata Done'); + END IF; + + table_name := get_table_name (); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Refcursor Table Name=' || table_name); + END IF; + + stmt := get_create_ddl (metadata, table_name); + + IF (utplsql.tracing) + THEN + utplsql_util.PRINT ('Create ddl=' || stmt); + END IF; + + execute_ddl (stmt); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Table created'); + END IF; + + IF (NVL (metadata.COUNT, 0) = 0) + THEN + RETURN (NULL); + END IF; + + --prepare_cursor_1(stmt,'UTPLSQL'||'.'||table_name,proc_name,metadata); + prepare_cursor_1 (stmt, table_name, proc_name, metadata); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done prepare_cursor_1'); + END IF; + + execute_ddl (stmt); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done execute_ddl'); + END IF; + + --RETURN(USER||'.'||table_name); + RETURN (table_name); + END; + + FUNCTION prepare_and_fetch_rc ( + proc_name VARCHAR2, + params utplsql_params, + refc_pos_in_proc PLS_INTEGER, + refc_metadata_from PLS_INTEGER DEFAULT 1, + refc_metadata_str VARCHAR2 DEFAULT NULL + ) + RETURN VARCHAR2 + IS + metadata utplsql_util.sqldata_tab; + stmt VARCHAR2 (32000); + table_name VARCHAR2 (50); + datatype VARCHAR2 (20); + BEGIN + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('In prepare_and_fetch_rc '); + DBMS_OUTPUT.put_line ('proc name =' || proc_name); + print_utplsql_params (params); + DBMS_OUTPUT.put_line ('Method=' || TO_CHAR (refc_metadata_from)); + PRINT ('refc_metadata_str=' || refc_metadata_str); + --dbms_output.put_line('refc_metadata_str='||refc_metadata_str); + DBMS_OUTPUT.put_line ('Position=' || TO_CHAR (refc_pos_in_proc)); + END IF; + + utplsql_util.get_metadata_for_proc ( + proc_name, + refc_pos_in_proc, + datatype, + metadata + ); + + IF (metadata.COUNT = 0) + THEN + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Weak ref cursor'); + END IF; + + IF (refc_metadata_from = 1) + THEN + utplsql_util.get_metadata_for_table (refc_metadata_str, metadata); + ELSIF (refc_metadata_from = 2) + THEN + utplsql_util.get_metadata_for_query (refc_metadata_str, metadata); + END IF; + END IF; + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done metadata'); + END IF; + + IF (metadata.COUNT = 0) + THEN + DBMS_OUTPUT.put_line ('ERROR: metadata is null'); + RETURN (NULL); + END IF; + + table_name := get_table_name (); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Refcursor Table Name=' || table_name); + END IF; + + stmt := get_create_ddl (metadata, table_name); + + IF (utplsql.tracing) + THEN + utplsql_util.PRINT ('Create ddl=' || stmt); + END IF; + + execute_ddl (stmt); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Table created'); + END IF; + + IF (NVL (metadata.COUNT, 0) = 0) + THEN + RETURN (NULL); + END IF; + + --prepare_cursor_100(stmt,'UTPLSQL'||'.'||table_name,proc_name,refc_pos_in_proc,metadata,params); + prepare_cursor_100 ( + stmt, + table_name, + proc_name, + refc_pos_in_proc, + metadata, + params + ); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done prepare_cursor_1'); + END IF; + + execute_ddl (stmt); + + IF (utplsql.tracing) + THEN + DBMS_OUTPUT.put_line ('Done execute_ddl'); + END IF; + + --RETURN(USER||'.'||table_name); + RETURN (table_name); + END; +END; +/ diff --git a/source/ut_plsql_util.pks b/source/ut_plsql_util.pks new file mode 100644 index 000000000..139a15072 --- /dev/null +++ b/source/ut_plsql_util.pks @@ -0,0 +1,212 @@ +CREATE OR REPLACE PACKAGE utplsql_util +&start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +AS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2003/11/25 13:54:49 chrisrimmer +Added back in AUTHID line + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + TYPE SQLDATA IS RECORD ( + col_name VARCHAR2 (50), + col_type PLS_INTEGER, + col_len PLS_INTEGER + ); + + TYPE sqldata_tab IS TABLE OF SQLDATA + INDEX BY BINARY_INTEGER; + + TYPE params_rec IS RECORD ( + par_name VARCHAR2 (50), + par_type VARCHAR2 (10), + par_sql_type VARCHAR2 (50), + par_inout PLS_INTEGER, + par_pos PLS_INTEGER, + par_val VARCHAR2 (32000) + ); + + TYPE utplsql_array IS RECORD ( + array_pos PLS_INTEGER, + array_val VARCHAR2 (32000) + ); + + TYPE utplsql_params IS TABLE OF params_rec + INDEX BY BINARY_INTEGER; + + TYPE array_table IS TABLE OF utplsql_array + INDEX BY BINARY_INTEGER; + + TYPE ut_refc IS REF CURSOR; + + TYPE v30_table IS TABLE OF VARCHAR2 (30) + INDEX BY BINARY_INTEGER; + + TYPE varchar_array IS TABLE OF VARCHAR2 (4000) + INDEX BY BINARY_INTEGER; + + array_holder array_table; + + PROCEDURE reg_in_param ( + par_pos PLS_INTEGER, + par_val VARCHAR2, + params IN OUT utplsql_params + ); + + PROCEDURE reg_in_array ( + par_pos IN PLS_INTEGER, + array_name IN VARCHAR2, + array_vals IN varchar_array, + params IN OUT utplsql_params + ); + + PROCEDURE reg_in_param ( + par_pos PLS_INTEGER, + par_val NUMBER, + params IN OUT utplsql_params + ); + + PROCEDURE reg_in_param ( + par_pos PLS_INTEGER, + par_val DATE, + params IN OUT utplsql_params + ); + + PROCEDURE reg_inout_param ( + par_pos PLS_INTEGER, + par_val VARCHAR2, + params IN OUT utplsql_params + ); + + PROCEDURE reg_inout_param ( + par_pos PLS_INTEGER, + par_val NUMBER, + params IN OUT utplsql_params + ); + + PROCEDURE reg_inout_param ( + par_pos PLS_INTEGER, + par_val DATE, + params IN OUT utplsql_params + ); + + PROCEDURE reg_out_param ( + par_pos PLS_INTEGER, + par_type VARCHAR2, + params IN OUT utplsql_params + ); + + PROCEDURE get_table_for_str ( + p_arr OUT v30_table, + p_string VARCHAR2, + delim VARCHAR2 := ',', + enclose_str VARCHAR2 DEFAULT NULL + ); + + PROCEDURE get_metadata_for_cursor ( + proc_name VARCHAR2, + metadata OUT sqldata_tab + ); + + PROCEDURE get_metadata_for_query ( + query_txt VARCHAR2, + metadata OUT sqldata_tab + ); + + PROCEDURE get_metadata_for_table ( + table_name VARCHAR2, + metadata OUT sqldata_tab + ); + + PROCEDURE get_metadata_for_proc ( + proc_name VARCHAR2, + POSITION INTEGER, + data_type OUT VARCHAR2, + metadata OUT sqldata_tab + ); + + PROCEDURE test_get_metadata_for_cursor (proc_name VARCHAR2); + + PROCEDURE print_metadata (metadata sqldata_tab); + + FUNCTION get_colnamesstr (metadata sqldata_tab) + RETURN VARCHAR2; + + FUNCTION get_coltypesstr (metadata sqldata_tab) + RETURN VARCHAR2; + + FUNCTION get_coltype_syntax (col_type PLS_INTEGER, col_len PLS_INTEGER) + RETURN VARCHAR2; + + PROCEDURE PRINT (str VARCHAR2); + + FUNCTION get_proc_name (p_proc_nm VARCHAR2) + RETURN VARCHAR2; + + FUNCTION get_version + RETURN VARCHAR2; + + FUNCTION get_val_for_table ( + table_name VARCHAR2, + col_name VARCHAR2, + col_val OUT VARCHAR2, + col_type OUT NUMBER + ) + RETURN NUMBER; + + FUNCTION get_table_name + RETURN VARCHAR2; + + PROCEDURE execute_ddl (stmt VARCHAR2); + + FUNCTION get_create_ddl ( + metadata utplsql_util.sqldata_tab, + table_name VARCHAR2, + owner_name VARCHAR2 DEFAULT NULL + ) + RETURN VARCHAR2; + + PROCEDURE prepare_cursor_1 ( + stmt IN OUT VARCHAR2, + table_name VARCHAR2, + call_proc_name VARCHAR2, + metadata utplsql_util.sqldata_tab + ); + + FUNCTION prepare_and_fetch_rc (proc_name VARCHAR2) + RETURN VARCHAR2; + + FUNCTION prepare_and_fetch_rc ( + proc_name VARCHAR2, + params utplsql_params, + refc_pos_in_proc PLS_INTEGER, + refc_metadata_from PLS_INTEGER DEFAULT 1, + refc_metadata_str VARCHAR2 DEFAULT NULL + ) + RETURN VARCHAR2; +END; +/ diff --git a/source/ut_receq.pkb b/source/ut_receq.pkb new file mode 100644 index 000000000..5037e47bb --- /dev/null +++ b/source/ut_receq.pkb @@ -0,0 +1,318 @@ +CREATE OR REPLACE PACKAGE BODY utreceq +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE delete_receq (id_in ut_receq.id%TYPE) + IS + v_cur PLS_INTEGER := DBMS_SQL.open_cursor; + sql_str VARCHAR2 (2000); + v_cnt PLS_INTEGER; + BEGIN + SELECT COUNT (*) + INTO v_cnt + FROM ut_receq_pkg + WHERE receq_id = id_in AND created_by = USER; + + IF v_cnt < 1 + THEN + SELECT 'DROP FUNCTION ' || test_name + INTO sql_str + FROM ut_receq + WHERE id = id_in AND created_by = USER; + + DBMS_SQL.parse (v_cur, sql_str, DBMS_SQL.native); + DBMS_SQL.close_cursor (v_cur); + END IF; + + DELETE FROM ut_receq + WHERE id = id_in AND created_by = USER; + EXCEPTION + WHEN OTHERS + THEN + utreport.pl (SQLERRM); + DBMS_SQL.close_cursor (v_cur); + utreport.pl ( + 'Delete failed - function probably used by another package' + ); + END; + + FUNCTION id_from_name ( + NAME_IN IN ut_receq.NAME%TYPE, + owner_in IN ut_receq.rec_owner%TYPE := USER + ) + RETURN INTEGER + IS + retval INTEGER; + BEGIN + SELECT id + INTO retval + FROM ut_receq + WHERE NAME = UPPER (NAME_IN) + AND rec_owner = UPPER (owner_in) + AND created_by = USER; + + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END id_from_name; + + FUNCTION name_from_id (id_in IN ut_receq.id%TYPE) + RETURN VARCHAR2 + IS + retval VARCHAR2 (30); + BEGIN + SELECT NAME + INTO retval + FROM ut_receq + WHERE id = id_in; + + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END name_from_id; + + FUNCTION receq_name ( + NAME_IN IN VARCHAR2, + owner_in IN VARCHAR2 DEFAULT USER, + test_name_in IN VARCHAR2 DEFAULT NULL + ) + RETURN VARCHAR2 + IS + retval VARCHAR2 (30); + func_len INTEGER; + BEGIN + IF test_name_in IS NOT NULL + THEN + retval := UPPER (test_name_in); + ELSE + retval := 'eq_'; + + IF owner_in <> USER + THEN + retval := retval || owner_in || '_'; + END IF; + + retval := retval || NAME_IN; + END IF; + + RETURN UPPER (retval); + EXCEPTION + WHEN VALUE_ERROR + THEN + utreport.pl ('Generated test name is too long'); + utreport.pl ( + 'Resubmit with a defined test_name_in=>''EQ_your_name''' + ); + RETURN NULL; + END receq_name; + + PROCEDURE COMPILE (receq_id_in IN ut_receq.id%TYPE) + IS + lines DBMS_SQL.varchar2s; + cur PLS_INTEGER := DBMS_SQL.open_cursor; + v_rec ut_receq%ROWTYPE; + v_schema ut_receq.rec_owner%TYPE; + BEGIN + lines.DELETE; + + SELECT * + INTO v_rec + FROM ut_receq + WHERE id = receq_id_in AND created_by = USER; + + IF v_rec.rec_owner <> USER + THEN + v_schema := v_rec.rec_owner || '.'; + END IF; + + lines (1) := 'CREATE OR REPLACE FUNCTION ' || v_rec.test_name || '('; + lines (lines.LAST + 1) := ' a ' || v_schema || v_rec.NAME || '%ROWTYPE , '; + lines (lines.LAST + 1) := ' b ' || v_schema || v_rec.NAME || '%ROWTYPE ) '; + lines (lines.LAST + 1) := 'RETURN BOOLEAN '; + lines (lines.LAST + 1) := 'IS BEGIN '; + lines (lines.LAST + 1) := ' RETURN ('; + + FOR utc_rec IN (SELECT * + FROM all_tab_columns + WHERE table_name = v_rec.NAME + AND owner = v_rec.rec_owner + ORDER BY column_id) + LOOP + IF utc_rec.column_id > 1 + THEN + lines (lines.LAST + 1) := ' AND '; + END IF; + + lines (lines.LAST + 1) := '( ( a.' + || utc_rec.column_name + || ' IS NULL AND b.' + || utc_rec.column_name + || ' IS NULL ) OR '; + + IF utc_rec.data_type = 'CLOB' + THEN + lines (lines.LAST) := lines (lines.LAST) + || 'DBMS_LOB.COMPARE( a.' + || utc_rec.column_name + || ' , b.' + || utc_rec.column_name + || ') = 0 )'; + ELSE + lines (lines.LAST) := lines (lines.LAST) + || 'a.' + || utc_rec.column_name + || ' = b.' + || utc_rec.column_name + || ')'; + END IF; + END LOOP; + + lines (lines.LAST + 1) := '); END ' || v_rec.test_name || ';'; + DBMS_SQL.parse ( + cur, + lines, + lines.FIRST, + lines.LAST, + TRUE , + DBMS_SQL.native + ); + DBMS_SQL.close_cursor (cur); + END COMPILE; + -- Public Methods + + PROCEDURE ADD ( + pkg_name_in IN ut_package.NAME%TYPE, + record_in IN ut_receq.NAME%TYPE, + rec_owner_in IN ut_receq.created_by%TYPE := USER + ) + IS + v_pkg_id NUMBER; + v_receq_id NUMBER; + v_obj_type user_objects.object_type%TYPE; + v_recname VARCHAR2 (30); + BEGIN + v_pkg_id := utpackage.id_from_name (pkg_name_in); + v_receq_id := id_from_name (record_in); + + IF v_pkg_id IS NULL + THEN + utreport.pl (pkg_name_in || ' does not exist'); + ELSIF v_receq_id IS NULL + THEN + SELECT object_type + INTO v_obj_type + FROM all_objects + WHERE object_name = UPPER (record_in) + AND owner = UPPER (rec_owner_in) + AND object_type IN ('TABLE', 'VIEW'); + + v_receq_id := utplsql.seqval ('ut_receq'); + v_recname := receq_name (record_in, rec_owner_in); + + INSERT INTO ut_receq + VALUES (v_receq_id, UPPER (record_in), v_recname, USER, UPPER ( + rec_owner_in + )); + END IF; + + utreceq.COMPILE (v_receq_id); + utreport.pl (v_recname || ' compiled for ' || v_obj_type || ' ' || record_in); + + BEGIN + INSERT INTO ut_receq_pkg + VALUES (v_receq_id, v_pkg_id, USER); + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + utreport.pl ( + v_recname || ' already registered for package ' || pkg_name_in + ); + END; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + utreport.pl (record_in || ' does not exist in schema ' || rec_owner_in); + END ADD; + + PROCEDURE COMPILE (pkg_name_in IN ut_package.NAME%TYPE) + IS + v_pkg_id NUMBER; + BEGIN + v_pkg_id := utpackage.id_from_name (pkg_name_in); + + FOR j IN (SELECT receq_id + FROM ut_receq_pkg + WHERE pkg_id = v_pkg_id AND created_by = USER) + LOOP + COMPILE (j.receq_id); + END LOOP; + END COMPILE; + + PROCEDURE REM ( + NAME_IN IN ut_receq.NAME%TYPE, + rec_owner_in IN ut_receq.created_by%TYPE, + for_package_in IN BOOLEAN := FALSE + ) + IS + v_pkg_id INTEGER; + v_receq_id INTEGER; + BEGIN + IF for_package_in + THEN + v_pkg_id := utpackage.id_from_name (NAME_IN); + + FOR j IN (SELECT receq_id + FROM ut_receq_pkg + WHERE pkg_id = v_pkg_id) + LOOP + DELETE FROM ut_receq_pkg + WHERE pkg_id = v_pkg_id + AND created_by = USER + AND receq_id = j.receq_id; + + delete_receq (v_receq_id); + END LOOP; + ELSE + v_receq_id := utreceq.id_from_name (NAME_IN, rec_owner_in); + + DELETE FROM ut_receq_pkg + WHERE receq_id = v_receq_id; + + delete_receq (v_receq_id); + END IF; + END REM; +END utreceq; +/ diff --git a/source/ut_receq.pks b/source/ut_receq.pks new file mode 100644 index 000000000..a5d4ca008 --- /dev/null +++ b/source/ut_receq.pks @@ -0,0 +1,66 @@ +CREATE OR REPLACE PACKAGE utreceq &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE add( + + pkg_name_in IN ut_package.name%TYPE , + + record_in IN ut_receq.name%TYPE , + + rec_owner_in IN ut_receq.created_by%TYPE := USER + + ); + + + + PROCEDURE compile( + + pkg_name_in IN ut_package.name%TYPE + + ); + + + + PROCEDURE rem( + + name_in IN ut_receq.name%TYPE, + + rec_owner_in IN ut_receq.created_by%TYPE := USER, + + for_package_in IN BOOLEAN := FALSE + + ); + + + +END utreceq; + +/ + diff --git a/source/ut_receq.tab b/source/ut_receq.tab new file mode 100644 index 000000000..08cc713c4 --- /dev/null +++ b/source/ut_receq.tab @@ -0,0 +1,30 @@ +-- register tables and view that will have record comparison functions created +-- 12/26/01 dws +CREATE TABLE ut_receq ( + id INTEGER, + name VARCHAR2(30), + test_name VARCHAR2(30), + created_by VARCHAR2(30), + rec_owner VARCHAR2(30), + CONSTRAINT ut_receq_pk PRIMARY KEY (id) +); + +CREATE UNIQUE INDEX ut_receq_idx1 ON + ut_receq(rec_owner , name); + + +-- Intersection table between ut_package and ut_receq +CREATE TABLE ut_receq_pkg ( + receq_id integer, + pkg_id INTEGER, + created_by VARCHAR2(30) +); + +ALTER TABLE ut_receq_pkg ADD CONSTRAINT ut_receq_pkg + primary key(receq_id,pkg_id,created_by); + +ALTER TABLE ut_receq_pkg ADD CONSTRAINT ut_receq_pkg_receq_FK + FOREIGN KEY(receq_id) REFERENCES ut_receq(id); + +ALTER TABLE ut_receq_pkg ADD CONSTRAINT ut_receq_pkg_pkg_FK + FOREIGN KEY(pkg_id) REFERENCES ut_package(id); diff --git a/source/ut_receq_seq.seq b/source/ut_receq_seq.seq new file mode 100644 index 000000000..5c8f218f0 --- /dev/null +++ b/source/ut_receq_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_receq_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; \ No newline at end of file diff --git a/source/ut_refcursor_results_seq.seq b/source/ut_refcursor_results_seq.seq new file mode 100644 index 000000000..4afb20e90 --- /dev/null +++ b/source/ut_refcursor_results_seq.seq @@ -0,0 +1 @@ +create sequence ut_refcursor_results_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_report.pkb b/source/ut_report.pkb new file mode 100644 index 000000000..9789bedd9 --- /dev/null +++ b/source/ut_report.pkb @@ -0,0 +1,226 @@ +/* Formatted on 2002/03/31 23:53 (Formatter Plus v4.5.2) */ +CREATE OR REPLACE PACKAGE BODY Utreport +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.1 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + + +************************************************************************/ + + DEFAULT_REPORTER VARCHAR2(100) := 'Output'; + + DYNAMIC_PLSQL_FAILURE NUMBER(10) := -6550; + + --This is the reporter we have been asked to use + g_reporter VARCHAR2(100); + + --This is the reporter we are actually using + --(this differs from the above in the event of error) + g_actual VARCHAR2(100); + + FUNCTION parse_it(proc IN VARCHAR2, params IN NUMBER, force_reporter IN VARCHAR2) + RETURN INTEGER + IS + dyn_handle INTEGER := NULL; + query VARCHAR2(1000); + BEGIN + dyn_handle := DBMS_SQL.OPEN_CURSOR; + QUERY := 'BEGIN ut' || NVL(force_reporter, g_actual) || 'Reporter.' || proc ; + IF params = 1 THEN + QUERY := QUERY || '(:p)'; + END IF; + QUERY := QUERY || '; END;'; + DBMS_SQL.PARSE(dyn_handle, QUERY, DBMS_SQL.NATIVE); + RETURN dyn_handle; + EXCEPTION + WHEN OTHERS THEN + DBMS_SQL.CLOSE_CURSOR (dyn_handle); + RAISE; + END; + + PROCEDURE execute_it(dyn_handle IN OUT INTEGER) + IS + dyn_result INTEGER; + BEGIN + dyn_result := DBMS_SQL.EXECUTE (dyn_handle); + DBMS_SQL.CLOSE_CURSOR (dyn_handle); + END; + + --We use this to make dynamic calls to reporter packages + PROCEDURE call(proc IN VARCHAR2, + param IN VARCHAR2, + params IN NUMBER := 1, + force_reporter IN VARCHAR2 := NULL, + failover IN BOOLEAN := TRUE) + IS + dyn_handle INTEGER := NULL; + BEGIN + dyn_handle := parse_it(proc, params, force_reporter); + IF params = 1 THEN + DBMS_SQL.BIND_VARIABLE (dyn_handle, 'p', param); + END IF; + execute_it(dyn_handle); + EXCEPTION + WHEN OTHERS THEN + + IF dyn_handle IS NOT NULL THEN + DBMS_SQL.CLOSE_CURSOR (dyn_handle); + END IF; + + IF g_actual <> DEFAULT_REPORTER THEN + + IF NOT failover OR SQLCODE <> DYNAMIC_PLSQL_FAILURE THEN + g_actual := DEFAULT_REPORTER; + pl(SQLERRM); + pl('** REVERTING TO DEFAULT REPORTER **'); + END IF; + + ELSE + RAISE; + END IF; + + call(proc, param, params, force_reporter => DEFAULT_REPORTER); + END; + + PROCEDURE call(proc IN VARCHAR2, + failover IN BOOLEAN := TRUE) + IS + BEGIN + call(proc => proc, + param => '', + params => 0, + failover => failover); + END; + + PROCEDURE use(reporter IN VARCHAR2) + IS + BEGIN + g_reporter := NVL(reporter, DEFAULT_REPORTER); + g_actual := g_reporter; + END; + + FUNCTION using RETURN VARCHAR2 + IS + BEGIN + RETURN g_reporter; + END; + + PROCEDURE open + IS + BEGIN + g_actual := g_reporter; + call('open', failover => FALSE); + END; + + PROCEDURE pl (str IN VARCHAR2) + IS + BEGIN + call('pl', str); + END; + + PROCEDURE pl (bool IN BOOLEAN) + IS + BEGIN + pl (Utplsql.bool2vc (bool)); + END; + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + call('before_results', run_id); + END; + + PROCEDURE show_failure(rec_result IN utr_outcome%ROWTYPE) + IS + BEGIN + outcome := rec_result; + call('show_failure'); + END; + + PROCEDURE show_result(rec_result IN utr_outcome%ROWTYPE) + IS + BEGIN + outcome := rec_result; + call('show_result'); + END; + + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE) + IS + BEGIN + call('after_results', run_id); + END; + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + call('before_errors', run_id); + END; + + PROCEDURE show_error(rec_error IN utr_error%ROWTYPE) + IS + BEGIN + error := rec_error; + call('show_error'); + END; + + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE) + IS + BEGIN + call('after_errors', run_id); + END; + + PROCEDURE close + IS + BEGIN + call('close'); + END; + + + /* + proc: before_suite_results + Show suite overall banner and suite run stats + + parameters: + suite_id - suite id + */ + PROCEDURE before_suite_results( + suite_id ut_suite.id%TYPE + ) + IS + BEGIN + call('before_suite_results', suite_id); + END before_suite_results; + +BEGIN + + g_reporter := NVL(utconfig.getreporter, DEFAULT_REPORTER); + g_actual := g_reporter; + +END; +/ diff --git a/source/ut_report.pks b/source/ut_report.pks new file mode 100644 index 000000000..a80d86162 --- /dev/null +++ b/source/ut_report.pks @@ -0,0 +1,54 @@ +CREATE OR REPLACE PACKAGE utreport &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log + +************************************************************************/ + + outcome utr_outcome%ROWTYPE; + error utr_error%ROWTYPE; + + PROCEDURE use(reporter IN VARCHAR2); + FUNCTION using RETURN VARCHAR2; + + PROCEDURE open; + + PROCEDURE pl (str IN VARCHAR2); + PROCEDURE pl (bool IN BOOLEAN); + + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE); + PROCEDURE show_failure(rec_result utr_outcome%ROWTYPE); + PROCEDURE show_result(rec_result utr_outcome%ROWTYPE); + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE); + + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE); + PROCEDURE show_error(rec_error utr_error%ROWTYPE); + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE); + + PROCEDURE close; + + PROCEDURE before_suite_results(suite_id ut_suite.id%TYPE); + +END; +/ diff --git a/source/ut_rerror.pkb b/source/ut_rerror.pkb new file mode 100644 index 000000000..4c01a05bf --- /dev/null +++ b/source/ut_rerror.pkb @@ -0,0 +1,339 @@ +/* Formatted on 2001/07/13 12:30 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utrerror +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION uterrcode (errmsg_in IN VARCHAR2 := NULL) + RETURN INTEGER + IS + BEGIN + -- FORMAT ORA-XXXXXX: UT-300XXX: + IF NVL (errmsg_in, SQLERRM) LIKE 'ORA-_____: ' || c_error_indicator + THEN + RETURN SUBSTR (NVL (errmsg_in, SQLERRM), 15, 6); + ELSE + RETURN NULL; + END IF; + END; + + PROCEDURE raise_error ( + errcode_in IN utr_error.errcode%TYPE, + errtext_in IN utr_error.errtext%TYPE + ) + IS + BEGIN + -- Raise "error reported" + IF errcode_in BETWEEN 300000 AND 399999 + THEN + raise_application_error ( + -20000, + SUBSTR ( 'UT-' + || errcode_in + || ': ' + || errtext_in, 1, 255) + ); + ELSE + raise_application_error ( + -20000, + SUBSTR ( errcode_in + || ': ' + || errtext_in + || '"', 1, 255) + ); + END IF; + END; + + PROCEDURE ins ( + run_id_in IN utr_error.run_id%TYPE := NULL, + suite_id_in IN utr_error.suite_id%TYPE := NULL, + utp_id_in IN utr_error.utp_id%TYPE := NULL, + unittest_id_in IN utr_error.unittest_id%TYPE := NULL, + testcase_id_in IN utr_error.testcase_id%TYPE := NULL, + outcome_id_in IN utr_error.outcome_id%TYPE := NULL, + errlevel_in IN utr_error.errlevel%TYPE := NULL, + errcode_in IN utr_error.errcode%TYPE := NULL, + errtext_in IN utr_error.errtext%TYPE := NULL, + description_in IN utr_error.description%TYPE := NULL, + recorderr IN BOOLEAN := TRUE, + raiseexc IN BOOLEAN := TRUE + ) + IS + l_message VARCHAR2 (2000); + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + BEGIN + -- If error already recorded, simply re-raise. + + IF errtext_in LIKE c_error_indicator + THEN + -- Already recorded. SKip this step. + NULL; + ELSE + IF recorderr + THEN + INSERT INTO utr_error + (run_id, suite_id, utp_id, unittest_id, + testcase_id, outcome_id, errlevel, occurred_on, + errcode, errtext, description) + VALUES (run_id_in, suite_id_in, utp_id_in, unittest_id_in, + testcase_id_in, outcome_id_in, errlevel_in, SYSDATE, + errcode_in, errtext_in, description_in); + ELSE + l_message := 'Error UT-' + || NVL (errcode_in, general_error) + || ': ' + || errtext_in; + + IF errlevel_in IS NOT NULL + THEN + l_message := l_message + || ' ' + || errlevel_in; + END IF; + + IF description_in IS NOT NULL + THEN + l_message := l_message + || ' ' + || description_in; + END IF; + + -- Simply display the error information. + utreport.pl (l_message); + END IF; + END IF; + + &start_ge_8_1 + COMMIT; + + &end_ge_8_1 + + IF raiseexc + THEN + raise_error (errcode_in, errtext_in); + END IF; + &start_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + ROLLBACK; + RAISE; + &end_ge_8_1 + END; + + PROCEDURE report ( + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + errlevel_in IN VARCHAR2 := NULL, + recorderr IN BOOLEAN := TRUE, + raiseexc IN BOOLEAN := TRUE + ) + IS + BEGIN + ins ( + run_id_in=> NULL, + suite_id_in=> NULL, + utp_id_in=> NULL, + unittest_id_in=> NULL, + testcase_id_in=> NULL, + outcome_id_in=> NULL, + errlevel_in=> errlevel_in, + errcode_in=> errcode_in, + errtext_in=> errtext_in, + description_in=> description_in, + recorderr=> recorderr, + raiseexc=> raiseexc + ); + END; + + PROCEDURE report_define_error ( + define_in IN VARCHAR2, + message_in IN VARCHAR2 := NULL + ) + IS + BEGIN + report ( + errcode_in=> SQLCODE, + errtext_in=> SQLERRM, + description_in=> message_in, + errlevel_in=> define_in, + recorderr=> FALSE, + raiseexc=> TRUE + ); + END; + + PROCEDURE assert ( + condition_in IN BOOLEAN, + message_in IN VARCHAR2, + raiseexc IN BOOLEAN := TRUE, + raiseerr IN INTEGER := NULL + ) + IS + BEGIN + IF condition_in IS NULL + OR NOT condition_in + THEN + report ( + errcode_in=> NVL (raiseerr, assertion_failure), + errtext_in=> message_in, + description_in=> NULL, + errlevel_in=> NULL, + recorderr=> FALSE, + raiseexc=> raiseexc + ); + END IF; + END; + + PROCEDURE suite_report ( + run_in IN INTEGER, + suite_in IN ut_suite.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ) + IS + BEGIN + ins ( + run_id_in=> run_in, + suite_id_in=> suite_in, + utp_id_in=> NULL, + unittest_id_in=> NULL, + testcase_id_in=> NULL, + outcome_id_in=> NULL, + errlevel_in=> ututp.c_abbrev, + errcode_in=> errcode_in, + errtext_in=> errtext_in, + description_in=> description_in, + raiseexc=> raiseexc + ); + END; + + PROCEDURE utp_report ( + run_in IN INTEGER, + utp_in IN ut_utp.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ) + IS + BEGIN + ins ( + run_id_in=> run_in, + utp_id_in=> utp_in, + unittest_id_in=> NULL, + testcase_id_in=> NULL, + outcome_id_in=> NULL, + errlevel_in=> ututp.c_abbrev, + errcode_in=> errcode_in, + errtext_in=> errtext_in, + description_in=> description_in, + raiseexc=> raiseexc + ); + END; + + PROCEDURE ut_report ( + run_in IN INTEGER, + unittest_in IN ut_unittest.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ) + IS + BEGIN + ins ( + run_id_in=> run_in, + utp_id_in=> NULL, + unittest_id_in=> unittest_in, + testcase_id_in=> NULL, + outcome_id_in=> NULL, + errlevel_in=> utunittest.c_abbrev, + errcode_in=> errcode_in, + errtext_in=> errtext_in, + description_in=> description_in, + raiseexc=> raiseexc + ); + END; + + PROCEDURE tc_report ( + run_in IN INTEGER, + testcase_in IN ut_testcase.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ) + IS + BEGIN + ins ( + run_id_in=> run_in, + utp_id_in=> NULL, + unittest_id_in=> NULL, + testcase_id_in=> testcase_in, + outcome_id_in=> NULL, + errlevel_in=> uttestcase.c_abbrev, + errcode_in=> errcode_in, + errtext_in=> errtext_in, + description_in=> description_in, + raiseexc=> raiseexc + ); + END; + + PROCEDURE oc_report ( + run_in IN INTEGER, + outcome_in IN ut_outcome.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ) + IS + BEGIN + ins ( + run_id_in=> run_in, + utp_id_in=> NULL, + unittest_id_in=> NULL, + testcase_id_in=> NULL, + outcome_id_in=> outcome_in, + errlevel_in=> utoutcome.c_abbrev, + errcode_in=> errcode_in, + errtext_in=> errtext_in, + description_in=> description_in, + raiseexc=> raiseexc + ); + END; +END utrerror; +/ diff --git a/source/ut_rerror.pks b/source/ut_rerror.pks new file mode 100644 index 000000000..add3bf61a --- /dev/null +++ b/source/ut_rerror.pks @@ -0,0 +1,112 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utrerror &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_error_indicator CONSTANT VARCHAR2 (7) := 'UT-300%'; + general_error CONSTANT INTEGER := 300000; + no_utp_for_program CONSTANT INTEGER := 300001; + cannot_run_program CONSTANT INTEGER := 300002; + undefined_outcome CONSTANT INTEGER := 300003; + undefined_suite CONSTANT INTEGER := 300004; + assertion_failure CONSTANT INTEGER := 300005; + exc_undefined_suite EXCEPTION; + + FUNCTION uterrcode (errmsg_in IN VARCHAR2 := NULL) + RETURN INTEGER; + + PROCEDURE assert ( + condition_in IN BOOLEAN, + message_in IN VARCHAR2, + raiseexc IN BOOLEAN := TRUE, + raiseerr IN INTEGER := NULL + ); + + PROCEDURE report ( + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + errlevel_in IN VARCHAR2 := NULL, + recorderr IN BOOLEAN := TRUE, + raiseexc IN BOOLEAN := TRUE + ); + + -- Generic reporting for definition actions. + -- Passes SQLCODE and SQLERRM, does NOT record the error + PROCEDURE report_define_error ( + define_in IN VARCHAR2, + message_in IN VARCHAR2 := NULL + ); + + PROCEDURE suite_report ( + run_in IN INTEGER, + suite_in IN ut_suite.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ); + + PROCEDURE utp_report ( + run_in IN INTEGER, + utp_in IN ut_utp.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ); + + PROCEDURE ut_report ( + run_in IN INTEGER, + unittest_in IN ut_unittest.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ); + + PROCEDURE tc_report ( + run_in IN INTEGER, + testcase_in IN ut_testcase.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ); + + PROCEDURE oc_report ( + run_in IN INTEGER, + outcome_in IN ut_outcome.id%TYPE, + errcode_in IN INTEGER, + errtext_in IN VARCHAR2 := NULL, + description_in IN VARCHAR2 := NULL, + raiseexc IN BOOLEAN := TRUE + ); +END utrerror; +/ diff --git a/source/ut_result.pkb b/source/ut_result.pkb new file mode 100644 index 000000000..de420f150 --- /dev/null +++ b/source/ut_result.pkb @@ -0,0 +1,311 @@ +CREATE OR REPLACE PACKAGE BODY utresult +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + resultindx PLS_INTEGER; + g_header_shown BOOLEAN := FALSE ; + g_include_successes BOOLEAN := TRUE ; + + PROCEDURE include_successes + IS + BEGIN + g_include_successes := TRUE ; + END; + + PROCEDURE ignore_successes + IS + BEGIN + g_include_successes := FALSE ; + END; + + PROCEDURE showone ( + run_id_in IN utr_outcome.run_id%TYPE := NULL, + indx_in IN PLS_INTEGER + ) + IS + BEGIN + utreport.pl (results (indx_in).NAME || ': ' || results (indx_in).msg); + END; + + PROCEDURE show ( + run_id_in IN utr_outcome.run_id%TYPE := NULL, + reset_in IN BOOLEAN := FALSE + ) + IS + indx PLS_INTEGER := results.FIRST; + l_id utr_outcome.run_id%TYPE := NVL (run_id_in, utplsql2.runnum); + norows BOOLEAN; + BEGIN + + utreport.before_results(run_id_in); + + FOR rec IN (SELECT * + FROM utr_outcome + WHERE run_id = l_id + ORDER BY tc_run_id -- 2.0.9.1 + ) + LOOP + IF rec.status = utplsql.c_success + AND + (NOT NVL (g_include_successes, FALSE ) + -- 2.0.10.1 + OR + utconfig.showingfailuresonly) + THEN + -- Ignore in this case + NULL; + ELSIF utconfig.showingfailuresonly + THEN + utreport.show_failure(rec); + ELSE + utreport.show_result(rec); + END IF; + END LOOP; + + utreport.after_results(run_id_in); + + utreport.before_errors(run_id_in); + + FOR rec IN (SELECT * + FROM utr_error + WHERE run_id = l_id) + LOOP + utreport.show_error(rec); + END LOOP; + + utreport.after_errors(run_id_in); + + IF reset_in + THEN + init; + END IF; + END; + + PROCEDURE showlast (run_id_in IN utr_outcome.run_id%TYPE := NULL) + IS + indx PLS_INTEGER := results.LAST; + BEGIN + -- 2.0.1 showheader; + + IF failure + THEN + showone (run_id_in, indx); + END IF; + END; + + PROCEDURE report (msg_in IN VARCHAR2) + IS + indx PLS_INTEGER := NVL (results.LAST, 0) + 1; + BEGIN + results (indx).NAME := utplsql.currcase.NAME; + results (indx).indx := utplsql.currcase.indx; + results (indx).msg := msg_in; + END; + + PROCEDURE init (from_suite_in IN BOOLEAN := FALSE ) + IS + BEGIN + results.DELETE; + -- Disable functionality + -- IF NOT from_suite_in THEN g_header_shown := FALSE; END IF; + END; + + FUNCTION success (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN BOOLEAN + IS + l_count PLS_INTEGER; + BEGIN + RETURN utresult2.run_succeeded (NVL (run_id_in, utplsql2.runnum)); + END; + + FUNCTION failure (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN BOOLEAN + IS + BEGIN + RETURN (NOT success (run_id_in)); + END; + + PROCEDURE firstresult (run_id_in IN utr_outcome.run_id%TYPE := NULL) + IS + BEGIN + resultindx := results.FIRST; + END; + + FUNCTION nextresult (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN result_rt + IS + BEGIN + /* 1.5.3 Must increment the counter */ + IF resultindx IS NULL + THEN + firstresult; + ELSE + resultindx := results.NEXT (resultindx); + END IF; + + RETURN results (resultindx); + END; + + FUNCTION nthresult ( + indx_in IN PLS_INTEGER, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ) + RETURN result_rt + IS + nullval result_rt; + BEGIN + IF indx_in > resultcount OR NOT results.EXISTS (indx_in) + THEN + RETURN nullval; + ELSE + RETURN results (indx_in); + END IF; + END; + + PROCEDURE nextresult ( + name_out OUT VARCHAR2, + msg_out OUT VARCHAR2, + case_indx_out OUT PLS_INTEGER, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ) + IS + rec result_rt; + BEGIN + rec := nextresult; + name_out := rec.NAME; + msg_out := rec.msg; + case_indx_out := rec.indx; + END; + + PROCEDURE nthresult ( + indx_in IN PLS_INTEGER, + name_out OUT VARCHAR2, + msg_out OUT VARCHAR2, + case_indx_out OUT PLS_INTEGER, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ) + IS + rec result_rt; + BEGIN + rec := nthresult (indx_in); + name_out := rec.NAME; + msg_out := rec.msg; + case_indx_out := rec.indx; + END; + + FUNCTION resultcount (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN PLS_INTEGER + IS + BEGIN + RETURN results.COUNT; + END; + /* + proc: showsuite + Show result for whole suite using reporter + */ + PROCEDURE showsuite( + suite_id ut_suite.id%TYPE + ) + IS + + BEGIN + --show suite banner and statistics + + utreport.before_suite_results(suite_id => suite_id); + + FOR rec IN ( + SELECT utp.last_run_id + FROM ut_package utp + WHERE utp.suite_id = showsuite.suite_id + --same order by as in utplsql.testsuite + ORDER BY utp.seq + ) LOOP + show( + run_id_in => rec.last_run_id, + reset_in => FALSE + ); + END LOOP; + END showsuite; + + FUNCTION suite_success ( + suite_id ut_suite.id%TYPE + ) + RETURN BOOLEAN + IS + BEGIN + RETURN utresult2.suite_succeded(suite_id => suite_id); + END suite_success; + + FUNCTION suite_failure( + suite_id ut_suite.id%TYPE + ) + RETURN BOOLEAN + IS + BEGIN + RETURN (NOT suite_success(suite_id => suite_id)); + END suite_failure; + + /* + func: get_suite_stats + return statistic on last run of suite. + Statistic consist of: + -number of packages + -number of packages succeeded + -number of asserts + -number of asserts succeeded + params: + suite_id - suite id + */ + FUNCTION get_suite_stats( + suite_id ut_suite.id%TYPE + ) RETURN TSuiteStats + IS + Stats TSuiteStats; + BEGIN + SELECT COUNT(utp.id) total_cnt, + SUM(decode(utp.last_status,utresult2.c_success,1,0)) succeeded_cnt + INTO Stats.totalpackages, + stats.succeededpackages + FROM ut_package utp + WHERE utp.suite_id = get_suite_stats.suite_id; + + SELECT COUNT(o.tc_run_id), + SUM(decode(o.status,utresult2.c_success,1,0)) + INTO Stats.totalasserts, + Stats.succeededasserts + FROM utr_outcome o, + ut_package utp + WHERE o.run_id = utp.last_run_id + AND utp.suite_id = get_suite_stats.suite_id; + + RETURN Stats; + END get_suite_stats; + +END utresult; +/ diff --git a/source/ut_result.pks b/source/ut_result.pks new file mode 100644 index 000000000..e78e02944 --- /dev/null +++ b/source/ut_result.pks @@ -0,0 +1,124 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utresult +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + /* Test result record structure */ + TYPE result_rt IS RECORD ( + name VARCHAR2 (100), + msg VARCHAR2 (32767), + indx PLS_INTEGER, + status BOOLEAN /* V2 */); + + TYPE result_tt IS TABLE OF result_rt + INDEX BY BINARY_INTEGER; + + results result_tt; + + TYPE TSuiteStats IS RECORD( + totalpackages PLS_INTEGER, + succeededpackages PLS_INTEGER, + totalasserts PLS_INTEGER, + succeededasserts PLS_INTEGER + ); + + PROCEDURE report (msg_in IN VARCHAR2); + + PROCEDURE show ( + run_id_in IN utr_outcome.run_id%TYPE := NULL, + reset_in IN BOOLEAN := FALSE + ); + + PROCEDURE showone ( + run_id_in IN utr_outcome.run_id%TYPE := NULL, + indx_in IN PLS_INTEGER + ); + + PROCEDURE showlast (run_id_in IN utr_outcome.run_id%TYPE := NULL); + + PROCEDURE init (from_suite_in IN BOOLEAN := FALSE); + + FUNCTION success (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN BOOLEAN; + + FUNCTION failure (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN BOOLEAN; + + PROCEDURE firstresult (run_id_in IN utr_outcome.run_id%TYPE := NULL); + + FUNCTION nextresult (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN result_rt; + + PROCEDURE nextresult ( + name_out OUT VARCHAR2, + msg_out OUT VARCHAR2, + case_indx_out OUT PLS_INTEGER, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ); + + FUNCTION nthresult ( + indx_in IN PLS_INTEGER, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ) + RETURN result_rt; + + PROCEDURE nthresult ( + indx_in IN PLS_INTEGER, + name_out OUT VARCHAR2, + msg_out OUT VARCHAR2, + case_indx_out OUT PLS_INTEGER, + run_id_in IN utr_outcome.run_id%TYPE := NULL + ); + + FUNCTION resultcount (run_id_in IN utr_outcome.run_id%TYPE := NULL) + RETURN PLS_INTEGER; + + procedure include_successes; + procedure ignore_successes; + + PROCEDURE showsuite( + suite_id ut_suite.id%TYPE + ); + + FUNCTION suite_success ( + suite_id ut_suite.id%TYPE + ) + RETURN BOOLEAN; + + FUNCTION suite_failure( + suite_id ut_suite.id%TYPE + ) + RETURN BOOLEAN; + + FUNCTION get_suite_stats( + suite_id ut_suite.id%TYPE + ) RETURN TSuiteStats; + +END utresult; +/ diff --git a/source/ut_result2.pkb b/source/ut_result2.pkb new file mode 100644 index 000000000..519ba1264 --- /dev/null +++ b/source/ut_result2.pkb @@ -0,0 +1,355 @@ +CREATE OR REPLACE PACKAGE BODY utresult2 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE report ( + outcome_in IN ut_outcome.ID%TYPE + ,description_in IN VARCHAR2 + ) + IS + BEGIN + NULL; + END; + + PROCEDURE report ( + outcome_in IN ut_outcome.ID%TYPE + ,test_failed_in IN BOOLEAN + ,description_in IN VARCHAR2 + ,register_in IN BOOLEAN := TRUE + , -- v1 compatibility + showresults_in IN BOOLEAN := FALSE -- v1 compatibility + ) + IS + l_id utr_outcome.outcome_id%TYPE := outcome_in; + l_description utr_outcome.description%TYPE := substr(description_in,1,2000); + BEGIN + IF utplsql2.tracing + THEN + utreport.pl ('Record outcome result:'); + utreport.pl (utplsql2.runnum); + utreport.pl (utplsql2.tc_runnum); + utreport.pl (outcome_in); + utreport.pl (test_failed_in); + utreport.pl (description_in); + END IF; + + IF register_in + THEN + IF l_id IS NULL + THEN + -- v1 compatibility. Create an outcome ID and + -- construct the message to match screen output. + l_id := utroutcome.next_v1_id (utplsql2.runnum); + l_description := substr(utplsql.currcase.NAME || ': ' || l_description,1,2000); + END IF; + + utroutcome.RECORD (utplsql2.runnum + ,utplsql2.tc_runnum + , -- 2.0.9.1 + l_id + ,test_failed_in + ,description_in + ); + END IF; + + -- v1 compatibility and output to screen + IF test_failed_in + THEN + IF register_in + THEN + utresult.report (description_in); + ELSE + utreport.pl (description_in); + END IF; + + IF showresults_in AND register_in + THEN + utresult.showlast; + END IF; + END IF; + END; + + -- NOTE: the logic in the following function is REPEATED three times. + -- Need to move to cursor variables or dynamic SQL. + + FUNCTION run_succeeded (runnum_in IN utr_outcome.run_id%TYPE) + RETURN BOOLEAN + /* A run succeeds if + a. there are no FAILUREs + b. there are no errors + */ + IS + l_val CHAR (1); + success_found BOOLEAN; + failure_found BOOLEAN; + + CURSOR err_cur + IS + SELECT 'x' + FROM utr_error + WHERE run_id = runnum_in; + + CURSOR stat_cur (status_in IN VARCHAR2) + IS + SELECT 'x' + FROM utr_outcome + WHERE run_id = runnum_in AND status LIKE status_in; + BEGIN + -- start: same for all *_succeeded programs + OPEN err_cur; + FETCH err_cur INTO l_val; + failure_found := err_cur%FOUND; + + IF NOT failure_found + THEN + OPEN stat_cur (c_success); + FETCH stat_cur INTO l_val; + success_found := stat_cur%FOUND; + CLOSE stat_cur; + OPEN stat_cur (c_failure); + FETCH stat_cur INTO l_val; + failure_found := stat_cur%FOUND; + CLOSE stat_cur; + END IF; + + IF NOT failure_found AND NOT success_found + THEN + RETURN NULL; -- Nothing was run. + ELSE + RETURN NOT failure_found; + END IF; + -- end: same for all *_succeeded programs + END run_succeeded; + + FUNCTION run_status (runnum_in IN utr_outcome.run_id%TYPE) + RETURN VARCHAR2 + IS + BEGIN + IF run_succeeded (runnum_in) + THEN + RETURN c_success; + ELSE + RETURN c_failure; + END IF; + END; + + FUNCTION utp_succeeded ( + runnum_in IN utr_outcome.run_id%TYPE + ,utp_in IN utr_utp.utp_id%TYPE + ) + RETURN BOOLEAN + IS + l_val CHAR (1); + success_found BOOLEAN; + failure_found BOOLEAN; + + CURSOR err_cur + IS + SELECT 'x' + FROM utr_error + WHERE run_id = runnum_in + AND utp_id = utp_in + AND errlevel = ututp.c_abbrev; + + CURSOR stat_cur (status_in IN VARCHAR2) + IS + SELECT 'x' + FROM utr_outcome + WHERE run_id = runnum_in + AND utoutcome.utp (outcome_id) = utp_in + AND status LIKE status_in; + BEGIN + OPEN err_cur; + FETCH err_cur INTO l_val; + failure_found := err_cur%FOUND; + + IF NOT failure_found + THEN + OPEN stat_cur (c_success); + FETCH stat_cur INTO l_val; + success_found := stat_cur%FOUND; + CLOSE stat_cur; + OPEN stat_cur (c_failure); + FETCH stat_cur INTO l_val; + failure_found := stat_cur%FOUND; + CLOSE stat_cur; + END IF; + + IF NOT failure_found AND NOT success_found + THEN + RETURN NULL; -- Nothing was run. + ELSE + RETURN NOT failure_found; + END IF; + END utp_succeeded; + + FUNCTION utp_status ( + runnum_in IN utr_outcome.run_id%TYPE + ,utp_in IN utr_utp.utp_id%TYPE + ) + RETURN VARCHAR2 + IS + BEGIN + IF utp_succeeded (runnum_in, utp_in) + THEN + RETURN c_success; + ELSE + RETURN c_failure; + END IF; + END; + + FUNCTION unittest_succeeded ( + runnum_in IN utr_outcome.run_id%TYPE + ,unittest_in IN utr_unittest.unittest_id%TYPE + ) + RETURN BOOLEAN + IS + l_val CHAR (1); + success_found BOOLEAN; + failure_found BOOLEAN; + + CURSOR err_cur + IS + SELECT 'x' + FROM utr_error + WHERE run_id = runnum_in + AND unittest_id = unittest_in + AND errlevel = utunittest.c_abbrev; + + CURSOR stat_cur (status_in IN VARCHAR2) + IS + SELECT 'x' + FROM utr_outcome + WHERE run_id = runnum_in + AND utoutcome.unittest (outcome_id) = unittest_in + AND status LIKE status_in; + BEGIN + OPEN err_cur; + FETCH err_cur INTO l_val; + failure_found := err_cur%FOUND; + + IF NOT failure_found + THEN + OPEN stat_cur (c_success); + FETCH stat_cur INTO l_val; + success_found := stat_cur%FOUND; + CLOSE stat_cur; + OPEN stat_cur (c_failure); + FETCH stat_cur INTO l_val; + failure_found := stat_cur%FOUND; + CLOSE stat_cur; + END IF; + + IF NOT failure_found AND NOT success_found + THEN + RETURN NULL; -- Nothing was run. + ELSE + RETURN NOT failure_found; + END IF; + END unittest_succeeded; + + FUNCTION unittest_status ( + runnum_in IN utr_outcome.run_id%TYPE + ,unittest_in IN utr_unittest.unittest_id%TYPE + ) + RETURN VARCHAR2 + IS + BEGIN + IF unittest_succeeded (runnum_in, unittest_in) + THEN + RETURN c_success; + ELSE + RETURN c_failure; + END IF; + END; + + FUNCTION results_headers (schema_in IN VARCHAR2, program_in IN VARCHAR2) + RETURN utconfig.refcur_t + IS + retval utconfig.refcur_t; + BEGIN + OPEN retval FOR + SELECT run_id, start_on, end_on, status + FROM ut_utp utp, utr_utp utpr + WHERE utp.ID = utpr.utp_id + AND utp.program = UPPER (program_in) + AND utp.owner = UPPER (schema_in) + ORDER BY end_on; + RETURN retval; + END results_headers; + + FUNCTION results_details ( + run_id_in IN utr_utp.run_id%TYPE + ,show_failures_only_in IN ut_config.show_failures_only%TYPE + ) + RETURN utconfig.refcur_t + IS + retval utconfig.refcur_t; + BEGIN + OPEN retval FOR + SELECT start_on, end_on, status, description + FROM utr_outcome + WHERE run_id = run_id_in + AND ( show_failures_only_in = 'N' + OR (show_failures_only_in = 'Y' AND status = 'FAILURE' + ) + ) + ORDER BY start_on; + RETURN retval; + END results_details; + /* + func: suite_succeded + Return TRUE if last run for all packages of suite was successfull + otherwise return FALSE + + parameters: + suuite_id + */ + FUNCTION suite_succeded( + suite_id ut_suite.id%TYPE + ) + RETURN BOOLEAN + IS + res BOOLEAN := TRUE; + BEGIN + FOR rec IN ( + SELECT u.last_run_id + FROM ut_package u + WHERE u.suite_id = suite_succeded.suite_id + ) LOOP + res := res AND run_succeeded(runnum_in => rec.last_run_id); + IF NOT res THEN + EXIT; + END IF; + END LOOP; + + RETURN res; + END suite_succeded; +END utresult2; +/ diff --git a/source/ut_result2.pks b/source/ut_result2.pks new file mode 100644 index 000000000..dca31aab7 --- /dev/null +++ b/source/ut_result2.pks @@ -0,0 +1,110 @@ +CREATE OR REPLACE PACKAGE utresult2 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_success CONSTANT CHAR (7) := 'SUCCESS'; + c_failure CONSTANT CHAR (7) := 'FAILURE'; + + /* Test result record structure */ + TYPE result_rt IS RECORD ( + NAME VARCHAR2 (100) + ,msg VARCHAR2 (32767) + ,indx PLS_INTEGER + ); + + TYPE result_tt IS TABLE OF result_rt + INDEX BY BINARY_INTEGER; + + CURSOR results_header_cur (schema_in IN VARCHAR2, program_in IN VARCHAR2) + IS + SELECT run_id, start_on, end_on, status + FROM ut_utp utp, utr_utp utpr + WHERE utp.ID = utpr.utp_id + AND utp.program = program_in + AND utp.owner = schema_in; + + PROCEDURE report ( + outcome_in IN ut_outcome.ID%TYPE + ,description_in IN VARCHAR2 + ); + + PROCEDURE report ( + outcome_in IN ut_outcome.ID%TYPE + ,test_failed_in IN BOOLEAN + ,description_in IN VARCHAR2 + ,register_in IN BOOLEAN := TRUE + , -- v1 compatibility + showresults_in IN BOOLEAN := FALSE -- v1 compatibility + ); + + FUNCTION run_succeeded (runnum_in IN utr_outcome.run_id%TYPE) + RETURN BOOLEAN; + + FUNCTION run_status (runnum_in IN utr_outcome.run_id%TYPE) + RETURN VARCHAR2; + + FUNCTION utp_succeeded ( + runnum_in IN utr_outcome.run_id%TYPE + ,utp_in IN utr_utp.utp_id%TYPE + ) + RETURN BOOLEAN; + + FUNCTION utp_status ( + runnum_in IN utr_outcome.run_id%TYPE + ,utp_in IN utr_utp.utp_id%TYPE + ) + RETURN VARCHAR2; + + FUNCTION unittest_succeeded ( + runnum_in IN utr_outcome.run_id%TYPE + ,unittest_in IN utr_unittest.unittest_id%TYPE + ) + RETURN BOOLEAN; + + FUNCTION unittest_status ( + runnum_in IN utr_outcome.run_id%TYPE + ,unittest_in IN utr_unittest.unittest_id%TYPE + ) + RETURN VARCHAR2; + + FUNCTION results_headers (schema_in IN VARCHAR2, program_in IN VARCHAR2) + RETURN utconfig.refcur_t; + + FUNCTION results_details ( + run_id_in IN utr_utp.run_id%TYPE + ,show_failures_only_in IN ut_config.show_failures_only%TYPE + ) + RETURN utconfig.refcur_t; + + FUNCTION suite_succeded( + suite_id ut_suite.id%TYPE + ) + RETURN BOOLEAN; +END utresult2; +/ diff --git a/source/ut_routcome.pkb b/source/ut_routcome.pkb new file mode 100644 index 000000000..d5c976d4e --- /dev/null +++ b/source/ut_routcome.pkb @@ -0,0 +1,235 @@ +CREATE OR REPLACE PACKAGE BODY utroutcome +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE initiate ( + run_id_in IN utr_outcome.run_id%TYPE + , outcome_id_in IN utr_outcome.outcome_id%TYPE + , start_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + utplsql2.set_current_outcome (outcome_id_in); + + INSERT INTO utr_outcome + (run_id, outcome_id, start_on + ) + VALUES (run_id_in, outcome_id_in, start_on_in + ); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Run has already been initiated. Ignore... + NULL; + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.oc_report (run_id_in + , outcome_id_in + , SQLCODE + , SQLERRM + , 'Unable to initiate outcome for run ' + || run_id_in + || ' outcome ID ' + || outcome_id_in + ); + END initiate; + + PROCEDURE RECORD ( + run_id_in IN utr_outcome.run_id%TYPE + , tc_run_id_in IN PLS_INTEGER + , outcome_id_in IN utr_outcome.outcome_id%TYPE + , test_failed_in IN BOOLEAN + , description_in IN VARCHAR2 := NULL + , end_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + + &end_ge_8_1 + + CURSOR start_cur (id_in IN utr_outcome.outcome_id%TYPE) + IS + SELECT start_on, end_on + FROM utr_outcome + WHERE run_id = run_id_in AND outcome_id = id_in; + + rec start_cur%ROWTYPE; + l_status utr_outcome.status%TYPE; + BEGIN + -- FALSE means that the test succeeded. + IF test_failed_in + THEN + l_status := utresult2.c_failure; + ELSE + l_status := utresult2.c_success; + END IF; + + OPEN start_cur (outcome_id_in); + FETCH start_cur INTO rec; + + IF start_cur%FOUND AND rec.end_on IS NULL + THEN + UPDATE utr_outcome + SET end_on = end_on_in + , status = l_status + , description = description_in + WHERE run_id = run_id_in AND outcome_id = outcome_id_in; + ELSIF start_cur%FOUND AND rec.end_on IS NOT NULL + THEN + -- Run is already terminated. Ignore... + NULL; + ELSE + INSERT INTO utr_outcome + (run_id, tc_run_id, outcome_id, status + , end_on, description + ) + VALUES (run_id_in, tc_run_id_in, outcome_id_in, l_status + , end_on_in, substr(description_in,1,2000) + ); + + utplsql2.move_ahead_tc_runnum; -- 2.0.9.1 + END IF; + + CLOSE start_cur; + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.oc_report (run_id_in + , outcome_id_in + , SQLCODE + , SQLERRM + , 'Unable to insert or update the utr_outcome table for run ' + || run_id_in + || ' outcome ID ' + || outcome_id_in + ); + END RECORD; + + FUNCTION next_v1_id (run_id_in IN utr_outcome.run_id%TYPE) + RETURN utr_outcome.outcome_id%TYPE + IS + retval utr_outcome.outcome_id%TYPE; + BEGIN + SELECT MIN (outcome_id) + INTO retval + FROM utr_outcome + WHERE run_id = run_id_in; + + retval := LEAST (NVL (retval, 0), 0) - 1; + RETURN retval; + END; + + PROCEDURE clear_results (run_id_in IN utr_outcome.run_id%TYPE) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + DELETE FROM utr_outcome + WHERE run_id = run_id_in; + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + END; + + PROCEDURE clear_results ( + owner_in IN VARCHAR2 + , program_in IN VARCHAR2 + , start_from_in IN DATE + ) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + DELETE FROM utr_outcome + WHERE start_on >= start_from_in + AND run_id IN ( + SELECT r.run_id + FROM utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + END; + + PROCEDURE clear_all_but_last (owner_in IN VARCHAR2, program_in IN VARCHAR2) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + DELETE FROM utr_outcome + WHERE start_on < + (SELECT MAX (o.start_on) + FROM utr_outcome o, utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in + AND o.run_id = r.run_id) + AND run_id IN ( + SELECT r.run_id + FROM utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in); + &start_ge_8_1 + COMMIT; + &start_ge_8_1 + END; +END utroutcome; +/ + diff --git a/source/ut_routcome.pks b/source/ut_routcome.pks new file mode 100644 index 000000000..3c474038c --- /dev/null +++ b/source/ut_routcome.pks @@ -0,0 +1,60 @@ +CREATE OR REPLACE PACKAGE utroutcome +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE RECORD ( + run_id_in IN utr_outcome.run_id%TYPE + , tc_run_id_in IN PLS_INTEGER + , outcome_id_in IN utr_outcome.outcome_id%TYPE + , test_failed_in IN BOOLEAN + , description_in IN VARCHAR2 := NULL + , end_on_in IN DATE := SYSDATE + ); + + PROCEDURE initiate ( + run_id_in IN utr_outcome.run_id%TYPE + , outcome_id_in IN utr_outcome.outcome_id%TYPE + , start_on_in IN DATE := SYSDATE + ); + + FUNCTION next_v1_id (run_id_in IN utr_outcome.run_id%TYPE) + RETURN utr_outcome.outcome_id%TYPE; + + PROCEDURE clear_results (run_id_in IN utr_outcome.run_id%TYPE); + + PROCEDURE clear_results ( + owner_in IN VARCHAR2 + , program_in IN VARCHAR2 + , start_from_in IN DATE + ); + + PROCEDURE clear_all_but_last (owner_in IN VARCHAR2, program_in IN VARCHAR2); +END utroutcome; +/ + diff --git a/source/ut_rsuite.pkb b/source/ut_rsuite.pkb new file mode 100644 index 000000000..174a9342b --- /dev/null +++ b/source/ut_rsuite.pkb @@ -0,0 +1,145 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utrsuite +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE initiate ( + run_id_in IN utr_suite.run_id%TYPE, + suite_id_in IN utr_suite.suite_id%TYPE, + start_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + + BEGIN + utplsql2.set_current_suite (suite_id_in); + + INSERT INTO utr_suite + (run_id, suite_id, start_on) + VALUES (run_id_in, suite_id_in, start_on_in); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Run has already been initiated. Ignore... + NULL; + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.suite_report ( + run_id_in, + suite_id_in, + SQLCODE, + SQLERRM, + 'Unable to initiate suite for run ' + || run_id_in + || ' SUITE ID ' + || suite_id_in + ); + END initiate; + + PROCEDURE terminate ( + run_id_in IN utr_suite.run_id%TYPE, + suite_id_in IN utr_suite.suite_id%TYPE, + end_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + + &end_ge_8_1 + + CURSOR start_cur + IS + SELECT start_on, end_on + FROM utr_suite + WHERE run_id = run_id_in + AND suite_id_in = suite_id; + + rec start_cur%ROWTYPE; + l_status utr_suite.status%TYPE; + BEGIN + l_status := utresult2.run_status (run_id_in); + OPEN start_cur; + FETCH start_cur INTO rec; + + IF start_cur%FOUND + AND rec.end_on IS NULL + THEN + UPDATE utr_suite + SET end_on = end_on_in, + status = l_status + WHERE run_id = run_id_in + AND suite_id_in = suite_id; + ELSIF start_cur%FOUND + AND rec.end_on IS NOT NULL + THEN + -- Run is already terminated. Ignore... + NULL; + ELSE + INSERT INTO utr_suite + (run_id, suite_id, status, end_on) + VALUES (run_id_in, suite_id_in, l_status, end_on_in); + END IF; + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.suite_report ( + run_id_in, + suite_id_in, + SQLCODE, + SQLERRM, + 'Unable to insert or update the utr_suite table for run ' + || run_id_in + || ' SUITE ID ' + || suite_id_in + ); + END terminate; +END utrsuite; +/ diff --git a/source/ut_rsuite.pks b/source/ut_rsuite.pks new file mode 100644 index 000000000..ad39fe58f --- /dev/null +++ b/source/ut_rsuite.pks @@ -0,0 +1,44 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utrsuite +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE terminate ( + run_id_in IN utr_suite.run_id%TYPE, + suite_id_in IN utr_suite.suite_id%TYPE, + end_on_in IN DATE := SYSDATE + ); + + PROCEDURE initiate ( + run_id_in IN utr_suite.run_id%TYPE, + suite_id_in IN utr_suite.suite_id%TYPE, + start_on_in IN DATE := SYSDATE + ); +END utrsuite; +/ diff --git a/source/ut_rtestcase.pkb b/source/ut_rtestcase.pkb new file mode 100644 index 000000000..bbefd44d4 --- /dev/null +++ b/source/ut_rtestcase.pkb @@ -0,0 +1,139 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utrtestcase +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE initiate ( + run_id_in IN utr_testcase.run_id%TYPE, + testcase_id_in IN utr_testcase.testcase_id%TYPE, + start_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + BEGIN + INSERT INTO utr_testcase + (run_id, testcase_id, start_on) + VALUES (run_id_in, testcase_id_in, start_on_in); + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Run has already been initiated. Ignore... + NULL; + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.tc_report ( + run_id_in, + testcase_id_in, + SQLCODE, + SQLERRM, + 'Unable to initiate testcase for run ' + || run_id_in + || ' testcase ID ' + || testcase_id_in + ); + END initiate; + + PROCEDURE terminate ( + run_id_in IN utr_testcase.run_id%TYPE, + testcase_id_in IN utr_testcase.testcase_id%TYPE, + end_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + + &end_ge_8_1 + CURSOR start_cur + IS + SELECT start_on, end_on + FROM utr_testcase + WHERE run_id = run_id_in + AND testcase_id_in = testcase_id; + + rec start_cur%ROWTYPE; + l_status utr_testcase.status%TYPE; + BEGIN + l_status := utresult2.run_status (run_id_in); + OPEN start_cur; + FETCH start_cur INTO rec; + + IF start_cur%FOUND + AND rec.end_on IS NULL + THEN + UPDATE utr_testcase + SET end_on = end_on_in, + status = l_status + WHERE run_id = run_id_in + AND testcase_id_in = testcase_id; + ELSIF start_cur%FOUND + AND rec.end_on IS NOT NULL + THEN + -- Run is already terminated. Ignore... + NULL; + ELSE + INSERT INTO utr_testcase + (run_id, testcase_id, status, end_on) + VALUES (run_id_in, testcase_id_in, l_status, end_on_in); + END IF; + + CLOSE start_cur; + CLOSE start_cur; + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.oc_report ( + run_id_in, + testcase_id_in, + SQLCODE, + SQLERRM, + 'Unable to insert or update the utr_testcase table for run ' + || run_id_in + || ' testcase ID ' + || testcase_id_in + ); + END terminate; +END utrtestcase; +/ diff --git a/source/ut_rtestcase.pks b/source/ut_rtestcase.pks new file mode 100644 index 000000000..bebc37e8b --- /dev/null +++ b/source/ut_rtestcase.pks @@ -0,0 +1,44 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utrtestcase +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE terminate ( + run_id_in IN utr_testcase.run_id%TYPE, + testcase_id_in IN utr_testcase.testcase_id%TYPE, + end_on_in IN DATE := SYSDATE + ); + + PROCEDURE initiate ( + run_id_in IN utr_testcase.run_id%TYPE, + testcase_id_in IN utr_testcase.testcase_id%TYPE, + start_on_in IN DATE := SYSDATE + ); +END utrtestcase; +/ diff --git a/source/ut_runittest.pkb b/source/ut_runittest.pkb new file mode 100644 index 000000000..86c3d7dfb --- /dev/null +++ b/source/ut_runittest.pkb @@ -0,0 +1,147 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utrunittest +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE initiate ( + run_id_in IN utr_unittest.run_id%TYPE, + unittest_id_in IN utr_unittest.unittest_id%TYPE, + start_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + BEGIN + utplsql2.set_current_unittest (unittest_id_in); + + INSERT INTO utr_unittest + (run_id, unittest_id, start_on) + VALUES (run_id_in, unittest_id_in, start_on_in); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Run has already been initiated. Ignore... + NULL; + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.ut_report ( + run_id_in, + unittest_id_in, + SQLCODE, + SQLERRM, + 'Unable to initiate unit test for run ' + || run_id_in + || ' unit test ID ' + || unittest_id_in + ); + END initiate; + + PROCEDURE terminate ( + run_id_in IN utr_unittest.run_id%TYPE, + unittest_id_in IN utr_unittest.unittest_id%TYPE, + end_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + + &end_ge_8_1 + + CURSOR start_cur + IS + SELECT start_on, end_on + FROM utr_unittest + WHERE run_id = run_id_in + AND unittest_id_in = unittest_id; + + rec start_cur%ROWTYPE; + l_status utr_unittest.status%TYPE + := utresult2.unittest_status (run_id_in, unittest_id_in); + BEGIN + OPEN start_cur; + FETCH start_cur INTO rec; + + IF start_cur%FOUND + AND rec.end_on IS NULL + THEN + UPDATE utr_unittest + SET end_on = end_on_in, + status = l_status + WHERE run_id = run_id_in + AND unittest_id_in = unittest_id; + ELSIF start_cur%FOUND + AND rec.end_on IS NOT NULL + THEN + -- Run is already terminated. Ignore... + NULL; + ELSE + INSERT INTO utr_unittest + (run_id, unittest_id, status, start_on, + end_on) + VALUES (run_id_in, unittest_id_in, l_status, SYSDATE, + end_on_in); + END IF; + + CLOSE start_cur; + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.ut_report ( + run_id_in, + unittest_id_in, + SQLCODE, + SQLERRM, + 'Unable to insert or update the utr_unittest table for run ' + || run_id_in + || ' outcome ID ' + || unittest_id_in + ); + END terminate; +END utrunittest; +/ diff --git a/source/ut_runittest.pks b/source/ut_runittest.pks new file mode 100644 index 000000000..51042bb1f --- /dev/null +++ b/source/ut_runittest.pks @@ -0,0 +1,44 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utrunittest +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE terminate ( + run_id_in IN utr_unittest.run_id%TYPE, + unittest_id_in IN utr_unittest.unittest_id%TYPE, + end_on_in IN DATE := SYSDATE + ); + + PROCEDURE initiate ( + run_id_in IN utr_unittest.run_id%TYPE, + unittest_id_in IN utr_unittest.unittest_id%TYPE, + start_on_in IN DATE := SYSDATE + ); +END utrunittest; +/ diff --git a/source/ut_rutp.pkb b/source/ut_rutp.pkb new file mode 100644 index 000000000..17d517abf --- /dev/null +++ b/source/ut_rutp.pkb @@ -0,0 +1,233 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utrutp +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE initiate ( + run_id_in IN utr_utp.run_id%TYPE, + utp_id_in IN utr_utp.utp_id%TYPE, + start_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + + BEGIN + utplsql2.set_current_utp (utp_id_in); + + INSERT INTO utr_utp + (run_id, utp_id, start_on) + VALUES (run_id_in, utp_id_in, start_on_in); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- Run has already been initiated. Ignore... + NULL; + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.utp_report ( + run_id_in, + utp_id_in, + SQLCODE, + SQLERRM, + 'Unable to initiate UTP for run ' + || run_id_in + || ' UTP ID ' + || utp_id_in + ); + END initiate; + + PROCEDURE terminate ( + run_id_in IN utr_utp.run_id%TYPE, + utp_id_in IN utr_utp.utp_id%TYPE, + end_on_in IN DATE := SYSDATE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + + &end_ge_8_1 + + CURSOR start_cur + IS + SELECT start_on, end_on + FROM utr_utp + WHERE run_id = run_id_in + AND utp_id_in = utp_id; + + rec start_cur%ROWTYPE; + l_status utr_utp.status%TYPE; + BEGIN + l_status := utresult2.run_status (run_id_in); + OPEN start_cur; + FETCH start_cur INTO rec; + + IF start_cur%FOUND + AND rec.end_on IS NULL + THEN + UPDATE utr_utp + SET end_on = end_on_in, + status = l_status + WHERE run_id = run_id_in + AND utp_id_in = utp_id; + ELSIF start_cur%FOUND + AND rec.end_on IS NOT NULL + THEN + -- Run is already terminated. Ignore... + NULL; + ELSE + INSERT INTO utr_utp + (run_id, utp_id, status, start_on, end_on) + VALUES (run_id_in, utp_id_in, l_status, end_on_in, end_on_in); + END IF; + + CLOSE start_cur; + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_ge_8_1 + ROLLBACK; + &end_ge_8_1 + utrerror.utp_report ( + run_id_in, + utp_id_in, + SQLCODE, + SQLERRM, + 'Unable to insert or update the utr_utp table for run ' + || run_id_in + || ' outcome ID ' + || utp_id_in + ); + END terminate; + + PROCEDURE clear_results (run_id_in IN utr_utp.run_id%TYPE) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + DELETE FROM utr_utp + WHERE run_id = run_id_in; + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + END; + + PROCEDURE clear_results ( + owner_in IN VARCHAR2 + , program_in IN VARCHAR2 + , start_from_in IN DATE + ) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + DELETE FROM utr_utp + WHERE start_on >= start_from_in + AND run_id IN ( + SELECT r.run_id + FROM utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + END; + + PROCEDURE clear_all_but_last (owner_in IN VARCHAR2, program_in IN VARCHAR2) + IS + &start_ge_8_1 + PRAGMA AUTONOMOUS_TRANSACTION; + &end_ge_8_1 + BEGIN + DELETE FROM utr_utp + WHERE start_on < + (SELECT MAX (r.start_on) + FROM utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in) + AND run_id IN ( + SELECT r.run_id + FROM utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in); + &start_ge_8_1 + COMMIT; + &start_ge_8_1 + END; + + FUNCTION last_run_status (owner_in IN VARCHAR2, program_in IN VARCHAR2) + RETURN utr_utp.status%TYPE + IS + retval utr_utp.status%TYPE; + BEGIN + SELECT status + INTO retval + FROM utr_utp + WHERE (utp_id, start_on) = + (SELECT r.utp_id, MAX (r.start_on) + FROM utr_utp r, ut_utp u + WHERE r.utp_id = u.ID + AND u.owner = owner_in + AND u.program = program_in + GROUP BY r.utp_id) + AND ROWNUM < 2; + + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + +END utrutp; +/ diff --git a/source/ut_rutp.pks b/source/ut_rutp.pks new file mode 100644 index 000000000..95d5f292e --- /dev/null +++ b/source/ut_rutp.pks @@ -0,0 +1,60 @@ +CREATE OR REPLACE PACKAGE utrutp +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE TERMINATE ( + run_id_in IN utr_utp.run_id%TYPE + , utp_id_in IN utr_utp.utp_id%TYPE + , end_on_in IN DATE := SYSDATE + ); + + PROCEDURE initiate ( + run_id_in IN utr_utp.run_id%TYPE + , utp_id_in IN utr_utp.utp_id%TYPE + , start_on_in IN DATE := SYSDATE + ); + + PROCEDURE clear_results (run_id_in IN utr_utp.run_id%TYPE); + + PROCEDURE clear_results ( + owner_in IN VARCHAR2 + , program_in IN VARCHAR2 + , start_from_in IN DATE + ); + + PROCEDURE clear_all_but_last (owner_in IN VARCHAR2, program_in IN VARCHAR2); + + function last_run_status ( + owner_in IN VARCHAR2 + , program_in IN VARCHAR2 + ) + return utr_utp.status%type; +END utrutp; +/ + diff --git a/source/ut_suite.pkb b/source/ut_suite.pkb new file mode 100644 index 000000000..c378fa90e --- /dev/null +++ b/source/ut_suite.pkb @@ -0,0 +1,282 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utsuite +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.6 2004/11/23 14:56:48 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.5 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.4 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.3 2003/12/23 15:30:53 chrisrimmer +Added Jens Schauder's show_suites procedure + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION name_from_id (id_in IN ut_suite.id%TYPE) + RETURN ut_suite.name%TYPE + IS + retval ut_suite.name%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_suite + WHERE id = id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION id_from_name (name_in IN ut_suite.name%TYPE) + RETURN ut_suite.id%TYPE + IS + retval ut_suite.id%TYPE; + BEGIN + SELECT id + INTO retval + FROM ut_suite + WHERE name = UPPER (name_in); + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION onerow (name_in IN ut_suite.name%TYPE) + RETURN ut_suite%ROWTYPE + IS + retval ut_suite%ROWTYPE; + BEGIN + SELECT * + INTO retval + FROM ut_suite + WHERE name = UPPER (name_in); + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN retval; + END; + + PROCEDURE ADD ( + name_in IN ut_suite.name%TYPE, + desc_in IN VARCHAR2 := NULL, + rem_if_exists_in IN BOOLEAN := TRUE, + per_method_setup_in in ut_suite.per_method_setup%type := null + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_id ut_suite.id%TYPE; + BEGIN + utrerror.assert (name_in IS NOT NULL, 'Suite names cannot be null.'); + + &start_ge_8_1 v_id := utplsql.seqval ('ut_suite'); &end_ge_8_1 + &start_lt_8_1 SELECT ut_suite_seq.NEXTVAL INTO v_id FROM dual; &end_lt_8_1 + + INSERT INTO ut_suite + (id, name, description, executions, failures,per_method_setup) + VALUES (v_id, UPPER (name_in), desc_in, 0, 0,per_method_setup_in); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + IF rem_if_exists_in + THEN + rem (name_in); + ADD (name_in, desc_in, per_method_setup_in => per_method_setup_in); + ELSE + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END IF; + WHEN OTHERS + THEN + + IF utrerror.uterrcode = utrerror.assertion_failure + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + raise; + ELSE + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error ( + c_abbrev, + 'Suite ' + || name_in + ); + END IF; + + END; + + PROCEDURE rem (id_in IN ut_suite.id%TYPE) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + BEGIN + -- V1 compatibility + DELETE FROM ut_package + WHERE suite_id = id_in; + + DELETE FROM ut_suite_utp + WHERE suite_id = id_in; + + DELETE FROM ut_suite + WHERE id = id_in; + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Remove suite error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE rem (name_in IN ut_suite.name%TYPE) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_id ut_suite.id%TYPE; + BEGIN + rem (id_from_name (name_in)); + END; + + PROCEDURE upd ( + id_in IN ut_suite.id%TYPE, + start_in DATE, + end_in DATE, + successful_in in BOOLEAN, + per_method_setup_in in ut_suite.per_method_setup%type := null + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + l_status VARCHAR2 (100) := utplsql.c_success; + v_failure PLS_INTEGER := 0; + + PROCEDURE do_upd + IS + BEGIN + UPDATE ut_suite + SET last_status = l_status, + last_start = start_in, + last_end = end_in, + per_method_setup = per_method_setup_in, + executions = NVL (executions, 0) + + 1, + failures = NVL (failures, 0) + + v_failure + WHERE id = id_in; + END; + BEGIN + IF NOT successful_in + THEN + v_failure := 1; + l_status := utplsql.c_failure; + END IF; + + do_upd; + + IF SQL%ROWCOUNT = 0 + THEN + ADD ( + name_in=> name_from_id (id_in), + desc_in=> 'No description for "' + || name_from_id (id_in) + || '"', + rem_if_exists_in=> FALSE, + per_method_setup_in=>per_method_setup_in + ); + do_upd; + END IF; + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Update suite error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE upd ( + name_in IN ut_suite.name%TYPE, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + per_method_setup_in in ut_suite.per_method_setup%type := null + ) + IS + BEGIN + upd (id_from_name (name_in), start_in, end_in, successful_in, + per_method_setup_in); + END; + + FUNCTION suites (name_like_in IN VARCHAR2 := '%') + RETURN utconfig.refcur_t + IS + retval utconfig.refcur_t; + BEGIN + OPEN retval FOR + SELECT * + FROM ut_suite + WHERE NAME LIKE UPPER (name_like_in); + RETURN retval; + EXCEPTION + WHEN OTHERS + THEN + RETURN retval; + END; + + --Simply write out the results of the above to dbms_output + PROCEDURE show_suites (name_like_in IN VARCHAR2 := '%') + IS + indent VARCHAR2(20) := ' '; + suites_cur utconfig.refcur_t; + suite ut_suite%ROWTYPE; + + CURSOR packages_cur (pi_id ut_suite.id%TYPE) IS + SELECT * FROM ut_package + WHERE suite_id = pi_id; + + BEGIN + suites_cur := suites(name_like_in); + + LOOP + FETCH suites_cur INTO suite; + EXIT WHEN suites_cur%NOTFOUND; + dbms_output.put_line(suite.name); + FOR pack IN packages_cur(suite.id) LOOP + dbms_output.put_line(indent || pack.name); + END LOOP; + END LOOP; + END show_suites; + +END utsuite; +/ diff --git a/source/ut_suite.pks b/source/ut_suite.pks new file mode 100644 index 000000000..90da3f0c1 --- /dev/null +++ b/source/ut_suite.pks @@ -0,0 +1,87 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE utsuite -- &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2003/12/23 15:30:54 chrisrimmer +Added Jens Schauder's show_suites procedure + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + /* Test suite API */ + + c_name CONSTANT CHAR (18) := 'TEST SUITE PACKAGE'; + c_abbrev CONSTANT CHAR (5) := 'SUITE'; + + FUNCTION name_from_id (id_in IN ut_suite.id%TYPE) + RETURN ut_suite.name%TYPE; + + FUNCTION id_from_name (name_in IN ut_suite.name%TYPE) + RETURN ut_suite.id%TYPE; + + FUNCTION onerow (name_in IN ut_suite.name%TYPE) + RETURN ut_suite%ROWTYPE; + + PROCEDURE ADD ( + name_in IN ut_suite.name%TYPE, + desc_in IN VARCHAR2 := NULL, + rem_if_exists_in IN BOOLEAN := TRUE, + per_method_setup_in in ut_suite.per_method_setup%type := null + + ); + + PROCEDURE rem (name_in IN ut_suite.name%TYPE); + + PROCEDURE rem (id_in IN ut_suite.id%TYPE); + + PROCEDURE upd ( + name_in IN ut_suite.name%TYPE, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + per_method_setup_in in ut_suite.per_method_setup%type := null + ); + + PROCEDURE upd ( + id_in IN ut_suite.id%TYPE, + start_in DATE, + end_in DATE, + successful_in BOOLEAN, + per_method_setup_in in ut_suite.per_method_setup%type := null + ); + + --Get a ref cursor returning suite details + FUNCTION suites ( + name_like_in IN VARCHAR2 := '%' + ) + RETURN utconfig.refcur_t; + + --Simply write out the results of the above to dbms_output + PROCEDURE show_suites (name_like_in IN VARCHAR2 := '%'); + +END utsuite; +/ diff --git a/source/ut_suite.tab b/source/ut_suite.tab new file mode 100644 index 000000000..7fc835a23 --- /dev/null +++ b/source/ut_suite.tab @@ -0,0 +1,19 @@ +CREATE TABLE ut_suite ( + id INTEGER, + name VARCHAR2(200), + description VARCHAR2(2000), + frequency VARCHAR2(2000), + created_by VARCHAR2(30), + created_on DATE, + executions INTEGER, -- V2 no longer used. see utr_suite + failures INTEGER, -- V2 no longer used. see utr_suite + last_status VARCHAR2(20), -- V2 no longer used. see utr_suite + last_start DATE, -- V2 no longer used. see utr_suite + last_end DATE, -- V2 no longer used. see utr_suite + per_method_setup char(1), -- 2.0.8.1 + CONSTRAINT ut_suite_pk PRIMARY KEY (id) +); + +CREATE unique index ut_suite_idx1 ON + ut_suite (name); + diff --git a/source/ut_suite_seq.seq b/source/ut_suite_seq.seq new file mode 100644 index 000000000..61195ee47 --- /dev/null +++ b/source/ut_suite_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_suite_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_suite_utp.tab b/source/ut_suite_utp.tab new file mode 100644 index 000000000..c22a938b5 --- /dev/null +++ b/source/ut_suite_utp.tab @@ -0,0 +1,11 @@ +create table ut_suite_utp ( +suite_id integer, +utp_id integer, +seq integer +); + +ALTER table ut_suite_utp add CONSTRAINT ut_suite_utp_pk + primary key (suite_id, utp_id); + +REM 2.1 - Allow enable/disable of individual packages in the suite. +ALTER table ut_suite_utp add enabled VARCHAR2(1); diff --git a/source/ut_suiteutp.pkb b/source/ut_suiteutp.pkb new file mode 100644 index 000000000..1054bc599 --- /dev/null +++ b/source/ut_suiteutp.pkb @@ -0,0 +1,194 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utsuiteutp +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2005/01/19 16:10:59 chrisrimmer +Removed AUTHID clauses from package bodies + +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION defined ( + suite_id_in IN ut_suite.id%TYPE, + utp_id_in IN ut_utp.id%TYPE + ) + RETURN BOOLEAN + IS + l_val CHAR (1); + BEGIN + SELECT 'x' + INTO l_val + FROM ut_suite_utp + WHERE suite_id = suite_id_in + AND utp_id_in = utp_id; + RETURN TRUE; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN FALSE; + END; + + FUNCTION seq ( + suite_id_in IN ut_suite.id%TYPE, + utp_id_in IN ut_utp.id%TYPE + ) + RETURN ut_suite_utp.seq%TYPE + IS + retval ut_suite_utp.seq%TYPE; + BEGIN + SELECT seq + INTO retval + FROM ut_suite_utp + WHERE suite_id = suite_id_in + AND utp_id_in = utp_id; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION enabled ( + suite_id_in IN ut_suite.id%TYPE, + utp_id_in IN ut_utp.id%TYPE + ) + RETURN ut_suite_utp.enabled%TYPE + IS + l_val ut_suite_utp.enabled%TYPE; + BEGIN + SELECT enabled + INTO l_val + FROM ut_suite_utp + WHERE suite_id = suite_id_in + AND utp_id_in = utp_id; + RETURN l_val; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + PROCEDURE ADD ( + suite_id_in IN ut_suite.id%TYPE, + utp_id_in IN ut_utp.id%TYPE, + seq_in IN ut_suite_utp.seq%TYPE := NULL + ,enabled_in IN ut_suite_utp.enabled%TYPE := NULL + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + BEGIN + utrerror.assert (suite_id_in IS NOT NULL, 'Suite ID cannot be null.'); + utrerror.assert (utp_id_in IS NOT NULL, 'UTP ID cannot be null.'); + + INSERT INTO ut_suite_utp + (suite_id, utp_id, seq, enabled) + VALUES (suite_id_in, utp_id_in, seq_in, enabled_in); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN DUP_VAL_ON_INDEX + THEN + -- already exists. Just ignore. + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + NULL; + WHEN OTHERS + THEN + IF utrerror.uterrcode = utrerror.assertion_failure + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + raise; + ELSE + + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error ( + c_abbrev, + 'Suite ' + || suite_id_in + || ' UTP ' + || utp_id_in + ); + end if; + END; + + PROCEDURE rem ( + suite_id_in IN ut_suite.id%TYPE, + utp_id_in IN ut_utp.id%TYPE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + BEGIN + DELETE FROM ut_suite_utp + WHERE suite_id = suite_id_in + AND utp_id = utp_id_in; + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Remove suite-utp error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + + FUNCTION utps ( + suite_in in ut_suite.id%TYPE + ) + RETURN utconfig.refcur_t + IS + retval utconfig.refcur_t; + BEGIN + OPEN retval FOR + SELECT u.program, u.name, u.id utp_id, su.enabled + FROM ut_utp u, ut_suite_utp su + WHERE su.suite_id = suite_in + and su.utp_id = u.id; + RETURN retval; + EXCEPTION + WHEN OTHERS + THEN + RETURN retval; + END; + + FUNCTION utps ( + suite_in in ut_suite.name%TYPE + ) + RETURN utconfig.refcur_t + IS + retval utconfig.refcur_t; + BEGIN + return utps (utsuite.id_from_name (suite_in)); + END; +END utsuiteutp; +/ diff --git a/source/ut_suiteutp.pks b/source/ut_suiteutp.pks new file mode 100644 index 000000000..c6f53df24 --- /dev/null +++ b/source/ut_suiteutp.pks @@ -0,0 +1,74 @@ +CREATE OR REPLACE PACKAGE utsuiteutp -- &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_name CONSTANT CHAR (18) := 'SUITE-UTP PACKAGE'; + c_abbrev CONSTANT CHAR (9) := 'SUITE-UTP'; + + FUNCTION defined ( + suite_id_in IN ut_suite.ID%TYPE + ,utp_id_in IN ut_utp.ID%TYPE + ) + RETURN BOOLEAN; + + FUNCTION seq ( + suite_id_in IN ut_suite.ID%TYPE + ,utp_id_in IN ut_utp.ID%TYPE + ) + RETURN ut_suite_utp.seq%TYPE; + + PROCEDURE ADD ( + suite_id_in IN ut_suite.ID%TYPE + ,utp_id_in IN ut_utp.ID%TYPE + ,seq_in IN ut_suite_utp.seq%TYPE := NULL + ,enabled_in IN ut_suite_utp.enabled%TYPE := NULL + ); + + FUNCTION enabled ( + suite_id_in IN ut_suite.ID%TYPE + ,utp_id_in IN ut_utp.ID%TYPE + ) + RETURN ut_suite_utp.enabled%TYPE; + + PROCEDURE REM ( + suite_id_in IN ut_suite.ID%TYPE + ,utp_id_in IN ut_utp.ID%TYPE + ); + + FUNCTION utps ( + suite_in in ut_suite.name%TYPE + ) + RETURN utconfig.refcur_t; + + FUNCTION utps ( + suite_in in ut_suite.id%TYPE + ) + RETURN utconfig.refcur_t; +END utsuiteutp; +/ diff --git a/source/ut_test.pkb b/source/ut_test.pkb new file mode 100644 index 000000000..43c845110 --- /dev/null +++ b/source/ut_test.pkb @@ -0,0 +1,188 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY uttest +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2004/11/23 14:56:48 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION name_from_id (id_in IN ut_test.id%TYPE) + RETURN ut_test.name%TYPE + IS + retval ut_test.name%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_test + WHERE id = id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION id_from_name (name_in IN ut_test.name%TYPE) + RETURN ut_test.id%TYPE + IS + retval ut_test.id%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_test + WHERE name = UPPER (name_in); + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + PROCEDURE ADD ( + package_in IN INTEGER, + test_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_id ut_test.id%TYPE; + BEGIN + &start_ge_8_1 v_id := utplsql.seqval ('ut_test'); &end_ge_8_1 + &start_lt_8_1 SELECT ut_test_seq.NEXTVAL INTO v_id FROM dual; &end_lt_8_1 + + INSERT INTO ut_test + (id, package_id, name, description, + seq) + VALUES (v_id, package_in, UPPER (test_in), desc_in, + NVL (seq_in, 1)); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Add test error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE ADD ( + package_in IN VARCHAR2, + test_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ) + IS + BEGIN + ADD (utpackage.id_from_name (package_in), test_in, desc_in, seq_in); + END; + + PROCEDURE rem (package_in IN INTEGER, test_in IN VARCHAR2) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + BEGIN + DELETE FROM ut_test + WHERE package_id = package_in + AND name LIKE UPPER (test_in); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Remove test error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE rem (package_in IN VARCHAR2, test_in IN VARCHAR2) + IS + BEGIN + rem (utpackage.id_from_name (package_in), test_in); + END; + + PROCEDURE upd ( + package_in IN INTEGER, + test_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_failure PLS_INTEGER := 0; + BEGIN + IF NOT successful_in + THEN + v_failure := 1; + END IF; + + UPDATE ut_test + SET last_start = start_in, + last_end = end_in, + executions = executions + + 1, + failures = failures + + v_failure + WHERE package_id = package_in + AND name = UPPER (test_in); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Update test error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE upd ( + package_in IN VARCHAR2, + test_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ) + IS + BEGIN + upd ( + utpackage.id_from_name (package_in), + test_in, + start_in, + end_in, + successful_in + ); + END; +END uttest; +/ diff --git a/source/ut_test.pks b/source/ut_test.pks new file mode 100644 index 000000000..fdda008e7 --- /dev/null +++ b/source/ut_test.pks @@ -0,0 +1,72 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE uttest -- &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION name_from_id (id_in IN ut_test.id%TYPE) + RETURN ut_test.name%TYPE; + + FUNCTION id_from_name (name_in IN ut_test.name%TYPE) + RETURN ut_test.id%TYPE; + + PROCEDURE ADD ( + package_in IN INTEGER, + test_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ); + + PROCEDURE ADD ( + package_in IN VARCHAR2, + test_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ); + + PROCEDURE rem (package_in IN INTEGER, test_in IN VARCHAR2); + + PROCEDURE rem (package_in IN VARCHAR2, test_in IN VARCHAR2); + + PROCEDURE upd ( + package_in IN INTEGER, + test_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ); + + PROCEDURE upd ( + package_in IN VARCHAR2, + test_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ); +END uttest; +/ diff --git a/source/ut_test.tab b/source/ut_test.tab new file mode 100644 index 000000000..9248386c8 --- /dev/null +++ b/source/ut_test.tab @@ -0,0 +1,19 @@ +CREATE TABLE ut_test ( + id INTEGER , + package_id INTEGER, + name VARCHAR2(200), + description VARCHAR2(2000), + seq INTEGER, + executions INTEGER, + failures INTEGER, + last_start DATE, + last_end DATE, + CONSTRAINT ut_test_pk PRIMARY KEY (id) +); + +CREATE unique index ut_test_idx1 ON + ut_test (name); + +ALTER table ut_test add CONSTRAINT ut_test_package_fk + FOREIGN KEY (package_id) REFERENCES ut_package; + diff --git a/source/ut_test_seq.seq b/source/ut_test_seq.seq new file mode 100644 index 000000000..86b102997 --- /dev/null +++ b/source/ut_test_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_test_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_testcase.pkb b/source/ut_testcase.pkb new file mode 100644 index 000000000..3fb04f5d4 --- /dev/null +++ b/source/ut_testcase.pkb @@ -0,0 +1,187 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY uttestcase +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.5 2004/11/23 14:56:48 chrisrimmer +Moved dbms_pipe code into its own package. Also changed some preprocessor flags + +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2004/07/14 17:01:57 chrisrimmer +Added first version of pluggable reporter packages + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION name_from_id (id_in IN ut_testcase.id%TYPE) + RETURN ut_testcase.name%TYPE + IS + retval ut_testcase.name%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_testcase + WHERE id = id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION id_from_name (name_in IN ut_testcase.name%TYPE) + RETURN ut_testcase.id%TYPE + IS + retval ut_testcase.id%TYPE; + BEGIN + SELECT name + INTO retval + FROM ut_testcase + WHERE name = UPPER (name_in); + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + PROCEDURE ADD ( + test_in IN INTEGER, + testcase_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_id ut_testcase.id%TYPE; + BEGIN + &start_ge_8_1 v_id := utplsql.seqval ('ut_testcase'); &end_ge_8_1 + &start_lt_8_1 SELECT ut_testcase_seq.NEXTVAL INTO v_id FROM dual; &end_lt_8_1 + INSERT INTO ut_testcase + (id, test_id, name, description, + seq) + VALUES (v_id, test_in, UPPER (testcase_in), desc_in, + NVL (seq_in, 1)); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Add test error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE ADD ( + test_in IN VARCHAR2, + testcase_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ) + IS + BEGIN + ADD (uttest.id_from_name (test_in), testcase_in, desc_in, seq_in); + END; + + PROCEDURE rem (test_in IN INTEGER, testcase_in IN VARCHAR2) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + BEGIN + DELETE FROM ut_testcase + WHERE test_id = test_in + AND name LIKE UPPER (testcase_in); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Remove test error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE rem (test_in IN VARCHAR2, testcase_in IN VARCHAR2) + IS + BEGIN + rem (uttest.id_from_name (test_in), testcase_in); + END; + + PROCEDURE upd ( + test_in IN INTEGER, + testcase_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ) + IS + &start_ge_8_1 PRAGMA AUTONOMOUS_TRANSACTION; &end_ge_8_1 + v_failure PLS_INTEGER := 0; + BEGIN + IF NOT successful_in + THEN + v_failure := 1; + END IF; + + UPDATE ut_testcase + SET last_start = start_in, + last_end = end_in, + executions = executions + + 1, + failures = failures + + v_failure + WHERE test_id = test_in + AND name = UPPER (testcase_in); + &start_ge_8_1 COMMIT; &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + utreport.pl ( 'Update test error: ' + || SQLERRM); + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + END; + + PROCEDURE upd ( + test_in IN VARCHAR2, + testcase_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ) + IS + BEGIN + upd ( + uttest.id_from_name (test_in), + testcase_in, + start_in, + end_in, + successful_in + ); + END; +END uttestcase; +/ diff --git a/source/ut_testcase.pks b/source/ut_testcase.pks new file mode 100644 index 000000000..c0ce414cc --- /dev/null +++ b/source/ut_testcase.pks @@ -0,0 +1,75 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE uttestcase -- &start_ge_8_1 AUTHID CURRENT_USER &end_ge_8_1 +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_name CONSTANT CHAR (9) := 'TEST CASE'; + c_abbrev CONSTANT CHAR (3) := 'TC'; + + FUNCTION name_from_id (id_in IN ut_testcase.id%TYPE) + RETURN ut_testcase.name%TYPE; + + FUNCTION id_from_name (name_in IN ut_testcase.name%TYPE) + RETURN ut_testcase.id%TYPE; + + PROCEDURE ADD ( + test_in IN INTEGER, + testcase_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ); + + PROCEDURE ADD ( + test_in IN VARCHAR2, + testcase_in IN VARCHAR2, + desc_in IN VARCHAR2 := NULL, + seq_in IN PLS_INTEGER := NULL + ); + + PROCEDURE rem (test_in IN INTEGER, testcase_in IN VARCHAR2); + + PROCEDURE rem (test_in IN VARCHAR2, testcase_in IN VARCHAR2); + + PROCEDURE upd ( + test_in IN INTEGER, + testcase_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ); + + PROCEDURE upd ( + test_in IN VARCHAR2, + testcase_in IN VARCHAR2, + start_in DATE, + end_in DATE, + successful_in BOOLEAN + ); +END uttestcase; +/ diff --git a/source/ut_testcase.tab b/source/ut_testcase.tab new file mode 100644 index 000000000..258e96f9d --- /dev/null +++ b/source/ut_testcase.tab @@ -0,0 +1,31 @@ +CREATE TABLE ut_testcase ( + id INTEGER, + unittest_id INTEGER, + name VARCHAR2(200), + seq integer DEFAULT 1, + description VARCHAR2(2000), + status VARCHAR2(20), /* ENABLED or DISABLED */ + declarations varchar2(2000), + setup varchar2(2000), + teardown varchar2(2000), + exceptions varchar2(2000), + /* From here down, for v1 compatibility only */ + test_id INTEGER, + prefix VARCHAR2(200), + assertion VARCHAR2(100), + inline_assertion_call CHAR(1) DEFAULT 'N', + executions INTEGER, + failures INTEGER, + last_start DATE, + last_end DATE, + CONSTRAINT ut_testcase_pk PRIMARY KEY (id) +) +/ + +CREATE unique index ut_testcase_idx1 ON + ut_testcase (name); + +ALTER table ut_testcase add CONSTRAINT ut_testcase_unitest_fk + FOREIGN KEY (unittest_id) REFERENCES ut_unittest; + + diff --git a/source/ut_testcase_seq.seq b/source/ut_testcase_seq.seq new file mode 100644 index 000000000..4b608a9a6 --- /dev/null +++ b/source/ut_testcase_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_testcase_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_testprep.pkb b/source/ut_testprep.pkb new file mode 100644 index 000000000..3be4f99e2 --- /dev/null +++ b/source/ut_testprep.pkb @@ -0,0 +1,46 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY uttestprep +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION setup_program (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + return null; + END setup_program; + + FUNCTION teardown_program (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + return null; + END teardown_program; +END; +/ diff --git a/source/ut_testprep.pks b/source/ut_testprep.pks new file mode 100644 index 000000000..922da4b9c --- /dev/null +++ b/source/ut_testprep.pks @@ -0,0 +1,39 @@ +/* Formatted on 2001/07/13 12:29 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE uttestprep +-- NO LONGER USED. +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION setup_program (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; + + FUNCTION teardown_program (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; +END; +/ diff --git a/source/ut_testprep.tab b/source/ut_testprep.tab new file mode 100644 index 000000000..225e0a129 --- /dev/null +++ b/source/ut_testprep.tab @@ -0,0 +1,13 @@ +CREATE TABLE ut_testprep ( +id integer, +type varchar2(20), +name varchar2(200), +action_level varchar2(10), +prep_id integer, +declarations varchar2 (2000), +setup varchar2 (2000), +teardown varchar2 (2000), + CONSTRAINT ut_testprep_pk PRIMARY KEY (id) +); + + diff --git a/source/ut_unittest.pkb b/source/ut_unittest.pkb new file mode 100644 index 000000000..f22ccd547 --- /dev/null +++ b/source/ut_unittest.pkb @@ -0,0 +1,196 @@ +/* Formatted on 2001/07/14 08:45 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY utunittest +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + FUNCTION name ( + ut_in IN ut_unittest%ROWTYPE + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN c_abbrev || utconfig.delimiter || ut_in.id; + END name; + + FUNCTION name ( + id_in IN ut_unittest.id%TYPE + ) + RETURN VARCHAR2 is rec ut_unittest%rowtype; + begin + rec := onerow (id_in); + return name (rec); end; + + +FUNCTION full_name ( + utp_in IN ut_utp%ROWTYPE, + ut_in IN ut_unittest%ROWTYPE + ) + RETURN VARCHAR2 + IS + BEGIN + RETURN ututp.qualified_name (utp_in) || '.' + || name (ut_in.id); + END full_name; + + FUNCTION onerow (id_in IN ut_unittest.id%TYPE) + RETURN ut_unittest%ROWTYPE + IS + retval ut_unittest%ROWTYPE; + empty_rec ut_unittest%ROWTYPE; + BEGIN + SELECT * + INTO retval + FROM ut_unittest + WHERE id = id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN empty_rec; + END; + + FUNCTION program_name (id_in IN ut_unittest.id%TYPE) + RETURN ut_unittest.program_name%TYPE + IS + retval ut_unittest.program_name%TYPE; + BEGIN + SELECT program_name + INTO retval + FROM ut_unittest + WHERE id = id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + END; + + FUNCTION id (name_in IN VARCHAR2) + RETURN ut_unittest.id%TYPE + IS + l_delimiter ut_config.delimiter%TYPE := utconfig.delimiter; + l_loc PLS_INTEGER; + retval ut_unittest.id%TYPE; + BEGIN + l_loc := INSTR (name_in, l_delimiter); + + IF l_loc = 0 + THEN + RETURN NULL; + ELSE + RETURN to_number (SUBSTR (name_in, l_loc + + LENGTH (l_delimiter)) + ); + END IF; + end; + + PROCEDURE ADD ( + utp_id_in IN ut_unittest.utp_id%TYPE, + program_name_in IN ut_unittest.program_name%TYPE, + seq_in IN ut_unittest.seq%TYPE := NULL, + description_in IN ut_unittest.description%TYPE + := NULL + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + l_id ut_unittest.id%TYPE; + BEGIN + SELECT ut_unittest_seq.NEXTVAL + INTO l_id + FROM DUAL; + + INSERT INTO ut_unittest + (id, program_name, seq, + description) + VALUES (l_id, UPPER (program_name_in), seq_in, description_in); + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + IF utrerror.uterrcode = utrerror.assertion_failure + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + ELSE + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error ( + c_abbrev, + 'Unittest for ' + || program_name_in + || ' UTP ID ' + || utp_id_in + ); + END IF; + END; + + PROCEDURE rem ( + name_in IN varchar2 + ) + IS begin rem (id (name_in)); + END; + + PROCEDURE rem (id_in IN ut_unittest.id%TYPE) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + BEGIN + DELETE FROM ut_unittest + WHERE id = id_in; + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + IF utrerror.uterrcode = utrerror.assertion_failure + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + ELSE + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error ( + c_abbrev, + 'Unittest ID ' + || id_in + ); + END IF; + END; +END utunittest; +/ + diff --git a/source/ut_unittest.pks b/source/ut_unittest.pks new file mode 100644 index 000000000..05e684ff7 --- /dev/null +++ b/source/ut_unittest.pks @@ -0,0 +1,77 @@ +/* Formatted on 2001/07/13 17:50 (RevealNet Formatter v4.4.0) */ +CREATE OR REPLACE PACKAGE utunittest +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_name CONSTANT CHAR (9) := 'UNIT TEST'; + c_abbrev CONSTANT CHAR (2) := 'UT'; + + /* UT##NNN */ + FUNCTION name ( + ut_in IN ut_unittest%ROWTYPE + ) + RETURN VARCHAR2; + + /* SCHEMA.UTP##NNN.UT##NNN */ + FUNCTION full_name ( + utp_in IN ut_utp%ROWTYPE, + ut_in IN ut_unittest%ROWTYPE + ) + RETURN VARCHAR2; + + FUNCTION name ( + id_in IN ut_unittest.id%TYPE + ) + RETURN VARCHAR2; + + FUNCTION onerow (id_in IN ut_unittest.id%TYPE) + RETURN ut_unittest%ROWTYPE; + + FUNCTION program_name (id_in IN ut_unittest.id%TYPE) + RETURN ut_unittest.program_name%TYPE; + + FUNCTION id (name_in IN VARCHAR2) + RETURN ut_unittest.id%TYPE; + + PROCEDURE ADD ( + utp_id_in IN ut_unittest.utp_id%TYPE, + program_name_in IN ut_unittest.program_name%TYPE, + seq_in IN ut_unittest.seq%TYPE := NULL, + description_in IN ut_unittest.description%TYPE + := NULL + ); + + PROCEDURE rem ( + name_in IN VARCHAR2 + ); + + PROCEDURE rem (id_in IN ut_unittest.id%TYPE); +END; +/ + diff --git a/source/ut_unittest.tab b/source/ut_unittest.tab new file mode 100644 index 000000000..236deff91 --- /dev/null +++ b/source/ut_unittest.tab @@ -0,0 +1,19 @@ +CREATE TABLE ut_unittest ( +id INTEGER, +utp_id INTEGER, +program_name VARCHAR2(30), +overload INTEGER, /* overloading in the package definition */ +seq INTEGER, +description VARCHAR2(2000), +status VARCHAR2(20), /* ENABLED or DISABLED */ +is_deterministic CHAR(1), +declarations varchar2(2000), +setup varchar2(2000), +teardown varchar2(2000), +exceptions varchar2(2000), + CONSTRAINT ut_unittest_pk PRIMARY KEY (id) +); + +ALTER TABLE ut_unittest ADD CONSTRAINT ut_unittest_utp_fk + FOREIGN KEY (utp_id) REFERENCES ut_utp; + diff --git a/source/ut_unittest_seq.seq b/source/ut_unittest_seq.seq new file mode 100644 index 000000000..f84bfe20b --- /dev/null +++ b/source/ut_unittest_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_unittest_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_utoutput.pkb b/source/ut_utoutput.pkb new file mode 100644 index 000000000..59e471cf5 --- /dev/null +++ b/source/ut_utoutput.pkb @@ -0,0 +1,220 @@ +CREATE OR REPLACE PACKAGE BODY ut_utoutput +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.3 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE clear_buffer + IS + lines number; + buffer DBMS_OUTPUT.CHARARR; + BEGIN + lines := 1000000; + dbms_output.get_lines(buffer, lines); + END; + + PROCEDURE ut_setup + IS + BEGIN + dbms_output.enable(1000000); + END; + + PROCEDURE ut_teardown + IS + BEGIN + NULL; + END; + + PROCEDURE ut_count + IS + BEGIN + + clear_buffer; + + utassert.eq('Count Empty buffer', utoutput.count, 0); + + dbms_output.put_line('XYZ'); + + utassert.eq('Count Single Line', utoutput.count, 1); + + utassert.eq('Count Single Line Still Present', utoutput.count, 1); + + dbms_output.put_line('ABC'); + + utassert.eq('Count Two Lines', utoutput.count, 2); + + clear_buffer; + + END ut_count; + + PROCEDURE ut_extract + IS + + buf dbms_output.CHARARR; + buf2 dbms_output.CHARARR; + + BEGIN + + utoutput.replace; + clear_buffer; + + dbms_output.put_line('Alpha'); + dbms_output.put_line('Beta'); + dbms_output.put_line('Gamma'); + + utoutput.save; + utassert.eq('Pull one line', utoutput.extract(max_lines_in => 1, + save_in => FALSE), 1); + utassert.eq('Pull two lines', utoutput.extract(buffer_out => buf, + max_lines_in => 2, + save_in => FALSE), 2); + utassert.eq('How Many Lines Pulled', buf.COUNT, 2); + utassert.eq('First Line Pulled', buf(buf.FIRST), 'Beta'); + utassert.eq('Second Line Pulled', buf(buf.NEXT(buf.FIRST)), 'Gamma'); + + clear_buffer; + + dbms_output.put_line('Al'); + dbms_output.put_line('Ben'); + dbms_output.put_line('Carol'); + dbms_output.put_line('Donna'); + + utoutput.extract(max_lines_in => 1); + utoutput.extract(buffer_out => buf); + + utassert.eq('2: How Many Lines Pulled', buf.COUNT, 3); + utassert.eq('2: First Line Pulled', buf(buf.FIRST), 'Ben'); + utassert.eq('2: Second Line Pulled', buf(buf.NEXT(buf.FIRST)), 'Carol'); + utassert.eq('2: Third Line Pulled', buf(buf.NEXT(buf.NEXT(buf.FIRST))), 'Donna'); + + utoutput.replace; + + utassert.eq('Count Lines Collected and Replaced', utoutput.COUNT, 4); + + clear_buffer; + + END ut_extract; + + PROCEDURE ut_nextline + IS + BEGIN + + clear_buffer; + + utassert.isnull('NextLine Empty Buffer', utoutput.nextline(raise_exc_in => FALSE, save_in => FALSE)); + utassert.throws('NextLine Empty Buffer with Exception', + 'declare + v varchar2(2000); + begin + v := utoutput.nextline(raise_exc_in => TRUE, save_in => FALSE); + end;', + 'utoutput.EMPTY_OUTPUT_BUFFER'); + + dbms_output.put_line('DEF'); + dbms_output.put_line('GHI'); + + utassert.eq('NextLine Typical 1', utoutput.nextline(raise_exc_in => FALSE, save_in => FALSE), 'DEF'); + utassert.eq('NextLine Typical 2', utoutput.nextline(raise_exc_in => FALSE, save_in => FALSE), 'GHI'); + + utassert.isnull('NextLine Empty Buffer Again', utoutput.nextline(raise_exc_in => FALSE, save_in => FALSE)); + + clear_buffer; + + END ut_nextline; + + PROCEDURE ut_replace + IS + + dummy VARCHAR2(2000); + + BEGIN + + utoutput.replace; + clear_buffer; + + --Put in some text, extract, then replace it + dbms_output.put_line('JKL'); + dummy := utoutput.nextline(raise_exc_in => FALSE, save_in => TRUE); + utoutput.replace; + + --Extract again, but don't save + dummy := utoutput.nextline(raise_exc_in => FALSE, save_in => FALSE); + utassert.eq('NextLine after replace', dummy, 'JKL'); + + --Try replacing when there should be nothing to replace + utoutput.replace; + + dummy := utoutput.nextline(raise_exc_in => FALSE, save_in => FALSE); + utassert.isnull('NextLine after empty replace', dummy); + + dbms_output.put_line('MNO'); + dbms_output.put_line('PQR'); + + --Pull out all the data, but save it + utoutput.save; + utoutput.extract(max_lines_in => 1000); + utoutput.nosave; + + --It should be empty now + dummy := utoutput.nextline(raise_exc_in => FALSE); + utassert.isnull('NextLine after full extract', dummy); + + --Put it back + utoutput.replace; + + utassert.eq('Count after multi-replace', utoutput.count, 2); + + utassert.eq('NextLine after multi-replace', utoutput.nextline, 'MNO'); + utassert.eq('NextLine again after multi-replace', utoutput.nextline, 'PQR'); + + --Make sure all is clear + utoutput.replace; + clear_buffer; + + END ut_replace; + + PROCEDURE ut_saving + IS + BEGIN + + utoutput.save; + + utassert.this('Saving Turned On', utoutput.saving); + + utoutput.nosave; + + utassert.this('Saving Turned Off', NOT utoutput.saving); + + utoutput.save; + + utassert.this('Saving Turned Back On', utoutput.saving); + + END ut_saving; + +END ut_utoutput; + +/ diff --git a/source/ut_utoutput.pks b/source/ut_utoutput.pks new file mode 100644 index 000000000..0dbc5f529 --- /dev/null +++ b/source/ut_utoutput.pks @@ -0,0 +1,41 @@ +CREATE OR REPLACE PACKAGE ut_utoutput +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + PROCEDURE ut_count; + PROCEDURE ut_extract; + PROCEDURE ut_nextline; + PROCEDURE ut_replace; + PROCEDURE ut_saving; + +END ut_utoutput; +/ diff --git a/source/ut_utp.pkb b/source/ut_utp.pkb new file mode 100644 index 000000000..203335e4c --- /dev/null +++ b/source/ut_utp.pkb @@ -0,0 +1,413 @@ +/* Formatted on 2001/09/14 10:34 (RevealNet Formatter v4.4.1) */ +CREATE OR REPLACE PACKAGE BODY ututp +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.4 2004/11/16 09:46:49 chrisrimmer +Changed to new version detection system. + +Revision 1.3 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + /* UTP##NNN */ + FUNCTION name (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + RETURN c_abbrev + || utconfig.delimiter + || utp_in.id; + END; + + FUNCTION name (id_in IN ut_utp.id%TYPE) + RETURN VARCHAR2 + IS + rec ut_utp%ROWTYPE; + BEGIN + rec := onerow (id_in); + RETURN name (rec); + END; + + /* schema.UTP##NNN */ + FUNCTION qualified_name (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + RETURN utp_in.owner + || '.' + || name (utp_in); + END; + + FUNCTION qualified_name (id_in IN ut_utp.id%TYPE) + RETURN VARCHAR2 + IS + rec ut_utp%ROWTYPE; + BEGIN + rec := onerow (id_in); + RETURN qualified_name (rec); + END; + + FUNCTION setup_procedure (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + RETURN utp_in.owner + || '.' + || name (utp_in) + || '.' + || utplsql.c_setup; + END; + + FUNCTION teardown_procedure (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + RETURN utp_in.owner + || '.' + || name (utp_in) + || '.' + || utplsql.c_teardown; + END; + + FUNCTION prefix (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2 + IS + BEGIN + RETURN utp_in.prefix; + END; + + FUNCTION onerow ( + owner_in IN ut_utp.owner%TYPE, + program_in IN ut_utp.program%TYPE + ) + RETURN ut_utp%ROWTYPE + IS + retval ut_utp%ROWTYPE; + empty_rec ut_utp%ROWTYPE; + BEGIN + SELECT * + INTO retval + FROM ut_utp + WHERE owner = NVL (UPPER (owner_in), USER) + AND program = UPPER (program_in); + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN empty_rec; + END; + + PROCEDURE get_onerow ( + owner_in IN ut_utp.owner%TYPE + ,program_in IN ut_utp.program%TYPE + ,id_out OUT ut_utp.ID%TYPE + ,description_out OUT ut_utp.description%TYPE + ,filename_out OUT ut_utp.filename%TYPE + ,program_directory_out OUT ut_utp.program_directory%TYPE + ,directory_out OUT ut_utp.DIRECTORY%TYPE + ,name_out OUT ut_utp.NAME%TYPE + ,utp_owner_out OUT ut_utp.utp_owner%TYPE + ,prefix_out OUT ut_utp.prefix%TYPE + ) + is + rec ut_utp%rowtype; + begin + rec := onerow (owner_in, program_in); + id_out := rec.id; + if rec.id is not null then +description_out := rec.description; +filename_out := rec.filename; +program_directory_out := rec.program_directory; +directory_out := rec.directory; +name_out := rec.name; +utp_owner_out := rec.utp_owner; +prefix_out := rec.prefix; + + end if; + end get_onerow; + + FUNCTION exists ( + owner_in IN ut_utp.owner%TYPE, + program_in IN ut_utp.program%TYPE + ) + RETURN Boolean + IS + retval char(1); + + BEGIN + SELECT 'x' + INTO retval + FROM ut_utp + WHERE owner = NVL (UPPER (owner_in), USER) + AND program = UPPER (program_in); + RETURN true; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN false; + END; + + FUNCTION onerow (utp_id_in IN ut_utp.id%TYPE) + RETURN ut_utp%ROWTYPE + IS + retval ut_utp%ROWTYPE; + empty_rec ut_utp%ROWTYPE; + BEGIN + SELECT * + INTO retval + FROM ut_utp + WHERE id = utp_id_in; + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN empty_rec; + END; + + FUNCTION id (name_in IN VARCHAR2) + RETURN ut_utp.id%TYPE + IS + l_delimiter ut_config.delimiter%TYPE := utconfig.delimiter; + l_loc PLS_INTEGER; + retval ut_utp.id%TYPE; + BEGIN + l_loc := INSTR (name_in, l_delimiter); + + IF l_loc = 0 + THEN + RETURN NULL; + ELSE + RETURN to_number (SUBSTR (name_in, l_loc + + LENGTH (l_delimiter)) + ); + END IF; + /* Use new formula; no query required + SELECT id + INTO retval + FROM ut_utp + WHERE name = UPPER (name_in); + RETURN retval; + EXCEPTION + WHEN NO_DATA_FOUND + THEN + RETURN NULL; + */ + END; + + PROCEDURE ADD ( + program_in IN ut_utp.program%TYPE := NULL, + owner_in IN ut_utp.owner%TYPE := NULL, + description_in IN ut_utp.description%TYPE := NULL, + filename_in IN ut_utp.filename%TYPE := NULL, + frequency_in IN ut_utp.frequency%TYPE := NULL, + program_map_in IN ut_utp.program_map%TYPE := NULL, + declarations_in IN ut_utp.declarations%TYPE + := NULL, + setup_in IN ut_utp.setup%TYPE := NULL, + teardown_in IN ut_utp.teardown%TYPE := NULL, + exceptions_in IN ut_utp.exceptions%TYPE := NULL, + program_directory_in IN ut_utp.program_directory%TYPE := NULL, + directory_in IN ut_utp.directory%TYPE := NULL, + name_in IN ut_utp.name%TYPE := NULL, + utp_owner_in IN ut_utp.utp_owner%TYPE := NULL, + prefix_in IN ut_utp.prefix%TYPE := NULL, + id_out OUT ut_utp.id%TYPE + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + l_id ut_utp.id%TYPE; + l_program ut_utp.name%type := program_in; + BEGIN + if l_program not like '"%' then l_program := upper (l_program); end if; + SELECT ut_utp_seq.NEXTVAL + INTO l_id + FROM DUAL; + + INSERT INTO ut_utp + (id, program, + owner, description, filename, + frequency, program_map, declarations, + setup, teardown, program_directory, directory, + name, utp_owner, prefix + ) + VALUES (l_id, l_program, + NVL (owner_in, USER), description_in, filename_in, + frequency_in, program_map_in, declarations_in, + setup_in, teardown_in, program_directory_in, directory_in, + name_in, utp_owner_in, prefix_in + ); + + &start_ge_8_1 + COMMIT; + + &end_ge_8_1 + id_out := l_id; + EXCEPTION + WHEN OTHERS + THEN + IF utrerror.uterrcode = utrerror.assertion_failure + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + ELSE + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error ( + c_abbrev, + 'UTP for ' + || program_in + || ' Owner ' + || owner_in + ); + END IF; + END; + + PROCEDURE ADD ( + program_in IN ut_utp.program%TYPE := NULL, + owner_in IN ut_utp.owner%TYPE := NULL, + description_in IN ut_utp.description%TYPE := NULL, + filename_in IN ut_utp.filename%TYPE := NULL, + frequency_in IN ut_utp.frequency%TYPE := NULL, + program_map_in IN ut_utp.program_map%TYPE := NULL, + declarations_in IN ut_utp.declarations%TYPE + := NULL, + setup_in IN ut_utp.setup%TYPE := NULL, + teardown_in IN ut_utp.teardown%TYPE := NULL, + exceptions_in IN ut_utp.exceptions%TYPE := NULL, + program_directory_in IN ut_utp.program_directory%TYPE := NULL, + directory_in IN ut_utp.directory%TYPE := NULL, + name_in IN ut_utp.name%TYPE := NULL, + utp_owner_in IN ut_utp.utp_owner%TYPE := NULL, + prefix_in IN ut_utp.prefix%TYPE := NULL + ) is l_id ut_utp.id%TYPE; begin + add (program_in => program_in, + owner_in => owner_in, + description_in => description_in, + filename_in => filename_in, + frequency_in => frequency_in, + program_map_in => program_map_in, + declarations_in => declarations_in, + setup_in => setup_in, + teardown_in => teardown_in, + exceptions_in => exceptions_in, + program_directory_in => program_directory_in, + directory_in => directory_in, + name_in => name_in, + utp_owner_in => utp_owner_in, + prefix_in => prefix_in, + id_out => l_id); + end; + + PROCEDURE rem (name_in IN VARCHAR2) + IS + BEGIN + rem (id (name_in)); + END; + + PROCEDURE rem (id_in IN ut_utp.id%TYPE) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + BEGIN + DELETE FROM ut_utp + WHERE id = id_in; + + &start_ge_8_1 + COMMIT; + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + IF utrerror.uterrcode = utrerror.assertion_failure + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + RAISE; + ELSE + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error (c_abbrev, 'UTP ' + || id_in); + END IF; + END; + + PROCEDURE upd ( + id_in IN ut_utp.id%TYPE, + program_directory_in IN ut_utp.program_directory%TYPE := NULL, + directory_in IN ut_utp.directory%TYPE := NULL, + name_in IN ut_utp.name%TYPE := NULL, + utp_owner_in IN ut_utp.utp_owner%TYPE := NULL, + filename_in IN ut_utp.filename%TYPE := NULL, + prefix_in IN ut_utp.prefix%TYPE := NULL + ) + IS + &start_ge_8_1 + PRAGMA autonomous_transaction; + &end_ge_8_1 + l_name ut_utp.name%type := name_in; + BEGIN + if l_name not like '"%' then l_name := upper (l_name); end if; + update ut_utp + set filename = filename_in, + program_directory = program_directory_in, + directory = directory_in, + name = l_name, + utp_owner = utp_owner_in, + prefix = prefix_in + where id = id_in; + &start_ge_8_1 + COMMIT; + + &end_ge_8_1 + EXCEPTION + WHEN OTHERS + THEN + &start_ge_8_1 ROLLBACK; &end_ge_8_1 + utrerror.report_define_error ( + c_abbrev, + 'UTP update for UTP ' + || id_in + ); + END; + + FUNCTION utps (program_like_in IN VARCHAR2 := '%') + RETURN utconfig.refcur_t + IS + retval utconfig.refcur_t; + BEGIN + OPEN retval FOR + SELECT * + FROM ut_utp + WHERE program LIKE UPPER (program_like_in); + RETURN retval; + EXCEPTION + WHEN OTHERS + THEN + RETURN retval; + END; +END ututp; +/ + diff --git a/source/ut_utp.pks b/source/ut_utp.pks new file mode 100644 index 000000000..97f09e6a1 --- /dev/null +++ b/source/ut_utp.pks @@ -0,0 +1,138 @@ +CREATE OR REPLACE PACKAGE ututp +IS + +/************************************************************************ +GNU General Public License for utPLSQL + +Copyright (C) 2000-2003 +Steven Feuerstein and the utPLSQL Project +(steven@stevenfeuerstein.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see license.txt); if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +************************************************************************ +$Log$ +Revision 1.2 2003/07/01 19:36:47 chrisrimmer +Added Standard Headers + +************************************************************************/ + + c_name CONSTANT CHAR (18) := 'UNIT TEST PACKAGE'; + c_abbrev CONSTANT CHAR (3) := 'UTP'; + + /* UTP##NNN */ + FUNCTION NAME (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; + + FUNCTION NAME (id_in IN ut_utp.ID%TYPE) + RETURN VARCHAR2; + + /* schema.UTP##NNN */ + FUNCTION qualified_name (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; + + FUNCTION qualified_name (id_in IN ut_utp.ID%TYPE) + RETURN VARCHAR2; + + FUNCTION setup_procedure (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; + + FUNCTION teardown_procedure (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; + + /* V1 compatibility */ + FUNCTION prefix (utp_in IN ut_utp%ROWTYPE) + RETURN VARCHAR2; + + FUNCTION onerow ( + owner_in IN ut_utp.owner%TYPE + ,program_in IN ut_utp.program%TYPE + ) + RETURN ut_utp%ROWTYPE; + + FUNCTION onerow (utp_id_in IN ut_utp.ID%TYPE) + RETURN ut_utp%ROWTYPE; + + PROCEDURE get_onerow ( + owner_in IN ut_utp.owner%TYPE + ,program_in IN ut_utp.program%TYPE + ,id_out OUT ut_utp.ID%TYPE + ,description_out OUT ut_utp.description%TYPE + ,filename_out OUT ut_utp.filename%TYPE + ,program_directory_out OUT ut_utp.program_directory%TYPE + ,directory_out OUT ut_utp.DIRECTORY%TYPE + ,name_out OUT ut_utp.NAME%TYPE + ,utp_owner_out OUT ut_utp.utp_owner%TYPE + ,prefix_out OUT ut_utp.prefix%TYPE + ); + + FUNCTION EXISTS ( + owner_in IN ut_utp.owner%TYPE + ,program_in IN ut_utp.program%TYPE + ) + RETURN BOOLEAN; + + FUNCTION ID (NAME_IN IN VARCHAR2) + RETURN ut_utp.ID%TYPE; + + PROCEDURE ADD ( + -- 2.0.7 name_in IN ut_utp.name%TYPE, + program_in IN ut_utp.program%TYPE := NULL + ,owner_in IN ut_utp.owner%TYPE := NULL + ,description_in IN ut_utp.description%TYPE := NULL + ,filename_in IN ut_utp.filename%TYPE := NULL + ,frequency_in IN ut_utp.frequency%TYPE := NULL + ,program_map_in IN ut_utp.program_map%TYPE := NULL + ,declarations_in IN ut_utp.declarations%TYPE := NULL + ,setup_in IN ut_utp.setup%TYPE := NULL + ,teardown_in IN ut_utp.teardown%TYPE := NULL + ,exceptions_in IN ut_utp.EXCEPTIONS%TYPE := NULL + ,program_directory_in IN ut_utp.program_directory%TYPE := NULL + ,directory_in IN ut_utp.DIRECTORY%TYPE := NULL + ,NAME_IN IN ut_utp.NAME%TYPE := NULL + ,utp_owner_in IN ut_utp.utp_owner%TYPE := NULL + ,prefix_in IN ut_utp.prefix%TYPE := NULL + -- V1 prefix_in IN ut_utp.prefix%TYPE := utconfig.c_prefix + ); + + PROCEDURE ADD ( + program_in IN ut_utp.program%TYPE := NULL + ,owner_in IN ut_utp.owner%TYPE := NULL + ,description_in IN ut_utp.description%TYPE := NULL + ,filename_in IN ut_utp.filename%TYPE := NULL + ,frequency_in IN ut_utp.frequency%TYPE := NULL + ,program_map_in IN ut_utp.program_map%TYPE := NULL + ,declarations_in IN ut_utp.declarations%TYPE := NULL + ,setup_in IN ut_utp.setup%TYPE := NULL + ,teardown_in IN ut_utp.teardown%TYPE := NULL + ,exceptions_in IN ut_utp.EXCEPTIONS%TYPE := NULL + ,program_directory_in IN ut_utp.program_directory%TYPE := NULL + ,directory_in IN ut_utp.DIRECTORY%TYPE := NULL + ,NAME_IN IN ut_utp.NAME%TYPE := NULL + ,utp_owner_in IN ut_utp.utp_owner%TYPE := NULL + ,prefix_in IN ut_utp.prefix%TYPE := NULL + ,id_out OUT ut_utp.ID%TYPE + ); + + PROCEDURE REM (NAME_IN IN VARCHAR2); + + PROCEDURE REM (id_in IN ut_utp.ID%TYPE); + + FUNCTION utps ( + program_like_in IN VARCHAR2 := '%' + ) + RETURN utconfig.refcur_t; + +END ututp; +/ diff --git a/source/ut_utp.tab b/source/ut_utp.tab new file mode 100644 index 000000000..9f7a9720d --- /dev/null +++ b/source/ut_utp.tab @@ -0,0 +1,32 @@ +CREATE TABLE ut_utp ( + id INTEGER, + description VARCHAR2(2000), + prefix VARCHAR2(10), /* V1 compatibility. V2: use ut_config.delimiter to construct names. */ + program VARCHAR2(30), /* name of program being tested */ + owner VARCHAR2(30), /* owner of program */ + filename VARCHAR2(2000), /* name of file containing source code for UTP */ + frequency VARCHAR2(2000), + program_map VARCHAR2(2000), + /* XML document representing parsed version of package. Should be LOB. */ + declarations varchar2(2000), + setup varchar2(2000), + teardown varchar2(2000), + exceptions varchar2(2000), + CONSTRAINT ut_utp_pk PRIMARY KEY (id) +); + +REM 2.0.8.1 +ALTER TABLE ut_utp ADD per_method_setup char(1); + +ALTER TABLE ut_utp ADD name VARCHAR2(30); + +REM 2.1.1 +REM /* Owner of UTP */ +ALTER TABLE ut_utp ADD utp_owner VARCHAR2(30); +REM File containing source code of program +ALTER TABLE ut_utp ADD program_filename VARCHAR2(30); +REM-- Location of UTP source file +ALTER TABLE ut_utp ADD directory VARCHAR2(30); +REM-- Location of program +ALTER TABLE ut_utp ADD program_directory VARCHAR2(30); + diff --git a/source/ut_utp_seq.seq b/source/ut_utp_seq.seq new file mode 100644 index 000000000..2f0799bbf --- /dev/null +++ b/source/ut_utp_seq.seq @@ -0,0 +1 @@ +CREATE sequence ut_utp_seq INCREMENT BY 1 START WITH 1 ORDER NOCACHE; diff --git a/source/ut_utreport.pkb b/source/ut_utreport.pkb new file mode 100644 index 000000000..53b1d8e76 --- /dev/null +++ b/source/ut_utreport.pkb @@ -0,0 +1,148 @@ +CREATE OR REPLACE PACKAGE BODY UT_UTREPORT +AS + + reporter_before VARCHAR2(1000); + + PROCEDURE ut_setup + IS + BEGIN + + reporter_before := utConfig.getreporter; + + EXECUTE IMMEDIATE 'CREATE OR REPLACE PACKAGE utTestReporter +AS + char_log VARCHAR2(1000); + + PROCEDURE open; + PROCEDURE pl (str IN VARCHAR2); + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE); + PROCEDURE show_failure; + PROCEDURE show_result; + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE); + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE); + PROCEDURE show_error; + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE); + PROCEDURE close; +END;'; + + EXECUTE IMMEDIATE 'CREATE OR REPLACE PACKAGE BODY utTestReporter +AS + PROCEDURE open IS BEGIN char_log := char_log || '' open''; END; + PROCEDURE pl (str IN VARCHAR2) IS BEGIN char_log := char_log || '' pl(''|| str || '')''; END; + PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE) + IS BEGIN char_log := char_log || '' before_results''; END; + PROCEDURE show_failure + IS BEGIN char_log := char_log || '' show_failure''; END; + PROCEDURE show_result + IS BEGIN char_log := char_log || '' show_result''; END; + PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE) + IS BEGIN char_log := char_log || '' after_results''; END; + PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE) + IS BEGIN char_log := char_log || '' before_errors''; END; + PROCEDURE show_error + IS BEGIN char_log := char_log || '' show_error''; END; + PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE) + IS BEGIN char_log := char_log || '' after_errors''; END; + PROCEDURE close + IS BEGIN char_log := char_log || '' close''; END; +END;'; + + END; + + PROCEDURE ut_teardown + IS + BEGIN + BEGIN + EXECUTE IMMEDIATE 'DROP PACKAGE utTestReporter'; + EXCEPTION + WHEN OTHERS THEN + NULL; + END; + + utConfig.setreporter(reporter_before); + + END; + + FUNCTION get_log RETURN VARCHAR2 IS + char_log VARCHAR2(1000); + BEGIN + EXECUTE IMMEDIATE 'BEGIN :1 := utTestReporter.char_log; END;' USING OUT char_log; + RETURN char_log; + END; + + PROCEDURE clear_log IS + BEGIN + EXECUTE IMMEDIATE 'BEGIN utTestReporter.char_log := NULL; END;'; + END; + + ----------------------------------------------------------- + --This checks that calls to utreport get passed through to + --our custom reporter package. + ----------------------------------------------------------- + PROCEDURE ut_check_report_facade + IS + + run_id utr_outcome.run_id%TYPE; + rec_result utr_outcome%ROWTYPE; + rec_error utr_error%ROWTYPE; + + BEGIN + + utreport.outcome.status := NULL; + utreport.error.description := NULL; + + utConfig.setreporter('Test'); + + clear_log; + utReport.open; + utAssert.eq('open', get_log, ' open'); + + clear_log; + utReport.pl('Blah'); + utAssert.eq('pl', get_log, ' pl(Blah)'); + + clear_log; + utReport.before_results(run_id); + utAssert.eq('before_results', get_log, ' before_results'); + + clear_log; + rec_result.STATUS := 'FAILURE'; + utReport.show_failure(rec_result); + utAssert.eq('show_failure', get_log, ' show_failure'); + utAssert.eq('show_failure: outcome set', utreport.outcome.status, 'FAILURE'); + + clear_log; + rec_result.STATUS := 'RESULT'; + utReport.show_result(rec_result); + utAssert.eq('show_result', get_log, ' show_result'); + utAssert.eq('show_failure: outcome set', utreport.outcome.status, 'RESULT'); + + clear_log; + utReport.after_results(run_id); + utAssert.eq('after_results', get_log, ' after_results'); + + clear_log; + utReport.before_errors(run_id); + utAssert.eq('before_errors', get_log, ' before_errors'); + + clear_log; + rec_error.DESCRIPTION := 'BOOM!'; + utReport.show_error(rec_error); + utAssert.eq('show_error', get_log, ' show_error'); + utAssert.eq('show_error: error set', utreport.error.description, 'BOOM!'); + + clear_log; + utReport.after_errors(run_id); + utAssert.eq('after_errors', get_log, ' after_errors'); + + utConfig.setreporter(reporter_before); + + EXCEPTION + WHEN OTHERS THEN + utConfig.setreporter(reporter_before); + RAISE; + + END; + +END; +/ diff --git a/source/ut_utreport.pks b/source/ut_utreport.pks new file mode 100644 index 000000000..25ff468c6 --- /dev/null +++ b/source/ut_utreport.pks @@ -0,0 +1,10 @@ +CREATE OR REPLACE PACKAGE UT_UTREPORT +AS + + PROCEDURE ut_setup; + PROCEDURE ut_teardown; + + PROCEDURE ut_check_report_facade; + +END; +/ \ No newline at end of file diff --git a/source/utr_error.tab b/source/utr_error.tab new file mode 100644 index 000000000..8181239cf --- /dev/null +++ b/source/utr_error.tab @@ -0,0 +1,28 @@ +CREATE TABLE utr_error ( + run_id INTEGER, + suite_id INTEGER, + utp_id INTEGER, + unittest_id INTEGER, + testcase_id INTEGER, + outcome_id INTEGER, + errlevel varchar2(100), + occurred_on DATE, + errcode integer, + errtext varchar2(1000), + description varchar2(2000)); + +ALTER TABLE utr_error ADD CONSTRAINT utr_error_suite_fk + FOREIGN KEY (suite_id) REFERENCES ut_suite; + +ALTER TABLE utr_error ADD CONSTRAINT utr_error_utp_fk + FOREIGN KEY (utp_id) REFERENCES ut_utp; + +ALTER TABLE utr_error ADD CONSTRAINT utr_error_unittest_fk + FOREIGN KEY (unittest_id) REFERENCES ut_unittest; + +ALTER TABLE utr_error ADD CONSTRAINT utr_error_testcase_fk + FOREIGN KEY (testcase_id) REFERENCES ut_testcase; + +ALTER TABLE utr_error ADD CONSTRAINT utr_error_outcome_fk + FOREIGN KEY (outcome_id) REFERENCES ut_outcome; + diff --git a/source/utr_outcome.tab b/source/utr_outcome.tab new file mode 100644 index 000000000..e85eb2a28 --- /dev/null +++ b/source/utr_outcome.tab @@ -0,0 +1,23 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2001/04/12 10:49 */ + +CREATE TABLE utr_outcome ( + run_id INTEGER, + outcome_id integer, + start_on date, + end_on date, + status varchar2(100), + description varchar2(2000) +); + +REM 2.0.9.1 Record order of execution of test. +ALTER TABLE utr_outcome ADD tc_run_id INTEGER; + +ALTER table utr_outcome add CONSTRAINT utr_outcome_pk + primary key (run_id, outcome_id); + +-- Turn off to support V1 compatibility +--ALTER table utr_outcome add CONSTRAINT utr_outcome_fk1 +-- FOREIGN KEY (outcome_id) REFERENCES ut_outcome; + + + diff --git a/source/utr_suite.tab b/source/utr_suite.tab new file mode 100644 index 000000000..e3610b478 --- /dev/null +++ b/source/utr_suite.tab @@ -0,0 +1,17 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2001/02/09 16:21 */ + +CREATE TABLE utr_suite ( + run_id INTEGER, + run_by VARCHAR2(30), + profiler_run_id INTEGER, + suite_id integer, + start_on date, + end_on date, + status varchar2(100)); + +ALTER table utr_suite add CONSTRAINT utr_suite_pk + primary key (run_id, suite_id); + +ALTER table utr_suite add CONSTRAINT utr_suite_fk1 + FOREIGN KEY (suite_id) REFERENCES ut_suite; + diff --git a/source/utr_testcase.tab b/source/utr_testcase.tab new file mode 100644 index 000000000..e000cabcb --- /dev/null +++ b/source/utr_testcase.tab @@ -0,0 +1,16 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2001/04/12 10:49 */ + +CREATE TABLE utr_testcase ( + run_id INTEGER, + testcase_id integer, + start_on date, + end_on date, + status varchar2(100)); + +ALTER table utr_testcase add CONSTRAINT utr_testcase_pk + primary key (run_id, testcase_id); + +ALTER table utr_testcase add CONSTRAINT utr_testcase_fk1 + FOREIGN KEY (testcase_id) REFERENCES ut_testcase; + + diff --git a/source/utr_unittest.tab b/source/utr_unittest.tab new file mode 100644 index 000000000..ef3279c32 --- /dev/null +++ b/source/utr_unittest.tab @@ -0,0 +1,16 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2001/04/12 10:49 */ + +CREATE TABLE utr_unittest ( + run_id INTEGER, + unittest_id integer, + start_on date, + end_on date, + status varchar2(100)); + +ALTER table utr_unittest add CONSTRAINT utr_unittest_pk + primary key (run_id, unittest_id); + +ALTER table utr_unittest add CONSTRAINT utr_unittest_fk1 + FOREIGN KEY (unittest_id) REFERENCES ut_unittest; + + diff --git a/source/utr_utp.tab b/source/utr_utp.tab new file mode 100644 index 000000000..6e042b543 --- /dev/null +++ b/source/utr_utp.tab @@ -0,0 +1,17 @@ +/* Formatted by PL/Formatter v3.1.2.1 on 2001/02/09 16:21 */ + +CREATE TABLE utr_utp ( + run_id INTEGER, + run_by VARCHAR2(30), + profiler_run_id INTEGER, + utp_id integer, + start_on date, + end_on date, + status varchar2(100)); + +ALTER table utr_utp add CONSTRAINT utr_utp_pk + primary key (run_id, utp_id); + +ALTER table utr_utp add CONSTRAINT utr_utp_fk1 + FOREIGN KEY (utp_id) REFERENCES ut_utp; + diff --git a/source/utv_last_run.sql b/source/utv_last_run.sql new file mode 100644 index 000000000..f9604c075 --- /dev/null +++ b/source/utv_last_run.sql @@ -0,0 +1,9 @@ +CREATE OR REPLACE VIEW utv_last_run +AS + SELECT a.id utp_id, program, run_id last_run_id + FROM ut_utp a, + (SELECT utp_id, MAX (run_id) run_id + FROM utv_result_full + GROUP BY utp_id) b + WHERE a.id = b.utp_id(+); + diff --git a/source/utv_result_full.sql b/source/utv_result_full.sql new file mode 100644 index 000000000..484879f0e --- /dev/null +++ b/source/utv_result_full.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE VIEW utv_result_full +AS + SELECT utp.id utp_id, program, ut.id unittest_id, + tc.id testcase_id, utr.outcome_id, run_id, + start_on, end_on, utr.status, utr.description + FROM ut_utp utp, + ut_unittest ut, + ut_testcase tc, + ut_outcome oc, + utr_outcome utr + WHERE utp.id = ut.utp_id + AND ut.id = tc.unittest_id + AND tc.id = oc.testcase_id + AND oc.id = utr.outcome_id; diff --git a/test/common_helper/utplsql.pkb b/test/common_helper/utplsql.pkb deleted file mode 100644 index c752caa41..000000000 --- a/test/common_helper/utplsql.pkb +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 51adbb117..000000000 --- a/test/common_helper/utplsql.pks +++ /dev/null @@ -1,9 +0,0 @@ -create or replace package utplsql is - - --%suite - - --%beforeall - procedure global_setup; - -end; -/ diff --git a/test/install_above_12_1.sql b/test/install_above_12_1.sql deleted file mode 100644 index fe20cf816..000000000 --- a/test/install_above_12_1.sql +++ /dev/null @@ -1,28 +0,0 @@ -set termout off -set echo off -spool dummy.sql -prompt whenever sqlerror exit failure rollback -spool off - - -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release >= 2 - or dbms_db_version.version > 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - - -@@&&SCRIPT_NAME - diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh deleted file mode 100755 index 1719f137a..000000000 --- a/test/install_and_run_tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -ev - -. ./development/env.sh - -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" -cd test - -time . ./install_tests.sh -time . ./run_tests.sh diff --git a/test/install_below_12_2.sql b/test/install_below_12_2.sql deleted file mode 100644 index 669ae75fc..000000000 --- a/test/install_below_12_2.sql +++ /dev/null @@ -1,28 +0,0 @@ -set termout off -set echo off -spool dummy.sql -prompt whenever sqlerror exit failure rollback -spool off - - -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release < 2 - or dbms_db_version.version < 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - - -@@&&SCRIPT_NAME - diff --git a/test/install_tests.sh b/test/install_tests.sh deleted file mode 100755 index 1b97ec33d..000000000 --- a/test/install_tests.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -ev - -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd ${SCRIPT_DIR} - - -"$SQLCLI" UT3_TESTER_HELPER/ut3@//${CONNECTION_STR} @install_ut3_tester_helper.sql - -"$SQLCLI" UT3_USER/ut3@//${CONNECTION_STR} @install_ut3_user_tests.sql - -"$SQLCLI" UT3_TESTER/ut3@//${CONNECTION_STR} @install_ut3_tester_tests.sql - diff --git a/test/install_ut3_tester_helper.sql b/test/install_ut3_tester_helper.sql deleted file mode 100644 index b78221627..000000000 --- a/test/install_ut3_tester_helper.sql +++ /dev/null @@ -1,74 +0,0 @@ -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_nested_object.tps -@@ut3_tester_helper/test_dummy_double_nested_object.tps -@@ut3_tester_helper/test_dummy_object_list.tps -@@ut3_tester_helper/test_dummy_nested_object_list.tps -@@ut3_tester_helper/test_dummy_double_nested_list.tps -@@ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps -@@ut3_tester_helper/test_tab_varchar2.tps -@@ut3_tester_helper/test_tab_varray.tps -@@ut3_tester_helper/test_nested_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 - -@@ut3_tester_helper/annotation_cache_helper.pks -@@ut3_tester_helper/annotation_cache_helper.pkb -create or replace synonym ut3_tester.annotation_cache_helper for ut3_tester_helper.annotation_cache_helper; -create or replace synonym ut3_user.coverage_helper for ut3_tester_helper.coverage_helper; - -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 deleted file mode 100644 index cc96b2b64..000000000 --- a/test/install_ut3_tester_tests.sql +++ /dev/null @@ -1,78 +0,0 @@ -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/annotations/test_annotation_cache.pks -@@ut3_tester/core/annotations/test_annot_disabled_reason.pks -@@ut3_tester/core/expectations/test_expectation_processor.pks -@@ut3_tester/core/test_ut_utils.pks -@@ut3_tester/core/test_ut_suite_tag_filter.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/annotations/test_annotation_manager.pkb -@@ut3_tester/core/annotations/test_annot_throws_exception.pkb -@@ut3_tester/core/annotations/test_annotation_cache.pkb -@@ut3_tester/core/annotations/test_annot_disabled_reason.pkb -@@ut3_tester/core/expectations/test_expectation_processor.pkb -@@ut3_tester/core/test_ut_utils.pkb -@@ut3_tester/core/test_ut_suite_tag_filter.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 deleted file mode 100644 index 518e07841..000000000 --- a/test/install_ut3_user_tests.sql +++ /dev/null @@ -1,138 +0,0 @@ -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/helpers/some_item.tps -@@ut3_user/helpers/some_items.tps -@@ut3_user/helpers/some_object.tps -@@ut3_user/test_user.pks -@@ut3_user/expectations.pks -@@ut3_user/expectations.pkb -@@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/binary/test_to_be_within.pks -@@ut3_user/expectations/binary/test_to_be_within_pct.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_tap_reporter.pks -@@ut3_user/reporters/test_coverage.pks -@@ut3_user/reporters/test_coverage/test_coverage_standalone.pks -set define on -@@ut3_user/reporters/test_coverage/test_extended_coverage.pks -@@ut3_user/reporters/test_coverage/test_html_coverage_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 -@@ut3_user/reporters/test_coverage/test_proftab_coverage.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/binary/test_to_be_within.pkb -@@ut3_user/expectations/binary/test_to_be_within_pct.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_tap_reporter.pkb -@@ut3_user/reporters/test_coverage/test_coverage_standalone.pkb -set define on -@@ut3_user/reporters/test_coverage/test_extended_coverage.pkb -@@ut3_user/reporters/test_coverage/test_html_coverage_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 -@@ut3_user/reporters/test_coverage/test_proftab_coverage.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/run_tests.sh b/test/run_tests.sh deleted file mode 100755 index 7d0431aec..000000000 --- a/test/run_tests.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -set -ev - -#goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" - -export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 - -time utPLSQL-cli/bin/utplsql run UT3_TESTER_HELPER/ut3@//${CONNECTION_STR} -D \ --source_path=source -owner=ut3_develop \ --p='ut3_tester,ut3_user' \ --test_path=test -c \ - -regex_expression="test/(\w+)(/(\w+))*/(\w+)\.(.{3})$" \ - -owner_subexpression=1 \ - -type_subexpression=5 \ - -name_subexpression=4 \ --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/ut3_tester/core.pkb b/test/ut3_tester/core.pkb deleted file mode 100644 index 41b6b10d1..000000000 --- a/test/ut3_tester/core.pkb +++ /dev/null @@ -1,11 +0,0 @@ -create or replace package body core is - - procedure global_setup is - begin - ut3_tester_helper.coverage_helper.set_develop_mode(); - --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 deleted file mode 100644 index 4565c47f3..000000000 --- a/test/ut3_tester/core.pks +++ /dev/null @@ -1,10 +0,0 @@ -create or replace package core is - - --%suite - --%suitepath(utplsql.ut3_tester) - - --%beforeall - procedure global_setup; - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb deleted file mode 100644 index 7f1e068a8..000000000 --- a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pkb +++ /dev/null @@ -1,484 +0,0 @@ -create or replace package body test_annot_disabled_reason -is - - - procedure compile_dummy_packages is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_package_1 is - - --%suite - --%displayname(disable_test_suite_level) - --%suitepath(tests) - --%rollback(manual) - - --%disabled( Tests are disabled on suite level ) - - --%context( First context ) - - --%test(Test1 from test package 1) - procedure test1; - - --%test(Test2 from test package 1) - procedure test2; - - --%endcontext - - --%context( Second context ) - - --%test(Test3 from test package 1) - procedure test3; - - --%test(Test4 from test package 1) - procedure test4; - - --%endcontext - -end test_package_1;]'; - - execute immediate q'[create or replace package body test_package_1 is - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2).to_equal(2); - end; - - procedure test3 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test4 is - begin - ut.expect(2).to_equal(2); - end; - -end test_package_1;]'; - - execute immediate q'[create or replace package test_package_2 is - - --%suite - --%displayname(Disable on context level) - --%suitepath(tests) - --%rollback(manual) - - --%context( First context ) - - --%disabled( Tests and disabled on first context level ) - - --%test(Test1 from test package 2) - procedure test1; - - --%test(Test2 from test package 2) - procedure test2; - - --%endcontext - - --%context( Second context ) - - --%test(Test3 from test package 2) - procedure test3; - - --%test(Test4 from test package 3) - procedure test4; - - --%endcontext - -end test_package_2;]'; - - execute immediate q'[create or replace package body test_package_2 is - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2).to_equal(2); - end; - - procedure test3 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test4 is - begin - ut.expect(2).to_equal(2); - end; - -end test_package_2;]'; - - execute immediate q'[create or replace package testing_package_3 is - - --%suite - --%displayname(Disable tests on test level) - --%suitepath(tests) - --%rollback(manual) - - --%context( First context ) - - --%test(Test1 from test package 3) - --%disabled( Test1 disabled from first context ) - procedure test1; - - --%test(Test2 from test package 3) - procedure test2; - - --%endcontext - - --%context( Second context ) - - --%test(Test3 from test package 3) - procedure test3; - - --%test(Test4 from test package 3) - --%disabled( Test4 disabled from second context ) - procedure test4; - - --%endcontext - -end testing_package_3;]'; - - execute immediate q'[create or replace package body testing_package_3 is - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2).to_equal(2); - end; - - procedure test3 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test4 is - begin - ut.expect(2).to_equal(2); - end; - -end testing_package_3;]'; - - execute immediate q'[create or replace package test_package_4 is - - --%suite - --%displayname(Disable reason is very long or have special characters) - --%suitepath(tests) - --%rollback(manual) - - - --%test(Test1 from test package 4) - --%disabled( $#?!%*&-/\^ ) - procedure test1; - - --%test(Test2 from test package 4) - --%disabled(verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext) - procedure test2; - -end test_package_4;]'; - - execute immediate q'[create or replace package body test_package_4 is - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2).to_equal(2); - end; - -end test_package_4;]'; - - execute immediate q'[create or replace package test_package_5 is - - --%suite - --%displayname(Disable tests on suite level overriding rest) - --%suitepath(tests) - --%rollback(manual) - - --%disabled( Disable on suite level ) - - --%context( First context ) - - --%disabled( Disable on 1st context level ) - - --%test(Test1 from test package 3) - --%disabled( Disable on 1st test level ) - procedure test1; - - --%test(Test2 from test package 3) - --%disabled( Disable on 2nd test level ) - procedure test2; - - --%endcontext - - --%context( Second context ) - - --%disabled( Disable on 2nd context level ) - - --%test(Test3 from test package 3) - --%disabled( Disable on 3rd test level ) - procedure test3; - - --%test(Test4 from test package 3) - --%disabled( Disable on 4th test level ) - procedure test4; - - --%endcontext - -end test_package_5;]'; - - execute immediate q'[create or replace package body test_package_5 is - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2).to_equal(2); - end; - - procedure test3 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test4 is - begin - ut.expect(2).to_equal(2); - end; - -end test_package_5;]'; - - execute immediate q'[create or replace package test_package_6 is - - --%suite - --%displayname(Disable tests on each of ctx level overriding rest) - --%suitepath(tests) - --%rollback(manual) - - --%context( First context ) - - --%disabled( Disable on 1st context level ) - - --%test(Test1 from test package 3) - --%disabled( Disable on 1st test level ) - procedure test1; - - --%test(Test2 from test package 3) - --%disabled( Disable on 2nd test level ) - procedure test2; - - --%endcontext - - --%context( Second context ) - - --%disabled( Disable on 2nd context level ) - - --%test(Test3 from test package 3) - --%disabled( Disable on 3rd test level ) - procedure test3; - - --%test(Test4 from test package 3) - --%disabled( Disable on 4th test level ) - procedure test4; - - --%endcontext - -end test_package_6;]'; - - execute immediate q'[create or replace package body test_package_6 is - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(2).to_equal(2); - end; - - procedure test3 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test4 is - begin - ut.expect(2).to_equal(2); - end; - -end test_package_6;]'; - - end; - - - procedure drop_dummy_packages is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_package_1'; - execute immediate 'drop package test_package_2'; - execute immediate 'drop package testing_package_3'; - execute immediate 'drop package test_package_4'; - execute immediate 'drop package test_package_5'; - execute immediate 'drop package test_package_6'; - end; - - procedure test_disable_on_suite_level is - l_test_results ut3_develop.ut_varchar2_list; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Act - - select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'))); - - l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); - - l_expected_message := q'[%tests -%disable_test_suite_level -%First context -%Test1 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) -%Test2 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) -%Second context -%Test3 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level) -%Test4 from test package 1 [0 sec] (DISABLED - Tests are disabled on suite level)%]'; - ut.expect(l_actual_message).to_be_like(l_expected_message); - - end; - - procedure test_dis_on_1st_ctx_level is - l_test_results ut3_develop.ut_varchar2_list; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Act - - select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'))); - - l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); - - l_expected_message := q'[%tests -%Disable on context level -%First context -%Test1 from test package 2 [0 sec] (DISABLED - Tests and disabled on first context level) -%Test2 from test package 2 [0 sec] (DISABLED - Tests and disabled on first context level) -%Second context -%Test3 from test package 2 [% sec] -%Test4 from test package 3 [% sec]%]'; - - ut.expect(l_actual_message).to_be_like(l_expected_message); - - end; - - procedure test_disable_tests_level is - l_test_results ut3_develop.ut_varchar2_list; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Act - - select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.testing_package_3'))); - - l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); - - l_expected_message := q'[%tests -%Disable tests on test level -%First context -%Test1 from test package 3 [0 sec] (DISABLED - Test1 disabled from first context) -%Test2 from test package 3 [% sec] -%Second context -%Test3 from test package 3 [% sec] -%Test4 from test package 3 [0 sec] (DISABLED - Test4 disabled from second context)%]'; - - ut.expect(l_actual_message).to_be_like(l_expected_message); - - - end; - - procedure test_long_text_spec_chr is - l_test_results ut3_develop.ut_varchar2_list; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Act - - select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_4'))); - - l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); - - l_expected_message := q'[%tests -%Disable reason is very long or have special characters -%Test1 from test package 4 [0 sec] (DISABLED - $#?!%*&-/\^) -%Test2 from test package 4 [0 sec] (DISABLED - verylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtextverylongtext)%]'; - - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure test_disable_suite_ctx_tst is - l_test_results ut3_develop.ut_varchar2_list; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Act - - select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_5'))); - - l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); - - l_expected_message := q'[%tests -%Disable tests on suite level overriding rest -%First context -%Test1 from test package 3 [0 sec] (DISABLED - Disable on suite level) -%Test2 from test package 3 [0 sec] (DISABLED - Disable on suite level) -%Second context -%Test3 from test package 3 [0 sec] (DISABLED - Disable on suite level) -%Test4 from test package 3 [0 sec] (DISABLED - Disable on suite level)%]'; - - ut.expect(l_actual_message).to_be_like(l_expected_message); - - - end; - - procedure test_disable_ctx_tst is - l_test_results ut3_develop.ut_varchar2_list; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Act - - select * bulk collect into l_test_results from table(ut3_develop.ut.run((sys_context('USERENV', 'CURRENT_USER')||'.test_package_6'))); - - l_actual_message := ut3_develop.ut_utils.table_to_clob(l_test_results); - - l_expected_message := q'[%tests -%Disable tests on each of ctx level overriding rest -%First context -%Test1 from test package 3 [0 sec] (DISABLED - Disable on 1st context level) -%Test2 from test package 3 [0 sec] (DISABLED - Disable on 1st context level) -%Second context -%Test3 from test package 3 [0 sec] (DISABLED - Disable on 2nd context level) -%Test4 from test package 3 [0 sec] (DISABLED - Disable on 2nd context level)%]'; - - ut.expect(l_actual_message).to_be_like(l_expected_message); - - end; - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks b/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks deleted file mode 100644 index cae5da1ee..000000000 --- a/test/ut3_tester/core/annotations/test_annot_disabled_reason.pks +++ /dev/null @@ -1,31 +0,0 @@ -create or replace package test_annot_disabled_reason -is - --%suite(annotations - disabled) - --%suitepath(utplsql.ut3_tester.core.annotations) - - --%beforeall - procedure compile_dummy_packages; - - --%afterall - procedure drop_dummy_packages; - - --%test(Disable all tests under the suite displaying suite level reason) - procedure test_disable_on_suite_level; - - --%test(Disable all tests under one of two contexts displaying context level reason) - procedure test_dis_on_1st_ctx_level; - - --%test(Disable a single tests from each of the contexts displaying test level reason) - procedure test_disable_tests_level; - - --%test(Disable tests with reason using special characters and long reason) - procedure test_long_text_spec_chr; - - --%test(Disable tests on suite , context and test level and display suite level reason) - procedure test_disable_suite_ctx_tst; - - --%test(Disable tests on context and test level and display context level reason) - procedure test_disable_ctx_tst; - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb b/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb deleted file mode 100644 index ac51d3a49..000000000 --- a/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb +++ /dev/null @@ -1,405 +0,0 @@ -create or replace package body test_annot_throws_exception -is - g_tests_results clob; - - procedure recollect_tests_results is - pragma autonomous_transaction; - - l_package_spec varchar2(32737); - l_package_body varchar2(32737); - l_exception_spec varchar2(32737); - l_test_results ut3_develop.ut_varchar2_list; - begin - l_exception_spec := q'[ - create or replace package exc_pkg is - c_e_single_exc constant number := -20200; - c_e_dummy constant varchar2(10) := 'dummy'; - c_e_varch_exc constant varchar2(10) := '-20201'; - c_e_list_1 number := -20202; - c_e_list_2 constant number := -20203; - c_e_diff_exc constant number := -20204; - c_e_mix_list constant number := -20205; - c_e_mix_missin constant number := -20206; - c_e_positive constant number := 20207; - - e_some_exception exception; - pragma exception_init(e_some_exception, -20207); - - end;]'; - - l_package_spec := ' - create package annotated_package_with_throws is - --%suite(Dummy package to test annotation throws) - - --%test(Throws same annotated exception) - --%throws(-20145) - procedure raised_same_exception; - - --%test(Throws one of the listed exceptions) - --%throws(-20145,-20146, -20189 ,-20563) - procedure raised_one_listed_exception; - - --%test(Leading zero is ignored in exception list) - --%throws(-01476) - procedure leading_0_exception_no; - - --%test(Throws diff exception) - --%throws(-20144) - procedure raised_diff_exception; - - --%test(Throws empty) - --%throws() - procedure empty_throws; - - --%test(Ignores annotation and fails when exception was thrown) - --%throws(hello,784#,0-=234,,u1234) - procedure bad_paramters_with_except; - - --%test(Ignores annotation and succeeds when no exception thrown) - --%throws(hello,784#,0-=234,,u1234) - procedure bad_paramters_without_except; - - --%test(Ignores annotation for positive exception number value) - --%throws(20001) - procedure positive_exception_number; - - --%test(Ignores annotation for positive exception number variable) - --%throws(exc_pkg.c_e_positive) - procedure positive_exception_number_var; - - --%test(Detects a valid exception number within many invalid ones) - --%throws(7894562, operaqk, -=1, -1, pow74d, posdfk3) - procedure one_valid_exception_number; - - --%test(Gives failure when a exception is expected and nothing is thrown) - --%throws(-20459, -20136, -20145) - procedure nothing_thrown; - - --%test(Single exception defined as a constant number in package) - --%throws(exc_pkg.c_e_single_exc) - procedure single_exc_const_pkg; - - --%test(Gives success when one of annotated exception using constant is thrown) - --%throws(exc_pkg.c_e_list_1,exc_pkg.c_e_list_2) - procedure list_of_exc_constant; - - --%test(Gives failure when the raised exception is different that the annotated one using variable) - --%throws(exc_pkg.c_e_diff_exc) - procedure fail_not_match_exc; - - --%test(Success when one of exception from mixed list of number and constant is thrown) - --%throws(exc_pkg.c_e_mix_list,-20105) - procedure mixed_exc_list; - - --%test(Success when match exception even if other variable on list dont exists) - --%throws(exc_pkg.c_e_mix_missin,utter_rubbish) - procedure mixed_list_notexi; - - --%test(Success resolve and match named exception defined in pragma exception init) - --%throws(exc_pkg.e_some_exception) - procedure named_exc_pragma; - - --%test(Success resolve and match oracle named exception) - --%throws(NO_DATA_FOUND) - procedure named_exc_ora; - - --%test(Success resolve and match oracle named exception dup val index) - --%throws(DUP_VAL_ON_INDEX) - procedure named_exc_ora_dup_ind; - - --%test(Success map no data 100 to -1403) - --%throws(-1403) - procedure nodata_exc_ora; - - --%test(Success for exception defined as varchar) - --%throws(exc_pkg.c_e_varch_exc) - procedure defined_varchar_exc; - - --%test(Non existing constant exception) - --%throws(dummy.c_dummy); - procedure non_existing_const; - - --%test(Bad exception constant) - --%throws(exc_pkg.c_e_dummy); - procedure bad_exc_const; - end; - '; - - l_package_body := ' - create package body annotated_package_with_throws is - procedure raised_same_exception is - begin - raise_application_error(-20145, ''Test error''); - end; - - procedure raised_one_listed_exception is - begin - raise_application_error(-20189, ''Test error''); - end; - - procedure leading_0_exception_no is - x integer; - begin - x := 1 / 0; - end; - - procedure raised_diff_exception is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure empty_throws is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure bad_paramters_with_except is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure bad_paramters_without_except is - begin - null; - end; - - procedure positive_exception_number is - begin - null; - end; - - procedure positive_exception_number_var is - begin - null; - end; - - procedure one_valid_exception_number is - begin - raise dup_val_on_index; - end; - - procedure nothing_thrown is - begin - null; - end; - - procedure single_exc_const_pkg is - begin - raise_application_error(exc_pkg.c_e_single_exc,''Test''); - end; - - procedure list_of_exc_constant is - begin - raise_application_error(exc_pkg.c_e_list_1,''Test''); - end; - - procedure fail_not_match_exc is - begin - raise NO_DATA_FOUND; - end; - - procedure mixed_exc_list is - begin - raise_application_error(exc_pkg.c_e_mix_list,''Test''); - end; - - procedure mixed_list_notexi is - begin - raise_application_error(exc_pkg.c_e_mix_missin,''Test''); - end; - - procedure named_exc_pragma is - begin - raise exc_pkg.e_some_exception; - end; - - procedure named_exc_ora is - begin - raise NO_DATA_FOUND; - end; - - procedure named_exc_ora_dup_ind is - begin - raise DUP_VAL_ON_INDEX; - end; - - procedure nodata_exc_ora is - begin - raise NO_DATA_FOUND; - end; - - procedure defined_varchar_exc is - begin - raise_application_error(exc_pkg.c_e_varch_exc,''Test''); - end; - - procedure non_existing_const is - begin - raise_application_error(-20143, ''Test error''); - end; - - procedure bad_exc_const is - begin - raise_application_error(-20143, ''Test error''); - end; - - end; - '; - - execute immediate l_exception_spec; - execute immediate l_package_spec; - execute immediate l_package_body; - - - select * bulk collect into l_test_results from table(ut3_develop.ut.run(('annotated_package_with_throws'))); - - g_tests_results := ut3_develop.ut_utils.table_to_clob(l_test_results); - end; - - procedure throws_same_annotated_except is - begin - ut.expect(g_tests_results).to_match('^\s*Throws same annotated exception \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('raised_same_exception'); - end; - - procedure throws_one_of_annotated_excpt is - begin - ut.expect(g_tests_results).to_match('^\s*Throws one of the listed exceptions \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('raised_one_listed_exception'); - end; - - procedure throws_with_leading_zero is - begin - ut.expect(g_tests_results).to_match('^\s*Leading zero is ignored in exception list \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('leading_0_exception_no'); - end; - - procedure throws_diff_annotated_except is - begin - ut.expect(g_tests_results).to_match('^\s*Throws diff exception \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('raised_diff_exception\s+Actual: -20143 was expected to equal: -20144\s+ORA-20143: Test error\s+ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure throws_empty is - begin - ut.expect(g_tests_results).to_match('^\s*Throws empty \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('empty_throws\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure bad_paramters_with_except is - begin - ut.expect(g_tests_results).to_match('^\s*Ignores annotation and fails when exception was thrown \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('bad_paramters_with_except\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure bad_paramters_without_except is - begin - ut.expect(g_tests_results).to_match('^\s*Ignores annotation and succeeds when no exception thrown \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).to_match('bad_paramters_without_except\s*Invalid parameter value ".*" for "--%throws" annotation. Parameter ignored.','m'); - end; - - procedure positive_exception_number is - begin - ut.expect(g_tests_results).to_match('^\s*Ignores annotation for positive exception number value \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).to_match('positive_exception_number\s*Invalid parameter value "20001" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.','m'); - end; - - procedure positive_exception_number_var is - begin - ut.expect(g_tests_results).to_match('^\s*Ignores annotation for positive exception number variable \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).to_match('positive_exception_number_var\s*Invalid parameter value ".*" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.','m'); - end; - - procedure one_valid_exception_number is - begin - ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).to_match('one_valid_exception_number\s*Invalid parameter value ".*" for "--%throws" annotation. Parameter ignored.','m'); - end; - - procedure nothing_thrown is - begin - ut.expect(g_tests_results).to_match('^\s*Gives failure when a exception is expected and nothing is thrown \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('nothing_thrown\s*Expected one of exceptions \(-20459, -20136, -20145\) but nothing was raised.'); - end; - - procedure single_exc_const_pkg is - begin - ut.expect(g_tests_results).to_match('^\s*Single exception defined as a constant number in package \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('single_exc_const_pkg'); - end; - - procedure list_of_exc_constant is - begin - ut.expect(g_tests_results).to_match('^\s*Gives success when one of annotated exception using constant is thrown \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('list_of_exc_constant'); - end; - - procedure fail_not_match_exc is - begin - ut.expect(g_tests_results).to_match('^\s*Gives failure when the raised exception is different that the annotated one using variable \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('fail_not_match_exc\s+Actual: -1403 was expected to equal: -20204\s+ORA-01403: no data found\s+ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure mixed_exc_list is - begin - ut.expect(g_tests_results).to_match('^\s*Success when one of exception from mixed list of number and constant is thrown \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('mixed_exc_list'); - end; - - procedure mixed_list_notexi is - begin - ut.expect(g_tests_results).to_match('^\s*Success when match exception even if other variable on list dont exists \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).to_match('mixed_list_notexi\s*Invalid parameter value "utter_rubbish" for "--%throws" annotation. Parameter ignored.','m'); - end; - - procedure named_exc_pragma is - begin - ut.expect(g_tests_results).to_match('^\s*Success resolve and match named exception defined in pragma exception init \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('named_exc_pragma'); - end; - - procedure named_exc_ora is - begin - ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('named_exc_ora'); - end; - - procedure named_exc_ora_dup_ind is - begin - ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception dup val index \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('named_exc_ora_dup_ind'); - end; - - procedure nodata_exc_ora is - begin - ut.expect(g_tests_results).to_match('^\s*Success map no data 100 to -1403 \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('nodata_exc_ora'); - end; - - procedure defined_varchar_exc is - begin - ut.expect(g_tests_results).to_match('^\s*Success for exception defined as varchar \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect(g_tests_results).not_to_match('defined_varchar_exc'); - end; - - procedure non_existing_const is - begin - ut.expect(g_tests_results).to_match('^\s*Non existing constant exception \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('non_existing_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure bad_exc_const is - begin - ut.expect(g_tests_results).to_match('^\s*Bad exception constant \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); - ut.expect(g_tests_results).to_match('bad_exc_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure drop_test_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package annotated_package_with_throws'; - execute immediate 'drop package exc_pkg'; - end; - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annot_throws_exception.pks b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks deleted file mode 100644 index a9d20183d..000000000 --- a/test/ut3_tester/core/annotations/test_annot_throws_exception.pks +++ /dev/null @@ -1,82 +0,0 @@ -create or replace package test_annot_throws_exception -is - --%suite(annotations - throws) - --%suitepath(utplsql.ut3_tester.core.annotations) - - --%beforeall - procedure recollect_tests_results; - - --%test(Gives success when annotated number exception is thrown) - procedure throws_same_annotated_except; - - --%test(Gives success when one of the annotated number exceptions is thrown) - procedure throws_one_of_annotated_excpt; - - --%test(Gives success when annotated number exceptions has leading zero) - procedure throws_with_leading_zero; - - --%test(Gives failure when the raised exception is different that the annotated one) - procedure throws_diff_annotated_except; - - --%test(Ignores when the annotation throws is empty) - procedure throws_empty; - - --%test(Ignores when only bad parameters are passed, the test raise a exception and it shows errored test) - procedure bad_paramters_with_except; - - --%test(Ignores when only bad parameters are passed, the test does not raise a exception and it shows successful test) - procedure bad_paramters_without_except; - - --%test(Ignores annotation for positive exception number value) - procedure positive_exception_number; - - --%test(Ignores annotation for positive exception number variable) - procedure positive_exception_number_var; - - --%test(Detects a valid exception number within many invalid ones) - procedure one_valid_exception_number; - - --%test(Gives failure when a exception is expected and nothing is thrown) - procedure nothing_thrown; - - --%test(Single exception defined as a constant number in package) - procedure single_exc_const_pkg; - - --%test(Gives success when one of annotated exception using constant is thrown) - procedure list_of_exc_constant; - - --%test(Gives failure when the raised exception is different that the annotated one using variable) - procedure fail_not_match_exc; - - --%test(Success when one of exception from mixed list of number and constant is thrown) - procedure mixed_exc_list; - - --%test(Success when match exception even if other variable on list dont exists) - procedure mixed_list_notexi; - - --%test(Success resolve and match named exception defined in pragma exception init) - procedure named_exc_pragma; - - --%test(Success resolve and match oracle named exception no data) - procedure named_exc_ora; - - --%test(Success resolve and match oracle named exception dup val index) - procedure named_exc_ora_dup_ind; - - --%test(Success map no data 100 to -1403) - procedure nodata_exc_ora; - - --%test(Success for exception defined as varchar) - procedure defined_varchar_exc; - - --%test(Non existing constant exception) - procedure non_existing_const; - - --%test(Bad exception constant) - procedure bad_exc_const; - - --%afterall - procedure drop_test_package; - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annotation_cache.pkb b/test/ut3_tester/core/annotations/test_annotation_cache.pkb deleted file mode 100644 index eefaf8800..000000000 --- a/test/ut3_tester/core/annotations/test_annotation_cache.pkb +++ /dev/null @@ -1,521 +0,0 @@ -create or replace package body test_annotation_cache is - - procedure cache_populated_for_packages(a_packages ut_varchar2_rows) is - l_actual_cache_info sys_refcursor; - l_expected_cache_info sys_refcursor; - begin - open l_actual_cache_info for - select * - from ut3_develop.ut_annotation_cache_info - where object_owner = 'UT3_CACHE_TEST_OWNER'; - open l_expected_cache_info for - select 'UT3_CACHE_TEST_OWNER' as object_owner, upper( column_value ) as object_name - from table (a_packages) x; - ut.expect( l_actual_cache_info ).to_equal( l_expected_cache_info ).exclude( 'CACHE_ID,PARSE_TIME,OBJECT_TYPE' ).JOIN_BY('OBJECT_NAME'); - end; - - procedure cant_run_any_packages(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - - --Assert - no suites are - ut.expect( l_actual ).to_be_like( '%0 tests, 0 failed%' ); - rollback; - end; - - procedure can_run_one_package(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - - --Assert - only granted_test_suite is invoked - ut.expect( l_actual ).to_be_like( 'granted_test_suite%2 tests, 0 failed%' ); - rollback; - end; - - procedure can_run_new_package(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Arrange - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.add_new_suite( ); - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - --Assert -Both granted_test_suite and new_suite are invoked - ut.expect( l_actual ).to_be_like( 'granted_test_suite%new_suite%4 tests, 0 failed%' ); - rollback; - end ; - - procedure cant_run_revoked_package(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Arrange - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.add_new_suite( ); - annotation_cache_helper.revoke_granted_suite( ); - - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - --Assert -Only new_suite gets invoked - ut.expect( l_actual ).to_be_like( 'new_suite%2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - ut.expect( l_actual ).not_to_be_like( '%granted_test_suite%' ); - rollback; - end; - - procedure cant_run_dropped_package(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Arrange - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.add_new_suite( ); - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.revoke_granted_suite( ); - annotation_cache_helper.cleanup_new_suite( ); - - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - --Assert - no test suites are invoked - ut.expect( l_actual ).to_be_like( '%0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - ut.expect( l_actual ).not_to_be_like( '%new_suite%' ); - ut.expect( l_actual ).not_to_be_like( '%granted_test_suite%' ); - rollback; - end; - - procedure can_run_all_packages(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - - --Assert - only granted_test_suite is invoked - ut.expect( l_actual ).to_be_like( 'granted_test_suite%not_granted_test_suite%4 tests, 0 failed%' ); - rollback; - end; - - procedure can_run_all_new_packages(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Arrange - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.add_new_suite( ); - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - - --Assert - only granted_test_suite is invoked - ut.expect( l_actual ).to_be_like( 'granted_test_suite%new_suite%not_granted_test_suite% tests, 0 failed%' ); - rollback; - end; - - procedure can_run_revoked_packages(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Arrange - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.add_new_suite( ); - annotation_cache_helper.revoke_granted_suite( ); - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - - --Assert - only granted_test_suite is invoked - ut.expect( l_actual ).to_be_like( 'granted_test_suite%new_suite%not_granted_test_suite% tests, 0 failed%' ); - rollback; - end; - - procedure can_run_all_but_dropped(a_user varchar2) is - l_actual clob; - l_current_time date := sysdate; - pragma autonomous_transaction; - begin - --Arrange - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.add_new_suite( ); - l_actual := annotation_cache_helper.run_tests_as( a_user ); - annotation_cache_helper.revoke_granted_suite( ); - annotation_cache_helper.cleanup_new_suite( ); - - --Act - l_actual := annotation_cache_helper.run_tests_as( a_user ); - --Assert - no test suites are invoked - ut.expect( l_actual ).to_be_like( 'granted_test_suite%not_granted_test_suite%4 tests, 0 failed%' ); - ut.expect( l_actual ).not_to_be_like( '%new_suite%' ); - rollback; - end; - - - procedure user_can_run_one_package is - begin - can_run_one_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure user_can_run_new_package is - begin - can_run_new_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure user_cant_run_revoked_package is - begin - cant_run_revoked_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure user_cant_run_dropped_package is - begin - cant_run_dropped_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure sel_cat_user_can_run_one is - begin - can_run_one_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure sel_cat_user_can_run_new is - begin - can_run_new_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure sel_cat_user_cant_run_revoked is - begin - cant_run_revoked_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure sel_cat_user_cant_run_dropped is - begin - cant_run_dropped_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure sel_any_user_can_run_one is - begin - can_run_one_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure sel_any_user_can_run_new is - begin - can_run_new_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure sel_any_user_cant_run_revoked is - begin - cant_run_revoked_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure sel_any_user_cant_run_dropped is - begin - cant_run_dropped_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure exe_any_user_can_run_all is - begin - can_run_all_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure exe_any_user_can_run_new is - begin - can_run_all_new_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure exe_any_user_can_run_revoked is - begin - can_run_revoked_packages('ut3_execute_any_proc_user'); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure exe_any_user_cant_run_dropped is - begin - can_run_all_but_dropped('ut3_execute_any_proc_user'); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure owner_user_can_run_all is - begin - can_run_all_packages( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - - procedure owner_user_can_run_new is - begin - can_run_all_new_packages( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure owner_user_cant_run_dropped is - begin - can_run_all_but_dropped('ut3_cache_test_owner'); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - - procedure t_user_can_run_one_package is - begin - can_run_one_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_user_can_run_new_package is - begin - can_run_new_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_user_cant_run_revoked_pkg is - begin - cant_run_revoked_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_user_cant_run_dropped_pkg is - begin - cant_run_dropped_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_cat_user_can_run_one is - begin - can_run_one_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_cat_user_can_run_new is - begin - can_run_new_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_cat_user_cant_run_revokd is - begin - cant_run_revoked_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_cat_user_cant_run_dropd is - begin - cant_run_dropped_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - - procedure t_sel_any_user_can_run_one is - begin - can_run_one_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_any_user_can_run_new is - begin - can_run_new_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_any_user_cant_run_revokd is - begin - cant_run_revoked_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_sel_any_user_cant_run_dropd is - begin - cant_run_dropped_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - - procedure t_exe_any_user_can_run_all is - begin - can_run_all_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_exe_any_user_can_run_new is - begin - can_run_all_new_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_exe_any_user_can_run_revokd is - begin - can_run_revoked_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_exe_any_user_cant_run_dropd is - begin - can_run_all_but_dropped( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_owner_user_can_run_all is - begin - can_run_all_packages( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_owner_user_can_run_new is - begin - can_run_all_new_packages( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_owner_user_cant_run_dropd is - begin - can_run_all_but_dropped( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure t_ut_owner_cannot_run_tests is - begin - cant_run_any_packages( 'ut3_develop' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - - - procedure p_user_can_run_one_package is - begin - can_run_one_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure p_user_can_run_new_package is - begin - can_run_new_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure p_user_cant_run_revoked_pack is - begin - cant_run_revoked_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure p_user_cant_run_dropped_pack is - begin - cant_run_dropped_package( 'ut3_no_extra_priv_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - - - procedure p_sel_cat_user_can_run_one is - begin - can_run_one_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure p_sel_cat_user_can_run_new is - begin - can_run_new_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure p_sel_cat_user_cant_run_revokd is - begin - cant_run_revoked_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure p_sel_cat_user_cant_run_dropd is - begin - cant_run_dropped_package( 'ut3_select_catalog_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure p_sel_any_user_can_run_one is - begin - can_run_one_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure p_sel_any_user_can_run_new is - begin - can_run_new_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure p_sel_any_user_cant_run_revokd is - begin - cant_run_revoked_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE' ) ); - end; - - procedure p_sel_any_user_cant_run_dropd is - begin - cant_run_dropped_package( 'ut3_select_any_table_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE' ) ); - end; - - procedure p_exe_any_user_can_run_all is - begin - can_run_all_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure p_exe_any_user_can_run_new is - begin - can_run_all_new_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure p_exe_any_user_can_run_revokd is - begin - can_run_revoked_packages( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure p_exe_any_user_cant_run_dropd is - begin - can_run_all_but_dropped( 'ut3_execute_any_proc_user' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure p_owner_user_can_run_all is - begin - can_run_all_packages( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure p_owner_user_can_run_new is - begin - can_run_all_new_packages( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NEW_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - - procedure p_owner_user_cant_run_dropped is - begin - can_run_all_but_dropped( 'ut3_cache_test_owner' ); - cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); - end; - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annotation_cache.pks b/test/ut3_tester/core/annotations/test_annotation_cache.pks deleted file mode 100644 index 5a3fdd8ca..000000000 --- a/test/ut3_tester/core/annotations/test_annotation_cache.pks +++ /dev/null @@ -1,280 +0,0 @@ -create or replace package test_annotation_cache is - - --%suite(annotation cache) - --%suitepath(utplsql.ut3_tester.core.annotations) - --%beforeall(annotation_cache_helper.create_run_function_for_users) - --%afterall(annotation_cache_helper.drop_run_function_for_users) - - --%context(With DDL trigger enabled) - - --%beforeall(annotation_cache_helper.enable_ddl_trigger) - --%beforeeach(annotation_cache_helper.setup_two_suites) - --%aftereach(annotation_cache_helper.cleanup_new_suite) - --%afterall(annotation_cache_helper.cleanup_two_suites) - - --%context(User without elevated privileges) - - --%test(Can only execute granted packages) - procedure t_user_can_run_one_package; - - --%test(Can see newly created packages as they are added) - procedure t_user_can_run_new_package; - - --%test(Cannot execute revoked packages) - procedure t_user_cant_run_revoked_pkg; - - --%test(Cannot execute dropped unit test packages) - procedure t_user_cant_run_dropped_pkg; - - --%endcontext - - --%context(User with select_catalog_role) - - --%test(Can only execute granted packages) - procedure t_sel_cat_user_can_run_one; - - --%test(Can see newly created packages as they are added) - procedure t_sel_cat_user_can_run_new; - - --%test(Cannot execute revoked packages) - procedure t_sel_cat_user_cant_run_revokd; - - --%test(Cannot execute dropped unit test packages) - procedure t_sel_cat_user_cant_run_dropd; - - --%endcontext - - --%context(User with select any table privilege) - - --%test(Can only execute granted packages) - procedure t_sel_any_user_can_run_one; - - --%test(Can see newly created packages as they are added) - procedure t_sel_any_user_can_run_new; - - --%test(Cannot execute revoked packages) - procedure t_sel_any_user_cant_run_revokd; - - --%test(Cannot execute dropped unit test packages) - procedure t_sel_any_user_cant_run_dropd; - - --%endcontext - - --%context(User with execute any procedure) - - --%test(Can execute and see all unit test packages) - procedure t_exe_any_user_can_run_all; - - --%test(Can see newly created packages as they are added) - procedure t_exe_any_user_can_run_new; - - --%test(Can execute revoked packages) - procedure t_exe_any_user_can_run_revokd; - - --%test(Cannot execute dropped unit test packages) - procedure t_exe_any_user_cant_run_dropd; - - --%endcontext - - --%context(User owning test packages) - - --%test(Can execute and see all unit test packages) - procedure t_owner_user_can_run_all; - - --%test(Can see newly created packages as they are added) - procedure t_owner_user_can_run_new; - - --%test(Cannot execute dropped unit test packages) - procedure t_owner_user_cant_run_dropd; - - --%endcontext - - --%context(utPLSQL framework owner) - - --%test(Cannot see any tests and doesn't impact annotation cache ) - procedure t_ut_owner_cannot_run_tests; - - --%endcontext - - --%endcontext - - --%context(With DDL trigger disabled) - - --%beforeall(annotation_cache_helper.disable_ddl_trigger) - --%beforeeach(annotation_cache_helper.setup_two_suites) - --%beforeeach(annotation_cache_helper.purge_annotation_cache) - --%aftereach(annotation_cache_helper.cleanup_new_suite) - --%afterall(annotation_cache_helper.enable_ddl_trigger) - --%afterall(annotation_cache_helper.cleanup_two_suites) - - --%context(User without elevated privileges) - - --%test(Can only execute granted packages) - procedure user_can_run_one_package; - - --%test(Can see newly created packages as they are added) - procedure user_can_run_new_package; - - --%test(Cannot execute revoked packages) - procedure user_cant_run_revoked_package; - - --%test(Cannot execute dropped unit test packages) - procedure user_cant_run_dropped_package; - - --%endcontext - - --%context(User with select_catalog_role) - - --%test(Can only execute granted packages) - procedure sel_cat_user_can_run_one; - - --%test(Can see newly created packages as they are added) - procedure sel_cat_user_can_run_new; - - --%test(Cannot execute revoked packages) - procedure sel_cat_user_cant_run_revoked; - - --%test(Cannot execute dropped unit test packages) - procedure sel_cat_user_cant_run_dropped; - - --%endcontext - - --%context(User with select any table privilege) - - --%test(Can only execute granted packages) - procedure sel_any_user_can_run_one; - - --%test(Can see newly created packages as they are added) - procedure sel_any_user_can_run_new; - - --%test(Cannot execute revoked packages) - procedure sel_any_user_cant_run_revoked; - - --%test(Cannot execute dropped unit test packages) - procedure sel_any_user_cant_run_dropped; - - --%endcontext - - --%context(User with execute any procedure) - - --%test(Can execute and see all unit test packages) - procedure exe_any_user_can_run_all; - - --%test(Can see newly created packages as they are added) - procedure exe_any_user_can_run_new; - - --%test(Can execute revoked packages) - procedure exe_any_user_can_run_revoked; - - --%test(Cannot execute dropped unit test packages) - procedure exe_any_user_cant_run_dropped; - - --%endcontext - - --%context(User owning test packages) - - --%test(Can execute and see all unit test packages) - procedure owner_user_can_run_all; - - --%test(Can see newly created packages as they are added) - procedure owner_user_can_run_new; - - --%test(Cannot execute dropped unit test packages) - procedure owner_user_cant_run_dropped; - - --%endcontext - - --%endcontext - - --%context(With DDL trigger enabled and cache purged) - - --%beforeall(annotation_cache_helper.enable_ddl_trigger) - - --%beforeeach(annotation_cache_helper.setup_two_suites) - --%beforeeach(annotation_cache_helper.purge_annotation_cache) - - --%aftereach(annotation_cache_helper.cleanup_new_suite) - --%aftereach(annotation_cache_helper.cleanup_two_suites) - - --%context(User without elevated privileges) - - --%test(Can only execute granted packages) - procedure p_user_can_run_one_package; - - --%test(Can see newly created packages as they are added) - procedure p_user_can_run_new_package; - - --%test(Cannot execute revoked packages) - procedure p_user_cant_run_revoked_pack; - - --%test(Cannot execute dropped unit test packages) - procedure p_user_cant_run_dropped_pack; - - --%endcontext - - --%context(User with select_catalog_role) - - --%test(Can only execute granted packages) - procedure p_sel_cat_user_can_run_one; - - --%test(Can see newly created packages as they are added) - procedure p_sel_cat_user_can_run_new; - - --%test(Cannot execute revoked packages) - procedure p_sel_cat_user_cant_run_revokd; - - --%test(Cannot execute dropped unit test packages) - procedure p_sel_cat_user_cant_run_dropd; - - --%endcontext - - --%context(User with select any table privilege) - - --%test(Can only execute granted packages) - procedure p_sel_any_user_can_run_one; - - --%test(Can see newly created packages as they are added) - procedure p_sel_any_user_can_run_new; - - --%test(Cannot execute revoked packages) - procedure p_sel_any_user_cant_run_revokd; - - --%test(Cannot execute dropped unit test packages) - procedure p_sel_any_user_cant_run_dropd; - - --%endcontext - - --%context(User with execute any procedure) - - --%test(Can execute and see all unit test packages) - procedure p_exe_any_user_can_run_all; - - --%test(Can see newly created packages as they are added) - procedure p_exe_any_user_can_run_new; - - --%test(Can execute revoked packages) - procedure p_exe_any_user_can_run_revokd; - - --%test(Cannot execute dropped unit test packages) - procedure p_exe_any_user_cant_run_dropd; - - --%endcontext - - --%context(User owning test packages) - - --%test(Can execute and see all unit test packages) - procedure p_owner_user_can_run_all; - - --%test(Can see newly created packages as they are added) - procedure p_owner_user_can_run_new; - - --%test(Cannot execute dropped unit test packages) - procedure p_owner_user_cant_run_dropped; - - --%endcontext - - - --%endcontext - -end; -/ diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pkb b/test/ut3_tester/core/annotations/test_annotation_manager.pkb deleted file mode 100644 index 8eb3c2f6d..000000000 --- a/test/ut3_tester/core/annotations/test_annotation_manager.pkb +++ /dev/null @@ -1,466 +0,0 @@ -create or replace package body test_annotation_manager is - - procedure exec_autonomous(a_sql varchar2) is - pragma autonomous_transaction; - begin - execute immediate a_sql; - end; - - procedure create_dummy_package is - begin - exec_autonomous(q'[create or replace package dummy_package as - procedure some_dummy_procedure; - end;]'); - end; - - procedure drop_dummy_package is - begin - exec_autonomous(q'[drop package dummy_package]'); - exception - when others then - null; - end; - - procedure recompile_dummy_package is - begin - exec_autonomous(q'[alter package dummy_package compile]'); - end; - - procedure create_dummy_test_package is - begin - exec_autonomous(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;]'); - exec_autonomous(q'[grant execute on dummy_test_package to public]'); - end; - - procedure modify_dummy_test_package is - begin - exec_autonomous(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 - begin - exec_autonomous(q'[drop package dummy_test_package]'); - exception - when others then - null; - end; - - procedure recompile_dummy_test_package is - begin - exec_autonomous(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_develop.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_develop.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_time timestamp) is - l_actual_cache_id integer; - l_data ut3_develop.ut_annotated_objects; - l_result sys_refcursor; - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_expected for - select - ut3_develop.ut_annotated_object( - sys_context('USERENV', 'CURRENT_USER'), - 'DUMMY_TEST_PACKAGE', 'PACKAGE', a_start_time, - ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', 'dummy_test_suite', null ), - ut3_develop.ut_annotation( 3, 'rollback', 'manual', null ), - ut3_develop.ut_annotation( 7, 'test', 'dummy_test', 'some_dummy_test_procedure' ), - ut3_develop.ut_annotation( 8, 'beforetest', 'some_procedure', 'some_dummy_test_procedure' ) - ) - ) annotated_object - from dual; - - l_result := ut3_develop.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE', a_start_time); - fetch l_result bulk collect into l_data; - open l_actual for select value(x) as annotated_object from table(l_data) x where object_name = 'DUMMY_TEST_PACKAGE'; - ut.expect(l_actual).to_equal(l_expected).exclude('ANNOTATED_OBJECT/PARSE_TIME').join_by('ANNOTATED_OBJECT/OBJECT_NAME'); - end; - - - procedure trg_skip_existing_package is - l_actual_cache_id integer; - begin - --Arrange - annotation_cache_helper.disable_ddl_trigger(); - create_dummy_test_package(); - --Act - annotation_cache_helper.enable_ddl_trigger(); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3_develop.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 - annotation_cache_helper.disable_ddl_trigger(); - create_dummy_test_package(); - --Act - annotation_cache_helper.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 - annotation_cache_helper.disable_ddl_trigger(); - create_dummy_test_package(); - create_dummy_package(); - --Act - annotation_cache_helper.enable_ddl_trigger(); - l_start_date := sysdate; - ut3_develop.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 - --Arrange - open l_actual for - select * - from ut3_develop.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(); - - --Act - create_dummy_package(); - --Assert - open l_actual for - select * - from ut3_develop.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; - - 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_develop.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; - - procedure trg_populate_cache_after_purge is - l_start_date date; - begin - --Arrange - create_dummy_test_package(); - l_start_date := sysdate; - ut3_develop.ut_annotation_manager.purge_cache(sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE'); - --Act & Assert - assert_dummy_test_package(l_start_date); - end; - - procedure add_annotated_package is - l_start_time timestamp := systimestamp; - begin - --Arrange - create_dummy_test_package(); - --Act & Assert - assert_dummy_test_package( l_start_time ); - end; - - procedure remove_annotated_package is - l_start_time timestamp := systimestamp; - begin - --Arrange - create_dummy_test_package(); - assert_dummy_test_package( l_start_time ); - - --Act - drop_dummy_test_package(); - - --Assert - ut.expect( - ut3_develop.ut_annotation_manager.get_annotated_objects( - sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time - ), - 'Annotations are empty after package was dropped' - ).to_be_empty(); - end; - - procedure add_not_annotated_package is - l_start_time timestamp := systimestamp; - begin - --Arrange - create_dummy_package(); - --Act & Assert - ut.expect( - ut3_develop.ut_annotation_manager.get_annotated_objects( - sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time - ), - 'Annotations are empty for not annotated package' - ).to_be_empty(); - end; - - procedure remove_not_annotated_package is - l_start_time timestamp := systimestamp; - begin - --Arrange - create_dummy_package(); - ut.expect( - ut3_develop.ut_annotation_manager.get_annotated_objects( - sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time - ), - 'Annotations are empty for non annotated package' - ).to_be_empty(); - - --Act - drop_dummy_package(); - - --Assert - ut.expect( - ut3_develop.ut_annotation_manager.get_annotated_objects( - sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time - ), - 'Annotations are empty after non annoteted package was dropped' - ).to_be_empty(); - end; - - procedure remove_annotations_from_pkg is - l_start_time timestamp := systimestamp; - begin - --Arrange - create_dummy_test_package(); - assert_dummy_test_package( l_start_time ); - - --Act - exec_autonomous(q'[create or replace package dummy_test_package as - procedure some_dummy_test_procedure; - end;]'); - - --Assert - ut.expect( - ut3_develop.ut_annotation_manager.get_annotated_objects( - sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time - ) - ).to_be_empty(); - end; - - procedure add_annotations_to_package is - l_start_time timestamp := systimestamp; - begin - --Arrange - exec_autonomous(q'[create or replace package dummy_test_package as - procedure some_dummy_test_procedure; - end;]'); - ut.expect( - ut3_develop.ut_annotation_manager.get_annotated_objects( - sys_context( 'USERENV', 'CURRENT_USER' ), 'PACKAGE', l_start_time - ) - ).to_be_empty(); - - --Act - create_dummy_test_package(); - - --Assert - assert_dummy_test_package( l_start_time ); - 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_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); - l_start_date := sysdate; - modify_dummy_test_package(); - --Act - ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); - --Assert - select max(cache_id) - into l_actual_cache_id - from ut3_develop.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_develop.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_cache_count integer; - l_start_date date; - begin - l_start_date := sysdate; - parse_dummy_test_as_ut3_user(); - drop_dummy_test_package(); - --Act - parse_dummy_test_as_ut3_user(); - --Assert - select count(1) - into l_cache_count - from ut3_develop.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_cache_count ).to_equal(1); - end; - - procedure no_data_for_dropped_object is - l_result sys_refcursor; - l_data ut3_develop.ut_annotated_objects; - l_actual sys_refcursor; - l_start_time timestamp := systimestamp; - begin - --Arrange - drop_dummy_test_package(); - --Act - l_result := ut3_develop.ut_annotation_manager.get_annotated_objects( sys_context('USERENV', 'CURRENT_USER'),'PACKAGE', l_start_time ); - fetch l_result bulk collect into l_data; - open l_actual for select object_name from table(l_data) 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; - begin - --Arrange - ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); - drop_dummy_test_package(); - --Act - ut3_develop.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); - --Assert - select count(1) - into l_cache_count - from ut3_develop.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; - - procedure populate_cache_after_purge is - l_start_date date; - begin - --Arrange - create_dummy_test_package(); - l_start_date := sysdate; - ut3_develop.ut_annotation_manager.purge_cache(sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE'); - --Act & Assert - assert_dummy_test_package(l_start_date); - 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 deleted file mode 100644 index 7207917f3..000000000 --- a/test/ut3_tester/core/annotations/test_annotation_manager.pks +++ /dev/null @@ -1,104 +0,0 @@ -create or replace package test_annotation_manager is - - --%suite(ut_annotation_manager) - --%suitepath(utplsql.ut3_tester.core.annotations) - - --%afterall(drop_dummy_test_package) - - --%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; - - --%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(Objects are populated on scan after cache was purged) - --%beforetest(annotation_cache_helper.disable_ddl_trigger) - --%aftertest(annotation_cache_helper.enable_ddl_trigger) - procedure trg_populate_cache_after_purge; - - --%endcontext - - --%context(Without DDL trigger) - - --%beforeall(annotation_cache_helper.disable_ddl_trigger) - - --%afterall(annotation_cache_helper.enable_ddl_trigger) - - --%beforeeach(create_dummy_package) - --%aftereach(drop_dummy_package) - - --%test(Returns annotations when annotated package was created) - --%aftertest(drop_dummy_test_package) - procedure add_annotated_package; - - --%test(Doesn't return annotations when annotated package was removed) - --%aftertest(drop_dummy_test_package) - procedure remove_annotated_package; - - --%test(Doesn't return annotations when package doesn't contain annotations) - procedure add_not_annotated_package; - - --%test(Doesn't return annotations when package without annotations was dropped) - procedure remove_not_annotated_package; - - --%test(Doesn't return annotations when annotations removed from package) - --%aftertest(drop_dummy_test_package) - procedure remove_annotations_from_pkg; - - --%test(Returns annotations when annotations were added to package) - --%aftertest(drop_dummy_test_package) - procedure add_annotations_to_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; - - --%test(Objects are populated on scan after cache was purged) - procedure populate_cache_after_purge; - - --%endcontext - -end test_annotation_manager; -/ diff --git a/test/ut3_tester/core/annotations/test_annotation_parser.pkb b/test/ut3_tester/core/annotations/test_annotation_parser.pkb deleted file mode 100644 index bc789c377..000000000 --- a/test/ut3_tester/core/annotations/test_annotation_parser.pkb +++ /dev/null @@ -1,461 +0,0 @@ -create or replace package body test_annotation_parser is - - procedure test_proc_comments is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - -- %ann1(Name of suite) - -- wrong line - -- %ann2(some_value) - procedure foo; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2,'suite',null, null), - ut3_develop.ut_annotation(3,'displayname','Name of suite',null), - ut3_develop.ut_annotation(4,'suitepath','all.globaltests',null), - ut3_develop.ut_annotation(6,'ann1','Name of suite',null), - ut3_develop.ut_annotation(8,'ann2','some_value','foo') - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure include_floating_annotations is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - -- %ann1(Name of suite) - -- %ann2(all.globaltests) - - --%test - procedure foo; - - -- %ann3(Name of suite) - -- %ann4(all.globaltests) - - --%test - procedure bar; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3_develop.ut_annotation( 6, 'ann1', 'Name of suite', null ), - ut3_develop.ut_annotation( 7, 'ann2', 'all.globaltests', null ), - ut3_develop.ut_annotation( 9, 'test', null, 'foo'), - ut3_develop.ut_annotation( 12, 'ann3', 'Name of suite', null ), - ut3_develop.ut_annotation( 13, 'ann4', 'all.globaltests', null ), - ut3_develop.ut_annotation( 15, 'test', null, 'bar') - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure parse_complex_with_functions is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - --%test - procedure foo; - - - --%beforeeach - procedure foo2; - - --test comment - -- wrong comment - - - /* - describtion of the procedure - */ - --%beforeeach(key=testval) - PROCEDURE foo3(a_value number default null); - - --%all - function foo4(a_val number default null - , a_par varchar2 default := ''asdf''); - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3_develop.ut_annotation( 6, 'test', null, 'foo' ), - ut3_develop.ut_annotation( 10, 'beforeeach', null,'foo2' ), - ut3_develop.ut_annotation( 20, 'beforeeach', 'key=testval','foo3' ), - ut3_develop.ut_annotation( 23, 'all', null,'foo4' ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure no_procedure_annotation is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure parse_accessible_by is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt accessible by (foo) AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure complex_package_declaration is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt - ACCESSIBLE BY (calling_proc) - authid current_user - AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 5, 'suite', null, null ), - ut3_develop.ut_annotation( 6, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 7, 'suitepath', 'all.globaltests', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure complex_text is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt AS - -- %suite - --%displayname(name = Name of suite) - -- %suitepath(key=all.globaltests,key2=foo,"--%some text") - - procedure foo; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'name = Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'key=all.globaltests,key2=foo,"--%some text"', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure ignore_annotations_in_comments is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt AS - /* - Some comment - -- inlined - -- %ignored - */ - -- %suite - --%displayname(Name of suite) - -- %suitepath(all.globaltests) - - procedure foo; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 7, 'suite', null, null ), - ut3_develop.ut_annotation( 8, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 9, 'suitepath', 'all.globaltests', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - - procedure ignore_wrapped_package is - l_source dbms_preprocessor.source_lines_t; - l_actual ut3_develop.ut_annotations; - begin - --Arrange - l_source(1) := 'create or replace PACKAGE tst_wrapped_pck wrapped -a000000 -369 -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -abcd -9 -34 6d -bg9Jaf2KguofrwaqloE8yvbggKcwg5m49TOf9b9cFj7R9JaW8lYWWi70llr/K6V0iwlp5+eb -v58yvbLAXLi9gYHwoIvAgccti+Cmpg0DKLY= --- %some_annotation_like_text -'; - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source,'PACKAGE'); - --Assert - ut.expect(anydata.convertCollection(l_actual)).to_be_empty(); - end; - - procedure brackets_in_desc is - - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - begin - l_source := 'PACKAGE test_tt AS - -- %suite(Name of suite (including some brackets) and some more text) -END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', 'Name of suite (including some brackets) and some more text', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure test_space_before_annot_params is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - - begin - l_source := 'PACKAGE test_tt AS - /* - Some comment - -- inlined - */ - -- %suite - -- %suitepath (all.globaltests) - - procedure foo; -END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 6, 'suite', null, null ), - ut3_develop.ut_annotation( 7, 'suitepath', 'all.globaltests', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure test_windows_newline - as - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - begin - l_source := 'PACKAGE test_tt AS - -- %suite - -- %displayname(Name of suite)' || chr(13) || chr(10) - || ' -- %suitepath(all.globaltests) - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure test_annot_very_long_name - as - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - begin - l_source := 'PACKAGE very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it AS - -- %suite - -- %displayname(Name of suite) - -- %suitepath(all.globaltests) - - --%test - procedure very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_dit_it; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3_develop.ut_annotation( 6, 'test', null, 'very_long_procedure_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_dit_it' ) - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure test_upper_annot is - l_source clob; - l_actual ut3_develop.ut_annotations; - l_expected ut3_develop.ut_annotations; - begin - l_source := 'PACKAGE test_tt AS - -- %SUITE - -- %DISPLAYNAME(Name of suite) - -- %SUITEPATH(all.globaltests) - - -- %ANN1(Name of suite) - -- %ANN2(all.globaltests) - - --%TEST - procedure foo; - - -- %ANN3(Name of suite) - -- %ANN4(all.globaltests) - - --%TEST - procedure bar; - END;'; - - --Act - l_actual := ut3_develop.ut_annotation_parser.parse_object_annotations(l_source); - - --Assert - l_expected := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 2, 'suite', null, null ), - ut3_develop.ut_annotation( 3, 'displayname', 'Name of suite', null ), - ut3_develop.ut_annotation( 4, 'suitepath', 'all.globaltests', null ), - ut3_develop.ut_annotation( 6, 'ann1', 'Name of suite', null ), - ut3_develop.ut_annotation( 7, 'ann2', 'all.globaltests', null ), - ut3_develop.ut_annotation( 9, 'test', null, 'foo'), - ut3_develop.ut_annotation( 12, 'ann3', 'Name of suite', null ), - ut3_develop.ut_annotation( 13, 'ann4', 'all.globaltests', null ), - ut3_develop.ut_annotation( 15, 'test', null, 'bar') - ); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - - end; - -end test_annotation_parser; -/ diff --git a/test/ut3_tester/core/annotations/test_annotation_parser.pks b/test/ut3_tester/core/annotations/test_annotation_parser.pks deleted file mode 100644 index a4fe3ed70..000000000 --- a/test/ut3_tester/core/annotations/test_annotation_parser.pks +++ /dev/null @@ -1,42 +0,0 @@ -create or replace package test_annotation_parser is - - --%suite(ut_annotation_parser) - --%suitepath(utplsql.ut3_tester.core.annotations) - - --%test(Treats procedure level annotations as package level, if mixed with comments) - procedure test_proc_comments; - --%test(Includes floating annotations between procedures and package) - procedure include_floating_annotations; - --%test(Parses complex annotations on procedures and functions) - procedure parse_complex_with_functions; - --%test(Parses package annotations without any procedure annotations) - procedure no_procedure_annotation; - --%test(Parses package level annotations with Accessible by) - procedure parse_accessible_by; - --%test(Parses package level annotations with multiline declaration) - procedure complex_package_declaration; - --%test(Parses complex text in annotation) - procedure complex_text; - --%test(Ignores content of multi-line comments) - procedure ignore_annotations_in_comments; - - --%test(Ignores wrapped package and does not raise exception) - procedure ignore_wrapped_package; - - --%test(Parses package level annotations with annotation params containing brackets) - procedure brackets_in_desc; - - --%test(Parses annotation text even with spaces before brackets) - procedure test_space_before_annot_params; - - -- %test(Parses source-code with Windows-style newline) - procedure test_windows_newline; - - -- %test(Parses annotations with very long object names) - procedure test_annot_very_long_name; - - -- %test(Parses upper case annotations) - procedure test_upper_annot; - -end test_annotation_parser; -/ diff --git a/test/ut3_tester/core/annotations/test_before_after_annotations.pkb b/test/ut3_tester/core/annotations/test_before_after_annotations.pkb deleted file mode 100644 index 75bbadcc0..000000000 --- a/test/ut3_tester/core/annotations/test_before_after_annotations.pkb +++ /dev/null @@ -1,310 +0,0 @@ -create or replace package body test_before_after_annotations is - - type t_executed_procedures is table of t_procedures index by t_procedure_name; - g_tests_results clob; - g_executed_procedures t_executed_procedures; - - - procedure set_procs_called(a_for_procedure t_procedure_name, a_procedures t_procedures) is - begin - g_executed_procedures(a_for_procedure) := a_procedures; - end; - - function get_procs_called(a_for_procedure varchar2) return t_procedures pipelined is - begin - if g_executed_procedures.exists(a_for_procedure) then - for i in 1 .. g_executed_procedures(a_for_procedure).count loop - pipe row (g_executed_procedures(a_for_procedure)(i)); - end loop; - end if; - return; - end; - - procedure create_tests_results is - pragma autonomous_transaction; - - - l_dummy_utility_pkg_spec varchar2(32737); - l_dummy_utility_pkg_body varchar2(32737); - l_test_package_spec varchar2(32737); - l_test_package_body varchar2(32737); - l_test_results ut3_develop.ut_varchar2_list; - - begin - l_dummy_utility_pkg_spec := q'[ - create or replace package shared_test_package is - - procedure before_test; - - procedure set_proc_called(a_procedure_name varchar2); - - function get_procs_called return test_before_after_annotations.t_procedures; - - procedure reset_proc_called; - - end; - ]'; - - l_dummy_utility_pkg_body := q'[ - create or replace package body shared_test_package is - - g_called_procedures test_before_after_annotations.t_procedures := test_before_after_annotations.t_procedures(); - - procedure set_proc_called(a_procedure_name varchar2) is - begin - g_called_procedures.extend; - g_called_procedures(g_called_procedures.last) := a_procedure_name; - end; - - function get_procs_called return test_before_after_annotations.t_procedures is - begin - return g_called_procedures; - end; - - procedure reset_proc_called is - begin - g_called_procedures.delete; - end; - - procedure before_test is - begin - set_proc_called('shared_test_package.before_test'); - end; - - end; - ]'; - - l_test_package_spec := q'[ - create or replace package dummy_before_after_test is - --%suite(Package to test annotations beforetest and aftertest) - - --%aftereach - procedure clean_global_variables; - - --%test(Executes Beforetest call to procedure inside package) - --%beforetest(before_test) - procedure beforetest_local_procedure; - - --%test(Executes beforetest procedure defined in the package when specified with package name) - --%beforetest(dummy_before_after_test.before_test) - procedure beforetest_local_proc_with_pkg; - - --%test(Executes Beforetest procedure twice when defined twice) - --%beforetest(before_test, before_test) - procedure beforetest_twice; - - --%test(Executes Beforetest procedure from external package) - --%beforetest(shared_test_package.before_test) - procedure beforetest_one_ext_procedure; - - --%test(Executed external and internal Beforetest procedures) - --%beforetest(shared_test_package.before_test, before_test) - procedure beforetest_multi_ext_procedure; - - --%test(Stops execution at first non-existing Beforetest procedure and marks test as errored) - --%beforetest(shared_test_package.before_test, non_existent_procedure, before_test) - procedure beforetest_missing_procedure; - - --%test(Stops execution at first erroring Beforetest procedure and marks test as errored) - --%beforetest(shared_test_package.before_test, before_test_erroring, before_test) - procedure beforetest_one_err_procedure; - - procedure before_test; - - procedure before_test_erroring; - - end; - ]'; - - l_test_package_body := q'[ - create or replace package body dummy_before_after_test is - - procedure clean_global_variables is - begin - shared_test_package.reset_proc_called; - end; - - procedure beforetest_local_procedure is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_local_procedure', - shared_test_package.get_procs_called() - ); - end; - - procedure beforetest_local_proc_with_pkg is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_local_proc_with_pkg', - shared_test_package.get_procs_called() - ); - end; - - procedure beforetest_twice is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_twice', - shared_test_package.get_procs_called() - ); - end; - - procedure beforetest_one_ext_procedure is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_one_ext_procedure', - shared_test_package.get_procs_called() - ); - end; - - procedure beforetest_multi_ext_procedure is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_multi_ext_procedure', - shared_test_package.get_procs_called() - ); - end; - - procedure beforetest_missing_procedure is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_missing_procedure', - shared_test_package.get_procs_called() - ); - end; - - procedure beforetest_one_err_procedure is - begin - test_before_after_annotations.set_procs_called( - 'beforetest_one_err_procedure', - shared_test_package.get_procs_called() - ); - end; - - procedure before_test is - begin - shared_test_package.set_proc_called('dummy_before_after_test.before_test'); - end; - - procedure before_test_erroring is - begin - shared_test_package.set_proc_called('dummy_before_after_test.before_test_erroring'); - raise program_error; - end; - - end; - ]'; - - execute immediate l_dummy_utility_pkg_spec; - execute immediate l_dummy_utility_pkg_body; - execute immediate l_test_package_spec; - execute immediate l_test_package_body; - - --Execute the tests and collect the results - select * bulk collect into l_test_results from table(ut3_develop.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_tester_helper.main_helper.table_to_clob(l_test_results); - end; - - procedure beforetest_local_procedure is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - open l_expected for - select 'dummy_before_after_test.before_test' as column_value from dual; - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_local_procedure')); - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure beforetest_local_proc_with_pkg is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - open l_expected for - select 'dummy_before_after_test.before_test' as column_value from dual; - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_local_procedure')); - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure beforetest_twice is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - open l_expected for - select 'dummy_before_after_test.before_test' as column_value from dual union all - select 'dummy_before_after_test.before_test' as column_value from dual; - - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_twice')); - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure beforetest_one_ext_procedure is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - open l_expected for - select 'shared_test_package.before_test' as column_value from dual; - - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_one_ext_procedure')); - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure beforetest_multi_ext_procedure is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - open l_expected for - select 'shared_test_package.before_test' as column_value from dual union all - select 'dummy_before_after_test.before_test' as column_value from dual; - - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_multi_ext_procedure')); - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure beforetest_missing_procedure is - l_actual sys_refcursor; - begin - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_missing_procedure')); - - ut.expect(l_actual).to_be_empty; - - ut.expect(g_tests_results).to_match( - '^\s*Stops execution at first non-existing Beforetest procedure and marks test as errored \[[,\.0-9]+ sec\] \(FAILED - 1\)\s*$' - ,'m' - ); - ut.expect(g_tests_results).to_match( - '1\) beforetest_missing_procedure\s+' || - 'Call params for beforetest are not valid: procedure UT3_TESTER\.DUMMY_BEFORE_AFTER_TEST\.NON_EXISTENT_PROCEDURE does not exist\.' - ,'m' - ); - end; - - procedure beforetest_one_err_procedure is - l_actual sys_refcursor; - begin - open l_actual for - select * from table(test_before_after_annotations.get_procs_called('beforetest_one_err_procedure')); - - ut.expect(l_actual).to_be_empty; - - ut.expect(g_tests_results).to_match( - '^\s*Stops execution at first non-existing Beforetest procedure and marks test as errored \[[,\.0-9]+ sec\] \(FAILED - 1\)\s*$' - ,'m' - ); - ut.expect(g_tests_results).to_match( - '2\) beforetest_one_err_procedure\s+' || - 'ORA-06501: PL/SQL: program error' - ,'m' - ); - end; - -end; -/ \ No newline at end of file diff --git a/test/ut3_tester/core/annotations/test_before_after_annotations.pks b/test/ut3_tester/core/annotations/test_before_after_annotations.pks deleted file mode 100644 index 062efff48..000000000 --- a/test/ut3_tester/core/annotations/test_before_after_annotations.pks +++ /dev/null @@ -1,38 +0,0 @@ -create or replace package test_before_after_annotations is - - --%suite(annotations - beforetest and aftertest) - --%suitepath(utplsql.ut3_tester.core.annotations) - - subtype t_procedure_name is varchar2(250) not null; - type t_procedures is table of t_procedure_name; - - procedure set_procs_called(a_for_procedure t_procedure_name, a_procedures t_procedures); - - function get_procs_called(a_for_procedure varchar2) return t_procedures pipelined; - - --%beforeall - procedure create_tests_results; - - --%test(Executes Beforetest call to procedure inside package) - procedure beforetest_local_procedure; - - --%test(Executes beforetest procedure defined in the package when specified with package name) - procedure beforetest_local_proc_with_pkg; - - --%test(Executes Beforetest procedure twice when defined twice) - procedure beforetest_twice; - - --%test(Executes Beforetest procedure from external package) - procedure beforetest_one_ext_procedure; - - --%test(Executed external and internal Beforetest procedures) - procedure beforetest_multi_ext_procedure; - - --%test(Stops execution at first non-existing Beforetest procedure and marks test as errored) - procedure beforetest_missing_procedure; - - --%test(Stops execution at first erroring Beforetest procedure and marks test as errored) - procedure beforetest_one_err_procedure; - -end; -/ \ No newline at end of file diff --git a/test/ut3_tester/core/expectations/test_expectation_processor.pkb b/test/ut3_tester/core/expectations/test_expectation_processor.pkb deleted file mode 100644 index 63ce3c791..000000000 --- a/test/ut3_tester/core/expectations/test_expectation_processor.pkb +++ /dev/null @@ -1,105 +0,0 @@ -create or replace package body test_expectation_processor is - - gc_user constant varchar2(128) := sys_context('userenv','current_schema'); - - procedure who_called_expectation is - l_stack_trace varchar2(4000); - l_source_line varchar2(4000); - begin - l_stack_trace := q'[----- PL/SQL Call Stack ----- - object line object - handle number name -34f88e4420 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR -353dfeb2f8 26 SCH_TEST.UT_EXPECTATION_RESULT -cba2493ce0 112 SCH_TEST.UT_EXPECTATION -3539881cf0 21 SCH_TEST.UT_EXPECTATION_NUMBER -351a608008 7 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR -351a608018 12 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR -351a608018 24 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR -351a6862b8 6 anonymous block -351fe31010 1825 package body SYS.DBMS_SQL -20befbe4d8 129 SCH_TEST.UT_EXECUTABLE -20befbe4d8 65 SCH_TEST.UT_EXECUTABLE -34f8ab7cd8 80 SCH_TEST.UT_TEST -34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -34f8ab9b10 74 SCH_TEST.UT_SUITE -34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -cba24bfad0 75 SCH_TEST.UT_LOGICAL_SUITE -353dfecf30 59 SCH_TEST.UT_RUN -34f8ab98f0 48 SCH_TEST.UT_SUITE_ITEM -357f5421e8 77 package body SCH_TEST.UT_RUNNER -357f5421e8 111 package body SCH_TEST.UT_RUNNER -20be951ab0 292 package body SCH_TEST.UT -20be951ab0 320 package body SCH_TEST.UT -]'; - ut.expect( - ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) - ).to_equal('at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 7 l_source_line varchar2(4000); -at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 12 -at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 24'); - end; - - - procedure who_called_expectation_0x is - l_stack_trace varchar2(4000); - l_source_line varchar2(4000); - begin - l_stack_trace := q'[----- PL/SQL Call Stack ----- - object line object - handle number name -0x80e701d8 26 UT3_DEVELOP.UT_EXPECTATION_RESULT -0x85e10150 112 UT3_DEVELOP.UT_EXPECTATION -0x8b54bad8 21 UT3_DEVELOP.UT_EXPECTATION_NUMBER -0x85cfd238 20 package body UT3_DEVELOP.UT_EXAMPLETEST -0x85def380 6 anonymous block -0x85e93750 1825 package body SYS.DBMS_SQL -0x80f4f608 129 UT3_DEVELOP.UT_EXECUTABLE -0x80f4f608 65 UT3_DEVELOP.UT_EXECUTABLE -0x8a116010 76 UT3_DEVELOP.UT_TEST -0x8a3348a0 48 UT3_DEVELOP.UT_SUITE_ITEM -0x887e9948 67 UT3_DEVELOP.UT_LOGICAL_SUITE -0x8a26de20 59 UT3_DEVELOP.UT_RUN -0x8a3348a0 48 UT3_DEVELOP.UT_SUITE_ITEM -0x838d17c0 28 anonymous block -]'; - ut.expect( - ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) - ).to_be_like('at "UT3_DEVELOP.UT_EXAMPLETEST", line 20 %'); - end; - - procedure who_call_expectation_win_stack is - l_stack_trace varchar2(4000); - l_source_line varchar2(4000); - begin - l_stack_trace := q'[----- PL/SQL Call Stack ----- -object line object -handle number name -00007FF8547B7D30 124 package body SCH_TEST.UT_EXPECTATION_PROCESSOR -00007FF8547B7D30 26 SCH_TEST.UT_EXPECTATION_RESULT -00007FF8547B7D30 112 SCH_TEST.UT_EXPECTATION -00007FF8547B7D30 21 SCH_TEST.UT_EXPECTATION_NUMBER -00007FF8547B7D30 7 package body SCOTT.TEST_BETWNSTR.BASIC_USAGE -00007FF81FF207B0 345 type body SCOTT.TEST_BETWNSTR.BASIC_USAGE_TYP -00007FF8544B21B8 6 anonymous block -00007FF8267FBFC8 1721 package body SYS.DBMS_SQL.EXECUTE -00007FF852BCFC68 142 type body UT3_DEVELOP.UT_EXECUTABLE.DO_EXECUTE -00007FF852BCFC68 44 type body UT3_DEVELOP.UT_EXECUTABLE.DO_EXECUTE -00007FF8512F9A90 74 type body UT3_DEVELOP.UT_EXECUTABLE_TEST.DO_EXECUTE -00007FF8512F9A90 38 type body UT3_DEVELOP.UT_EXECUTABLE_TEST.DO_EXECUTE -00007FF8231A2088 79 type body UT3_DEVELOP.UT_TEST.DO_EXECUTE -00007FF81FF207B0 49 type body UT3_DEVELOP.UT_SUITE_ITEM.DO_EXECUTE -00007FF852C83270 66 type body UT3_DEVELOP.UT_SUITE.DO_EXECUTE -00007FF82165F3B0 67 type body UT3_DEVELOP.UT_RUN.DO_EXECUTE -00007FF81FF207B0 49 type body UT3_DEVELOP.UT_SUITE_ITEM.DO_EXECUTE -00007FF8266285C0 172 package body UT3_DEVELOP.UT_RUNNER.RUN -00007FF854710538 134 package body UT3_DEVELOP.UT.RUN_AUTONOMOUS -00007FF854710538 488 package body UT3_DEVELOP.UT.RUN -00007FF854710538 623 package body UT3_DEVELOP.UT.RUN -00007FF81CFFA388 1 anonymous block]'; - ut.expect( - ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) - ).to_be_like('at "SCOTT.TEST_BETWNSTR.BASIC_USAGE", line 7 %'); - end; - -end; -/ diff --git a/test/ut3_tester/core/expectations/test_expectation_processor.pks b/test/ut3_tester/core/expectations/test_expectation_processor.pks deleted file mode 100644 index 6087eb045..000000000 --- a/test/ut3_tester/core/expectations/test_expectation_processor.pks +++ /dev/null @@ -1,23 +0,0 @@ -create or replace package test_expectation_processor is - - --%suite(expectation_processor) - --%suitepath(utplsql.ut3_tester.core.expectations) - - --%beforeall(ut3_tester_helper.main_helper.set_ut_run_context) - --%afterall(ut3_tester_helper.main_helper.clear_ut_run_context) - - --%context(who_called_expectation_in_test) - - --%test(parses stack trace containing 0x and returns objects and line that called expectation) - procedure who_called_expectation_0x; - - --%test(parses stack trace and returns objects and line that called expectation) - procedure who_called_expectation; - - --%test(parses stack trace for Windows DB os - regression for #1000) - procedure who_call_expectation_win_stack; - - --%endcontext - -end; -/ diff --git a/test/ut3_tester/core/test_file_mapper.pkb b/test/ut3_tester/core/test_file_mapper.pkb deleted file mode 100644 index fccc487bd..000000000 --- a/test/ut3_tester/core/test_file_mapper.pkb +++ /dev/null @@ -1,45 +0,0 @@ -create or replace package body test_file_mapper is - - procedure default_mappings is - l_actual ut3_develop.ut_file_mappings; - l_expected ut3_develop.ut_file_mappings; - begin - --Arrange - l_expected := ut3_develop.ut_file_mappings( - ut3_develop.ut_file_mapping('C:\tests\helpers\core.pkb',sys_context('USERENV', 'CURRENT_USER'),'CORE','PACKAGE BODY'), - ut3_develop.ut_file_mapping('tests/helpers/test_file_mapper.pkb',sys_context('USERENV', 'CURRENT_USER'),'TEST_FILE_MAPPER','PACKAGE BODY') - ); - --Act - l_actual := ut3_develop.ut_file_mapper.build_file_mappings( - ut3_develop.ut_varchar2_list( - 'C:\tests\helpers\core.pkb', - 'tests/helpers/test_file_mapper.pkb' - ) - ); - --Assert - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure specific_owner is - l_actual ut3_develop.ut_file_mappings; - l_expected ut3_develop.ut_file_mappings; - begin - --Arrange - l_expected := ut3_develop.ut_file_mappings( - ut3_develop.ut_file_mapping('C:\source\core\types\ut_file_mapping.tpb','UT3_DEVELOP','UT_FILE_MAPPING','TYPE BODY'), - ut3_develop.ut_file_mapping('source/core/ut_file_mapper.pkb','UT3_DEVELOP','UT_FILE_MAPPER','PACKAGE BODY') - ); - --Act - l_actual := ut3_develop.ut_file_mapper.build_file_mappings( - 'UT3_DEVELOP', - ut3_develop.ut_varchar2_list( - 'C:\source\core\types\ut_file_mapping.tpb', - 'source/core/ut_file_mapper.pkb' - ) - ); - --Assert - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - -end; -/ diff --git a/test/ut3_tester/core/test_file_mapper.pks b/test/ut3_tester/core/test_file_mapper.pks deleted file mode 100644 index b2443766c..000000000 --- a/test/ut3_tester/core/test_file_mapper.pks +++ /dev/null @@ -1,13 +0,0 @@ -create or replace package test_file_mapper is - - --%suite(file_mapper) - --%suitepath(utplsql.ut3_tester.core) - - --%test(Maps file paths into database objects using default mappings) - procedure default_mappings; - - --%test(Used specified object owner to perform mapping when files have no owner indication) - procedure specific_owner; - -end; -/ diff --git a/test/ut3_tester/core/test_output_buffer.pkb b/test/ut3_tester/core/test_output_buffer.pkb deleted file mode 100644 index 317e7e3d5..000000000 --- a/test/ut3_tester/core/test_output_buffer.pkb +++ /dev/null @@ -1,200 +0,0 @@ -create or replace package body test_output_buffer is - - procedure test_receive is - l_actual_text clob; - l_actual_item_type varchar2(1000); - l_remaining integer; - l_expected_text clob; - l_expected_item_type varchar2(1000); - l_buffer ut3_develop.ut_output_buffer_base; - begin - --Arrange - l_buffer := ut3_develop.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')) - || chr(13) || chr(10) || to_clob(lpad('a text', 31000, ',a text')) || to_clob(lpad('a text', 31000, ',a text')); - l_expected_item_type := lpad('some item type',1000,'-'); - --Act - l_buffer.lock_buffer(); - l_buffer.send_clob(l_expected_text, l_expected_item_type); - l_buffer.close(); - - select text, item_type - into l_actual_text, l_actual_item_type - from table(l_buffer.get_lines(0.1,0.1)); - - --Assert - 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 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; - - procedure test_wait_for_producer is - l_buffer ut3_develop.ut_output_buffer_base; - begin - l_buffer := ut3_develop.ut_output_clob_table_buffer(); - ut.expect( l_buffer.get_lines_cursor(0.1) ).to_be_empty(); - end; - - procedure test_doesnt_send_on_null_text is - l_cur sys_refcursor; - l_result integer; - l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); - begin - ut3_tester_helper.run_helper.delete_buffer(); - --Act - l_buffer.send_line(null); - - 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_actual sys_refcursor; - l_expected sys_refcursor; - l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.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_develop.ut_varchar2_rows(null)); - l_buffer.send_lines(ut3_develop.ut_varchar2_rows('test')); - - open l_actual for - select text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); - open l_expected for - select 'test' as text from dual; - - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure test_send_line is - l_result varchar2(4000); - c_expected constant varchar2(4000) := lpad('a text',4000,',a text'); - l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); - begin - l_buffer.send_line(c_expected); - - 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; - - procedure test_waiting_for_data is - l_result clob; - l_remaining integer; - l_expected clob; - l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); - l_start timestamp; - l_duration interval day to second; - begin - --Arrange - l_expected := 'a text'; - l_buffer.lock_buffer(); - l_buffer.send_line(l_expected); - l_start := localtimestamp; - --Act - begin - select text into l_result from table(l_buffer.get_lines(0,0.3)); - ut.fail('Expected a timeout exception but nothing was raised'); - exception - when others then - l_duration := localtimestamp - l_start; - --Assert - --Fetches data from output - ut.expect(l_result).to_equal(l_expected); - --Throws a timeout exception - ut.expect(dbms_utility.format_error_stack()).to_match('ORA'||ut3_develop.ut_utils.gc_out_buffer_timeout); - --Waited for one second - ut.expect(l_duration).to_be_greater_or_equal(interval '0.3' second); - end; - - 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_develop.ut_output_buffer_base ) is - l_stale_buffer ut3_develop.ut_output_buffer_base := a_buffer; - l_fresh_buffer ut3_develop.ut_output_buffer_base; - l_buffer ut3_develop.ut_output_buffer_base; - begin - --Arrange - l_stale_buffer.start_date := sysdate - 10; - --initialize with new start date - l_stale_buffer.init(); - l_stale_buffer.lock_buffer(); - l_stale_buffer.send_line('some text'); - l_stale_buffer.close(); - - l_fresh_buffer := ut3_develop.ut_output_table_buffer(); - l_fresh_buffer.lock_buffer(); - l_fresh_buffer.send_line('some text'); - l_fresh_buffer.close(); - - --Act - purge is performed on new buffer create - l_buffer := ut3_develop.ut_output_table_buffer(); - - --Assert - -- Data in "fresh" buffer remains - ut.expect( l_fresh_buffer.get_lines_cursor(0,0), l_fresh_buffer.self_type ).to_have_count(1); - -- Data in "stale" 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_stale_buffer.self_type ).to_be_empty(); - end; - - procedure test_purge_text_buffer is - begin - test_purge(ut3_develop.ut_output_table_buffer()); - end; - - procedure test_purge_clob_buffer is - begin - test_purge(ut3_develop.ut_output_clob_table_buffer()); - end; - - procedure text_buffer_send_multibyte is - l_input varchar2(32767); - l_max_len integer := ut3_develop.ut_utils.gc_max_storage_varchar2_len; - l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); - l_text varchar2(4000); - begin - --Arrange - ut3_tester_helper.run_helper.delete_buffer(); - l_input := rpad( '❀', l_max_len, 'a' ); - ut.expect( lengthb( l_input ) ).to_be_greater_than(l_max_len); - - --Act - l_buffer.send_line(l_input); - --Assert - select text into l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); - ut.expect(lengthb(l_text)).to_be_less_or_equal(l_max_len); - end; - - procedure text_buffer_send_clob_multib is - l_input clob; - l_max_len integer := ut3_develop.ut_utils.gc_max_storage_varchar2_len; - l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); - l_text varchar2(4000); - begin - --Arrange - ut3_tester_helper.run_helper.delete_buffer(); - l_input := rpad( '❀', l_max_len, 'a' ); - ut.expect( ut3_develop.ut_utils.lengthb_clob( l_input ) ).to_be_greater_than(l_max_len); - - --Act - l_buffer.send_clob(l_input); - --Assert - select text into l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp); - ut.expect(lengthb(l_text)).to_be_less_or_equal(l_max_len); - end; - - end test_output_buffer; -/ diff --git a/test/ut3_tester/core/test_output_buffer.pks b/test/ut3_tester/core/test_output_buffer.pks deleted file mode 100644 index 5b6cd678b..000000000 --- a/test/ut3_tester/core/test_output_buffer.pks +++ /dev/null @@ -1,57 +0,0 @@ -create or replace package test_output_buffer is - - --%suite(output_buffer) - --%suitepath(utplsql.ut3_tester.core) - - - --%context(Read and write within the same session) - - - --%endcontext - - --%context(Buffer is read in a different session than buffer write) - - --reader will wait for a_initial_timeout seconds for the writer process to start and then it will finish with error - - --reader will wait forever (beyond a_initial_timeout) if the writer process is started and end of data row was not received from the buffer - - --reader stops after reading the end of data signal from the buffer - - --reader stops when writer process ends and all data was read from the buffer - - - --%endcontext - - --%test(Receives a line from buffer table and deletes) - procedure test_receive; - - --%test(Waits specified time for producer to lock the buffer ) - --%throws(-20218) - procedure test_wait_for_producer; - - --%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) - procedure test_purge_text_buffer; - - --%test(Purges clob buffer data older than one day and leaves the rest) - procedure test_purge_clob_buffer; - - --%test(Successfully sends multibyte long line into text buffer) - procedure text_buffer_send_multibyte; - - --%test(Successfully sends multibyte long clob line into text buffer) - procedure text_buffer_send_clob_multib; - -end test_output_buffer; -/ diff --git a/test/ut3_tester/core/test_suite_builder.pkb b/test/ut3_tester/core/test_suite_builder.pkb deleted file mode 100644 index 570d86a0d..000000000 --- a/test/ut3_tester/core/test_suite_builder.pkb +++ /dev/null @@ -1,1925 +0,0 @@ -create or replace package body test_suite_builder is - - function invoke_builder_for_annotations( - a_annotations ut3_develop.ut_annotations, - a_package_name varchar2 := 'TEST_SUITE_BUILDER_PACKAGE' - ) return clob is - l_suites ut3_develop.ut_suite_items; - l_suite ut3_develop.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( - ut3_develop.ut_annotated_objects( - ut3_develop.ut_annotated_object('UT3_TESTER', a_package_name, 'PACKAGE', systimestamp, a_annotations) - ) ) x; - - l_suites := ut3_develop.ut_suite_manager.build_suites_from_annotations( - a_owner_name => 'UT3_TESTER', - a_annotated_objects => l_cursor, - a_path => null, - a_object_name => a_package_name, - a_skip_all_objects => true - ); - l_suite := treat( l_suites(l_suites.first) as ut3_develop.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( - l_xml, - '//RESULTS_COUNT|//START_TIME|//END_TIME|//RESULT|//ASSOCIATED_EVENT_NAME' || - '|//TRANSACTION_INVALIDATORS|//ERROR_BACKTRACE|//ERROR_STACK|//SERVEROUTPUT' - ) - into l_xml - from dual; - - return l_xml.getClobVal(); - end; - - procedure no_suite_description is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_match( - 'UT3_TESTERsome_packagesome_package()?\s*some_package' - ); - end; - - procedure suite_description_from_suite is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Some description', null), - ut3_develop.ut_annotation(2, 'suite','Another description', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%some_packageSome description%' - ); - end; - - procedure suitepath_from_non_empty_path is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite',null, null), - ut3_develop.ut_annotation(2, 'suitepath','org.utplsql.some', null), - ut3_develop.ut_annotation(3, 'suitepath','dummy.utplsql.some', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%org.utplsql.some%' - ); - end; - - procedure suite_descr_from_displayname is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Some description', null), - ut3_develop.ut_annotation(2, 'suite','Another description', null), - ut3_develop.ut_annotation(3, 'displayname','New description', null), - ut3_develop.ut_annotation(4, 'displayname','Newest description', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%some_packageNew description%' - ); - end; - - procedure rollback_type_valid is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite',null, null), - ut3_develop.ut_annotation(2, 'rollback','manual', null), - ut3_develop.ut_annotation(3, 'rollback','bad', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%'||ut3_develop.ut_utils.gc_rollback_manual||'%' - ); - end; - - procedure rollback_type_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite',null, null), - ut3_develop.ut_annotation(2, 'rollback','manual', null), - ut3_develop.ut_annotation(3, 'rollback','bad', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%rollback"%%UT3_TESTER.SOME_PACKAGE%3%%' - ); - end; - - procedure suite_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'suite','bad', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Cool%%"--%suite"%UT3_TESTER.SOME_PACKAGE%line 8%%' - ); - end; - - procedure test_annotation is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'test','Some test', '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 test_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.ut_annotation(9, 'test','Dup', 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Cool%%"--%test"%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%%' - ); - end; - - procedure beforeall_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'beforeall', null, 'test_procedure'), - ut3_develop.ut_annotation(9, 'beforeall', null, 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Cool%%"--%beforeall"%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%%' - ); - end; - - procedure beforeeach_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'beforeeach', null, 'test_procedure'), - ut3_develop.ut_annotation(9, 'beforeeach', null, 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Cool%%"--%beforeeach"%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%%' - ); - end; - - procedure afterall_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'afterall', null, 'test_procedure'), - ut3_develop.ut_annotation(9, 'afterall', null, 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Cool%%"--%afterall"%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%%' - ); - end; - - procedure aftereach_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(8, 'aftereach', null, 'test_procedure'), - ut3_develop.ut_annotation(9, 'aftereach', null, 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Cool%%"--%aftereach"%UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE%line 9%%' - ); - end; - - procedure suitepath_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(3, 'suitepath','dummy.utplsql.some', null), - ut3_develop.ut_annotation(4, 'suitepath','org.utplsql.some', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%suitepath"%line 4%%' - ); - end; - - procedure displayname_annot_duplicated is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'displayname','New description', null), - ut3_develop.ut_annotation(5, 'displayname','Newest description', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%displayname"%line 5%%' - ); - end; - - procedure suitepath_annot_empty is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(3, 'suitepath',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%suitepath" annotation requires a non-empty parameter value.%%' - ); - end; - - procedure suitepath_annot_invalid_path is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'suitepath','path with spaces', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%Invalid path value in annotation "--%suitepath(path with spaces)"%%' - ); - end; - - procedure displayname_annot_empty is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(3, 'displayname',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%displayname" annotation requires a non-empty parameter value.%%' - ); - end; - - procedure rollback_type_empty is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(3, 'rollback',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%rollback" annotation requires one of values as parameter:%%' - ); - end; - - procedure rollback_type_invalid is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'rollback','bad', null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%rollback" annotation requires one of values as parameter: "auto" or "manual". Annotation ignored.%%' - ); - end; - - procedure multiple_before_after is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'first_before_all'), - ut3_develop.ut_annotation(3, 'beforeall',null, 'another_before_all'), - ut3_develop.ut_annotation(4, 'beforeeach',null, 'first_before_each'), - ut3_develop.ut_annotation(5, 'beforeeach',null, 'another_before_each'), - ut3_develop.ut_annotation(6, 'aftereach',null, 'first_after_each'), - ut3_develop.ut_annotation(7, 'aftereach',null, 'another_after_each'), - ut3_develop.ut_annotation(8, 'afterall',null, 'first_after_all'), - ut3_develop.ut_annotation(9, 'afterall',null, 'another_after_all'), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%some_packagefirst_before_each' || - '%some_packageanother_before_each' || - '%' || - '%' || - '%some_packagebefore_test_proc' || - '%some_packagebefore_test_proc2' || - '%' || - '%' || - '%some_packageafter_test_proc' || - '%some_packageafter_test_proc2' || - '%' || - '%' || - '%some_packagefirst_after_each' || - '%some_packageanother_after_each' || - '%' || - '%' || - '%' || - '%some_packagefirst_before_all' || - '%some_packageanother_before_all' || - '%' || - '%' || - '%some_packagefirst_after_all' || - '%some_packageanother_after_all' || - '%%' - ); - end; - - procedure multiple_standalone_bef_aft is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall', 'some_package.first_before_all',null), - ut3_develop.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), - ut3_develop.ut_annotation(4, 'beforeeach', 'first_before_each',null), - ut3_develop.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), - ut3_develop.ut_annotation(6, 'aftereach', 'first_after_each',null), - ut3_develop.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), - ut3_develop.ut_annotation(8, 'afterall', 'first_after_all',null), - ut3_develop.ut_annotation(9, 'afterall', 'another_after_all',null), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%some_packagefirst_before_each' || - '%different_ownerdifferent_packageanother_before_each' || - '%' || - '%' || - '%some_packagebefore_test_proc' || - '%some_packagebefore_test_proc2' || - '%' || - '%' || - '%some_packageafter_test_proc' || - '%some_packageafter_test_proc2' || - '%' || - '%' || - '%some_packagefirst_after_each' || - '%some_packageanother_after_each' || - '%different_ownerdifferent_packageone_more_after_each' || - '%' || - '%' || - '%' || - '%some_packagefirst_before_all' || - '%different_packageanother_before_all' || - '%' || - '%' || - '%some_packagefirst_after_all' || - '%some_packageanother_after_all' || - '%%' - ); - end; - - procedure before_after_on_single_proc is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'do_stuff'), - ut3_develop.ut_annotation(3, 'beforeeach',null, 'do_stuff'), - ut3_develop.ut_annotation(4, 'aftereach',null, 'do_stuff'), - ut3_develop.ut_annotation(5, 'afterall',null, 'do_stuff'), - ut3_develop.ut_annotation(6, 'test','A test', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%some_packagedo_stuff' || - '%' || - '%' || - '%some_packagedo_stuff' || - '%' || - '%' || - '%' || - '%some_packagedo_stuff' || - '%' || - '%' || - '%some_packagedo_stuff' || - '%%' - ); - end; - - procedure multiple_mixed_bef_aft is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall', null,'first_before_all'), - ut3_develop.ut_annotation(3, 'beforeall', 'different_package.another_before_all',null), - ut3_develop.ut_annotation(4, 'beforeeach', 'first_before_each',null), - ut3_develop.ut_annotation(5, 'beforeeach', 'different_owner.different_package.another_before_each',null), - ut3_develop.ut_annotation(6, 'aftereach', null, 'first_after_each'), - ut3_develop.ut_annotation(7, 'aftereach', 'another_after_each,different_owner.different_package.one_more_after_each',null), - ut3_develop.ut_annotation(8, 'afterall', 'first_after_all',null), - ut3_develop.ut_annotation(9, 'afterall', 'another_after_all',null), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test'), - ut3_develop.ut_annotation(21, 'beforeall', null,'last_before_all'), - ut3_develop.ut_annotation(22, 'aftereach', null, 'last_after_each'), - ut3_develop.ut_annotation(23, 'afterall', null, 'last_after_all') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%some_packagefirst_before_each' || - '%different_ownerdifferent_packageanother_before_each' || - '%' || - '%' || - '%some_packagebefore_test_proc' || - '%some_packagebefore_test_proc2' || - '%' || - '%' || - '%some_packageafter_test_proc' || - '%some_packageafter_test_proc2' || - '%' || - '%' || - '%some_packagefirst_after_each' || - '%some_packageanother_after_each' || - '%different_ownerdifferent_packageone_more_after_each' || - '%some_packagelast_after_each' || - '%' || - '%' || - '%' || - '%some_packagefirst_before_all' || - '%different_packageanother_before_all' || - '%some_packagelast_before_all' || - '%' || - '%' || - '%some_packagefirst_after_all' || - '%some_packageanother_after_all' || - '%some_packagelast_after_all' || - '%%' - ); - end; - - - procedure before_after_mixed_with_test is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'do_stuff'), - ut3_develop.ut_annotation(3, 'beforeeach',null, 'do_stuff'), - ut3_develop.ut_annotation(4, 'aftereach',null, 'do_stuff'), - ut3_develop.ut_annotation(5, 'afterall',null, 'do_stuff'), - ut3_develop.ut_annotation(6, 'test','A test', 'do_stuff') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - 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 package "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('%%'); - ut.expect(l_actual).not_to_be_like('%%'); - end; - - procedure suite_from_context is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(5, 'name','a_context', null), - ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(8, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '%' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '%a_contextA contextsome_package.a_context' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || - '%' || - '' || - '' || - '%some_packagecontext_setup' || - '%' || - '' || - '' || - '' || - '' || - '%some_packagesuite_level_beforeall' || - '%' || - '' || - ''|| - '' - ); - end; - - procedure nested_contexts is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 1, 'suite','Cool', null), - ut3_develop.ut_annotation( 2, 'beforeall',null, 'suite_level_beforeall'), - ut3_develop.ut_annotation( 3, 'test','In suite', 'suite_level_test'), - ut3_develop.ut_annotation( 4, 'context','A context', null), - ut3_develop.ut_annotation( 5, 'name','a_context', null), - ut3_develop.ut_annotation( 6, 'beforeall',null, 'context_setup'), - ut3_develop.ut_annotation( 7, 'test', 'First test in context', 'first_test_in_a_context'), - ut3_develop.ut_annotation( 8, 'context','A nested context', null), - ut3_develop.ut_annotation( 9, 'name','a_nested_context', null), - ut3_develop.ut_annotation(10, 'beforeall',null, 'nested_context_setup'), - ut3_develop.ut_annotation(11, 'test', 'Test in nested context', 'test_in_nested_context'), - ut3_develop.ut_annotation(12, 'endcontext',null, null), - ut3_develop.ut_annotation(13, 'context',null, null), - ut3_develop.ut_annotation(14, 'name','nested_context_2', null), - ut3_develop.ut_annotation(15, 'test', 'Test in nested context', 'test_in_nested_context_2'), - ut3_develop.ut_annotation(16, 'context','a_nested_context_3', null), - ut3_develop.ut_annotation(17, 'test', 'Test in nested context', 'test_in_nested_context_3'), - ut3_develop.ut_annotation(18, 'endcontext',null, null), - ut3_develop.ut_annotation(19, 'endcontext',null, null), - ut3_develop.ut_annotation(20, 'test', 'Second test in context', 'second_test_in_a_context'), - ut3_develop.ut_annotation(21, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '%' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '%a_contextA contextsome_package.a_context' || - '%' || - '' || - '%first_test_in_a_contextFirst test in contextsome_package.a_context.first_test_in_a_context' || - '%' || - '' || - '%a_nested_contextA nested contextsome_package.a_context.a_nested_context' || - '%' || - '' || - '%test_in_nested_contextTest in nested contextsome_package.a_context.a_nested_context.test_in_nested_context' || - '%' || - '' || - '' || - '%some_packagenested_context_setup' || - '%' || - '%' || - '' || - '%nested_context_2nested_context_2some_package.a_context.nested_context_2' || - '%' || - '' || - '%test_in_nested_context_2Test in nested contextsome_package.a_context.nested_context_2.test_in_nested_context_2' || - '%' || - '' || - '%nested_context_#1a_nested_context_3some_package.a_context.nested_context_2.nested_context_#1' || - '%' || - '' || - '%test_in_nested_context_3Test in nested contextsome_package.a_context.nested_context_2.nested_context_#1.test_in_nested_context_3' || - '%' || - '' || - '' || - '%' || - '' || - '' || - '%' || - '' || - '%second_test_in_a_contextSecond test in contextsome_package.a_context.second_test_in_a_context' || - '%' || - '' || - '' || - '%some_packagecontext_setup' || - '%' || - '' || - '' || - '' || - '' || - '%some_packagesuite_level_beforeall' || - '%' || - '' || - ''|| - '' - ); - end; - - procedure nested_contexts_2 is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation( 1, 'suite','Cool', null), - ut3_develop.ut_annotation( 2, 'suitepath','path', null), - ut3_develop.ut_annotation( 3, 'context','Level 1', null), - ut3_develop.ut_annotation( 4, 'name','context_1', null), - ut3_develop.ut_annotation( 5, 'context','Level 1.1', null), - ut3_develop.ut_annotation( 6, 'name','context_1_1', null), - ut3_develop.ut_annotation( 7, 'test', 'Test 1.1.1', 'test_1_1_1'), - ut3_develop.ut_annotation( 8, 'test', 'Test 1.1.2', 'test_1_1_2'), - ut3_develop.ut_annotation( 9, 'endcontext', null, null), - ut3_develop.ut_annotation(10, 'endcontext', null, null), - ut3_develop.ut_annotation(11, 'context','Level 2', null), - ut3_develop.ut_annotation(12, 'name','context_2', null), - ut3_develop.ut_annotation(13, 'test', 'Test 2.1', 'test_2_1'), - ut3_develop.ut_annotation(14, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%%' || - '' || - '%context_1Level 1path.some_package.context_1' || - '%' || - '' || - '%context_1_1Level 1.1path.some_package.context_1.context_1_1' || - '%' || - '' || - '%test_1_1_1Test 1.1.1path.some_package.context_1.context_1_1.test_1_1_1' || - '%' || - '' || - '%test_1_1_2Test 1.1.2path.some_package.context_1.context_1_1.test_1_1_2' || - '%' || - '' || - '%' || - '%' || - '' || - '%' || - '%' || - '%'|| - '' - ); - -- Test both contexts separately due to ordering - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%%' || - '' || - '%context_2Level 2path.some_package.context_2' || - '%' || - '' || - '%test_2_1Test 2.1path.some_package.context_2.test_2_1' || - '%' || - '%' || - '%' || - '%' || - '%'|| - '' - ); - end; - - - procedure before_after_in_context is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite', 'Cool', null), - ut3_develop.ut_annotation(2, 'test', 'In suite', 'suite_level_test'), - ut3_develop.ut_annotation(3, 'context', 'A context', null), - ut3_develop.ut_annotation(4, 'beforeall', 'context_beforeall', null), - ut3_develop.ut_annotation(5, 'beforeeach', null, 'context_beforeeach'), - ut3_develop.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(7, 'aftereach', 'context_aftereach' ,null), - ut3_develop.ut_annotation(8, 'afterall', null, 'context_afterall'), - ut3_develop.ut_annotation(9, 'endcontext', null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '%' || - '%suite_level_test' || - '%%suite_level_test%' || - '%' || - '%' || - '%nested_context_#1A contextsome_package.nested_context_#1' || - '%' || - '%' || - '%test_in_a_context' || - '%%context_beforeeach%' || - '%%test_in_a_context%' || - '%%context_aftereach%' || - '%' || - '%' || - '%%context_beforeall%' || - '%%context_afterall%' || - '%' || - '%' || - '%'|| - '' - ); - ut.expect(l_actual).not_to_be_like('%%%%%%'); - ut.expect(l_actual).not_to_be_like('%%%%%%'); - ut.expect(l_actual).not_to_be_like('%%%%%%'); - ut.expect(l_actual).not_to_be_like('%%%%%%'); - end; - - procedure before_after_out_of_context is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3_develop.ut_annotation(3, 'beforeeach',null, 'suite_level_beforeeach'), - ut3_develop.ut_annotation(4, 'test','In suite', 'suite_level_test'), - ut3_develop.ut_annotation(5, 'context',null, null), - ut3_develop.ut_annotation(6, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(7, 'endcontext',null, null), - ut3_develop.ut_annotation(8, 'aftereach',null, 'suite_level_aftereach'), - ut3_develop.ut_annotation(9, 'afterall',null, 'suite_level_afterall') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '%' || - '%suite_level_test' || - '%%suite_level_beforeeach%' || - '%%suite_level_test%' || - '%%suite_level_aftereach%' || - '%' || - '%' || - '%nested_context_#1nested_context_#1some_package.nested_context_#1' || - '%' || - '%' || - '%test_in_a_context' || - '%%suite_level_beforeeach%' || - '%%test_in_a_context%' || - '%%suite_level_aftereach%' || - '%' || - '%' || - '%' || - '%' || - '%%suite_level_beforeall%' || - '%%suite_level_afterall%' || - '%'|| - '' - ); - ut.expect(l_actual).not_to_be_like('%%%%%%'); - ut.expect(l_actual).not_to_be_like('%%%%%%'); - end; - - procedure context_without_endcontext is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3_develop.ut_annotation(4, 'context','Some context', null), - ut3_develop.ut_annotation(5, 'name','a_context', null), - ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Missing "--\%endcontext" annotation for a "--\%context" annotation. The end of package is considered end of context.%at package "UT3_TESTER.SOME_PACKAGE", line 4%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '%' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '%' || - '%a_contextSome contextsome_package.a_context' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || - '%' || - '' || - '' || - '%some_packagecontext_setup' || - '%' || - '%' || - '' || - '' || - '%some_packagesuite_level_beforeall' || - '%' || - '' || - ''|| - '' - ); - end; - - procedure endcontext_without_context is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(5, 'name','a_context', null), - ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(8, 'endcontext',null, null), - ut3_develop.ut_annotation(9, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Extra "--\%endcontext" annotation found. Cannot find corresponding "--\%context". Annotation ignored.%at package "UT3_TESTER.SOME_PACKAGE", line 9%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '%a_contextA contextsome_package.a_context' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || - '%' || - '' || - '' || - '%some_packagecontext_setup' || - '%' || - '' || - '' || - '' || - '' || - '%some_packagesuite_level_beforeall' || - '%' || - '' || - ''|| - '' - ); - end; - - procedure duplicate_context_name is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), - ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(5, 'name','a_context', null), - ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(8, 'endcontext',null, null), - ut3_develop.ut_annotation(9, 'context','A context', null), - ut3_develop.ut_annotation(10, 'name','a_context', null), - ut3_develop.ut_annotation(11, 'beforeall',null, 'setup_in_duplicated_context'), - ut3_develop.ut_annotation(12, 'test', 'In duplicated context', 'test_in_duplicated_context'), - ut3_develop.ut_annotation(13, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Context name "a_context" already used in this scope. Name must be unique. Using fallback name nested_context_#2.%%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '%a_contextA contextsome_package.a_context' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || - '%' || - '' || - '' || - '%some_packagecontext_setup' || - '%' || - '' || - '' || - '' || - '%nested_context_#2A contextsome_package.nested_context_#2' || - '%' || - '' || - '%test_in_duplicated_contextIn duplicated contextsome_package.nested_context_#2.test_in_duplicated_context' || - '%' || - '' || - '' || - '%some_packagesetup_in_duplicated_context' || - '%' || - '' || - '' || - '' || - '' || - '%some_packagesuite_level_beforeall' || - '%' || - '' || - ''|| - '' - ); - end; - - procedure hard_stop_in_ctx_name is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - l_bad_name varchar2(100); - begin - --Arrange - l_bad_name := 'ctx_with_dot.in_it'; - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'context',null, null), - ut3_develop.ut_annotation(5, 'name',l_bad_name, null), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(13, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Invalid value "'||l_bad_name||'" for context name. Context name ignored and fallback to auto-name "nested_context_#1"%' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%nested_context_#1nested_context_#1some_package.nested_context_#1' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || - '%' || - '%' || - '%' || - '%' || - ''|| - '' - ); - end; - - procedure name_with_spaces_invalid is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - l_bad_name varchar2(100); - begin - --Arrange - l_bad_name := 'context name with spaces'; - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'context',null, null), - ut3_develop.ut_annotation(5, 'name',l_bad_name, null), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(13, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Invalid value "'||l_bad_name||'" for context name. Context name ignored and fallback to auto-name "nested_context_#1"%' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%nested_context_#1nested_context_#1some_package.nested_context_#1' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || - '%' || - '%' || - '%' || - '%' || - ''|| - '' - ); - end; - - procedure duplicate_name_annotation is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(5, 'name','a_context_name', null), - ut3_develop.ut_annotation(6, 'name','a_newer_context_name', null), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(8, 'endcontext',null, null), - ut3_develop.ut_annotation(12, 'test', 'In suite', 'suite_level_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%Duplicate annotation "--%name". Annotation ignored.%%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%a_context_nameA contextsome_package.a_context_name' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.a_context_name.test_in_a_context' || - '%' || - '' || - '' || - '' || - '' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '' || - '' || - ''|| - '' - ); - end; - - procedure name_outside_of_context is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(3, 'name','a_context_name', null), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(8, 'endcontext',null, null), - ut3_develop.ut_annotation(12, 'test', 'In suite', 'suite_level_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%nested_context_#1A contextsome_package.nested_context_#1' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || - '%' || - '' || - '' || - '' || - '' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '' || - '' || - ''|| - '' - ); - end; - - procedure name_empty_value is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(5, 'name',null, null), - ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), - ut3_develop.ut_annotation(8, 'endcontext',null, null), - ut3_develop.ut_annotation(12, 'test', 'In suite', 'suite_level_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%nested_context_#1A contextsome_package.nested_context_#1' || - '%' || - '' || - '%test_in_a_contextIn contextsome_package.nested_context_#1.test_in_a_context' || - '%' || - '' || - '' || - '' || - '' || - '' || - '%suite_level_testIn suitesome_package.suite_level_test' || - '%' || - '' || - '' || - '' || - ''|| - '' - ); - end; - - procedure multiple_contexts is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'context','A context', null), - ut3_develop.ut_annotation(6, 'test', 'In context1', 'test_in_a_context1'), - ut3_develop.ut_annotation(7, 'endcontext',null, null), - ut3_develop.ut_annotation(8, 'context','A context', null), - ut3_develop.ut_annotation(10, 'test', 'In context2', 'test_in_a_context2'), - ut3_develop.ut_annotation(11, 'endcontext',null, null) - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%' - ,'\' - ); - ut.expect(l_actual).to_be_like( - ''|| - '' || - '%' || - '' || - '%nested_context_#1A contextsome_package.nested_context_#1' || - '%' || - '' || - '%test_in_a_context1In context1some_package.nested_context_#1.test_in_a_context1' || - '%' || - '' || - '' || - '' || - '' || - '' || - '%nested_context_#2A contextsome_package.nested_context_#2' || - '%' || - '' || - '%test_in_a_context2In context2some_package.nested_context_#2.test_in_a_context2' || - '%' || - '' || - '' || - '' || - '' || - '' || - '' || - '' || - ''|| - '' - ); - end; - - procedure throws_value_empty is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(3, 'test','A test with empty throws annotation', 'A_TEST_PROCEDURE'), - ut3_develop.ut_annotation(3, 'throws',null, 'A_TEST_PROCEDURE') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%"--%throws" annotation requires a parameter. Annotation ignored.%%' - ); - end; - - - procedure before_aftertest_multi is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','before_test_proc', 'some_test'), - ut3_develop.ut_annotation(16, 'beforetest','before_test_proc2', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','after_test_proc', 'some_test'), - ut3_develop.ut_annotation(20, 'aftertest','after_test_proc2', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%some_packagebefore_test_proc' || - '%some_packagebefore_test_proc2' || - '%' || - '%' || - '%some_packageafter_test_proc' || - '%some_packageafter_test_proc2' || - '%' || - '%%' - ); - end; - - procedure before_aftertest_twice is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','before_test_proc, before_test_proc2', 'some_test'), - ut3_develop.ut_annotation(16, 'beforetest','before_test_proc3', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','after_test_proc,after_test_proc2', 'some_test'), - ut3_develop.ut_annotation(20, 'aftertest','after_test_proc3', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%some_packagebefore_test_proc' || - '%some_packagebefore_test_proc2' || - '%some_packagebefore_test_proc3' || - '%' || - '%' || - '%some_packageafter_test_proc' || - '%some_packageafter_test_proc2' || - '%some_packageafter_test_proc3' || - '%' || - '%%' - ); - end; - - procedure before_aftertest_pkg_proc is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','external_package.before_test_proc', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','external_package.after_test_proc', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%external_packagebefore_test_proc' || - '%' || - '%' || - '%external_packageafter_test_proc' || - '%' || - '%%' - ); - end; - - procedure before_aftertest_mixed_syntax is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(14, 'test','A test', 'some_test'), - ut3_develop.ut_annotation(15, 'beforetest','external_package.before_test_proc, before_test_proc2', 'some_test'), - ut3_develop.ut_annotation(18, 'aftertest','external_package.after_test_proc, after_test_proc2', 'some_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%some_test' || - '%' || - '%external_packagebefore_test_proc' || - '%some_packagebefore_test_proc2' || - '%' || - '%' || - '%external_packageafter_test_proc' || - '%some_packageafter_test_proc2' || - '%' || - '%%' - ); - end; - - procedure test_annotation_ordering is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(4, 'test','B test', 'b_test'), - ut3_develop.ut_annotation(10, 'test','Z test', 'z_test'), - ut3_develop.ut_annotation(14, 'test','A test', 'a_test') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%%some_package%b_test' || - '%%'|| - '%%some_package%z_test' || - '%%'|| - '%%some_package%a_test' || - '%%' - ); - end; - - procedure test_bad_procedure_annotation is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(2, 'bad_procedure_annotation',null, 'some_procedure'), - ut3_develop.ut_annotation(6, 'test','A test', 'do_stuff') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_match('(.*)(Unsupported annotation "--%bad_procedure_annotation"\. Annotation ignored\.)(.*)( line 2)(.*)', 'n'); - end; - - procedure test_bad_package_annotation is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(1, 'suite','Cool', null), - ut3_develop.ut_annotation(17, 'bad_package_annotation',null, null), - ut3_develop.ut_annotation(24, 'test','A test', 'do_stuff') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - 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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.ut_annotation(9, 'tags','testtag', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(3, 'tags','suitetag', null), - ut3_develop.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_develop.ut_annotations; - begin - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.ut_annotation(9, 'tags','testtag,testtag1,testtag', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(3, 'tags','suitetag,suitetag1,suitetag', null), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.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_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.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; - - procedure test_spaces_in_tag is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(3, 'tags',' good_tag , bad tag , good-tag ', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.ut_annotation(9, 'tags',' good_tag , bad tag , good-tag ', 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%good_taggood-tag%'|| - 'good_taggood-tag%' - ); - ut.expect(l_actual).to_be_like( - '%Invalid value "bad tag" for "--%tags" annotation.'|| - ' See documentation for details on valid tag values. Annotation value ignored.' || - '%at package "UT3_TESTER.SOME_PACKAGE", line 3%' - ); - ut.expect(l_actual).to_be_like( - '%Invalid value "bad tag" for "--%tags" annotation.'|| - ' See documentation for details on valid tag values. Annotation value ignored.' || - '%at package "UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE", line 9%' - ); - end; - - procedure test_minus_in_tag is - l_actual clob; - l_annotations ut3_develop.ut_annotations; - begin - --Arrange - l_annotations := ut3_develop.ut_annotations( - ut3_develop.ut_annotation(2, 'suite','testsuite', null), - ut3_develop.ut_annotation(3, 'tags',' good_tag , -invalid_tag , good-tag ', null), - ut3_develop.ut_annotation(8, 'test','Some test', 'test_procedure'), - ut3_develop.ut_annotation(9, 'tags',' good_tag , -invalid_tag , good-tag ', 'test_procedure') - ); - --Act - l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); - --Assert - ut.expect(l_actual).to_be_like( - '%good_taggood-tag%'|| - 'good_taggood-tag%' - ); - ut.expect(l_actual).to_be_like( - '%Invalid value "-invalid_tag" for "--%tags" annotation.'|| - ' See documentation for details on valid tag values. Annotation value ignored.' || - '%at package "UT3_TESTER.SOME_PACKAGE", line 3%' - ); - ut.expect(l_actual).to_be_like( - '%Invalid value "-invalid_tag" for "--%tags" annotation.'|| - ' See documentation for details on valid tag values. Annotation value ignored.' || - '%at package "UT3_TESTER.SOME_PACKAGE.TEST_PROCEDURE", line 9%' - ); - end; - -end test_suite_builder; -/ diff --git a/test/ut3_tester/core/test_suite_builder.pks b/test/ut3_tester/core/test_suite_builder.pks deleted file mode 100644 index 4cbfcad74..000000000 --- a/test/ut3_tester/core/test_suite_builder.pks +++ /dev/null @@ -1,245 +0,0 @@ -create or replace package test_suite_builder is - --%suite(suite_builder) - --%suitepath(utplsql.ut3_tester.core) - - --%context(--%suite annotation) - --%name(suite) - - --%test(Sets suite name from package name and leaves description empty) - procedure no_suite_description; - - --%test(Sets suite description using first --%suite annotation) - procedure suite_description_from_suite; - - --%test(Gives warning if more than one --%suite annotation used) - procedure suite_annot_duplicated; - - --%endcontext - - --%context(--%displayname annotation) - - --%test(Overrides suite description using first --%displayname annotation) - procedure suite_descr_from_displayname; - - --%test(Gives warning if more than one --%displayname annotation used) - procedure displayname_annot_duplicated; - - --%test(Gives warning if --%displayname annotation has no value) - procedure displayname_annot_empty; - - --%endcontext - - --%context(--%test annotation) - - --%test(Creates a test item for procedure annotated with --%test annotation) - procedure test_annotation; - - --%test(Gives warning if more than one --%test annotation used) - procedure test_annot_duplicated; - - --%test(Is added to suite according to annotation order in package spec) - procedure test_annotation_ordering; - - --%endcontext - - --%context(--%suitepath annotation) - - --%test(Sets suite path using first --%suitepath annotation) - procedure suitepath_from_non_empty_path; - - --%test(Gives warning if more than one --%suitepath annotation used) - procedure suitepath_annot_duplicated; - - --%test(Gives warning if --%suitepath annotation has no value) - procedure suitepath_annot_empty; - - --%test(Gives warning if --%suitepath annotation has invalid value) - procedure suitepath_annot_invalid_path; - - --%endcontext - - --%context--%rollback annotation) - - --%test(Sets rollback type using first --%rollback annotation) - procedure rollback_type_valid; - - --%test(Gives warning if more than one --%rollback annotation used) - procedure rollback_type_duplicated; - - --%test(Gives warning if --%rollback annotation has no value) - procedure rollback_type_empty; - - --%test(Gives warning if --%rollback annotation has invalid value) - procedure rollback_type_invalid; - - --%endcontext - - --%context(--%before/after all/each annotations) - - --%test(Supports multiple before/after all/each procedure level definitions) - procedure multiple_before_after; - - --%test(Supports multiple before/after all/each standalone level definitions) - procedure multiple_standalone_bef_aft; - - --%test(Supports mixing before/after all/each annotations on single procedure) - procedure before_after_on_single_proc; - - --%test(Supports mixed before/after all/each as standalone and procedure level definitions) - procedure multiple_mixed_bef_aft; - - --%test(Gives warning if more than one --%beforeall annotation used on procedure) - procedure beforeall_annot_duplicated; - - --%test(Gives warning if more than one --%beforeeach annotation used on procedure) - procedure beforeeach_annot_duplicated; - - --%test(Gives warning if more than one --%afterall annotation used on procedure) - procedure afterall_annot_duplicated; - - --%test(Gives warning if more than one --%aftereach annotation used on procedure) - procedure aftereach_annot_duplicated; - - --%test(Gives warning on before/after all/each annotations mixed with test) - procedure before_after_mixed_with_test; - - --%endcontext - - --%context(--%context annotation) - --%name(context) - - --%test(Creates nested suite for content between context/endcontext annotations) - procedure suite_from_context; - - --%test(Creates nested contexts inside a context) - procedure nested_contexts; - - --%test(Creates multiple nested contexts inside a context) - procedure nested_contexts_2; - - --%test(Associates before/after all/each to tests in context only) - procedure before_after_in_context; - - --%test(Propagates beforeeach/aftereach to context) - procedure before_after_out_of_context; - - --%test(Gives warning when endcontext is missing) - procedure context_without_endcontext; - - --%test(Gives warning if --%endcontext is missing a preceding --%context) - procedure endcontext_without_context; - - --%test(Gives warning when two contexts have the same name and falls back to default context name) - procedure duplicate_context_name; - - --%endcontext - - --%context(--%name annotation) - - --%test(Falls back to default context name and gives warning when context name contains "." character) - procedure hard_stop_in_ctx_name; - - --%test(Falls back to default context name and gives warning when name contains spaces) - procedure name_with_spaces_invalid; - - --%test(Raises warning when more than one name annotation used ) - procedure duplicate_name_annotation; - - --%test(Is ignored when used outside of context - no warning given) - procedure name_outside_of_context; - - --%test(Is ignored when name value is empty) - procedure name_empty_value; - - --%test(Is applied to corresponding context when multiple contexts used) - procedure multiple_contexts; - - --%endcontext - - --%context(--%throws annotation) - - --%test(Gives warning if --%throws annotation has no value) - procedure throws_value_empty; - - --%endcontext - - --%context(--%beforetest/aftertest annotation) - - --%test(Supports multiple occurrences of beforetest/aftertest for a test) - procedure before_aftertest_multi; - - --%test(Supports same procedure defined twice) - procedure before_aftertest_twice; - - --%test(Supports beforetest from external package) - procedure before_aftertest_pkg_proc; - - --%test(Supports mix of procedure and package.procedure) - procedure before_aftertest_mixed_syntax; - - --%endcontext - - --%context(--%bad_annotation) - - --%test(Gives warning when unknown procedure level annotation passed) - procedure test_bad_procedure_annotation; - - --%test(Gives warning when unknown package level annotation passed) - procedure test_bad_package_annotation; - - --%endcontext - - --%context(--%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; - - --%test(Raise warning and ignore tag with spaces in tag name) - procedure test_spaces_in_tag; - - --%test(Raise warning and ignore tag starting ith '-') - procedure test_minus_in_tag; - - --%endcontext - -end test_suite_builder; -/ diff --git a/test/ut3_tester/core/test_suite_manager.pkb b/test/ut3_tester/core/test_suite_manager.pkb deleted file mode 100644 index c818ad212..000000000 --- a/test/ut3_tester/core/test_suite_manager.pkb +++ /dev/null @@ -1,2238 +0,0 @@ -create or replace package body test_suite_manager is - - ex_obj_doesnt_exist exception; - pragma exception_init(ex_obj_doesnt_exist, -04043); - - procedure create_dummy_long_test_package is - begin - ut3_tester_helper.run_helper.create_dummy_long_test_package(); - end; - - procedure drop_dummy_long_test_package is - begin - ut3_tester_helper.run_helper.drop_dummy_long_test_package(); - end; - - procedure compile_dummy_packages is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_package_1 is - - --%suite - --%displayname(test_package_1) - --%suitepath(tests) - --%rollback(manual) - - gv_glob_val number; - - --%beforeeach - procedure global_setup; - - --%aftereach - procedure global_teardown; - - --%test - --%displayname(Test1 from test package 1) - procedure test1; - - --%test(Test2 from test package 1) - --%beforetest(test2_setup) - --%aftertest(test2_teardown) - procedure test2; - - procedure test2_setup; - - procedure test2_teardown; - -end test_package_1;]'; - - execute immediate q'[create or replace package body test_package_1 is - gv_var_1 number; - gv_var_1_temp number; - - procedure global_setup is - begin - gv_var_1 := 1; - gv_glob_val := 1; - end; - - procedure global_teardown is - begin - gv_var_1 := 0; - gv_glob_val := 0; - end; - - procedure test1 is - begin - ut.expect(gv_var_1, 'Some expectation').to_equal(1); - end; - - procedure test2 is - begin - ut.expect(gv_var_1, 'Some expectation').to_equal(2); - end; - - procedure test2_setup is - begin - gv_var_1_temp := gv_var_1; - gv_var_1 := 2; - end; - - procedure test2_teardown is - begin - gv_var_1 := gv_var_1_temp; - gv_var_1_temp := null; - end; - -end test_package_1;]'; - - execute immediate q'[create or replace package test_package_2 is - --%suite - --%suitepath(tests.test_package_1) - - gv_glob_val varchar2(1); - - --%beforeeach - procedure global_setup; - - --%aftereach - procedure global_teardown; - - --%test - procedure test1; - - --%test - --%beforetest(test2_setup) - --%aftertest(test2_teardown) - procedure test2; - - procedure test2_setup; - - procedure test2_teardown; - - --%beforeall - procedure context_setup; - - --%test(Test in a context) - procedure context_test; - - --%afterall - procedure context_teardown; - -end test_package_2;]'; - - execute immediate q'[create or replace package body test_package_2 is - gv_var_1 varchar2(1); - gv_var_1_temp varchar2(1); - - procedure global_setup is - begin - gv_var_1 := 'a'; - gv_glob_val := 'z'; - end; - - procedure global_teardown is - begin - gv_var_1 := 'n'; - gv_glob_val := 'n'; - end; - - procedure test1 is - begin - ut.expect(gv_var_1).to_equal('a'); - end; - - procedure test2 is - begin - ut.expect(gv_var_1).to_equal('b'); - end; - - procedure test2_setup is - begin - gv_var_1_temp := gv_var_1; - gv_var_1 := 'b'; - end; - - procedure test2_teardown is - begin - gv_var_1 := gv_var_1_temp; - gv_var_1_temp := null; - end; - - procedure context_setup is - begin - gv_var_1_temp := gv_var_1 || 'a'; - end; - - procedure context_test is - begin - ut.expect(gv_var_1_temp, 'Some expectation').to_equal('na'); - end; - - procedure context_teardown is - begin - gv_var_1_temp := null; - end; - -end test_package_2;]'; - - execute immediate q'[create or replace package test_package_3 is - --%suite - --%suitepath(tests2) - --%rollback(auto) - - gv_glob_val number; - - --%beforeeach - procedure global_setup; - - --%aftereach - procedure global_teardown; - - --%test - --%rollback(auto) - procedure test1; - - --%test - --%beforetest(test2_setup) - --%aftertest(test2_teardown) - procedure test2; - - procedure test2_setup; - - procedure test2_teardown; - - --%test - --%disabled - procedure disabled_test; - -end test_package_3;]'; - - execute immediate q'[create or replace package body test_package_3 is - gv_var_1 number; - gv_var_1_temp number; - - procedure global_setup is - begin - gv_var_1 := 1; - gv_glob_val := 1; - end; - - procedure global_teardown is - begin - gv_var_1 := 0; - gv_glob_val := 0; - end; - - procedure test1 is - begin - ut.expect(gv_var_1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(gv_var_1).to_equal(2); - end; - - procedure test2_setup is - begin - gv_var_1_temp := gv_var_1; - gv_var_1 := 2; - end; - - procedure test2_teardown is - begin - gv_var_1 := gv_var_1_temp; - gv_var_1_temp := null; - end; - - procedure disabled_test is - begin - null; - end; - -end test_package_3;]'; - - execute immediate q'[create or replace package test_package_with_ctx is - - --%suite(test_package_with_ctx) - - gv_glob_val number; - - --%context(Some context description) - --%name(some_context) - - --%test - --%displayname(Test1 from test package 1) - procedure test1; - - --%endcontext - -end test_package_with_ctx;]'; - - execute immediate q'[create or replace package body test_package_with_ctx is - - procedure test1 is - begin - null; - end; - -end test_package_with_ctx;]'; - - execute immediate q'[create or replace package test1_frontwildcard is - - --%suite - --%displayname(test1_frontwildcard) - --%suitepath(front_wildcard) - --%rollback(manual) - - --%test - --%displayname(Test1 from test test1_frontwildcard) - procedure first_test; - - --%test - --%displayname(Test2 from test test1_frontwildcard) - procedure second_test; - -end test1_frontwildcard;]'; - - execute immediate q'[create or replace package body test1_frontwildcard is - - procedure first_test is - begin - ut.expect(1).to_equal(1); - end; - - procedure second_test is - begin - ut.expect(1).to_equal(2); - end; - -end test1_frontwildcard;]'; - - execute immediate q'[create or replace package test2_frontwildcard is - - --%suite - --%displayname(test2_frontwildcard) - --%suitepath(front_wildcard) - --%rollback(manual) - - --%test - --%displayname(Test1 from test package test2_frontwildcard) - procedure first_test; - -end test2_frontwildcard;]'; - - execute immediate q'[create or replace package body test2_frontwildcard is - - procedure first_test is - begin - ut.expect(1).to_equal(1); - end; - -end test2_frontwildcard;]'; - - execute immediate q'[create or replace package middle_test1_wildcard is - - --%suite - --%displayname(middle_test1_wildcard) - --%suitepath(wild_middle_card) - --%rollback(manual) - - --%test - --%displayname(Test1 from test middle_test1_wildcard) - procedure middle_first_test; - - --%test - --%displayname(Test2 from test middle_test1_wildcard) - procedure middle_second_test; - -end middle_test1_wildcard;]'; - - execute immediate q'[create or replace package body middle_test1_wildcard is - - procedure middle_first_test is - begin - ut.expect(1).to_equal(1); - end; - - procedure middle_second_test is - begin - ut.expect(1).to_equal(2); - end; - -end middle_test1_wildcard;]'; - - execute immediate q'[create or replace package middle_test2_wildcard is - - --%suite - --%displayname(middle_test2_wildcard) - --%suitepath(wild_middle_card) - --%rollback(manual) - - --%test - --%displayname(Test1 from test package middle_test2_wildcard) - procedure middle_first_test; - -end middle_test2_wildcard;]'; - - execute immediate q'[create or replace package body middle_test2_wildcard is - - procedure middle_first_test is - begin - ut.expect(1).to_equal(1); - end; - -end middle_test2_wildcard;]'; - - execute immediate q'[create or replace package test1_multi_wildcard is - - --%suite - --%displayname(test1_multi_wildcard) - --%suitepath(wildcard_multi_asterisks) - --%rollback(manual) - - --%test - --%displayname(Test1 from test test1_multi_wildcard) - procedure first_multi_test1; - - --%test - --%displayname(Test2 from test test1_multi_wildcard) - procedure second_multi_test2; - -end test1_multi_wildcard;]'; - - execute immediate q'[create or replace package body test1_multi_wildcard is - - procedure first_multi_test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure second_multi_test2 is - begin - ut.expect(1).to_equal(2); - end; - -end test1_multi_wildcard;]'; - - execute immediate q'[create or replace package test2_multi_wildcard is - - --%suite - --%displayname(test2_multi_wildcard) - --%suitepath(wildcard_multi_asterisks) - --%rollback(manual) - - --%test - --%displayname(Test1 from test package test2_multi_wildcard) - procedure first_multi_test1; - -end test2_multi_wildcard;]'; - - execute immediate q'[create or replace package body test2_multi_wildcard is - - procedure first_multi_test1 is - begin - ut.expect(1).to_equal(1); - end; - -end test2_multi_wildcard;]'; - - end; - - procedure drop_dummy_packages is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_package_1'; - execute immediate 'drop package test_package_2'; - execute immediate 'drop package test_package_3'; - execute immediate 'drop package test_package_with_ctx'; - execute immediate 'drop package test1_frontwildcard'; - execute immediate 'drop package test2_frontwildcard'; - execute immediate 'drop package middle_test1_wildcard'; - execute immediate 'drop package middle_test2_wildcard'; - execute immediate 'drop package test1_multi_wildcard'; - execute immediate 'drop package test2_multi_wildcard'; - end; - - procedure test_schema_run is - c_path constant varchar2(100) := sys_context('USERENV', 'CURRENT_USER'); - l_objects_to_run ut3_develop.ut_suite_items := ut3_develop.ut_suite_items(); - l_all_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_all_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - for i in 1..l_all_objects_to_run.count loop - if l_all_objects_to_run(i).name in ('tests', 'tests2') then - l_objects_to_run.extend; - l_objects_to_run(l_objects_to_run.last) := l_all_objects_to_run(i); - end if; - end loop; - - --Assert - ut.expect(l_objects_to_run.count).to_equal(2); - - for i in 1 .. 2 loop - l_test0_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite); - ut.expect(l_test0_suite.name in ('tests', 'tests2')).to_be_true; - - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - case l_test0_suite.name - when 'tests' then - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - when 'tests2' then - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - end case; - - end loop; - - end; - - procedure test_top2_by_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - ut.expect(l_test2_suite.items.count).to_equal(3); - end; - - procedure test_top2_bt_name_cur_user is - c_path varchar2(100) := 'test_package_2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - ut.expect(l_test2_suite.items.count).to_equal(3); - end; - - procedure test_by_path_to_subsuite is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test_package_2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - end; - - procedure test_by_path_to_subsuite_cu is - c_path varchar2(100) := ':tests.test_package_1.test_package_2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - end; - - procedure test_subsute_proc_by_path is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test_package_2.test2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - ut.expect(l_test2_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); - ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); - - end; - - procedure test_subsute_proc_by_path_cu is - c_path varchar2(100) := ':tests.test_package_1.test_package_2.test2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); - ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); - end; - - procedure test_top_pack_by_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(2); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).after_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(0); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(l_test1_suite.items(2).description).to_equal('Test2 from test package 1'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).after_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(0); - - end; - - procedure test_top_pack_by_name_cu is - c_path varchar2(100) := 'test_package_1'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_suite; - l_test2_suite ut3_develop.ut_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(2); - - ut.expect(l_test1_suite.items(1).name).to_equal('test1'); - ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1'); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).after_test_list.count).to_equal(0); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(1) as ut3_develop.ut_test).disabled_flag).to_equal(0); - - ut.expect(l_test1_suite.items(2).name).to_equal('test2'); - ut.expect(l_test1_suite.items(2).description).to_equal('Test2 from test package 1'); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).after_test_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).before_each_list.count).to_be_greater_than(0); - ut.expect(treat(l_test1_suite.items(2) as ut3_develop.ut_test).disabled_flag).to_equal(0); - - end; - - procedure test_top_pack_by_path is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - end; - - procedure test_top_pack_by_path_cu is - c_path varchar2(100) := ':tests'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - end; - - procedure test_top_pck_proc_by_path is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests.test_package_1.test2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.description).to_equal('Test2 from test package 1'); - ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); - ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); - end; - - procedure test_top_pck_proc_by_path_cu is - c_path varchar2(100) := ':tests.test_package_1.test2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.description).to_equal('Test2 from test package 1'); - ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); - ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); - end; - - procedure test_top_pkc_proc_by_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1.test2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); - ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); - end; - - procedure test_top_pkc_proc_by_name_cu is - c_path varchar2(100) := 'test_package_1.test2'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(1); - - l_test_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test2'); - ut.expect(l_test_proc.before_test_list.count).to_be_greater_than(0); - ut.expect(l_test_proc.after_test_list.count).to_be_greater_than(0); - end; - - procedure test_top_pkc_nosub_by_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_3'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1 ut3_develop.ut_test; - l_test3 ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.DISABLED_FLAG).to_equal(1); - end; - - procedure test_top_pkc_nosub_by_name_cu is - c_path varchar2(100) := 'test_package_3'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1 ut3_develop.ut_test; - l_test3 ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.DISABLED_FLAG).to_equal(1); - end; - - procedure test_top_subpck_by_path is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests2.test_package_3'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1 ut3_develop.ut_test; - l_test3 ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.DISABLED_FLAG).to_equal(1); - end; - - procedure test_top_subpck_by_path_cu is - c_path varchar2(100) := ':tests2.test_package_3'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test0_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1 ut3_develop.ut_test; - l_test3 ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test0_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test0_suite.name).to_equal('tests2'); - ut.expect(l_test0_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test0_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - l_test1 := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1.name).to_equal('test1'); - ut.expect(l_test1.DISABLED_FLAG).to_equal(0); - - l_test3 := treat(l_test1_suite.items(3) as ut3_develop.ut_test); - ut.expect(l_test3.name).to_equal('disabled_test'); - ut.expect(l_test3.DISABLED_FLAG).to_equal(1); - end; - - procedure test_search_invalid_pck is - l_objects_to_run ut3_develop.ut_suite_items; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('failing_invalid_spec')); - - ut3_develop.ut.expect(l_objects_to_run.count).to_be_greater_than(0); - ut3_develop.ut.expect(l_objects_to_run(l_objects_to_run.first).object_name).to_equal('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; - - --%beforeall - procedure before_all; - --%test - procedure test1; - --%test - procedure test2; -end;]'; - exception when ex_compilation_error then null; - end; - begin - execute immediate q'[create or replace package body failing_invalid_spec as - procedure before_all is begin gv_glob_val := 1; end; - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 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 test_search_nonexisting_pck is - l_objects_to_run ut3_develop.ut_suite_items; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop.failing_non_existing')); - ut.fail('Non existing package did not raise exception'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%failing_non_existing%'); - end; - - procedure test_search_nonex_pck_wild is - l_objects_to_run ut3_develop.ut_suite_items; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop.failing_non_*')); - ut.fail('Non existing package did not raise exception'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%failing_non_*%'); - end; - - procedure test_search_nonex_prc_wild is - l_objects_to_run ut3_develop.ut_suite_items; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_tester.test_package_1.nonexist*')); - ut.fail('Non existing package did not raise exception'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%nonexist*%'); - end; - - procedure test_search_nonex_path_wild is - l_objects_to_run ut3_develop.ut_suite_items; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop:failing_non_*')); - ut.fail('Non existing path did not raise exception'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%:failing_non_*%'); - end; - - procedure test_search_nonexist_sch_pck is - l_objects_to_run ut3_develop.ut_suite_items; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('failing_non_existing')); - ut.fail('Non existing package without schema did not raise exception'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%ORA-44001: invalid schema%'); - end; - - procedure test_desc_with_comma is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_to_be_dropped')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - - ut.expect(l_suite.name).to_equal('tst_package_to_be_dropped'); - ut.expect(l_suite.description).to_equal('A suite description, though with comma, is assigned by suite_manager'); - ut.expect(l_suite.items.count).to_equal(2); - - l_test := treat(l_suite.items(1) as ut3_develop.ut_test); - - ut.expect(l_test.name).to_equal('test1'); - ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager'); - --- l_test := treat(l_suite.items(2) as ut3_develop.ut_test); --- --- ut.expect(l_test.name).to_equal('test2'); --- ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager'); - - end; - procedure setup_desc_with_comma is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_package_to_be_dropped as - --%suite(A suite description, though with comma, is assigned by suite_manager) - - --%test(A test description, though with comma, is assigned by suite_manager) - procedure test1; - - --%test - --%displayname(A test description, though with comma, is assigned by suite_manager) - procedure test2; -end;'; - - execute immediate 'create or replace package body tst_package_to_be_dropped as - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - procedure clean_desc_with_comma is - pragma autonomous_transaction; - begin - begin - execute immediate 'drop package tst_package_to_be_dropped'; - exception - when ex_obj_doesnt_exist then - null; - end; - end; - - procedure test_inv_cache_on_drop is - l_test_report ut3_develop.ut_varchar2_list; - begin - - select * bulk collect into l_test_report from table(ut3_develop.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_develop.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.tst_package_to_be_dropped')); - ut.fail('Cache not invalidated on package drop'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%tst_package_to_be_dropped%does not exist%'); - end; - - end; - procedure setup_inv_cache_on_drop is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_package_to_be_dropped as - --%suite - - --%test - procedure test1; -end;'; - - execute immediate 'create or replace package body tst_package_to_be_dropped as - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - - procedure clean_inv_cache_on_drop is - pragma autonomous_transaction; - begin - execute immediate 'drop package tst_package_to_be_dropped'; - exception - when ex_obj_doesnt_exist then - null; - end; - - procedure test_inv_pck_bodies is - l_test_report ut3_develop.ut_varchar2_list; - begin - - select * bulk collect into l_test_report from table(ut3_develop.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_develop.ut.run(''UT3_DEVELOP.test_dependencies'', ut3_develop.utplsql_test_reporter()))' into l_result; - --- ut.expect(l_result).to_equal(ut3_develop.ut_utils.gc_success); - end; - procedure setup_inv_pck_bodies is - pragma autonomous_transaction; - begin - execute immediate 'create table test_dependency_table (id integer)'; - execute immediate 'create or replace package test_dependencies as - -- %suite - - -- %test - procedure dependant; -end;'; - execute immediate 'create or replace package body test_dependencies as - gc_dependant_variable test_dependency_table.id%type; - procedure dependant is begin null; end; -end;'; - - execute immediate 'alter table test_dependency_table modify id number'; - - end; - procedure clean_inv_pck_bodies is - pragma autonomous_transaction; - begin - execute immediate 'drop table test_dependency_table'; - execute immediate 'drop package test_dependencies'; - end; - - procedure test_pck_with_dollar is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - begin - --act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with$dollar')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - ut.expect(l_suite.name).to_equal('tst_package_with$dollar'); - end; - procedure setup_pck_with_dollar is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_package_with$dollar as - --%suite - - --%test - procedure test1; -end;'; - - execute immediate 'create or replace package body tst_package_with$dollar as - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - procedure clean_pck_with_dollar is - pragma autonomous_transaction; - begin - execute immediate 'drop package tst_package_with$dollar'; - end; - - - procedure test_pck_with_hash is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - begin - --act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with#hash')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - ut.expect(l_suite.name).to_equal('tst_package_with#hash'); - end; - procedure setup_pck_with_hash is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_package_with#hash as - --%suite - - --%test - procedure test1; -end;'; - - execute immediate 'create or replace package body tst_package_with#hash as - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - procedure clean_pck_with_hash is - pragma autonomous_transaction; - begin - execute immediate 'drop package tst_package_with#hash'; - end; - - - procedure test_test_with_dollar is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with_dollar_test.test$1')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - - ut.expect(l_suite.name).to_equal('tst_package_with_dollar_test'); - ut.expect(l_suite.items.count).to_equal(1); - - l_test := treat(l_suite.items(1) as ut3_develop.ut_test); - - ut.expect(l_test.name).to_equal('test$1'); - - end; - procedure setup_test_with_dollar is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_package_with_dollar_test as - --%suite - - --%test - procedure test$1; -end;'; - - execute immediate 'create or replace package body tst_package_with_dollar_test as - procedure test$1 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - procedure clean_test_with_dollar is - pragma autonomous_transaction; - begin - execute immediate 'drop package tst_package_with_dollar_test'; - end; - - procedure test_test_with_hash is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_package_with_hash_test.test#1')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - - ut.expect(l_suite.name).to_equal('tst_package_with_hash_test'); - ut.expect(l_suite.items.count).to_equal(1); - - l_test := treat(l_suite.items(1) as ut3_develop.ut_test); - - ut.expect(l_test.name).to_equal('test#1'); - - end; - procedure setup_test_with_hash is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_package_with_hash_test as - --%suite - - --%test - procedure test#1; -end;'; - - execute immediate 'create or replace package body tst_package_with_hash_test as - procedure test#1 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - procedure clean_test_with_hash is - pragma autonomous_transaction; - begin - execute immediate 'drop package tst_package_with_hash_test'; - end; - - procedure test_empty_suite_path is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - begin - - --act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('tst_empty_suite_path')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - - ut.expect(l_suite.name).to_equal('tst_empty_suite_path'); - end; - - procedure setup_empty_suite_path is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package tst_empty_suite_path as - --%suite - --%suitepath - - --%test - procedure test1; -end;'; - execute immediate 'create or replace package body tst_empty_suite_path as - procedure test1 is begin ut.expect(1).to_equal(1); end; -end;'; - end; - - procedure clean_empty_suite_path is - pragma autonomous_transaction; - begin - execute immediate 'drop package tst_empty_suite_path'; - end; - - procedure test_pck_with_same_path is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite1 ut3_develop.ut_logical_suite; - l_suite2 ut3_develop.ut_logical_suite; - l_suite3 ut3_develop.ut_suite; - begin - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(':test1.test2$.test_package_same_1')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_suite1 := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_suite1.name).to_equal('test1'); - ut.expect(l_suite1.items.count).to_equal(1); - - l_suite2 := treat(l_suite1.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_suite2.name).to_equal('test2$'); - ut.expect(l_suite2.items.count).to_equal(1); - - l_suite3 := treat(l_suite2.items(1) as ut3_develop.ut_suite); - ut.expect(l_suite3.name).to_equal('test_package_same_1'); - end; - - procedure setup_pck_with_same_path is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package test_package_same_1 as - --%suite - --%suitepath(test1.test2$) - - --%test - procedure test1; -end;'; - execute immediate 'create or replace package body test_package_same_1 as - procedure test1 is begin null; end; -end;'; - execute immediate 'create or replace package test_package_same_1_a as - --%suite - --%suitepath(test1.test2$) - - --%test - procedure test1; -end;'; - execute immediate 'create or replace package body test_package_same_1_a as - procedure test1 is begin null; end; -end;'; - end; - - procedure clean_pck_with_same_path is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_package_same_1'; - execute immediate 'drop package test_package_same_1_a'; - end; - - procedure setup_disabled_pck is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_disabled_floating as - --%suite - - --%test - procedure test1; - - --%disabled - - --%test - procedure test2; - -end;]'; - end; - - procedure clean_disabled_pck is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_disabled_floating'; - end; - - procedure disable_suite_floating_annot is - l_objects_to_run ut3_develop.ut_suite_items; - l_suite ut3_develop.ut_suite; - begin - --Arrange - setup_disabled_pck; - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('test_disabled_floating')); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_suite := treat(l_objects_to_run(1) as ut3_develop.ut_suite); - ut.expect(l_suite.name).to_equal('test_disabled_floating'); - ut.expect(l_suite.get_disabled_flag()).to_be_true(); - - clean_disabled_pck; - end; - - procedure pck_proc_in_ctx_by_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_with_ctx.test1'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test_suite ut3_develop.ut_logical_suite; - l_ctx_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('test_package_with_ctx'); - ut.expect(l_test_suite.items.count).to_equal(1); - - l_ctx_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_ctx_suite.name).to_equal('some_context'); - ut.expect(l_ctx_suite.description).to_equal('Some context description'); - ut.expect(l_ctx_suite.items.count).to_equal(1); - - l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test1'); - end; - - procedure pck_proc_in_ctx_by_path is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':test_package_with_ctx.some_context.test1'; - l_objects_to_run ut3_develop.ut_suite_items; - - l_test_suite ut3_develop.ut_logical_suite; - l_ctx_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('test_package_with_ctx'); - ut.expect(l_test_suite.items.count).to_equal(1); - - l_ctx_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_ctx_suite.name).to_equal('some_context'); - ut.expect(l_ctx_suite.description).to_equal('Some context description'); - ut.expect(l_ctx_suite.items.count).to_equal(1); - - l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test1'); - end; - - procedure test_get_schema_ut_packages is - l_expected ut3_develop.ut_object_names; - l_actual ut3_develop.ut_object_names; - begin - l_expected := ut3_develop.ut_object_names( - ut3_develop.ut_object_name('UT3_DEVELOP','SOME_TEST_PACKAGE') - ); - l_actual := ut3_tester_helper.run_helper.get_schema_ut_packages('UT3_DEVELOP'); - - ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); - end; - - procedure create_ut3_suite is - begin - ut3_tester_helper.run_helper.create_ut3_suite(); - end; - - procedure drop_ut3_suite is - pragma autonomous_transaction; - begin - ut3_tester_helper.run_helper.drop_ut3_suite(); - end; - - procedure add_new_long_test_package is - l_actual ut3_develop.ut_object_names; - l_expected_message varchar2(500); - begin - l_expected_message := q'[ORA-20217: 'Suitepath exceeds 1000 CHAR on: UT3_DEVELOP.DUMMY_LONG_TEST_PACKAGE,UT3_DEVELOP.DUMMY_LONG_TEST_PACKAGE1'%]'; - l_actual := ut3_tester_helper.run_helper.get_schema_ut_packages('UT3_DEVELOP'); - ut.fail('Expected exception for suitpaths over 1k for two packages'); - exception - when others then - ut.expect(dbms_utility.format_error_stack()).to_be_like(l_expected_message); - ut.expect(SQLCODE).to_equal(ut3_develop.ut_utils.gc_value_too_large); - end; - - procedure setup_remove_annot_test is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_removing_annotation as - --%suite - - --%test - procedure test1; - - --%test - procedure test2; - -end;]'; - end; - - procedure remove_annot_from_test is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_removing_annotation as - - procedure test1; - - procedure test2; - -end;]'; - end; - - procedure rem_one_annot_test is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_removing_annotation as - --%suite - - procedure test1; - - --%test - procedure test2; - -end;]'; - execute immediate q'[create or replace package body test_removing_annotation as - - procedure test1 is - begin - ut.expect(1).to_equal(1); - end; - - procedure test2 is - begin - ut.expect(1).to_equal(1); - end; - -end;]'; - end; - - procedure clean_remove_annot_test is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_removing_annotation'; - end; - - procedure test_rem_cache_on_create is - l_test_report ut3_develop.ut_varchar2_list; - begin - - select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_removing_annotation')); - - -- drop all tests - remove_annot_from_test; - - begin - select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.test_removing_annotation')); - exception - when others then - ut.expect(sqlerrm).to_be_like('%ORA-20204: Suite package ut3_tester.test_removing_annotation does not exist%'); - end; - - end; - - procedure test_rem_cache_on_crt_anno is - l_test_report ut3_develop.ut_varchar2_list; - l_results clob; - begin - - select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_removing_annotation')); - - -- drop single test - rem_one_annot_test; - ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')|| '.test_removing_annotation',a_reporter => ut3_develop.ut_documentation_reporter() ); - l_results := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); - --Assert - ut.expect( l_results ).to_be_like( '%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' ); - - end; - - procedure test_wild_card_obj_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_*'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - l_ctx_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(3); - - - for i in 1 .. 3 loop - l_test_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name in ('test_package_with_ctx','tests', 'tests2')).to_be_true; - - case l_test_suite.name - when 'test_package_with_ctx' then - ut.expect(l_test_suite.items.count).to_equal(1); - l_ctx_suite:= treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_ctx_suite.name).to_equal('some_context'); - ut.expect(l_ctx_suite.description).to_equal('Some context description'); - ut.expect(l_ctx_suite.items.count).to_equal(1); - l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name).to_equal('test1'); - when 'tests' then - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - ut.expect(l_test1_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite); - - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual); - when 'tests2' then - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - end case; - - end loop; - - end; - - procedure test_wild_card_prc_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1.test*'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('tests'); - - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(2); - - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('test1'); - - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('test2'); - end; - - procedure test_wild_card_path_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests*'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test2_suite ut3_develop.ut_logical_suite; - l_ctx_suite ut3_develop.ut_logical_suite; - l_test_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(2); - - - for i in 1 .. 2 loop - l_test_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name in ('tests', 'tests2')).to_be_true; - - case l_test_suite.name - when 'tests' then - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test_package_1'); - ut.expect(l_test1_suite.items.count).to_equal(3); - - for i in 1 ..3 loop - case l_test1_suite.items(i).self_type - when 'UT_SUITE' then - l_test2_suite := treat(l_test1_suite.items(i) as ut3_develop.ut_logical_suite); - ut.expect(l_test2_suite.name).to_equal('test_package_2'); - ut.expect(l_test2_suite.items.count).to_equal(3); - - l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true; - - l_test_proc := treat(l_test2_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true; - - l_test_proc := treat(l_test2_suite.items(3) as ut3_develop.ut_test); - ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true; - - when 'UT_TEST' then - l_test_proc := treat(l_test1_suite.items(i) as ut3_develop.ut_test); - ut.expect(l_test_proc.name in ('test1', 'test2')).to_be_true; - end case; - end loop; - when 'tests2' then - ut.expect(l_test_suite.items.count).to_equal(1); - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test_package_3'); - ut.expect(l_test1_suite.items.count).to_equal(3); - for i in 1 .. 3 loop - l_test_proc := treat(l_test1_suite.items(i) as ut3_develop.ut_test); - ut.expect(l_test_proc.name in ('test1', 'test2','disabled_test')).to_be_true; - end loop; - end case; - - end loop; - - end; - - procedure test_wild_card_front_obj_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.*_frontwildcard'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('front_wildcard'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'test1_frontwildcard' then - ut.expect(l_test1_suite.items.count).to_equal(2); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_test'); - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('second_test'); - when 'test2_frontwildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_test'); - end case; - - end loop; - end; - - procedure test_wild_card_front_prc_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test1_frontwildcard.*_test'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('front_wildcard'); - - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test1_frontwildcard'); - ut.expect(l_test1_suite.items.count).to_equal(2); - - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_test'); - - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('second_test'); - end; - - procedure test_wild_card_front_path_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':*_wildcard'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('front_wildcard'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'test1_frontwildcard' then - ut.expect(l_test1_suite.items.count).to_equal(2); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_test'); - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('second_test'); - when 'test2_frontwildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_test'); - end case; - - end loop; - end; - - procedure test_wild_card_mid_obj_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.middle_*_wildcard'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wild_middle_card'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'middle_test1_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(2); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('middle_first_test'); - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('middle_second_test'); - when 'middle_test2_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('middle_first_test'); - end case; - - end loop; - end; - - procedure test_wild_card_mid_prc_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.middle_test1_wildcard.middle_*_test'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wild_middle_card'); - - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('middle_test1_wildcard'); - ut.expect(l_test1_suite.items.count).to_equal(2); - - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('middle_first_test'); - - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('middle_second_test'); - end; - - procedure test_wild_card_mid_path_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':wild_*card'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wild_middle_card'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'middle_test1_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(2); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('middle_first_test'); - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('middle_second_test'); - when 'middle_test2_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('middle_first_test'); - end case; - - end loop; - end; - - procedure test_wild_card_mul_obj_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.*_multi_*card'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'test1_multi_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(2); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('second_multi_test2'); - when 'test2_multi_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - end case; - - end loop; - end; - - procedure test_wild_card_mul_prc_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test1_multi_wildcard.*_multi_*'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); - - l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test1_suite.name).to_equal('test1_multi_wildcard'); - ut.expect(l_test1_suite.items.count).to_equal(2); - - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('second_multi_test2'); - end; - - procedure test_wild_card_mul_path_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':wild*_multi_*risks'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'test1_multi_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(2); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test); - ut.expect(l_test2_proc.name).to_equal('second_multi_test2'); - when 'test2_multi_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - end case; - - end loop; - end; - - procedure tst_wild_card_mul_lv_path_name is - c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':wild*_multi_*risks.*_multi_wildcard.*_multi_test1'; - l_objects_to_run ut3_develop.ut_suite_items; - l_test_suite ut3_develop.ut_logical_suite; - l_test1_suite ut3_develop.ut_logical_suite; - l_test1_proc ut3_develop.ut_test; - l_test2_proc ut3_develop.ut_test; - begin - --Act - l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path)); - - --Assert - ut.expect(l_objects_to_run.count).to_equal(1); - l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite); - ut.expect(l_test_suite.name).to_equal('wildcard_multi_asterisks'); - ut.expect(l_test_suite.items.count).to_equal(2); - - for i in 1 .. 2 loop - l_test1_suite := treat(l_test_suite.items(i) as ut3_develop.ut_logical_suite); - case l_test1_suite.name - when 'test1_multi_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - when 'test2_multi_wildcard' then - ut.expect(l_test1_suite.items.count).to_equal(1); - l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test); - ut.expect(l_test1_proc.name).to_equal('first_multi_test1'); - end case; - - end loop; - end; - - --%test(Path validation does not fail on Estonian NLS_SORT - fix #1252) - procedure path_validate_nls_sort is - l_schema_names ut3_develop.ut_varchar2_rows; - begin - --Arrange - execute immediate q'[alter session set nls_sort='estonian']'; - --Act - l_schema_names := ut3_develop.ut_suite_manager.get_schema_names(ut3_develop.ut_varchar2_list('ut3')); - --Asseert - ut.expect(sqlcode).to_equal(0); - end; - - - procedure reset_nls_sort is - begin - execute immediate q'[alter session set nls_sort='binary']'; - end; -end test_suite_manager; -/ diff --git a/test/ut3_tester/core/test_suite_manager.pks b/test/ut3_tester/core/test_suite_manager.pks deleted file mode 100644 index 44f102716..000000000 --- a/test/ut3_tester/core/test_suite_manager.pks +++ /dev/null @@ -1,251 +0,0 @@ -create or replace package test_suite_manager is - - --%suite(suite_manager) - --%suitepath(utplsql.ut3_tester.core) - - - --%beforeall - procedure compile_dummy_packages; - --%afterall - procedure drop_dummy_packages; - - --%test(Prepare Runner For The Schema) - procedure test_schema_run; - - --%test(Prepare runner for the top 2 package by package user.package_name) - procedure test_top2_by_name; - - --%test(Prepare runner for the top2 package by name cur user) - procedure test_top2_bt_name_cur_user; - - --%test(Prepare runner for the subsuite by path) - procedure test_by_path_to_subsuite; - - --%test(Prepare runner for the subsuite by path for current user) - procedure test_by_path_to_subsuite_cu; - - --%test(Prepare runner for the subsuite proc only by path) - procedure test_subsute_proc_by_path; - - --%test(Prepare runner for the subsuite proc only by path for current user) - procedure test_subsute_proc_by_path_cu; - - --%test(Prepare runner for the top package by package name) - procedure test_top_pack_by_name; - - --%test(Prepare runner for the top package by package name for current user) - procedure test_top_pack_by_name_cu; - - --%test(Prepare runner for the top package by path) - procedure test_top_pack_by_path; - - --%test(Prepare runner for the top package by path for current user) - procedure test_top_pack_by_path_cu; - - --%test(Prepare runner for the top package procedure by path) - procedure test_top_pck_proc_by_path; - - --%test(Prepare runner for the top package procedure by path for current user) - procedure test_top_pck_proc_by_path_cu; - - --%test(Prepare runner for the top package procedure without sub-suites by package name) - procedure test_top_pkc_proc_by_name; - - --%test(Prepare runner for the top package procedure without sub-suites by package name for current user) - procedure test_top_pkc_proc_by_name_cu; - - --%test(Prepare runner for the top package without sub-suites by package name) - procedure test_top_pkc_nosub_by_name; - - --%test(Prepare runner for the top package without sub-suites by package name for current user) - procedure test_top_pkc_nosub_by_name_cu; - - --%test(Prepare runner for the suites package by path) - procedure test_top_subpck_by_path; - - --%test(Prepare runner for the suites package by path for current user) - procedure test_top_subpck_by_path_cu; - - --%test(Prepare runner for invalid package - it will add to suite but fail on exec ) - --%beforetest(compile_invalid_package) - --%aftertest(drop_invalid_package) - procedure test_search_invalid_pck; - procedure compile_invalid_package; - procedure drop_invalid_package; - - --%test(Prepare runner for nonexisting package with schema) - procedure test_search_nonexisting_pck; - - --%test(Prepare runner for nonexisting package using wildcard filter) - procedure test_search_nonex_pck_wild; - - --%test(Prepare runner for nonexisting procedure using wildcard filter) - procedure test_search_nonex_prc_wild; - - --%test(Prepare runner for nonexisting path using wildcard filter) - procedure test_search_nonex_path_wild; - - --%test(Prepare runner for nonexisting package without schema) - procedure test_search_nonexist_sch_pck; - - --%test(Test description with comma) - --%beforetest(setup_desc_with_comma) - --%aftertest(clean_desc_with_comma) - procedure test_desc_with_comma; - procedure setup_desc_with_comma; - procedure clean_desc_with_comma; - - --%test(Invalidate cache on package drop) - --%beforetest(setup_inv_cache_on_drop) - --%aftertest(clean_inv_cache_on_drop) - procedure test_inv_cache_on_drop; - procedure setup_inv_cache_on_drop; - procedure clean_inv_cache_on_drop; - - --%test(Includes Invalid Package Bodies In The Run) - --%beforetest(setup_inv_pck_bodies) - --%aftertest(clean_inv_pck_bodies) - procedure test_inv_pck_bodies; - procedure setup_inv_pck_bodies; - procedure clean_inv_pck_bodies; - - --%test(Package With Dollar Sign) - --%beforetest(setup_pck_with_dollar) - --%aftertest(clean_pck_with_dollar) - procedure test_pck_with_dollar; - procedure setup_pck_with_dollar; - procedure clean_pck_with_dollar; - - --%test(Package With Hash Sign) - --%beforetest(setup_pck_with_hash) - --%aftertest(clean_pck_with_hash) - procedure test_pck_with_hash; - procedure setup_pck_with_hash; - procedure clean_pck_with_hash; - - --%test(Package with test with dollar sign) - --%beforetest(setup_test_with_dollar) - --%aftertest(clean_test_with_dollar) - procedure test_test_with_dollar; - procedure setup_test_with_dollar; - procedure clean_test_with_dollar; - - --%test(Package with test with hash sign) - --%beforetest(setup_test_with_hash) - --%aftertest(clean_test_with_hash) - procedure test_test_with_hash; - procedure setup_test_with_hash; - procedure clean_test_with_hash; - - - --%test(Setup suite with empty suitepath) - --%beforetest(setup_empty_suite_path) - --%aftertest(clean_empty_suite_path) - procedure test_empty_suite_path; - procedure setup_empty_suite_path; - procedure clean_empty_suite_path; - - --%test(only the defined in suitepath suite/test is executed if multiple similarly named test suites exist in the context differed only by comment) - --%beforetest(setup_pck_with_same_path) - --%aftertest(clean_pck_with_same_path) - procedure test_pck_with_same_path; - procedure setup_pck_with_same_path; - procedure clean_pck_with_same_path; - - --%test(Whole suite gets disabled with floating annotation) - procedure disable_suite_floating_annot; - - --%test(Prepare runner for a package procedure inside context) - procedure pck_proc_in_ctx_by_name; - - --%test(Prepare runner for a package procedure inside context by path) - procedure pck_proc_in_ctx_by_path; - - --%context(get_schema_ut_packages) - - --%test(returns list of all unit test packages in given schema excluding packages that are not suites) - --%beforetest(create_ut3_suite) - --%aftertest(drop_ut3_suite) - procedure test_get_schema_ut_packages; - procedure create_ut3_suite; - procedure drop_ut3_suite; - - --%endcontext - - --%test(Adds suitepath to cache over 1k characters long) - --%beforetest(create_dummy_long_test_package) - --%aftertest(drop_dummy_long_test_package) - procedure add_new_long_test_package; - procedure create_dummy_long_test_package; - procedure drop_dummy_long_test_package; - - - procedure setup_remove_annot_test; - procedure clean_remove_annot_test; - - --%test(Remove cache on package create or replace when all annotations removed) - --%beforetest(setup_remove_annot_test) - --%aftertest(clean_remove_annot_test) - procedure test_rem_cache_on_create; - - - --%test(Remove cache on package create or replace when single annotation removed) - --%beforetest(setup_remove_annot_test) - --%aftertest(clean_remove_annot_test) - procedure test_rem_cache_on_crt_anno; - - --%context(wildcard_filters) - - --%test(Execute test_packages using a object_name with wildcard at the end ) - procedure test_wild_card_obj_name; - - --%test(Execute test_packages using a procedure name with wildcard at the end) - procedure test_wild_card_prc_name; - - --%test(Execute test_packages using a path name with wildcard at the end) - procedure test_wild_card_path_name; - - --%test(Execute test_packages using a object_name with wildcard in the front) - procedure test_wild_card_front_obj_name; - - --%test(Execute test_packages using a procedure name with wildcard in the front) - procedure test_wild_card_front_prc_name; - - -- %test(Execute test_packages using a path name with wildcard in the front) - procedure test_wild_card_front_path_name; - - --%test(Execute test_packages using a object_name with wildcard in the middle) - procedure test_wild_card_mid_obj_name; - - --%test(Execute test_packages using a procedure name with wildcard in the middle) - procedure test_wild_card_mid_prc_name; - - -- %test(Execute test_packages using a path name with wildcard in the middle) - procedure test_wild_card_mid_path_name; - - --%test(Execute test_packages using a object_name with multiple wildcards) - procedure test_wild_card_mul_obj_name; - - --%test(Execute test_packages using a procedure name with multiple wildcards) - procedure test_wild_card_mul_prc_name; - - -- %test(Execute test_packages using a path name with multiple wildcards) - procedure test_wild_card_mul_path_name; - - -- %test(Execute test_packages using a path name with multiple wildcards on different level) - procedure tst_wild_card_mul_lv_path_name; - - --%endcontext - - --%context(paths validation) - - --%test(Path validation does not fail on Estonian NLS_SORT - fix #1252) - --%aftertest(reset_nls_sort) - procedure path_validate_nls_sort; - - procedure reset_nls_sort; - - --%endcontext - -end test_suite_manager; -/ diff --git a/test/ut3_tester/core/test_ut_executable.pkb b/test/ut3_tester/core/test_ut_executable.pkb deleted file mode 100644 index e27a2e432..000000000 --- a/test/ut3_tester/core/test_ut_executable.pkb +++ /dev/null @@ -1,78 +0,0 @@ -create or replace package body test_ut_executable is - - g_dbms_output_text varchar2(30) := 'Some output from procedure'; - - procedure exec_schema_package_proc is - l_executable ut3_develop.ut_executable; - l_test ut3_develop.ut_test; - l_result boolean; - begin - --Arrange - l_test := ut3_develop.ut_test(a_object_name => 'test_ut_executable',a_name => 'test_ut_executable', a_line_no=> 1); - l_executable := ut3_develop.ut_executable_test( null, 'test_ut_executable', 'passing_proc', ut3_develop.ut_utils.gc_test_execute ); - --Act - l_result := l_executable.do_execute(l_test); - --Assert - ut.expect(l_result).to_be_true; - ut.expect(l_executable.serveroutput).to_be_null; - ut.expect(l_executable.get_error_stack_trace()).to_be_null; - end; - - procedure exec_package_proc_output is - l_executable ut3_develop.ut_executable; - l_test ut3_develop.ut_test; - l_result boolean; - begin - --Arrange - l_test := ut3_develop.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_develop.ut_executable_test( a_owner => 'ut3_tester', a_package => 'test_ut_executable', - a_procedure_name => 'output_proc', a_executable_type => ut3_develop.ut_utils.gc_test_execute ); - --Act - l_result := l_executable.do_execute(l_test); - --Assert - ut.expect(l_result).to_be_true; - ut.expect(l_executable.serveroutput).to_equal(to_clob(g_dbms_output_text||chr(10))); - ut.expect(l_executable.get_error_stack_trace()).to_be_null; - end; - - procedure exec_failing_proc is - l_executable ut3_develop.ut_executable; - l_test ut3_develop.ut_test; - l_result boolean; - begin - --Arrange - l_test := ut3_develop.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_develop.ut_executable_test( 'ut3_tester', 'test_ut_executable', 'throwing_proc', ut3_develop.ut_utils.gc_test_execute ); - --Act - l_result := l_executable.do_execute(l_test); - --Assert - ut.expect(l_result).to_be_false; - ut.expect(l_executable.serveroutput).to_be_null; - ut.expect(l_executable.get_error_stack_trace()).to_be_like('ORA-06501: PL/SQL: program error%'); - end; - - procedure form_name is - begin - ut.expect(ut3_develop.ut_executable_test( user, ' package ', 'proc', null ).form_name()).to_equal(user||'.package.proc'); - ut.expect(ut3_develop.ut_executable_test( null, 'package', ' proc ', null ).form_name()).to_equal('package.proc'); - ut.expect(ut3_develop.ut_executable_test( null, 'proc', null, null ).form_name()).to_equal('proc'); - ut.expect(ut3_develop.ut_executable_test( ' '||user||' ', 'proc', null, null ).form_name()).to_equal(user||'.proc'); - end; - - procedure passing_proc is - begin - null; - end; - - procedure output_proc is - begin - dbms_output.put_line('Some output from procedure'); - end; - - procedure throwing_proc is - begin - raise program_error; - end; - -end; -/ diff --git a/test/ut3_tester/core/test_ut_executable.pks b/test/ut3_tester/core/test_ut_executable.pks deleted file mode 100644 index 882f0f209..000000000 --- a/test/ut3_tester/core/test_ut_executable.pks +++ /dev/null @@ -1,33 +0,0 @@ -create or replace package test_ut_executable is - - --%suite(ut_executable) - --%suitepath(utplsql.ut3_tester.core) - - --%context(do_execute) - - --%test(Executes procedure in current schema when user was not provided) - procedure exec_schema_package_proc; - - --%test(Executes procedure and saves dbms_output) - procedure exec_package_proc_output; - - --%test(Executes a procedure raising exception, saves dbms_output and exception stack trace) - procedure exec_failing_proc; - - --%endcontext - - --%context(form_name) - - --%test(Builds a name for the executable test) - procedure form_name; - - --%endcontext - - procedure passing_proc; - - procedure output_proc; - - procedure throwing_proc; - -end; -/ diff --git a/test/ut3_tester/core/test_ut_suite.pkb b/test/ut3_tester/core/test_ut_suite.pkb deleted file mode 100644 index 7cb9121f6..000000000 --- a/test/ut3_tester/core/test_ut_suite.pkb +++ /dev/null @@ -1,164 +0,0 @@ -create or replace package body test_ut_suite is - - procedure cleanup_package_state is - begin - 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_develop.ut_suite; - begin - --Arrange - l_suite := ut3_develop.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.disabled_flag := ut3_develop.ut_utils.boolean_to_int(true); - l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - l_suite.after_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'add_1_to_g_number', ut3_develop.ut_utils.gc_before_all)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.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_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_be_null; - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(0); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(0); - end; - - procedure beforeall_errors is - l_suite ut3_develop.ut_suite; - begin - --Arrange - l_suite := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3_develop.ut_utils.gc_before_all)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_be_null; - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(0); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(1); - end; - - procedure aftereall_errors is - l_suite ut3_develop.ut_suite; - begin - --Arrange - l_suite := ut3_develop.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.after_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_EXAMPLE_TESTS', 'failing_procedure', ut3_develop.ut_utils.gc_after_all)); - - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.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_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(2); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(0); - end; - - procedure package_without_body is - l_suite ut3_develop.ut_suite; - begin - l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_WITHOUT_BODY', a_line_no=> 1); - l_suite.path := 'UT_WITHOUT_BODY'; - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_name => 'ut_without_body',a_name => 'test1', a_line_no=> 1); - --Act - l_suite.do_execute(); - --Assert - ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure package_with_invalid_body is - l_suite ut3_develop.ut_suite; - begin - l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_WITH_INVALID_BODY', a_line_no=> 1); - l_suite.path := 'UT_WITH_INVALID_BODY'; - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_name => 'ut_with_invalid_body',a_name => 'test1', a_line_no=> 1); - --Act - l_suite.do_execute(); - --Assert - ut.expect(l_suite.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure rollback_auto is - l_suite ut3_develop.ut_suite; - begin - --Arrange - execute immediate 'delete from ut3_tester_helper.ut$test_table'; - l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); - l_suite.path := 'ut3_tester_helper.ut_transaction_control'; - l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable(USER, 'UT_TRANSACTION_CONTROL', 'setup', ut3_develop.ut_utils.gc_before_all)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.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_develop.ut_utils.gc_rollback_auto); - - --Act - l_suite.do_execute(); - - --Assert - 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 - ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3_develop.ut_utils.gc_rollback_auto, equal(0) ); - end; - - procedure rollback_manual is - begin - ut3_tester_helper.run_helper.test_rollback_type('test', ut3_develop.ut_utils.gc_rollback_manual, be_greater_than(0) ); - end; - - procedure rollback_manual_on_failure is - begin - ut3_tester_helper.run_helper.test_rollback_type('test_failure', ut3_develop.ut_utils.gc_rollback_manual, be_greater_than(0) ); - end; - - procedure trim_transaction_invalidators is - l_suite ut3_develop.ut_suite; - begin - --arrange - l_suite := ut3_develop.ut_suite(a_object_owner => USER, a_object_name => 'UT_EXAMPLE_TESTS', a_line_no=> 1); - for i in 1 .. 100 loop - l_suite.add_transaction_invalidator('schema_name.package_name.procedure_name'||i); - end loop; - --Act - l_suite.rollback_to_savepoint('dummy_savepoint'); - --Assert - ut.expect(l_suite.warnings.count).to_equal(1); - end; - -end; -/ \ No newline at end of file diff --git a/test/ut3_tester/core/test_ut_suite.pks b/test/ut3_tester/core/test_ut_suite.pks deleted file mode 100644 index 385d00fc7..000000000 --- a/test/ut3_tester/core/test_ut_suite.pks +++ /dev/null @@ -1,51 +0,0 @@ -create or replace package test_ut_suite is - - --%suite(ut_suite) - --%suitepath(utplsql.ut3_tester.core) - - --%beforeeach - procedure cleanup_package_state; - - --%test(Disabled flag skips tests execution in suite) - procedure disabled_suite; - - --%test(Marks each test as errored if beforeall raises exception) - procedure beforeall_errors; - - --%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; - - --%test(Performs automatic rollback after a suite even if test fails) - procedure rollback_auto_on_failure; - - --%test(rollback(manual) - disables automatic rollback after a suite) - procedure rollback_manual; - - --%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; - -end; -/ diff --git a/test/ut3_tester/core/test_ut_suite_tag_filter.pkb b/test/ut3_tester/core/test_ut_suite_tag_filter.pkb deleted file mode 100644 index edfb27cfc..000000000 --- a/test/ut3_tester/core/test_ut_suite_tag_filter.pkb +++ /dev/null @@ -1,82 +0,0 @@ -create or replace package body test_ut_suite_tag_filter is - - procedure test_conversion_to_rpn is - l_postfix ut3_develop.ut_varchar2_list; - l_postfix_string varchar2(4000); - l_input_token ut3_develop.ut_varchar2_list; - begin - l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('A'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); - ut.expect(l_postfix_string).to_equal('A'); - - l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('A|B'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); - ut.expect(l_postfix_string).to_equal('AB|'); - - l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('(a|b)|c&d'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); - ut.expect(l_postfix_string).to_equal('ab|cd&|'); - - l_input_token := ut3_develop.ut_suite_tag_filter.tokenize_tags_string('!a|b'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,''); - ut.expect(l_postfix_string).to_equal('a!b|'); - end; - - procedure test_conversion_opr_by_opr is - l_postfix ut3_develop.ut_varchar2_list; - l_input_token ut3_develop.ut_varchar2_list; - begin - l_input_token := ut3_develop.ut_varchar2_list('A','B'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - ut.fail('Expected exception but nothing was raised'); - end; - - procedure test_conversion_oprd_by_opd is - l_postfix ut3_develop.ut_varchar2_list; - l_input_token ut3_develop.ut_varchar2_list; - begin - l_input_token := ut3_develop.ut_varchar2_list('|','|'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - ut.fail('Expected exception but nothing was raised'); - end; - - procedure test_conversion_lb_by_oper is - l_postfix ut3_develop.ut_varchar2_list; - l_input_token ut3_develop.ut_varchar2_list; - begin - l_input_token := ut3_develop.ut_varchar2_list('(','A','|','B',')','('); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - ut.fail('Expected exception but nothing was raised'); - end; - - procedure test_conversion_rb_by_oprd is - l_postfix ut3_develop.ut_varchar2_list; - l_input_token ut3_develop.ut_varchar2_list; - begin - l_input_token := ut3_develop.ut_varchar2_list(')','A'); - l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); - ut.fail('Expected exception but nothing was raised'); - end; - - procedure conv_from_tag_to_sql_filter is - l_sql_filter varchar2(4000); - begin - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1'); - ut.expect(l_sql_filter).to_equal(q'['test1' member of tags]'); - - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1|test2'); - ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags or 'test2' member of tags)]'); - - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1|!test2'); - ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags or not('test2' member of tags))]'); - - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1&!test2'); - ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags and not('test2' member of tags))]'); - end; - -end test_ut_suite_tag_filter; -/ diff --git a/test/ut3_tester/core/test_ut_suite_tag_filter.pks b/test/ut3_tester/core/test_ut_suite_tag_filter.pks deleted file mode 100644 index 0f84b751b..000000000 --- a/test/ut3_tester/core/test_ut_suite_tag_filter.pks +++ /dev/null @@ -1,33 +0,0 @@ -create or replace package test_ut_suite_tag_filter is - - --%suite(ut_suite_tag_filter) - --%suitepath(utplsql.ut3_tester.core) - - --%context( Conversion to Reverse Polish Notation) - - --%test( Test conversion of expression into Reverse Polish Notation) - procedure test_conversion_to_rpn; - - --%test( Operator is followed by operator) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_opr_by_opr; - - --%test( Operand is followed by operand) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_oprd_by_opd; - - --%test( Left Bracket is followed by operator) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_lb_by_oper; - - --%test( Right Bracket is followed by operand) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_rb_by_oprd; - - --%endcontext - - --%test( Test conversion of expression from tag into custom where filter for SQL) - procedure conv_from_tag_to_sql_filter; - -end test_ut_suite_tag_filter; -/ diff --git a/test/ut3_tester/core/test_ut_test.pkb b/test/ut3_tester/core/test_ut_test.pkb deleted file mode 100644 index f6f59df08..000000000 --- a/test/ut3_tester/core/test_ut_test.pkb +++ /dev/null @@ -1,727 +0,0 @@ -create or replace package body test_ut_test is - - procedure cleanup_package_state is - begin - ut3_tester_helper.ut_example_tests.g_number := null; - end; - - procedure disabled_test is - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --Arrange - l_suite := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.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_develop.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_develop.ut_utils.boolean_to_int(true); - --Act - l_suite.do_execute(); - --Assert - ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(1); - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(1); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(0); - end; - - procedure aftertest_errors is - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --Arrange - l_suite := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - - l_test := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_before_test)); - l_test.after_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.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_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_equal(3); - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(1); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(1); - end; - - procedure aftereach_errors is - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --Arrange - l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); - l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - l_test := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_before_each)); - l_test.after_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.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_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_equal(3); - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(1); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(1); - end; - - procedure beforetest_errors is - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --Arrange - l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); - l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - l_test := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.ut_utils.gc_before_test)); - l_test.after_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.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_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_equal(2); - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(1); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(1); - end; - - procedure beforeeach_errors is - l_suite ut3_develop.ut_suite; - l_test ut3_develop.ut_test; - begin - --Arrange - l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'ut_example_tests', a_line_no=> 1); - l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_all)); - l_test := ut3_develop.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_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'failing_procedure', ut3_develop.ut_utils.gc_before_each)); - l_test.after_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.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_develop.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(ut3_tester_helper.ut_example_tests.g_number).to_equal(2); - ut.expect(l_suite.result).to_equal(ut3_develop.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); - ut.expect(l_suite.results_count.success_count).to_equal(1); - ut.expect(l_suite.results_count.failure_count).to_equal(0); - ut.expect(l_suite.results_count.errored_count).to_equal(1); - end; - - procedure after_each_executed is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.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_develop.ut_executables( - ut3_develop.ut_executable( - 'ut3_tester_helper', - 'ut_example_tests', - 'add_1_to_g_number', - ut3_develop.ut_utils.gc_after_each - ) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); - 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_develop.ut_test := ut3_develop.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_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid setup name', ut3_develop.ut_utils.gc_after_each) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - 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_develop.ut_test := ut3_develop.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_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_after_each) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); - end; - - procedure create_app_info_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut_output_tests - as - --%suite - - gv_before_all_client_info varchar2(200); - gv_before_each_client_info varchar2(200); - gv_before_test_client_info varchar2(200); - gv_after_test_client_info varchar2(200); - gv_after_each_client_info varchar2(200); - gv_after_all_client_info varchar2(200); - - --%test - --%beforetest(before_test) - --%aftertest(after_test) - procedure the_test; - - --%beforeall - procedure beforeall; - - --%beforeeach - procedure beforeeach; - - procedure before_test; - procedure after_test; - - --%aftereach - procedure aftereach; - - --%afterall - procedure afterall; - - end;]'; - execute immediate q'[create or replace package body ut_output_tests - as - - procedure the_test - as - l_module_name varchar2(4000); - l_action_name varchar2(4000); - l_client_info varchar2(4000); - begin - --Generate empty output - dbms_output.put_line(''); - ut.expect(1,'Test 1 Should Pass').to_equal(1); - dbms_application_info.read_module(module_name => l_module_name, action_name => l_action_name); - dbms_application_info.read_client_info(l_client_info); - ut.expect(l_module_name).to_equal('utPLSQL'); - ut.expect(l_action_name).to_be_like('ut_output_tests'); - ut.expect(l_client_info).to_be_like('the_test'); - end; - - procedure beforeall is - begin - dbms_application_info.read_client_info(gv_before_all_client_info); - end; - - procedure beforeeach is - begin - dbms_application_info.read_client_info(gv_before_each_client_info); - end; - - procedure before_test is - begin - dbms_application_info.read_client_info(gv_before_test_client_info); - end; - procedure after_test is - begin - dbms_application_info.read_client_info(gv_after_test_client_info); - end; - - procedure aftereach is - begin - dbms_application_info.read_client_info(gv_after_each_client_info); - end; - - procedure afterall is - begin - dbms_application_info.read_client_info(gv_after_all_client_info); - end; - - end;]'; - end; - - procedure drop_app_info_package is - pragma autonomous_transaction; - begin - execute immediate q'[drop package ut_output_tests]'; - end; - - procedure application_info_on_execution is - l_output_data ut3_develop.ut_varchar2_list; - l_output clob; - function get_test_value(a_variable_name varchar2) return varchar2 is - l_result varchar2(4000); - begin - execute immediate 'begin :i := ut_output_tests.'||a_variable_name||'; end;' using out l_result; - return l_result; - end; - begin - --act - select * bulk collect into l_output_data - from table(ut3_develop.ut.run('ut_output_tests')); - l_output := ut3_develop.ut_utils.table_to_clob(l_output_data); - --assert - - ut.expect(get_test_value('gv_before_all_client_info')).to_equal('beforeall'); - ut.expect(get_test_value('gv_before_each_client_info')).to_equal('beforeeach'); - ut.expect(get_test_value('gv_before_test_client_info')).to_equal('before_test'); - ut.expect(get_test_value('gv_after_test_client_info')).to_equal('after_test'); - ut.expect(get_test_value('gv_after_each_client_info')).to_equal('aftereach'); - ut.expect(get_test_value('gv_after_all_client_info')).to_equal('afterall'); - ut.expect(l_output).to_be_like('%0 failed, 0 errored, 0 disabled, 0 warning(s)%'); - end; - - procedure before_each_executed is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.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 - ); - begin - l_test.before_each_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_each)); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); - 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_develop.ut_test := ut3_develop.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.before_each_list := ut3_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid setup name', ut3_develop.ut_utils.gc_before_each) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - 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_develop.ut_test := ut3_develop.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.before_each_list := ut3_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_before_each) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - 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_develop.ut_test := ut3_develop.ut_test( - a_object_owner => 'ut3_tester_helper', - a_object_name => 'ut_example_tests', - a_name => 'ut_commit_test', - a_line_no => null - ); - begin - l_test.rollback_type := ut3_develop.ut_utils.gc_rollback_auto; - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); - end; - - procedure owner_name_invalid is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.ut_test( - a_object_owner => 'invalid owner name', - a_object_name => 'ut_example_tests', - a_name => 'set_g_number_0', - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.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_develop.ut_test := ut3_develop.ut_test( - a_object_name => 'ut_example_tests', - a_name => 'set_g_number_0', - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); - ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); - end; - - procedure create_invalid_package is - pragma autonomous_transaction; - begin - execute immediate 'create or replace package invalid_package is - v_variable non_existing_type; - procedure ut_exampletest; - end;'; - exception when others then - null; - end; - - procedure drop_invalid_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package invalid_package'; - exception when others then - null; - end; - - procedure package_in_invalid_state is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.ut_test( - a_object_name => 'invalid_package', - a_name => 'ut_exampletest', - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure package_name_invalid is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.ut_test( - a_object_name => 'invalid package name', - a_name => 'set_g_number_0', - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure package_name_null is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.ut_test( - a_object_name => null, - a_name => 'set_g_number_0', - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure procedure_name_invalid is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.ut_test( - a_object_owner => 'ut3_tester_helper', - a_object_name => 'ut_example_tests', - a_name => 'invalid procedure name', - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure procedure_name_null is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.ut_test( - a_object_owner => 'ut3_tester_helper', - a_object_name => 'ut_example_tests', - a_name => null, - a_line_no => null - ); - begin - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - end; - - procedure before_test_executed is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.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 - ); - begin - l_test.before_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'set_g_number_0', ut3_develop.ut_utils.gc_before_test)); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); - 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_develop.ut_test := ut3_develop.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.before_test_list := ut3_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid setup name', ut3_develop.ut_utils.gc_before_test) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - 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_develop.ut_test := ut3_develop.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.before_test_list := ut3_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_before_test) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_be_null; - end; - - procedure after_test_executed is - --Arrange - l_test ut3_develop.ut_test := ut3_develop.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_test_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'add_1_to_g_number', ut3_develop.ut_utils.gc_after_test)); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_success); - 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_develop.ut_test := ut3_develop.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_test_list := ut3_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', 'invalid procedure name', ut3_develop.ut_utils.gc_after_test) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - 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_develop.ut_test := ut3_develop.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_test_list := ut3_develop.ut_executables( - ut3_develop.ut_executable('ut3_tester_helper', 'ut_example_tests', null, ut3_develop.ut_utils.gc_after_test) - ); - --Act - l_test.do_execute(); - --Assert - ut.expect(l_test.result).to_equal(ut3_develop.ut_utils.gc_error); - ut.expect(ut3_tester_helper.ut_example_tests.g_number).to_equal(0); - end; - - procedure create_output_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut_output_tests - as - --%suite - - --%beforeeach - procedure beforeeach; - - --%aftereach - procedure aftereach; - - --%test - --%beforetest(beforetest) - --%aftertest(aftertest) - procedure ut_passing_test; - - procedure beforetest; - - procedure aftertest; - - --%beforeall - procedure beforeall; - --%afterall - procedure afterall; - - end;]'; - execute immediate q'[create or replace package body ut_output_tests - as - - procedure beforetest is - begin - dbms_output.put_line(''); - end; - - procedure aftertest is - begin - dbms_output.put_line(''); - end; - - procedure beforeeach is - begin - dbms_output.put_line(''); - end; - - procedure aftereach is - begin - dbms_output.put_line(''); - end; - - procedure ut_passing_test is - begin - dbms_output.put_line(''); - ut.expect(1,'Test 1 Should Pass').to_equal(1); - end; - - procedure beforeall is - begin - dbms_output.put_line(''); - end; - - procedure afterall is - begin - dbms_output.put_line(''); - end; - - end;]'; - exception when others then - null; - end; - - procedure drop_output_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package ut_output_tests'; - exception when others then - null; - end; - - procedure test_output_gathering is - l_output_data ut3_develop.ut_varchar2_list; - l_output clob; - begin - select * bulk collect into l_output_data - from table(ut3_develop.ut.run('ut_output_tests')); - l_output := ut3_develop.ut_utils.table_to_clob(l_output_data); - ut.expect(l_output).to_be_like( - '%%%%%%%%1 tests, 0 failed, 0 errored%' - ); - end; - - -end; -/ diff --git a/test/ut3_tester/core/test_ut_test.pks b/test/ut3_tester/core/test_ut_test.pks deleted file mode 100644 index caf75eb6c..000000000 --- a/test/ut3_tester/core/test_ut_test.pks +++ /dev/null @@ -1,101 +0,0 @@ -create or replace package test_ut_test is - - --%suite(ut_test) - --%suitepath(utplsql.ut3_tester.core) - - --%beforeeach - procedure cleanup_package_state; - - --%test(Disabled flag for a test skips the tests execution in suite) - procedure disabled_test; - - --%test(Marks test as errored if aftertest raises exception) - procedure aftertest_errors; - - --%test(Marks each test as errored if aftereach raises exception) - procedure aftereach_errors; - - --%test(Marks test as errored if beforetest raises exception) - procedure beforetest_errors; - - --%test(Marks each test as errored if beforeeach raises exception) - procedure beforeeach_errors; - - - --%context(executables in test) - - --%test(Executes aftereach procedure) - procedure after_each_executed; - - --%test(Fails test when aftereach procedure name invalid) - procedure after_each_proc_name_invalid; - --%test(Fails test when aftereach procedure name null) - procedure after_each_procedure_name_null; - - procedure create_app_info_package; - procedure drop_app_info_package; - --%beforetest(create_app_info_package) - --%aftertest(drop_app_info_package) - --%test(Sets application_info on execution of individual items) - procedure application_info_on_execution; - - --%test(Executes beforeeach procedure) - procedure before_each_executed; - --%test(Fails test when beforeeach procedure name invalid) - procedure before_each_proc_name_invalid; - --%test(Fails test when beforeeach procedure name null) - procedure before_each_proc_name_null; - --%test(Does not raise exception when rollback to savepoint fails) - 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; - procedure drop_invalid_package; - --%beforetest(create_app_info_package) - --%aftertest(drop_app_info_package) - --%test(Fails the test that references package with compilation errors) - procedure package_in_invalid_state; - --%test(Fails the test when package name is invalid) - procedure package_name_invalid; - --%test(Fails the test when package name is null) - procedure package_name_null; - --%test(Fails the test when procedure name invalid) - procedure procedure_name_invalid; - --%test(Fails the test when procedure name null) - procedure procedure_name_null; - - - --%test(Executes befroretest procedure) - procedure before_test_executed; - --%test(Fails test when befroretest procedure name invalid) - procedure before_test_proc_name_invalid; - --%test(Fails test when befroretest procedure name is null) - procedure before_test_proc_name_null; - --%test(Executes aftertest procedure) - procedure after_test_executed; - --%test(Fails test when aftertest procedure name invalid) - procedure after_test_proce_name_invalid; - --%test(Fails test when aftertest procedure name is null) - procedure after_test_proc_name_null; - - procedure create_output_package; - procedure drop_output_package; - --%beforetest(create_output_package) - --%aftertest(drop_output_package) - --%test(Test output gathering) - procedure test_output_gathering; - - --%endcontext - -end; -/ diff --git a/test/ut3_tester/core/test_ut_utils.pkb b/test/ut3_tester/core/test_ut_utils.pkb deleted file mode 100644 index 433987c01..000000000 --- a/test/ut3_tester/core/test_ut_utils.pkb +++ /dev/null @@ -1,511 +0,0 @@ -create or replace package body test_ut_utils is - - gv_nls_value nls_session_parameters.value%type; - - gc_delimiter varchar2(1) := get_numeric_delimiter(); - - function get_numeric_delimiter return varchar2 is - l_result varchar2(1); - begin - select substr(value, 1, 1) into l_result from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS'; - return l_result; - end; - - function clob_to_blob(p_clob clob) return blob is - l_blob blob; - l_dest_offset integer := 1; - l_source_offset integer := 1; - l_lang_context integer := dbms_lob.default_lang_ctx; - l_warning integer := dbms_lob.warn_inconvertible_char; - begin - dbms_lob.createtemporary(l_blob, true); - dbms_lob.converttoblob( - dest_lob =>l_blob, - src_clob =>p_clob, - amount =>DBMS_LOB.LOBMAXSIZE, - dest_offset =>l_dest_offset, - src_offset =>l_source_offset, - blob_csid =>DBMS_LOB.DEFAULT_CSID, - lang_context=>l_lang_context, - warning =>l_warning - ); - return l_blob; - end; - - - procedure common_clob_to_table_exec(p_clob varchar2, p_delimiter varchar2, p_expected_list ut3_develop.ut_varchar2_list, p_limit number) is - begin - execute immediate 'declare - l_clob clob := '''||p_clob||'''; - l_delimiter varchar2(1) := '''||p_delimiter||'''; - l_expected ut3_develop.ut_varchar2_list := :p_expected_list; - l_result ut3_develop.ut_varchar2_list; - l_limit integer := '||p_limit||q'[; - l_result_str varchar2(32767); - l_errors integer := 0; - function compare_element(a_element_id integer, a_expected ut3_develop.ut_varchar2_list, a_actual ut3_develop.ut_varchar2_list) return integer is - begin - if a_expected.exists(a_element_id) and a_actual.exists(a_element_id) then - if a_expected(a_element_id) = a_actual(a_element_id) or a_expected(a_element_id) is null and a_actual(a_element_id) is null then - return 0; - else - dbms_output.put('a_expected('||a_element_id||')='||a_expected(a_element_id)||' | a_actual('||a_element_id||')='||a_actual(a_element_id)); - end if; - end if; - if not a_expected.exists(a_element_id) then - dbms_output.put('a_expected('||a_element_id||') does not exist '); - end if; - if not a_actual.exists(a_element_id) then - dbms_output.put('a_actual('||a_element_id||') does not exist '); - end if; - dbms_output.put_line(null); - return 1; - end; -begin ---Act - select column_value bulk collect into l_result from table( ut3_develop.ut_utils.clob_to_table(l_clob, l_limit, l_delimiter) ); - for i in 1 .. l_result.count loop - l_result_str := l_result_str||''''||l_result(i)||''''||l_delimiter; - end loop; - l_result_str := rtrim(l_result_str,l_delimiter); ---Assert - for i in 1 .. greatest(l_expected.count, l_result.count) loop - l_errors := l_errors + compare_element(i, l_expected, l_result); - end loop; - ut.expect(l_errors).to_equal(0); -end;]' using p_expected_list; - end; - - procedure test_clob_to_table is - begin - common_clob_to_table_exec('a,b,c,d', ',', ut3_develop.ut_varchar2_list('a','b','c','d'), 1000); - common_clob_to_table_exec( '', ',', ut3_develop.ut_varchar2_list(), 1000); - common_clob_to_table_exec( '1,b,c,d', '', ut3_develop.ut_varchar2_list('1,b,','c,d'), 4); - common_clob_to_table_exec( 'abcdefg,hijk,axa,a', ',', ut3_develop.ut_varchar2_list('abc','def','g','hij','k','axa','a'), 3); - common_clob_to_table_exec( ',a,,c,d,', ',', ut3_develop.ut_varchar2_list('','a','','c','d',''), 1000); - end; - - procedure test_test_result_to_char is - begin - ut.expect(ut3_develop.ut_utils.test_result_to_char(-1),'test unknown').to_equal('Unknown(-1)'); - ut.expect(ut3_develop.ut_utils.test_result_to_char(null),'test unknown').to_equal('Unknown(NULL)'); - ut.expect(ut3_develop.ut_utils.test_result_to_char(ut3_develop.ut_utils.gc_success),'test unknown').to_equal(ut3_develop.ut_utils.gc_success_char); - end; - - procedure to_string_emptyblob is - begin - ut.expect(ut3_develop.ut_data_value_blob(empty_blob()).to_string()).to_equal('EMPTY'); - end; - - procedure to_string_emptyclob is - begin - ut.expect(ut3_develop.ut_data_value_clob(empty_clob()).to_string()).to_equal('EMPTY'); - end; - - procedure to_string_nullblob is - begin - ut.expect(ut3_develop.ut_data_value_blob(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nullclob is - begin - ut.expect(ut3_develop.ut_data_value_clob(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nulldate is - begin - ut.expect(ut3_develop.ut_data_value_date(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nullnumber is - begin - ut.expect(ut3_develop.ut_data_value_number(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nulltimestamp is - begin - ut.expect(ut3_develop.ut_data_value_timestamp(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nulltimestamp_ltz is - begin - ut.expect(ut3_develop.ut_data_value_timestamp_ltz(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nulltimestamp_tz is - begin - ut.expect(ut3_develop.ut_data_value_timestamp_tz(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_nullvarchar2 is - begin - ut.expect(ut3_develop.ut_data_value_varchar2(null).to_string()).to_equal('NULL'); - end; - - procedure to_string_blob is - l_text varchar2(32767) := 'A test char'; - l_value blob := utl_raw.cast_to_raw(l_text); - l_expected varchar2(32767) := ''''||rawtohex(l_value)||''''; - begin - ut.expect(ut3_develop.ut_data_value_blob(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_clob is - l_value clob := 'A test char'; - l_expected varchar2(32767) := ''''||l_value||''''; - begin - ut.expect(ut3_develop.ut_data_value_clob(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_date is - l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss'); - l_expected varchar2(100) := ' 2016-12-31T23:59:59'; - begin - ut.expect(ut3_develop.ut_data_value_date(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_timestamp is - l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_expected varchar2(100) := ' 2016-12-31T23:59:59'||gc_delimiter||'123456789'; - begin - ut.expect(ut3_develop.ut_data_value_timestamp(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_timestamp_ltz is - l_value timestamp(9) with local time zone := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff'); - l_expected varchar2(100) := ' 2016-12-31T23:59:59'||gc_delimiter||'123456789'; - begin - ut.expect(ut3_develop.ut_data_value_timestamp_ltz(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_timestamp_tz is - l_value timestamp(9) with time zone := to_timestamp_tz('2016-12-31 23:59:59.123456789 -8:00', 'yyyy-mm-dd hh24:mi:ss.ff tzh:tzm'); - l_expected varchar2(100) := ' 2016-12-31T23:59:59'||gc_delimiter||'123456789 -08:00'; - begin - ut.expect(ut3_develop.ut_data_value_timestamp_tz(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_varchar2 is - l_value varchar2(20) := 'A test char'; - l_expected varchar2(100) := ''''||l_value||''''; - begin - ut.expect(ut3_develop.ut_data_value_varchar2(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_verybigblob is - l_text clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); - l_value blob; - begin - l_value := clob_to_blob(l_text); - ut.expect(length(ut3_develop.ut_data_value_blob(l_value).to_string())).to_equal(ut3_develop.ut_utils.gc_max_output_string_length); - ut.expect(ut3_develop.ut_data_value_blob(l_value).to_string()).to_be_like('%'||ut3_develop.ut_utils.gc_more_data_string); - end; - - procedure to_string_verybigclob is - l_value clob := lpad('A test char',32767,'1')||lpad('1',32767,'1'); - begin - ut.expect(length(ut3_develop.ut_data_value_clob(l_value).to_string())).to_equal(ut3_develop.ut_utils.gc_max_output_string_length); - ut.expect(ut3_develop.ut_data_value_clob(l_value).to_string()).to_be_like('%'||ut3_develop.ut_utils.gc_more_data_string); - end; - - procedure to_string_verybignumber is - l_value number := 1234567890123456789012345678901234567890; - l_expected varchar2(100) := '1234567890123456789012345678901234567890'; - begin - ut.expect(ut3_develop.ut_data_value_number(l_value).to_string()).to_equal(l_expected); - end; - - procedure to_string_verybigvarchar2 is - l_value varchar2(32767) := lpad('A test char',32767,'1'); - l_result varchar2(32767); - begin - ut.expect(length(ut3_develop.ut_data_value_varchar2(l_value).to_string())).to_equal(ut3_develop.ut_utils.gc_max_output_string_length); - ut.expect(ut3_develop.ut_data_value_varchar2(l_value).to_string()).to_be_like('%'||ut3_develop.ut_utils.gc_more_data_string); - end; - - procedure to_string_verysmallnumber is - l_value number := 0.123456789012345678901234567890123456789; - l_expected varchar2(100) := gc_delimiter||'123456789012345678901234567890123456789'; - begin - ut.expect(ut3_develop.ut_data_value_number(l_value).to_string()).to_equal(l_expected); - end; - - procedure test_table_to_clob is - procedure exec_table_to_clob(a_list ut3_develop.ut_varchar2_list, a_delimiter varchar2, a_expected clob) is - l_result clob; - begin - l_result := ut3_develop.ut_utils.table_to_clob(a_list, a_delimiter); - - ut.expect(l_result).to_equal(a_expected, a_nulls_are_equal => true); - end; - begin - exec_table_to_clob(null, ',', ''); - exec_table_to_clob(ut3_develop.ut_varchar2_list(), ',', ''); - exec_table_to_clob(ut3_develop.ut_varchar2_list('a', 'b', 'c', 'd'), ',', 'a,b,c,d'); - exec_table_to_clob(ut3_develop.ut_varchar2_list('1,b,', 'c,d'), ',', '1,b,,c,d'); - exec_table_to_clob(ut3_develop.ut_varchar2_list('', 'a', '', 'c', 'd', ''), ',', ',a,,c,d,'); - end; - - procedure test_append_with_multibyte is - l_lines sys.dbms_preprocessor.source_lines_t; - l_result clob; - begin - l_lines := sys.dbms_preprocessor.get_post_processed_source( - object_type => 'PACKAGE', - schema_name => sys_context('USERENV', 'CURRENT_USER'), - object_name => 'TST_CHARS' - ); - - for i in 1..l_lines.count loop - l_result := null; - ut3_develop.ut_utils.append_to_clob(l_result, l_lines(i)); - - --Assert - ut.expect(dbms_lob.getlength(l_result),'Error for index '||i).to_equal(dbms_lob.getlength(l_lines(i))); - end loop; - end; - - procedure setup_append_with_multibyte is - pragma autonomous_transaction; - begin - select value into gv_nls_value from nls_session_parameters where parameter = 'NLS_DATE_LANGUAGE'; - execute immediate 'alter session set nls_date_language=ENGLISH'; - execute immediate 'create or replace package tst_chars as --- 2) Status of the process = 😑PE😑 with no linked data -end;'; - execute immediate 'alter session set nls_date_language=RUSSIAN'; - - end; - procedure clean_append_with_multibyte is - pragma autonomous_transaction; - begin - execute immediate 'alter session set nls_date_language='||gv_nls_value; - execute immediate 'drop package tst_chars'; - end; - - procedure test_clob_to_table_multibyte is - l_varchar2_byte_limit integer := 32767; - l_workaround_byte_limit integer := 8191; - l_singlebyte_string_max_size varchar2(32767 char) := rpad('x',l_varchar2_byte_limit,'x'); - l_twobyte_character char(1 char) := '�?'; - l_clob_multibyte clob := l_twobyte_character||l_singlebyte_string_max_size; --here we have 32769(2+32767) bytes and 32768 chars - l_expected ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); - l_result ut3_develop.ut_varchar2_list; - begin - l_expected.extend(1); - l_expected(1) := l_twobyte_character||substr(l_singlebyte_string_max_size,1,l_workaround_byte_limit-1); - --Act - l_result := ut3_develop.ut_utils.clob_to_table(l_clob_multibyte); - --Assert - ut.expect(l_result(1)).to_equal(l_expected(1)); - end; - - procedure test_to_version_split is - l_version ut3_develop.ut_utils.t_version; - begin - l_version := ut3_develop.ut_utils.to_version('v034.0.0456.0333'); - ut.expect(l_version.major).to_equal(34); - ut.expect(l_version.minor).to_equal(0); - ut.expect(l_version.bugfix).to_equal(456); - ut.expect(l_version.build).to_equal(333); - end; - - procedure test_trim_list_elements - is - l_list_to_be_equal ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('hello', 'world', 'okay'); - l_list ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(' hello ', chr(9)||'world ', 'okay'); - begin - --Act - l_list := ut3_develop.ut_utils.trim_list_elements(l_list); - --Assert - ut.expect(anydata.convertcollection(l_list)).to_equal(anydata.convertcollection(l_list_to_be_equal)); - end; - - procedure trim_list_elemts_null_collect - is - l_list_to_be_null ut3_develop.ut_varchar2_list; - begin - --Act - l_list_to_be_null := ut3_develop.ut_utils.trim_list_elements(l_list_to_be_null); - --Assert - ut.expect(anydata.convertcollection(l_list_to_be_null)).to_be_null; - end; - - procedure trim_list_elemts_empty_collect - is - l_list_to_be_empty ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); - begin - --Act - l_list_to_be_empty := ut3_develop.ut_utils.trim_list_elements(l_list_to_be_empty); - --Assert - ut.expect(anydata.convertcollection(l_list_to_be_empty)).to_be_empty; - end; - - procedure test_filter_list - is - l_list_to_be_equal ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('-12458', '8956', '789'); - l_list ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('-12458', '8956', 'okay', null,'458963', '789'); - begin - --Act - l_list := ut3_develop.ut_utils.filter_list(l_list, '^-?[[:digit:]]{1,5}$'); - --Assert - ut.expect(anydata.convertcollection(l_list)).to_equal(anydata.convertcollection(l_list_to_be_equal)); - end; - - procedure filter_list_null_collection - is - l_list_to_be_null ut3_develop.ut_varchar2_list; - begin - --Act - l_list_to_be_null := ut3_develop.ut_utils.filter_list(l_list_to_be_null, '^-?[[:digit:]]{1,5}$'); - --Assert - ut.expect(anydata.convertcollection(l_list_to_be_null)).to_be_null; - end; - - procedure filter_list_empty_collection - is - l_list_to_be_empty ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); - begin - --Act - l_list_to_be_empty := ut3_develop.ut_utils.filter_list(l_list_to_be_empty, '^-?[[:digit:]]{1,5}$'); - --Assert - ut.expect(anydata.convertcollection(l_list_to_be_empty)).to_be_empty; - end; - - procedure replace_multiline_comments - is - l_source clob; - l_actual clob; - l_expected clob; - begin - --Arrange - l_source := q'[ -create or replace package dummy as - - -- single line comment with disabled /* multi-line comment */ - gv_text0 varchar2(200) := q'{/* multi-line comment - in escaped q'multi-line - string*/}'; - gv_text1 varchar2(200) := '/* multi-line comment in a string*/'; - gv_text2 varchar2(200) := '/* multi-line comment - in a multi-line - string*/'; - -- ignored start of multi-line comment with multi-byte text � /* - -- ignored end of multi-line comment with multi-byte text � */ - /* multi-line comment - with - multi-byte characters ��� - in it */ - gv_text3 varchar2(200) := 'some text'; /* multiline comment*/ --followed by single-line comment - /* multi-line comment in one line*/ - gv_text4 varchar2(200) := q'{/* multi-line comment - in escaped q'multi-line - string*/}'; -end; -]'; - l_expected := q'[ -create or replace package dummy as - - -- single line comment with disabled /* multi-line comment */ - gv_text0 varchar2(200) := q'{/* multi-line comment - in escaped q'multi-line - string*/}'; - gv_text1 varchar2(200) := '/* multi-line comment in a string*/'; - gv_text2 varchar2(200) := '/* multi-line comment - in a multi-line - string*/'; - -- ignored start of multi-line comment with multi-byte text � /* - -- ignored end of multi-line comment with multi-byte text � */ - ]'||q'[ - - - - gv_text3 varchar2(200) := 'some text'; --followed by single-line comment - ]'||q'[ - gv_text4 varchar2(200) := q'{/* multi-line comment - in escaped q'multi-line - string*/}'; -end; -]'; - --Act - l_actual := ut3_develop.ut_utils.replace_multiline_comments(l_source); - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure int_conv_ds_sec is - l_expected varchar2(100) := '1 second'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' second); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ds_minute is - l_expected varchar2(100) := '1 minute'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' minute); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ds_hour is - l_expected varchar2(100) := '1 hour'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' hour); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ds_day is - l_expected varchar2(100) := '1 day'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' day); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ds_date is - l_expected varchar2(100) := '2 days 3 hours 4 minutes 11.333 seconds'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(INTERVAL '2 3:04:11.333' DAY TO SECOND); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ym_year is - l_expected varchar2(100) := '1 year'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' year); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ym_month is - l_expected varchar2(100) := '1 month'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(interval '1' month); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure int_conv_ym_date is - l_expected varchar2(100) := '1 year 2 months'; - l_actual varchar2(200) := ut3_develop.ut_utils.interval_to_text(INTERVAL '1-2' YEAR TO MONTH); - begin - ut.expect(l_expected).to_equal(l_actual); - end; - - procedure convert_collection_multibyte is - l_input ut3_develop.ut_varchar2_list; - l_max_len integer := ut3_develop.ut_utils.gc_max_storage_varchar2_len; - begin - --Arrange - l_input := ut3_develop.ut_varchar2_list( rpad( '❀', l_max_len, 'a' ) ); - ut.expect( lengthb( l_input( 1 ) ) ).to_be_greater_than(l_max_len); - - --Act - ut.expect( lengthb( ut3_develop.ut_utils.convert_collection(l_input)(1) ) ).to_be_less_or_equal(l_max_len); - end; - - procedure lengthb_gives_length_in_bytes is - l_clob clob; - begin - l_clob := '❀'; - ut.expect(ut3_develop.ut_utils.lengthb_clob(l_clob)).to_be_greater_than(1); - end; -end test_ut_utils; -/ diff --git a/test/ut3_tester/core/test_ut_utils.pks b/test/ut3_tester/core/test_ut_utils.pks deleted file mode 100644 index ca2e7b304..000000000 --- a/test/ut3_tester/core/test_ut_utils.pks +++ /dev/null @@ -1,166 +0,0 @@ -create or replace package test_ut_utils is - - --%suite(ut_utils) - --%suitepath(utplsql.ut3_tester.core) - - function get_numeric_delimiter return varchar2; - - --%test(clob_to_table - Converts a clob into ut_varchar2_list using specified delimiter) - procedure test_clob_to_table; - - --%test(test_result_to_char - Converts numeric test result to character representation) - procedure test_test_result_to_char; - - - --%context(to_string) - - --%test(Returns 'EMPTY' string for NULL BLOB) - procedure to_string_emptyblob; - - --%test(Returns 'EMPTY' string for NULL CLOB) - procedure to_string_emptyclob; - - --%test(Returns 'NULL' string for NULL BLOB) - procedure to_string_nullblob; - - --%test(Returns 'NULL' string for NULL CLOB) - procedure to_string_nullclob; - - --%test(Returns 'NULL' string for NULL date) - procedure to_string_nulldate; - - --%test(Returns 'NULL' string for NULL number) - procedure to_string_nullnumber; - - --%test(Returns 'NULL' string for NULL timestamp) - procedure to_string_nulltimestamp; - - --%test(Returns 'NULL' string for NULL timestamp with local timezone) - procedure to_string_nulltimestamp_ltz; - - --%test(Returns 'NULL' string for NULL timestamp with timezone) - procedure to_string_nulltimestamp_tz; - - --%test(Returns 'NULL' string for NULL varchar) - procedure to_string_nullvarchar2; - - --%test(Returns string representation of BLOB) - procedure to_string_blob; - - --%test(Returns string representation of CLOB) - procedure to_string_clob; - - --%test(Returns string representation of date) - procedure to_string_date; - - --%test(Returns string representation of timestamp) - procedure to_string_timestamp; - - --%test(Returns string representation of timestamp with local timezone) - procedure to_string_timestamp_ltz; - - --%test(Returns string representation of timestamp with timezone) - procedure to_string_timestamp_tz; - - --%test(Returns varchar value) - procedure to_string_varchar2; - - --%test(Returns BLOB trimmed to 4000 chars with trailing [...]) - procedure to_string_verybigblob; - ---%test(Returns CLOB trimmed to 4000 chars with trailing [...]) - procedure to_string_verybigclob; - - --%test(Returns string representation of large number) - procedure to_string_verybignumber; - - --%test(Returns varchar2 trimmed to 4000 chars with trailing [...]) - procedure to_string_verybigvarchar2; - - --%test(Returns string representation of small number) - procedure to_string_verysmallnumber; - - --%endcontext - - --%test(table_to_clob - converts ut_varchar2_list into a CLOB value) - procedure test_table_to_clob; - - --%test(append_to_clob - adds multibyte varchar to CLOB) - --%beforetest(setup_append_with_multibyte) - --%aftertest(clean_append_with_multibyte) - procedure test_append_with_multibyte; - procedure setup_append_with_multibyte; - procedure clean_append_with_multibyte; - - --%test(clob_to_table - converts multibyte CLOB to ut_varchar2_list) - --%disabled(We cannot run this test successfully on 12.1 until we change NLSCHARACTERSET from US7ASCII to AL32UTF8) - procedure test_clob_to_table_multibyte; - - --%test(to_version - splits version string into individual version components) - procedure test_to_version_split; - - --%context(trim_list_elements) - - --%test(Trims the elements of a collection) - procedure test_trim_list_elements; - - --%test(Trim list elements with null collection) - procedure trim_list_elemts_null_collect; - - --%test(Trim list elements with empty collection) - procedure trim_list_elemts_empty_collect; - - --%endcontext - - --%context(filter_list) - - --%test(Filters the collection's elements) - procedure test_filter_list; - - --%test(Filter list elements with null collection) - procedure filter_list_null_collection; - - --%test(Filter list elements with empty collection) - procedure filter_list_empty_collection; - - --%endcontext - - --%test(replace_multiline_comments - replaces multi-line comments with empty lines) - procedure replace_multiline_comments; - - --%context(interval_converter_to_strin) - - --%test(returns text representation of interval day to second for 1 second interval) - procedure int_conv_ds_sec; - - --%test(returns text representation of interval day to second for 1 minute interval) - procedure int_conv_ds_minute; - - --%test(returns text representation of interval day to second for 1 hour interval) - procedure int_conv_ds_hour; - - --%test(returns text representation of interval day to second for 1 day interval) - procedure int_conv_ds_day; - - --%test(returns text representation of interval day to second for combination interval) - procedure int_conv_ds_date; - - --%test(returns text representation of interval year to month for 1 year interval) - procedure int_conv_ym_year; - - --%test(returns text representation of interval year to month for 1 month interval) - procedure int_conv_ym_month; - - --%test(returns text representation of interval year to month for custom interval) - procedure int_conv_ym_date; - - --%endcontext - - --%test(convert_collection does not fail on multibyte strings - Issue #1245 ) - procedure convert_collection_multibyte; - - --%test(lengthb returns length of a CLOB in bytes ) - procedure lengthb_gives_length_in_bytes; - -end test_ut_utils; -/ diff --git a/test/ut3_tester_helper/annotation_cache_helper.pkb b/test/ut3_tester_helper/annotation_cache_helper.pkb deleted file mode 100644 index 0715b6af1..000000000 --- a/test/ut3_tester_helper/annotation_cache_helper.pkb +++ /dev/null @@ -1,169 +0,0 @@ -create or replace package body annotation_cache_helper as - - procedure setup_two_suites is - pragma autonomous_transaction; - begin - execute immediate - 'create or replace package ut3_cache_test_owner.granted_test_suite authid definer is - --%suite - - --%test - procedure test1; - --%test - procedure test2; - end;'; - - execute immediate - 'create or replace package body ut3_cache_test_owner.granted_test_suite is - procedure test1 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; - procedure test2 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; - end;'; - execute immediate - 'create or replace package ut3_cache_test_owner.not_granted_test_suite authid definer is - --%suite - - --%test - procedure test1; - --%test - procedure test2; - end;'; - execute immediate - 'create or replace package body ut3_cache_test_owner.not_granted_test_suite is - procedure test1 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; - procedure test2 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; - end;'; - - execute immediate - 'grant execute on ut3_cache_test_owner.granted_test_suite to - ut3_execute_any_proc_user, ut3_select_any_table_user, ut3_select_catalog_user, ut3_no_extra_priv_user'; - end; - - procedure revoke_granted_suite is - pragma autonomous_transaction; - begin - execute immediate - 'revoke execute on ut3_cache_test_owner.granted_test_suite from - ut3_execute_any_proc_user, ut3_select_any_table_user, ut3_select_catalog_user, ut3_no_extra_priv_user'; - exception - when others then - null; - end; - - - procedure add_new_suite is - pragma autonomous_transaction; - begin - execute immediate - 'create or replace package ut3_cache_test_owner.new_suite authid definer is - --%suite - - --%test - procedure test1; - --%test - procedure test2; - end;'; - - execute immediate - 'create or replace package body ut3_cache_test_owner.new_suite is - procedure test1 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; - procedure test2 is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; - end;'; - execute immediate - 'grant execute on ut3_cache_test_owner.new_suite to - ut3_execute_any_proc_user, ut3_select_any_table_user, ut3_select_catalog_user, ut3_no_extra_priv_user'; - end; - - procedure cleanup_two_suites is - pragma autonomous_transaction; - begin - begin - execute immediate 'drop package ut3_cache_test_owner.not_granted_test_suite'; - exception - when others then - null; - end; - begin - execute immediate 'drop package ut3_cache_test_owner.granted_test_suite'; - exception - when others then - null; - end; - end; - - procedure cleanup_new_suite is - pragma autonomous_transaction; - begin - execute immediate 'drop package ut3_cache_test_owner.new_suite'; - exception - when others then - null; - end; - - procedure purge_annotation_cache is - begin - ut3_develop.ut_runner.purge_cache( 'UT3_CACHE_TEST_OWNER' ); - end; - - - procedure disable_ddl_trigger is - pragma autonomous_transaction; - begin - execute immediate 'alter trigger ut3_develop.ut_trigger_annotation_parsing disable'; - execute immediate 'begin ut3_develop.ut_trigger_check.is_alive( ); end;'; - end; - - procedure enable_ddl_trigger is - pragma autonomous_transaction; - begin - execute immediate 'alter trigger ut3_develop.ut_trigger_annotation_parsing enable'; - end; - - procedure create_run_function_for_user(a_user varchar2) is - pragma autonomous_transaction; - begin - execute immediate - 'create or replace function ' || a_user || '.call_ut_run return clob is - l_data ut3_develop.ut_varchar2_list; - l_results clob; - begin - select * bulk collect into l_data from table (ut3_develop.ut.run( ''ut3_cache_test_owner'' )); - return ut3_tester_helper.main_helper.table_to_clob( l_data ); - end; - '; - execute immediate 'grant execute on ' || a_user || '.call_ut_run to public '; - end; - - procedure drop_run_function_for_user(a_user varchar2) is - pragma autonomous_transaction; - begin - execute immediate 'drop function ' || a_user || '.call_ut_run'; - end; - - procedure create_run_function_for_users is - begin - create_run_function_for_user( 'ut3_no_extra_priv_user' ); - create_run_function_for_user( 'ut3_select_catalog_user' ); - create_run_function_for_user( 'ut3_select_any_table_user' ); - create_run_function_for_user( 'ut3_execute_any_proc_user' ); - create_run_function_for_user( 'ut3_cache_test_owner' ); - create_run_function_for_user( 'ut3_develop' ); - end; - - procedure drop_run_function_for_users is - begin - drop_run_function_for_user( 'ut3_no_extra_priv_user' ); - drop_run_function_for_user( 'ut3_select_catalog_user' ); - drop_run_function_for_user( 'ut3_select_any_table_user' ); - drop_run_function_for_user( 'ut3_execute_any_proc_user' ); - drop_run_function_for_user( 'ut3_cache_test_owner' ); - drop_run_function_for_user( 'ut3_develop' ); - end; - - function run_tests_as(a_user varchar2) return clob is - l_results clob; - begin - execute immediate 'begin :x := '||a_user||'.call_ut_run; end;' using out l_results; - return l_results; - end; -end; -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/annotation_cache_helper.pks b/test/ut3_tester_helper/annotation_cache_helper.pks deleted file mode 100644 index d6ab1f8e2..000000000 --- a/test/ut3_tester_helper/annotation_cache_helper.pks +++ /dev/null @@ -1,21 +0,0 @@ -create or replace package annotation_cache_helper as - - procedure setup_two_suites; - procedure add_new_suite; - procedure revoke_granted_suite; - - procedure cleanup_two_suites; - procedure cleanup_new_suite; - - procedure purge_annotation_cache; - - procedure disable_ddl_trigger; - procedure enable_ddl_trigger; - - procedure create_run_function_for_users; - procedure drop_run_function_for_users; - - function run_tests_as(a_user varchar2) return clob; - -end; -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/coverage_helper.pkb b/test/ut3_tester_helper/coverage_helper.pkb deleted file mode 100644 index ef14c586f..000000000 --- a/test/ut3_tester_helper/coverage_helper.pkb +++ /dev/null @@ -1,577 +0,0 @@ -create or replace package body coverage_helper is - - g_job_no integer := 0; - - function block_coverage_available return boolean is - begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - return true; - $else - return false; - $end - end; - - function covered_package_name return varchar2 is - begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - return 'dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long'; - $else - return 'dummy_coverage'; - $end - end; - - function substitute_covered_package( a_text varchar2, a_substitution varchar2 ) return varchar2 is - begin - return replace( replace( a_text, a_substitution, covered_package_name() ), upper(a_substitution), upper(covered_package_name()) ); - end; - - procedure set_develop_mode is - begin - ut3_develop.ut_coverage.set_develop_mode(true); - end; - - - procedure create_dummy_coverage is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut3_develop.]'||covered_package_name||q'[ is - procedure do_stuff(i_input in number); - end;]'; - - execute immediate q'[create or replace package body ut3_develop.]'||covered_package_name||q'[ is - procedure do_stuff(i_input in number) is - begin - if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); - else - dbms_output.put_line('should not get here'); - end if; - end; - end;]'; - - execute immediate q'[create or replace package ut3_develop.some_other_package is - procedure do_stuff(i_input in number); - end;]'; - - execute immediate q'[create or replace package body ut3_develop.some_other_package is - procedure do_stuff(i_input in number) is - begin - if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); - else - dbms_output.put_line('should not get here'); - end if; - end; - end;]'; - - execute immediate q'[create or replace package ut3_develop.test_dummy_coverage is - --%suite(dummy coverage test) - --%suitepath(coverage_testing) - - --%test - procedure test_do_stuff; - - --%test - procedure zero_coverage; - end;]'; - - execute immediate q'[create or replace package body ut3_develop.test_dummy_coverage is - procedure test_do_stuff is - begin - ]'||covered_package_name||q'[.do_stuff(1); - ut.expect(1).to_equal(1); - end; - procedure zero_coverage is - begin - null; - end; - end;]'; - - end; - - procedure drop_dummy_coverage is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3_develop.test_dummy_coverage]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.some_other_package]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.]'||covered_package_name; exception when others then null; end; - end; - - - procedure create_dummy_coverage_1 is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut3_develop.dummy_coverage_1 is - procedure do_stuff; - end;]'; - - execute immediate q'[create or replace package body ut3_develop.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_develop.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_develop.test_dummy_coverage_1 is - procedure test_do_stuff is - begin - dummy_coverage_1.do_stuff; - end; - - end;]'; - end; - - procedure drop_dummy_coverage_1 is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3_develop.dummy_coverage_1]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.test_dummy_coverage_1]'; exception when others then null; end; - end; - - procedure create_cov_with_dbms_stats is - pragma autonomous_transaction; - begin - execute immediate q'[create table ut3_develop.table_to_test_stats as select * from user_objects]'; - - execute immediate q'[create or replace package ut3_develop.stats is - procedure gather; - end;]'; - - execute immediate q'[create or replace package body ut3_develop.stats is - procedure gather is - begin - dbms_Stats.gather_table_stats('UT3_DEVELOP','TABLE_TO_TEST_STATS'); - end; - end;]'; - - execute immediate q'[create or replace package ut3_develop.test_stats is - --%suite(stats gathering coverage test) - --%suitepath(coverage_testing) - - --%test - procedure test_stats_gather; - - end;]'; - - execute immediate q'[create or replace package body ut3_develop.test_stats is - procedure test_stats_gather is - begin - stats.gather; - ut.expect(1).to_equal(1); - end; - end;]'; - - end; - - procedure create_regex_dummy_for_schema(p_schema in varchar2) is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ]'||p_schema||q'[.regex_dummy_cov is - procedure do_stuff(i_input in number); - end;]'; - - execute immediate q'[create or replace package body ]'||p_schema||q'[.regex_dummy_cov is - procedure do_stuff(i_input in number) is - begin - if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); - else - dbms_output.put_line('should not get here'); - end if; - end; - end;]'; - - execute immediate q'[create or replace package ]'||p_schema||q'[.test_regex_dummy_cov is - --%suite(dummy coverage test) - --%suitepath(coverage_testing) - - --%test - procedure test_do_stuff; - - --%test - procedure zero_coverage; - end;]'; - - execute immediate q'[create or replace package body ]'||p_schema||q'[.test_regex_dummy_cov is - procedure test_do_stuff is - begin - regex_dummy_cov.do_stuff(1); - ut.expect(1).to_equal(1); - end; - procedure zero_coverage is - begin - null; - end; - end;]'; - end; - - procedure create_regex_dummy_obj is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut3_develop.regex123_dummy_cov is - procedure do_stuff(i_input in number); - end;]'; - - execute immediate q'[create or replace package body ut3_develop.regex123_dummy_cov is - procedure do_stuff(i_input in number) is - begin - if i_input = 2 then dbms_output.put_line('should not get here'); elsif i_input = 1 then dbms_output.put_line('should get here'); - else - dbms_output.put_line('should not get here'); - end if; - end; - end;]'; - - execute immediate q'[create or replace package ut3_develop.test_regex123_dummy_cov is - --%suite(dummy coverage test) - --%suitepath(coverage_testing) - - --%test - procedure test_do_stuff; - - --%test - procedure zero_coverage; - end;]'; - - execute immediate q'[create or replace package body ut3_develop.test_regex123_dummy_cov is - procedure test_do_stuff is - begin - regex123_dummy_cov.do_stuff(1); - ut.expect(1).to_equal(1); - end; - procedure zero_coverage is - begin - null; - end; - end;]'; - end; - - procedure create_regex_dummy_cov is - begin - create_regex_dummy_for_schema('ut3_develop'); - create_regex_dummy_for_schema('ut3_tester_helper'); - create_regex_dummy_obj; - end; - - procedure drop_regex_dummy_cov is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3_develop.regex_dummy_cov]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.test_regex_dummy_cov]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_tester_helper.regex_dummy_cov]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_tester_helper.test_regex_dummy_cov]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.regex123_dummy_cov]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.test_regex123_dummy_cov]'; exception when others then null; end; - end; - - - procedure drop_cov_with_dbms_stats is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3_develop.test_stats]'; exception when others then null; end; - begin execute immediate q'[drop package ut3_develop.stats]'; exception when others then null; end; - begin execute immediate q'[drop table ut3_develop.table_to_test_stats]'; exception when others then null; end; - end; - - - procedure run_standalone_coverage(a_coverage_run_id raw, a_input integer) is - begin - ut3_develop.ut_runner.coverage_start(a_coverage_run_id); - execute immediate 'begin ut3_develop.'||covered_package_name||'.do_stuff(:a_input); end;' using in a_input; - ut3_develop.ut_runner.coverage_stop(); - end; - - function get_job_status(a_job_name varchar2, a_job_started_after timestamp with time zone) return user_scheduler_job_run_details%rowtype is - l_result user_scheduler_job_run_details%rowtype; - begin - begin - select * into l_result - from user_scheduler_job_run_details - where job_name = upper(a_job_name) - and req_start_date >= a_job_started_after; - exception - when no_data_found then - null; - end; - return l_result; - end; - - procedure run_job_and_wait_for_finish(a_job_action varchar2) is - l_job_run_info user_scheduler_job_run_details%rowtype; - l_job_name varchar2(30); - l_timestamp timestamp with time zone := current_timestamp; - i integer := 0; - pragma autonomous_transaction; - begin - g_job_no := g_job_no + 1; - l_job_name := 'utPLSQL_selftest_job_'||g_job_no; - dbms_lock.sleep(0.15); - dbms_scheduler.create_job( - job_name => l_job_name, - job_type => 'PLSQL_BLOCK', - job_action => a_job_action, - start_date => l_timestamp, - enabled => TRUE, - auto_drop => TRUE, - comments => 'one-time-job' - ); - while (l_job_run_info.status is null or l_job_run_info.status not in ('SUCCEEDED','FAILED')) and i < 6000 loop - l_job_run_info := get_job_status( l_job_name, l_timestamp ); - dbms_lock.sleep(0.1); - i := i + 1; - end loop; - commit; - if nvl(l_job_run_info.status,'null') <> 'SUCCEEDED' then - raise_application_error(-20000, 'Scheduler job '''||l_job_name||''', status='''||l_job_run_info.status||'''. Additional info: '||l_job_run_info.additional_info); - end if; - end; - - procedure run_coverage_job(a_coverage_run_id raw, a_input integer) is - begin - run_job_and_wait_for_finish( - 'begin coverage_helper.run_standalone_coverage('''||a_coverage_run_id||''', '||a_input||'); end;' - ); - end; - - procedure create_test_results_table is - pragma autonomous_transaction; - e_exists exception; - pragma exception_init ( e_exists, -955 ); - begin - execute immediate 'create table test_results (id integer, text varchar2(4000))'; - exception - when e_exists then - null; - end; - - procedure drop_test_results_table is - pragma autonomous_transaction; - e_not_exists exception; - pragma exception_init ( e_not_exists, -942 ); - begin - execute immediate 'drop table test_results'; - exception - when e_not_exists then - null; - end; - - function run_code_as_job( a_plsql_block varchar2 ) return clob is - l_result_clob clob; - pragma autonomous_transaction; - begin - run_job_and_wait_for_finish( a_plsql_block ); - dbms_lock.sleep(0.1); - execute immediate q'[ - declare - l_results ut3_develop.ut_varchar2_list; - begin - select text - bulk collect into l_results - from test_results - order by id; - delete from test_results; - commit; - :clob_results := ut3_tester_helper.main_helper.table_to_clob(l_results); - end; - ]' - using out l_result_clob; - - return l_result_clob; - end; - - procedure copy_coverage_data_to_ut3(a_coverage_run_id raw) is - pragma autonomous_transaction; - l_current_coverage_run_id raw(32) := hextoraw(sys_context('UT3_INFO','COVERAGE_RUN_ID')); - begin - insert into ut3.ut_coverage_runs(coverage_run_id, line_coverage_id, block_coverage_id) - select l_current_coverage_run_id, -line_coverage_id, -block_coverage_id - from ut3_develop.ut_coverage_runs - where coverage_run_id = a_coverage_run_id; - - insert into ut3.plsql_profiler_runs(runid, related_run, run_owner, run_date, run_comment, run_total_time, run_system_info, run_comment1, spare1) - select -runid, related_run, run_owner, run_date, run_comment, run_total_time, run_system_info, run_comment1, spare1 - from ut3_develop.plsql_profiler_runs c - join ut3_develop.ut_coverage_runs r - on r.line_coverage_id = c.runid - where r.coverage_run_id = a_coverage_run_id; - - insert into ut3.plsql_profiler_units(runid, unit_number, unit_type, unit_owner, unit_name, unit_timestamp, total_time, spare1, spare2) - select -runid, unit_number, unit_type, unit_owner, unit_name, unit_timestamp, total_time, spare1, spare2 - from ut3_develop.plsql_profiler_units c - join ut3_develop.ut_coverage_runs r - on r.line_coverage_id = c.runid - where r.coverage_run_id = a_coverage_run_id; - - insert into ut3.plsql_profiler_data(runid, unit_number, line#, total_occur, total_time, min_time, max_time, spare1, spare2, spare3, spare4) - select -runid, unit_number, line#, total_occur, total_time, min_time, max_time, spare1, spare2, spare3, spare4 - from ut3_develop.plsql_profiler_data c - join ut3_develop.ut_coverage_runs r - on r.line_coverage_id = c.runid - where r.coverage_run_id = a_coverage_run_id; - - insert into ut3.dbmspcc_runs(run_id, run_comment, run_owner, run_timestamp) - select -run_id, run_comment, run_owner, run_timestamp - from ut3_develop.dbmspcc_runs c - join ut3_develop.ut_coverage_runs r - on r.block_coverage_id = c.run_id - where r.coverage_run_id = a_coverage_run_id; - - insert into ut3.dbmspcc_units(run_id, object_id, owner, name, type, last_ddl_time) - select -run_id, object_id, owner, name, type, last_ddl_time - from ut3_develop.dbmspcc_units c - join ut3_develop.ut_coverage_runs r - on r.block_coverage_id = c.run_id - where r.coverage_run_id = a_coverage_run_id; - - insert into ut3.dbmspcc_blocks(run_id, object_id, block, line, col, covered, not_feasible) - select -run_id, object_id, block, line, col, covered, not_feasible - from ut3_develop.dbmspcc_blocks c - join ut3_develop.ut_coverage_runs r - on r.block_coverage_id = c.run_id - where r.coverage_run_id = a_coverage_run_id; - - commit; - end; - - function gather_coverage_on_coverage( a_cov_options varchar2) return clob is - pragma autonomous_transaction; - l_plsql_block varchar2(32767); - l_result_clob clob; - l_coverage_id raw(32) := sys_guid(); - begin - l_plsql_block := q'[ - declare - l_coverage_options ut3_develop.ut_coverage_options; - l_coverage_run_id raw(32) := ']'||rawtohex(l_coverage_id)||q'['; - l_result ut3_develop.ut_coverage.t_coverage; - begin - ut3_develop.ut_runner.coverage_start(l_coverage_run_id); - ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => true); - l_coverage_options := {a_cov_options}; - l_result := ut3_develop.ut_coverage.get_coverage_data(l_coverage_options); - ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => false); - ut3_develop.ut_runner.coverage_stop(); - insert into test_results select rownum, owner||'.'||name from ut3_develop.ut_coverage_sources_tmp; - commit; - end;]'; - l_plsql_block := replace(l_plsql_block,'{a_cov_options}',a_cov_options); - run_job_and_wait_for_finish( l_plsql_block ); - execute immediate q'[ - declare - l_results ut3_develop.ut_varchar2_list; - begin - select text - bulk collect into l_results - from test_results - order by id; - delete from test_results; - commit; - :clob_results := ut3_tester_helper.main_helper.table_to_clob(l_results); - end; - ]' - using out l_result_clob; - copy_coverage_data_to_ut3(l_coverage_id); - return l_result_clob; - end; - - function run_tests_as_job( a_run_command varchar2 ) return clob is - l_plsql_block varchar2(32767); - l_result_clob clob; - l_coverage_id raw(32) := sys_guid(); - begin - l_plsql_block := q'[ - declare - x dbms_output.chararr; - i integer := 100000; - begin -/* - execute immediate 'alter session set statistics_level=all'; - dbms_hprof.start_profiling( - location => 'PLSHPROF_DIR' - , filename => 'profiler_utPLSQL_run_]'||rawtohex(l_coverage_id)||q'[.txt' - ); -*/ - ut3_develop.ut_runner.coverage_start(']'||rawtohex(l_coverage_id)||q'['); - ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => true); - --gather coverage on the command executed - begin {a_run_command}; end; - dbms_output.get_lines(x,i); - ut3_develop.ut_coverage.set_develop_mode(a_develop_mode => false); - ut3_develop.ut_runner.coverage_stop(); - --get the actual results of the command gathering the coverage - insert into test_results select rownum as id, x.* from table( {a_run_command} ) x; - commit; -/* - dbms_hprof.stop_profiling; -*/ - end;]'; - l_plsql_block := replace(l_plsql_block,'{a_run_command}',a_run_command); - l_result_clob := run_code_as_job( l_plsql_block ); - copy_coverage_data_to_ut3(l_coverage_id); - return l_result_clob; - end; - - procedure create_dup_object_name is - pragma autonomous_transaction; - begin - execute immediate 'create table ut3_develop.test_table(id integer)'; - execute immediate q'[ - create or replace trigger ut3_develop.duplicate_name - before insert on ut3_develop.test_table - begin - - dbms_output.put_line('A'); - end; - ]'; - execute immediate q'[ - create or replace package ut3_develop.duplicate_name is - procedure some_procedure; - end; - ]'; - execute immediate q'[ - create or replace package body ut3_develop.duplicate_name is - procedure some_procedure is - begin - insert into test_table(id) values(1); - end; - end; - ]'; - execute immediate q'[ - create or replace package ut3_develop.test_duplicate_name is - --%suite - - --%test - procedure run_duplicate_name; - end; - ]'; - execute immediate q'[ - create or replace package body ut3_develop.test_duplicate_name is - procedure run_duplicate_name is - l_actual sys_refcursor; - begin - ut3_develop.duplicate_name.some_procedure; - ut.expect(l_actual).to_have_count(1); - end; - end; - ]'; - end; - - procedure drop_dup_object_name is - pragma autonomous_transaction; - begin - execute immediate 'drop table ut3_develop.test_table'; - execute immediate 'drop package ut3_develop.duplicate_name'; - execute immediate 'drop package ut3_develop.test_duplicate_name'; - end; - -end; -/ diff --git a/test/ut3_tester_helper/coverage_helper.pks b/test/ut3_tester_helper/coverage_helper.pks deleted file mode 100644 index 8d2c1c150..000000000 --- a/test/ut3_tester_helper/coverage_helper.pks +++ /dev/null @@ -1,36 +0,0 @@ -create or replace package coverage_helper is - - function block_coverage_available return boolean; - - function covered_package_name return varchar2; - - function substitute_covered_package( a_text varchar2, a_substitution varchar2 := '{p}' ) return varchar2; - - procedure set_develop_mode; - - procedure create_dummy_coverage; - procedure drop_dummy_coverage; - - procedure create_dummy_coverage_1; - procedure drop_dummy_coverage_1; - - procedure create_regex_dummy_cov; - procedure drop_regex_dummy_cov; - - procedure create_cov_with_dbms_stats; - procedure drop_cov_with_dbms_stats; - - procedure run_standalone_coverage(a_coverage_run_id raw, a_input integer); - procedure run_coverage_job(a_coverage_run_id raw, a_input integer); - - function gather_coverage_on_coverage( a_cov_options varchar2) return clob; - function run_tests_as_job( a_run_command varchar2 ) return clob; - function run_code_as_job( a_plsql_block varchar2 ) return clob; - procedure create_test_results_table; - procedure drop_test_results_table; - - procedure drop_dup_object_name; - procedure create_dup_object_name; - -end; -/ diff --git a/test/ut3_tester_helper/expectations_helper.pkb b/test/ut3_tester_helper/expectations_helper.pkb deleted file mode 100644 index c5c1f379f..000000000 --- a/test/ut3_tester_helper/expectations_helper.pkb +++ /dev/null @@ -1,57 +0,0 @@ -create or replace package body expectations_helper is - - function unary_expectation_block( - a_matcher_name varchar2, - a_data_type varchar2, - a_data_value varchar2 - ) return varchar2 is - l_execute varchar2(32000); - begin - l_execute := ' - declare - l_expected '||a_data_type||' := '||a_data_value||'; - begin - --act - execute the expectation - ut3_develop.ut.expect(l_expected).'||a_matcher_name||'(); - end;'; - return l_execute; - end; - - function unary_expectation_object_block( - a_matcher_name varchar2, - a_object_name varchar2, - a_object_value varchar2, - a_object_type varchar2 - ) return varchar2 is - begin - return ' - declare - l_object '||a_object_name||' := '||a_object_value||'; - begin - ut3_develop.ut.expect(anydata.convert'||a_object_type||'(l_object)).'||a_matcher_name||'(); - end;'; - end; - - function binary_expectation_block( - a_matcher_name varchar2, - a_actual_data_type varchar2, - a_actual_data varchar2, - a_expected_data_type varchar2, - a_expected_data varchar2 - ) return varchar2 - is - l_execute varchar2(32000); - begin - l_execute := ' - declare - l_actual '||a_actual_data_type||' := '||a_actual_data||'; - l_expected '||a_expected_data_type||' := '||a_expected_data||'; - begin - --act - execute the expectation - ut3_develop.ut.expect( l_actual ).'||a_matcher_name||'(l_expected); - end;'; - return l_execute; - end; - -end; -/ diff --git a/test/ut3_tester_helper/expectations_helper.pks b/test/ut3_tester_helper/expectations_helper.pks deleted file mode 100644 index 9c1d54333..000000000 --- a/test/ut3_tester_helper/expectations_helper.pks +++ /dev/null @@ -1,25 +0,0 @@ -create or replace package expectations_helper is - - function unary_expectation_block( - a_matcher_name varchar2, - a_data_type varchar2, - a_data_value varchar2 - ) return varchar2; - - function unary_expectation_object_block( - a_matcher_name varchar2, - a_object_name varchar2, - a_object_value varchar2, - a_object_type varchar2 - ) return varchar2; - - function binary_expectation_block( - a_matcher_name varchar2, - a_actual_data_type varchar2, - a_actual_data varchar2, - a_expected_data_type varchar2, - a_expected_data varchar2 - ) return varchar2; - -end; -/ diff --git a/test/ut3_tester_helper/main_helper.pkb b/test/ut3_tester_helper/main_helper.pkb deleted file mode 100644 index f1dadec66..000000000 --- a/test/ut3_tester_helper/main_helper.pkb +++ /dev/null @@ -1,160 +0,0 @@ -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_develop.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_develop.ut_varchar2_list; - begin - select * bulk collect into l_lines from table(ut3_develop.ut.run(a_path)); - return ut3_develop.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_develop.ut_varchar2_list is - l_expectations_result ut3_develop.ut_expectation_results := ut3_develop.ut_expectation_processor.get_failed_expectations(); - l_result ut3_develop.ut_varchar2_list := ut3_develop.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_develop.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_develop.ut_expectation_processor.get_failed_expectations()); - end; - - function get_failed_expectations_num return number is - l_num_failed number; - l_results ut3_develop.ut_expectation_results := ut3_develop.ut_expectation_processor.get_failed_expectations(); - begin - l_num_failed := l_results.count; - return l_num_failed; - end; - - procedure clear_expectations is - begin - ut3_develop.ut_expectation_processor.clear_expectations(); - end; - - function table_to_clob(a_results in ut3_develop.ut_varchar2_list) return clob is - begin - return ut3_develop.ut_utils.table_to_clob(a_results); - end; - - function get_warnings return ut3_develop.ut_varchar2_rows is - begin - return ut3_develop.ut_expectation_processor.get_warnings(); - end; - - procedure reset_nulls_equal is - begin - ut3_develop.ut_expectation_processor.nulls_Are_equal(ut3_develop.ut_expectation_processor.gc_default_nulls_are_equal); - end; - - procedure nulls_are_equal(a_nulls_equal boolean := true) is - begin - ut3_develop.ut_expectation_processor.nulls_Are_equal(a_nulls_equal); - end; - - procedure cleanup_annotation_cache is - pragma autonomous_transaction; - begin - delete from ut3_develop.ut_annotation_cache_info - where object_owner = 'UT3_TESTER' 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_develop.ut_runner.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; - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_list, a_item varchar2) is - begin - ut3_develop.ut_utils.append_to_list(a_list,a_item); - end; - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item varchar2) is - begin - ut3_develop.ut_utils.append_to_list(a_list,a_item); - end; - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item clob) is - begin - ut3_develop.ut_utils.append_to_list(a_list,a_item); - end; - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_items ut3_develop.ut_varchar2_rows) is - begin - ut3_develop.ut_utils.append_to_list(a_list,a_items); - end; - - procedure set_ut_run_context is - begin - ut3_develop.ut_session_context.set_context('RUN_PATHS',' '); - end; - - procedure clear_ut_run_context is - begin - ut3_develop.ut_session_context.clear_all_context; - end; - -end; -/ diff --git a/test/ut3_tester_helper/main_helper.pks b/test/ut3_tester_helper/main_helper.pks deleted file mode 100644 index 7decad88d..000000000 --- a/test/ut3_tester_helper/main_helper.pks +++ /dev/null @@ -1,51 +0,0 @@ -create or replace package main_helper is - - gc_success number := ut3_develop.ut_utils.gc_success; - gc_failure number := ut3_develop.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_develop.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_develop.ut_varchar2_list) return clob; - - function get_warnings return ut3_develop.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; - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_list, a_item varchar2); - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item varchar2); - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_item clob); - - procedure append_to_list(a_list in out nocopy ut3_develop.ut_varchar2_rows, a_items ut3_develop.ut_varchar2_rows); - - procedure set_ut_run_context; - - procedure clear_ut_run_context; - -end; -/ diff --git a/test/ut3_tester_helper/other_dummy_object.tps b/test/ut3_tester_helper/other_dummy_object.tps deleted file mode 100644 index 7453d5dcf..000000000 --- a/test/ut3_tester_helper/other_dummy_object.tps +++ /dev/null @@ -1,16 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'OTHER_DUMMY_OBJECT'; - if l_exists > 0 then - execute immediate 'drop type other_dummy_object force'; - end if; -end; -/ - -create or replace type other_dummy_object as object ( - id number, - "name" varchar2(30), - "Value" varchar2(30) -) -/ diff --git a/test/ut3_tester_helper/run_helper.pkb b/test/ut3_tester_helper/run_helper.pkb deleted file mode 100644 index 9d65d6667..000000000 --- a/test/ut3_tester_helper/run_helper.pkb +++ /dev/null @@ -1,930 +0,0 @@ -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) - --%suitepath(some.path) - --%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]'; - - execute immediate q'[create or replace package ut3_user.bad_test_package as - --%rollback(manual) - --%test(dummy_test) - procedure some_dummy_test_procedure; - end;]'; - 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) - --%suitepath(some.path) - --%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_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_USER','PACKAGE'); - ut3_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_USER','PROCEDURE'); - ut3_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER_HELPER','PROCEDURE'); - end; - - procedure cleanup_cache is - pragma autonomous_transaction; - begin - delete from ut3_develop.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_develop.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'[create or replace package test_tag_pkg_1 is - --%suite - --%tags(suite1,release_3_1_13,development,complex,end_to_end) - --%suitepath(suite1) - --%rollback(manual) - - --%test(Test1 from test_tag_pkg_1) - --%tags(test1,development,fast) - procedure test1; - - --%test(Test2 from test_tag_pkg_1) - --%tags(test2,production,slow,patch_3_1_13) - procedure test2; - - end test_tag_pkg_1; - ]'; - - execute immediate q'[create or replace package body test_tag_pkg_1 is - procedure test1 is - begin - dbms_output.put_line('test_tag_pkg_1.test1 executed'); - end; - procedure test2 is - begin - dbms_output.put_line('test_tag_pkg_1.test2 executed'); - end; - end test_tag_pkg_1; - ]'; - - execute immediate q'[create or replace package test_tag_pkg_2 is - --%suite - --%tags(suite2,release_3_1_12,development,simple) - --%suitepath(suite1.suite2) - --%rollback(manual) - - --%test(Test3 from test_tag_pkg_2) - --%tags(test3,development,fast) - procedure test3; - - --%test(Test4 from test_tag_pkg_1) - --%tags(test4,production,slow) - procedure test4; - - end test_tag_pkg_2; - ]'; - - execute immediate q'[create or replace package body test_tag_pkg_2 is - procedure test3 is - begin - dbms_output.put_line('test_tag_pkg_2.test3 executed'); - end; - procedure test4 is - begin - dbms_output.put_line('test_tag_pkg_2.test4 executed'); - end; - end test_tag_pkg_2; - ]'; - - execute immediate q'[create or replace package test_tag_pkg_3 is - --%suite - --%tags(suite3,release_3_1_13,production,simple,end_to_end) - --%suitepath(suite3) - --%rollback(manual) - - --%test(Test5 from test_tag_pkg_3) - --%tags(test5,release_3_1_13,production,patch_3_1_13) - procedure test5; - - --%test(Test6 from test_tag_pkg_3) - --%tags(test6,development,patch_3_1_14) - procedure test6; - - end test_tag_pkg_3; - ]'; - - execute immediate q'[create or replace package body test_tag_pkg_3 is - procedure test5 is - begin - dbms_output.put_line('test_tag_pkg_3.test5 executed'); - end; - procedure test6 is - begin - dbms_output.put_line('test_tag_pkg_3.test6 executed'); - end; - end test_tag_pkg_3; - ]'; - - execute immediate q'[create or replace package suite1_level1_pkg is - - --%suite(suite1_level1) - --%suitepath(any_none) - --%rollback(manual) - - --%test(Test 1 from Suite1 on level 1) - --%tags(suite1,level1,test1,test1_level1) - procedure test1_level1; - - --%test(Test 2 from Suite1 on level 1) - procedure test2_level1; - - end suite1_level1_pkg; - ]'; - - execute immediate q'[create or replace package body suite1_level1_pkg is - procedure test1_level1 is - begin - dbms_output.put_line('suite1_level1_pkg.test1_level1 executed'); - end; - procedure test2_level1 is - begin - dbms_output.put_line('suite1_level1_pkg.test2_level1 executed'); - end; - end suite1_level1_pkg; - ]'; - - execute immediate q'[create or replace package suite1_1_level2_pkg is - - --%suite(suite1_1_level2) - --%suitepath(any_none.suite1_level1) - --%rollback(manual) - - --%test(Test 1 from Suite1_2 on level 2) - --%tags(level2,test1,test1_level2) - procedure suite1_1_test1_level2; - - --%test(Test 2 from Suite1_2 on level 2) - procedure suite1_1_test2_level2; - - end suite1_1_level2_pkg; - ]'; - - execute immediate q'[create or replace package body suite1_1_level2_pkg is - procedure suite1_1_test1_level2 is - begin - dbms_output.put_line('suite1_1_level2_pkg.suite1_1_test1_level2 executed'); - end; - procedure suite1_1_test2_level2 is - begin - dbms_output.put_line('suite1_1_level2_pkg.suite1_1_test2_level2 executed'); - end; - end suite1_1_level2_pkg; - ]'; - - execute immediate q'[create or replace package suite1_2_level2_pkg is - - --%suite(suite1_2_level2) - --%tags(level2,suite1_2,suites) - --%suitepath(any_none.suite1_level1) - --%rollback(manual) - - --%test(Test 1 from Suite1_2 on level 2) - procedure suite1_2_test1_level2; - - --%test(Test 2 from Suite1_2 on level 2) - --%tags(level2,test2,test2_level2) - procedure suite1_2_test2_level1; - - end suite1_2_level2_pkg; - ]'; - - execute immediate q'[create or replace package body suite1_2_level2_pkg is - procedure suite1_2_test1_level2 is - begin - dbms_output.put_line('suite1_2_level2_pkg.suite1_2_test1_level2 executed'); - end; - procedure suite1_2_test2_level1 is - begin - dbms_output.put_line('suite1_2_level2_pkg.suite1_2_test2_level1 executed'); - end; - end suite1_2_level2_pkg; - ]'; - - execute immediate q'[create or replace package suite2_level1_pkg is - - --%suite(suite2_level1) - --%tags(level1,suite2,suites) - --%suitepath(any_none) - --%rollback(manual) - - --%test(Test 1 from Suite1 on level 1) - --%tags(suite2,level1,test1,test1_level1) - procedure test1_level1; - - --%test(Test 2 from Suite1 on level 1) - procedure test2_level1; - - end suite2_level1_pkg; - ]'; - - execute immediate q'[create or replace package body suite2_level1_pkg is - procedure test1_level1 is - begin - dbms_output.put_line('suite2_level1_pkg.test1_level1 executed'); - end; - procedure test2_level1 is - begin - dbms_output.put_line('suite2_level1_pkg.test2_level1 executed'); - end; - end suite2_level1_pkg; - ]'; - - execute immediate q'[create or replace package suite2_2_level2_pkg is - - --%suite(suite2_2_level2) - --%tags(level2,suite2_2,suites) - --%suitepath(any_none.suite2_level1) - --%rollback(manual) - - --%test(Test 1 from Suite2_2 on level 2) - procedure suite2_2_test1_level2; - - --%test(Test 2 from Suite2_2 on level 2) - --%tags(level2,test2,test2_level2) - procedure suite2_2_test2_level2; - - end suite2_2_level2_pkg; - ]'; - - execute immediate q'[create or replace package body suite2_2_level2_pkg is - procedure suite2_2_test1_level2 is - begin - dbms_output.put_line('suite2_2_level2_pkg.suite2_2_test1_level2 executed'); - end; - procedure suite2_2_test2_level2 is - begin - dbms_output.put_line('suite2_2_level2_pkg.suite2_2_test2_level2 executed'); - end; - end suite2_2_level2_pkg; - ]'; - - - 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]'; - execute immediate q'[grant execute on test_tag_pkg_1 to public]'; - execute immediate q'[grant execute on test_tag_pkg_2 to public]'; - execute immediate q'[grant execute on test_tag_pkg_3 to public]'; - - execute immediate q'[grant execute on suite1_level1_pkg to public]'; - execute immediate q'[grant execute on suite1_1_level2_pkg to public]'; - execute immediate q'[grant execute on suite1_2_level2_pkg to public]'; - execute immediate q'[grant execute on suite2_level1_pkg to public]'; - execute immediate q'[grant execute on suite2_2_level2_pkg 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]'; - execute immediate q'[drop package test_tag_pkg_1]'; - execute immediate q'[drop package test_tag_pkg_2]'; - execute immediate q'[drop package test_tag_pkg_3]'; - - execute immediate q'[drop package suite2_2_level2_pkg]'; - execute immediate q'[drop package suite2_level1_pkg]'; - execute immediate q'[drop package suite1_2_level2_pkg]'; - execute immediate q'[drop package suite1_level1_pkg]'; - execute immediate q'[drop package suite1_1_level2_pkg]'; - 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_develop.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_develop.ut_reporter_base := null) is - begin - ut3_develop.ut.run(a_reporter); - end; - - procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null) is - begin - ut3_develop.ut.run(a_path, a_reporter); - end; - - procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null) is - begin - ut3_develop.ut.run(a_paths, a_reporter); - end; - - procedure run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) is - begin - ut3_develop.ut.run( - a_paths, - a_reporter, - a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => a_test_files - ); - end; - - function run(a_reporter ut3_develop.ut_reporter_base := null) return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.ut.run(a_reporter)); - return l_results; - end; - - function run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table ( - ut3_develop.ut.run( - a_paths, - a_reporter, a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => a_test_files - )); - return l_results; - end; - - function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null) - return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.ut.run(a_path, a_reporter)); - return l_results; - end; - - function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null) - return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.ut.run(a_paths, a_reporter)); - return l_results; - end; - - function run(a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) - return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table ( - ut3_develop.ut.run( - a_reporter, a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => a_test_files - )); - return l_results; - end; - - procedure run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) is - begin - ut3_develop.ut.run(a_reporter,a_tags => a_tags); - end; - - procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) is - begin - ut3_develop.ut.run(a_path, a_reporter,a_tags => a_tags); - end; - - procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) is - begin - ut3_develop.ut.run(a_paths, a_reporter,a_tags => a_tags); - end; - - function run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.ut.run(a_reporter, a_tags => a_tags)); - return l_results; - end; - - function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) - return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.ut.run(a_path, a_reporter,a_tags => a_tags)); - return l_results; - end; - - function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) - return ut3_develop.ut_varchar2_list is - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.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 ut_matcher) is - l_suite ut3_develop.ut_suite; - begin - --Arrange - execute immediate 'delete from ut$test_table'; - l_suite := ut3_develop.ut_suite(a_object_owner => 'ut3_tester_helper', a_object_name => 'UT_TRANSACTION_CONTROL', a_line_no=> 1); - l_suite.path := 'ut_transaction_control'; - l_suite.before_all_list := ut3_develop.ut_executables(ut3_develop.ut_executable('ut3_tester_helper', 'UT_TRANSACTION_CONTROL', 'setup', ut3_develop.ut_utils.gc_before_all)); - l_suite.items.extend; - l_suite.items(l_suite.items.last) := ut3_develop.ut_test(a_object_owner => 'ut3_tester_helper', 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_develop.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_develop.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_develop.dummy_long_test_package]'; - execute immediate q'[drop package ut3_develop.dummy_long_test_package1]'; - end; - - procedure create_ut3_suite is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package ut3_develop.some_test_package - as - --%suite - - --%test - procedure some_test; - - end;]'; - execute immediate q'[ - create or replace package ut3_develop.package_that_is_not_a_test - as - --%parameter(a comment inside) - --%parameters( description ) - - --%test - procedure some_test; - - end;]'; - end; - - procedure drop_ut3_suite is - pragma autonomous_transaction; - begin - execute immediate q'[drop package ut3_develop.package_that_is_not_a_test]'; - execute immediate q'[drop package ut3_develop.some_test_package]'; - end; - - function get_schema_ut_packages(a_owner in varchar2) return ut3_develop.ut_object_names is - begin - return ut3_develop.ut_suite_manager.get_schema_ut_packages(ut3_develop.ut_varchar2_rows(a_owner), null); - 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_develop.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_develop.ut_output_buffer_tmp; - end; - - function get_annotation_cache_info_cur( - a_owner varchar2, - a_type varchar2 - ) return sys_refcursor is - l_result sys_refcursor; - begin - open l_result for - select * from ut3_develop.ut_annotation_cache_info - where object_owner = a_owner and object_type = a_type; - - return l_result; - end; - - function get_annotation_cache_cursor( - a_owner varchar2, - a_type varchar2, - a_name varchar2 := null - ) return sys_refcursor is - l_result sys_refcursor; - begin - open l_result for - select * - from ut3_develop.ut_annotation_cache_info i - join ut3_develop.ut_annotation_cache c on c.cache_id = i.cache_id - where object_owner = a_owner and object_type = a_type and object_name = nvl( a_name, object_name ); - - return l_result; - end; - -end; -/ diff --git a/test/ut3_tester_helper/run_helper.pks b/test/ut3_tester_helper/run_helper.pks deleted file mode 100644 index ad0f615e5..000000000 --- a/test/ut3_tester_helper/run_helper.pks +++ /dev/null @@ -1,78 +0,0 @@ -create or replace package run_helper is - - g_run_id integer; - - type t_out_buff_tab is table of ut3_develop.ut_output_buffer_tmp%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_develop.ut_reporter_base := null); - procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null); - procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null); - procedure run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, - a_reporter ut3_develop.ut_reporter_base); - function run(a_reporter ut3_develop.ut_reporter_base := null) return ut3_develop.ut_varchar2_list; - function run(a_paths ut3_develop.ut_varchar2_list, a_test_files ut3_develop.ut_varchar2_list, - a_reporter ut3_develop.ut_reporter_base) return ut3_develop.ut_varchar2_list; - function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null) - return ut3_develop.ut_varchar2_list; - function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null) - return ut3_develop.ut_varchar2_list; - function run(a_test_files ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base) - return ut3_develop.ut_varchar2_list; - - procedure run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2); - procedure run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2); - procedure run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2); - function run(a_reporter ut3_develop.ut_reporter_base := null,a_tags varchar2) return ut3_develop.ut_varchar2_list; - function run(a_path varchar2, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) - return ut3_develop.ut_varchar2_list; - function run(a_paths ut3_develop.ut_varchar2_list, a_reporter ut3_develop.ut_reporter_base := null, a_tags varchar2) - return ut3_develop.ut_varchar2_list; - - procedure test_rollback_type(a_procedure_name varchar2, a_rollback_type integer, a_expectation ut_matcher); - - procedure create_dummy_long_test_package; - procedure drop_dummy_long_test_package; - procedure create_ut3_suite; - procedure drop_ut3_suite; - function get_schema_ut_packages(a_owner in varchar2) return ut3_develop.ut_object_names; - - function ut_output_buffer_tmp return t_out_buff_tab pipelined; - procedure delete_buffer; - - function get_annotation_cache_info_cur( - a_owner varchar2, - a_type varchar2 - ) return sys_refcursor; - - function get_annotation_cache_cursor( - a_owner varchar2, - a_type varchar2, - a_name varchar2 := null - ) return sys_refcursor; - -end; -/ diff --git a/test/ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps b/test/ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps deleted file mode 100644 index 5134fef21..000000000 --- a/test/ut3_tester_helper/test_dummy_dble_nest_lst_obj.tps +++ /dev/null @@ -1,17 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DBLE_NEST_LST_OBJ'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_dble_nest_lst_obj force'; - end if; -end; -/ - -CREATE TYPE test_dummy_dble_nest_lst_obj AS OBJECT -( - some_number_id NUMBER, - some_name VARCHAR2 (25), - dummy_list test_dummy_double_nested_list -); -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_double_nested_list.tps b/test/ut3_tester_helper/test_dummy_double_nested_list.tps deleted file mode 100644 index 625462824..000000000 --- a/test/ut3_tester_helper/test_dummy_double_nested_list.tps +++ /dev/null @@ -1,13 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DOUBLE_NESTED_LIST'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_double_nested_list force'; - end if; -end; -/ - -CREATE TYPE test_dummy_double_nested_list AS - TABLE OF test_dummy_nested_object_list; -/ diff --git a/test/ut3_tester_helper/test_dummy_double_nested_object.tps b/test/ut3_tester_helper/test_dummy_double_nested_object.tps deleted file mode 100644 index 8f74f7ecb..000000000 --- a/test/ut3_tester_helper/test_dummy_double_nested_object.tps +++ /dev/null @@ -1,15 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DOUBLE_NESTED_OBJ'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_double_nested_obj force'; - end if; -end; -/ - -create or replace type test_dummy_double_nested_obj as object ( - first_double_nested_obj test_dummy_nested_object, - "Value" varchar2(30) -) -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_nested_object.tps b/test/ut3_tester_helper/test_dummy_nested_object.tps deleted file mode 100644 index 6aef3bef8..000000000 --- a/test/ut3_tester_helper/test_dummy_nested_object.tps +++ /dev/null @@ -1,15 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_NESTED_OBJECT'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_nested_object force'; - end if; -end; -/ - -create or replace type test_dummy_nested_object as object ( - first_nested_obj test_dummy_object, - sec_nested_obj test_dummy_object -) -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_nested_object_list.tps b/test/ut3_tester_helper/test_dummy_nested_object_list.tps deleted file mode 100644 index fd47b55bd..000000000 --- a/test/ut3_tester_helper/test_dummy_nested_object_list.tps +++ /dev/null @@ -1,15 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_NESTED_OBJECT_LIST'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_nested_object_list force'; - end if; -end; -/ - -create or replace type test_dummy_nested_object_list as object ( - first_nested_obj test_dummy_object_list, - somename varchar2(50) -) -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_dummy_number.tps b/test/ut3_tester_helper/test_dummy_number.tps deleted file mode 100644 index b6283c93b..000000000 --- a/test/ut3_tester_helper/test_dummy_number.tps +++ /dev/null @@ -1,14 +0,0 @@ -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/ut3_tester_helper/test_dummy_object.tps b/test/ut3_tester_helper/test_dummy_object.tps deleted file mode 100644 index 7f095fc0a..000000000 --- a/test/ut3_tester_helper/test_dummy_object.tps +++ /dev/null @@ -1,16 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_OBJECT'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_object force'; - end if; -end; -/ - -create or replace type test_dummy_object as object ( - id number, - "name" varchar2(30), - "Value" varchar2(30) -) -/ diff --git a/test/ut3_tester_helper/test_dummy_object_list.tps b/test/ut3_tester_helper/test_dummy_object_list.tps deleted file mode 100644 index 849974da1..000000000 --- a/test/ut3_tester_helper/test_dummy_object_list.tps +++ /dev/null @@ -1,12 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_OBJECT_LIST'; - if l_exists > 0 then - execute immediate 'drop type test_dummy_object_list force'; - end if; -end; -/ - -create or replace type test_dummy_object_list as table of test_dummy_object -/ diff --git a/test/ut3_tester_helper/test_event_list.tps b/test/ut3_tester_helper/test_event_list.tps deleted file mode 100644 index 8abf71b13..000000000 --- a/test/ut3_tester_helper/test_event_list.tps +++ /dev/null @@ -1,2 +0,0 @@ -create or replace type test_event_list as table of test_event_object; -/ diff --git a/test/ut3_tester_helper/test_event_object.tps b/test/ut3_tester_helper/test_event_object.tps deleted file mode 100644 index da458d2c2..000000000 --- a/test/ut3_tester_helper/test_event_object.tps +++ /dev/null @@ -1,15 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_EVENT_OBJECT'; - if l_exists > 0 then - execute immediate 'drop type test_event_object force'; - end if; -end; -/ - -create or replace type test_event_object as object ( - event_type varchar2(1000), - event_doc xmltype -) -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_nested_tab_varray.tps b/test/ut3_tester_helper/test_nested_tab_varray.tps deleted file mode 100644 index 9f58d090e..000000000 --- a/test/ut3_tester_helper/test_nested_tab_varray.tps +++ /dev/null @@ -1,14 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'TEST_NESTED_TAB_VARRAY'; - if l_exists > 0 then - execute immediate 'drop type test_nested_tab_varray force'; - end if; -end; -/ - -create or replace type test_nested_tab_varray as object ( - n_varray t_varray -) -/ diff --git a/test/ut3_tester_helper/test_tab_varchar2.tps b/test/ut3_tester_helper/test_tab_varchar2.tps deleted file mode 100644 index 17086292a..000000000 --- a/test/ut3_tester_helper/test_tab_varchar2.tps +++ /dev/null @@ -1,12 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'T_TAB_VARCHAR'; - if l_exists > 0 then - execute immediate 'drop type t_tab_varchar force'; - end if; -end; -/ - -create or replace type t_tab_varchar is table of varchar2(1) -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/test_tab_varray.tps b/test/ut3_tester_helper/test_tab_varray.tps deleted file mode 100644 index 3c684afca..000000000 --- a/test/ut3_tester_helper/test_tab_varray.tps +++ /dev/null @@ -1,13 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_types where type_name = 'T_VARRAY'; - if l_exists > 0 then - execute immediate 'drop type t_varray force'; - end if; -end; -/ - - -create or replace type t_varray is varray(1) of number -/ \ No newline at end of file diff --git a/test/ut3_tester_helper/ut_example_tests.pkb b/test/ut3_tester_helper/ut_example_tests.pkb deleted file mode 100644 index 7e795d184..000000000 --- a/test/ut3_tester_helper/ut_example_tests.pkb +++ /dev/null @@ -1,36 +0,0 @@ -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/ut3_tester_helper/ut_example_tests.pks b/test/ut3_tester_helper/ut_example_tests.pks deleted file mode 100644 index a62c02332..000000000 --- a/test/ut3_tester_helper/ut_example_tests.pks +++ /dev/null @@ -1,12 +0,0 @@ -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; - procedure ut_commit_test; -end; -/ diff --git a/test/ut3_tester_helper/ut_test_table.sql b/test/ut3_tester_helper/ut_test_table.sql deleted file mode 100644 index c4832a10f..000000000 --- a/test/ut3_tester_helper/ut_test_table.sql +++ /dev/null @@ -1,12 +0,0 @@ -declare - l_exists integer; -begin - select count(1) into l_exists from user_tables where table_name = 'UT$TEST_TABLE'; - if l_exists > 0 then - execute immediate 'drop table ut$test_table'; - end if; -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 deleted file mode 100644 index f0cfd8373..000000000 --- a/test/ut3_user/api/test_ut_run.pkb +++ /dev/null @@ -1,1657 +0,0 @@ -create or replace package body test_ut_run is - - gc_owner constant varchar2(250) := sys_context('userenv', 'current_schema'); - gc_module constant varchar2(32767) := 'test module'; - gc_action constant varchar2(32767) := 'test action'; - gc_client_info constant varchar2(32767) := 'test client info'; - - g_context_test_results clob; - g_timestamp timestamp; - - 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_develop.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); - end; - - procedure ut_fail is - begin - --Act - ut3_develop.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_develop.ut.run('ut3_tester_helper',a_reporter => ut3_develop.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_develop.ut.run( - 'ut3_tester_helper', - a_reporter => ut3_develop.ut_sonar_test_reporter(), - a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => ut3_develop.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_develop.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_develop.ut.run( - 'ut3_tester_helper.test_package_3', - ut3_develop.ut_sonar_test_reporter(), a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => ut3_develop.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_develop.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_develop.ut_varchar2_list(':tests.test_package_1',':tests'), - a_reporter => ut3_develop.ut_sonar_test_reporter(), - a_test_files => ut3_develop.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_develop.ut.run('ut3_tester_helper', cast(null as ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - begin - --Act - l_results := ut3_tester_helper.run_helper.run(ut3_develop.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_develop.ut_varchar2_list; - begin - --Act - select * bulk collect into l_results from table ( - ut3_develop.ut.run('ut3_tester_helper', - ut3_develop.ut_sonar_test_reporter(), - a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => ut3_develop.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_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.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_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table ( - ut3_develop.ut.run('ut3_tester_helper.test_package_3', - ut3_develop.ut_sonar_test_reporter(), - a_source_files => ut3_develop.ut_varchar2_list(), - a_test_files => ut3_develop.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_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.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_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run( - a_paths => ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'), - a_reporter => ut3_develop.ut_sonar_test_reporter(), - a_test_files => ut3_develop.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_develop.ut_varchar2_list; - begin - --Act - select * bulk collect into l_results from table (ut3_develop.ut.run('ut3_tester_helper',cast(null as ut3_develop.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_develop.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_develop.ut_varchar2_list; - l_paths ut3_develop.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_develop.ut_varchar2_list; - begin - --Act - l_results := ut3_tester_helper.run_helper.run(ut3_develop.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_develop.ut_varchar2_list; - begin - --Act - l_results := ut3_tester_helper.run_helper.run( - a_test_files => ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767); - begin - select * bulk collect into l_results from table(ut3_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - l_actual clob; - begin - - select * bulk collect into l_results from table(ut3_develop.ut.run('bad_annotations')); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - - ut.expect(l_actual).to_be_like('%Missing "--%endcontext" annotation for a "--%context" annotation. The end of package is considered end of context.% -%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_develop.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_develop.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_develop.ut_varchar2_list; - l_expected clob; - begin - select * bulk collect into l_results - from table ( ut3_develop.ut.run( gc_owner||'.'||gc_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 '||gc_owner||'.'||gc_owner||' as - --%suite - - --%test - procedure sample_test; - end;'; - - execute immediate ' - create or replace package body '||gc_owner||'.'||gc_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 '||gc_owner||'.'||gc_owner; - end; - - procedure create_suites_with_path is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package ut_abc is - -- %suite - -- %suitepath(main.abc) - - -- %test - procedure ut_test_01; - end ut_abc;]'; - - execute immediate q'[create or replace package body ut_abc - is - procedure ut_test_01 as begin ut.expect(true).to_be_true(); end; - end;]'; - - execute immediate q'[create or replace package ut_abc_def - is - -- %suite - -- %suitepath(main.abc_def) - - -- %test - procedure ut_test_01; - end ut_abc_def;]'; - - execute immediate q'[create or replace package body ut_abc_def - is - procedure ut_test_01 as begin ut.expect(true).to_be_true(); end; - end;]'; - - end; - - procedure drop_suites_with_path is - pragma autonomous_transaction; - begin - execute immediate q'[drop package ut_abc]'; - execute immediate q'[drop package ut_abc_def]'; - end; - - procedure run_suite_with_nls_sort is - L_current_sort varchar2(2000); - l_results ut3_develop.ut_varchar2_list; - l_expected clob; - begin - --Arrange - select value - into l_current_sort - from nls_session_parameters where parameter = 'NLS_SORT'; - - execute immediate 'alter session set nls_sort=GERMAN'; - - --Act - select * - bulk collect into l_results - from table ( ut3_develop.ut.run( gc_owner||':main' ) ); - --Assert - l_expected := q'[main% - abc_def% - ut_abc_def% - ut_test_01% - abc% - ut_abc% - ut_test_01%]'; - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( l_expected ); - - execute immediate 'alter session set nls_sort='||l_current_sort; - end; - - procedure run_with_random_order is - l_random_results ut3_develop.ut_varchar2_list; - l_results ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_random_results - from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 6 ) ) - 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_develop.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_develop.ut_varchar2_list; - begin - select * bulk collect into l_actual - from table ( ut3_develop.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_develop.ut_varchar2_list; - l_actual ut3_develop.ut_varchar2_list; - begin - - select * bulk collect into l_expected - from table ( ut3_develop.ut.run( 'ut3_tester_helper.test_package_1', a_random_test_order_seed => 3 ) ); - select * bulk collect into l_actual - from table ( ut3_develop.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 two_test_run_by_two_tags_leg 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_develop.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_develop.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_develop.ut.run( - 'ut3_tester_helper.test_package_1', - ut3_develop.ut_sonar_test_reporter(), a_source_files => ut3_develop.ut_varchar2_list(),a_tags => 'suite1', - a_test_files => ut3_develop.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_develop.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_develop.ut_varchar2_list; - begin - select * bulk collect into l_results from table (ut3_develop.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_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.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; - - procedure tag_run_func_path_list_leg is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.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; - - procedure tag_inc_exc_run_func_path_list is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => '(suite1test1|suite2test1)&!suite2'); - --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) ).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_3%' ); - end; - - procedure tag_inc_exc_run_fun_pth_lst_lg is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests.test_package_1',':tests'),a_tags => 'suite1test1,suite2test1,-suite2'); - --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) ).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_3%' ); - end; - - procedure tag_exclude_run_func_path_list is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2'),a_tags => '!suite1test2&!suite2test1&!test1suite3'); - --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_3%' ); - 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.test1%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).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.test1%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_3.test2%executed%' ); - end; - -procedure tag_exclude_run_fun_pth_lst_lg is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2'),a_tags => '-suite1test2,-suite2test1,-test1suite3'); - --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_3%' ); - 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.test1%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).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.test1%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_3.test2%executed%' ); - end; - - procedure tag_include_exclude_run_func is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(a_tags => '(suite1)&(!suite1test2&!suite2test1&!test1suite3)'); - --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%' ); - 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.test1%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test2%executed%' ); - end; - - procedure tag_include_exclude_run_fun_lg is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(a_tags => 'suite1,-suite1test2,-suite2test1,-test1suite3'); - --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%' ); - 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.test1%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_package_2.test2%executed%' ); - end; - - procedure tag_complex_expressions is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(a_tags => 'release_3_1_13&(fast|simple)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test6 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_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.test3%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); - - l_results := ut3_tester_helper.run_helper.run(a_tags => 'release_3_1_13&(!patch_3_1_13&!patch_3_1_14)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_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.test3%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test5%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test6%executed%' ); - - l_results := ut3_tester_helper.run_helper.run(a_tags => 'release_3_1_13&(patch_3_1_13&!slow)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_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.test3%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test6%executed%' ); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(simple&end_to_end)|(development&fast)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_2.test3 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test6 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.test4%executed%' ); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&end_to_end)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%test_tag_pkg_3.test5 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_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.test3%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_2.test4%executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%test_package_3.test6%executed%' ); - - l_results := ut3_tester_helper.run_helper.run(a_tags => 'any'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_level1_pkg.test1_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_level1_pkg.test2_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_level1_pkg.test1_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_2_level2_pkg.suite2_2_test1_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite2_2_level2_pkg.suite2_2_test2_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_2_level2_pkg.suite1_2_test1_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_2_level2_pkg.suite1_2_test2_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_1_level2_pkg.suite1_1_test1_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_level1_pkg.test2_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_1_level2_pkg.suite1_1_test2_level2 executed%' ); - - l_results := ut3_tester_helper.run_helper.run(a_tags => 'none'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_level1_pkg.test2_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%suite1_1_level2_pkg.suite1_1_test2_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_level1_pkg.test1_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_level1_pkg.test2_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_level1_pkg.test1_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_2_level2_pkg.suite2_2_test1_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite2_2_level2_pkg.suite2_2_test2_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_2_level2_pkg.suite1_2_test1_level2 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_2_level2_pkg.suite1_2_test2_level1 executed%' ); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%suite1_1_level2_pkg.suite1_1_test1_level2 executed%' ); - - - end; - - procedure invalid_tag_expression is - l_results ut3_develop.ut_varchar2_list; - begin - l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development!&end_to_end)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&&end_to_end)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&end_to_end|)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&!!end_to_end)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(&development&end_to_end)'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); - - l_results := ut3_tester_helper.run_helper.run(a_tags => '(development|end_to_end))'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); - - end; - - procedure set_application_info is - begin - dbms_application_info.set_module( gc_module, gc_action ); - dbms_application_info.set_client_info( gc_client_info ); - end; - - procedure create_context_test_suite is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package check_context is - --%suite(Suite description) - --%suitepath(some.suite.path) - - --%beforeall - procedure before_suite; - - --%context(context description) - --%name(some_context) - - --%beforeall - procedure before_context; - - --%beforeeach - procedure before_each_test; - - --%test(Some test description) - --%beforetest(before_test) - --%aftertest(after_test) - procedure the_test; - procedure before_test; - procedure after_test; - - --%aftereach - procedure after_each_test; - - --%afterall - procedure after_context; - - --%endcontext - - - --%afterall - procedure after_suite; - - end;]'; - execute immediate q'[ - create or replace package body check_context is - - procedure print_context( a_procedure_name varchar2 ) is - l_results ut_varchar2_rows; - l_module varchar2(32767); - l_action varchar2(32767); - l_client_info varchar2(32767); - begin - select attribute||'='||value - bulk collect into l_results - from session_context where namespace = 'UT3_DEVELOP_INFO' - order by attribute; - for i in 1 .. l_results.count loop - dbms_output.put_line( upper(a_procedure_name) ||':'|| l_results(i) ); - end loop; - dbms_application_info.read_module( l_module, l_action ); - dbms_application_info.read_client_info( l_client_info ); - - dbms_output.put_line( 'APPLICATION_INFO:MODULE=' || l_module ); - dbms_output.put_line( 'APPLICATION_INFO:ACTION=' || l_action ); - dbms_output.put_line( 'APPLICATION_INFO:CLIENT_INFO=' || l_client_info ); - end; - - procedure before_suite is - begin - print_context('before_suite'); - end; - - procedure before_context is - begin - print_context('before_context'); - end; - - procedure before_each_test is - begin - print_context('before_each_test'); - end; - - procedure the_test is - begin - print_context('the_test'); - end; - - procedure before_test is - begin - print_context('before_test'); - end; - - procedure after_test is - begin - print_context('after_test'); - end; - - procedure after_each_test is - begin - print_context('after_each_test'); - end; - - procedure after_context is - begin - print_context('after_context'); - end; - - procedure after_suite is - begin - print_context('after_suite'); - end; - - end;]'; - end; - - procedure drop_context_test_suite is - pragma autonomous_transaction; - begin - execute immediate q'[drop package check_context]'; - end; - - procedure run_context_test_suite is - l_lines ut3_develop.ut_varchar2_list; - begin - select * bulk collect into l_lines from table(ut3_develop.ut.run('check_context')); - g_context_test_results := ut3_tester_helper.main_helper.table_to_clob(l_lines); - g_timestamp := current_timestamp; - end; - - - procedure sys_ctx_on_suite_beforeall is - begin - ut.expect(g_context_test_results).to_be_like( - '%BEFORE_SUITE:COVERAGE_RUN_ID=________________________________%' - ||'%BEFORE_SUITE:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_suite' - ||'%BEFORE_SUITE:CURRENT_EXECUTABLE_TYPE=beforeall' - ||'%BEFORE_SUITE:RUN_PATHS=check_context' - ||'%BEFORE_SUITE:SUITE_DESCRIPTION=Suite description' - ||'%BEFORE_SUITE:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%BEFORE_SUITE:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_SUITE:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=before_suite%' - ); - ut.expect(g_context_test_results).not_to_be_like('%BEFORE_SUITE:CONTEXT_%'); - ut.expect(g_context_test_results).not_to_be_like('%BEFORE_SUITE:TEST_%'); - end; - - procedure sys_ctx_on_context_beforeall is - begin - ut.expect(g_context_test_results).to_be_like( - '%BEFORE_CONTEXT:CONTEXT_DESCRIPTION=context description' - ||'%BEFORE_CONTEXT:CONTEXT_NAME=some_context' - ||'%BEFORE_CONTEXT:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%BEFORE_CONTEXT:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%BEFORE_CONTEXT:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_context' - ||'%BEFORE_CONTEXT:CURRENT_EXECUTABLE_TYPE=beforeall' - ||'%BEFORE_CONTEXT:RUN_PATHS=check_context' - ||'%BEFORE_CONTEXT:SUITE_DESCRIPTION=Suite description' - ||'%BEFORE_CONTEXT:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%BEFORE_CONTEXT:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_CONTEXT:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=before_context%' - ); - ut.expect(g_context_test_results).not_to_be_like('%BEFORE_CONTEXT:TEST_%'); - end; - - procedure sys_ctx_on_beforeeach is - begin - ut.expect(g_context_test_results).to_be_like( - '%BEFORE_EACH_TEST:CONTEXT_DESCRIPTION=context description' - ||'%BEFORE_EACH_TEST:CONTEXT_NAME=some_context' - ||'%BEFORE_EACH_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%BEFORE_EACH_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%BEFORE_EACH_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_each_test' - ||'%BEFORE_EACH_TEST:CURRENT_EXECUTABLE_TYPE=beforeeach' - ||'%BEFORE_EACH_TEST:RUN_PATHS=check_context' - ||'%BEFORE_EACH_TEST:SUITE_DESCRIPTION=Suite description' - ||'%BEFORE_EACH_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%BEFORE_EACH_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_EACH_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%BEFORE_EACH_TEST:TEST_DESCRIPTION=Some test description' - ||'%BEFORE_EACH_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%BEFORE_EACH_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=before_each_test%' - ); - end; - - procedure sys_ctx_on_beforetest is - begin - ut.expect(g_context_test_results).to_be_like( - '%BEFORE_TEST:CONTEXT_DESCRIPTION=context description' - ||'%BEFORE_TEST:CONTEXT_NAME=some_context' - ||'%BEFORE_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%BEFORE_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%BEFORE_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.before_test' - ||'%BEFORE_TEST:CURRENT_EXECUTABLE_TYPE=beforetest' - ||'%BEFORE_TEST:RUN_PATHS=check_context' - ||'%BEFORE_TEST:SUITE_DESCRIPTION=Suite description' - ||'%BEFORE_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%BEFORE_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%BEFORE_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%BEFORE_TEST:TEST_DESCRIPTION=Some test description' - ||'%BEFORE_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%BEFORE_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=before_test%' - ); - end; - - procedure sys_ctx_on_test is - begin - ut.expect(g_context_test_results).to_be_like( - '%THE_TEST:CONTEXT_DESCRIPTION=context description' - ||'%THE_TEST:CONTEXT_NAME=some_context' - ||'%THE_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%THE_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%THE_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.the_test' - ||'%THE_TEST:CURRENT_EXECUTABLE_TYPE=test' - ||'%THE_TEST:RUN_PATHS=check_context' - ||'%THE_TEST:SUITE_DESCRIPTION=Suite description' - ||'%THE_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%THE_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%THE_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%THE_TEST:TEST_DESCRIPTION=Some test description' - ||'%THE_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%THE_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=the_test%' - ); - end; - - procedure sys_ctx_on_aftertest is - begin - ut.expect(g_context_test_results).to_be_like( - '%AFTER_TEST:CONTEXT_DESCRIPTION=context description' - ||'%AFTER_TEST:CONTEXT_NAME=some_context' - ||'%AFTER_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%AFTER_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%AFTER_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_test' - ||'%AFTER_TEST:CURRENT_EXECUTABLE_TYPE=aftertest' - ||'%AFTER_TEST:RUN_PATHS=check_context' - ||'%AFTER_TEST:SUITE_DESCRIPTION=Suite description' - ||'%AFTER_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%AFTER_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%AFTER_TEST:TEST_DESCRIPTION=Some test description' - ||'%AFTER_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%AFTER_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=after_test%' - ); - end; - - procedure sys_ctx_on_aftereach is - begin - ut.expect(g_context_test_results).to_be_like( - '%AFTER_EACH_TEST:CONTEXT_DESCRIPTION=context description' - ||'%AFTER_EACH_TEST:CONTEXT_NAME=some_context' - ||'%AFTER_EACH_TEST:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%AFTER_EACH_TEST:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%AFTER_EACH_TEST:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_each_test' - ||'%AFTER_EACH_TEST:CURRENT_EXECUTABLE_TYPE=aftereach' - ||'%AFTER_EACH_TEST:RUN_PATHS=check_context' - ||'%AFTER_EACH_TEST:SUITE_DESCRIPTION=Suite description' - ||'%AFTER_EACH_TEST:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%AFTER_EACH_TEST:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_EACH_TEST:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%AFTER_EACH_TEST:TEST_DESCRIPTION=Some test description' - ||'%AFTER_EACH_TEST:TEST_NAME='||gc_owner||'.check_context.the_test' - ||'%AFTER_EACH_TEST:TEST_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=after_each_test%' - ); - end; - - procedure sys_ctx_on_context_afterall is - begin - ut.expect(g_context_test_results).to_be_like( - '%AFTER_CONTEXT:CONTEXT_DESCRIPTION=context description' - ||'%AFTER_CONTEXT:CONTEXT_NAME=some_context' - ||'%AFTER_CONTEXT:CONTEXT_PATH=some.suite.path.check_context.some_context' - ||'%AFTER_CONTEXT:CONTEXT_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%AFTER_CONTEXT:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_context' - ||'%AFTER_CONTEXT:CURRENT_EXECUTABLE_TYPE=afterall' - ||'%AFTER_CONTEXT:RUN_PATHS=check_context' - ||'%AFTER_CONTEXT:SUITE_DESCRIPTION=Suite description' - ||'%AFTER_CONTEXT:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%AFTER_CONTEXT:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_CONTEXT:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=after_context%' - ); - ut.expect(g_context_test_results).not_to_be_like('%AFTER_CONTEXT:TEST_%'); - end; - - procedure sys_ctx_on_suite_afterall is - begin - ut.expect(g_context_test_results).to_be_like( - '%AFTER_SUITE:CURRENT_EXECUTABLE_NAME='||gc_owner||'.check_context.after_suite' - ||'%AFTER_SUITE:CURRENT_EXECUTABLE_TYPE=afterall' - ||'%AFTER_SUITE:RUN_PATHS=check_context' - ||'%AFTER_SUITE:SUITE_DESCRIPTION=Suite description' - ||'%AFTER_SUITE:SUITE_PACKAGE='||gc_owner||'.check_context' - ||'%AFTER_SUITE:SUITE_PATH=some.suite.path.check_context' - ||'%AFTER_SUITE:SUITE_START_TIME='||to_char(g_timestamp,'syyyy-mm-dd"T"hh24:mi') - ||'%APPLICATION_INFO:MODULE=utPLSQL' - ||'%APPLICATION_INFO:ACTION=check_context' - ||'%APPLICATION_INFO:CLIENT_INFO=after_suite%' - ); - ut.expect(g_context_test_results).not_to_be_like('%AFTER_SUITE:CONTEXT_%'); - ut.expect(g_context_test_results).not_to_be_like('%AFTER_SUITE:TEST_%'); - end; - - procedure sys_ctx_clear_after_run is - l_actual sys_refcursor; - begin - open l_actual for - select attribute||'='||value - from session_context where namespace = 'UT3_DEVELOP_INFO'; - - ut.expect(l_actual).to_be_empty(); - end; - - procedure app_info_restore_after_run is - l_module varchar2(32767); - l_action varchar2(32767); - l_client_info varchar2(32767); - begin - dbms_application_info.read_module( l_module, l_action ); - dbms_application_info.read_client_info( l_client_info ); - - ut.expect(l_module).to_equal(gc_module); - ut.expect(l_action).to_equal(gc_action); - --Disabled as it can't be tested. - --UT3_LATEST_RELEASE is also setting the client_info on each procedure - -- ut.expect(l_client_info).to_equal(gc_client_info); - end; - -end; -/ diff --git a/test/ut3_user/api/test_ut_run.pks b/test/ut3_user/api/test_ut_run.pks deleted file mode 100644 index c57788bff..000000000 --- a/test/ut3_user/api/test_ut_run.pks +++ /dev/null @@ -1,321 +0,0 @@ -create or replace package test_ut_run is - --%suite(ut.run) - --%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) - --%beforetest(ut3_tester_helper.main_helper.set_ut_run_context) - --%aftertest(clear_expectations, ut3_tester_helper.main_helper.clear_ut_run_context) - procedure ut_fail; - - --%context(ut_run_procedure) - --%displayname(ut.run() procedure options) - --%beforeall(create_ut3_user_tests) - --%afterall(drop_ut3_user_tests) - - --%test(Runs all tests in current schema with default reporter when no parameters given) - procedure run_proc_no_params; - --%test(Runs all tests in current schema with specified reporter) - procedure run_proc_specific_reporter; - --%test(Runs all tests in current schema with coverage file list) - procedure run_proc_cov_file_list; - - --%test(Runs given package only with package name given as path) - procedure run_proc_pkg_name; - --%test(Runs all from given package with package name given as path and coverage file list) - procedure run_proc_pkg_name_file_list; - --%test(Runs tests from given paths only with paths list) - procedure run_proc_path_list; - --%test(Runs tests from given paths only with paths list and coverage file list) - procedure run_proc_path_list_file_list; - --%test(Runs all tests in current schema using default reporter when null reporter given) - procedure run_proc_null_reporter; - --%test(Runs all tests in current schema with null path provided) - procedure run_proc_null_path; - --%test(Runs all tests in current schema with null path list given) - procedure run_proc_null_path_list; - --%test(Runs all tests in current schema with empty path list given) - procedure run_proc_empty_path_list; - - procedure create_suite_with_commit; - procedure drop_suite_with_commit; - --%test(Reports a warning if transaction was invalidated by test with automatic rollback) - --%beforetest(create_suite_with_commit) - --%aftertest(drop_suite_with_commit) - procedure run_proc_warn_on_commit; - - - procedure create_failing_beforeall_suite; - procedure drop_failing_beforeall_suite; - --%test(Marks child suite as failed when parent's suite beforeall fails) - --%beforetest(create_failing_beforeall_suite) - --%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; - - --%endcontext - - --%context(run_proc_transaction_control) - - --%beforeall - procedure transaction_setup; - --%afterall - procedure transaction_cleanup; - --%test(Leaves transaction open and uncommitted with a_force_manual_rollback) - procedure run_proc_keep_test_data; - --%test(Leaves transaction open and uncommitted with a_force_manual_rollback with exceptions) - procedure run_proc_keep_test_data_raise; - --%test(Does not impact current transaction when ran without a_force_manual_rollback) - procedure run_proc_discard_test_data; - - --%endcontext - - - --%context(ut_run_function) - - --%displayname(ut.run() function options) - --%beforeall(create_ut3_user_tests) - --%afterall(drop_ut3_user_tests) - - --%test(Runs all tests in current schema with default reporter when no parameters given) - procedure run_func_no_params; - --%test(Runs all tests in current schema with specified reporter) - procedure run_func_specific_reporter; - --%test(Runs all tests in current schema with coverage file list) - procedure run_func_cov_file_list; - - --%test(Runs given package only with package name given as path) - procedure run_func_pkg_name; - --%test(Runs all from given package with package name given as path and coverage file list) - procedure run_func_pkg_name_file_list; - --%test(Runs tests from given paths with paths list) - procedure run_func_path_list; - --%test(Runs tests from given paths with paths list and coverage file list) - procedure run_func_path_list_file_list; - --%test(Runs all tests in current schema using default reporter when null reporter given) - procedure run_func_null_reporter; - --%test(Runs all tests in current schema with null path provided) - procedure run_func_null_path; - --%test(Runs all tests in current schema with null path list given) - procedure run_func_null_path_list; - --%test(Runs all tests in current schema with empty path list given) - procedure run_func_empty_path_list; - --%test(Runs all tests in current schema with coverage file list and default reporter) - procedure run_func_cov_file_lst_null_rep; - --%test(Executes successfully an empty suite) - procedure run_func_empty_suite; - - --disabled(Makes session wait for lock on 18.1 due to library cache pin wait) - --%test(ut.run - raises after completing all tests if a test fails with ORA-04068 or ORA-04061) - --%beforetest(create_test_suite) - --%aftertest(drop_test_suite) - procedure raise_in_invalid_state; - procedure create_test_suite; - procedure drop_test_suite; - - --%test(ut.run - Does not execute suite when specified package is not valid) - --%beforetest(compile_invalid_package) - --%aftertest(drop_invalid_package) - procedure run_in_invalid_state; - procedure compile_invalid_package; - procedure drop_invalid_package; - - --%test(Invalidate package specs via rebuild but still execute package) - --%beforetest(generate_invalid_spec) - --%aftertest(drop_invalid_spec) - procedure run_and_revalidate_specs; - procedure generate_invalid_spec; - procedure drop_invalid_spec; - - --%test(Provides warnings on invalid annotations) - --%beforetest(create_bad_annot) - --%aftertest(drop_bad_annot) - 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; - - --%test(Runs properly formed suite hierarchy regardless of NLS_SORT settings - Issue #1060) - --%beforetest(create_suites_with_path) - --%aftertest(drop_suites_with_path) - procedure run_suite_with_nls_sort; - procedure create_suites_with_path; - procedure drop_suites_with_path; - - --%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 tests by passing two tags - Legacy notation) - procedure two_test_run_by_two_tags_leg; - - --%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; - - --%test(Runs tests from given paths with paths list and a tag - Legacy Notation) - procedure tag_run_func_path_list_leg; - - --%test(Runs tests from given paths with paths list and include/exclude tags) - procedure tag_inc_exc_run_func_path_list; - - --%test(Runs tests from given paths with paths list and include/exclude tags - Legacy Notation) - procedure tag_inc_exc_run_fun_pth_lst_lg; - - --%test(Runs tests from given path and excludes specific tags) - procedure tag_exclude_run_func_path_list; - - --%test(Runs tests from given path and excludes specific tags - Legacy Notation) - procedure tag_exclude_run_fun_pth_lst_lg; - - --%test(Runs tests from given tags and exclude tags) - procedure tag_include_exclude_run_func; - - --%test(Runs tests from given tags and exclude tags - Legacy Notation) - procedure tag_include_exclude_run_fun_lg; - - --%test(Runs tests suing complex expressions) - procedure tag_complex_expressions; - - --%test(Testing invalid tag expression) - --%throws(-20219) - procedure invalid_tag_expression; - - --%endcontext - - --%context(ut3_info context) - - --%beforeall - procedure set_application_info; - --%beforeall - procedure create_context_test_suite; - - --%beforeall - procedure run_context_test_suite; - - --%afterall - procedure drop_context_test_suite; - - --%test(sets context for suite level beforeall) - procedure sys_ctx_on_suite_beforeall; - - --%test(sets context for context level beforeall) - procedure sys_ctx_on_context_beforeall; - - --%test(set for context level beforeeach) - procedure sys_ctx_on_beforeeach; - - --%test(set for context level beforetest) - procedure sys_ctx_on_beforetest; - - --%test(set for context level test) - procedure sys_ctx_on_test; - - --%test(set for context level aftertest) - procedure sys_ctx_on_aftertest; - - --%test(set for context level aftereach) - procedure sys_ctx_on_aftereach; - - --%test(set for context level afterall) - procedure sys_ctx_on_context_afterall; - - --%test(set for suite level afterall) - procedure sys_ctx_on_suite_afterall; - - --%test(is cleared after run) - procedure sys_ctx_clear_after_run; - - --%test(application info is restored after run) - procedure app_info_restore_after_run; - - --%endcontext - -end; -/ - diff --git a/test/ut3_user/api/test_ut_runner.pkb b/test/ut3_user/api/test_ut_runner.pkb deleted file mode 100644 index d665718e1..000000000 --- a/test/ut3_user/api/test_ut_runner.pkb +++ /dev/null @@ -1,658 +0,0 @@ -create or replace package body test_ut_runner is - - procedure setup_cache_objects is - begin - 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 - begin - ut3_tester_helper.run_helper.setup_cache(); - end; - - procedure cleanup_cache is - begin - ut3_tester_helper.run_helper.cleanup_cache(); - end; - - procedure create_test_spec - as - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_cache as - --%suite - - --%test - procedure failing_test; -end; -]'; - end; - - procedure create_test_body(a_number integer) - as - pragma autonomous_transaction; - begin - execute immediate 'create or replace package body test_cache as - procedure failing_test is - begin - ut3_develop.ut.expect('||a_number||').to_be_null; - end; -end;'; - end; - - procedure drop_test_package - as - pragma autonomous_transaction; - begin - execute immediate 'drop package test_cache'; - end; - - - - procedure keep_an_open_transaction is - l_expected varchar2(300); - l_output_data dbms_output.chararr; - l_num_lines integer := 100000; - begin - --Arrange - create_test_spec(); - create_test_body(0); - l_expected := dbms_transaction.local_transaction_id(true); - --Act - ut3_develop.ut.run('test_cache'); - dbms_output.get_lines( l_output_data, l_num_lines); - --Assert - ut.expect(dbms_transaction.local_transaction_id()).to_equal(l_expected); - drop_test_package(); - 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(); - create_test_body(0); - rollback; - --Act - ut3_develop.ut.run('test_cache'); - dbms_output.get_lines( l_output_data, l_num_lines); - --Assert - ut.expect(dbms_transaction.local_transaction_id()).to_be_null(); - drop_test_package(); - end; - - procedure version_comp_check_compare is - begin - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.0.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.123.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.123.0.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.13.31.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.1.0','v3.0.0.0') ).to_equal(0); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.1.0.0','v3.0.0.0') ).to_equal(0); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v2.0.0.0') ).to_equal(0); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v4.0.0.0') ).to_equal(0); - end; - - procedure version_comp_check_ignore is - begin - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.123','v3.0.0.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0.0','v3.0.0.123') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0','v3.0.0.0') ).to_equal(1); - end; - - procedure version_comp_check_short is - begin - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0.0','v3.0.0.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3.0','v3.0.123.0') ).to_equal(1); - ut.expect( ut3_develop.ut_runner.version_compatibility_check('v3','v3.123.0.0') ).to_equal(1); - end; - - procedure version_comp_check_exception is - procedure throws(a_requested varchar2, a_current varchar2) is - l_compatible integer; - begin - l_compatible := ut3_develop.ut_runner.version_compatibility_check(a_requested,a_current); - ut.fail('Expected exception but nothing was raised'); - exception - when others then - ut.expect(sqlcode).to_equal(-20214); - end; - begin - throws('bad_ver','v3.0.0.0'); - throws('v3.0.0.0','bad_ver'); - end; - - procedure run_reset_package_body_cache is - l_results ut3_develop.ut_varchar2_list; - l_expected clob; - l_actual clob; - begin - --Arrange - create_test_spec(); - create_test_body(0); - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_cache')); - - --Act - create_test_body(1); - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_cache')); - --Assert - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - l_expected := '%ut3_develop.ut.expect(1).to_be_null;%'; - ut.expect(l_actual).to_be_like(l_expected); - drop_test_package(); - end; - - procedure run_keep_dbms_output_buffer is - l_expected dbmsoutput_linesarray; - l_actual dbmsoutput_linesarray; - l_results ut3_develop.ut_varchar2_list; - l_lines number := 10000; - begin - --Arrange - create_test_spec(); - create_test_body(0); - - l_expected := dbmsoutput_linesarray( - 'A text placed into DBMS_OUTPUT', - 'Another line', - lpad('A very long line',10000,'a') - ); - for i in 1 .. 300 loop - l_expected.extend; - l_expected(l_expected.last) := 'line '||i; - end loop; - - for i in 1 .. l_expected.count loop - dbms_output.put_line(l_expected(i)); - end loop; - - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_cache')); - - --Assert - dbms_output.get_lines(lines => l_actual, numlines => l_lines); - for i in 1 .. l_lines loop - ut.expect(l_actual(i)).to_equal(l_expected(i)); - end loop; - drop_test_package(); - end; - - procedure test_purge_cache_schema_type is - l_actual sys_refcursor; - begin - --Arrange - l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( - a_owner => sys_context('USERENV', 'CURRENT_USER'), - a_type => 'PROCEDURE' - ); - - ut.expect(l_actual).not_to_be_empty(); - - --Act - ut3_develop.ut_runner.purge_cache(sys_context('USERENV', 'CURRENT_USER'),'PROCEDURE'); - - --Assert - - l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( - a_owner => sys_context('USERENV', 'CURRENT_USER'), - a_type => 'PROCEDURE' - ); - --Cache purged for object owner/type - ut.expect(l_actual).to_be_empty(); - - l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( - a_owner => sys_context('USERENV', 'CURRENT_USER'), - a_type => 'PACKAGE' - ); - --Cache not purged for other types - ut.expect(l_actual).not_to_be_empty(); - - l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( - a_owner => 'UT3_TESTER_HELPER', - a_type => 'PROCEDURE' - ); - --Cache not purged for other owners - ut.expect(l_actual).not_to_be_empty(); - - end; - - procedure test_rebuild_cache_schema_type is - l_actual sys_refcursor; - begin - --Act - ut3_develop.ut_runner.rebuild_annotation_cache( sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE' ); - --Assert - l_actual := ut3_tester_helper.run_helper.get_annotation_cache_cursor( - a_owner => sys_context('USERENV', 'CURRENT_USER'), - a_type => 'PACKAGE', - a_name => 'DUMMY_TEST_PACKAGE' - ); - - --Rebuild cache for sys_context('USERENV', 'CURRENT_USER')/packages - ut.expect(l_actual).to_have_count(4); - - l_actual := ut3_tester_helper.run_helper.get_annotation_cache_cursor( - a_owner => sys_context('USERENV', 'CURRENT_USER'), - a_type => 'PACKAGE' - ); - - --Did not rebuild cache for ut3_develop/procedures - ut.expect(l_actual).to_have_count(0); - end; - - procedure test_get_suites_info_notag 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, - 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,null 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, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,null tags - from dual union all - select - 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, - null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null disabled_reason, null tags - from dual union all - select - 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, - null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null disabled_reason, null tags - from dual; - --Act - open l_actual for select * from table(ut3_develop.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, - 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,'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, 7 item_line_no, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,'testtag' tags - from dual union all - select - 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, - null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null disabled_reason, null tags - from dual union all - select - 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, - null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null disabled_reason, null tags - from dual; - --Act - open l_actual for select * from table(ut3_develop.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, null disabled_reason,'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, null disabled_reason,'testtag1,testtag2' tags - from dual; - --Act - open l_actual for select * from table(ut3_develop.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_by_path 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, - 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason,null 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, - 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason,null tags - from dual union all - select - 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, - null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some.path' path, 0 disabled_flag, null disabled_reason, null tags - from dual union all - select - 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, - null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, - 'some' path, 0 disabled_flag, null disabled_reason, null tags - from dual; - --Act - open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('ut3_user:some.path.dummy_test_package')); - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure test_get_reporters_list is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for - select 'UT3_DEVELOP.UT_COVERAGE_COBERTURA_REPORTER' reporter_object_name, 'Y' is_output_reporter from dual union all - select 'UT3_DEVELOP.UT_DEBUG_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_COVERAGE_HTML_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_COVERAGE_SONAR_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_COVERALLS_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_DOCUMENTATION_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_JUNIT_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_REALTIME_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_SONAR_TEST_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_TEAMCITY_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_TFS_JUNIT_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_XUNIT_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_TAP_REPORTER', 'Y' from dual - order by 1; - --Act - open l_actual for select * from table(ut3_develop.ut_runner.GET_REPORTERS_LIST()) order by 1; - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure db_link_cleanup is - pragma autonomous_transaction; - begin - ut3_tester_helper.run_helper.db_link_cleanup(); - end; - - procedure db_link_setup is - pragma autonomous_transaction; - begin - ut3_tester_helper.run_helper.db_link_setup(); - end; - - procedure raises_20213_on_fail_link is - l_reporter ut3_develop.ut_documentation_reporter := ut3_develop.ut_documentation_reporter(); - l_lines ut3_develop.ut_varchar2_list; - pragma autonomous_transaction; - begin - --Arrange - --Act - ut3_develop.ut_runner.run(ut3_develop.ut_varchar2_list('test_db_link'), ut3_develop.ut_reporters(l_reporter), a_fail_on_errors=> true); - ut.fail('Expected exception but nothing was raised'); - exception - when others then - --Assert - ut.expect(sqlcode).to_equal(-20213); - ut.expect(dbms_utility.format_error_stack||dbms_utility.format_error_backtrace).not_to_be_like('%ORA-02055%'); - end; - - procedure create_test_csl_packages is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package test_csl_names1 as - --%suite - --%suitepath(test_csl_names) - - --%test - procedure one_is_one; - - --%test - procedure two_is_two; - - end; - ]'; - - execute immediate q'{ - create or replace package body test_csl_names1 as - - procedure one_is_one is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - - procedure two_is_two is - begin - ut3_develop.ut.expect(2).to_equal(2); - end; - - end; - }'; - - execute immediate q'[ - create or replace package test_csl_names2 as - --%suite - --%suitepath(test_csl_names) - - --%test - procedure one_is_one; - - --%test - procedure two_is_two; - - end; - ]'; - - execute immediate q'{ - create or replace package body test_csl_names2 as - - procedure one_is_one is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - - procedure two_is_two is - begin - ut3_develop.ut.expect(2).to_equal(2); - end; - - end; - }'; - - end; - - procedure drop_test_csl_packages is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_csl_names1'; - execute immediate 'drop package test_csl_names2'; - end; - - procedure pass_varchar2_name_list is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run(ut3_develop.ut_varchar2_list('test_csl_names1','test_csl_names2'))); - - 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; - - procedure pass_varchar2_name is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_csl_names1')); - - 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; - - procedure pass_varchar2_suite_csl is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_csl_names1,test_csl_names2')); - - 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; - - procedure pass_varchar2_test_csl is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_csl_names1.one_is_one,test_csl_names2.one_is_one')); - - 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; - - procedure pass_varch_test_csl_spc is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_csl_names1.one_is_one, test_csl_names2.one_is_one')); - - 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; - - procedure pass_csl_with_srcfile is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - - select * - bulk collect into l_results - from table( - ut3_develop.ut.run( - a_path => 'test_csl_names1.one_is_one,test_csl_names2.one_is_one', - a_source_files => ut3_develop.ut_varchar2_list('ut3_develop.ut'), - a_test_files => ut3_develop.ut_varchar2_list('ut3_tester.test_csl_names2') - ) - ); - - 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; - - procedure pass_csl_within_var2list is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run(ut3_develop.ut_varchar2_list('test_csl_names1.one_is_one,test_csl_names2.one_is_one'))); - - 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; - - procedure is_test_true is - begin - ut.expect( - ut3_develop.ut_runner.is_test( - a_owner => 'UT3_USER', - a_package_name => 'DUMMY_TEST_PACKAGE', - a_procedure_name => 'SOME_DUMMY_TEST_PROCEDURE' - ) - ).to_be_true(); - ut.expect( ut3_develop.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_develop.ut_runner.is_test( 'UT3_USER','DUMMY_TEST_PACKAGE', 'BAD' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER','BAD_TEST_PACKAGE', 'some_dummy_test_procedure' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER','DUMMY_TEST_PACKAGE', null ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_test( 'UT3_USER',null,'some_dummy_test_procedure' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_test( null,'DUMMY_TEST_PACKAGE','some_dummy_test_procedure' ) ).to_be_false(); - end; - - procedure is_suite_true is - begin - ut.expect( - ut3_develop.ut_runner.is_suite( - a_owner => 'UT3_USER', - a_package_name => 'DUMMY_TEST_PACKAGE' - ) - ).to_be_true(); - - ut.expect( ut3_develop.ut_runner.is_suite( 'ut3_user','dummy_test_package' ) ).to_be_true(); - end; - - procedure is_suite_false is - begin - ut.expect( ut3_develop.ut_runner.is_suite( 'UT3_USER','BAD' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_suite( 'UT3_USER', null ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_suite( null,'DUMMY_TEST_PACKAGE' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.is_suite( 'UT3_USER','bad_test_package' ) ).to_be_false(); - end; - - procedure has_suites_true is - begin - ut.expect( ut3_develop.ut_runner.has_suites( a_owner => 'UT3_USER' ) ).to_be_true(); - ut.expect( ut3_develop.ut_runner.has_suites( 'ut3_user' ) ).to_be_true(); - end; - - procedure has_suites_false is - begin - ut.expect( ut3_develop.ut_runner.has_suites( 'UT3' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.has_suites( 'BAD' ) ).to_be_false(); - ut.expect( ut3_develop.ut_runner.has_suites( null ) ).to_be_false(); - end; - -end; -/ diff --git a/test/ut3_user/api/test_ut_runner.pks b/test/ut3_user/api/test_ut_runner.pks deleted file mode 100644 index e003ba852..000000000 --- a/test/ut3_user/api/test_ut_runner.pks +++ /dev/null @@ -1,153 +0,0 @@ -create or replace package test_ut_runner is - - --%suite(ut_runner) - --%suitepath(utplsql.test_user.api) - --%rollback(manual) - - --%test(transaction stays open after the run if it was opened before the run) - procedure keep_an_open_transaction; - - --%test(closes open transactions if no transaction was open before run) - procedure close_newly_opened_transaction; - - --%context(version_compatibility_check) - - --%test(compares major, minor and bugfix number) - procedure version_comp_check_compare; - - --%test(ignores build number) - procedure version_comp_check_ignore; - - --%test(compares short version to a full version) - procedure version_comp_check_short; - - --%test(raises exception when invalid version passed) - procedure version_comp_check_exception; - - --%endcontext - - --%test(run resets cache of package body after every run) - procedure run_reset_package_body_cache; - - --%test(does not consume dbms_output from before the run) - procedure run_keep_dbms_output_buffer; - - procedure setup_cache; - procedure cleanup_cache; - - --%test(Purges cache for a given schema and object type) - --%beforetest(setup_cache) - --%aftertest(cleanup_cache) - 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_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_suites_info returns a cursor containing records for a newly created test with passed path) - --%beforetest(setup_cache_objects) - --%aftertest(cleanup_cache) - procedure test_get_suites_info_by_path; - - --%test(get_reporters_list returns a cursor containing all built-in reporters and information about output-reporter) - --%beforetest(setup_cache_objects) - --%aftertest(cleanup_cache) - procedure test_get_reporters_list; - - procedure db_link_cleanup; - procedure db_link_setup; - - --%test(ORA-20213 is thrown with a_raise_on_failure when database link operations are used - regression) - --%beforetest(db_link_setup) - --%aftertest(db_link_cleanup) - procedure raises_20213_on_fail_link; - - procedure create_test_csl_packages; - procedure drop_test_csl_packages; - - --%context(ut_run_coma_sep_list) - --%beforeall(create_test_csl_packages) - --%afterall(drop_test_csl_packages) - - --%test( Pass name of tests as varchar2_list ) - procedure pass_varchar2_name_list; - - --%test( Pass single test name as varchar2 ) - procedure pass_varchar2_name; - - --%test( Pass coma separated list of suite names ) - procedure pass_varchar2_suite_csl; - - --%test( Pass coma separated list of test names ) - procedure pass_varchar2_test_csl; - - --%test( Pass coma separated list of test names with spaces ) - procedure pass_varch_test_csl_spc; - - --%test( Pass coma separated list and source and test files ) - procedure pass_csl_with_srcfile; - - --%test( Pass coma separated list in varchar2list ) - procedure pass_csl_within_var2list; - - --%endcontext - - --%context(is_test) - --%beforeall(setup_cache_objects) - --%afterall(cleanup_cache) - - --%test(Returns true when procedure is a test) - procedure is_test_true; - - --%test(Returns false when procedure is not a test) - procedure is_test_false; - - --%endcontext - - --%context(is_suite) - --%beforeall(setup_cache_objects) - --%afterall(cleanup_cache) - - --%test(Returns true when package is a test suite) - procedure is_suite_true; - - --%test(Returns false when package is not a test suite) - procedure is_suite_false; - - --%endcontext - - --%context(has_suites) - --%beforeall(setup_cache_objects) - --%afterall(cleanup_cache) - - --%test(Returns true when schema contains test suites) - procedure has_suites_true; - - --%test(Returns false when schema does not contain test suites) - procedure has_suites_false; - - --%endcontext - -end; -/ diff --git a/test/ut3_user/expectations.pkb b/test/ut3_user/expectations.pkb deleted file mode 100644 index be8627712..000000000 --- a/test/ut3_user/expectations.pkb +++ /dev/null @@ -1,60 +0,0 @@ -create or replace package body expectations as - - procedure inline_expectation_to_dbms_out is - l_expected clob; - l_actual clob; - pragma autonomous_transaction; - begin - --Arrange - --Act - execute immediate 'begin some_pkg.some_procedure; end;'; - ut3_develop.ut.expect(1).to_equal(0); - ut3_develop.ut.expect(0).to_equal(0); - - --Assert - l_actual := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); - - l_expected := q'[FAILURE - Actual: 1 (number) was expected to equal: 0 (number) - at "UT3_USER.SOME_PKG%", line 4 ut3_develop.ut.expect(1).to_equal(0); - at "anonymous block", line 1 - at "UT3_USER.EXPECTATIONS%", line 10 -SUCCESS - Actual: 0 (number) was expected to equal: 0 (number) -FAILURE - Actual: 1 (number) was expected to equal: 0 (number) - at "UT3_USER.EXPECTATIONS%", line 11 ut3_develop.ut.expect(1).to_equal(0); -SUCCESS - Actual: 0 (number) was expected to equal: 0 (number) -]'; - - ut.expect(l_actual).to_be_like(l_expected); - rollback; - end; - - procedure create_some_pkg is - pragma autonomous_transaction; - begin - execute immediate q'[ - create or replace package some_pkg is - procedure some_procedure; - end;]'; - - execute immediate q'[ - create or replace package body some_pkg is - procedure some_procedure is - begin - ut3_develop.ut.expect(1).to_equal(0); - ut3_develop.ut.expect(0).to_equal(0); - end; - end;]'; - end; - - procedure drop_some_pkg is - pragma autonomous_transaction; - begin - execute immediate 'drop package some_pkg'; - end; - -end; -/ \ No newline at end of file diff --git a/test/ut3_user/expectations.pks b/test/ut3_user/expectations.pks deleted file mode 100644 index 0324f9ac0..000000000 --- a/test/ut3_user/expectations.pks +++ /dev/null @@ -1,18 +0,0 @@ -create or replace package expectations as - --%suite - --%suitepath(utplsql.test_user) - - --%beforeall(ut3_tester_helper.main_helper.set_ut_run_context) - - --%afterall(ut3_tester_helper.main_helper.clear_ut_run_context) - - --%test(Expectations return data to screen when called standalone) - --%beforetest( create_some_pkg, ut3_tester_helper.main_helper.clear_ut_run_context ) - --%aftertest( drop_some_pkg, ut3_tester_helper.main_helper.set_ut_run_context ) - procedure inline_expectation_to_dbms_out; - - procedure create_some_pkg; - procedure drop_some_pkg; - -end; -/ \ No newline at end of file diff --git a/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb deleted file mode 100644 index 3f92c84c7..000000000 --- a/test/ut3_user/expectations/binary/test_be_greater_or_equal.pkb +++ /dev/null @@ -1,263 +0,0 @@ -create or replace package body test_be_greater_or_equal is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function to_greater_equal_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - 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; - - function not_to_greater_equal_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - 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; - - procedure actual_date_greater is - begin - --Act - execute immediate to_greater_equal_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_number_greater is - begin - --Act - execute immediate to_greater_equal_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ym_greater is - begin - --Act - execute immediate to_greater_equal_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ds_greater is - begin - --Act - execute immediate to_greater_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_greater is - begin - --Act - execute immediate to_greater_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_tz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_ltz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_date_equal is - begin - --Act - execute immediate to_greater_equal_block('date', 'sysdate', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_number_equal is - begin - --Act - execute immediate to_greater_equal_block('number', '2.0', '2.00'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ym_equal is - begin - --Act - execute immediate to_greater_equal_block('interval year to month', '''2-1''', '''2-1'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ds_equal is - begin - --Act - execute immediate to_greater_equal_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_equal is - begin - --Act - execute immediate to_greater_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_tz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_ltz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_date_less is - begin - --Act - execute immediate to_greater_equal_block('date', 'sysdate-1', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_number_less is - begin - --Act - execute immediate to_greater_equal_block('number', '1.0', '1.01'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ym_less is - begin - --Act - execute immediate to_greater_equal_block('interval year to month', '''2-1''', '''2-2'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ds_less is - begin - --Act - execute immediate to_greater_equal_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_less is - begin - --Act - execute immediate to_greater_equal_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_tz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_ltz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_date_greater is - begin - --Act - execute immediate not_to_greater_equal_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_number_greater is - begin - --Act - execute immediate not_to_greater_equal_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_interval_ym_greater is - begin - --Act - execute immediate not_to_greater_equal_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_interval_ds_greater is - begin - --Act - execute immediate not_to_greater_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_timestamp_greater is - begin - --Act - execute immediate not_to_greater_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_timestamp_tz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_timestamp_ltz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_clob is - begin - --Act - ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_greater_or_equal(3) ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_be_greater_or_equal.pks b/test/ut3_user/expectations/binary/test_be_greater_or_equal.pks deleted file mode 100644 index 3f51e8e3f..000000000 --- a/test/ut3_user/expectations/binary/test_be_greater_or_equal.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_be_greater_or_equal is - - --%suite((not)to_be_greater_or_equal) - --%suitepath(utplsql.test_user.expectations.binary) - - --%aftereach - procedure cleanup_expectations; - - --%test(Gives success when actual date is greater than expected) - procedure actual_date_greater; - - --%test(Gives success when actual number is greater than expected) - procedure actual_number_greater; - - --%test(Gives success when actual interval year to month is greater than expected) - procedure actual_interval_ym_greater; - - --%test(Gives success when actual interval day to second is greater than expected) - procedure actual_interval_ds_greater; - - --%test(Gives success when actual timestamp is greater than expected) - procedure actual_timestamp_greater; - - --%test(Gives success when actual timestamp with time zone is greater than expected) - procedure actual_timestamp_tz_greater; - - --%test(Gives success when actual timestamp with local time zone is greater than expected) - procedure actual_timestamp_ltz_greater; - - --%test(Gives success when actual date is equal expected) - procedure actual_date_equal; - - --%test(Gives success when actual number is equal expected) - procedure actual_number_equal; - - --%test(Gives success when actual interval year to month is equal expected) - procedure actual_interval_ym_equal; - - --%test(Gives success when actual interval day to second is equal expected) - procedure actual_interval_ds_equal; - - --%test(Gives success when actual timestamp is equal expected) - procedure actual_timestamp_equal; - - --%test(Gives success when actual timestamp with time zone is equal expected) - procedure actual_timestamp_tz_equal; - - --%test(Gives success when actual timestamp with local time zone is equal expected) - procedure actual_timestamp_ltz_equal; - - --%test(Gives failure when actual date is less than expected) - procedure actual_date_less; - - --%test(Gives failure when actual number is less than expected) - procedure actual_number_less; - - --%test(Gives failure when actual interval year to month is less than expected) - procedure actual_interval_ym_less; - - --%test(Gives failure when actual interval day to second is less than expected) - procedure actual_interval_ds_less; - - --%test(Gives failure when actual timestamp is less than expected) - procedure actual_timestamp_less; - - --%test(Gives failure when actual timestamp with time zone is less than expected) - procedure actual_timestamp_tz_less; - - --%test(Gives failure when actual timestamp with local time zone is less than expected) - procedure actual_timestamp_ltz_less; - - --%test(Negated - Gives failure when actual date is greater than expected) - procedure not_actual_date_greater; - - --%test(Negated - Gives failure when actual number is greater than expected) - procedure not_actual_number_greater; - - --%test(Negated - Gives failure when actual interval year to month is greater than expected) - procedure not_actual_interval_ym_greater; - - --%test(Negated - Gives failure when actual interval day to second is greater than expected) - procedure not_actual_interval_ds_greater; - - --%test(Negated - Gives failure when actual timestamp is greater than expected) - procedure not_actual_timestamp_greater; - - --%test(Negated - Gives failure when actual timestamp with time zone is greater than expected) - procedure not_actual_timestamp_tz_gretr; - - --%test(Negated - Gives failure when actual timestamp with local time zone is greater than expected) - procedure not_actual_timestamp_ltz_gretr; - - --%test(Gives failure when running against CLOB) - procedure actual_clob; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_be_greater_than.pkb b/test/ut3_user/expectations/binary/test_be_greater_than.pkb deleted file mode 100644 index 6724b5c41..000000000 --- a/test/ut3_user/expectations/binary/test_be_greater_than.pkb +++ /dev/null @@ -1,263 +0,0 @@ -create or replace package body test_be_greater_than is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function to_greater_than_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - return ut3_tester_helper.expectations_helper.binary_expectation_block( - 'to_be_greater_than', a_data_type, a_actual, a_data_type, a_expected - ); - end; - - function not_to_greater_than_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - 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; - - procedure actual_date_greater is - begin - --Act - execute immediate to_greater_than_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_number_greater is - begin - --Act - execute immediate to_greater_than_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ym_greater is - begin - --Act - execute immediate to_greater_than_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ds_greater is - begin - --Act - execute immediate to_greater_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_greater is - begin - --Act - execute immediate to_greater_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_tz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_ltz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_date_equal is - begin - --Act - execute immediate to_greater_than_block('date', 'sysdate', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_number_equal is - begin - --Act - execute immediate to_greater_than_block('number', '2.0', '2.00'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ym_equal is - begin - --Act - execute immediate to_greater_than_block('interval year to month', '''2-1''', '''2-1'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ds_equal is - begin - --Act - execute immediate to_greater_than_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_equal is - begin - --Act - execute immediate to_greater_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_tz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_ltz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_date_less is - begin - --Act - execute immediate to_greater_than_block('date', 'sysdate-1', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_number_less is - begin - --Act - execute immediate to_greater_than_block('number', '1.0', '1.01'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ym_less is - begin - --Act - execute immediate to_greater_than_block('interval year to month', '''2-1''', '''2-2'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ds_less is - begin - --Act - execute immediate to_greater_than_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_less is - begin - --Act - execute immediate to_greater_than_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_tz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_ltz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_date_greater is - begin - --Act - execute immediate not_to_greater_than_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_number_greater is - begin - --Act - execute immediate not_to_greater_than_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_interval_ym_greater is - begin - --Act - execute immediate not_to_greater_than_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_interval_ds_greater is - begin - --Act - execute immediate not_to_greater_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_timestamp_greater is - begin - --Act - execute immediate not_to_greater_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_timestamp_tz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_actual_timestamp_ltz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_clob is - begin - --Act - ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_greater_than(2) ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_be_greater_than.pks b/test/ut3_user/expectations/binary/test_be_greater_than.pks deleted file mode 100644 index fb158dddb..000000000 --- a/test/ut3_user/expectations/binary/test_be_greater_than.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_be_greater_than is - - --%suite((not)to_be_greater_than) - --%suitepath(utplsql.test_user.expectations.binary) - - --%aftereach - procedure cleanup_expectations; - - --%test(Gives success when actual date is greater than expected) - procedure actual_date_greater; - - --%test(Gives success when actual number is greater than expected) - procedure actual_number_greater; - - --%test(Gives success when actual interval year to month is greater than expected) - procedure actual_interval_ym_greater; - - --%test(Gives success when actual interval day to second is greater than expected) - procedure actual_interval_ds_greater; - - --%test(Gives success when actual timestamp is greater than expected) - procedure actual_timestamp_greater; - - --%test(Gives success when actual timestamp with time zone is greater than expected) - procedure actual_timestamp_tz_greater; - - --%test(Gives success when actual timestamp with local time zone is greater than expected) - procedure actual_timestamp_ltz_greater; - - --%test(Gives failure when actual date is equal expected) - procedure actual_date_equal; - - --%test(Gives failure when actual number is equal expected) - procedure actual_number_equal; - - --%test(Gives failure when actual interval year to month is equal expected) - procedure actual_interval_ym_equal; - - --%test(Gives failure when actual interval day to second is equal expected) - procedure actual_interval_ds_equal; - - --%test(Gives failure when actual timestamp is equal expected) - procedure actual_timestamp_equal; - - --%test(Gives failure when actual timestamp with time zone is equal expected) - procedure actual_timestamp_tz_equal; - - --%test(Gives failure when actual timestamp with local time zone is equal expected) - procedure actual_timestamp_ltz_equal; - - --%test(Gives failure when actual date is less than expected) - procedure actual_date_less; - - --%test(Gives failure when actual number is less than expected) - procedure actual_number_less; - - --%test(Gives failure when actual interval year to month is less than expected) - procedure actual_interval_ym_less; - - --%test(Gives failure when actual interval day to second is less than expected) - procedure actual_interval_ds_less; - - --%test(Gives failure when actual timestamp is less than expected) - procedure actual_timestamp_less; - - --%test(Gives failure when actual timestamp with time zone is less than expected) - procedure actual_timestamp_tz_less; - - --%test(Gives failure when actual timestamp with local time zone is less than expected) - procedure actual_timestamp_ltz_less; - - --%test(Negated - Gives failure when actual date is greater than expected) - procedure not_actual_date_greater; - - --%test(Negated - Gives failure when actual number is greater than expected) - procedure not_actual_number_greater; - - --%test(Negated - Gives failure when actual interval year to month is greater than expected) - procedure not_actual_interval_ym_greater; - - --%test(Negated - Gives failure when actual interval day to second is greater than expected) - procedure not_actual_interval_ds_greater; - - --%test(Negated - Gives failure when actual timestamp is greater than expected) - procedure not_actual_timestamp_greater; - - --%test(Negated - Gives failure when actual timestamp with time zone is greater than expected) - procedure not_actual_timestamp_tz_gretr; - - --%test(Negated - Gives failure when actual timestamp with local time zone is greater than expected) - procedure not_actual_timestamp_ltz_gretr; - - --%test(Gives failure when running against CLOB) - procedure actual_clob; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb b/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb deleted file mode 100644 index aefb58849..000000000 --- a/test/ut3_user/expectations/binary/test_be_less_or_equal.pkb +++ /dev/null @@ -1,263 +0,0 @@ -create or replace package body test_be_less_or_equal is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function to_less_or_equal_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - 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; - - function not_to_less_or_equal_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - 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; - - procedure actual_date_greater is - begin - --Act - execute immediate to_less_or_equal_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_number_greater is - begin - --Act - execute immediate to_less_or_equal_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ym_greater is - begin - --Act - execute immediate to_less_or_equal_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ds_greater is - begin - --Act - execute immediate to_less_or_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_greater is - begin - --Act - execute immediate to_less_or_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_tz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_ltz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_date_equal is - begin - --Act - execute immediate to_less_or_equal_block('date', 'sysdate', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_number_equal is - begin - --Act - execute immediate to_less_or_equal_block('number', '2.0', '2.00'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ym_equal is - begin - --Act - execute immediate to_less_or_equal_block('interval year to month', '''2-1''', '''2-1'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ds_equal is - begin - --Act - execute immediate to_less_or_equal_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_equal is - begin - --Act - execute immediate to_less_or_equal_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_tz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_ltz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_date_less is - begin - --Act - execute immediate to_less_or_equal_block('date', 'sysdate-1', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_number_less is - begin - --Act - execute immediate to_less_or_equal_block('number', '1.0', '1.01'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ym_less is - begin - --Act - execute immediate to_less_or_equal_block('interval year to month', '''2-1''', '''2-2'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ds_less is - begin - --Act - execute immediate to_less_or_equal_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_less is - begin - --Act - execute immediate to_less_or_equal_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_tz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_ltz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_date_greater is - begin - --Act - execute immediate not_to_less_or_equal_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_number_greater is - begin - --Act - execute immediate not_to_less_or_equal_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_interval_ym_greater is - begin - --Act - execute immediate not_to_less_or_equal_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_interval_ds_greater is - begin - --Act - execute immediate not_to_less_or_equal_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_timestamp_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_timestamp_tz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_timestamp_ltz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_clob is - begin - --Act - ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_less_or_equal(3) ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_be_less_or_equal.pks b/test/ut3_user/expectations/binary/test_be_less_or_equal.pks deleted file mode 100644 index d6baf037e..000000000 --- a/test/ut3_user/expectations/binary/test_be_less_or_equal.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_be_less_or_equal is - - --%suite((not)to_be_less_or_equal) - --%suitepath(utplsql.test_user.expectations.binary) - - --%aftereach - procedure cleanup_expectations; - - --%test(Gives failure when actual date is greater than expected) - procedure actual_date_greater; - - --%test(Gives failure when actual number is greater than expected) - procedure actual_number_greater; - - --%test(Gives failure when actual interval year to month is greater than expected) - procedure actual_interval_ym_greater; - - --%test(Gives failure when actual interval day to second is greater than expected) - procedure actual_interval_ds_greater; - - --%test(Gives failure when actual timestamp is greater than expected) - procedure actual_timestamp_greater; - - --%test(Gives failure when actual timestamp with time zone is greater than expected) - procedure actual_timestamp_tz_greater; - - --%test(Gives failure when actual timestamp with local time zone is greater than expected) - procedure actual_timestamp_ltz_greater; - - --%test(Gives success when actual date is equal expected) - procedure actual_date_equal; - - --%test(Gives success when actual number is equal expected) - procedure actual_number_equal; - - --%test(Gives success when actual interval year to month is equal expected) - procedure actual_interval_ym_equal; - - --%test(Gives success when actual interval day to second is equal expected) - procedure actual_interval_ds_equal; - - --%test(Gives success when actual timestamp is equal expected) - procedure actual_timestamp_equal; - - --%test(Gives success when actual timestamp with time zone is equal expected) - procedure actual_timestamp_tz_equal; - - --%test(Gives success when actual timestamp with local time zone is equal expected) - procedure actual_timestamp_ltz_equal; - - --%test(Gives success when actual date is less than expected) - procedure actual_date_less; - - --%test(Gives success when actual number is less than expected) - procedure actual_number_less; - - --%test(Gives success when actual interval year to month is less than expected) - procedure actual_interval_ym_less; - - --%test(Gives success when actual interval day to second is less than expected) - procedure actual_interval_ds_less; - - --%test(Gives success when actual timestamp is less than expected) - procedure actual_timestamp_less; - - --%test(Gives success when actual timestamp with time zone is less than expected) - procedure actual_timestamp_tz_less; - - --%test(Gives success when actual timestamp with local time zone is less than expected) - procedure actual_timestamp_ltz_less; - - --%test(Negated - Gives success when actual date is greater than expected) - procedure not_actual_date_greater; - - --%test(Negated - Gives success when actual number is greater than expected) - procedure not_actual_number_greater; - - --%test(Negated - Gives success when actual interval year to month is greater than expected) - procedure not_actual_interval_ym_greater; - - --%test(Negated - Gives success when actual interval day to second is greater than expected) - procedure not_actual_interval_ds_greater; - - --%test(Negated - Gives success when actual timestamp is greater than expected) - procedure not_actual_timestamp_greater; - - --%test(Negated - Gives success when actual timestamp with time zone is greater than expected) - procedure not_actual_timestamp_tz_gretr; - - --%test(Negated - Gives success when actual timestamp with local time zone is greater than expected) - procedure not_actual_timestamp_ltz_gretr; - - --%test(Gives failure when running against CLOB) - procedure actual_clob; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_equal.pkb b/test/ut3_user/expectations/binary/test_equal.pkb deleted file mode 100644 index 735915348..000000000 --- a/test/ut3_user/expectations/binary/test_equal.pkb +++ /dev/null @@ -1,264 +0,0 @@ -create or replace package body test_equal is - - procedure reset_nulls_equal is - begin - ut3_tester_helper.main_helper.reset_nulls_equal; - end; - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function to_equal_block( - a_matcher_name varchar2, - a_actual_type varchar2, - a_expected_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_nulls_equal boolean := null - ) return varchar2 is - l_nulls_equal varchar2(10); - begin - l_nulls_equal := case when a_nulls_equal then 'true' when not a_nulls_equal then 'false' else 'null' end; - return ' - declare - l_actual '||a_actual_type||' := '||a_actual||'; - l_expected '||a_expected_type||' := '||a_expected||'; - begin - ut3_develop.ut.expect( l_actual ).'||a_matcher_name||'(l_expected, a_nulls_are_equal=>'||l_nulls_equal||'); - end;'; - end; - - procedure test_to_equal_success( - a_actual_type varchar2, - a_expected_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_nulls_equal boolean := null - ) is - begin - execute immediate - to_equal_block( 'to_equal', a_actual_type, a_expected_type, a_actual, a_expected, a_nulls_equal ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - cleanup_expectations; - end; - - procedure test_to_equal_success( - a_actual_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_nulls_equal boolean := null - ) is - begin - test_to_equal_success(a_actual_type, a_actual_type, a_actual, a_expected, a_nulls_equal); - end; - - - procedure test_to_equal_fail( - a_actual_type varchar2, - a_expected_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_nulls_equal boolean := null - ) is - begin - execute immediate - to_equal_block( 'to_equal', a_actual_type, a_expected_type, a_actual, a_expected, a_nulls_equal ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - cleanup_expectations; - end; - - procedure test_not_to_equal_fail( - a_actual_type varchar2, - a_expected_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_nulls_equal boolean := null - ) 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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - cleanup_expectations; - end; - - procedure test_to_equal_fail( - a_actual_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_nulls_equal boolean := null - ) is - begin - test_to_equal_fail(a_actual_type, a_actual_type, a_actual, a_expected, a_nulls_equal); - end; - - procedure equal_fail_on_type_diff is - begin - test_to_equal_fail('boolean', 'integer', 'true', '1'); - test_to_equal_fail('integer', 'boolean', '1', 'true'); - test_to_equal_fail('blob', 'clob', 'to_blob(''ABC'')', '''ABC'''); - test_to_equal_fail('clob', 'blob', '''ABC''', 'to_blob(''ABC'')'); - test_to_equal_fail('clob', 'anydata', '''ABC''', 'null'); - test_to_equal_fail('anydata', 'sys_refcursor', 'null', 'null'); - test_to_equal_fail('sys_refcursor', 'anydata', 'null', 'null'); - test_to_equal_fail('clob', 'varchar2(4000)', '''Abc''', '''Abc'''); - test_to_equal_fail('date', 'timestamp', 'sysdate', 'sysdate'); - test_to_equal_fail('date', 'timestamp with local time zone', 'sysdate', 'sysdate'); - test_to_equal_fail('timestamp', 'date', 'sysdate', 'sysdate'); - test_to_equal_fail('timestamp with local time zone', 'timestamp', 'sysdate', 'sysdate'); - test_to_equal_fail('timestamp with local time zone', 'timestamp with time zone', 'sysdate', 'sysdate'); - test_to_equal_fail('number', 'varchar2(4000)', '1', '''1'''); - test_to_equal_fail('varchar2(4000)', 'number', '''1''', '1'); - test_to_equal_fail('varchar2(4000)', 'boolean', '''true''', 'true'); - test_to_equal_fail('interval day to second', 'interval year to month', '''2 01:00:00''', '''1-1'''); - test_to_equal_fail('interval year to month', 'interval day to second', '''1-1''', '''2 01:00:00'''); - end; - - procedure not_equal_fail_on_type_diff is - begin - test_not_to_equal_fail('boolean', 'integer', 'true', '1'); - test_not_to_equal_fail('integer', 'boolean', '1', 'true'); - test_not_to_equal_fail('blob', 'clob', 'to_blob(''ABC'')', '''ABC'''); - test_not_to_equal_fail('clob', 'blob', '''ABC''', 'to_blob(''ABC'')'); - test_not_to_equal_fail('clob', 'anydata', '''ABC''', 'null'); - test_not_to_equal_fail('anydata', 'sys_refcursor', 'null', 'null'); - test_not_to_equal_fail('sys_refcursor', 'anydata', 'null', 'null'); - test_not_to_equal_fail('clob', 'varchar2(4000)', '''Abc''', '''Abc'''); - test_not_to_equal_fail('date', 'timestamp', 'sysdate', 'sysdate'); - test_not_to_equal_fail('date', 'timestamp with local time zone', 'sysdate', 'sysdate'); - test_not_to_equal_fail('timestamp', 'date', 'sysdate', 'sysdate'); - test_not_to_equal_fail('timestamp with local time zone', 'timestamp', 'sysdate', 'sysdate'); - test_not_to_equal_fail('timestamp with local time zone', 'timestamp with time zone', 'sysdate', 'sysdate'); - test_not_to_equal_fail('number', 'varchar2(4000)', '1', '''1'''); - test_not_to_equal_fail('varchar2(4000)', 'number', '''1''', '1'); - test_not_to_equal_fail('varchar2(4000)', 'boolean', '''true''', 'true'); - test_not_to_equal_fail('interval day to second', 'interval year to month', '''2 01:00:00''', '''1-1'''); - test_not_to_equal_fail('interval year to month', 'interval day to second', '''1-1''', '''2 01:00:00'''); - end; - - procedure failure_on_data_diff is - begin - test_to_equal_fail('blob', 'to_blob(''abc'')', 'to_blob(''abd'')'); - test_to_equal_fail('boolean', 'false', 'true'); - test_to_equal_fail('boolean', 'true', 'false'); - test_to_equal_fail('clob', '''Abc''', '''abc'''); - test_to_equal_fail('date', 'sysdate', 'sysdate-1'); - test_to_equal_fail('number', '0.1', '0.3'); - test_to_equal_fail('timestamp', 'systimestamp', 'systimestamp'); - test_to_equal_fail('timestamp with local time zone', 'systimestamp', 'systimestamp'); - test_to_equal_fail('timestamp with time zone', 'systimestamp', 'systimestamp'); - test_to_equal_fail('varchar2(4000)', '''Abc''', '''abc'''); - test_to_equal_fail('interval day to second', '''2 01:00:00''', '''2 01:00:01'''); - test_to_equal_fail('interval year to month', '''1-1''', '''1-2'''); - end; - - procedure failure_on_actual_null is - begin - test_to_equal_fail('blob', 'NULL', 'to_blob(''abc'')'); - test_to_equal_fail('boolean', 'NULL', 'true'); - test_to_equal_fail('clob', 'NULL', '''abc'''); - test_to_equal_fail('date', 'NULL', 'sysdate'); - test_to_equal_fail('number', 'NULL', '1'); - test_to_equal_fail('timestamp', 'NULL', 'systimestamp'); - test_to_equal_fail('timestamp with local time zone', 'NULL', 'systimestamp'); - test_to_equal_fail('timestamp with time zone', 'NULL', 'systimestamp'); - test_to_equal_fail('varchar2(4000)', 'NULL', '''abc'''); - test_to_equal_fail('interval day to second', 'NULL', '''2 01:00:00'''); - test_to_equal_fail('interval year to month', 'NULL', '''1-1'''); - end; - - procedure failure_on_expected_null is - begin - test_to_equal_fail('blob', 'to_blob(''abc'')', 'NULL'); - test_to_equal_fail('boolean', 'true', 'NULL'); - test_to_equal_fail('clob', '''abc''', 'NULL'); - test_to_equal_fail('date', 'sysdate', 'NULL'); - test_to_equal_fail('number', '1234', 'NULL'); - test_to_equal_fail('timestamp', 'systimestamp', 'NULL'); - test_to_equal_fail('timestamp with local time zone', 'systimestamp', 'NULL'); - test_to_equal_fail('timestamp with time zone', 'systimestamp', 'NULL'); - test_to_equal_fail('varchar2(4000)', '''abc''', 'NULL'); - test_to_equal_fail('interval day to second', '''2 01:00:00''', 'NULL'); - test_to_equal_fail('interval year to month', '''1-1''', 'NULL'); - end; - - procedure failure_on_both_null_with_parm is - begin - test_to_equal_fail('blob', 'NULL', 'NULL', false); - test_to_equal_fail('boolean', 'NULL', 'NULL', false); - test_to_equal_fail('clob', 'NULL', 'NULL', false); - test_to_equal_fail('date', 'NULL', 'NULL', false); - test_to_equal_fail('number', 'NULL', 'NULL', false); - test_to_equal_fail('timestamp', 'NULL', 'NULL', false); - test_to_equal_fail('timestamp with local time zone', 'NULL', 'NULL', false); - test_to_equal_fail('timestamp with time zone', 'NULL', 'NULL', false); - test_to_equal_fail('varchar2(4000)', 'NULL', 'NULL', false); - test_to_equal_fail('interval day to second', 'NULL', 'NULL', false); - test_to_equal_fail('interval year to month', 'NULL', 'NULL', false); - end; - - procedure failure_on_both_null_with_conf is - begin - 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'); - test_to_equal_fail('date', 'NULL', 'NULL'); - test_to_equal_fail('number', 'NULL', 'NULL'); - test_to_equal_fail('timestamp', 'NULL', 'NULL'); - test_to_equal_fail('timestamp with local time zone', 'NULL', 'NULL'); - test_to_equal_fail('timestamp with time zone', 'NULL', 'NULL'); - test_to_equal_fail('varchar2(4000)', 'NULL', 'NULL'); - test_to_equal_fail('interval day to second', 'NULL', 'NULL'); - test_to_equal_fail('interval year to month', 'NULL', 'NULL'); - end; - - procedure success_on_equal_data is - begin - test_to_equal_success('blob', 'to_blob(''Abc'')', 'to_blob(''abc'')'); - test_to_equal_success('boolean', 'true', 'true'); - test_to_equal_success('clob', '''Abc''', '''Abc'''); - test_to_equal_success('date', 'sysdate', 'sysdate'); - test_to_equal_success('number', '12345', '12345'); - test_to_equal_success('timestamp(9)', 'to_Timestamp(''2016 123456789'',''yyyy ff'')', 'to_Timestamp(''2016 123456789'',''yyyy ff'')'); - test_to_equal_success('timestamp(9) with local time zone', 'to_Timestamp(''2016 123456789'',''yyyy ff'')', 'to_Timestamp(''2016 123456789'',''yyyy ff'')'); - test_to_equal_success('timestamp(9) with time zone', 'to_Timestamp(''2016 123456789'',''yyyy ff'')', 'to_Timestamp(''2016 123456789'',''yyyy ff'')'); - test_to_equal_success('varchar2(4000)', '''Abc''', '''Abc'''); - test_to_equal_success('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); - test_to_equal_success('interval year to month', '''1-1''', '''1-1'''); - end; - - procedure success_on_both_null is - begin - test_to_equal_success('blob', 'NULL', 'NULL'); - test_to_equal_success('boolean', 'NULL', 'NULL'); - test_to_equal_success('clob', 'NULL', 'NULL'); - test_to_equal_success('date', 'NULL', 'NULL'); - test_to_equal_success('number', 'NULL', 'NULL'); - test_to_equal_success('timestamp', 'NULL', 'NULL'); - test_to_equal_success('timestamp with local time zone', 'NULL', 'NULL'); - test_to_equal_success('timestamp with time zone', 'NULL', 'NULL'); - test_to_equal_success('varchar2(4000)', 'NULL', 'NULL'); - test_to_equal_success('interval day to second', 'NULL', 'NULL'); - test_to_equal_success('interval year to month', 'NULL', 'NULL'); - end; - - procedure success_on_both_null_with_parm is - begin - 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); - test_to_equal_success('date', 'NULL', 'NULL', true); - test_to_equal_success('number', 'NULL', 'NULL', true); - test_to_equal_success('timestamp', 'NULL', 'NULL', true); - test_to_equal_success('timestamp with local time zone', 'NULL', 'NULL', true); - test_to_equal_success('timestamp with time zone', 'NULL', 'NULL', true); - test_to_equal_success('varchar2(4000)', 'NULL', 'NULL', true); - test_to_equal_success('interval day to second', 'NULL', 'NULL', true); - test_to_equal_success('interval year to month', 'NULL', 'NULL', true); - end; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_equal.pks b/test/ut3_user/expectations/binary/test_equal.pks deleted file mode 100644 index 923d43a31..000000000 --- a/test/ut3_user/expectations/binary/test_equal.pks +++ /dev/null @@ -1,38 +0,0 @@ -create or replace package test_equal is - - --%suite((not)to_be_equal) - --%suitepath(utplsql.test_user.expectations.binary) - - procedure reset_nulls_equal; - - --%aftereach - procedure cleanup_expectations; - - --%test(Gives failure for different data types) - procedure equal_fail_on_type_diff; - --%test(Negated - gives failure for different data types) - procedure not_equal_fail_on_type_diff; - --%test(Gives failure for different data values) - procedure failure_on_data_diff; - --%test(Gives failure when actual is null) - procedure failure_on_actual_null; - --%test(Gives failure when expected is null) - procedure failure_on_expected_null; - --%test(Gives failure when both values are null and argument nulls_are_equal is false) - procedure failure_on_both_null_with_parm; - - --%test(Gives failure when both values are null and configuration nulls_are_equal is false) - --%aftertest(reset_nulls_equal) - procedure failure_on_both_null_with_conf; - - --%test(Gives success for equal values) - procedure success_on_equal_data; - --%test(Gives success when both values are null) - procedure success_on_both_null; - - --%test(Gives success when both values are null and argument nulls_are_equal is true) - --%aftertest(reset_nulls_equal) - procedure success_on_both_null_with_parm; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb deleted file mode 100644 index dbf6e30a4..000000000 --- a/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pkb +++ /dev/null @@ -1,263 +0,0 @@ -create or replace package body test_expect_to_be_less_than is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function to_be_less_than_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - return ut3_tester_helper.expectations_helper.binary_expectation_block( - 'to_be_less_than', a_data_type, a_actual, a_data_type, a_expected - ); - end; - - function not_to_be_less_than_block( - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2 - ) return varchar2 is - begin - 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; - - procedure actual_date_greater is - begin - --Act - execute immediate to_be_less_than_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_number_greater is - begin - --Act - execute immediate to_be_less_than_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ym_greater is - begin - --Act - execute immediate to_be_less_than_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ds_greater is - begin - --Act - execute immediate to_be_less_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_greater is - begin - --Act - execute immediate to_be_less_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 12'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_tz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_ltz_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_date_equal is - begin - --Act - execute immediate to_be_less_than_block('date', 'sysdate', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_number_equal is - begin - --Act - execute immediate to_be_less_than_block('number', '2.0', '2.00'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ym_equal is - begin - --Act - execute immediate to_be_less_than_block('interval year to month', '''2-1''', '''2-1'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_interval_ds_equal is - begin - --Act - execute immediate to_be_less_than_block('interval day to second', '''2 01:00:00''', '''2 01:00:00'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_equal is - begin - --Act - execute immediate to_be_less_than_block('timestamp', 'to_timestamp(''1997 13'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_tz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_timestamp_ltz_equal is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure actual_date_less is - begin - --Act - execute immediate to_be_less_than_block('date', 'sysdate-1', 'sysdate'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_number_less is - begin - --Act - execute immediate to_be_less_than_block('number', '1.0', '1.01'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ym_less is - begin - --Act - execute immediate to_be_less_than_block('interval year to month', '''2-1''', '''2-2'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_interval_ds_less is - begin - --Act - execute immediate to_be_less_than_block('interval day to second', '''2 00:59:58''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_less is - begin - --Act - execute immediate to_be_less_than_block('timestamp', 'to_timestamp(''1997 12'',''YYYY FF'')', 'to_timestamp(''1997 13'',''YYYY FF'')'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_tz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_timestamp_ltz_less is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_date_greater is - begin - --Act - execute immediate not_to_be_less_than_block('date', 'sysdate', 'sysdate-1'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_number_greater is - begin - --Act - execute immediate not_to_be_less_than_block('number', '2.0', '1.99'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_interval_ym_greater is - begin - --Act - execute immediate not_to_be_less_than_block('interval year to month', '''2-1''', '''2-0'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_interval_ds_greater is - begin - --Act - execute immediate not_to_be_less_than_block('interval day to second', '''2 01:00:00''', '''2 00:59:59'''); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_timestamp_greater is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_timestamp_tz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_actual_timestamp_ltz_gretr is - begin - --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(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure actual_clob is - begin - --Act - ut3_develop.ut.expect(to_clob('3')).to_( ut3_develop.be_less_than(4) ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pks b/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pks deleted file mode 100644 index c03f0d28e..000000000 --- a/test/ut3_user/expectations/binary/test_expect_to_be_less_than.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_expect_to_be_less_than is - - --%suite((not)to_be_less_than) - --%suitepath(utplsql.test_user.expectations.binary) - - --%aftereach - procedure cleanup_expectations; - - --%test(Gives failure when actual date is greater than expected) - procedure actual_date_greater; - - --%test(Gives failure when actual number is greater than expected) - procedure actual_number_greater; - - --%test(Gives failure when actual interval year to month is greater than expected) - procedure actual_interval_ym_greater; - - --%test(Gives failure when actual interval day to second is greater than expected) - procedure actual_interval_ds_greater; - - --%test(Gives failure when actual timestamp is greater than expected) - procedure actual_timestamp_greater; - - --%test(Gives failure when actual timestamp with time zone is greater than expected) - procedure actual_timestamp_tz_greater; - - --%test(Gives failure when actual timestamp with local time zone is greater than expected) - procedure actual_timestamp_ltz_greater; - - --%test(Gives failure when actual date is equal expected) - procedure actual_date_equal; - - --%test(Gives failure when actual number is equal expected) - procedure actual_number_equal; - - --%test(Gives failure when actual interval year to month is equal expected) - procedure actual_interval_ym_equal; - - --%test(Gives failure when actual interval day to second is equal expected) - procedure actual_interval_ds_equal; - - --%test(Gives failure when actual timestamp is equal expected) - procedure actual_timestamp_equal; - - --%test(Gives failure when actual timestamp with time zone is equal expected) - procedure actual_timestamp_tz_equal; - - --%test(Gives failure when actual timestamp with local time zone is equal expected) - procedure actual_timestamp_ltz_equal; - - --%test(Gives success when actual date is less than expected) - procedure actual_date_less; - - --%test(Gives success when actual number is less than expected) - procedure actual_number_less; - - --%test(Gives success when actual interval year to month is less than expected) - procedure actual_interval_ym_less; - - --%test(Gives success when actual interval day to second is less than expected) - procedure actual_interval_ds_less; - - --%test(Gives success when actual timestamp is less than expected) - procedure actual_timestamp_less; - - --%test(Gives success when actual timestamp with time zone is less than expected) - procedure actual_timestamp_tz_less; - - --%test(Gives success when actual timestamp with local time zone is less than expected) - procedure actual_timestamp_ltz_less; - - --%test(Negated - Gives success when actual date is greater than expected) - procedure not_actual_date_greater; - - --%test(Negated - Gives success when actual number is greater than expected) - procedure not_actual_number_greater; - - --%test(Negated - Gives success when actual interval year to month is greater than expected) - procedure not_actual_interval_ym_greater; - - --%test(Negated - Gives success when actual interval day to second is greater than expected) - procedure not_actual_interval_ds_greater; - - --%test(Negated - Gives success when actual timestamp is greater than expected) - procedure not_actual_timestamp_greater; - - --%test(Negated - Gives success when actual timestamp with time zone is greater than expected) - procedure not_actual_timestamp_tz_gretr; - - --%test(Negated - Gives success when actual timestamp with local time zone is greater than expected) - procedure not_actual_timestamp_ltz_gretr; - - --%test(Gives failure when running against CLOB) - procedure actual_clob; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within.pkb b/test/ut3_user/expectations/binary/test_to_be_within.pkb deleted file mode 100644 index 032b684a5..000000000 --- a/test/ut3_user/expectations/binary/test_to_be_within.pkb +++ /dev/null @@ -1,360 +0,0 @@ -create or replace package body test_to_be_within is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function be_within_expectation_block( - a_matcher_name varchar2, - a_actual_data_type varchar2, - a_actual_data varchar2, - a_expected_data_type varchar2, - a_expected_data varchar2, - a_distance varchar2, - a_distance_data_type varchar2, - a_matcher_end varchar2 - ) return varchar2 - is - l_execute varchar2(32000); - begin - l_execute := ' - declare - l_actual '||a_actual_data_type||' := '||a_actual_data||'; - l_expected '||a_expected_data_type||' := '||a_expected_data||'; - l_distance '||a_distance_data_type||' := '||a_distance||'; - begin - --act - execute the expectation - ut3_develop.ut.expect( l_actual ).'||a_matcher_name||'(l_distance).of_(l_expected)'||a_matcher_end||'; - end;'; - return l_execute; - end; - - procedure test_to_be_within_fail( - a_matcher_name varchar2, - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_distance varchar2, - a_distance_data_type varchar2, - a_matcher_end varchar2 := null - ) is - begin - execute immediate be_within_expectation_block( - a_matcher_name,a_data_type, a_actual, a_data_type, a_expected, - a_distance,a_distance_data_type, a_matcher_end - ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).not_to_equal(0); - cleanup_expectations; - end; - - procedure test_to_be_within_success( - a_matcher_name varchar2, - a_data_type varchar2, - a_actual varchar2, - a_expected varchar2, - a_distance varchar2, - a_distance_data_type varchar2, - a_matcher_end varchar2 := null - ) is - begin - execute immediate be_within_expectation_block( - a_matcher_name,a_data_type, a_actual, a_data_type, a_expected, - a_distance,a_distance_data_type, a_matcher_end - ); - ut.expect - (ut3_tester_helper.main_helper.get_failed_expectations_num - ,be_within_expectation_block( - a_matcher_name,a_data_type, a_actual, a_data_type, a_expected, - a_distance,a_distance_data_type, a_matcher_end - ) - ).to_equal(0); - cleanup_expectations; - end; - - procedure success_tests is - begin - test_to_be_within_success('to_be_within','number', '2', '4','2','number'); - test_to_be_within_success('to_be_within','number', '4', '2','2','number'); - test_to_be_within_success('to_be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month'); - test_to_be_within_success('to_be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month'); - - test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2017-08-09 07:00:00']', q'[TIMESTAMP '2017-08-08 06:59:48.667']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2017-08-08 06:59:48.667']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2017-08-09 07:00:00']', q'[TIMESTAMP '2018-08-09 07:00:00']','''1-0''','interval year to month'); - test_to_be_within_success('to_be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month'); - test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); - test_to_be_within_success('to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); - test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); - test_to_be_within_success('to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2018-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']','''1-0''','interval year to month'); - - test_to_be_within_success('to_( ut3_develop.be_within','number', '2', '4','2','number', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','number', '4', '2','2','number', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); - test_to_be_within_success('to_( ut3_develop.be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); - test_to_be_within_fail('not_to_be_within','number', '2', '4','2','number'); - test_to_be_within_fail('not_to_be_within','number', '4', '2','2','number'); - test_to_be_within_fail('not_to_be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second'); - test_to_be_within_fail('not_to_be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second'); - test_to_be_within_fail('not_to_be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month'); - test_to_be_within_fail('not_to_be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month'); - test_to_be_within_fail('not_to( ut3_develop.be_within','number', '2', '4','2','number',')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','number', '4', '2','2','number',')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''1 0:00:11.333''','interval day to second',')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''1 0:00:11.333''','interval day to second',')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+200','''1-0''','interval year to month',')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','date', 'sysdate+200', 'sysdate','''1-0''','interval year to month',')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month', ')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); - test_to_be_within_fail('not_to( ut3_develop.be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second', ')'); - test_to_be_within_fail('not_to_be_within','timestamp', q'[TIMESTAMP '2018-08-09 07:00:00']', q'[TIMESTAMP '2017-08-09 07:00:00']','''1-0''','interval year to month'); - test_to_be_within_fail('not_to_be_within','timestamp_tz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); - test_to_be_within_fail('not_to_be_within','timestamp_ltz_unconstrained', q'[TIMESTAMP '2017-08-09 07:00:00 -7:00']', q'[TIMESTAMP '2017-08-08 05:59:48.668 -8:00']','''1 0:00:11.333''','interval day to second'); - end; - - procedure failed_tests is - begin - test_to_be_within_fail('to_be_within','number', '2', '4','1','number'); - test_to_be_within_fail('to_be_within','number', '4', '2','1','number'); - test_to_be_within_fail('to_be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second'); - test_to_be_within_fail('to_be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second'); - test_to_be_within_fail('to_be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month'); - test_to_be_within_fail('to_be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month'); - test_to_be_within_fail('to_( ut3_develop.be_within','number', '2', '4','1','number',')'); - test_to_be_within_fail('to_( ut3_develop.be_within','number', '4', '2','1','number',')'); - test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second',')'); - test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second',')'); - test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month',')'); - test_to_be_within_fail('to_( ut3_develop.be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month',')'); - test_to_be_within_success('not_to_be_within','number', '2', '4','1','number'); - test_to_be_within_success('not_to_be_within','number', '4', '2','1','number'); - test_to_be_within_success('not_to_be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second'); - test_to_be_within_success('not_to_be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second'); - test_to_be_within_success('not_to_be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month'); - test_to_be_within_success('not_to_be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month'); - test_to_be_within_success('not_to( ut3_develop.be_within','number', '2', '4','1','number',')'); - test_to_be_within_success('not_to( ut3_develop.be_within','number', '4', '2','1','number',')'); - test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+1','''0 0:00:11.333''','interval day to second',')'); - test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate+1', 'sysdate','''0 0:00:11.333''','interval day to second',')'); - test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate', 'sysdate+750','''1-0''','interval year to month',')'); - test_to_be_within_success('not_to( ut3_develop.be_within','date', 'sysdate+750', 'sysdate','''1-0''','interval year to month',')'); - end; - - procedure fail_for_number_not_within is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - --Act - ut3_develop.ut.expect(4).to_be_within(1).of_(7); - --Assert - l_expected_message := q'[Actual: 4 (number) was expected to be within 1 of 7 (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_for_ds_int_not_within is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - --Act - ut3_develop.ut.expect(sysdate).to_be_within(interval '1' second).of_(sysdate+1); - --Assert - l_expected_message := q'[Actual: % (date) was expected to be within 1 second of % (date)]'; - 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_for_custom_ds_int is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - --Act - ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '2 3:04:11.333' DAY TO SECOND).of_(sysdate+100); - --Assert - l_expected_message := q'[Actual: % (date) was expected to be within 2 days 3 hours 4 minutes 11.333 seconds of % (date)]'; - 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_for_ym_int_not_within is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - --Act - ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '1' MONTH).of_(sysdate+ 46); - --Assert - l_expected_message := q'[Actual: % (date) was expected to be within 1 month of % (date)]'; - 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_for_custom_ym_int is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - --Act - ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '1-3' YEAR TO MONTH).of_(sysdate+720); - --Assert - l_expected_message := q'[Actual: % (date) was expected to be within 1 year 3 months % (date)]'; - 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_msg_when_not_within is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - --Act - ut3_develop.ut.expect(1).to_be_within(3).of_(12); - --Assert - l_expected_message := q'[Actual: 1 (number) was expected to be within 3 of 12 (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_msg_wrong_types is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(sysdate).to_be_within(interval '1' second).of_(systimestamp); - --Assert - l_expected_message := q'[Matcher 'be within' cannot be used to compare Actual (date) with Expected (timestamp with time zone) using distance (interval day to second).]'; - 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_expected is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(sysdate).to_be_within(interval '1' second).of_(to_date(null)); - --Assert - l_expected_message := q'[Actual: % (date) was expected to be within 1 second of NULL (date)]'; - 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_actual_and_expected is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(to_date(null)).to_be_within(interval '1' second).of_(to_date(null)); - --Assert - l_expected_message := q'[Actual: NULL (date) was expected to be within 1 second of NULL (date)]'; - 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_actual is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(to_date(null)).to_be_within(interval '1' second).of_(sysdate); - --Assert - l_expected_message := q'[Actual: NULL (date) was expected to be within 1 second of % (date)]'; - 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_distance is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(sysdate).to_be_within(cast(null as interval day to second)).of_(sysdate); - --Assert - l_expected_message := q'[Actual: % (date) was expected to be within NULL of % (date)]'; - 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 invalid_distance_for_number is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(2).to_be_within(interval '1' second).of_(1); - --Assert - l_expected_message := q'[Matcher 'be within' cannot be used to compare Actual (number) with Expected (number) using distance (interval day to second).]'; - 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 invalid_distance_for_timestamp is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(sysdate).to_be_within(1).of_(sysdate); - --Assert - l_expected_message := q'[Matcher 'be within' cannot be used to compare Actual (date) with Expected (date) using distance (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 failure_on_tiny_time_diff is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(timestamp'2022-01-29 23:23:23.000000009').to_be_within(interval '0.000000001' second).of_(timestamp'2022-01-29 23:23:23.000000001'); - --Assert - l_expected_message := q'[Actual: 2022-01-29T23:23:23.000000009 (timestamp) was expected to be within .000000001 seconds of 2022-01-29T23:23:23.000000001 (timestamp)]'; - 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 failure_on_large_years_compare is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Act - ut3_develop.ut.expect(to_date('-4000-01-01','syyyy-mm-dd')).to_be_within(interval '9990' year).of_(date '9999-12-31'); - --Assert - l_expected_message := q'[Actual: -4000-01-01T00:00:00 (date) was expected to be within 9990 years of 9999-12-31T00:00:00 (date)]'; - 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; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within.pks b/test/ut3_user/expectations/binary/test_to_be_within.pks deleted file mode 100644 index 966e9baaf..000000000 --- a/test/ut3_user/expectations/binary/test_to_be_within.pks +++ /dev/null @@ -1,61 +0,0 @@ -create or replace package test_to_be_within is - - --%suite((not)to_be_within) - --%suitepath(utplsql.test_user.expectations.binary) - - --%aftereach - procedure cleanup_expectations; - - --%test(gives success for values within a distance) - procedure success_tests; - - --%test(gives failure when value is not within distance) - procedure failed_tests; - - --%test(returns well formatted failure message when expectation fails) - procedure fail_for_number_not_within; - - --%test(returns well formatted failure message for inteval of 1 sec not within) - procedure fail_for_ds_int_not_within; - - --%test(returns well formatted failure message for custom ds interval not within) - procedure fail_for_custom_ds_int; - - --%test(returns well formatted failure message for inteval of 1 month not within) - procedure fail_for_ym_int_not_within; - - --%test(returns well formatted failure message for custom ym interval not within) - procedure fail_for_custom_ym_int; - - --%test(returns well formatted failure message for simple within) - procedure fail_msg_when_not_within; - - --%test(returns well formatted failure message when comparing different datatypes) - procedure fail_msg_wrong_types; - - --%test(failure on null expected value) - procedure null_expected; - - --%test(failure on null actual value) - procedure null_actual; - - --%test(failure on null expected and actual value) - procedure null_actual_and_expected; - - --%test(failure on null distance value) - procedure null_distance; - - --%test(failure on invalid distance datatype for number expected) - procedure invalid_distance_for_number; - - --%test(failure on invalid distance datatype for timestamp expected) - procedure invalid_distance_for_timestamp; - - --%test(failure on exceeding difference in day second time by nanosecond) - procedure failure_on_tiny_time_diff; - - --%test(failure when comparing very large year difference) - procedure failure_on_large_years_compare; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within_pct.pkb b/test/ut3_user/expectations/binary/test_to_be_within_pct.pkb deleted file mode 100644 index da634d90e..000000000 --- a/test/ut3_user/expectations/binary/test_to_be_within_pct.pkb +++ /dev/null @@ -1,221 +0,0 @@ -create or replace package body test_to_be_within_pct is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - function be_within_expectation_block( - a_matcher varchar2, - a_actual_type varchar2, - a_actual varchar2, - a_expected_type varchar2, - a_expected varchar2, - a_distance varchar2, - a_distance_type varchar2, - a_matcher_end varchar2 - ) return varchar2 - is - l_execute varchar2(32000); - begin - l_execute := ' - declare - l_actual '||a_actual_type||' := '||a_actual||'; - l_expected '||a_expected_type||' := '||a_expected||'; - l_distance '||a_distance_type||' := '||a_distance||'; - begin - --act - execute the expectation - ut3_develop.ut.expect( l_actual ).'||a_matcher||'( l_distance ).of_( l_expected )'||a_matcher_end||'; - end;'; - return l_execute; - end; - - procedure test_to_be_within_fail( - a_matcher varchar2, - a_actual_type varchar2, - a_actual varchar2, - a_expected_type varchar2, - a_expected varchar2, - a_distance varchar2, - a_distance_type varchar2, - a_failure_message varchar2 := null, - a_matcher_end varchar2 := null - ) is - l_failure_text varchar2(4000); - begin - execute immediate be_within_expectation_block( - a_matcher,a_actual_type, a_actual, a_expected_type, a_expected, - a_distance,a_distance_type, a_matcher_end - ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); - if a_failure_message is not null then - l_failure_text := ut3_tester_helper.main_helper.get_failed_expectations(1); - ut.expect( l_failure_text ).to_be_like('%'||a_failure_message||'%' ); - end if; - cleanup_expectations; - end; - - procedure test_to_be_within_success( - a_matcher varchar2, - a_actual_type varchar2, - a_actual varchar2, - a_expected_type varchar2, - a_expected varchar2, - a_distance varchar2, - a_distance_type varchar2, - a_matcher_end varchar2 := null - ) is - begin - execute immediate be_within_expectation_block( - a_matcher,a_actual_type, a_actual, a_expected_type, a_expected, - a_distance,a_distance_type, a_matcher_end - ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - cleanup_expectations; - end; - - - procedure test_to_be_within_error( - a_matcher varchar2, - a_actual_type varchar2, - a_actual varchar2, - a_expected_type varchar2, - a_expected varchar2, - a_distance varchar2, - a_distance_type varchar2, - a_error_message varchar2, - a_matcher_end varchar2 := null - ) is - begin - execute immediate be_within_expectation_block( - a_matcher,a_actual_type, a_actual, a_expected_type, a_expected, - a_distance,a_distance_type, a_matcher_end - ); - cleanup_expectations; - ut.fail('Expected exception but nothing was raised'); - exception - when others then - ut.expect(sqlerrm).to_be_like('%'||a_error_message||'%'); - cleanup_expectations; - end; - - - procedure expect_success is - begin - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - cleanup_expectations; - end; - - procedure expect_failure is - begin - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); - cleanup_expectations; - end; - - procedure success_tests is - begin - ut3_develop.ut.expect( 1 ).to_be_within_pct( 0.01 ).of_(1.0001); - expect_success; - - ut3_develop.ut.expect( 1.0001 ).to_( ut3_develop.be_within_pct( 0.01 ).of_(1) ); - expect_success; - - ut3_develop.ut.expect( 1.0002 ).not_to_be_within_pct( 0.01 ).of_(1); - expect_success; - - ut3_develop.ut.expect( 1 ).not_to( ut3_develop.be_within_pct( 0.01 ).of_(1.0002) ); - expect_success; - - ut3_develop.ut.expect( 1.0001 ).to_be_within_pct( -0.01 ).of_(1); - expect_success; - - ut3_develop.ut.expect( 1 ).to_( ut3_develop.be_within_pct( -0.01 ).of_(1.0001) ); - expect_success; - - ut3_develop.ut.expect( 1.00000001 ).not_to_be_within_pct( 0 ).of_(1); - expect_success; - - ut3_develop.ut.expect( 0 ).not_to( ut3_develop.be_within_pct( 0.01 ).of_(0.000001) ); - expect_success; - - ut3_develop.ut.expect( 0 ).to_be_within_pct( 0 ).of_( 0 ); - expect_success; - - ut3_develop.ut.expect( 0 ).to_be_within_pct( 100 ).of_( 1 ); - expect_success; - - ut3_develop.ut.expect( -1 ).to_be_within_pct( 200 ).of_( 1 ); - expect_success; - end; - - procedure failed_tests is - begin - ut3_develop.ut.expect( 1 ).not_to_be_within_pct( 0.01 ).of_(1.0001); - expect_failure; - - ut3_develop.ut.expect( 1.0001 ).not_to( ut3_develop.be_within_pct( 0.01 ).of_(1) ); - expect_failure; - - ut3_develop.ut.expect( 1.0002 ).to_be_within_pct( 0.01 ).of_(1); - expect_failure; - - ut3_develop.ut.expect( 1 ).to_( ut3_develop.be_within_pct( 0.01 ).of_(1.0002) ); - expect_failure; - - ut3_develop.ut.expect( 1.0001 ).not_to_be_within_pct( -0.01 ).of_(1); - expect_failure; - - ut3_develop.ut.expect( 1 ).not_to( ut3_develop.be_within_pct( -0.01 ).of_(1.0001) ); - expect_failure; - - ut3_develop.ut.expect( 1.00000001 ).to_be_within_pct( 0 ).of_(1); - expect_failure; - - ut3_develop.ut.expect( 0 ).to_( ut3_develop.be_within_pct( 0.01 ).of_(0.000001) ); - expect_failure; - - ut3_develop.ut.expect( 0 ).not_to_be_within_pct( 0 ).of_( 0 ); - expect_failure; - - ut3_develop.ut.expect( 0 ).not_to_be_within_pct( 100 ).of_( 1 ); - expect_failure; - - ut3_develop.ut.expect( -1 ).not_to_be_within_pct( 200 ).of_( 1 ); - expect_failure; - end; - - procedure fail_for_number_not_within is - begin - test_to_be_within_fail( - 'to_be_within_pct','number', '4', 'number','7', - '1','number', - q'[Actual: 4 (number) was expected to be within 1 % of 7 (number)]' - ); - end; - - procedure fail_at_invalid_argument_types is - begin - test_to_be_within_error( - 'to_be_within_pct','date', 'sysdate', 'date','sysdate', - '''0 0:00:11.333''','interval day to second', - 'wrong number or types of arguments in call to ''TO_BE_WITHIN_PCT''' - ); - test_to_be_within_error( - 'to_be_within_pct','number','1', 'date', 'sysdate', - '1','number', - ' wrong number or types of arguments in call to ''OF_''' - ); - test_to_be_within_error( - 'to_be_within_pct','number','1','number','1', - 'sysdate', 'date', - ' wrong number or types of arguments in call to ''TO_BE_WITHIN_PCT''' - ); - test_to_be_within_fail( - 'to_be_within_pct','date', 'sysdate', 'number','1', - '1','number', - 'Matcher ''be within pct'' cannot be used to compare Actual (date) with Expected (number) using distance (number).' - ); - end; - -end; -/ diff --git a/test/ut3_user/expectations/binary/test_to_be_within_pct.pks b/test/ut3_user/expectations/binary/test_to_be_within_pct.pks deleted file mode 100644 index 4b8f0cb4c..000000000 --- a/test/ut3_user/expectations/binary/test_to_be_within_pct.pks +++ /dev/null @@ -1,22 +0,0 @@ -create or replace package test_to_be_within_pct is - - --%suite((not)to_be_within_pct) - --%suitepath(utplsql.test_user.expectations.binary) - - --%aftereach - procedure cleanup_expectations; - - --%test(gives success for values within a distance) - procedure success_tests; - - --%test(gives failure when number is not within distance) - procedure failed_tests; - - --%test(returns well formatted failure message when expectation fails) - procedure fail_for_number_not_within; - - --%test(fails at compile or run time for unsupported data-types ) - procedure fail_at_invalid_argument_types; - -end; -/ diff --git a/test/ut3_user/expectations/test_expectation_anydata.pkb b/test/ut3_user/expectations/test_expectation_anydata.pkb deleted file mode 100644 index c70d41f9e..000000000 --- a/test/ut3_user/expectations/test_expectation_anydata.pkb +++ /dev/null @@ -1,1259 +0,0 @@ -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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ null ] was expected to equal: ut3_tester_helper.test_dummy_object_list [ count = 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 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_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); - --Assert - l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_object_list [ null ] 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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - begin - --Arrange - l_list := ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - begin - --Arrange - l_list := ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - l_include ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - l_actual varchar2(32767); - begin - --Arrange - l_include := ut3_develop.ut_varchar2_list('key','ID','Value'); - l_exclude := ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3_develop.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_develop.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_develop.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3_develop.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_develop.ut.expect(get_anydata()).to_(ut3_develop.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_develop.ut.expect(get_anydata()).to_(ut3_develop.equal(get_anydata(), a_exclude => ut3_develop.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_develop.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_develop.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_develop.ut_varchar2_list; - begin - l_list := ut3_develop.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_develop.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_develop.ut_varchar2_list; - begin - l_list := ut3_develop.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_develop.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_develop.ut_varchar2_list; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - l_list := ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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 [ null ] -%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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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 [ null ] -%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_develop.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_develop.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_develop.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_develop.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_develop.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 22 -%PK 2 - Expected: Something 11 -%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_develop.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_develop.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_develop.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_develop.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_develop.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 collection_not_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, 'Something2 '||rownum, rownum+100) - 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_develop.ut.expect(anydata.convertCollection(l_actual)).not_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_develop.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_develop.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_develop.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; - - procedure failure_nesting_objects is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') )); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'C', '0') )); - --Act - l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_nested_object was expected to equal: ut3_tester_helper.test_dummy_nested_object -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: 1C0 -%Row No. 1 - Expected: 1B0]'; - ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected); - 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 failure_double_nested_objects is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test')); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'C', '0') ),'Test')); - --Act - l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_double_nested_obj was expected to equal: ut3_tester_helper.test_dummy_double_nested_obj -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: 1A01C0 -%Row No. 1 - Expected: 1A01B0]'; - ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected); - 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 success_nesting_objects is - begin - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') )); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') )); - --Act - ut3_develop.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 success_double_nested_objects is - begin - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test')); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_obj(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test')); - --Act - ut3_develop.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 failure_nested_object_list is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - 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 + 1, 'Something '||rownum, rownum) - bulk collect into l_actual - from dual connect by level <=2 - order by rownum desc; - 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; - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_actual,'Test')); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_expected,'Test')); - --Act - l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_nested_object_list was expected to equal: ut3_tester_helper.test_dummy_nested_object_list -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: 2Something 221Something 11 -%Row No. 1 - Expected: 3Something 222Something 11]'; - ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected); - 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 success_nested_object_list 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 <=2 - order by rownum desc; - 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; - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_actual,'Test')); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object_list(l_expected,'Test')); - --Act - ut3_develop.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 nested_varray_same_data is - begin - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(1)) ); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(1)) ); - --Act - ut3_develop.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 nested_varray_diff_data is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - g_test_expected := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(1)) ); - g_test_actual := anydata.convertObject( ut3_tester_helper.test_nested_tab_varray(ut3_tester_helper.t_varray(2)) ); - --Act - ut3_develop.ut.expect( g_test_actual ).to_equal( g_test_expected ); - l_expected_message := q'[%Actual: ut3_tester_helper.test_nested_tab_varray was expected to equal: ut3_tester_helper.test_nested_tab_varray -%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 user_def_type_null_issue_1098 is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_actual ut3_tester_helper.test_dummy_dble_nest_lst_obj; - l_expected ut3_tester_helper.test_dummy_dble_nest_lst_obj; - begin - l_actual:= ut3_tester_helper.test_dummy_dble_nest_lst_obj( - 1, 'North America', - ut3_tester_helper.test_dummy_double_nested_list ( - ut3_tester_helper.test_dummy_nested_object_list( - ut3_tester_helper.test_dummy_object_list( - ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), - ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) - ),'USA' - ), - ut3_tester_helper.test_dummy_nested_object_list( - ut3_tester_helper.test_dummy_object_list(),'USA' - ) - ) - ); - - l_expected := ut3_tester_helper.test_dummy_dble_nest_lst_obj( - 1, - 'North America', - ut3_tester_helper.test_dummy_double_nested_list(ut3_tester_helper.test_dummy_nested_object_list(ut3_tester_helper.test_dummy_object_list( - ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), - ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) - ), 'USA')) - ); - ut3_develop.ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)).unordered; - - l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_dble_nest_lst_obj was expected to equal: ut3_tester_helper.test_dummy_dble_nest_lst_obj -%Diff: -%Rows: [ 2 differences ] -%Extra: 1North America1100 Broadway24742200 Indian School Rd85016USAUSA -%Missing: 1North America1100 Broadway24742200 Indian School Rd85016USA]'; - 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 complex_nested_object_success is - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - l_actual ut3_tester_helper.test_dummy_dble_nest_lst_obj; - l_expected ut3_tester_helper.test_dummy_dble_nest_lst_obj; - begin - l_actual:= ut3_tester_helper.test_dummy_dble_nest_lst_obj( - 1, 'North America', - ut3_tester_helper.test_dummy_double_nested_list ( - ut3_tester_helper.test_dummy_nested_object_list( - ut3_tester_helper.test_dummy_object_list( - ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), - ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) - ),'USA' - ), - ut3_tester_helper.test_dummy_nested_object_list( - ut3_tester_helper.test_dummy_object_list(),'USA' - ) - ) - ); - - l_expected := ut3_tester_helper.test_dummy_dble_nest_lst_obj( - 1, 'North America', - ut3_tester_helper.test_dummy_double_nested_list ( - ut3_tester_helper.test_dummy_nested_object_list( - ut3_tester_helper.test_dummy_object_list( - ut3_tester_helper.test_dummy_object(1, '100 Broadway', 02474), - ut3_tester_helper.test_dummy_object(2, '200 Indian School Rd', 85016) - ),'USA' - ), - ut3_tester_helper.test_dummy_nested_object_list( - ut3_tester_helper.test_dummy_object_list(),'USA' - ) - ) - ); - ut3_develop.ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected)).unordered; - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - - end; - - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - procedure long_names_object_types is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace type - very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it - is object ( - code number(18) - )]'; - execute immediate q'[ - begin - ut3_develop.ut.expect(anydata.convertObject( - very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it(1) - )).to_equal(anydata.convertObject( - very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it(1) - )); - end;]'; - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - execute immediate 'drop type very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it'; - exception - when others then - execute immediate 'drop type very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it'; - raise; - end; - $end - -end; -/ \ No newline at end of file diff --git a/test/ut3_user/expectations/test_expectation_anydata.pks b/test/ut3_user/expectations/test_expectation_anydata.pks deleted file mode 100644 index 54c246bd3..000000000 --- a/test/ut3_user/expectations/test_expectation_anydata.pks +++ /dev/null @@ -1,246 +0,0 @@ -create or replace package test_expectation_anydata is - - --%suite(equal on anydata) - --%suitepath(utplsql.test_user.expectations) - - --%aftereach - procedure cleanup; - - --%test(Gives failure when comparing NULL objects of different type) - procedure fail_on_different_type_null; - - --%test(Gives failure when comparing objects of different type) - procedure fail_on_different_type; - - --%test(Gives failure when objects holds different data) - procedure fail_on_different_object_data; - - --%test(Gives failure when one of objects is NULL) - procedure fail_on_one_object_null; - - --%test(Gives failure when comparing object to collection) - procedure fail_on_collection_vs_object; - - --%test(Gives failure when comparing empty collection to NULL collection) - procedure fail_on_null_vs_empty_coll; - - --%test(Gives failure when one of collections is NULL) - procedure fail_on_one_collection_null; - - --%test(Gives failure when one of collections is empty) - procedure fail_on_one_collection_empty; - - --%test(Gives failure when collections holds different data) - procedure fail_on_different_coll_data; - - --%test(Gives success when both anydata are NULL) - procedure success_on_both_anydata_null; - - --%test(Gives success when both objects are null) - procedure success_on_both_object_null; - - --%test(Gives success when both collections are null) - procedure success_on_both_coll_null; - - --%test(Gives success when both collections are of same type contain identical data) - procedure success_on_same_coll_data; - - --%test(Gives failure when both collections contain the same data in different order) - procedure fail_on_coll_different_order; - - --%test(Gives success when both objects are of same type and hold the same data) - procedure success_on_same_object_data; - - --%test(List of attributes to exclude is case sensitive) - procedure exclude_attributes_as_list; - - --%test(Comma separated list of attributes to exclude is case sensitive) - procedure exclude_attributes_as_csv; - - --%test(Exclude attributes by XPath is case sensitive) - procedure exclude_attributes_xpath; - - --%test(Excludes existing attributes when some of attributes on exclude are not valid column names) - procedure exclude_ignores_invalid_attrib; - - --%test(List of attributes to include is case sensitive) - procedure include_attributes_as_list; - - --%test(Comma separated list of attributes to include is case sensitive) - procedure include_attributes_as_csv; - - --%test(Include attributes by XPath is case sensitive) - procedure include_attributes_xpath; - - --%test(Includes existing attributes when some of attributes on exclude are not valid column names) - procedure include_ignores_invalid_attrib; - - --%test(Includes only attributes that are not excluded) - procedure include_exclude_attributes_csv; - - --%test(Includes only attributes that are not on exclude list) - procedure include_exclude_attrib_list; - - --%test(Reports diff on incorrect attributes of an object type) - procedure reports_diff_attribute; - - --%test(Reports diff on incorrect rows and attributes of a collection type) - procedure reports_diff_structure; - - --%test(Adds a warning when using depreciated syntax to_equal( a_expected anydata, a_exclude varchar2 )) - procedure deprec_to_equal_excl_varch; - - --%test(Adds a warning when using depreciated syntax to_equal( a_expected anydata, a_exclude ut_varchar2_list )) - procedure deprec_to_equal_excl_list; - - --%test(Adds a warning when using depreciated syntax not_to_equal( a_expected anydata, a_exclude varchar2 )) - procedure deprec_not_to_equal_excl_varch; - - --%test(Adds a warning when using depreciated syntax not_to_equal( a_expected anydata, a_exclude ut_varchar2_list )) - procedure deprec_not_to_equal_excl_list; - - --%test(Adds a warning when using depreciated syntax to_( equal( a_expected anydata, a_exclude varchar2 ) )) - procedure deprec_equal_excl_varch; - - --%test(Adds a warning when using depreciated syntax to_( equal( a_expected anydata, a_exclude ut_varchar2_list )) ) - procedure deprec_equal_excl_list; - - --%test(Reports only mismatched attributes on row data mismatch) - procedure data_diff_on_atr_data_mismatch; - - --%test(Reports only first 20 rows of diff and gives a full diff count) - procedure data_diff_on_20_rows_only; - - --%test(Validate include list on collections of objects) - procedure collection_include_list; - - --%test(Validate exclude list on collections of objects) - procedure collection_exclude_list; - - --%test(Validate include list on collections of objects fail) - procedure collection_include_list_fail; - - --%test(Two ARRAYS with same data) - procedure array_same_data; - - --%test(Two ARRAYS with different data) - procedure array_diff_data; - - --%test(ARRAY is atomically null) - procedure array_is_null; - - --%test(Compare two null ARRAYs) - procedure array_null_equal_array_null; - - --%test(Compare null ARRAY to ARRAY with data) - procedure array_null_equal_array_notnull; - - --%test(Empty ARRAY have count of 0) - procedure empty_array_have_zero_elem; - - --%test(Compare two empty ARRAYs) - procedure array_empty_equal_array_empty; - - --%test(Compare empty ARRAY to ARRAY with data) - procedure arr_empty_equal_arr_notempty; - - --%test(Collection is atomically NULL) - procedure collection_is_null; - - --%test(Collection is empty) - procedure collection_is_empty; - - --%test(Two VARRAYS with same data) - procedure varray_same_data; - - --%test(Two VARRAYS with different data) - procedure varray_diff_data; - - --%test(VARRAY is atomically null) - procedure varray_is_null; - - --%test(Compare two null VARRAYs) - procedure varray_null_equal_varray_null; - - --%test(Compare null VARRAY to VARRAY with data) - procedure varr_null_equal_varr_notnull; - - --%test(Empty VARRAY have count of 0) - procedure empty_varray_have_zero_elem; - - --%test(Compare two empty VARRAYs) - procedure varr_empty_equal_varr_empty; - - --%test(Compare empty VARRAY to VARRAY with data) - procedure varr_empty_equal_varr_notempty; - - --%test( Anydata collection using joinby ) - procedure collection_join_by; - - --%test( Anydata collection using joinby fail) - procedure collection_join_by_fail; - - --%test( Anydata collection unordered ) - procedure collection_unordered; - - --%test( Anydata collection unordered fail ) - procedure collection_unordered_fail; - - --%test( Anydata object using joinby ) - procedure object_join_by; - - --%test( Anydata object unordered ) - procedure object_unordered; - - --%test( Success when anydata collection contains data from another anydata collection) - procedure collection_to_contain; - - --%test( Success when anydata collection not contains data from another anydata collection) - procedure collection_not_to_contain; - - --%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; - - --%test ( Reports diff between not equal nested objects ) - procedure failure_nesting_objects; - - --%test ( Reports diff between not equal double nested objects ) - procedure failure_double_nested_objects; - - --%test (Reports success when comparing identical nested object ) - procedure success_nesting_objects; - - --%test ( Reports success when comparing identical double nested object ) - procedure success_double_nested_objects; - - --%test ( Reports diff between two not equal nested object list ) - procedure failure_nested_object_list; - - --%test ( Reports success when comparing identical nested object list ) - procedure success_nested_object_list; - - --%test ( Reports success when comparing identical nested VARRAYS ) - procedure nested_varray_same_data; - - --%test ( Reports diff between two not equal nested VARRAYS ) - procedure nested_varray_diff_data; - - --%test ( Comparision won't fail on user_defined type that is null as per issue 1098 ) - procedure user_def_type_null_issue_1098; - - --%test ( Reports success when comparing complex nested objects ) - procedure complex_nested_object_success; - - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - --%test ( Compares object types with long names - Issue #1235 ) - procedure long_names_object_types; - $end - -end; -/ diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb deleted file mode 100644 index a4ef4e8f2..000000000 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ /dev/null @@ -1,2996 +0,0 @@ -create or replace package body test_expectations_cursor is - - gc_blob blob := to_blob('123'); - gc_clob clob := to_clob('abc'); - gc_date date := sysdate; - gc_ds_int interval day(9) to second(9) := numtodsinterval(1.12345678912, 'day'); - gc_num number := 123456789.1234567890123456789; - gc_ts timestamp(9) := to_timestamp_tz('2017-03-30 00:21:12.123456789 cet','yyyy-mm-dd hh24:mi:ss.ff9 tzr'); - gc_ts_tz timestamp(9) with time zone := to_timestamp_tz('2017-03-30 00:21:12.123456789 cet','yyyy-mm-dd hh24:mi:ss.ff9 tzr'); - gc_ts_ltz timestamp(9) with local time zone := to_timestamp_tz('2017-03-30 00:21:12.123456789 cet','yyyy-mm-dd hh24:mi:ss.ff9 tzr'); - gc_varchar varchar2(4000) := 'a varchar2'; - gc_ym_int interval year(9) to month := numtoyminterval(1.1, 'year'); - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - procedure setup_temp_table_test - as - pragma autonomous_transaction; - begin - execute immediate 'create global temporary table gtt_test_table ( - value varchar2(250) - ) on commit delete rows'; - - end; - - procedure cleanup_temp_table_test - as - pragma autonomous_transaction; - begin - execute immediate 'drop table gtt_test_table'; - end; - - procedure with_temp_table - as - pragma autonomous_transaction; - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - -- Arrange - execute immediate 'insert into gtt_test_table ( value ) ' || - 'select ''Test-entry'' from dual union all ' || - 'select ''Other test entry'' from dual'; - open l_expected for - select 'Test-entry' as value from dual union all - select 'Other test entry' as value from dual; - open l_actual for 'select * from gtt_test_table'; - --Act - execute the expectation on cursor opened on GTT - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - --Cleanup - rollback; - end; - - - procedure success_on_same_data - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - -- Arrange - ut3_develop.ut.set_nls; - open l_expected for - select 1 as my_num, - 'This is my test string' as my_string, - to_clob('This is an even longer test clob') as my_clob, - to_date('1984-09-05', 'YYYY-MM-DD') as my_date - from dual; - open l_actual for - select 1 as my_num, - 'This is my test string' as my_string, - to_clob('This is an even longer test clob') as my_clob, - to_date('1984-09-05', 'YYYY-MM-DD') as my_date - from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - ut3_develop.ut.reset_nls; - end; - - procedure success_on_same_data_float - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - -- Arrange - ut3_develop.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_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - ut3_develop.ut.reset_nls; - end; - - procedure success_on_empty - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - -- Arrange - open l_expected for select * from dual where 1=0; - open l_actual for select * from dual where 1=0; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_on_both_null - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_to_be_null - as - l_actual sys_refcursor; - begin - --Act - ut3_develop.ut.expect( l_actual ).to_be_null(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_not_to_be_not_null - as - l_actual sys_refcursor; - begin - --Act - ut3_develop.ut.expect( l_actual ).not_to_be_not_null(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_not_to_be_null - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_be_not_null(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_to_be_not_null - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_be_not_null(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_is_empty - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual where 0=1; - --Act - ut3_develop.ut.expect( l_actual ).to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure success_is_not_empty - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual; - --Act - ut3_develop.ut.expect( l_actual ).not_to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure failure_is_null - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_be_null(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure failure_is_not_null - as - l_actual sys_refcursor; - begin - --Act - ut3_develop.ut.expect( l_actual ).not_to_be_null(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure failure_is_empty - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure failure_is_not_empty - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select * from dual where 0=1; - --Act - ut3_develop.ut.expect( l_actual ).not_to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_null_vs_empty - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select * from dual where 1=0; - --Act - ut3_develop.ut.expect( l_actual ).not_to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_on_difference - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select to_clob('This is an even longer test clob') as my_clob from dual; - open l_actual for select to_clob('Another totally different story') as my_clob from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_on_expected_missing - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as my_num from dual; - open l_actual for select 1 as my_num from dual union all select 1 as my_num from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_on_actual_missing - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as my_num from dual union all select 1 as my_num from dual; - open l_actual for select 1 as my_num from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_on_different_column_name - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as col_1 from dual; - open l_actual for select 1 as col_2 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - - procedure fail_on_different_column_order - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as col_1, 2 as col_2 from dual; - open l_actual for select 2 as col_2, 1 as col_1 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure pass_on_different_column_order - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as col_1, 2 as col_2 from dual; - open l_actual for select 2 as col_2, 1 as col_1 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_( ut3_develop.equal( l_expected ).unordered_columns() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure pass_on_diff_column_ord_uc - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as col_1, 2 as col_2 from dual; - open l_actual for select 2 as col_2, 1 as col_1 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_( ut3_develop.equal( l_expected ).uc() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_on_multi_diff_col_order - as - l_expected sys_refcursor; - l_actual sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual; - open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns; - --Assert - l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: 3040 -%Row No. 1 - Expected: 34]'; - 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_multi_diff_col_ord_uc - as - l_expected sys_refcursor; - l_actual sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual; - open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).uc; - --Assert - l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%Row No. 1 - Actual: 3040 -%Row No. 1 - Expected: 34]'; - 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_row_order - as - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for select 1 as my_num from dual union all select 2 as my_num from dual; - open l_actual for select 2 as my_num from dual union all select 1 as my_num from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure include_time_in_date_with_nls - as - l_expected sys_refcursor; - l_actual sys_refcursor; - c_second constant number := 1/24/60/60; - begin - --Arrange - ut3_develop.ut.set_nls; - open l_actual for select gc_date as some_date from dual; - open l_expected for select gc_date - c_second some_date from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - ut3_develop.ut.reset_nls; - end; - - procedure uses_default_nls_for_date - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select gc_date as some_date from dual; - open l_expected for select to_date(to_char(gc_date)) as some_date from dual; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure exclude_columns_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3_develop.ut_varchar2_list('A_COLUMN','Some_Col')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure exclude_columns_as_csv - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,Some_Col'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure exclude_columns_as_mixed_list is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3_develop.ut_varchar2_list('A_COLUMN','/ROW/Some_Col')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure exclude_columns_as_mix_csv_lst is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'A_COLUMN,/ROW/Some_Col'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure exclude_columns_xpath_invalid - as - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN,\\//Some_Col'); - --Assert - l_expected_message := q'[Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ] -%Diff: -%Rows: [ 3 differences ] -%Row No. 1 - Actual: d -%Row No. 1 - Expected: c -%Row No. 2 - Actual: d -%Row No. 2 - Expected: c -%Row No. 3 - Actual: d -%Row No. 3 - Expected: c]'; - 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 exclude_columns_xpath - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual; - open l_expected for select 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>'/ROW/A_COLUMN|/ROW/Some_Col'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure exclude_ignores_invalid_column - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'c' as A_COLUMN from dual a connect by level < 4; - open l_expected for select rownum as rn, 'd' as A_COLUMN from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected, a_exclude=>ut3_develop.ut_varchar2_list('A_COLUMN','non_existing_column')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure include_columns_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure include_columns_as_csv - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include('RN,//A_Column, SOME_COL'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure include_columns_xpath - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_( ut3_develop.equal(l_expected).include('/ROW/RN|//A_Column|//SOME_COL') ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure include_ignores_invalid_column - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'c' as A_COLUMN from dual a connect by level < 4; - open l_expected for select rownum as rn, 'd' as A_COLUMN from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list(' RN ',' non_existing_column ')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure include_exclude_col_csv_xpath - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude('Some_Col').include('/ROW/RN|//Some_Col'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure include_exclude_columns_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN')).include(ut3_develop.ut_varchar2_list('RN','A_Column','A_COLUMN')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure data_diff_on_rows_mismatch - as - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select 1 rn from dual union all select 6 rn from dual; - open l_expected for select rownum rn from dual connect by level <=3; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ] -Diff: -Rows: [ 2 differences ] - Row No. 2 - Actual: 6 - Row No. 2 - Expected: 2 - Row No. 3 - Missing: 3]'; - 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 char_and_varchar2_col_is_equal is - l_expected sys_refcursor; - l_actual sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select cast('a' as char(1)) a_column, 1 as id from dual; - open l_expected for select cast('a' as varchar2(10)) a_column from dual; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] -Diff: -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure column_diff_on_data_type_diff is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select to_char(rownum) rn, rownum another_rn from dual connect by level <=2; - open l_expected for select rownum rn, rownum another_rn from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -Diff: -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure column_diff_on_col_name_diff is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum rn, rownum bad_column_name from dual connect by level <=2; - open l_expected for select rownum rn, rownum expected_column_name from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure column_diff_on_col_position is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum+1 col_1, rownum+2 col_2, rownum+3 col_3, rownum+4 col_4 from dual connect by level <=2; - open l_expected for select rownum+1 col_1, rownum+4 col_4, rownum+2 col_2, rownum+3 col_3 from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -Diff: -Columns: - Column is misplaced. Expected position: 2, actual position: 4. - Column is misplaced. Expected position: 3, actual position: 2. - 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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure column_diff_on_col_pos_unord is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum+1 col_1, rownum+2 col_2, rownum+3 col_3, rownum+4 col_4 from dual connect by level <=2; - open l_expected for select rownum+1 col_1, rownum+4 col_4, rownum+2 col_2, rownum+3 col_3 from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered_columns; - - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - --%test(Reports only mismatched columns on column data mismatch) - procedure data_diff_on_col_data_mismatch is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum good_col, -rownum bad_col from dual connect by level <=2; - open l_expected for select rownum good_col, rownum bad_col from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -Diff: -Rows: [ 2 differences ] - Row No. 1 - Actual: -1 - Row No. 1 - Expected: 1 - Row No. 2 - Actual: -2 - Row No. 2 - Expected: 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 data_diff_on_20_rows_only is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for - select rownum - * case when mod(rownum,2) = 0 then -1 else 1 end bad_col, - rownum good_col - from dual connect by level <=100; - open l_expected for select rownum bad_col, rownum good_col from dual connect by level <=110; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[Actual: refcursor [ count = 100 ] was expected to equal: refcursor [ count = 110 ] -Diff: -Rows: [ 60 differences, showing first 20 ] - Row No. 2 - Actual: -2 - Row No. 2 - Expected: 2 - Row No. 4 - Actual: -4 - Row No. 4 - Expected: 4 - Row No. 6 - Actual: -6 - Row No. 6 - Expected: 6 - Row No. 8 - Actual: -8 - Row No. 8 - Expected: 8 - % - Row No. 38 - Actual: -38 - Row No. 38 - Expected: 38 - Row No. 40 - Actual: -40 - Row No. 40 - Expected: 40]'; - 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 column_and_data_diff is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for - select 1 as ID, 'JACK' as FIRST_NAME, 'SPARROW' AS LAST_NAME, 10000 AS SALARY from dual union all - select 2 as ID, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 1000 AS SALARY from dual union all - select 3 as ID, 'TONY' as FIRST_NAME, 'STARK' AS LAST_NAME, 100000 AS SALARY from dual; - open l_actual for - select 'M' AS GENDER, 'JACK' as FIRST_NAME, 'SPARROW' AS LAST_NAME, 1 as ID, '25000' AS SALARY from dual union all - select 'M' AS GENDER, 'TONY' as FIRST_NAME, 'STARK' AS LAST_NAME, 3 as ID, '100000' AS SALARY from dual union all - select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY from dual union all - select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY from dual; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - l_expected_message := q'[Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ] -Diff: -Columns: - Column is misplaced. Expected position: 1, actual position: 4. - Column data-type is invalid. Expected: NUMBER, actual: VARCHAR2. - Column [position: 1, data-type: CHAR] is not expected in results. -Rows: [ 4 differences ] - Row No. 1 - Actual: 25000 - Row No. 1 - Expected: 10000 - Row No. 2 - Actual: 3TONYSTARK100000 - Row No. 2 - Expected: 2LUKESKYWALKER1000 - Row No. 3 - Actual: 4JESSICAJONES2345 - Row No. 3 - Expected: 3TONYSTARK100000 - Row No. 4 - Extra: MLUKESKYWALKER21000]'; - 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 col_and_data_diff_not_ordered is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for - select 1 as ID, 'JACK' as FIRST_NAME, 'SPARROW' AS LAST_NAME, 10000 AS SALARY from dual union all - select 2 as ID, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 1000 AS SALARY from dual union all - select 3 as ID, 'TONY' as FIRST_NAME, 'STARK' AS LAST_NAME, 100000 AS SALARY from dual; - open l_actual for - select 'M' AS GENDER, 'JACK' as FIRST_NAME, 'SPARROW' AS LAST_NAME, 1 as ID, '25000' AS SALARY from dual union all - select 'M' AS GENDER, 'TONY' as FIRST_NAME, 'STARK' AS LAST_NAME, 3 as ID, '100000' AS SALARY from dual union all - select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY from dual union all - select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY from dual; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered_columns; - l_expected_message := q'[Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ] -Diff: -Columns: - Column data-type is invalid. Expected: NUMBER, actual: VARCHAR2. - Column [position: 1, data-type: CHAR] is not expected in results. -Rows: [ 4 differences ] - Row No. 1 - Actual: 25000 - Row No. 1 - Expected: 10000 - Row No. 2 - Actual: 3TONYSTARK100000 - Row No. 2 - Expected: 2LUKESKYWALKER1000 - Row No. 3 - Actual: 4JESSICAJONES2345 - Row No. 3 - Expected: 3TONYSTARK100000 - Row No. 4 - Extra: MLUKESKYWALKER21000]'; - 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 prepare_table - as - pragma autonomous_transaction; - begin - execute immediate - 'create table test_table_for_cursors ( - some_blob blob, - some_clob clob, - some_date date, - some_ds_interval interval day(9) to second(9), - some_nummber number, - some_timestamp timestamp(9), - some_timestamp_tz timestamp(9) with time zone, - some_timestamp_ltz timestamp(9) with local time zone, - some_varchar2 varchar2(4000), - some_ym_interval interval year(9) to month - )'; - execute immediate q'[ - insert into test_table_for_cursors - values( :gc_blob, :gc_clob, :gc_date, :gc_ds_int, :gc_num, :gc_ts, :gc_ts_tz, :gc_ts_ltz, :gc_varchar, :gc_ym_int - ) -]' using gc_blob, gc_clob, gc_date, gc_ds_int, gc_num, gc_ts, gc_ts_tz, gc_ts_ltz, gc_varchar, gc_ym_int; - commit; - end; - - procedure cleanup_table - as - pragma autonomous_transaction; - begin - execute immediate 'drop table test_table_for_cursors'; - end; - - procedure compares_sql_and_plsql_types is - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - --Arrange - open l_expected for - select gc_blob some_blob, - gc_clob some_clob, - gc_date some_date, - gc_ds_int some_ds_interval, - gc_num some_nummber, - gc_ts some_timestamp, - gc_ts_tz some_timestamp_tz, - gc_ts_ltz some_timestamp_ltz , - gc_varchar some_varchar2, - gc_ym_int some_ym_interval - from dual; - open l_actual for q'[select * from test_table_for_cursors]'; - --Act - ut3_develop.ut.expect(l_expected).to_equal(l_actual); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure closes_cursor_after_use - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select 1 as value from dual; - --Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - ut.expect(l_actual%isopen).to_be_false(); - end; - - procedure closes_cursor_after_use_on_err - as - l_actual sys_refcursor; - begin - --Arrange - open l_actual for select 1/0 as value from dual; - --Act - begin - ut3_develop.ut.expect(l_actual).to_be_empty(); - exception - when others then - null; - end; - --Assert - ut.expect(l_actual%isopen).to_be_false(); - end; - - procedure reports_on_exception_in_cursor - as - l_actual sys_refcursor; - begin - --Act - open l_actual for select 1/0 as error_column from dual connect by level < 10; - ut3_develop.ut.expect(l_actual).to_be_empty(); - - 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 - is - l_actual sys_refcursor; - l_error_code constant integer := -20155; - begin - --Arrange - open l_actual for select * from dual; - close l_actual; - --Act - ut3_develop.ut.expect( l_actual ).not_to_be_null; - exception - when others then - --Assert - ut.expect(sqlcode).to_equal(l_error_code); - end; - - procedure compares_over_1000_rows - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - 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_develop.ut.expect(l_actual).to_equal(l_expected); - - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - function get_cursor return sys_refcursor is - l_cursor sys_refcursor; - begin - open l_cursor for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - return l_cursor; - end; - - procedure deprec_to_equal_excl_varch is - begin - --Act - ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor(), 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_develop.ut.expect(get_cursor()).to_equal(get_cursor(), a_exclude => ut3_develop.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_develop.ut.expect(get_cursor()).not_to_equal(get_cursor(), 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_develop.ut.expect(get_cursor()).not_to_equal(get_cursor(), a_exclude => ut3_develop.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_develop.ut.expect(get_cursor()).to_(ut3_develop.equal(get_cursor(), 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_develop.ut.expect(get_cursor()).to_(ut3_develop.equal(get_cursor(), a_exclude => ut3_develop.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 col_diff_on_col_name_implicit is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select '1' , '2' from dual connect by level <=2; - open l_expected for select rownum , rownum expected_column_name from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -%Diff: -%Columns: -%Column [data-type: NUMBER] is missing. Expected column position: 1. -%Column [data-type: NUMBER] is missing. Expected column position: 2. -%Column <1> [position: 1, data-type: CHAR] is not expected in results. -%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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure col_mtch_on_col_name_implicit is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select '1' , rownum from dual connect by level <=2; - open l_expected for select '1' , rownum from dual connect by level <=2; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_unorderd_compr_success is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select username , user_id from all_users order by username asc; - open l_expected for select username , user_id from all_users order by username desc; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_unord_compr_success_uc is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select user_id, username from all_users order by username asc; - open l_expected for select username , user_id from all_users order by username desc; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered().uc(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_unordered_compare_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select 'test1' username,-100 user_id from dual - union all - select 'test' username,-666 user_id from dual - order by 1 asc; - - open l_expected for select 'test1' username,-100 user_id from dual - union all - select 'test' username,-667 user_id from dual - order by 1 desc; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -%Diff:% -%Rows: [ 2 differences ]% -%Extra: test-666% -%Missing: test-667%]'; - 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 cursor_joinby_compare_uc is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select owner, object_id, object_name,object_type from all_objects where owner = user; - open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID').uc(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_joinby_compare is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select object_id, owner, object_name,object_type from all_objects where owner = user; - open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_joinby_col_not_ord - as - l_expected sys_refcursor; - l_actual sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual; - open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual; - --Act - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).join_by('COL_1').unordered_columns; - --Assert - l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%PK 1 - Actual: 3040 -%PK 1 - Expected: 34]'; - 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 cursor_joinby_compare_twocols is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select object_id, owner, object_name,object_type from all_objects where owner = user; - open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('OBJECT_ID,OBJECT_NAME')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_joinby_compare_nokey is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure cur_joinby_comp_twocols_nokey is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('OWNER,USER_ID')); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% -Diff:% -%Unable to join sets:% -%Join key OWNER does not exists in expected% -%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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure cursor_joinby_compare_exkey is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('SOME_COL').exclude('SOME_COL'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure cur_joinby_comp_twocols_exkey is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('RN,SOME_COL')).exclude('RN'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure cursor_joinby_comp_nokey_ex is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rni, 'x' SOME_COL from dual a connect by level < 4; - open l_expected for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% -Diff:% -%Unable to join sets:% -%Join key RNI does not exists in expected%]'; - 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 cursor_joinby_comp_nokey_ac is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn, 'x' SOME_COL from dual a connect by level < 4; - open l_expected for select rownum as rni, 'x' SOME_COL from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('RNI'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]% -Diff:% -%Unable to join sets:% -%Join key RNI does not exists in actual%]'; - 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 cursor_joinby_compare_1000 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; - open l_expected for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_unorder_compare_1000 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; - open l_expected for select level object_id, level || '_TEST' object_name from dual connect by level <=1100; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_joinby_compare_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for select username, user_id from all_users union all - select 'TEST' username, -600 user_id from dual order by 1 desc; - - open l_actual for select username, user_id from all_users union all - select 'TEST' username, -610 user_id from dual order by 1 asc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] -%Diff:% -%Rows: [ 1 differences ]% -%PK TEST - Actual:%-610% -%PK TEST - Expected:%-600%]'; - 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 cursor_joinby_cmp_twocol_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for select username, user_id from all_users union all - select 'TEST' username, -600 user_id from dual order by 1 desc; - - open l_actual for select username, user_id from all_users union all - select 'TEST' username, -610 user_id from dual order by 1 asc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('USERNAME,USER_ID')); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] -%Diff:% -%Rows: [ 2 differences ]% -%PK TEST-610 - Extra: TEST-610% -%PK TEST-600 - Missing: TEST-600%]'; - 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 cur_joinby_cmp_threcol_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_expected for select username, user_id,'Y' is_valid from all_users union all - select 'TEST' username, -600 user_id,'Y' is_valid from dual order by 1 desc; - - open l_actual for select username, user_id,'Y' is_valid from all_users union all - select 'TEST' username, -610 user_id,'Y' is_valid from dual order by 1 asc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('USERNAME,IS_VALID')); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to equal: refcursor [ count = % ] -%Diff:% -%Rows: [ 1 differences ]% -%PK TESTY - Actual:%-610% -%PK TESTY - Expected:%-600%]'; - 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 unord_incl_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).unordered; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure joinby_incl_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure joinby_excl_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure unord_excl_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 4; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN|//Some_Col')).unordered; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure excl_dif_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; - open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure inlc_dif_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; - open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure inlc_exc_dif_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'TEST' as A_COLUMN from dual a connect by level < 4; - open l_expected for select rownum as rn, 1 as A_COLUMN from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include(ut3_develop.ut_varchar2_list('RN')).exclude(ut3_develop.ut_varchar2_list('A_COLUMN')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure compare_obj_typ_col_un is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - 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 ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval - from dual connect by level <=2 order by rownum desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure compare_obj_typ_col_jb is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - 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 ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval - from dual connect by level <=2 order by rownum desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure comp_obj_typ_col_un_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - 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 ut3_tester_helper.test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval - from dual connect by level <=3 order by rownum desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).unordered; - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]% -Diff:% -Rows: [ 5 differences% -%Extra: 1Something 11% -%Extra: 2Something 22% -%Missing: 3Somethings 33% -%Missing: 2Somethings 22% -%Missing: 1Somethings 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 comp_obj_typ_col_jb_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - 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 ut3_tester_helper.test_dummy_object( rownum, 'Somethings '||rownum, rownum) as colval - from dual connect by level <=2 order by rownum desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/ID'); - --Assert - 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 - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - 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,ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval - from dual connect by level <=2 order by rownum desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('RN,COLVAL/ID')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure comp_obj_typ_col_jb_nokey is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - 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 ut3_tester_helper.test_dummy_object( rownum, 'Something '||rownum, rownum) as colval - from dual connect by level <=2 order by rownum desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('COLVAL/IDS'); - - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -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_tester_helper.main_helper.get_failed_expectations(1); - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure compare_nest_tab_col_jb is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select key,value - from table(l_actual_tab) order by 1 asc; - - open l_expected for select key,value - from table(l_expected_tab) order by 1 desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); - - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure compare_nest_tab_col_jb_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - select ut3_develop.ut_key_value_pair(rownum,'Somethings '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select key,value - from table(l_actual_tab) order by 1 asc; - - open l_expected for select key,value - from table(l_expected_tab) order by 1 desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('KEY'); - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -%Diff:% -%Rows: [ 2 differences ]% -%PK % - Actual: %% -%PK % - Expected: %% -%PK % - Actual: %% -%PK % - Expected: %%]'; - 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 compare_nest_tab_cols_jb is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select key,value - from table(l_actual_tab) order by 1 asc; - - open l_expected for select key,value - from table(l_expected_tab) order by 1 desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('KEY,VALUE')); - - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure compare_nest_tab_cols_jb_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - select ut3_develop.ut_key_value_pair(rownum,'Somethings '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select key,value - from table(l_actual_tab) order by 1 asc; - - open l_expected for select key,value - from table(l_expected_tab) order by 1 desc; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by(ut3_develop.ut_varchar2_list('KEY,VALUE')); - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -%Diff:% -%Rows: [ 4 differences ]% -%PK %% - Extra% -%PK %% - Extra% -%PK %% - Missing% -%PK %% - Missing%]'; - 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 compare_tabtype_as_cols_jb is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - select ut3_develop.ut_key_value_pair(rownum,'Somethings '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select rownum rn, l_actual_tab as nested_table - from dual connect by level <=2; - - open l_expected for select rownum rn, l_expected_tab as nested_table - from dual connect by level <=2; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); - - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]% -%Diff:% -%Rows: [ 4 differences ]% -%PK %%%%%%%%%%%%%Extra%%% -%PK %%%%%%%%%%%%%Extra%%% -%PK %%%%%%%%%%%%%Missing%%% -%PK %%%%%%%%%%%%%Missing%%%]'; - 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 compare_tabtype_as_cols is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2 order by rownum asc; - - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2 order by rownum asc; - - --Arrange - open l_actual for select rownum rn, l_actual_tab as nested_table - from dual connect by level <=2; - - open l_expected for select rownum rn, l_expected_tab as nested_table - from dual connect by level <=2; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - - end; - - procedure compare_tabtype_as_cols_coll is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Apples '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - select ut3_develop.ut_key_value_pair(rownum,'Peaches '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select rownum rn, l_actual_tab as nested_table - from dual connect by level <=2; - - open l_expected for select rownum rn, l_expected_tab as nested_table - from dual connect by level <=2; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/UT_KEY_VALUE_PAIRS'); - - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -%Diff: -%Rows: [ 4 differences ] -%Extra: 11Apples 12Apples 2 -%Extra: 21Apples 12Apples 2 -%Missing: 11Peaches 12Peaches 2 -%Missing: 21Peaches 12Peaches 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 compare_rec_colltype_as_cols is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab some_object; - l_expected_tab some_object; - begin - select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) - into l_actual_tab from dual; - - select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) - into l_expected_tab from dual; - - --Arrange - open l_actual for select l_actual_tab as nested_table from dual; - - open l_expected for select l_expected_tab as nested_table from dual; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - - end; - - procedure compare_rec_colltype_as_attr is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab some_object; - l_expected_tab some_object; - begin - select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) - into l_actual_tab from dual; - - select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) - into l_expected_tab from dual; - - --Arrange - open l_actual for select l_actual_tab as nested_table from dual; - - open l_expected for select l_expected_tab as nested_table from dual; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - - end; - - procedure compare_collection_in_rec is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab some_object; - l_expected_tab some_object; - begin - select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) - into l_actual_tab from dual; - - select some_object( user,'TEST', gc_date, some_items( some_item(1,'test'), some_item(2,'test') ) ) - into l_expected_tab from dual; - - --Arrange - open l_actual for select l_actual_tab as nested_table from dual; - - open l_expected for select l_expected_tab as nested_table from dual; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - - end; - - procedure compare_rec_coll_as_cols_fl is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab some_object; - l_expected_tab some_object; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) - into l_actual_tab from dual; - - select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) - into l_expected_tab from dual; - - --Arrange - open l_actual for select rownum rn, l_actual_tab as nested_table - from dual; - - open l_expected for select rownum rn, l_expected_tab as nested_table - from dual; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/OBJECT_OWNER'); - - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] -%Diff: -%Rows: [ 1 differences ] -%PK TEST - Actual: TESTTEST%1BAD2test% -%PK TEST - Expected: TESTTEST%1TEST2test%]'; - 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 compare_rec_coll_as_join is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab some_object; - l_expected_tab some_object; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) - into l_actual_tab from dual; - - select some_object( 'TEST','TEST', gc_date, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) - into l_expected_tab from dual; - - --Arrange - open l_actual for select l_actual_tab as nested_table from dual; - - open l_expected for select l_expected_tab as nested_table from dual; - - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS/ID'); - - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]% -%Diff:% -%Unable to join sets:% -%Join key NESTED_TABLE/ITEMS/ID does not exists in expected% -%Join key NESTED_TABLE/ITEMS/ID does not exists in actual% -%Please make sure that your join clause is not refferring to collection element%]'; - 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 unordered_fix_764 is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - open l_expected for - select 'Table' as name from dual - union all - select 'Desk' as name from dual - union all - select 'Table' as name from dual; - - open l_actual for - select 'Desk' as name from dual - union all - select 'Table' as name from dual; - - --Assert - ut3_develop.ut.expect( l_actual ).to_equal( l_expected ).unordered(); - - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ] -%Diff: -%Rows: [ 1 differences ] -%Missing: Table%]'; - 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 cursor_to_contain 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 - and rownum < 20; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_to_contain_uc 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 object_type, owner, object_name from all_objects where owner = user - and rownum < 20; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).uc(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_to_contain_unordered is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for - 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 rownum owner, rownum||'name' object_name,'PACKAGE' object_type from dual connect by level < 10; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).unordered(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_to_contain_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - 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_develop.ut.expect(l_actual).to_contain(l_expected); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 4 ] was expected to contain: refcursor [ count = 9 ] -%Diff: -%Rows: [ 5 differences ] -%Missing: %%%% -%Missing: %%%% -%Missing: %%%% -%Missing: %%%% -%Missing: %%%%]'; - 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 cursor_contain_joinby is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select username,user_id from all_users; - open l_expected for select username ,user_id from all_users where rownum < 5; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_contain_joinby_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - open l_actual for select username, user_id from all_users - union all - select 'TEST' username, -600 user_id from dual - order by 1 desc; - open l_expected for select username, user_id from all_users - union all - select 'TEST' username, -601 user_id from dual - order by 1 asc; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME'); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to contain: refcursor [ count = % ] -%Diff: -%Rows: [ 1 differences ] -%PK TEST - Actual: -600 -%PK TEST - Expected: -601%]'; - 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_contain_incl_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 6; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure to_cont_join_incl_cols_as_lst - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure contain_join_excl_cols_as_lst - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure contain_excl_cols_as_list - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected).exclude(ut3_develop.ut_varchar2_list('A_COLUMN|//Some_Col')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_not_to_contain - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_expected for select 'TEST' username, -600 user_id from dual; - - open l_actual for select username, user_id from all_users - union all - select 'TEST1' username, -601 user_id from dual; - - --Act - ut3_develop.ut.expect(l_actual).not_to_contain(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_not_to_contain2 - as - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_expected for select 'TEST' username, -600 user_id from dual; - - open l_actual for select username, user_id from all_users - union all - select 'TEST1' username, -601 user_id from dual; - - --Act - ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected)); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_not_to_contain_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - open l_expected for select 'TEST' username, -600 user_id from dual; - - open l_actual for select username, user_id from all_users - union all - select 'TEST' username, -600 user_id from dual; - - --Act - ut3_develop.ut.expect(l_actual).not_to_contain(l_expected); - --Assert - l_expected_message := q'[%Actual: (refcursor [ count = % ])% -%Data-types:% -%VARCHAR2NUMBER% -%Data:% -%was expected not to contain:(refcursor [ count = 1 ])% -%Data-types:% -%CHARNUMBER% -%Data:% -%TEST-600%]'; - 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 cursor_not_to_contain_fail2 is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - open l_expected for select 'TEST' username, -600 user_id from dual; - - open l_actual for select username, user_id from all_users - union all - select 'TEST' username, -600 user_id from dual; - - --Act - ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected)); - --Assert - l_expected_message := q'[%Actual: (refcursor [ count = % ])% -%Data-types:% -%VARCHAR2NUMBER% -%Data:% -%was expected not to contain:(refcursor [ count = 1 ])% -%Data-types:% -%CHARNUMBER% -%Data:% -%TEST-600%]'; - 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 cursor_not_to_contain_joinby is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select username,rownum * 10 user_id from all_users where rownum < 5; - open l_expected for select username||to_char(rownum) username ,rownum user_id from all_users where rownum < 5; - - --Act - ut3_develop.ut.expect(l_actual).not_to_contain(l_expected).join_by('USER_ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure cursor_not_to_contain_joinby2 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select username,rownum * 10 user_id from all_users where rownum < 5; - open l_expected for select username||to_char(rownum) username ,rownum user_id from all_users where rownum < 5; - - --Act - ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected).join_by('USER_ID')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_cont_join_incl_cols_as_lst is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'b' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum * 20 rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).not_to_contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_con_join_incl_cols_as_lst2 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'b' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum * 20 rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected).include(ut3_develop.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_cont_join_excl_cols_as_lst is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'y' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum * 20 as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).not_to_contain(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_con_join_excl_cols_as_lst2 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'y' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10; - open l_expected for select rownum * 20 as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4; - --Act - ut3_develop.ut.expect(l_actual).not_to(ut3_develop.contain(l_expected).exclude(ut3_develop.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN')); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure to_contain_duplicates is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_actual for select rownum as rn from dual a connect by level < 10 - union all - select rownum as rn from dual a connect by level < 4; - open l_expected for select rownum as rn from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure to_contain_duplicates_fail is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - open l_actual for select rownum as rn from dual a connect by level < 10; - open l_expected for select rownum as rn from dual a connect by level < 4 - union all select rownum as rn from dual a connect by level < 4; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 9 ] was expected to contain: refcursor [ count = 6 ] -%Diff: -%Rows: [ 3 differences ] -%Missing: % -%Missing: % -%Missing: %]'; - 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_not_contain_fails_1245 is - c1 sys_refcursor; - c2 sys_refcursor; - begin - open c1 for select 'a' as letter from dual union all select 'b' from dual; - open c2 for select 'c' as letter from dual; - ut3_develop.ut.expect(c1).not_to(ut3_develop.contain(c2)); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure udt_messg_format_eq is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_expected_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_expected_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select object_name, owner from all_objects where rownum < 3; - open l_expected for select value(x) as udt from table(l_expected_tab) x; - - --Act - ut3_develop.ut.expect(l_actual).to_contain(l_expected); - --Assert - l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to contain: refcursor [ count = 2 ] -%Diff: -%Columns: -%Column [data-type: UT_KEY_VALUE_PAIR] is missing. Expected column position: 1. -%Column [position: 1, data-type: VARCHAR2] is not expected in results. -%Column [position: 2, data-type: VARCHAR2] is not expected in results. -%Rows: [ 2 differences ] -%Missing: 1Something 1 -%Missing: 2Something 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 udt_messg_format_empt is - l_actual sys_refcursor; - l_actual_tab ut3_develop.ut_key_value_pairs := ut3_develop.ut_key_value_pairs(); - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - select ut3_develop.ut_key_value_pair(rownum,'Something '||rownum) - bulk collect into l_actual_tab - from dual connect by level <=2; - - --Arrange - open l_actual for select value(x) as udt from table(l_actual_tab) x; - - --Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - l_expected_message := q'[%Actual: (refcursor [ count = 2 ]) -%Data-types: -%UT_KEY_VALUE_PAIR -%Data: -%1Something 12Something 2 -%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 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 % ut3_develop.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_develop.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 % ut3_develop.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_develop.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_develop.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_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - ut3_develop.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_develop.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_develop.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_develop.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 space_only_vs_empty 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_develop.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 tab_only_vs_empty 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(chr(9))); - --Assert - ut3_develop.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 insignificant_start_end_space 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_develop.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 double_vs_single_start_end_ws 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_develop.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 leading_tab_vs_space is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_expected for - select ' t' t1 from dual; - - open l_actual for - select chr(9)||'t' t1 from dual; - --Assert - ut3_develop.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_develop.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_develop.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_develop.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; - - procedure compare_long_column_names is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - -- populate actual - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - open l_actual for - select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; - - open l_expected for - select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; - - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include('ID,SOME_COLUMN_WITH_A_PRETTY_LONG_ENOUGH_NAME').join_by('ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - $else - null; - $end - end; - - procedure compare_specific_column_names is - function get_cursor return sys_refcursor is - l_result sys_refcursor; - begin - open l_result for - select 'a' as item_data, rownum as data_id, rownum as item_no, rownum as dup_no, rownum as position from dual; - return l_result; - end; - begin - ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor()); - ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor()).unordered(); - ut3_develop.ut.expect(get_cursor()).to_equal(get_cursor()).join_by('ITEM_DATA,DATA_ID,ITEM_NO,DUP_NO'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure multiple_cursor_expectations is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_actual for select rownum rn from dual connect by level < 5; - open l_expected for select rownum rn from dual connect by level = 1; - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - open l_actual for select rownum rn from dual connect by level < 3; - open l_expected for select * from (select rownum rn from dual connect by level < 3) order by 1 desc; - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations(1)).to_equal( -'Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 1 ] -Diff: -Rows: [ 3 differences ] - Row No. 2 - Extra: 2 - Row No. 3 - Extra: 3 - Row No. 4 - Extra: 4' - ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations(2)).to_equal( -'Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ] -Diff: -Rows: [ 2 differences ] - Row No. 1 - Actual: 1 - Row No. 1 - Expected: 2 - Row No. 2 - Actual: 2 - Row No. 2 - Expected: 1' - ); - end; - - procedure cr_joinby_compare_issue_1293 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_expected for - select 'FOO' username, 12 from dual union all - select 'TEST' username, -600 user_id from dual - order by 1 desc; - open l_actual for - select 'FOO' username, 12 from dual union all - select 'TEST' username, -600 user_id from dual union all - -- DUPLICATE!!! - select 'TEST' username, -600 user_id from dual - order by 1 asc; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure cr_not_joinby_comp_issue_1293 is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - --Arrange - open l_expected for - select 'FOO' username, 12 from dual union all - select 'TEST' username, -600 user_id from dual - order by 1 desc; - open l_actual for - select 'FOO' username, 12 from dual union all - select 'TEST' username, -600 user_id from dual union all - -- DUPLICATE!!! - select 'TEST' username, -600 user_id from dual - order by 1 asc; - --Act - ut3_develop.ut.expect(l_actual).to_equal(l_expected); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ diff --git a/test/ut3_user/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks deleted file mode 100644 index 8cceb5e01..000000000 --- a/test/ut3_user/expectations/test_expectations_cursor.pks +++ /dev/null @@ -1,495 +0,0 @@ -create or replace package test_expectations_cursor is - - --%suite(cursor expectations) - --%suitepath(utplsql.test_user.expectations) - - --%aftereach - procedure cleanup_expectations; - - procedure setup_temp_table_test; - procedure cleanup_temp_table_test; - - --%test(Compares data from cursor on temporary table) - --%beforetest(setup_temp_table_test) - --%aftertest(cleanup_temp_table_test) - procedure with_temp_table; - - --%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; - - --%test(Gives success when both cursors are null) - procedure success_on_both_null; - - --%test(Gives success on to_be_null if cursor is null) - procedure success_to_be_null; - - --%test(Gives success on not_to_be_not_null if cursor is null) - procedure success_not_to_be_not_null; - - --%test(Gives success on not_to_be_null if cursor is not null) - procedure success_not_to_be_null; - - --%test(Gives success on to_be_not_null if cursor is not null) - procedure success_to_be_not_null; - - --%test(Gives success on is_empty if cursor is empty) - procedure success_is_empty; - - --%test(Gives success on is_not_empty if cursor is not empty) - procedure success_is_not_empty; - - --%test(Gives failure on is_null if cursor is null) - procedure failure_is_null; - - --%test(Gives failure on is_not_null if cursor is not null) - procedure failure_is_not_null; - - --%test(Gives failure on is_empty if cursor is empty) - procedure failure_is_empty; - - --%test(Gives failure on is_not_empty if cursor is not empty) - procedure failure_is_not_empty; - - --%test(Gives failure when one cursor is empty and another is null) - procedure fail_null_vs_empty; - - --%test(Gives failure when different data present in one of rows) - procedure fail_on_difference; - - --%test(Gives failure when more rows exist in actual) - procedure fail_on_expected_missing; - - --%test(Gives failure when more rows exist in expected) - procedure fail_on_actual_missing; - - --%test(Gives failure when different column name is used in cursors) - procedure fail_on_different_column_name; - - --%test(Gives failure when different column ordering is used in cursors when enforced column order) - procedure fail_on_different_column_order; - - --%test(Pass when different column ordering is used in cursors) - procedure pass_on_different_column_order; - - --%test(Pass when different column ordering is used in cursors - shortname) - procedure pass_on_diff_column_ord_uc; - - --%test(Fail and highlight diffrence between columns when columns are unordered and different value) - procedure fail_on_multi_diff_col_order; - - --%test(Fail and highlight diffrence between columns when columns are unordered and different value - shortname) - procedure fail_on_multi_diff_col_ord_uc; - - --%test(Gives failure when different row ordering is used in cursors) - procedure fail_on_different_row_order; - - --%test(Compares time part of date when set_nls was used) - procedure include_time_in_date_with_nls; - - --%test(Uses default NLS for date when set_nls was not used) - procedure uses_default_nls_for_date; - - --%test(List of columns to exclude is case sensitive) - procedure exclude_columns_as_list; - - --%test(Comma separated list of columns to exclude is case sensitive) - procedure exclude_columns_as_csv; - - --%test(Excludes list of mixed columns and XPath) - procedure exclude_columns_as_mixed_list; - - --%test(Excludes comma separated list of mixed columns and XPath) - procedure exclude_columns_as_mix_csv_lst; - - --%test(Exclude column with invalid filter will result in column being included ) - procedure exclude_columns_xpath_invalid; - - --%test(Exclude columns by XPath is case sensitive) - procedure exclude_columns_xpath; - - --%test(Excludes existing columns when some of columns on exclude are not valid column names) - procedure exclude_ignores_invalid_column; - - --%test(List of columns to include is case sensitive) - procedure include_columns_as_list; - - --%test(Comma separated list of columns to include is case sensitive) - procedure include_columns_as_csv; - - --%test(Include columns by XPath is case sensitive) - procedure include_columns_xpath; - - --%test(Includes existing columns when some of columns on exclude are not valid column names) - procedure include_ignores_invalid_column; - - --%test(Includes only columns that are not excluded using combination of CSV and XPath) - procedure include_exclude_col_csv_xpath; - - --%test(Includes only columns that are not on exclude list) - procedure include_exclude_columns_list; - - --%test(Reports data-diff on rows mismatch) - procedure data_diff_on_rows_mismatch; - - --%test(Char and varchar2 data-types are equal) - procedure char_and_varchar2_col_is_equal; - - --%test(Reports column diff on cursor with different column data-type) - procedure column_diff_on_data_type_diff; - - --%test(Reports column diff on cursor with different column name) - procedure column_diff_on_col_name_diff; - - --%test(Reports column diff on cursor with different column positions when column order is enforced) - procedure column_diff_on_col_position; - - --%test(Reports column diff on cursor with different column positions) - procedure column_diff_on_col_pos_unord; - - --%test(Reports only mismatched columns on row data mismatch) - procedure data_diff_on_col_data_mismatch; - - --%test(Reports only first 20 rows of diff and gives a full diff count) - procedure data_diff_on_20_rows_only; - - --%test(Reports data diff and column diff when both are different with enforced ordered columns) - procedure column_and_data_diff; - - --%test(Reports data diff and column diff when both are different when columns are not ordered) - procedure col_and_data_diff_not_ordered; - - procedure prepare_table; - procedure cleanup_table; - - --%test(Compares cursor on table to cursor on plsql data) - --%beforetest(prepare_table) - --%aftertest(cleanup_table) - procedure compares_sql_and_plsql_types; - - --%test(Closes the cursor after use) - procedure closes_cursor_after_use; - - --%test(Closes the cursor after use when exception was raised) - procedure closes_cursor_after_use_on_err; - - --%test(Reports exception when cursor raises exception) - procedure reports_on_exception_in_cursor; - - --%test(Reports an exception when cursor is closed) - procedure exception_when_closed_cursor; - - --%test(Compares cursors with more than 1000 rows) - procedure compares_over_1000_rows; - - --%test(Adds a warning when using depreciated syntax to_equal( a_expected sys_refcursor, a_exclude varchar2 )) - procedure deprec_to_equal_excl_varch; - - --%test(Adds a warning when using depreciated syntax to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )) - procedure deprec_to_equal_excl_list; - - --%test(Adds a warning when using depreciated syntax not_to_equal( a_expected sys_refcursor, a_exclude varchar2 )) - procedure deprec_not_to_equal_excl_varch; - - --%test(Adds a warning when using depreciated syntax not_to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )) - procedure deprec_not_to_equal_excl_list; - - --%test(Adds a warning when using depreciated syntax to_( equal( a_expected sys_refcursor, a_exclude varchar2 ) )) - procedure deprec_equal_excl_varch; - - --%test(Adds a warning when using depreciated syntax to_( equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )) ) - procedure deprec_equal_excl_list; - - --%test(Reports column diff on cursor with column name implicit ) - procedure col_diff_on_col_name_implicit; - - --%test(Reports column match on cursor with column name implicit ) - procedure col_mtch_on_col_name_implicit; - - --%test( Compare cursors using unordered method success) - procedure cursor_unorderd_compr_success; - - --%test( Compare cursors using unordered method success and unordered columns position) - procedure cursor_unord_compr_success_uc; - - --%test( Compare cursors using unordered method failure) - procedure cursor_unordered_compare_fail; - - --%test( Compare cursors join by single key ) - procedure cursor_joinby_compare; - - --%test( Compare cursors join by single key with unordered columns position using shortname) - procedure cursor_joinby_compare_uc; - - --%test(Compare cursors by single key with unordered columns position) - procedure cursor_joinby_col_not_ord; - - --%test( Compare cursors join by composite key) - procedure cursor_joinby_compare_twocols; - - --%test( Compare cursors join by single key - key doesnt exists ) - procedure cursor_joinby_compare_nokey; - - --%test( Compare cursors join by composite key - one part of key doesnt exists ) - procedure cur_joinby_comp_twocols_nokey; - - --%test( Compare cursors join by single key - key doesnt is excluded ) - procedure cursor_joinby_compare_exkey; - - --%test( Compare cursors join by composite key - one part of key is excluded exists ) - procedure cur_joinby_comp_twocols_exkey; - - --%test( Compare cursors join by single key - key doesnt exists in expected) - procedure cursor_joinby_comp_nokey_ex; - - --%test( Compare cursors join by single key - key doesnt exists in actual) - procedure cursor_joinby_comp_nokey_ac; - - --%test( Compare cursors join by single key more than 1000 rows) - procedure cursor_joinby_compare_1000; - - --%test( Compare cursors unorder more than 1000 rows) - procedure cursor_unorder_compare_1000; - - --%test( Compare two column cursors join by and fail to match ) - procedure cursor_joinby_compare_fail; - - --%test( Compare two column cursors join by two columns and fail to match ) - procedure cursor_joinby_cmp_twocol_fail; - - --%test( Compare three column cursors join by two columns and fail to match ) - procedure cur_joinby_cmp_threcol_fail; - - --%test(Unordered List of columns to include) - procedure unord_incl_cols_as_list; - - --%test(Join By List of columns to include) - procedure joinby_incl_cols_as_list; - - --%test(Unordered List of columns to exclude) - procedure unord_excl_cols_as_list; - - --%test(Join By List of columns to exclude) - procedure joinby_excl_cols_as_list; - - --%test(Exclude columns of different type) - procedure excl_dif_cols_as_list; - - --%test(Include column of same type leaving different type out) - procedure inlc_dif_cols_as_list; - - --%test(Include column of same type leaving different type out and exclude different type) - procedure inlc_exc_dif_cols_as_list; - - --%test(Compare object type unordered) - procedure compare_obj_typ_col_un; - - --%test(Compare object type join by) - procedure compare_obj_typ_col_jb; - - --%test(Compare nested table type unordered fail) - procedure comp_obj_typ_col_un_fail; - - --%test(Compare object type join by fail) - procedure comp_obj_typ_col_jb_fail; - - --%test(Compare object type join by multi key) - procedure comp_obj_typ_col_jb_multi; - - --%test(Compare object type join by missing nested key) - procedure comp_obj_typ_col_jb_nokey; - - --%test(Compare table type join by) - procedure compare_nest_tab_col_jb; - - --%test(Compare table type join by - Failure) - procedure compare_nest_tab_col_jb_fail; - - --%test(Compare table type join by mulitple columns) - procedure compare_nest_tab_cols_jb; - - --%test(Compare table type join by multiple columns- Failure) - procedure compare_nest_tab_cols_jb_fail; - - --%test(Compare table type as column join by multiple columns - Cannot find match) - procedure compare_tabtype_as_cols_jb; - - --%test(Compare table type as column normal compare ) - procedure compare_tabtype_as_cols; - - --%test(Compare table type as column join on collection element ) - procedure compare_tabtype_as_cols_coll; - - --%test(Compare same content on record with collections join on record) - procedure compare_rec_colltype_as_cols; - - --%test(Compare same content record with collection join on record attribute) - procedure compare_rec_colltype_as_attr; - - --%test(Compare same content record with collection join on whole collection) - procedure compare_collection_in_rec; - - --%test(Compare diffrent content record with collection join on record attribute) - procedure compare_rec_coll_as_cols_fl; - - --%test(Trying to join on collection element inside record ) - procedure compare_rec_coll_as_join; - - --%test( Unordered fix for issues with duplicate no : #764 ) - procedure unordered_fix_764; - - --%test( Success when cursor contains data from another cursor) - procedure cursor_to_contain; - - --%test( Fail cursor contains data from another cursor using second keyword) - procedure cursor_to_contain_fail; - - --%test( Success cursor to contain cursor with unordered columns) - procedure cursor_to_contain_uc; - - --%test( Does not fail when comparing cursor to contain cursor with unordered rows option) - procedure cursor_to_contain_unordered; - - --%test( Cursor contains data from another cursor with joinby) - procedure cursor_contain_joinby; - - --%test( Fail cursor contains data from another cursor with joinby) - procedure cursor_contain_joinby_fail; - - --%test(Cursor contains data with list of columns to include) - procedure to_contain_incl_cols_as_list; - - --%test(Cursor contains data with of columns to include and join by value) - procedure to_cont_join_incl_cols_as_lst; - - --%test(Cursor contains data with of columns to exclude and join by value) - procedure contain_join_excl_cols_as_lst; - - --%test(Cursor contains data with of columns to exclude) - procedure contain_excl_cols_as_list; - - --%test( Cursor not to contains data from another cursor) - procedure cursor_not_to_contain; - - --%test( Cursor not_to[contain] data from another cursor) - procedure cursor_not_to_contain2; - - --%test( Cursor fail not to contains data from another cursor) - procedure cursor_not_to_contain_fail; - - --%test( Cursor fail not_to[contain] data from another cursor) - procedure cursor_not_to_contain_fail2; - - --%test( Cursor not contains data from another cursor with joinby clause) - procedure cursor_not_to_contain_joinby; - - --%test( Cursor not_to[contain] data from another cursor with joinby clause) - procedure cursor_not_to_contain_joinby2; - - --%test(Cursor not contains data with of columns to include and join by value) - procedure not_cont_join_incl_cols_as_lst; - - --%test(Cursor not_to[contain] data with of columns to include and join by value) - procedure not_con_join_incl_cols_as_lst2; - - --%test(Cursor not contains data with of columns to exclude and join by value) - procedure not_cont_join_excl_cols_as_lst; - - --%test(Cursor not_to[contain] data with of columns to exclude and join by value) - procedure not_con_join_excl_cols_as_lst2; - - --%test(Cursor to contain duplicates) - procedure to_contain_duplicates; - - --%test(Cursor to contain duplicates fail) - procedure to_contain_duplicates_fail; - - --%test(Cursor using not_to[contain] fails #1245) - procedure to_not_contain_fails_1245; - - --%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; - - --%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 reading properly in XMLTable - See - Issue #880 */ - --%disabled - --%test ( Space-only string is not equal empty string ) - procedure space_only_vs_empty; - - /*Oracle Bug not reading properly in XMLTable - See - Issue #880 */ - --%disabled - --%test ( Tab-only string is not equal empty string ) - procedure tab_only_vs_empty; - - --%test ( Insignificant start/end whitespaces are considered ) - procedure insignificant_start_end_space; - - --%test ( Double and single leading/trailing space is distinguished ) - procedure double_vs_single_start_end_ws; - - --%test ( Leading Tab vs. Space is distinguished ) - procedure leading_tab_vs_space; - - - --%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; - - --%test( Compares cursors with long column names - Issue #952 ) - procedure compare_long_column_names; - - --%test( Compares cursors with specific column names - Issue #997 ) - procedure compare_specific_column_names; - - --%test( Multiple failures reported correctly - Issue #998 ) - procedure multiple_cursor_expectations; - - --%test( Compares cursors with duplicate rows using join by - Issue #1293 ) - procedure cr_joinby_compare_issue_1293; - - --%test( Compares cursors with duplicate rows - Issue #1293 ) - procedure cr_not_joinby_comp_issue_1293; - -end; -/ diff --git a/test/ut3_user/expectations/test_expectations_json.pkb b/test/ut3_user/expectations/test_expectations_json.pkb deleted file mode 100644 index 2c501d71f..000000000 --- a/test/ut3_user/expectations/test_expectations_json.pkb +++ /dev/null @@ -1,1807 +0,0 @@ -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_develop.ut.expect( l_actual ).to_( ut3_develop.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_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"]}'); - l_expected := 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_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - l_expected_message := q'[%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); - ut.expect(l_actual_message).to_be_like('%Diff: 20 differences found%'); - ut.expect(l_actual_message).to_be_like('%13 missing properties%'); - ut.expect(l_actual_message).to_be_like('%4 unequal values%'); - ut.expect(l_actual_message).to_be_like('%3 incorrect types%'); - end; - - procedure null_json_variable - as - l_expected json_object_t ; - begin - -- Arrange - l_expected := cast (null as json_object_t ); - - --Act - ut3_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_develop.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_actual := 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_expected := 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_develop.ut.expect(json_array_t(json_query(l_actual.stringify,'$.Actors[1].children'))).to_equal(json_array_t(json_query(l_expected - .stringify,'$.Actors.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_develop.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_develop.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_develop.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_actual := 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_expected := 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_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - l_expected_message := q'[%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); - ut.expect(l_actual_message).to_be_like('%Diff: 133 differences found, showing first 20%'); - ut.expect(l_actual_message).to_be_like('%1 missing properties%'); - ut.expect(l_actual_message).to_be_like('%132 unequal values%'); - 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_develop.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_develop.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - $if dbms_db_version.version >= 21 $then - - procedure success_on_same_data_njson - as - l_actual json; - begin - -- Arrange - l_actual := json(' { - "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_develop.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_njson - as - l_expected json; - l_actual json; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - -- Arrange - l_actual := json('{"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_expected := json('{"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_develop.ut.expect( l_actual ).to_equal( l_expected ); - --Assert - l_expected_message := q'[%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); - ut.expect(l_actual_message).to_be_like('%Diff: 20 differences found%'); - ut.expect(l_actual_message).to_be_like('%13 missing properties%'); - ut.expect(l_actual_message).to_be_like('%4 unequal values%'); - ut.expect(l_actual_message).to_be_like('%3 incorrect types%'); - end; - - - --Please note that by the looks of things the call to json() results in null value being returned. - procedure null_json_variable_njson - as - l_expected json ; - begin - -- Arrange - l_expected := cast (null as json ); - - --Act - ut3_develop.ut.expect( l_expected ).to_be_null; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure to_have_count_njson as - l_actual json; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - -- Arrange - l_actual := json('{"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_develop.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_njson - as - l_actual json; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - -- Arrange - l_actual := json('{"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_develop.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_njson - as - l_actual json; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - -- Arrange - l_actual := json('{"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_develop.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_njson - as - l_actual json; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - -- Arrange - l_actual := json('{"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_develop.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; - - $end - - procedure p_1113_reg_exp_chg_with_act is - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - ut3_develop.ut.expect(json_element_t.parse('{"a":"value a"}')).to_equal(json_element_t.parse('{"a":"value b"}')); - - --Assert - l_expected_message := q'[%Actual: json was expected to equal: json -%Diff: 1 differences found -%1 unequal values -%Actual value: "value a" was expected to be: "value b" on path: $."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; - - -end; -/ diff --git a/test/ut3_user/expectations/test_expectations_json.pks b/test/ut3_user/expectations/test_expectations_json.pks deleted file mode 100644 index 410c3050b..000000000 --- a/test/ut3_user/expectations/test_expectations_json.pks +++ /dev/null @@ -1,107 +0,0 @@ -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; - - $if dbms_db_version.version >= 21 $then - - --%test(Gives success for identical data using native json for 21c and above) - procedure success_on_same_data_njson; - - --%test(Gives failure for different data using native json for 21c and above) - procedure fail_on_diff_data_njson; - - --%test( Json variable is null using native json for 21c and above) - procedure null_json_variable_njson; - - --%test( Json object to have count using native json for 21c and above) - procedure to_have_count_njson; - - --%test( Fail Json object to have count using native json for 21c and above) - procedure fail_to_have_count_njson; - - --%test( Json object not to have count using native json for 21c and above) - procedure not_to_have_count_njson; - - --%test( Fail Json object not to have count using native json for 21c and above) - procedure fail_not_to_have_count_njson; - - $end - - --%test( Regression scenario tests for issue #1113 where the expected has been switched with actual) - procedure p_1113_reg_exp_chg_with_act; - -end; -/ diff --git a/test/ut3_user/expectations/test_matchers.pkb b/test/ut3_user/expectations/test_matchers.pkb deleted file mode 100644 index e1d87d4cb..000000000 --- a/test/ut3_user/expectations/test_matchers.pkb +++ /dev/null @@ -1,271 +0,0 @@ -create or replace package body test_matchers is - - procedure cleanup_expectations is - begin - 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 - l_statement varchar2(32767); - begin - l_statement := ' - declare - l_actual '||a_type||' := '||a_actual_value||'; - l_expected '||a_type||' := '||a_expected_value||'; - begin - ut3_develop.ut.expect( l_actual ).'||a_prefix||'to_'||a_matcher||'( l_expected ); - end;'; - execute immediate l_statement; - 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(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); - end if; - cleanup_expectations(); - end exec_matcher; - - procedure exec_be_between(a_type varchar2, a_actual_value varchar2, a_expected1_value varchar2, a_expected2_value varchar2,a_result integer) is - l_statement varchar2(32767); - begin - l_statement := ' - declare - l_actual_value '||a_type||' := '||a_actual_value||'; - l_lower '||a_type||' := '||a_expected1_value||'; - l_higher '||a_type||' := '||a_expected2_value||'; - begin - ut3_develop.ut.expect(l_actual_value).to_be_between(l_lower, l_higher); - end;'; - execute immediate l_statement; - 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(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); - end if; - cleanup_expectations(); - end exec_be_between; - - procedure exec_be_between2(a_type varchar2, a_actual_value varchar2, a_expected1_value varchar2, a_expected2_value varchar2,a_result integer, a_not_prefix varchar2 default null) is - l_statement varchar2(32767); - begin - l_statement := ' - declare - l_actual_value '||a_type||' := '||a_actual_value||'; - l_value1 '||a_type||' := '||a_expected1_value||'; - l_value2 '||a_type||' := '||a_expected2_value||'; - begin - ut3_develop.ut.expect(l_actual_value).'||a_not_prefix||'to_be_between(l_value1, l_value2); - end;'; - execute immediate l_statement; - 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(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); - end if; - cleanup_expectations(); - end exec_be_between2; - - procedure exec_be_like(a_type varchar2, a_value varchar2, a_pattern varchar2, a_escape varchar2, a_result integer, a_prefix varchar2 default null) is - begin - execute immediate - 'declare - l_actual ' || a_type || ' := '||a_value||'; - l_pattern varchar2(32767) := :pattern; - l_escape_char varchar2(32767) := :a_escape; - l_result integer; - begin - ut3_develop.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_tester_helper.main_helper.gc_success then - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); - else - 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 - l_statement := - 'declare - l_actual '||a_type||' := '||a_actual_value||'; - l_pattern varchar2(32767) := :a_pattern; - l_modifiers varchar2(32767) := :a_modifiers; - l_result integer; - begin - ut3_develop.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_tester_helper.main_helper.gc_success then - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_equal(0); - else - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num()).to_be_greater_than(0); - end if; - cleanup_expectations(); - end; - - procedure test_be_between2 is - begin - - --failure when value out of range - 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_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_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_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_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_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_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_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_tester_helper.main_helper.gc_failure, ''); - end; - - procedure test_match is - begin - 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_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_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_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_tester_helper.main_helper.gc_failure); - end; - - procedure test_be_like is - begin - 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_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_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_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_tester_helper.main_helper.gc_failure); - end; - - procedure test_timestamp_between is - l_value timestamp := to_timestamp('1997-01-31 09:26:50.13','YYYY-MM-DD HH24.MI.SS.FF'); - l_value_lower timestamp := to_timestamp('1997-01-31 09:26:50.11','YYYY-MM-DD HH24.MI.SS.FF'); - l_value_upper timestamp := to_timestamp('1997-01-31 09:26:50.14','YYYY-MM-DD HH24.MI.SS.FF'); - begin - ut3_develop.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); - ut3_develop.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); - end; - - procedure test_timestamp_ltz_between is - l_value timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +02:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_lower timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_upper timestamp with local time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - begin - ut3_develop.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); - ut3_develop.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); - end; - - procedure test_timestamp_tz_between is - l_value timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +02:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_lower timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +03:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - l_value_upper timestamp with time zone := to_timestamp_tz('1997-01-31 09:26:50.12 +01:00','YYYY-MM-DD HH24.MI.SS.FF TZR'); - begin - ut3_develop.ut.expect(l_value).to_be_between(l_value_lower, l_value_upper); - ut3_develop.ut.expect(l_value).not_to_be_between(l_value_upper, l_value_lower); - end; - -end test_matchers; -/ diff --git a/test/ut3_user/expectations/test_matchers.pks b/test/ut3_user/expectations/test_matchers.pks deleted file mode 100644 index e3e22e0cd..000000000 --- a/test/ut3_user/expectations/test_matchers.pks +++ /dev/null @@ -1,27 +0,0 @@ -create or replace package test_matchers is - - --%suite(matchers) - --%suitepath(utplsql.test_user.expectations) - - --%aftereach - procedure cleanup_expectations; - - --%test - procedure test_be_between2; - --%test - procedure test_match; - - --%test - procedure test_be_like; - - --%test - procedure test_timestamp_between; - - --%test - procedure test_timestamp_ltz_between; - - --%test - procedure test_timestamp_tz_between; - -end test_matchers; -/ 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 deleted file mode 100644 index 448addb8c..000000000 --- a/test/ut3_user/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 - 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/ut3_user/expectations/unary/test_expect_not_to_be_null.pks b/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pks deleted file mode 100644 index 11648d5d2..000000000 --- a/test/ut3_user/expectations/unary/test_expect_not_to_be_null.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_expect_not_to_be_null -is - --%suite(not_to_be_null) - --%suitepath(utplsql.test_user.expectations.unary) - - --%aftereach - procedure cleanup_expectations; - - --%beforeall - procedure create_types; - - --%afterall - procedure drop_types; - - --%test(Gives success for not null blob) - procedure blob_not_null; - - --%test(Gives success for blob with length 0) - procedure blob_0_length; - - --%test(Gives success for not null boolean) - procedure boolean_not_null; - - --%test(Gives success for not null clob) - procedure clob_not_null; - - --%test(Gives success for clob with length 0) - procedure clob_0_length; - - --%test(Gives success for not null date) - procedure date_not_null; - - --%test(Gives success for not null number) - procedure number_not_null; - - --%test(Gives success for not null timestamp) - procedure timestamp_not_null; - - --%test(Gives success for not null timestamp with local time zone) - procedure timestamp_with_ltz_not_null; - - --%test(Gives success for not null timestamp with time zone) - procedure timestamp_with_tz_not_null; - - --%test(Gives success for not null varchar2) - procedure varchar2_not_null; - - --%test(Gives success for initialized object within anydata) - procedure initialized_object; - - --%test(Gives success for initialized nested table within anydata) - procedure initialized_nested_table; - - --%test(Gives success for initialized varray within anydata) - procedure initialized_varray; - - --%test(Gives failure with null blob) - procedure null_blob; - - --%test(Gives failure with null boolean) - procedure null_boolean; - - --%test(Gives failure with null clob) - procedure null_clob; - - --%test(Gives failure with null date) - procedure null_date; - - --%test(Gives failure with null number) - procedure null_number; - - --%test(Gives failure null timestamp) - procedure null_timestamp; - - --%test(Gives failure with null timestamp with local time zone) - procedure null_timestamp_with_ltz; - - --%test(Gives failure with null timestamp with time zone) - procedure null_timestamp_with_tz; - - --%test(Gives failure with null varchar2) - procedure null_varchar2; - - --%test(Gives failure with null anydata) - procedure null_anydata; - - --%test(Gives failure with uninitialized object within anydata) - procedure uninit_object_in_anydata; - - --%test(Gives failure with uninitialized nested table within anydata) - procedure uninit_nested_table_in_anydata; - - --%test(Gives failure with uninitialized varray within anydata) - procedure uninit_varray_in_anydata; - -end test_expect_not_to_be_null; -/ diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb deleted file mode 100644 index 931e24d10..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_be_empty.pkb +++ /dev/null @@ -1,270 +0,0 @@ -create or replace package body test_expect_to_be_empty is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - procedure success_be_empty_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual where 1 = 2; - --Act - ut3_develop.ut.expect(l_cursor).to_be_empty; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_be_empty_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual; - --Act - ut3_develop.ut.expect(l_cursor).to_be_empty; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_be_empty_cursor_report is - l_cursor sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_cursor for select * from dual; - --Act - ut3_develop.ut.expect(l_cursor).to_be_empty; - - l_expected_message := q'[Actual: (refcursor [ count = 1 ])% - X% - 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 success_not_be_empty_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual; - --Act - ut3_develop.ut.expect(l_cursor).not_to_be_empty; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_not_be_empty_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual where 1 = 2; - --Act - ut3_develop.ut.expect(l_cursor).not_to_be_empty; - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_be_empty_collection is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); - -- Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_be_empty_collection is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); - -- Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_not_be_empty_coll is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); - -- Act - ut3_develop.ut.expect(l_actual).not_to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_not_be_empty_collection is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); - -- Act - ut3_develop.ut.expect(l_actual).not_to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_be_empty_null_collection is - l_actual anydata; - l_data ora_mining_varchar2_nt; - begin - --Arrange - l_actual := anydata.convertcollection(l_data); - -- Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - 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 - l_actual anydata; - l_data ora_mining_varchar2_nt; - begin - --Arrange - l_actual := anydata.convertcollection(l_data); - -- Act - ut3_develop.ut.expect(l_actual).not_to_be_empty(); - --Assert - 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_tester_helper.test_dummy_number(1)); - -- Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - 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_tester_helper.test_dummy_number; - begin - --Arrange - l_actual := anydata.convertObject(l_data); - -- Act - ut3_develop.ut.expect(l_actual).to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_be_empty_number is - begin - -- Act - ut3_develop.ut.expect( 1 ).to_( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - /** - * https://docs.oracle.com/en/database/oracle/oracle-database/18/adobj/declaring-initializing-objects-in-plsql.html#GUID-23135172-82E2-4C3E-800D-E584B43B578E - * User-defined types, just like collections, are atomically null, until you initialize the object by calling the constructor for its object type. That is, the object itself is null, not just its attributes. - */ - procedure fail_not_be_empty_object is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); - -- Act - ut3_develop.ut.expect(l_actual).not_to_be_empty(); - --Assert - 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_tester_helper.test_dummy_number; - begin - --Arrange - l_actual := anydata.convertObject(l_data); - -- Act - ut3_develop.ut.expect(l_actual).not_to_be_empty(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_not_be_empty_number is - begin - -- Act - ut3_develop.ut.expect( 1 ).not_to( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_be_empty_clob is - begin - -- Act - ut3_develop.ut.expect( empty_clob() ).to_( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_be_empty_clob is - begin - -- Act - ut3_develop.ut.expect( to_clob(' ') ).to_( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_be_empty_blob is - begin - -- Act - ut3_develop.ut.expect( empty_blob() ).to_( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_be_empty_blob is - begin - -- Act - ut3_develop.ut.expect( to_blob('AA') ).to_( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - - procedure fail_not_be_empty_clob is - begin - -- Act - ut3_develop.ut.expect( empty_clob() ).not_to( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_not_be_empty_clob is - begin - -- Act - ut3_develop.ut.expect( to_clob(' ') ).not_to( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_not_be_empty_blob is - begin - -- Act - ut3_develop.ut.expect( empty_blob() ).not_to( ut3_develop.be_empty() ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_not_be_empty_blob is - begin - -- Act - ut3_develop.ut.expect( to_blob('AA') ).not_to( ut3_develop.be_empty() ); - --Assert - 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/ut3_user/expectations/unary/test_expect_to_be_empty.pks b/test/ut3_user/expectations/unary/test_expect_to_be_empty.pks deleted file mode 100644 index a76787ac5..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_be_empty.pks +++ /dev/null @@ -1,93 +0,0 @@ -create or replace package test_expect_to_be_empty is - - --%suite - --%suitepath(utplsql.test_user.expectations.unary) - - --%aftereach - procedure cleanup_expectations; - - --%context(to_be_empty) - - --%test(Gives success for an empty cursor) - procedure success_be_empty_cursor; - - --%test(Gives failure for a non empty cursor) - procedure fail_be_empty_cursor; - - --%test(Reports the content of cursor when cursor is not empty) - procedure fail_be_empty_cursor_report; - - --%test(Gives success for an empty collection) - procedure success_be_empty_collection; - - --%test(Gives failure for a non empty collection) - procedure fail_be_empty_collection; - - --%test(Gives failure for a NULL collection) - procedure fail_be_empty_null_collection; - - --%test(Gives failure for an object) - procedure fail_be_empty_object; - - --%test(Gives failure for a null object) - procedure fail_be_empty_null_object; - - --%test(Gives failure for number) - procedure fail_be_empty_number; - - --%test(Gives success for an empty CLOB) - procedure success_be_empty_clob; - - --%test(Gives failure for a non empty CLOB) - procedure fail_be_empty_clob; - - --%test(Gives success for an empty BLOB) - procedure success_be_empty_blob; - - --%test(Gives failure for a non empty BLOB) - procedure fail_be_empty_blob; - - --%endcontext - - --%context(not_to_be_empty) - - --%test(Gives failure for an empty cursor) - procedure fail_not_be_empty_cursor; - - --%test(Gives success for a non empty cursor) - procedure success_not_be_empty_cursor; - - --%test(Gives success for a non empty collection) - procedure success_not_be_empty_coll; - - --%test(Gives failure for an empty collection) - procedure fail_not_be_empty_collection; - - --%test(Gives failure for an empty collection) - procedure fail_not_be_empty_null_coll; - - --%test(Gives failure for an empty object) - procedure fail_not_be_empty_object; - - --%test(Gives failure for a null object) - procedure fail_not_be_empty_null_object; - - --%test(Gives failure for number) - procedure fail_not_be_empty_number; - - --%test(Gives failure for an empty CLOB) - procedure fail_not_be_empty_clob; - - --%test(Gives success for a non empty CLOB) - procedure success_not_be_empty_clob; - - --%test(Gives failure for an empty BLOB) - procedure fail_not_be_empty_blob; - - --%test(Gives success for a non empty BLOB) - procedure success_not_be_empty_blob; - - --%endcontext - -end; -/ 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 deleted file mode 100644 index 0e747eb85..000000000 --- a/test/ut3_user/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 - 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/ut3_user/expectations/unary/test_expect_to_be_not_null.pks b/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pks deleted file mode 100644 index 7cb7cc265..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_be_not_null.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_expect_to_be_not_null -is - --%suite(to_be_not_null) - --%suitepath(utplsql.test_user.expectations.unary) - - --%aftereach - procedure cleanup_expectations; - - --%beforeall - procedure create_types; - - --%afterall - procedure drop_types; - - --%test(Gives success for not null blob) - procedure blob_not_null; - - --%test(Gives success for empty blob) - procedure empty_blob; - - --%test(Gives success for not null boolean) - procedure boolean_not_null; - - --%test(Gives success for not null clob) - procedure clob_not_null; - - --%test(Gives success for empty clob) - procedure empty_clob; - - --%test(Gives success for not null date) - procedure date_not_null; - - --%test(Gives success for not null number) - procedure number_not_null; - - --%test(Gives success for not null timestamp) - procedure timestamp_not_null; - - --%test(Gives success for not null timestamp with local time zone) - procedure timestamp_with_ltz_not_null; - - --%test(Gives success for not null timestamp with time zone) - procedure timestamp_with_tz_not_null; - - --%test(Gives success for not null varchar2) - procedure varchar2_not_null; - - --%test(Gives success for initialized object within anydata) - procedure initialized_object; - - --%test(Gives success for initialized nested table within anydata) - procedure initialized_nested_table; - - --%test(Gives success for initialized varray within anydata) - procedure initialized_varray; - - --%test(Gives failure with null blob) - procedure null_blob; - - --%test(Gives failure with null boolean) - procedure null_boolean; - - --%test(Gives failure with null clob) - procedure null_clob; - - --%test(Gives failure with null date) - procedure null_date; - - --%test(Gives failure with null number) - procedure null_number; - - --%test(Gives failure null timestamp) - procedure null_timestamp; - - --%test(Gives failure with null timestamp with local time zone) - procedure null_timestamp_with_ltz; - - --%test(Gives failure with null timestamp with time zone) - procedure null_timestamp_with_tz; - - --%test(Gives failure with null varchar2) - procedure null_varchar2; - - --%test(Gives failure with null anydata) - procedure null_anydata; - - --%test(Gives failure with uninitialized object within anydata) - procedure uninit_object_in_anydata; - - --%test(Gives failure with uninitialized nested table within anydata) - procedure uninit_nested_table_in_anydata; - - --%test(Gives failure with uninitialized varray within anydata) - procedure uninit_varray_in_anydata; - -end test_expect_to_be_not_null; -/ 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 deleted file mode 100644 index c0899c08d..000000000 --- a/test/ut3_user/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 - 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/ut3_user/expectations/unary/test_expect_to_be_null.pks b/test/ut3_user/expectations/unary/test_expect_to_be_null.pks deleted file mode 100644 index f1758316e..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_be_null.pks +++ /dev/null @@ -1,97 +0,0 @@ -create or replace package test_expect_to_be_null -is - --%suite(to_be_null) - --%suitepath(utplsql.test_user.expectations.unary) - - --%aftereach - procedure cleanup_expectations; - - --%beforeall - procedure create_types; - - --%afterall - procedure drop_types; - - --%test(Gives success with null blob) - procedure null_blob; - - --%test(Gives success with null boolean) - procedure null_boolean; - - --%test(Gives success with null clob) - procedure null_clob; - - --%test(Gives success with null date) - procedure null_date; - - --%test(Gives success with null number) - procedure null_number; - - --%test(Gives success null timestamp) - procedure null_timestamp; - - --%test(Gives success with null timestamp with local time zone) - procedure null_timestamp_with_ltz; - - --%test(Gives success with null timestamp with time zone) - procedure null_timestamp_with_tz; - - --%test(Gives success with null varchar2) - procedure null_varchar2; - - --%test(Gives success with null anydata) - procedure null_anydata; - - --%test(Gives success with uninitialized object within anydata) - procedure uninit_object_in_anydata; - - --%test(Gives success with uninitialized nested table within anydata) - procedure uninit_nested_table_in_anydata; - - --%test(Gives success with uninitialized varray within anydata) - procedure uninit_varray_in_anydata; - - --%test(Gives failure for not null blob) - procedure blob_not_null; - - --%test(Gives failure with empty blob) - procedure empty_blob; - - --%test(Gives failure for not null boolean) - procedure boolean_not_null; - - --%test(Gives failure for not null clob) - procedure clob_not_null; - - --%test(Gives failure with empty clob) - procedure empty_clob; - - --%test(Gives failure for not null date) - procedure date_not_null; - - --%test(Gives failure for not null number) - procedure number_not_null; - - --%test(Gives failure for not null timestamp) - procedure timestamp_not_null; - - --%test(Gives failure for not null timestamp with local time zone) - procedure timestamp_with_ltz_not_null; - - --%test(Gives failure for not null timestamp with time zone) - procedure timestamp_with_tz_not_null; - - --%test(Gives failure for not null varchar2) - procedure varchar2_not_null; - - --%test(Gives failure for initialized object within anydata) - procedure initialized_object; - - --%test(Gives failure for initialized nested table within anydata) - procedure initialized_nested_table; - - --%test(Gives failure for initialized varray within anydata) - procedure initialized_varray; - -end test_expect_to_be_null; -/ diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb deleted file mode 100644 index c1067044b..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pkb +++ /dev/null @@ -1,139 +0,0 @@ -create or replace package body test_expect_to_be_true_false -is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - procedure to_be_true_null_boolean is - begin - --Act - ut3_develop.ut.expect( 1=null ).to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure to_be_true_success is - begin - --Act - ut3_develop.ut.expect( 1=1 ).to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure to_be_true_failure is - begin - --Act - ut3_develop.ut.expect( 1=2 ).to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure to_be_true_bad_type is - begin - --Act - ut3_develop.ut.expect( 1 ).to_be_true(); - --Assert - 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 - begin - --Act - ut3_develop.ut.expect( 1=null ).not_to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_to_be_true_success is - begin - --Act - ut3_develop.ut.expect( 1=2 ).not_to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_to_be_true_failure is - begin - --Act - ut3_develop.ut.expect( 1=1 ).not_to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - - procedure not_to_be_true_bad_type is - begin - --Act - ut3_develop.ut.expect( 1 ).not_to_be_true(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure to_be_false_null_boolean is - begin - --Act - ut3_develop.ut.expect( 1=null ).to_be_false(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure to_be_false_success is - begin - --Act - ut3_develop.ut.expect( 1=2 ).to_be_false(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure to_be_false_failure is - begin - --Act - ut3_develop.ut.expect( 1=1 ).to_be_false(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure to_be_false_bad_type is - begin - --Act - ut3_develop.ut.expect( 1 ).to_be_false(); - --Assert - 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 - begin - --Act - ut3_develop.ut.expect( 1=null ).not_to_be_false(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure not_to_be_false_success is - begin - --Act - ut3_develop.ut.expect( 1=1 ).not_to_be_false(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure not_to_be_false_failure is - begin - --Act - ut3_develop.ut.expect( 1=2 ).not_to_be_false(); - --Assert - 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 - begin - --Act - ut3_develop.ut.expect( 1 ).not_to_be_false(); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ diff --git a/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pks b/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pks deleted file mode 100644 index 28bbae6f7..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_be_true_false.pks +++ /dev/null @@ -1,58 +0,0 @@ -create or replace package test_expect_to_be_true_false -is - --%suite(to_be_true/false) - --%suitepath(utplsql.test_user.expectations.unary) - - --%aftereach - procedure cleanup_expectations; - - --%test(to_be_true - Gives failure with null boolean) - procedure to_be_true_null_boolean; - - --%test(to_be_true - Gives success with true expression) - procedure to_be_true_success; - - --%test(to_be_true - Gives failure with false expression) - procedure to_be_true_failure; - - --%test(to_be_true - Gives failure with non-boolean data type) - procedure to_be_true_bad_type; - - --%test(not_to_be_true - Gives failure with null boolean) - procedure not_to_be_true_null_boolean; - - --%test(not_to_be_true - Gives failure with true expression) - procedure not_to_be_true_success; - - --%test(not_to_be_true - Gives success with false expression) - procedure not_to_be_true_failure; - - --%test(not_to_be_true - Gives failure with non-boolean data type) - procedure not_to_be_true_bad_type; - - --%test(to_be_false - Gives failure with null boolean) - procedure to_be_false_null_boolean; - - --%test(to_be_false - Gives failure with true expression) - procedure to_be_false_success; - - --%test(to_be_false - Gives success with false expression) - procedure to_be_false_failure; - - --%test(to_be_false - Gives failure with non-boolean data type) - procedure to_be_false_bad_type; - - --%test(not_to_be_false - Gives failure with null boolean) - procedure not_to_be_false_null_boolean; - - --%test(not_to_be_false - Gives success with true expression) - procedure not_to_be_false_success; - - --%test(not_to_be_false - Gives failure with false expression) - procedure not_to_be_false_failure; - - --%test(not_to_be_false - Gives failure with non-boolean data type) - procedure not_to_be_false_bad_type; - -end; -/ diff --git a/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb b/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb deleted file mode 100644 index 2167c44ef..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_have_count.pkb +++ /dev/null @@ -1,210 +0,0 @@ -create or replace package body test_expect_to_have_count is - - procedure cleanup_expectations is - begin - ut3_tester_helper.main_helper.clear_expectations( ); - end; - - procedure success_have_count_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual connect by level <= 11; - --Act - ut3_develop.ut.expect(l_cursor).to_have_count(11); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_have_count_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual where 0=1; - --Act - ut3_develop.ut.expect(l_cursor).to_have_count(1); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_have_count_cursor_report is - l_cursor sys_refcursor; - l_actual_message varchar2(32767); - l_expected_message varchar2(32767); - begin - --Arrange - open l_cursor for select * from dual; - --Act - ut3_develop.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_tester_helper.main_helper.get_failed_expectations(1); - - --Assert - ut.expect(l_actual_message).to_be_like(l_expected_message); - end; - - procedure success_not_have_count_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual; - --Act - ut3_develop.ut.expect(l_cursor).not_to_have_count(2); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_not_have_count_cursor is - l_cursor sys_refcursor; - begin - --Arrange - open l_cursor for select * from dual where 1 = 2; - --Act - ut3_develop.ut.expect(l_cursor).not_to_have_count(0); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_have_count_collection is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); - -- Act - ut3_develop.ut.expect(l_actual).to_have_count(0); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_have_count_collection is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); - -- Act - ut3_develop.ut.expect(l_actual).to_have_count(0); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure success_not_have_count_coll is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt('a')); - -- Act - ut3_develop.ut.expect(l_actual).not_to_have_count(2); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - end; - - procedure fail_not_have_count_coll is - l_actual anydata; - begin - --Arrange - l_actual := anydata.convertcollection(ora_mining_varchar2_nt()); - -- Act - ut3_develop.ut.expect(l_actual).not_to_have_count(0); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_have_count_null_coll is - l_actual anydata; - l_data ora_mining_varchar2_nt; - begin - --Arrange - l_actual := anydata.convertcollection(l_data); - -- Act - ut3_develop.ut.expect(l_actual).to_have_count(0); - --Assert - 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 - l_actual anydata; - l_data ora_mining_varchar2_nt; - begin - --Arrange - l_actual := anydata.convertcollection(l_data); - -- Act - ut3_develop.ut.expect(l_actual).not_to_have_count(0); - --Assert - 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_tester_helper.test_dummy_number(1)); - -- Act - ut3_develop.ut.expect(l_actual).to_have_count(0); - --Assert - 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_tester_helper.test_dummy_number; - begin - --Arrange - l_actual := anydata.convertObject(l_data); - -- Act - ut3_develop.ut.expect(l_actual).to_have_count(0); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_have_count_number is - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - -- Act - ut3_develop.ut.expect( 1 ).to_( ut3_develop.have_count(0) ); - --Assert - l_expected_message := q'[%The matcher 'have count' cannot be used with data type (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_object is - l_actual anydata; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); - begin - --Arrange - l_actual := anydata.convertObject(ut3_tester_helper.test_dummy_number(1)); - -- Act - ut3_develop.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_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_tester_helper.test_dummy_number; - begin - --Arrange - l_actual := anydata.convertObject(l_data); - -- Act - ut3_develop.ut.expect(l_actual).not_to_have_count(0); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - - procedure fail_not_have_count_number is - begin - -- Act - ut3_develop.ut.expect( 1 ).not_to( ut3_develop.have_count(0) ); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; - -end; -/ \ No newline at end of file diff --git a/test/ut3_user/expectations/unary/test_expect_to_have_count.pks b/test/ut3_user/expectations/unary/test_expect_to_have_count.pks deleted file mode 100644 index b944d8800..000000000 --- a/test/ut3_user/expectations/unary/test_expect_to_have_count.pks +++ /dev/null @@ -1,61 +0,0 @@ -create or replace package test_expect_to_have_count is - - --%suite((not)to_have_count) - --%suitepath(utplsql.test_user.expectations.unary) - - --%aftereach - procedure cleanup_expectations; - - --%test(Gives success for an empty cursor) - procedure success_have_count_cursor; - - --%test(Gives failure for a non empty cursor) - procedure fail_have_count_cursor; - - --%test(Reports the content of cursor when cursor is not empty) - procedure fail_have_count_cursor_report; - - --%test(Negated - Gives success for a non empty cursor) - procedure success_not_have_count_cursor; - - --%test(Negated - Gives failure for an empty cursor) - procedure fail_not_have_count_cursor; - - --%test(Gives success for an empty collection) - procedure success_have_count_collection; - - --%test(Gives failure for a non empty collection) - procedure fail_have_count_collection; - - --%test(Negated - Gives success for a non empty collection) - procedure success_not_have_count_coll; - - --%test(Negated - Gives failure for an empty collection) - procedure fail_not_have_count_coll; - - --%test(Gives failure for a NULL collection) - procedure fail_have_count_null_coll; - - --%test(Negated - Gives failure for an empty collection) - procedure fail_not_have_count_null_coll; - - --%test(Gives failure for an object) - procedure fail_have_count_object; - - --%test(Gives failure for a null object) - procedure fail_have_count_null_object; - - --%test(Gives failure for number) - procedure fail_have_count_number; - - --%test(Negated - Gives failure for an object) - procedure fail_not_have_count_object; - - --%test(Negated - Gives failure for a null object) - procedure fail_not_have_count_null_obj; - - --%test(Negated - Gives failure for number) - procedure fail_not_have_count_number; - -end; -/ diff --git a/test/ut3_user/helpers/some_item.tps b/test/ut3_user/helpers/some_item.tps deleted file mode 100644 index 336f44d9a..000000000 --- a/test/ut3_user/helpers/some_item.tps +++ /dev/null @@ -1,6 +0,0 @@ -create or replace type some_item force as object( - item_id number(38), - item_name varchar2(250) -) -/ - diff --git a/test/ut3_user/helpers/some_items.tps b/test/ut3_user/helpers/some_items.tps deleted file mode 100644 index 8b984f8a4..000000000 --- a/test/ut3_user/helpers/some_items.tps +++ /dev/null @@ -1,2 +0,0 @@ -create or replace type some_items force as table of some_item -/ diff --git a/test/ut3_user/helpers/some_object.tps b/test/ut3_user/helpers/some_object.tps deleted file mode 100644 index 024379974..000000000 --- a/test/ut3_user/helpers/some_object.tps +++ /dev/null @@ -1,7 +0,0 @@ -create or replace type some_object force as object( - object_owner varchar2(250), - object_name varchar2(250), - create_time timestamp, - items some_items -) -/ diff --git a/test/ut3_user/reporters.pkb b/test/ut3_user/reporters.pkb deleted file mode 100644 index 031683615..000000000 --- a/test/ut3_user/reporters.pkb +++ /dev/null @@ -1,196 +0,0 @@ -create or replace package body reporters is - - procedure create_test_helper_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package test_reporters -as - --%suite(A suite for testing different outcomes from reporters) - --%suitepath(org.utplsql.tests.helpers) - - --%beforeall - procedure beforeall; - - --%beforeeach - procedure beforeeach; - - --%context(A description of some context) - --%name(some_context) - - --%test - --%beforetest(beforetest) - --%aftertest(aftertest) - procedure passing_test; - - --%endcontext - - procedure beforetest; - - procedure aftertest; - - --%test(a test with failing assertion) - procedure failing_test; - - --%test(a test raising unhandled exception) - procedure erroring_test; - - --%test(a disabled test) - --%disabled(Disabled for testing purpose) - procedure disabled_test; - - --%test(a disabled test with no reason) - --%disabled - procedure disabled_test_no_reason; - - --%aftereach - procedure aftereach; - - --%afterall - procedure afterall; - -end;]'; - - execute immediate q'[create or replace package body test_reporters -as - - procedure beforetest is - begin - dbms_output.put_line(''); - end; - - procedure aftertest - is - begin - dbms_output.put_line(''); - end; - - procedure beforeeach is - begin - dbms_output.put_line(''); - end; - - procedure aftereach is - begin - dbms_output.put_line(''); - end; - - procedure passing_test - is - begin - dbms_output.put_line(''); - ut3_develop.ut.expect(1,'Test 1 Should Pass').to_equal(1); - end; - - procedure failing_test - is - begin - dbms_output.put_line(''); - ut3_develop.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] '); - end; - - procedure erroring_test - is - l_integer_variable integer; - begin - dbms_output.put_line(''); - l_integer_variable := 'a string'; - end; - - procedure disabled_test - is - begin - dbms_output.put_line(''); - ut3_develop.ut.expect(1,'this should not execute').to_equal(1); - end; - - procedure disabled_test_no_reason - is - begin - dbms_output.put_line(''); - ut3_develop.ut.expect(1,'this should not execute').to_equal(1); - end; - - procedure beforeall is - begin - dbms_output.put_line(''); - end; - - procedure afterall is - begin - dbms_output.put_line(''); - 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_develop.ut.expect('test').to_equal(''); - end; - end;]'; - - end; - - procedure reporters_setup is - begin - create_test_helper_package; - 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 - pragma autonomous_transaction; - begin - drop_test_helper_package; - end; - - procedure check_xml_encoding_included( - a_reporter ut3_develop.ut_reporter_base, - a_client_character_set varchar2 - ) is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_reporters', a_reporter, a_client_character_set => a_client_character_set)); - 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_develop.ut_reporter_base - ) is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table( ut3_develop.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_develop.ut.expect('test').to_equal('');]' - ||'%]]>%' - ); - end; - -end reporters; -/ diff --git a/test/ut3_user/reporters.pks b/test/ut3_user/reporters.pks deleted file mode 100644 index c5ad72e22..000000000 --- a/test/ut3_user/reporters.pks +++ /dev/null @@ -1,22 +0,0 @@ -create or replace package reporters is - - --%suite - --%suitepath(utplsql.test_user) - - --%beforeall - procedure reporters_setup; - - --%afterall - procedure reporters_cleanup; - - procedure check_xml_encoding_included( - a_reporter ut3_develop.ut_reporter_base, - a_client_character_set varchar2 - ); - - procedure check_xml_failure_escaped( - a_reporter ut3_develop.ut_reporter_base - ); - -end reporters; -/ diff --git a/test/ut3_user/reporters/test_coverage.pks b/test/ut3_user/reporters/test_coverage.pks deleted file mode 100644 index 11bc6d480..000000000 --- a/test/ut3_user/reporters/test_coverage.pks +++ /dev/null @@ -1,14 +0,0 @@ -create or replace package test_coverage is - - --%suite - --%suitepath(utplsql.test_user.reporters) - - --%beforeall(ut3_tester_helper.coverage_helper.create_test_results_table) - --%beforeall(ut3_tester_helper.coverage_helper.create_dummy_coverage) - - - --%afterall(ut3_tester_helper.coverage_helper.drop_dummy_coverage) - --%afterall(ut3_tester_helper.coverage_helper.drop_test_results_table) - -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 deleted file mode 100644 index ad6c9dbb4..000000000 --- a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb +++ /dev/null @@ -1,57 +0,0 @@ -create or replace package body test_cov_cobertura_reporter is - - procedure report_on_file is - l_expected clob; - l_actual clob; - l_block_cov clob; - l_name varchar2(250); - l_file_path varchar2(250); - begin - - - --Arrange - l_name := ut3_tester_helper.coverage_helper.covered_package_name; - l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := ''; - else - l_block_cov := ''; - end if; - l_expected := - q'[ - - - -]'||l_file_path||q'[ - - - - - - -]'||l_block_cov||q'[ - - - - - - -]'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter => ut3_develop.ut_coverage_cobertura_reporter( ), - a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), - a_test_files => ut3_develop.ut_varchar2_list( ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks deleted file mode 100644 index 365815964..000000000 --- a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks +++ /dev/null @@ -1,10 +0,0 @@ -create or replace package test_cov_cobertura_reporter is - - --%suite(ut_cov_cobertura_reporter) - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(reports on a project file mapped to database object) - procedure report_on_file; - -end test_cov_cobertura_reporter; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb deleted file mode 100644 index 50d7bfe4c..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb +++ /dev/null @@ -1,43 +0,0 @@ -create or replace package body test_coverage_sonar_reporter is - - procedure report_on_file is - l_expected clob; - l_actual clob; - l_block_cov clob; - begin - --Arrange - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := ''; - else - l_block_cov := ''; - end if; - l_expected := ' - - -'||l_block_cov||' - - -'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_source_files => ut3_develop.ut_varchar2_list( 'test/ut3_develop.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[.pkb' ), - a_test_files => ut3_develop.ut_varchar2_list( ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure check_encoding_included is - begin - reporters.check_xml_encoding_included(ut3_develop.ut_coverage_sonar_reporter(), 'UTF-8'); - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks deleted file mode 100644 index 7a98355cf..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks +++ /dev/null @@ -1,13 +0,0 @@ -create or replace package test_coverage_sonar_reporter is - - --%suite(ut_coverge_sonar_reporter) - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(reports on a project file mapped to database object) - procedure report_on_file; - - --%test(Includes XML header with encoding when encoding provided) - procedure check_encoding_included; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb deleted file mode 100644 index 90cfb484e..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb +++ /dev/null @@ -1,101 +0,0 @@ -create or replace package body test_coverage_standalone is - - function run_coverage_twice(a_overage_run_id raw, a_object_name varchar2, a_charset varchar2) return clob is - l_expected clob; - l_block_cov clob; - l_file_path varchar2(250); - begin - l_file_path := 'package body ut3_develop.'||a_object_name; - --Arrange - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := ''; - else - l_block_cov := ''; - end if; - l_expected := - q'[ - - - -]'||l_file_path||q'[ - - - - - - -]'||l_block_cov||q'[ - - - - - - -]'; - --Act - ut3_tester_helper.coverage_helper.run_coverage_job(a_overage_run_id, 1); - ut3_tester_helper.coverage_helper.run_coverage_job(a_overage_run_id, 3); - return l_expected; - end; - - procedure coverage_without_ut_run is - l_coverage_run_id raw(32) := sys_guid(); - l_actual ut3_develop.ut_varchar2_list; - l_expected clob; - l_name varchar2(250); - l_charset varchar2(100) := 'ISO-8859-1'; - begin - l_name := ut3_tester_helper.coverage_helper.covered_package_name; - - --Arrange and Act - l_expected := run_coverage_twice(l_coverage_run_id, l_name, l_charset); - - select * - bulk collect into l_actual - from - table ( - ut3_develop.ut_coverage_cobertura_reporter().get_report( - a_coverage_options => ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - include_objects => ut3_develop.ut_varchar2_rows(l_name), - schema_names => ut3_develop.ut_varchar2_rows('UT3_DEVELOP') - ), - a_client_character_set => l_charset - ) - ); - - --Assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_actual)).to_be_like( l_expected ); - end; - - procedure coverage_cursor_without_ut_run is - l_coverage_run_id raw(32) := sys_guid(); - l_coverage_cursor sys_refcursor; - l_actual ut3_develop.ut_varchar2_list; - l_expected clob; - l_name varchar2(250); - l_charset varchar2(100) := 'ISO-8859-1'; - begin - l_name := ut3_tester_helper.coverage_helper.covered_package_name; - - --Arrange and Act - l_expected := run_coverage_twice(l_coverage_run_id, l_name, l_charset); - - l_coverage_cursor := - ut3_develop.ut_coverage_cobertura_reporter( ).get_report_cursor( - a_coverage_options => ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - include_objects => ut3_develop.ut_varchar2_rows(l_name), - schema_names => ut3_develop.ut_varchar2_rows('UT3_DEVELOP') - ), - a_client_character_set => l_charset - ); - fetch l_coverage_cursor bulk collect into l_actual; - close l_coverage_cursor; - - --Assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_actual)).to_be_like( l_expected ); - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pks b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pks deleted file mode 100644 index 1d5bb9a2c..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pks +++ /dev/null @@ -1,12 +0,0 @@ -create or replace package test_coverage_standalone authid current_user is - - --%suite - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(Coverage can be invoked standalone in multiple sessions and a combined report can be produced at the end) - procedure coverage_without_ut_run; - - --%test(Coverage can be invoked standalone in multiple sessions and a combined report can be produced at the end as cursor) - procedure coverage_cursor_without_ut_run; -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb deleted file mode 100644 index e3806cd97..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb +++ /dev/null @@ -1,77 +0,0 @@ -create or replace package body test_coveralls_reporter is - - procedure report_on_file is - l_expected clob; - l_actual clob; - l_file_path varchar2(250); - begin - --Arrange - l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; - l_expected := q'[{"source_files":[ -{ "name": "]'||l_file_path||q'[", -"coverage": [ -null, -null, -null, -3, -null, -0 -] -} -]} - ]'; - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter => ut3_develop.ut_coveralls_reporter( ), - a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), - a_test_files => ut3_develop.ut_varchar2_list( ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure report_zero_coverage is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := q'[{"source_files":[ -{ "name": "package body ut3_develop.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[", -"coverage": [ -0, -0, -0, -0, -0, -0, -0, -0, -0 -] -} -]} - ]'; - - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - 'ut3_develop.test_dummy_coverage.zero_coverage', - ut3_develop.ut_coveralls_reporter(), - a_include_objects => ut3_develop.ut_varchar2_list('UT3_DEVELOP.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[') - ) - ]' - ); - --Assert - ut.expect(l_actual).to_equal(l_expected); - - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks deleted file mode 100644 index d958b8f12..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks +++ /dev/null @@ -1,13 +0,0 @@ -create or replace package test_coveralls_reporter is - - --%suite(ut_coveralls_reporter) - --%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) - procedure report_zero_coverage; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb deleted file mode 100644 index d7f1b61d7..000000000 --- a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb +++ /dev/null @@ -1,318 +0,0 @@ -create or replace package body test_extended_coverage is - - function get_block_coverage_line return clob is - begin - return - case - when ut3_tester_helper.coverage_helper.block_coverage_available then - '%' - else - '%' - end; - end; - procedure coverage_for_object is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - get_block_coverage_line|| - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[' ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_schema is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - get_block_coverage_line || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_coverage_schemes => ut3_develop.ut_varchar2_list( 'ut3_develop' ) - ) - ]' - ); - --Assert - 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_file_path varchar2(250); - begin - --Arrange - l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; - l_expected := '%' || - get_block_coverage_line || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), - a_test_files => ut3_develop.ut_varchar2_list( ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_with_dbms_stats is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_stats', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_coverage_schemes => ut3_develop.ut_varchar2_list( 'ut3_develop' ), - a_include_objects => ut3_develop.ut_varchar2_list('stats') - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_regex_include_schema is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - '%%'; - l_not_expected := '%' || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_tester_helper.test_regex_dummy_cov'), - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_schema_expr => '^ut3_tester_hel.*', - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) - ) - ]' - ); - - --Assert - --The below is a workaround for problem with large CLOB like comparison on 11g XE db. - ut.expect(to_char(substr(l_actual,instr(l_actual,''),2000))).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - ut.expect(l_actual).not_to_be_like('%ut3_tester_helper.test_regex_dummy_cov%'); - end; - - procedure coverage_regex_include_object is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - '%%'; - l_not_expected := '%' || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_develop.test_regex123_dummy_cov'), - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_object_expr => 'regex123', - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure coverage_regex_exclude_schema is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - '%%'; - l_not_expected := '%' || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_tester_helper.test_regex_dummy_cov'), - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_exclude_schema_expr => '^ut3_tester', - a_exclude_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure coverage_regex_exclude_object is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%' || - '%%'; - l_not_expected := '%' || - '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_paths => ut3_develop.ut_varchar2_list('ut3_develop.test_regex_dummy_cov', 'ut3_develop.test_regex123_dummy_cov'), - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_exclude_object_expr => 'regex123', - a_exclude_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.regex_dummy_cov' ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure cove_rgx_inc_schema_norun is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; - l_not_expected := '%UT3_TESTER_HELPER.REGEX123_DUMMY_COV%'; - --Act - l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( - q'[ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - include_schema_expr => '^ut3_develop' - )]'); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure cove_rgx_inc_object_norun is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%UT3_DEVELOP.REGEX123_DUMMY_COV%'; - l_not_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; - --Act - l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( - q'[ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - include_object_expr => 'regex123' - )]'); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure cove_rgx_exc_schema_norun is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; - l_not_expected := '%UT3_TESTER_HELPER.REGEX_DUMMY_COV%'; - --Act - l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( - q'[ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - schema_names => ut3_develop.ut_varchar2_rows( 'UT3_DEVELOP','UT3_TESTER_HELPER' ), - exclude_schema_expr => '^ut3_tester', - exclude_objects => ut3_develop.ut_varchar2_rows( 'ut3_develop.regex_dummy_cov' ) - )]'); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure cove_rgx_exc_object_norun is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; - l_not_expected := '%UT3_DEVELOP.REGEX123_DUMMY_COV%'; - --Act - l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( - q'[ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - schema_names => ut3_develop.ut_varchar2_rows( 'UT3_DEVELOP' ), - exclude_object_expr => 'regex123', - exclude_objects => ut3_develop.ut_varchar2_rows( 'ut3_develop.regex_dummy_cov' ) - )]'); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like(l_not_expected); - end; - - procedure cov_file_mapping_no_utrun is - l_expected clob; - l_not_expected clob; - l_actual clob; - begin - --Arrange - l_expected := '%UT3_DEVELOP.REGEX_DUMMY_COV%'; - --Act - l_actual := ut3_tester_helper.coverage_helper.gather_coverage_on_coverage( - q'[ut3_develop.ut_coverage_options( - coverage_run_id => l_coverage_run_id, - file_mappings => ut3_develop.ut_file_mappings( ut3_develop.ut_file_mapping('C:\tests\helpers\core.pkb','UT3_DEVELOP','REGEX_DUMMY_COV','PACKAGE BODY')) - )]'); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pks b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pks deleted file mode 100644 index 82b19fbed..000000000 --- a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pks +++ /dev/null @@ -1,66 +0,0 @@ -create or replace package test_extended_coverage is - - --%suite - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(Coverage is gathered for specified object - extended coverage type) - procedure coverage_for_object; - - --%test(Coverage is gathered for specified schema - extended coverage type) - procedure coverage_for_schema; - - --%test(Coverage is gathered for specified file - extended coverage type) - procedure coverage_for_file; - - --%beforetest(ut3_tester_helper.coverage_helper.create_cov_with_dbms_stats) - --%aftertest(ut3_tester_helper.coverage_helper.drop_cov_with_dbms_stats) - --%tags(#1097,#1094) - --%test(Extended coverage does not fail the test run then tested code calls DBMS_STATS) - procedure coverage_with_dbms_stats; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with schema regex include with ut_run) - procedure coverage_regex_include_schema; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with object regex include with ut_run) - procedure coverage_regex_include_object; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with schema regex exclude with ut_run) - procedure coverage_regex_exclude_schema; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with object regex exclude with ut_run) - procedure coverage_regex_exclude_object; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with schema regex include without ut_run) - procedure cove_rgx_inc_schema_norun; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with object regex include without ut_run) - procedure cove_rgx_inc_object_norun; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with schema regex exclude without ut_run) - procedure cove_rgx_exc_schema_norun; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for objects with object regex exclude without ut_run) - procedure cove_rgx_exc_object_norun; - - --%beforetest(ut3_tester_helper.coverage_helper.create_regex_dummy_cov) - --%aftertest(ut3_tester_helper.coverage_helper.drop_regex_dummy_cov) - --%test(Collect coverage for file mapping without ut_run) - procedure cov_file_mapping_no_utrun; -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb deleted file mode 100644 index 2f2200116..000000000 --- a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb +++ /dev/null @@ -1,101 +0,0 @@ -create or replace package body test_html_coverage_reporter is - - procedure report_on_file is - l_expected varchar2(32767); - l_actual clob; - l_block_cov clob; - l_name varchar2(250); - l_charset varchar2(100) := 'ISO-8859-1'; - begin - --Arrange - l_name := ut3_tester_helper.coverage_helper.covered_package_name; - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := '(including 1 lines partially covered ) '; - end if; - l_expected := '%%

UT3_DEVELOP.'||upper(l_name)||'

' || - '%2 relevant lines. 1 lines covered ' || - l_block_cov || 'and 1 lines missed%'; - - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_html_reporter(), - a_source_files => ut3_develop.ut_varchar2_list( 'test/ut3_develop.]'||l_name||q'[.pkb' ), - a_test_files => ut3_develop.ut_varchar2_list( ), - a_client_character_set => ']'||l_charset||q'[' - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure setup_long_lines is - pragma autonomous_transaction; - begin - - execute immediate q'[create or replace type string_array is table of varchar2(5 char);]'; - execute immediate q'[ - create or replace function f return integer is - l_string_array string_array; - l_count integer; - begin - -- line is 1912 chars long, 1911 characters seem to be the max. line length that works (@formatter:off) - l_string_array := string_array('aahed', 'aalii', 'aargh', 'aarti', 'abaca', 'abaci', 'abacs', 'abaft', 'abaka', 'abamp', 'aband', 'abash', 'abask', 'abaya', 'abbas', 'abbed', 'abbes', 'abcee', 'abeam', 'abear', 'abele', 'abers', 'abets', 'abies', 'abler', 'ables', 'ablet', 'ablow', 'abmho', 'abohm', 'aboil', 'aboma', 'aboon', 'abord', 'abore', 'abram', 'abray', 'abrim', 'abrin', 'abris', 'absey', 'absit', 'abuna', 'abune', 'abuts', 'abuzz', 'abyes', 'abysm', 'acais', 'acari', 'accas', 'accoy', 'acerb', 'acers', 'aceta', 'achar', 'ached', 'aches', 'achoo', 'acids', 'acidy', 'acing', 'acini', 'ackee', 'acker', 'acmes', 'acmic', 'acned', 'acnes', 'acock', 'acold', 'acred', 'acres', 'acros', 'acted', 'actin', 'acton', 'acyls', 'adaws', 'adays', 'adbot', 'addax', 'added', 'adder', 'addio', 'addle', 'adeem', 'adhan', 'adieu', 'adios', 'adits', 'adman', 'admen', 'admix', 'adobo', 'adown', 'adoze', 'adrad', 'adred', 'adsum', 'aduki', 'adunc', 'adust', 'advew', 'adyta', 'adzed', 'adzes', 'aecia', 'aedes', 'aegis', 'aeons', 'aerie', 'aeros', 'aesir', 'afald', 'afara', 'afars', 'afear', 'aflaj', 'afore', 'afrit', 'afros', 'agama', 'agami', 'agars', 'agast', 'agave', 'agaze', 'agene', 'agers', 'agger', 'aggie', 'aggri', 'aggro', 'aggry', 'aghas', 'agila', 'agios', 'agism', 'agist', 'agita', 'aglee', 'aglet', 'agley', 'agloo', 'aglus', 'agmas', 'agoge', 'agone', 'agons', 'agood', 'agora', 'agria', 'agrin', 'agros', 'agued', 'agues', 'aguna', 'aguti', 'aheap', 'ahent', 'ahigh', 'ahind', 'ahing', 'ahint', 'ahold', 'ahull', 'ahuru', 'aidas', 'aided', 'aides', 'aidoi', 'aidos', 'aiery', 'aigas', 'aight', 'ailed', 'aimed', 'aimer', 'ainee', 'ainga', 'aioli', 'aired', 'airer', 'airns', 'airth', 'airts', 'aitch', 'aitus', 'aiver', 'aiyee', 'aizle', 'ajies', 'ajiva', 'ajuga', 'ajwan', 'akees', 'akela', 'akene', 'aking', 'akita', 'akkas', 'alaap', 'alack', 'alamo', 'aland', 'alane', 'alang', 'a'); - select count(*) into l_count from table(l_string_array); - return l_count; - end;]'; - - execute immediate q'[ - create or replace package test_f is - --%suite - - --%test - procedure fail_ut_coverage_html_reporter; - end;]'; - - execute immediate q'[ - create or replace package body test_f is - procedure fail_ut_coverage_html_reporter is - begin - ut3_develop.ut.expect(f()).to_be_greater_or_equal(1); - end; - end; - ]'; - end; - - procedure cleanup_long_lines is - pragma autonomous_transaction; - begin - execute immediate 'drop package test_f'; - execute immediate 'drop function f'; - execute immediate 'drop type string_array force'; - end; - - procedure report_long_lines is - l_expected varchar2(32767); - l_actual clob; - l_name varchar2(250); - begin - --Arrange - l_expected := '%l_string_array := string_array%'; - - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_user.test_f', - a_reporter=> ut3_develop.ut_coverage_html_reporter(), - a_include_objects => ut3_develop.ut_varchar2_list( 'UT3_USER.F' ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - -end test_html_coverage_reporter; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks deleted file mode 100644 index a11f3e912..000000000 --- a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks +++ /dev/null @@ -1,18 +0,0 @@ -create or replace package test_html_coverage_reporter is - - --%suite(ut_html_extended_reporter) - --%suitepath(utplsql.test_user.reporters.test_coverage.test_extended_coverage) - - --%test(reports on a project file mapped to database object in extended profiler coverage) - procedure report_on_file; - - procedure setup_long_lines; - procedure cleanup_long_lines; - - --%test(reports on lines exceeding 4000 chars after conversion to XML) - --%beforetest(setup_long_lines) - --%aftertest(cleanup_long_lines) - procedure report_long_lines; - -end test_html_coverage_reporter; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_proftab_coverage.pkb b/test/ut3_user/reporters/test_coverage/test_proftab_coverage.pkb deleted file mode 100644 index f3aad5702..000000000 --- a/test/ut3_user/reporters/test_coverage/test_proftab_coverage.pkb +++ /dev/null @@ -1,211 +0,0 @@ -create or replace package body test_proftab_coverage is - - procedure coverage_for_object is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := coverage_helper.substitute_covered_package('%%'); - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - coverage_helper.substitute_covered_package( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.{p}' ) - ) - ]' - ) - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_object_no_owner is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := coverage_helper.substitute_covered_package('%%'); - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - coverage_helper.substitute_covered_package( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_objects => ut3_develop.ut_varchar2_list( '{p}' ) - ) - ]' - ) - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_for_schema is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := ''; - l_expected := '%'||l_expected||'%'||l_expected||'%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_coverage_schemes => ut3_develop.ut_varchar2_list( 'ut3_develop' ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - ut.expect(l_actual).not_to_be_like('%%'); - end; - - procedure coverage_for_file is - l_expected clob; - l_actual clob; - l_file_path varchar2(250); - begin - --Arrange - l_file_path := coverage_helper.substitute_covered_package('test/ut3_develop.{p}.pkb'); - l_expected := '%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), - a_test_files => ut3_develop.ut_varchar2_list( ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure dup_object_name_coverage is - l_actual clob; - l_expected clob; - begin - l_expected := - '%%' || - '%%%'; - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_duplicate_name', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.duplicate_name' ) - ) - ]' - ); - --Assert - --TODO - need to fix coverage reporting so that coverage is grouped by object type not only object name - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure coverage_tmp_data_refresh is - l_actual clob; - l_test_code varchar2(32767); - begin - l_test_code := q'[ - declare - l_tmp_data ut3_develop.ut_varchar2_list; - begin - --Arrange - select * bulk collect into l_tmp_data - from table( - ut3_develop.ut.run( - a_path => 'ut3_develop:coverage_testing', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.{p}' ) - ) - ); - coverage_helper.drop_dummy_coverage(); - coverage_helper.create_dummy_coverage_1(); - - --Act - insert into test_results - select rownum, x.* - from table( - ut3_develop.ut.run( - a_path => 'ut3_develop:coverage_testing', - a_reporter=> ut3_develop.ut_coverage_sonar_reporter( ), - a_include_objects => ut3_develop.ut_varchar2_list( 'ut3_develop.{p}' ) - ) - ) x; - commit; - end; - ]'; - - l_actual := ut3_tester_helper.coverage_helper.run_code_as_job( coverage_helper.substitute_covered_package(l_test_code) ); - --Assert - ut.expect(l_actual).to_equal(to_clob(' - -')); - end; - - procedure report_zero_coverage is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := - q'[ - - - -package body ut3_develop.{p} - - - - - - - - - - - - - - - - - - - - -]'; - - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - coverage_helper.substitute_covered_package( - q'[ - ut3_develop.ut.run( - 'ut3_develop.test_dummy_coverage.zero_coverage', - ut3_develop.ut_coverage_cobertura_reporter(), - a_include_objects => ut3_develop.ut_varchar2_list('UT3_DEVELOP.{P}') - ) - ]' - ) - ); - --Assert - ut.expect(l_actual).to_be_like(coverage_helper.substitute_covered_package(l_expected)); - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_proftab_coverage.pks b/test/ut3_user/reporters/test_coverage/test_proftab_coverage.pks deleted file mode 100644 index 740862f86..000000000 --- a/test/ut3_user/reporters/test_coverage/test_proftab_coverage.pks +++ /dev/null @@ -1,32 +0,0 @@ -create or replace package test_proftab_coverage is - - --%suite - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(Coverage is gathered for specified object - default coverage type) - procedure coverage_for_object; - - --%test(Coverage is gathered for specified schema - default coverage type) - procedure coverage_for_object_no_owner; - - --%test(Coverage is gathered for specified schema) - procedure coverage_for_schema; - - --%test(Coverage is gathered for specified file - default coverage type) - procedure coverage_for_file; - - --%beforetest(ut3_tester_helper.coverage_helper.create_dup_object_name) - --%aftertest(ut3_tester_helper.coverage_helper.drop_dup_object_name) - --%test(Coverage on duplicate object name) - procedure dup_object_name_coverage; - - --%test(Coverage data is not cached between runs - issue #562 ) - --%aftertest(ut3_tester_helper.coverage_helper.drop_dummy_coverage_1) - --%aftertest(ut3_tester_helper.coverage_helper.create_dummy_coverage) - procedure coverage_tmp_data_refresh; - - --%test(reports zero coverage on each line of non-executed database object - Issue #917) - procedure report_zero_coverage; - -end; -/ diff --git a/test/ut3_user/reporters/test_debug_reporter.pkb b/test/ut3_user/reporters/test_debug_reporter.pkb deleted file mode 100644 index a022b5af8..000000000 --- a/test/ut3_user/reporters/test_debug_reporter.pkb +++ /dev/null @@ -1,45 +0,0 @@ -create or replace package body test_debug_reporter as - - g_actual clob; - - procedure run_reporter is - l_results ut3_develop.ut_varchar2_list; - begin - select * - bulk collect into l_results - from table( - ut3_develop.ut.run( - 'test_reporters', - ut3_develop.ut_debug_reporter() - ) - ); - g_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - end; - - procedure includes_event_info is - l_expected varchar2(32767); - begin - l_expected := '\s+' || - '(\s+' || - ' [0-9\-]+T[0-9:\.]+<\/TIMESTAMP>\s+' || - '[0-9 \+:\.]+<\/TIME_FROM_START>\s+' || - '[0-9 \+:\.]+<\/TIME_FROM_PREVIOUS>\s+' || - '\w+<\/EVENT_NAME>\s+' || - '(\s|\S)+?<\/CALL_STACK>(\s|\S)+?' || - '<\/DEBUG>\s+)+' || - '<\/DEBUG_LOG>'; - ut.expect( g_actual ).to_match( l_expected, 'm' ); - end; - - procedure includes_run_info is - l_expected varchar2(32767); - begin - l_expected := '(\s|\S)+?(\s|\S)+?<\/UT_RUN_INFO>\s+<\/DEBUG>'; - ut.expect( g_actual ).to_match( l_expected, 'm' ); - end; - - -end; -/ - - diff --git a/test/ut3_user/reporters/test_debug_reporter.pks b/test/ut3_user/reporters/test_debug_reporter.pks deleted file mode 100644 index 4d7f7962f..000000000 --- a/test/ut3_user/reporters/test_debug_reporter.pks +++ /dev/null @@ -1,16 +0,0 @@ -create or replace package test_debug_reporter as - - --%suite(ut_debug_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%beforeall - procedure run_reporter; - - --%test(Includes event info for every event) - procedure includes_event_info; - - --%test(Includes run info) - procedure includes_run_info; - -end; -/ diff --git a/test/ut3_user/reporters/test_documentation_reporter.pkb b/test/ut3_user/reporters/test_documentation_reporter.pkb deleted file mode 100644 index 016cec256..000000000 --- a/test/ut3_user/reporters/test_documentation_reporter.pkb +++ /dev/null @@ -1,59 +0,0 @@ -create or replace package body test_documentation_reporter as - - procedure report_produces_expected_out is - l_results ut3_develop.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 - Disabled for testing purpose) - a disabled test with no reason [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_develop.ut.expect('number [1] ','Fails as values are different').to_equal('number [2] '); -% - 2) erroring_test - ORA-06502: PL/SQL: %: character to number conversion error - ORA-06512: at "UT3_USER.TEST_REPORTERS", line 44% - ORA-06512: at line 6 -Finished in % seconds -5 tests, 1 failed, 1 errored, 2 disabled, 0 warning(s)%]'; - - begin - select * - bulk collect into l_results - from table( - ut3_develop.ut.run( - 'test_reporters', - ut3_develop.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; -/ diff --git a/test/ut3_user/reporters/test_documentation_reporter.pks b/test/ut3_user/reporters/test_documentation_reporter.pks deleted file mode 100644 index ec6894c61..000000000 --- a/test/ut3_user/reporters/test_documentation_reporter.pks +++ /dev/null @@ -1,10 +0,0 @@ -create or replace package test_documentation_reporter as - - --%suite(ut_documentation_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%test(Report produces expected output) - procedure report_produces_expected_out; - -end; -/ diff --git a/test/ut3_user/reporters/test_junit_reporter.pkb b/test/ut3_user/reporters/test_junit_reporter.pkb deleted file mode 100644 index 4a574591c..000000000 --- a/test/ut3_user/reporters/test_junit_reporter.pkb +++ /dev/null @@ -1,326 +0,0 @@ -create or replace package body test_junit_reporter as - - procedure create_a_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package check_junit_reporting is - --%suite(A suite with ) - - --%test(A test with ) - procedure test_do_stuff; - - end;]'; - execute immediate q'[create or replace package body check_junit_reporting is - procedure test_do_stuff is - begin - ut3_develop.ut.expect(1).to_equal(1); - ut3_develop.ut.expect(1).to_equal(2); - dbms_output.put_line(' ]]>'); - end; - - end;]'; - - execute immediate q'[create or replace package check_junit_rep_suitepath is - --%suitepath(core) - --%suite(check_junit_rep_suitepath) - --%displayname(Check junit Get path for suitepath) - - --%test(check_junit_rep_suitepath) - --%displayname(Check junit Get path for suitepath) - procedure check_junit_rep_suitepath; - end;]'; - execute immediate q'[create or replace package body check_junit_rep_suitepath is - procedure check_junit_rep_suitepath is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - end;]'; - - - execute immediate q'[create or replace package tst_package_junit_nodesc as - --%suite(Suite name) - - --%test - procedure test1; - - --%test(Test name) - procedure test2; - end;]'; - - execute immediate q'[create or replace package body tst_package_junit_nodesc as - procedure test1 is begin ut.expect(1).to_equal(1); end; - procedure test2 is begin ut.expect(1).to_equal(1); end; - end;]'; - - execute immediate q'[create or replace package tst_package_junit_nosuite as - --%suite - - --%test(Test name) - procedure test1; - end;]'; - - execute immediate q'[create or replace package body tst_package_junit_nosuite as - procedure test1 is begin ut.expect(1).to_equal(1); end; - end;]'; - - execute immediate q'[create or replace package Tst_Fix_Case_Sensitive as - --%suite - - --%test(bugfix) - procedure bUgFiX; - end;]'; - - 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;]'; - - end; - - procedure escapes_special_chars is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_junit_reporter())); - 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>%'); - ut.expect(l_actual).to_be_like(q'/% ]]]]> -]]>%/'); - end; - - procedure reports_only_failed_or_errored is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_junit_reporter())); - 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_xunit_only_fail_or_err is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_xunit_reporter())); - 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 check_classname_suite is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_junit_reporter())); - 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; - - procedure check_nls_number_formatting is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_nls_numeric_characters varchar2(30); - begin - --Arrange - select replace(nsp.value,'''','''''') into l_nls_numeric_characters - from nls_session_parameters nsp - where parameter = 'NLS_NUMERIC_CHARACTERS'; - execute immediate q'[alter session set NLS_NUMERIC_CHARACTERS=', ']'; - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting', ut3_develop.ut_junit_reporter())); - 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 - execute immediate 'alter session set NLS_NUMERIC_CHARACTERS='''||l_nls_numeric_characters||''''; - end; - - procedure check_classname_suitepath is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_rep_suitepath',ut3_develop.ut_junit_reporter())); - 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; - - procedure report_test_without_desc is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767):= q'[ - - - - - - - - - - - - - -]'; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('tst_package_junit_nodesc',ut3_develop.ut_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure report_suite_without_desc is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767):= q'[ - - - - - - - - - -]'; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('tst_package_junit_nosuite',ut3_develop.ut_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure reporort_produces_expected_out is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767):=q'[ - - - - - - - - -% - - - - - - - -%Fails as values are different% - -% - - - - -%ORA-06502:% - -% - - - - - - - - - - - - - - - -% - - - - - - - -]'; - - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('test_reporters',ut3_develop.ut_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - ut.expect(l_actual).to_be_like(l_expected); - end; - - procedure check_failure_escaped is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - reporters.check_xml_failure_escaped(ut3_develop.ut_junit_reporter()); - end; - - procedure check_classname_is_populated is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767):= q'[ - - - - - - - - - -]'; - begin - select * - bulk collect into l_results - from table(ut3_develop.ut.run('Tst_Fix_Case_Sensitive',ut3_develop.ut_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.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_develop.ut_junit_reporter(), 'UTF-8'); - end; - - procedure remove_test_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package check_junit_reporting'; - 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 Tst_Fix_Case_Sensitive'; - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_junit_reporter.pks b/test/ut3_user/reporters/test_junit_reporter.pks deleted file mode 100644 index 71443c180..000000000 --- a/test/ut3_user/reporters/test_junit_reporter.pks +++ /dev/null @@ -1,48 +0,0 @@ -create or replace package test_junit_reporter as - - --%suite(ut_junit_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%beforeall - procedure create_a_test_package; - - --%test(Escapes special characters from test and suite description) - procedure escapes_special_chars; - - --%test(Reports only failed expectations and exceptions) - procedure reports_only_failed_or_errored; - - --%test(Xunit Backward Compatibility - Reports only failed expectations and exceptions) - procedure reports_xunit_only_fail_or_err; - - --%test(Check that classname is returned correct suite) - procedure check_classname_suite; - - --%test(Check that classname is returned correct suitepath) - procedure check_classname_suitepath; - - --%test(Reports duration according to XML specification for numbers) - procedure check_nls_number_formatting; - - --%test(Report on test without description) - procedure report_test_without_desc; - - --%test(Report on suite without description) - procedure report_suite_without_desc; - - --%test(Report produces expected output) - procedure reporort_produces_expected_out; - - --%test( Check classname is populated when procedure is mixed cased - bug #659) - procedure check_classname_is_populated; - - --%test( Validate that fail with special char are escaped ) - procedure check_failure_escaped; - - --%test(Includes XML header with encoding when encoding provided) - procedure check_encoding_included; - - --%afterall - procedure remove_test_package; -end; -/ diff --git a/test/ut3_user/reporters/test_realtime_reporter.pkb b/test/ut3_user/reporters/test_realtime_reporter.pkb deleted file mode 100644 index 84053c3c9..000000000 --- a/test/ut3_user/reporters/test_realtime_reporter.pkb +++ /dev/null @@ -1,536 +0,0 @@ -create or replace package body test_realtime_reporter as - - g_events ut3_tester_helper.test_event_list := ut3_tester_helper.test_event_list(); - - procedure create_test_suites_and_run is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package check_realtime_reporting1 is - --%suite(suite ) - --%suitepath(realtime_reporting) - - --%context - --%name(test_context) - - --%test(test 1 - OK) - procedure test_1_ok; - - --%test(test 2 - NOK) - procedure test_2_nok; - - --%endcontext - end;]'; - execute immediate q'[create or replace package body check_realtime_reporting1 is - procedure test_1_ok is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - - procedure test_2_nok is - begin - ut3_develop.ut.expect(1).to_equal(2); - end; - end;]'; - - execute immediate q'[create or replace package check_realtime_reporting2 is - --%suite - --%suitepath(realtime_reporting) - - --%test - procedure test_3_ok; - - --%test - procedure test_4_nok; - - --%test - --%disabled - procedure test_5; - - --%test - --%disabled(Cannot run this item at this time runtime > 10 mins.) - procedure test_6_disabled_reason; - end;]'; - execute immediate q'[create or replace package body check_realtime_reporting2 is - procedure test_3_ok is - begin - ut3_develop.ut.expect(2).to_equal(2); - end; - - procedure test_4_nok is - begin - ut3_develop.ut.expect(2).to_equal(3); - ut3_develop.ut.expect(2).to_equal(4); - end; - - procedure test_5 is - begin - null; - end; - - procedure test_6_disabled_reason is - begin - null; - end; - end;]'; - - execute immediate q'[create or replace package check_realtime_reporting3 is - --%suite - --%suitepath(realtime_reporting) - - --%test - procedure test_6_with_runtime_error; - - --%test - procedure test_7_with_serveroutput; - - --%afterall - procedure print_and_raise; - end;]'; - execute immediate q'[create or replace package body check_realtime_reporting3 is - procedure test_6_with_runtime_error is - l_actual integer; - begin - execute immediate 'select 6 from non_existing_table' into l_actual; - ut3_develop.ut.expect(6).to_equal(l_actual); - end; - - procedure test_7_with_serveroutput is - begin - dbms_output.put_line('before test 7'); - ut3_develop.ut.expect(7).to_equal(7); - dbms_output.put_line('after test 7'); - end; - - procedure print_and_raise is - begin - dbms_output.put_line('Now, a no_data_found exception is raised'); - dbms_output.put_line('dbms_output and error stack is reported for this suite.'); - dbms_output.put_line('A runtime error in afterall is counted as a warning.'); - 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_develop.ut.expect(8).to_equal(8); - end; - end;]'; - - execute immediate q'[create or replace package check_realtime_reporting5 is - --%suite - --%suitepath(realtime_reporting_bufix) - - --%test(test XML with nested CDATA) - procedure test_nested_cdata; - end;]'; - - execute immediate q'[create or replace package body check_realtime_reporting5 is - procedure test_nested_cdata is - begin - dbms_output.put_line('nested cdata block: , to be handled.'); - ut.expect(1).to_equal(1); - end; - end;]'; - - <> - declare - l_reporter ut3_develop.ut_realtime_reporter := ut3_develop.ut_realtime_reporter(); - begin - -- produce - ut3_develop.ut_runner.run( - a_paths => ut3_develop.ut_varchar2_list(':realtime_reporting'), - a_reporters => ut3_develop.ut_reporters(l_reporter) - ); - -- consume - select ut3_tester_helper.test_event_object(item_type, xmltype(text)) - bulk collect into g_events - 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; - - procedure xml_report_structure is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_actual for - select t.event_doc.extract('/event/@type').getstringval() as event_type, - t.event_doc.extract('/event/suite/@id|/event/test/@id').getstringval() as item_id - from table(g_events) t; - 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 - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting3.test_7_with_serveroutput' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting3.test_7_with_serveroutput' as item_id from dual union all - select 'post-suite' as event_type, 'realtime_reporting.check_realtime_reporting3' as item_id from dual union all - select 'pre-suite' as event_type, 'realtime_reporting.check_realtime_reporting2' as item_id from dual union all - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_3_ok' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_3_ok' as item_id from dual union all - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_4_nok' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_4_nok' as item_id from dual union all - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_5' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_5' as item_id from dual union all - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_6_disabled_reason' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting2.test_6_disabled_reason' as item_id from dual union all - select 'post-suite' as event_type, 'realtime_reporting.check_realtime_reporting2' as item_id from dual union all - select 'pre-suite' as event_type, 'realtime_reporting.check_realtime_reporting1' as item_id from dual union all - select 'pre-suite' as event_type, 'realtime_reporting.check_realtime_reporting1.test_context' as item_id from dual union all - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting1.test_context.test_1_ok' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting1.test_context.test_1_ok' as item_id from dual union all - select 'pre-test' as event_type, 'realtime_reporting.check_realtime_reporting1.test_context.test_2_nok' as item_id from dual union all - select 'post-test' as event_type, 'realtime_reporting.check_realtime_reporting1.test_context.test_2_nok' as item_id from dual union all - select 'post-suite' as event_type, 'realtime_reporting.check_realtime_reporting1.test_context' as item_id from dual union all - select 'post-suite' as event_type, 'realtime_reporting.check_realtime_reporting1' as item_id from dual union all - select 'post-suite' as event_type, 'realtime_reporting' as item_id from dual union all - select 'post-run' as event_type, null as item_id from dual; - ut.expect(l_actual).to_equal(l_expected); - end xml_report_structure; - - procedure pre_run_composite_nodes is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_actual for - select x.node_path - from table(g_events) t, - xmltable( - q'[ - for $i in //(event|items|suite|test) - return {$i/string-join(ancestor-or-self::*/name(.), '/')} - ]' - passing t.event_doc - columns node_path varchar2(128) path '.' - ) x - where event_type = 'pre-run'; - open l_expected for - select 'event' as node_path from dual union all - select 'event/items' as node_path from dual union all - select 'event/items/suite' as node_path from dual union all - select 'event/items/suite/items' 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' 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 - 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/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 - select 'event/items/suite/items/suite/items/suite' as node_path from dual union all - select 'event/items/suite/items/suite/items/suite/items' as node_path from dual union all - select 'event/items/suite/items/suite/items/suite/items/test' as node_path from dual union all - select 'event/items/suite/items/suite/items/suite/items/test' as node_path from dual; - ut.expect(l_actual).to_equal(l_expected); - end pre_run_composite_nodes; - - procedure total_number_of_tests is - l_actual integer; - l_expected integer := 9; - begin - select t.event_doc.extract('/event/totalNumberOfTests/text()').getnumberval() - into l_actual - from table(g_events) t - where t.event_type = 'pre-run'; - ut.expect(l_actual).to_equal(l_expected); - end total_number_of_tests; - - procedure execution_time_of_run is - l_actual number; - begin - select t.event_doc.extract('/event/run/executionTime/text()').getnumberval() - into l_actual - from table(g_events) t - where t.event_type = 'post-run'; - ut.expect(l_actual).to_be_not_null; - end execution_time_of_run; - - procedure escaped_characters is - l_actual varchar2(32767); - l_expected varchar2(20) := 'suite <A>'; - begin - select t.event_doc.extract( - '//suite[@id="realtime_reporting.check_realtime_reporting1"]/description/text()' - ).getstringval() - into l_actual - from table(g_events) t - where t.event_type = 'pre-run'; - ut.expect(l_actual).to_equal(l_expected); - end escaped_characters; - - procedure pre_test_nodes is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_actual for - select t.event_doc.extract('//test/testNumber/text()') - .getnumberval() as test_number, - t.event_doc.extract('//test/totalNumberOfTests/text()') - .getnumberval() as total_number_of_tests - from table(g_events) t - where t.event_type = 'pre-test' - and t.event_doc.extract('//test/@id').getstringval() is not null; - open l_expected for - select level as test_number, - 9 as total_number_of_tests - from dual - connect by level <= 9; - ut.expect(l_actual).to_equal(l_expected).unordered; - end pre_test_nodes; - - procedure post_test_nodes is - l_actual sys_refcursor; - l_expected sys_refcursor; - begin - open l_actual for - select t.event_doc.extract('//test/testNumber/text()') - .getnumberval() as test_number, - t.event_doc.extract('//test/totalNumberOfTests/text()') - .getnumberval() as total_number_of_tests - from table(g_events) t - where t.event_type = 'post-test' - and t.event_doc.extract('//test/@id').getstringval() is not null - and t.event_doc.extract('//test/startTime/text()').getstringval() is not null - and t.event_doc.extract('//test/endTime/text()').getstringval() is not null - and t.event_doc.extract('//test/executionTime/text()').getnumberval() is not null - and t.event_doc.extract('//test/counter/disabled/text()').getnumberval() is not null - and t.event_doc.extract('//test/counter/success/text()').getnumberval() is not null - and t.event_doc.extract('//test/counter/failure/text()').getnumberval() is not null - and t.event_doc.extract('//test/counter/error/text()').getnumberval() is not null - and t.event_doc.extract('//test/counter/warning/text()').getnumberval() is not null; - open l_expected for - select level as test_number, - 9 as total_number_of_tests - from dual - connect by level <= 9; - ut.expect(l_actual).to_equal(l_expected).unordered; - end post_test_nodes; - - procedure single_failed_message is - l_actual varchar2(32767); - l_expected varchar2(80) := ''; - begin - select t.event_doc.extract( - '/event/test/failedExpectations/expectation[1]/message/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_reporting1.test_context.test_2_nok'; - ut.expect(l_actual).to_equal(l_expected); - end single_failed_message; - - procedure multiple_failed_messages is - l_actual integer; - l_expected integer := 2; - begin - select count(*) - into l_actual - from table(g_events) t, - xmltable( - '/event/test/failedExpectations/expectation' - passing t.event_doc - columns message clob path 'message', - caller clob path 'caller' - ) x - where t.event_doc.extract('/event[@type="post-test"]/test/@id').getstringval() - = 'realtime_reporting.check_realtime_reporting2.test_4_nok' - and x.message is not null - and x.caller is not null; - ut.expect(l_actual).to_equal(l_expected); - end multiple_failed_messages; - - procedure serveroutput_of_test is - l_actual clob; - l_expected_list ut3_develop.ut_varchar2_list; - l_expected clob; - begin - select t.event_doc.extract('//event/test/serverOutput/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_reporting3.test_7_with_serveroutput'; - 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; - - procedure serveroutput_of_testsuite is - l_actual clob; - l_expected_list ut3_develop.ut_varchar2_list; - l_expected clob; - begin - select t.event_doc.extract('//event/suite/serverOutput/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_reporting3'; - 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; - - procedure error_stack_of_test is - l_actual clob; - l_expected_list ut3_develop.ut_varchar2_list; - l_expected clob; - begin - select t.event_doc.extract('//event/test/errorStack/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_reporting3.test_6_with_runtime_error'; - 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; - - procedure error_stack_of_testsuite is - l_actual clob; - l_expected_list ut3_develop.ut_varchar2_list; - l_expected clob; - begin - select t.event_doc.extract('//event/suite/errorStack/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_reporting3'; - 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_develop.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_develop.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_develop.ut_realtime_reporter; - l_actual varchar2(4000); - l_expected varchar2(80) := '%SQL Developer%'; - begin - l_reporter := ut3_develop.ut_realtime_reporter(); - l_actual := l_reporter.get_description(); - ut.expect(l_actual).to_be_like(l_expected); - end get_description; - - procedure nested_cdata_output is - l_text varchar2(4000); - l_xml xmltype; - -- - function produce_and_consume return varchar2 is - pragma autonomous_transaction; - l_reporter ut3_develop.ut_realtime_reporter := ut3_develop.ut_realtime_reporter(); - l_text varchar2(4000); - begin - -- produce - ut3_develop.ut_runner.run( - a_paths => ut3_develop.ut_varchar2_list(':realtime_reporting_bufix'), - a_reporters => ut3_develop.ut_reporters(l_reporter) - ); - -- consume - select text - into l_text - from table(l_reporter.get_lines()) - where item_type = 'post-test'; - return l_text; - end produce_and_consume; - begin - l_text := produce_and_consume(); - ut.expect(l_text).to_be_not_null(); - -- this fails, if l_text is not a valid XML - l_xml := xmltype(l_text); - ut.expect(l_xml is not null).to_be_true(); - end; - - procedure disabled_reason is - l_actual varchar2(32767); - l_expected varchar2(80) := dbms_xmlgen.convert('Cannot run this item at this time runtime > 10 mins.'); - begin - select t.event_doc.extract( - '//test/disabledReason/text()' - ).getstringval() - into l_actual - from table(g_events) t - where xmlexists( - '/event[@type="pre-run"]/*//test[@id="realtime_reporting.check_realtime_reporting2.test_6_disabled_reason"]' - passing t.event_doc - ); - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure remove_test_suites is - pragma autonomous_transaction; - begin - 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'; - execute immediate 'drop package check_realtime_reporting5'; - end remove_test_suites; - -end test_realtime_reporter; -/ diff --git a/test/ut3_user/reporters/test_realtime_reporter.pks b/test/ut3_user/reporters/test_realtime_reporter.pks deleted file mode 100644 index 087713f79..000000000 --- a/test/ut3_user/reporters/test_realtime_reporter.pks +++ /dev/null @@ -1,67 +0,0 @@ -create or replace package test_realtime_reporter as - - --%suite(ut_realtime_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%beforeall - procedure create_test_suites_and_run; - - --%test(Provide a report structure with pre-run information and event based messages per suite and per test) - procedure xml_report_structure; - - --%test(Provide the total number of tests as part of the pre-run information structure) - procedure total_number_of_tests; - - --%test(Provide composite structure for items, an item is either a suite or a test, suites may have nested items) - procedure pre_run_composite_nodes; - - --%test(Provide the execution time as part of the post-run information structure) - procedure execution_time_of_run; - - --%test(Escape special characters in data such as the test suite description) - procedure escaped_characters; - - --%test(Provide a node before starting a test with testNumber and totalNumberOfTests) - procedure pre_test_nodes; - - --%test(Provide a node after completion of a test with test results) - procedure post_test_nodes; - - --%test(Provide expectation message for a failed test) - procedure single_failed_message; - - --%test(Provide expectation messages for each failed assertion of a failed test) - procedure multiple_failed_messages; - - --%test(Provide dbms_output produced in a test) - procedure serveroutput_of_test; - - --%test(Provide dbms_output produced in a testsuite) - procedure serveroutput_of_testsuite; - - --%test(Provide the error stack of a test) - procedure error_stack_of_test; - - --%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; - - --%test(Escape nested CDATA sections in test output) - procedure nested_cdata_output; - - --%test(Provide reason disabled test) - procedure disabled_reason; - - --%afterall - procedure remove_test_suites; - -end test_realtime_reporter; -/ diff --git a/test/ut3_user/reporters/test_sonar_test_reporter.pkb b/test/ut3_user/reporters/test_sonar_test_reporter.pkb deleted file mode 100644 index 7c30fd91d..000000000 --- a/test/ut3_user/reporters/test_sonar_test_reporter.pkb +++ /dev/null @@ -1,42 +0,0 @@ -create or replace package body test_sonar_test_reporter as - - procedure report_produces_expected_out is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_expected varchar2(32767):=q'[ - - -% -%%% -%%% -%% -%% - -]'; - - begin - select * - bulk collect into l_results - from table( - ut3_develop.ut.run( - 'test_reporters', - ut3_develop.ut_sonar_test_reporter(), - a_test_file_mappings => ut3_develop.ut_file_mapper.build_file_mappings( sys_context('USERENV', 'CURRENT_USER'), ut3_develop.ut_varchar2_list('tests/helpers/test_reporters.pkb')) - ) - ); - l_actual :=ut3_tester_helper.main_helper.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_develop.ut_sonar_test_reporter(), 'UTF-8'); - end; - - procedure check_failure_escaped is - begin - reporters.check_xml_failure_escaped(ut3_develop.ut_sonar_test_reporter()); - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_sonar_test_reporter.pks b/test/ut3_user/reporters/test_sonar_test_reporter.pks deleted file mode 100644 index ade449dba..000000000 --- a/test/ut3_user/reporters/test_sonar_test_reporter.pks +++ /dev/null @@ -1,16 +0,0 @@ -create or replace package test_sonar_test_reporter as - - --%suite(ut_sonar_test_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%test(Report produces expected output) - procedure report_produces_expected_out; - - --%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/ut3_user/reporters/test_tap_reporter.pkb b/test/ut3_user/reporters/test_tap_reporter.pkb deleted file mode 100644 index 786c53ee0..000000000 --- a/test/ut3_user/reporters/test_tap_reporter.pkb +++ /dev/null @@ -1,254 +0,0 @@ -create or replace package body test_tap_reporter as - - gc_boilerplate_suitepath_expression constant varchar2(300) := 'TAP version 14\s*1..1\s*# Subtest: org\s{5}1..1\s{5}# Subtest: utplsql\s{9}1..1\s{9}# Subtest: tests\s{13}1..1\s{13}# Subtest: helpers\s{17}1..1\s{17}# Subtest: A suite for testing different outcomes from reporters'; - - - procedure compile_tests as - pragma autonomous_transaction; - begin - - execute immediate q'[ - create or replace package test_tap_escaping as - --%suite(Some \ and # to be escaped) - - --%test(Even more \\ and multiple ###) - procedure more_escaping; - - --%test(Disabled test) - --%disabled(With \ and # in skip reason) - procedure not_skipping_escapes; - - --%test(Escaped Comments) - procedure escaped_comments; - - --%context(Some context) - - --%test(Another disabled test) - --%disabled - procedure another_disabled_test; - - --%endcontext - end test_tap_escaping; - ]'; - - execute immediate q'[ - create or replace package body test_tap_escaping as - - procedure more_escaping as - begin - ut.expect(1).to_equal(1); - end more_escaping; - - - procedure not_skipping_escapes as - begin - ut.expect(10).to_equal(1); - end not_skipping_escapes; - - procedure escaped_comments as - begin - dbms_output.put_line('This \ and # should not be escaped, and this not as well!!!'); - ut.expect(1).to_equal(1); - end escaped_comments; - - procedure another_disabled_test as - begin - ut.expect(10).to_equal(1); - end; - end test_tap_escaping; - ]'; - - end compile_tests; - - - procedure simple_succeeding_test as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := gc_boilerplate_suitepath_expression || '\s{21}1..1\s{21}# \s{21}# Subtest: A description of some context\s{25}1..1\s{25}ok - passing_test\s{25}# \s{25}# \s{25}# \s{25}# \s{25}# \s{21}# \sok - org\s*'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.passing_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected); - end simple_succeeding_test; - - procedure simple_failing_test as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# \s{21}not ok - a test with failing assertion\s{23}---\s{23}message: '"Fails as values are different"'\s{23}severity: fail\s{23}...\s{21}# \s{21}# \s{21}# \s{21}# \snot ok - org\s*]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.failing_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected); - end simple_failing_test; - - - procedure simple_erroring_test as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# \s{21}not ok - a test raising unhandled exception\s{23}---\s{23}message: |\s{25ORA-06502: .*\s{25}ORA-06512: at line [[:digit:]]+\s{23}severity: error\s{23}...\s{21}# \s{21}# \s{21}# \s{21}# \snot ok - org\s*]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.erroring_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected); - end simple_erroring_test; - - - procedure disabled_test as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# \s{21}ok - a disabled test # SKIP: Disabled for testing purpose\s{21}# \sok - org\s*]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.disabled_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected); - end disabled_test; - - - procedure disabled_test_no_description as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# \s{21}ok - a disabled test with no reason # SKIP\s{21}# \sok - org\s*]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.disabled_test_no_reason',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected); - end disabled_test_no_description; - - - procedure multiple_tests_different_outcome as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[TAP version 14\s*1..1\s*# Subtest: org.*# Subtest: A suite.*\s{21}1..5\s{21}# \s{21}# Subtest: A desc.*\s{25}1..1\s{25}ok - passing_test\s{25}# \s{25}# \s{21}not ok - a test w.*\s{23}---\s{23}message:.*\s{21}# .*\s{21}# not ok - a test rai.*\s{23}---\s{23}message: |.*ok - a disabled test # SKIP: Disabled for testing purpose.*ok - a dis.* # SKIP\s{21}# \snot ok - org\s*]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected, 'n'); - end multiple_tests_different_outcome; - - - procedure escape_suite_name as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[%# Subtest: Some \\ and \# to be escaped%ok - Some \\ and \# to be escaped%]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_tap_escaping.more_escaping',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end escape_suite_name; - - - procedure escape_multiple_characters_test_name as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[%ok - Even more \\\\ and multiple \#\#\#%]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_tap_escaping.more_escaping',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end escape_multiple_characters_test_name; - - - procedure special_characters_in_disabled_reason as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[%ok - Disabled test # SKIP: With \\ and \# in skip reason%]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_tap_escaping.not_skipping_escapes',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end special_characters_in_disabled_reason; - - - procedure special_characters_in_comment as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[%ok - Escaped Comments%# This \ and # should not be escaped, and this not as well!!!%]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_tap_escaping.escaped_comments',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end special_characters_in_comment; - - - procedure context_as_commented_subtests as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[%# Subtest: A suite for testing different outcomes from reporters%# Subtest: A description of some context%]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.passing_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - - end context_as_commented_subtests; - - - procedure suitepath_as_chopped_subtests as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[.*# Subtest: org.*1\s{5}# Subtest: utplsql.*1\s{9}# Subtest: tests.*1\s{13}# Subtest: helpers.*1\s{17}# Subtest: A suite for testing different outcomes from reporters.*]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters.passing_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected, 'n'); - - end suitepath_as_chopped_subtests; - - - procedure include_context_with_skipped_tests as - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'[%# Subtest: Some context%]'; - - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_tap_escaping.another_disabled_test',ut3_develop.ut_tap_reporter())); - - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - - end include_context_with_skipped_tests; - - - procedure drop_help_tests as - pragma autonomous_transaction; - begin - execute immediate 'drop package test_tap_escaping'; - end drop_help_tests; -end test_tap_reporter; -/ \ No newline at end of file diff --git a/test/ut3_user/reporters/test_tap_reporter.pks b/test/ut3_user/reporters/test_tap_reporter.pks deleted file mode 100644 index 27f9651bc..000000000 --- a/test/ut3_user/reporters/test_tap_reporter.pks +++ /dev/null @@ -1,53 +0,0 @@ -create or replace package test_tap_reporter as - - --%suite(ut_tap_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%beforeall - procedure compile_tests; - - --%test(Simple succeeding test) - procedure simple_succeeding_test; - - --%test(Simple failing test) - procedure simple_failing_test; - - --%test(Simple erroring test) - procedure simple_erroring_test; - - --%test(Skipped test) - procedure disabled_test; - - --%test(Skipped test without description) - procedure disabled_test_no_description; - - --%test(Multiple tests with different outcome) - procedure multiple_tests_different_outcome; - - --%test(Escape special characters in suite name) - procedure escape_suite_name; - - --%test(Escape multiple special characters in test name) - procedure escape_multiple_characters_test_name; - - --%test(Disabled Test with special characters in disable reason) - procedure special_characters_in_disabled_reason; - - --%test(Don't escape special characters in comment) - procedure special_characters_in_comment; - - --%test(Include context as commented subtests) - procedure context_as_commented_subtests; - - --%test(Suitepath as chopped subtests) - procedure suitepath_as_chopped_subtests; - - --%test(Include context with only skipped tests in output) - procedure include_context_with_skipped_tests; - - - --%afterall - procedure drop_help_tests; - -end test_tap_reporter; -/ \ No newline at end of file diff --git a/test/ut3_user/reporters/test_teamcity_reporter.pkb b/test/ut3_user/reporters/test_teamcity_reporter.pkb deleted file mode 100644 index 517ddc037..000000000 --- a/test/ut3_user/reporters/test_teamcity_reporter.pkb +++ /dev/null @@ -1,197 +0,0 @@ -create or replace package body test_teamcity_reporter as - - procedure create_a_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package check_escape_special_chars is - --%suite(A suite with 'quote') - - --%test(A test with 'quote') - procedure test_do_stuff; - - end;]'; - execute immediate q'[create or replace package body check_escape_special_chars is - procedure test_do_stuff is - begin - ut3_develop.ut.expect(' [ ' || chr(13) || chr(10) || ' ] ' ).to_be_null; - end; - - end;]'; - - execute immediate q'[create or replace package check_trims_long_output is - --%suite - - --%test - procedure long_output; - end;]'; - execute immediate q'[create or replace package body check_trims_long_output is - procedure long_output is - begin - ut3_develop.ut.expect(rpad('aVarchar',4000,'a')).to_be_null; - end; - end;]'; - - execute immediate q'[create or replace package check_multiple_failures is - --%suite - - --%test - procedure multi_failure; - - --%test - procedure multi_failure_on_error; - end;]'; - execute immediate q'[create or replace package body check_multiple_failures is - procedure multi_failure is - begin - ut3_develop.ut.expect(1).to_be_null; - ut3_develop.ut.expect(2).to_equal(1); - ut3_develop.ut.expect('Bad').to_equal('Good'); - end; - procedure multi_failure_on_error is - l_integer_variable integer; - begin - ut3_develop.ut.expect(1).to_be_null; - ut3_develop.ut.expect(2).to_equal(1); - ut3_develop.ut.expect('Bad').to_equal('Good'); - l_integer_variable := 'a string'; - end; - end;]'; - - end; - - - procedure report_produces_expected_out is - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='org'] -%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql'] -%##teamcity[testSuiteStarted timestamp='%' name='org.utplsql.tests'] -%##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_user.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_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_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_user.test_reporters.erroring_test' out='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.TEST_REPORTERS", line %|nORA-06512: at %|n'] -%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.TEST_REPORTERS", line %|nORA-06512: at %|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'] -%##teamcity[testSuiteFinished timestamp='%' name='org.utplsql'] -%##teamcity[testSuiteFinished timestamp='%' name='org']}'; - --act - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('test_reporters',ut3_develop.ut_teamcity_reporter())); - - --assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end; - - procedure escape_special_chars is - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='A suite with |'quote|''] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_escape_special_chars.test_do_stuff'] -%##teamcity[testFailed timestamp='%' details='Actual: (varchar2)|n |' |[ |r|n |] |'|n was 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 * - bulk collect into l_output_data - from table(ut3_develop.ut.run('check_escape_special_chars',ut3_develop.ut_teamcity_reporter())); - - --assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end; - - procedure trims_long_output is - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_trims_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 * - bulk collect into l_output_data - from table(ut3_develop.ut.run('check_trims_long_output',ut3_develop.ut_teamcity_reporter())); - - --assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end; - - procedure report_multiple_expectations is - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_multiple_failures'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_multiple_failures.multi_failure'] -%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure'] -%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure'] -%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure'] -%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}'; - --act - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('check_multiple_failures.multi_failure',ut3_develop.ut_teamcity_reporter())); - - --assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end; - - procedure report_multiple_expect_on_err is - l_output_data ut3_develop.ut_varchar2_list; - l_expected varchar2(32767); - begin - l_expected := q'{%##teamcity[testSuiteStarted timestamp='%' name='check_multiple_failures'] -%##teamcity[testStarted timestamp='%' captureStandardOutput='true' name='ut3_user.check_multiple_failures.multi_failure_on_error'] -%##teamcity[testStdErr timestamp='%' name='ut3_user.check_multiple_failures.multi_failure_on_error' out='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.CHECK_MULTIPLE_FAILURES", line %|nORA-06512: at %|n'] -%##teamcity[testFailed timestamp='%' details='Test exception:|nORA-06502: PL/SQL: %: character to number conversion error|nORA-06512: at "UT3_USER.CHECK_MULTIPLE_FAILURES", line %|nORA-06512: at %|n' message='Error occured' name='ut3_user.check_multiple_failures.multi_failure_on_error'] -%##teamcity[testFailed timestamp='%' details='Actual: 1 (number) was expected to be null' name='ut3_user.check_multiple_failures.multi_failure_on_error'] -%##teamcity[testFailed timestamp='%' details='Actual: 2 (number) was expected to equal: 1 (number)' name='ut3_user.check_multiple_failures.multi_failure_on_error'] -%##teamcity[testFailed timestamp='%' details='Actual: |'Bad|' (varchar2) was expected to equal: |'Good|' (varchar2)' name='ut3_user.check_multiple_failures.multi_failure_on_error'] -%##teamcity[testFinished timestamp='%' duration='%' name='ut3_user.check_multiple_failures.multi_failure_on_error'] -%##teamcity[testSuiteFinished timestamp='%' name='check_multiple_failures']}'; - --act - select * - bulk collect into l_output_data - from table(ut3_develop.ut.run('check_multiple_failures.multi_failure_on_error',ut3_develop.ut_teamcity_reporter())); - - --assert - ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected); - end; - - procedure remove_test_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package check_escape_special_chars'; - execute immediate 'drop package check_trims_long_output'; - execute immediate 'drop package check_multiple_failures'; - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_teamcity_reporter.pks b/test/ut3_user/reporters/test_teamcity_reporter.pks deleted file mode 100644 index 1b9277e7a..000000000 --- a/test/ut3_user/reporters/test_teamcity_reporter.pks +++ /dev/null @@ -1,28 +0,0 @@ -create or replace package test_teamcity_reporter as - - --%suite(ut_teamcity_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%beforeall - procedure create_a_test_package; - - --%test(Report produces expected output) - procedure report_produces_expected_out; - - --%test(Escapes special characters) - procedure escape_special_chars; - - --%test(Trims output so it fits into 4000 chars) - procedure trims_long_output; - - --%test(Reports failures on multiple expectations) - procedure report_multiple_expectations; - - --%test(Reports failures on multiple expectations) - procedure report_multiple_expect_on_err; - - --%afterall - procedure remove_test_package; - -end; -/ diff --git a/test/ut3_user/reporters/test_tfs_junit_reporter.pkb b/test/ut3_user/reporters/test_tfs_junit_reporter.pkb deleted file mode 100644 index 1036be2ba..000000000 --- a/test/ut3_user/reporters/test_tfs_junit_reporter.pkb +++ /dev/null @@ -1,312 +0,0 @@ -create or replace package body test_tfs_junit_reporter as - - procedure crate_a_test_package is - pragma autonomous_transaction; - begin - execute immediate q'[create or replace package check_junit_reporting is - --%suite(A suite with ) - - --%test(A test with ) - procedure test_do_stuff; - - end;]'; - execute immediate q'[create or replace package body check_junit_reporting is - procedure test_do_stuff is - begin - ut3_develop.ut.expect(1).to_equal(1); - ut3_develop.ut.expect(1).to_equal(2); - end; - - end;]'; - - execute immediate q'[create or replace package check_junit_rep_suitepath is - --%suitepath(core) - --%suite(check_junit_rep_suitepath) - --%displayname(Check JUNIT Get path for suitepath) - - --%test(check_junit_rep_suitepath) - --%displayname(Check JUNIT Get path for suitepath) - procedure check_junit_rep_suitepath; - end;]'; - execute immediate q'[create or replace package body check_junit_rep_suitepath is - procedure check_junit_rep_suitepath is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - end;]'; - - execute immediate q'[create or replace package check_junit_flat_suitepath is - --%suitepath(core.check_junit_rep_suitepath) - --%suite(flatsuitepath) - - --%beforeall - procedure donuffin; - end;]'; - execute immediate q'[create or replace package body check_junit_flat_suitepath is - procedure donuffin is - begin - null; - end; - end;]'; - - execute immediate q'[create or replace package check_junit_in_context is - --%suitepath(core.check_junit_rep_suitepath) - --%suite(inctxsuite) - --%displayname(JUNIT test are inside context) - - -- %context(incontext) - -- %name(incontext) - - --%test(incontext) - --%displayname(Check JUNIT Get path incontext) - procedure check_junit_rep_incontext; - - -- %endcontext - end;]'; - execute immediate q'[create or replace package body check_junit_in_context is - procedure check_junit_rep_incontext is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - end;]'; - - execute immediate q'[create or replace package check_junit_out_context is - --%suitepath(core) - --%suite(outctxsuite) - --%displayname(JUNIT test are outside context) - - -- %context(outcontext) - -- %name(outcontext) - - -- %endcontext - - - --%test(outctx) - --%displayname(outctx) - procedure outctx; - - - end;]'; - execute immediate q'[create or replace package body check_junit_out_context is - procedure outctx is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - end;]'; - - execute immediate q'[create or replace package check_junit_inout_context is - --%suitepath(core) - --%suite(inoutcontext) - --%displayname(Test in and out of context) - - -- %context(incontext) - -- %name(ProductincontextFeatures) - - --%test(inctx) - --%displayname(inctx) - procedure inctx; - - -- %endcontext - - - --%test(outctx) - --%displayname(outctx) - procedure outctx; - - - end;]'; - execute immediate q'[create or replace package body check_junit_inout_context is - procedure inctx is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - - procedure outctx is - begin - ut3_develop.ut.expect(1).to_equal(1); - end; - end;]'; - - end; - - procedure escapes_special_chars is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_tfs_junit_reporter())); - 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>%'); - end; - - procedure reports_only_failed_or_errored is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_tfs_junit_reporter())); - 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 check_classname_suite is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting',ut3_develop.ut_tfs_junit_reporter())); - 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; - - procedure check_flatten_nested_suites is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_flat_suitepath',ut3_develop.ut_tfs_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like(' - - - - - -%'); - end; - - procedure check_nls_number_formatting is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - l_nls_numeric_characters varchar2(30); - begin - --Arrange - select replace(nsp.value,'''','''''') into l_nls_numeric_characters - from nls_session_parameters nsp - where parameter = 'NLS_NUMERIC_CHARACTERS'; - execute immediate q'[alter session set NLS_NUMERIC_CHARACTERS=', ']'; - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_reporting', ut3_develop.ut_tfs_junit_reporter())); - 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 - execute immediate 'alter session set NLS_NUMERIC_CHARACTERS='''||l_nls_numeric_characters||''''; - end; - - procedure check_failure_escaped is - begin - reporters.check_xml_failure_escaped(ut3_develop.ut_tfs_junit_reporter()); - end; - - procedure check_classname_suitepath is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_rep_suitepath',ut3_develop.ut_tfs_junit_reporter())); - 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; - procedure remove_test_package is - pragma autonomous_transaction; - begin - execute immediate 'drop package check_junit_reporting'; - execute immediate 'drop package check_junit_rep_suitepath'; - execute immediate 'drop package check_junit_flat_suitepath'; - end; - - procedure check_encoding_included is - begin - reporters.check_xml_encoding_included(ut3_develop.ut_tfs_junit_reporter(), 'UTF-8'); - end; - - procedure reports_only_test_in_ctx is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_in_context',ut3_develop.ut_tfs_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like(' - - - - - - - - -%'); - end; - - procedure reports_only_test_out_ctx is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_out_context',ut3_develop.ut_tfs_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like(' - - - - - - - - -%'); - end; - - procedure reports_only_test_inout_ctx is - l_results ut3_develop.ut_varchar2_list; - l_actual clob; - begin - --Act - select * - bulk collect into l_results - from table(ut3_develop.ut.run('check_junit_inout_context',ut3_develop.ut_tfs_junit_reporter())); - l_actual := ut3_tester_helper.main_helper.table_to_clob(l_results); - --Assert - ut.expect(l_actual).to_be_like(' - - - - - - - - - - -%'); - end; - -end; -/ \ No newline at end of file diff --git a/test/ut3_user/reporters/test_tfs_junit_reporter.pks b/test/ut3_user/reporters/test_tfs_junit_reporter.pks deleted file mode 100644 index 70f78e334..000000000 --- a/test/ut3_user/reporters/test_tfs_junit_reporter.pks +++ /dev/null @@ -1,45 +0,0 @@ -create or replace package test_tfs_junit_reporter as - - --%suite(ut_tfs_junit_reporter) - --%suitepath(utplsql.test_user.reporters) - - --%beforeall - procedure crate_a_test_package; - - --%test(Escapes special characters from test and suite description) - procedure escapes_special_chars; - - --%test(Reports only failed expectations and exceptions) - procedure reports_only_failed_or_errored; - - --%test(Check that classname is returned correct suite) - procedure check_classname_suite; - - --%test(Check that classname is returned correct suitepath) - procedure check_classname_suitepath; - - --%test(Check that nested suites are being flatten) - procedure check_flatten_nested_suites; - - --%test(Reports duration according to XML specification for numbers) - procedure check_nls_number_formatting; - - --%test( Validate that failures with special char are escaped ) - procedure check_failure_escaped; - - --%test(Includes XML header with encoding when encoding provided) - procedure check_encoding_included; - - --%test(Reports only testsuites where there are any testcases, all tests are in context) - procedure reports_only_test_in_ctx; - - --%test(Reports only testsuites where there are any testcases, all tests are outside context) - procedure reports_only_test_out_ctx; - - --%test(Reports only testsuites where there are any testcases, one test in ctx one test outside) - procedure reports_only_test_inout_ctx; - - --%afterall - procedure remove_test_package; -end; -/ diff --git a/test/ut3_user/test_user.pkb b/test/ut3_user/test_user.pkb deleted file mode 100644 index 9fec79d96..000000000 --- a/test/ut3_user/test_user.pkb +++ /dev/null @@ -1,11 +0,0 @@ -create or replace package body test_user is - - procedure global_setup is - begin - ut3_tester_helper.coverage_helper.set_develop_mode(); - --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 deleted file mode 100644 index ea0435efd..000000000 --- a/test/ut3_user/test_user.pks +++ /dev/null @@ -1,10 +0,0 @@ -create or replace package test_user is - - --%suite - --%suitepath(utplsql) - - --%beforeall - procedure global_setup; - -end; -/