diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6c848b6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,95 @@ +name: Build and deploy snapshot + +on: + push: + branches-ignore: [ main ] + pull_request: + branches: [ develop ] + + workflow_dispatch: + + repository_dispatch: + type: [utPLSQL-build,utPLSQL-java-api-build] + +jobs: + build: + + runs-on: ubuntu-latest + + services: + oracle: + image: gvenzl/oracle-xe:21-slim + env: + ORACLE_PASSWORD: oracle + ports: + - 1521:1521 + options: >- + --health-cmd healthcheck.sh + --health-interval 10s + --health-timeout 5s + --health-retries 10 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install utPLSQL + run: sh ${{ github.workspace }}/scripts/1_install_utplsql.sh + + - name: Install demo project + run: sh ${{ github.workspace }}/scripts/2_install_demo_project.sh + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'adopt' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Maven unit and integration tests with sonar + run: mvn clean verify sonar:sonar -Pcoverage -Dsonar.projectKey=org.utplsql:utplsql-maven-plugin + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Maven deploy snapshot + run: mvn deploy -DskipTests + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + - name: Publish unit test results + uses: EnricoMi/publish-unit-test-result-action@v1.24 + if: always() + with: + files: target/**/TEST**.xml + + slack-workflow-status: + if: always() + name: Post Workflow Status To Slack + needs: [ build ] + runs-on: ubuntu-latest + steps: + - name: Slack Workflow Notification + uses: Gamesight/slack-workflow-status@master + with: + # Required Input + repo_token: ${{secrets.GITHUB_TOKEN}} + slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} + # Optional Input + 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 new file mode 100644 index 0000000..4825e34 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Build and deploy release + +on: + push: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + services: + oracle: + image: gvenzl/oracle-xe:21-slim + env: + ORACLE_PASSWORD: oracle + ports: + - 1521:1521 + options: >- + --health-cmd healthcheck.sh + --health-interval 10s + --health-timeout 5s + --health-retries 10 + + steps: + - uses: actions/checkout@v2 + + - name: Install utPLSQL + run: sh ${{ github.workspace }}/scripts/1_install_utplsql.sh + + - name: Install demo project + run: sh ${{ github.workspace }}/scripts/2_install_demo_project.sh + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Maven deploy release + run: mvn clean deploy -Prelease + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + slack-workflow-status: + if: always() + name: Post Workflow Status To Slack + needs: [ build ] + runs-on: ubuntu-latest + steps: + - name: Slack Workflow Notification + uses: Gamesight/slack-workflow-status@master + with: + # Required Input + repo_token: ${{secrets.GITHUB_TOKEN}} + slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} + # Optional Input + name: 'Github Actions[bot]' + icon_url: 'https://octodex.github.com/images/mona-the-rivetertocat.png' diff --git a/.gitignore b/.gitignore index 1bb6467..ed6f99b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ dependency-reduced-pom.xml # Docs doc/ +/utPLSQL/ +/utPLSQL.zip +/tree.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ffb48ba..0000000 --- a/.travis.yml +++ /dev/null @@ -1,62 +0,0 @@ -sudo: required -language: java - -services: - - docker - -jdk: - - openjdk8 - -env: - global: - - DOCKER_CFG=$HOME/.docker - - DOCKER_REPO="utplsqlv3/oracledb" - - CACHE_DIR=$HOME/.cache - - MAVEN_HOME=/usr/local/maven - - MAVEN_CFG=$HOME/.m2 - - DB_URL="127.0.0.1:1521:XE" - - DB_UT3_USER=ut3 - - DB_UT3_PASS=ut3 - - ORACLE_VERSION="11g-r2-xe" - - DOCKER_OPTIONS="--shm-size=1g" - -cache: - directories: - - $DOCKER_CFG - - $CACHE_DIR - - $MAVEN_CFG - -install: - - bash .travis/maven_cfg.sh - - bash .travis/start_db.sh - - bash .travis/install_utplsql.sh - - bash .travis/install_demo_project.sh - -script: - - echo "Run Verify with Coverage" - - mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify -DdbUser="${DB_UT3_USER}" -DdbPass="${DB_UT3_PASS}" -DdbUrl="jdbc:oracle:thin:@${DB_URL}" - -before_deploy: - - echo $GPG_SECRET_KEYS | base64 --decode | ${GPG_EXECUTABLE} --import - - echo $GPG_OWNERTRUST | base64 --decode | ${GPG_EXECUTABLE} --import-ownertrust - -deploy: - - provider: script - skip_cleanup: true - script: bash .travis/deploy_snapshot.sh - on: - repo: utPLSQL/utPLSQL-maven-plugin - branch: develop - - provider: script - skip_cleanup: true - script: bash .travis/deploy_release.sh - on: - repo: utPLSQL/utPLSQL-maven-plugin - branch: main - -notifications: - slack: - rooms: - - secure: "Gz0pGOOM6xbnz8Q/B3RzOFoVr8QGXsDSHcgCloPnO3ZkEOh4JJikqWAVdZrksMxhewIBRpbdIWAZOgsNXvW+cEDXxfml3X9Clj2wg5Uon97UeI+5WEHDhLYHn7t9EYr9QvVSOuQgBIiddk6kURxY4N0eAA4VUti8BDcMRq+gPxF1w/toFJXVR/I/tkLxcHPTbWQ9X87nNWcQgMoHe2AixYpglntmtoLXJ5F8MF08fcyTX7GJQ5xjq7HbYy+/39nEhQo2ZPhHHfk2rS6gIUY0wc+MAqobxvesplgGDybdTQyrdl48VjJ/CiQDedglUbNN9VYTFjPIYMdWCUCLV1uL866aNMiBpB7CQoNhi5WS7RERE9gblVPX2k6tOda27fEWlhjha6OmdK6TQ9qTITU7U4OTSOz41dDPeVfqMHRggxo3ozlLONTiZ1y9fz/Ez9WjiJjtUDt60vgnVIo7BcQV/yDJcqAtQbfWyf0n73g5lMBvLGnO2Agm2N7hNEeCbpr+PZUoqkEM/e4SxdUCQGi8Ppi9Zp0E4v0iG7hyjzol+G4T8JN0bUGg0OOow/bfZa5J2aUsrC1qP/ZLpMA94NI6ZlL2wRHhZ9JtVSDLjtSwq9yW5XF7o7kdqBWBCslbGnYPoCoHOzfZuUvArSlRoGNu75dw/Qhoo9gFl1RG/RlChaU=" - on_success: change - on_failure: always diff --git a/.travis/deploy_release.sh b/.travis/deploy_release.sh deleted file mode 100755 index d6590e9..0000000 --- a/.travis/deploy_release.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -ev - -VERSION=$(tr -d "/v/" <<<${TRAVIS_TAG}) -mvn org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion=${VERSION} - -mvn deploy -DskipTests -U -Prelease diff --git a/.travis/deploy_snapshot.sh b/.travis/deploy_snapshot.sh deleted file mode 100755 index 27a6878..0000000 --- a/.travis/deploy_snapshot.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -ev - -#DATE=`date +%Y%m%d%H%M` -# Using this solution to get version into variable: https://stackoverflow.com/a/26514030/1470603 -#OLD_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) -#VERSION=`sed "s/-SNAPSHOT/-${DATE}-SNAPSHOT/g" <<<"${OLD_VERSION}"` - -#echo "Changing snapshot version, OLD: ${OLD_VERSION} NEW: ${VERSION}" -#mvn org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion=${VERSION} - -mvn deploy -DskipTests -U -Prelease diff --git a/.travis/install_demo_project.sh b/.travis/install_demo_project.sh deleted file mode 100644 index af6ff00..0000000 --- a/.travis/install_demo_project.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -ev - -DB_URL="//127.0.0.1:1521/XE" -SQLPLUS_IMAGE=${DOCKER_REPO}:${ORACLE_VERSION} -VOLUME="/project" - -docker run --rm -v $(pwd):${VOLUME} -w ${VOLUME} --network host --entrypoint sqlplus ${SQLPLUS_IMAGE} \ - sys/oracle@${DB_URL} as sysdba @.travis/sql/create_users.sql - -docker run --rm -v $(pwd):${VOLUME} -w ${VOLUME} --network host --entrypoint sqlplus ${SQLPLUS_IMAGE} \ - app/pass@${DB_URL} @.travis/sql/create_app_objects.sql - -docker run --rm -v $(pwd):${VOLUME} -w ${VOLUME} --network host --entrypoint sqlplus ${SQLPLUS_IMAGE} \ - code_owner/pass@${DB_URL} @.travis/sql/create_source_owner_objects.sql - -docker run --rm -v $(pwd):${VOLUME} -w ${VOLUME} --network host --entrypoint sqlplus ${SQLPLUS_IMAGE} \ - tests_owner/pass@${DB_URL} @.travis/sql/create_tests_owner_objects.sql diff --git a/.travis/install_utplsql.sh b/.travis/install_utplsql.sh deleted file mode 100644 index b02907b..0000000 --- a/.travis/install_utplsql.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -ev -cd $(dirname $(readlink -f $0)) - -DB_URL="//127.0.0.1:1521/XE" -UTPLSQL_VERSION="v3.1.9" -UTPLSQL_DIR="utPLSQL" -SQLPLUS_IMAGE=${DOCKER_REPO}:${ORACLE_VERSION} -VOLUME="/utPLSQL" - -git clone --depth=1 --branch=${UTPLSQL_VERSION} https://github.com/utPLSQL/utPLSQL.git ${UTPLSQL_DIR} - -docker run --rm -v $(pwd)/${UTPLSQL_DIR}:${VOLUME} -w ${VOLUME}/source --network host --entrypoint sqlplus ${SQLPLUS_IMAGE} \ - sys/oracle@${DB_URL} as sysdba @install_headless.sql ${DB_UT3_USER} ${DB_UT3_PASS} users diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh deleted file mode 100644 index 82661ad..0000000 --- a/.travis/maven_cfg.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -ev -cd $(dirname $(readlink -f $0)) - -cp settings.xml $MAVEN_CFG/settings.xml diff --git a/.travis/settings.xml b/.travis/settings.xml deleted file mode 100644 index 5f7d87e..0000000 --- a/.travis/settings.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - ossrh - - true - - - ${env.GPG_EXECUTABLE} - ${env.GPG_PASSPHRASE} - - - - - - - ossrh - ${env.SONATYPE_USERNAME} - ${env.SONATYPE_PASSWORD} - - - diff --git a/.travis/sql/create_app_objects.sql b/.travis/sql/create_app_objects.sql deleted file mode 100644 index 734b51e..0000000 --- a/.travis/sql/create_app_objects.sql +++ /dev/null @@ -1,9 +0,0 @@ -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -@src/test/resources/simple-project/scripts/sources/TO_TEST_ME.tab -@src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc -@src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy - -@src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc -@src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy diff --git a/.travis/sql/create_source_owner_objects.sql b/.travis/sql/create_source_owner_objects.sql deleted file mode 100644 index 2d15146..0000000 --- a/.travis/sql/create_source_owner_objects.sql +++ /dev/null @@ -1,6 +0,0 @@ -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -@src/test/resources/owner-param-project/scripts/sources/foo/tables/TO_TEST_ME.tab -@src/test/resources/owner-param-project/scripts/sources/foo/packages/PKG_TEST_ME.sql -@src/test/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql diff --git a/.travis/sql/create_tests_owner_objects.sql b/.travis/sql/create_tests_owner_objects.sql deleted file mode 100644 index e2d9a7c..0000000 --- a/.travis/sql/create_tests_owner_objects.sql +++ /dev/null @@ -1,7 +0,0 @@ -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -create synonym TO_TEST_ME for CODE_OWNER.TO_TEST_ME; -create synonym PKG_TEST_ME for CODE_OWNER.PKG_TEST_ME; -@src/test/resources/owner-param-project/scripts/test/bar/packages/TEST_PKG_TEST_ME.sql -@src/test/resources/owner-param-project/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql diff --git a/.travis/start_db.sh b/.travis/start_db.sh deleted file mode 100644 index a5b2414..0000000 --- a/.travis/start_db.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -ev - -# If docker credentials are not cached, do the login. -if [ ! -f $DOCKER_CFG/config.json ]; then - docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" -else - echo "Using docker login from cache..." -fi - -# Pull the specified db version from docker hub. -docker pull $DOCKER_REPO:$ORACLE_VERSION -docker run -d --name $ORACLE_VERSION $DOCKER_OPTIONS -p 127.0.0.1:1521:1521 $DOCKER_REPO:$ORACLE_VERSION -docker logs -f $ORACLE_VERSION | grep -m 1 "DATABASE IS READY TO USE!" --line-buffered diff --git a/README.md b/README.md index 96c7e87..d57328f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,22 @@ -[![Build status](https://travis-ci.org/utPLSQL/utPLSQL-maven-plugin.svg?branch=develop)](https://travis-ci.org/utPLSQL/utPLSQL-maven-plugin) +[![Build status](https://github.com/utPLSQL/utPLSQL-maven-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/utPLSQL/utPLSQL-maven-plugin/actions/workflows/build.yml) [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=org.utplsql%3Autplsql-maven-plugin&metric=alert_status)](https://sonarcloud.io/dashboard?id=org.utplsql%3Autplsql-maven-plugin) # utPLSQL-maven-plugin + A maven plugin for running Unit Tests with utPLSQL v3+. ## Compatibility + This plugin is compatible with utPLSQL 3.1.0+. ## Prerequisites + * Java SE Runtime Environment 8 * Maven Version 3.5+ -* Oracle JDBC driver +* Oracle JDBC driver ```xml + com.oracle.database.jdbc ojdbc8 @@ -27,6 +31,7 @@ This plugin is compatible with utPLSQL 3.1.0+. To skip running the tests for a particular project, set the **skipUtplsqlTests** property to true. ```xml + true @@ -38,9 +43,11 @@ You can also skip the tests via the command line by executing the following comm #### Skipping by Default -If you want to skip tests by default but want the ability to re-enable tests from the command line, you need to go via a properties section in the pom: +If you want to skip tests by default but want the ability to re-enable tests from the command line, you need to go via a +properties section in the pom: ```xml + true @@ -55,9 +62,10 @@ This will allow you to run with all tests disabled by default and to run them wi Please refer to the following usage example for the parameters descriptions: ```xml + + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.my_org @@ -82,7 +90,7 @@ Please refer to the following usage example for the parameters descriptions: org.utplsql utplsql-maven-plugin - 3.1.5 + 3.1.11 @@ -90,8 +98,9 @@ Please refer to the following usage example for the parameters descriptions: - + + @@ -115,7 +124,7 @@ Please refer to the following usage example for the parameters descriptions: - + src/test/resources/scripts/test @@ -125,13 +134,13 @@ Please refer to the following usage example for the parameters descriptions: - + - + false - + false @@ -144,6 +153,10 @@ Please refer to the following usage example for the parameters descriptions: false + + + 0 + test_tag @@ -153,17 +166,29 @@ Please refer to the following usage example for the parameters descriptions: true 5 - + app.test1,app.test2 - + app.test1,app.test2 - + + + app.test1,app.test2 + + + app.test1,app.test2 + + + app.test1,app.test2 + + + app.test1,app.test2 + @@ -194,7 +219,7 @@ Please refer to the following usage example for the parameters descriptions: UT_TEAMCITY_REPORTER - + code_owner @@ -208,7 +233,7 @@ Please refer to the following usage example for the parameters descriptions: package_bodies - + tests_owner @@ -231,9 +256,12 @@ Please refer to the following usage example for the parameters descriptions: ``` -More project samples are available in the src/test/resources directory: +More project samples are available in the `src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT` +directory: + * **simple-project:** Minimalist test project with standard project directory structure. -* **regex-project:** Overrides project directory structure and use additional parameters (sourcesRegexExpression, testsRegexExpression, ...), to tell utPLSQL how project files should be mapped into database objects. +* **regex-project:** Overrides project directory structure and use additional parameters (sourcesRegexExpression, + testsRegexExpression, ...), to tell utPLSQL how project files should be mapped into database objects. * **type-mapping-project:** Example how to use regex and custom type parameters together. * **owner-param-project:** Demonstrates how to use sourcesOwner and testsOwner parameters. diff --git a/mvnw b/mvnw index e96ccd5..41c0f0c 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -114,7 +114,6 @@ if $mingw ; then M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -200,6 +199,85 @@ if [ -z "$BASE_DIR" ]; then exit 1; fi +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} if [ "$MVNW_VERBOSE" = true ]; then echo $MAVEN_PROJECTBASEDIR @@ -218,6 +296,11 @@ if $cygwin; then MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ diff --git a/mvnw.cmd b/mvnw.cmd index 019bd74..8611571 100755 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script +@REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -26,7 +26,7 @@ @REM Optional ENV vars @REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,7 +35,9 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -115,10 +117,47 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end diff --git a/pom.xml b/pom.xml index b4422e6..760417b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.utplsql utplsql-maven-plugin - 3.1.5 + 3.1.12-SNAPSHOT maven-plugin utPLSQL Maven Plugin @@ -53,71 +53,50 @@ 1.8 1.8 UTF-8 + 3.5.2 - 2.0.9 - 2.3.1 + 0.11.0 + 5.8.1 + + utplsql + https://sonarcloud.io - - com.sun.xml.bind - jaxb-core - 3.0.1 - - - - javax.xml.bind - jaxb-api - ${jaxb.version} - - - - com.sun.xml.bind - jaxb-impl - ${jaxb.version} - - - - com.oracle.database.jdbc - ojdbc8 - 21.3.0.0 - - - - org.utplsql - java-api - 3.1.8 - - org.apache.maven maven-core ${maven.version} + provided - - org.apache.maven - maven-model + org.apache.maven.plugin-tools + maven-plugin-annotations ${maven.version} + provided + + + org.apache.maven.shared + maven-shared-utils + 3.3.4 - org.apache.maven - maven-plugin-api - ${maven.version} + org.utplsql + utplsql-java-api + 3.1.15 - org.apache.maven.plugin-tools - maven-plugin-annotations - ${maven.version} - provided + com.oracle.database.jdbc + ojdbc8 + 21.3.0.0 org.codehaus.plexus plexus-utils - 3.4.1 + 3.1.0 @@ -127,58 +106,54 @@ ${maven.version} test - - org.powermock - powermock-module-junit4 - ${powermock.version} + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 3.3.0 test - org.powermock - powermock-api-mockito2 - ${powermock.version} + org.junit.jupiter + junit-jupiter-engine + ${junit.version} test - - org.apache.maven.plugin-testing - maven-plugin-testing-harness - 3.3.0 + org.junit.vintage + junit-vintage-engine + ${junit.version} test - org.assertj - assertj-core - 3.21.0 + com.soebes.itf.jupiter.extension + itf-jupiter-extension + ${itf.version} test - - junit - junit - 4.13.2 + com.soebes.itf.jupiter.extension + itf-assertj + ${itf.version} test - org.apache.maven.shared - maven-verifier - 1.6 - test - - - commons-io - commons-io - 2.6 + org.slf4j + slf4j-simple + 1.7.32 test + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + org.apache.maven.plugins maven-failsafe-plugin @@ -192,6 +167,21 @@ + + com.soebes.itf.jupiter.extension + itf-maven-plugin + ${itf.version} + + + installing + pre-integration-test + + install + resources-its + + + + org.apache.maven.plugins maven-shade-plugin @@ -250,6 +240,32 @@ + + coverage + + + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + prepare-agent + + prepare-agent + + + + report + + report + + + + + + + release @@ -262,7 +278,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.1.1 + 3.3.1 attach-javadocs @@ -289,7 +305,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.0.1 sign-artifacts @@ -304,17 +320,4 @@ - - - - utplsql-java-api - https://packagecloud.io/utplsql/utplsql-java-api/maven2 - - true - - - true - - - diff --git a/scripts/0_start_db.sh b/scripts/0_start_db.sh new file mode 100644 index 0000000..d319407 --- /dev/null +++ b/scripts/0_start_db.sh @@ -0,0 +1 @@ +docker run -d --name ora-utplsql -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-xe:21-slim diff --git a/scripts/1_install_utplsql.sh b/scripts/1_install_utplsql.sh new file mode 100644 index 0000000..bb6577c --- /dev/null +++ b/scripts/1_install_utplsql.sh @@ -0,0 +1,8 @@ +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') + +curl -Lk "${UTPLSQL_DOWNLOAD_URL}" -o utPLSQL.zip + +unzip -q utPLSQL.zip + +docker run --rm -v $(pwd)/utPLSQL:/utPLSQL -w /utPLSQL/source --network host \ + --entrypoint sqlplus truemark/sqlplus:19.8 sys/oracle@//127.0.0.1:1521/XE as sysdba @install_headless.sql UT3 UT3 users diff --git a/scripts/2_install_demo_project.sh b/scripts/2_install_demo_project.sh new file mode 100644 index 0000000..a4089b1 --- /dev/null +++ b/scripts/2_install_demo_project.sh @@ -0,0 +1,11 @@ +docker run --rm -v $(pwd):/work -w /work/ --network host --entrypoint sqlplus truemark/sqlplus:19.8 \ + sys/oracle@//127.0.0.1:1521/XE as sysdba @scripts/sql/create_users.sql + +docker run --rm -v $(pwd):/work -w /work/ --network host --entrypoint sqlplus truemark/sqlplus:19.8 \ + app/pass@//127.0.0.1:1521/XE @scripts/sql/create_app_objects.sql + +docker run --rm -v $(pwd):/work -w /work/ --network host --entrypoint sqlplus truemark/sqlplus:19.8 \ + code_owner/pass@//127.0.0.1:1521/XE @scripts/sql/create_source_owner_objects.sql + +docker run --rm -v $(pwd):/work -w /work/ --network host --entrypoint sqlplus truemark/sqlplus:19.8 \ + tests_owner/pass@//127.0.0.1:1521/XE @scripts/sql/create_tests_owner_objects.sql diff --git a/scripts/sql/create_app_objects.sql b/scripts/sql/create_app_objects.sql new file mode 100644 index 0000000..9afffba --- /dev/null +++ b/scripts/sql/create_app_objects.sql @@ -0,0 +1,9 @@ +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/TO_TEST_ME.sql +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pks +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pkb + +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb diff --git a/scripts/sql/create_source_owner_objects.sql b/scripts/sql/create_source_owner_objects.sql new file mode 100644 index 0000000..35cb4aa --- /dev/null +++ b/scripts/sql/create_source_owner_objects.sql @@ -0,0 +1,6 @@ +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/tables/TO_TEST_ME.sql +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/packages/PKG_TEST_ME.pks +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/package_bodies/PKG_TEST_ME.pkb diff --git a/scripts/sql/create_tests_owner_objects.sql b/scripts/sql/create_tests_owner_objects.sql new file mode 100644 index 0000000..777dd95 --- /dev/null +++ b/scripts/sql/create_tests_owner_objects.sql @@ -0,0 +1,8 @@ +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +create synonym TO_TEST_ME for CODE_OWNER.TO_TEST_ME; +create synonym PKG_TEST_ME for CODE_OWNER.PKG_TEST_ME; + +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/test/bar/packages/TEST_PKG_TEST_ME.pks +@src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.pkb diff --git a/.travis/sql/create_users.sql b/scripts/sql/create_users.sql similarity index 100% rename from .travis/sql/create_users.sql rename to scripts/sql/create_users.sql diff --git a/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java b/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java deleted file mode 100644 index aaad826..0000000 --- a/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java +++ /dev/null @@ -1,388 +0,0 @@ -package org.utplsql.maven.plugin; - -import oracle.jdbc.pool.OracleDataSource; -import org.apache.commons.lang3.StringUtils; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.utils.logging.MessageUtils; -import org.utplsql.api.DBHelper; -import org.utplsql.api.FileMapperOptions; -import org.utplsql.api.JavaApiVersionInfo; -import org.utplsql.api.KeyValuePair; -import org.utplsql.api.TestRunner; -import org.utplsql.api.Version; -import org.utplsql.api.db.DatabaseInformation; -import org.utplsql.api.db.DefaultDatabaseInformation; -import org.utplsql.api.exception.SomeTestsFailedException; -import org.utplsql.api.reporter.CoreReporters; -import org.utplsql.api.reporter.Reporter; -import org.utplsql.api.reporter.ReporterFactory; -import org.utplsql.maven.plugin.helper.PluginDefault; -import org.utplsql.maven.plugin.helper.SQLScannerHelper; -import org.utplsql.maven.plugin.model.ReporterParameter; -import org.utplsql.maven.plugin.reporter.ReporterWriter; - -import java.io.File; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -/** - * This class expose the {@link TestRunner} interface to Maven. - * - * @author Alberto Hernández - * @author Simon Martinelli - */ -@Mojo(name = "test", defaultPhase = LifecyclePhase.TEST) -public class UtPLSQLMojo extends AbstractMojo { - - @Parameter(readonly = true, defaultValue = "${project}") - private MavenProject project; - - @Parameter(property = "dbUrl") - protected String url; - - @Parameter(property = "dbUser") - protected String user; - - @Parameter(property = "dbPass") - protected String password; - - @Parameter - protected String includeObject; - - @Parameter - protected String excludeObject; - - @Parameter(defaultValue = "false") - protected boolean skipCompatibilityCheck; - - @Parameter - protected List reporters = new ArrayList<>(); - - @Parameter - protected List paths = new ArrayList<>(); - - // Sources Configuration - @Parameter - protected List sources = new ArrayList<>(); - - @Parameter - private String sourcesOwner; - - @Parameter - private String sourcesRegexExpression; - - @Parameter - private Integer sourcesOwnerSubexpression; - - @Parameter - private Integer sourcesNameSubexpression; - - @Parameter - private Integer sourcesTypeSubexpression; - - @Parameter - private List sourcesCustomTypeMapping; - - // Tests Configuration - @Parameter - protected List tests = new ArrayList<>(); - - @Parameter - private String testsOwner; - - @Parameter - private String testsRegexExpression; - - @Parameter - private Integer testsOwnerSubexpression; - - @Parameter - private Integer testsNameSubexpression; - - @Parameter - private Integer testsTypeSubexpression; - - @Parameter - private List testsCustomTypeMapping; - - @Parameter - private final Set tags = new LinkedHashSet<>(); - - @Parameter - private boolean randomTestOrder; - - @Parameter - private Integer randomTestOrderSeed; - - @Parameter(defaultValue = "${project.build.directory}", readonly = true) - protected String targetDir; - - @Parameter(defaultValue = "${maven.test.failure.ignore}") - protected boolean ignoreFailure; - - @Parameter(property = "skipUtplsqlTests", defaultValue = "false") - protected boolean skipUtplsqlTests; - - @Parameter - protected boolean dbmsOutput; - - // Color in the console, bases on Maven logging configuration. - private final boolean colorConsole = MessageUtils.isColorEnabled(); - - private ReporterWriter reporterWriter; - - private final DatabaseInformation databaseInformation = new DefaultDatabaseInformation(); - - /** - * Executes the plugin. - */ - @Override - public void execute() throws MojoExecutionException { - if (skipUtplsqlTests) { - getLog().info("utPLSQLTests are skipped."); - } else { - getLog().debug("Java Api Version = " + JavaApiVersionInfo.getVersion()); - loadConfFromEnvironment(); - - Connection connection = null; - try { - FileMapperOptions sourceMappingOptions = buildSourcesOptions(); - FileMapperOptions testMappingOptions = buildTestsOptions(); - OracleDataSource ds = new OracleDataSource(); - ds.setURL(url); - ds.setUser(user); - ds.setPassword(password); - connection = ds.getConnection(); - - Version utlVersion = this.databaseInformation.getUtPlsqlFrameworkVersion(connection); - getLog().info("utPLSQL Version = " + utlVersion); - - List reporterList = initReporters(connection, utlVersion, ReporterFactory.createEmpty()); - - logParameters(sourceMappingOptions, testMappingOptions, reporterList); - - if (dbmsOutput) { - DBHelper.enableDBMSOutput(connection); - getLog().info("Enabled dbms_output."); - } - - TestRunner runner = new TestRunner() - .addPathList(paths) - .addReporterList(reporterList) - .sourceMappingOptions(sourceMappingOptions) - .testMappingOptions(testMappingOptions) - .skipCompatibilityCheck(skipCompatibilityCheck) - .colorConsole(colorConsole) - .addTags(tags) - .randomTestOrder(randomTestOrder) - .randomTestOrderSeed(randomTestOrderSeed) - .failOnErrors(!ignoreFailure); - - if (StringUtils.isNotBlank(excludeObject)) { - runner.excludeObject(excludeObject); - } - if (StringUtils.isNotBlank(includeObject)) { - runner.includeObject(includeObject); - } - - runner.run(connection); - - } catch (SomeTestsFailedException e) { - if (!this.ignoreFailure) { - throw new MojoExecutionException(e.getMessage(), e); - } - } catch (SQLException e) { - throw new MojoExecutionException(e.getMessage(), e); - } finally { - try { - if (null != connection) { - reporterWriter.writeReporters(connection); - - DBHelper.disableDBMSOutput(connection); - connection.close(); - } - } catch (Exception e) { - getLog().error(e.getMessage(), e); - } - } - } - } - - private void loadConfFromEnvironment() { - if (StringUtils.isEmpty(url)) { - url = System.getProperty("dbUrl"); - } - if (StringUtils.isEmpty(user)) { - user = System.getProperty("dbUser"); - } - if (StringUtils.isEmpty(password)) { - password = System.getProperty("dbPass"); - } - } - - private FileMapperOptions buildSourcesOptions() throws MojoExecutionException { - try { - if (sources.isEmpty()) { - File defaultSourceDirectory = new File(project.getBasedir(), PluginDefault.SOURCE_DIRECTORY); - if (defaultSourceDirectory.exists()) { - sources.add(PluginDefault.buildDefaultSource()); - } else { - return new FileMapperOptions(new ArrayList<>()); - } - } - - List scripts = SQLScannerHelper.findSQLs(project.getBasedir(), sources, - PluginDefault.SOURCE_DIRECTORY, PluginDefault.SOURCE_FILE_PATTERN); - FileMapperOptions fileMapperOptions = new FileMapperOptions(scripts); - - if (StringUtils.isNotEmpty(sourcesOwner)) { - fileMapperOptions.setObjectOwner(sourcesOwner); - } - - if (StringUtils.isNotEmpty(sourcesRegexExpression)) { - fileMapperOptions.setRegexPattern(sourcesRegexExpression); - } - - if (sourcesOwnerSubexpression != null) { - fileMapperOptions.setOwnerSubExpression(sourcesOwnerSubexpression); - } - - if (sourcesNameSubexpression != null) { - fileMapperOptions.setNameSubExpression(sourcesNameSubexpression); - } - - if (sourcesTypeSubexpression != null) { - fileMapperOptions.setTypeSubExpression(sourcesTypeSubexpression); - } - - if (sourcesCustomTypeMapping != null && !sourcesCustomTypeMapping.isEmpty()) { - fileMapperOptions.setTypeMappings(new ArrayList<>()); - for (CustomTypeMapping typeMapping : sourcesCustomTypeMapping) { - fileMapperOptions.getTypeMappings() - .add(new KeyValuePair(typeMapping.getCustomMapping(), typeMapping.getType())); - } - } - - return fileMapperOptions; - - } catch (Exception e) { - throw new MojoExecutionException("Invalid in your pom.xml", e); - } - - } - - private FileMapperOptions buildTestsOptions() throws MojoExecutionException { - try { - if (tests.isEmpty()) { - File defaultTestDirectory = new File(project.getBasedir(), PluginDefault.TEST_DIRECTORY); - if (defaultTestDirectory.exists()) { - tests.add(PluginDefault.buildDefaultTest()); - } else { - return new FileMapperOptions(new ArrayList<>()); - } - } - - List scripts = SQLScannerHelper.findSQLs(project.getBasedir(), tests, PluginDefault.TEST_DIRECTORY, - PluginDefault.TEST_FILE_PATTERN); - FileMapperOptions fileMapperOptions = new FileMapperOptions(scripts); - - if (StringUtils.isNotEmpty(testsOwner)) { - fileMapperOptions.setObjectOwner(testsOwner); - } - - if (StringUtils.isNotEmpty(testsRegexExpression)) { - fileMapperOptions.setRegexPattern(testsRegexExpression); - } - - if (testsOwnerSubexpression != null) { - fileMapperOptions.setOwnerSubExpression(testsOwnerSubexpression); - } - - if (testsNameSubexpression != null) { - fileMapperOptions.setNameSubExpression(testsNameSubexpression); - } - - if (testsTypeSubexpression != null) { - fileMapperOptions.setTypeSubExpression(testsTypeSubexpression); - } - - if (testsCustomTypeMapping != null && !testsCustomTypeMapping.isEmpty()) { - fileMapperOptions.setTypeMappings(new ArrayList<>()); - for (CustomTypeMapping typeMapping : testsCustomTypeMapping) { - fileMapperOptions.getTypeMappings() - .add(new KeyValuePair(typeMapping.getCustomMapping(), typeMapping.getType())); - } - } - - return fileMapperOptions; - - } catch (Exception e) { - throw new MojoExecutionException("Invalid in your pom.xml: " + e.getMessage()); - } - - } - - private List initReporters(Connection connection, Version utlVersion, ReporterFactory reporterFactory) - throws SQLException { - - List reporterList = new ArrayList<>(); - reporterWriter = new ReporterWriter(targetDir, utlVersion, getLog()); - - if (reporters.isEmpty()) { - ReporterParameter reporterParameter = new ReporterParameter(); - reporterParameter.setConsoleOutput(true); - reporterParameter.setName(CoreReporters.UT_DOCUMENTATION_REPORTER.name()); - reporters.add(reporterParameter); - } - - for (ReporterParameter reporterParameter : reporters) { - Reporter reporter = reporterFactory.createReporter(reporterParameter.getName()); - reporter.init(connection); - reporterList.add(reporter); - - // Turns the console output on by default if both file and console output are empty. - if (!reporterParameter.isFileOutput() && null == reporterParameter.getConsoleOutput()) { - reporterParameter.setConsoleOutput(true); - } - - // Only added the reporter if at least one of the output is required - if (StringUtils.isNotBlank(reporterParameter.getFileOutput()) || reporterParameter.isConsoleOutput()) { - reporterWriter.addReporter(reporterParameter, reporter); - } - } - - return reporterList; - } - - private void logParameters(FileMapperOptions sourceMappingOptions, FileMapperOptions testMappingOptions, - List reporterList) { - Log log = getLog(); - log.info("Invoking TestRunner with: " + targetDir); - - if (!log.isDebugEnabled()) { - return; - } - - log.debug("Invoking TestRunner with: "); - - log.debug("reporters="); - reporterList.forEach((Reporter r) -> log.debug(r.getTypeName())); - - log.debug("sources="); - sourceMappingOptions.getFilePaths().forEach(log::debug); - - log.debug("tests="); - testMappingOptions.getFilePaths().forEach(log::debug); - } -} diff --git a/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java b/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java new file mode 100644 index 0000000..c0ba4be --- /dev/null +++ b/src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java @@ -0,0 +1,404 @@ +package org.utplsql.maven.plugin; + +import oracle.jdbc.pool.OracleDataSource; +import org.apache.maven.model.Resource; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.logging.MessageUtils; +import org.utplsql.api.DBHelper; +import org.utplsql.api.FileMapperOptions; +import org.utplsql.api.JavaApiVersionInfo; +import org.utplsql.api.KeyValuePair; +import org.utplsql.api.TestRunner; +import org.utplsql.api.Version; +import org.utplsql.api.db.DefaultDatabaseInformation; +import org.utplsql.api.exception.SomeTestsFailedException; +import org.utplsql.api.reporter.CoreReporters; +import org.utplsql.api.reporter.Reporter; +import org.utplsql.api.reporter.ReporterFactory; +import org.utplsql.maven.plugin.io.ReportWriter; +import org.utplsql.maven.plugin.io.SqlFileScanner; +import org.utplsql.maven.plugin.model.CustomTypeMapping; +import org.utplsql.maven.plugin.model.ReporterParameter; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.utplsql.maven.plugin.util.StringUtil.isEmpty; +import static org.utplsql.maven.plugin.util.StringUtil.isNotBlank; +import static org.utplsql.maven.plugin.util.StringUtil.isNotEmpty; + +/** + * This class expose the {@link TestRunner} interface to Maven. + * + * @author Alberto Hernández + * @author Simon Martinelli + */ +@Mojo(name = "test", defaultPhase = LifecyclePhase.TEST) +public class UtPlsqlMojo extends AbstractMojo { + + @Parameter(readonly = true, defaultValue = "${project}") + MavenProject project; + + @Parameter(property = "dbUrl") + String url; + @Parameter(property = "dbUser") + String user; + @Parameter(property = "dbPass") + String password; + + @Parameter + String includeObject; + @Parameter + String excludeObject; + + @Parameter + String includeSchemaExpr; + @Parameter + String excludeSchemaExpr; + @Parameter + String includeObjectExpr; + @Parameter + String excludeObjectExpr; + + @Parameter(defaultValue = "false") + boolean skipCompatibilityCheck; + + @Parameter + final List reporters = new ArrayList<>(); + + @Parameter + final List paths = new ArrayList<>(); + + @Parameter + final List sources = new ArrayList<>(); + @Parameter + String sourcesOwner; + @Parameter + String sourcesRegexExpression; + @Parameter + Integer sourcesOwnerSubexpression; + @Parameter + Integer sourcesNameSubexpression; + @Parameter + Integer sourcesTypeSubexpression; + @Parameter + List sourcesCustomTypeMapping; + + @Parameter + final List tests = new ArrayList<>(); + @Parameter + String testsOwner; + @Parameter + String testsRegexExpression; + @Parameter + Integer testsOwnerSubexpression; + @Parameter + Integer testsNameSubexpression; + @Parameter + Integer testsTypeSubexpression; + @Parameter + List testsCustomTypeMapping; + + @Parameter + final Set tags = new LinkedHashSet<>(); + + @Parameter + boolean randomTestOrder; + + @Parameter + Integer randomTestOrderSeed; + + @Parameter(defaultValue = "${project.build.directory}", readonly = true) + String targetDir; + + @Parameter(defaultValue = "${maven.test.failure.ignore}") + boolean ignoreFailure; + + @Parameter(property = "skipUtplsqlTests", defaultValue = "false") + boolean skipUtplsqlTests; + + @Parameter + boolean dbmsOutput; + + @Parameter(defaultValue = "0") + Integer oraStuckTimeout; + + private final SqlFileScanner sqlFileScanner = new SqlFileScanner(); + + @Override + public void execute() throws MojoExecutionException { + if (skipUtplsqlTests) { + getLog().info("utPLSQLTests are skipped."); + } else { + getLog().debug("Java API Version = " + JavaApiVersionInfo.getVersion()); + + Connection connection = null; + ReportWriter reportWriter = null; + try { + connection = createConnection(); + + Version utlVersion = new DefaultDatabaseInformation().getUtPlsqlFrameworkVersion(connection); + getLog().info("utPLSQL Version = " + utlVersion); + + FileMapperOptions sourceMappingOptions = buildSourcesOptions(); + FileMapperOptions testMappingOptions = buildTestsOptions(); + + reportWriter = new ReportWriter(targetDir, utlVersion, getLog()); + List reporterList = initReporters(connection, reportWriter, ReporterFactory.createEmpty()); + + logParameters(sourceMappingOptions, testMappingOptions, reporterList); + + TestRunner runner = new TestRunner() + .addPathList(paths) + .addReporterList(reporterList) + .sourceMappingOptions(sourceMappingOptions) + .testMappingOptions(testMappingOptions) + .skipCompatibilityCheck(skipCompatibilityCheck) + .colorConsole(MessageUtils.isColorEnabled()) + .addTags(tags) + .randomTestOrder(randomTestOrder) + .randomTestOrderSeed(randomTestOrderSeed) + .failOnErrors(!ignoreFailure) + .oraStuckTimeout(oraStuckTimeout); + + if (isNotBlank(excludeObject)) { + if (excludeObject.contains(",")) { + String[] excludes = excludeObject.split(","); + runner.excludeObjects(Arrays.asList(excludes)); + } else { + runner.excludeObject(excludeObject); + } + + } + if (isNotBlank(includeObject)) { + if (includeObject.contains(",")) { + String[] includes = includeObject.split(","); + runner.includeObjects(Arrays.asList(includes)); + } else { + runner.includeObject(includeObject); + } + } + + if (isNotBlank(excludeSchemaExpr)) { + runner.excludeSchemaExpr(excludeSchemaExpr); + } + if (isNotBlank(includeSchemaExpr)) { + runner.includeSchemaExpr(includeSchemaExpr); + } + + if (isNotBlank(excludeObjectExpr)) { + runner.excludeObjectExpr(excludeObjectExpr); + } + if (isNotBlank(includeObjectExpr)) { + runner.includeObjectExpr(includeObjectExpr); + } + + runner.run(connection); + + } catch (SomeTestsFailedException e) { + if (!ignoreFailure) { + throw new MojoExecutionException(e.getMessage(), e); + } + } catch (SQLException | IOException e) { + throw new MojoExecutionException(e.getMessage(), e); + } finally { + try { + if (connection != null) { + if (reportWriter != null) { + reportWriter.writeReports(connection); + } + DBHelper.disableDBMSOutput(connection); + connection.close(); + } + } catch (SQLException | IOException e) { + getLog().error(e.getMessage(), e); + } + } + } + } + + private Connection createConnection() throws SQLException { + if (isEmpty(url)) { + url = System.getProperty("dbUrl"); + } + if (isEmpty(user)) { + user = System.getProperty("dbUser"); + } + if (isEmpty(password)) { + password = System.getProperty("dbPass"); + } + + OracleDataSource ds = new OracleDataSource(); + ds.setURL(url); + ds.setUser(user); + ds.setPassword(password); + + Connection connection = ds.getConnection(); + if (dbmsOutput) { + DBHelper.enableDBMSOutput(connection); + getLog().info("Enabled dbms_output."); + } + return connection; + } + + FileMapperOptions buildSourcesOptions() throws IOException { + if (sources.isEmpty()) { + File defaultSourceDirectory = new File(project.getBasedir(), Defaults.SOURCE_DIRECTORY); + if (defaultSourceDirectory.exists()) { + sources.add(Defaults.buildDefaultSource()); + } else { + return new FileMapperOptions(new ArrayList<>()); + } + } + + List scripts = sqlFileScanner.findSqlScripts(project.getBasedir(), sources, + Defaults.SOURCE_DIRECTORY, Defaults.SOURCE_FILE_PATTERN); + return createFileMapperOptions(scripts, sourcesOwner, sourcesRegexExpression, sourcesOwnerSubexpression, + sourcesNameSubexpression, sourcesTypeSubexpression, sourcesCustomTypeMapping); + } + + FileMapperOptions buildTestsOptions() throws IOException { + if (tests.isEmpty()) { + File defaultTestDirectory = new File(project.getBasedir(), Defaults.TEST_DIRECTORY); + if (defaultTestDirectory.exists()) { + tests.add(Defaults.buildDefaultTest()); + } else { + return new FileMapperOptions(new ArrayList<>()); + } + } + + List scripts = sqlFileScanner.findSqlScripts(project.getBasedir(), tests, Defaults.TEST_DIRECTORY, + Defaults.TEST_FILE_PATTERN); + return createFileMapperOptions(scripts, testsOwner, testsRegexExpression, testsOwnerSubexpression, + testsNameSubexpression, testsTypeSubexpression, testsCustomTypeMapping); + } + + private FileMapperOptions createFileMapperOptions(List scripts, String objectOwner, String regexPattern, + Integer ownerSubExpression, Integer nameSubExpression, + Integer typeSubExpression, List typeMappings) { + FileMapperOptions fileMapperOptions = new FileMapperOptions(scripts); + + if (isNotEmpty(objectOwner)) { + fileMapperOptions.setObjectOwner(objectOwner); + } + if (isNotEmpty(regexPattern)) { + fileMapperOptions.setRegexPattern(regexPattern); + } + if (ownerSubExpression != null) { + fileMapperOptions.setOwnerSubExpression(ownerSubExpression); + } + if (nameSubExpression != null) { + fileMapperOptions.setNameSubExpression(nameSubExpression); + } + if (typeSubExpression != null) { + fileMapperOptions.setTypeSubExpression(typeSubExpression); + } + if (typeMappings != null && !typeMappings.isEmpty()) { + fileMapperOptions.setTypeMappings(typeMappings.stream() + .map(mapping -> new KeyValuePair(mapping.getCustomMapping(), mapping.getType())) + .collect(Collectors.toList())); + } + return fileMapperOptions; + } + + List initReporters(Connection connection, ReportWriter reportWriter, ReporterFactory reporterFactory) throws SQLException { + List reporterList = new ArrayList<>(); + if (reporters.isEmpty()) { + getLog().debug("No reporters configured using default"); + + ReporterParameter reporterParameter = new ReporterParameter(); + reporterParameter.setConsoleOutput(true); + reporterParameter.setName(CoreReporters.UT_DOCUMENTATION_REPORTER.name()); + reporters.add(reporterParameter); + } + for (ReporterParameter reporterParameter : reporters) { + Reporter reporter = reporterFactory.createReporter(reporterParameter.getName()); + reporter.init(connection); + reporterList.add(reporter); + + // Turns the console output on by default if both file and console output are empty. + if (!reporterParameter.isFileOutput() && reporterParameter.getConsoleOutput() == null) { + reporterParameter.setConsoleOutput(true); + } + + // Only added the reporter if at least one of the output is required + if (isNotBlank(reporterParameter.getFileOutput()) || reporterParameter.isConsoleOutput()) { + reportWriter.addReporter(reporterParameter, reporter); + } + } + return reporterList; + } + + private void logParameters(FileMapperOptions sourceMappingOptions, FileMapperOptions testMappingOptions, List reporterList) { + getLog().info("Invoking TestRunner with: " + targetDir); + + if (getLog().isDebugEnabled()) { + getLog().debug("Invoking TestRunner with: "); + + getLog().debug("reporters="); + reporterList.forEach((Reporter r) -> getLog().debug(r.getTypeName())); + + getLog().debug("sources="); + sourceMappingOptions.getFilePaths().forEach(getLog()::debug); + + getLog().debug("tests="); + testMappingOptions.getFilePaths().forEach(getLog()::debug); + } + } + + /** + * This class provides methods to retrieve the list of resources in the default {@literal and } directories. + * + * @author Alberto Hernández + * @author Simon Martinelli + */ + private static class Defaults { + + public static final String SOURCE_DIRECTORY = "src/main/plsql"; + public static final String TEST_DIRECTORY = "src/test/plsql"; + public static final String SOURCE_FILE_PATTERN = "**/*.*"; + public static final String TEST_FILE_PATTERN = "**/*.pkg"; + + private Defaults() { + } + + /** + * This method returns {@link Resource} for the default {@code source} directory + * + * @return a {@link Resource} + */ + public static Resource buildDefaultSource() { + return buildDirectory(SOURCE_DIRECTORY, SOURCE_FILE_PATTERN); + } + + /** + * This method returns {@link Resource} for the default {@code test} directory + * + * @return a {@link Resource} + */ + public static Resource buildDefaultTest() { + return buildDirectory(TEST_DIRECTORY, TEST_FILE_PATTERN); + } + + private static Resource buildDirectory(String directory, String includes) { + Resource resource = new Resource(); + resource.setDirectory(directory); + resource.setIncludes(Collections.singletonList(includes)); + return resource; + } + } +} diff --git a/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java b/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java deleted file mode 100644 index ef50d39..0000000 --- a/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.utplsql.maven.plugin.helper; - -import org.apache.maven.model.Resource; - -import java.util.Collections; - -/** - * This class provides methods to retrieve the list of resources in the default - * {@literal and } directories. - * - * @author Alberto Hernández - */ -public class PluginDefault { - - /** - * Source directory. - */ - public static final String SOURCE_DIRECTORY = "src/main/plsql"; - - /** - * Test directory. - */ - public static final String TEST_DIRECTORY = "src/test/plsql"; - - /** - * Default source file pattern. - */ - public static final String SOURCE_FILE_PATTERN = "**/*.*"; - - /** - * Default test file pattern. - */ - public static final String TEST_FILE_PATTERN = "**/*.pkg"; - - private PluginDefault() { - // NA - } - - /** - * This method returns {@link Resource} for the default {@code source} directory - * - * @return a {@link Resource} - */ - public static Resource buildDefaultSource() { - return buildDirectory(SOURCE_DIRECTORY, SOURCE_FILE_PATTERN); - } - - /** - * This method returns {@link Resource} for the default {@code test} directory - * - * @return a {@link Resource} - */ - public static Resource buildDefaultTest() { - return buildDirectory(TEST_DIRECTORY, TEST_FILE_PATTERN); - } - - private static Resource buildDirectory(String directory, String includes) { - Resource resource = new Resource(); - resource.setDirectory(directory); - resource.setIncludes(Collections.singletonList(includes)); - return resource; - } -} diff --git a/src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java b/src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java deleted file mode 100644 index 3838a8c..0000000 --- a/src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.utplsql.maven.plugin.helper; - -import org.utplsql.api.reporter.Reporter; - -/** - * This class is an enumeration of all the known reporter in {@code utPLSQL}. - * Furthermore, it defines the default output file for each {@link Reporter}. - * In case the output file is set to {@code -}, it will mean the stdout of the - * process. - * - * @author Alberto Hernández - */ -public enum ReporterDefault { - - UT_DOCUMENTATION_REPORTER("-"), - UT_COVERAGE_HTML_REPORTER("utplsql/coverage-html-reporter.html"), - UT_TEAMCITY_REPORTER("utplsql/teamcity-reporter.txt"), - UT_XUNIT_REPORTER("utplsql/xunit-reporter.xml"), - UT_COVERALLS_REPORTER("utplsql/coveralls-reporter.json"), - UT_COVERAGE_SONAR_REPORTER("utplsql/coverage-sonar-reporter.xml"), - UT_SONAR_TEST_REPORTER("utplsql/sonar-test-reporter.xml"); - - private final String outputFile; - - ReporterDefault(String outputFile) { - this.outputFile = outputFile; - } - - public String getOutputFile() { - return outputFile; - } -} diff --git a/src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java b/src/main/java/org/utplsql/maven/plugin/io/ReportWriter.java similarity index 51% rename from src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java rename to src/main/java/org/utplsql/maven/plugin/io/ReportWriter.java index 78a0b39..e70f635 100644 --- a/src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java +++ b/src/main/java/org/utplsql/maven/plugin/io/ReportWriter.java @@ -1,9 +1,6 @@ -package org.utplsql.maven.plugin.reporter; +package org.utplsql.maven.plugin.io; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.logging.SystemStreamLog; import org.utplsql.api.Version; import org.utplsql.api.outputBuffer.OutputBuffer; import org.utplsql.api.outputBuffer.OutputBufferProvider; @@ -15,14 +12,21 @@ import java.io.IOException; import java.io.PrintStream; import java.sql.Connection; +import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import static java.lang.String.format; -public class ReporterWriter { +/** + * Writes the reports + * + * @author Alberto Hernández + * @author Simon Martinelli + */ +public class ReportWriter { - private final List> listReporters; + private final List reporters; private final String outputDirectory; @@ -33,81 +37,74 @@ public class ReporterWriter { /** * Constructor of the reporter writer. * - * @param outputDirectory the reporter output directory - * @param databaseVersion the utPLSQL framework version + * @param outputDirectory the report output directory + * @param databaseVersion the utPLSQL framework {@link Version} * @param log the Maven log */ - public ReporterWriter(String outputDirectory, Version databaseVersion, Log log) { - this.listReporters = new ArrayList<>(); + public ReportWriter(String outputDirectory, Version databaseVersion, Log log) { + this.reporters = new ArrayList<>(); this.outputDirectory = outputDirectory; this.databaseVersion = databaseVersion; this.log = log; } /** - * Adds a new reporter to the writter. + * Adds a new reporter to the writer. * - * @param parameter the reporter parameter - * @param reporter the reporter Object + * @param parameter the {@link ReporterParameter} + * @param reporter the {@link Reporter} */ public void addReporter(ReporterParameter parameter, Reporter reporter) { - listReporters.add(Pair.of(reporter, parameter)); + reporters.add(new ReporterAndReporterParameter(reporter, parameter)); } /** - * Writes the reporters to the output. + * Writes the reports to the output. * - * @param connection the database connection - * @throws MojoExecutionException if any exception happens + * @param connection The database {@link Connection} + * @throws SQLException if database access fails + * @throws IOException if files can't be written */ - public void writeReporters(Connection connection) throws MojoExecutionException { - for (Pair pair : listReporters) { - writeReports(connection, pair.getLeft(), pair.getRight()); + public void writeReports(Connection connection) throws SQLException, IOException { + for (ReporterAndReporterParameter pair : reporters) { + writeReports(connection, pair.getReporter(), pair.getReporterParameter()); } } - private void writeReports(Connection connection, Reporter reporter, ReporterParameter reporterParameter) - throws MojoExecutionException { - List printStreams = new ArrayList<>(); - FileOutputStream fout = null; - - // + private void writeReports(Connection connection, Reporter reporter, ReporterParameter reporterParameter) throws IOException, SQLException { + FileOutputStream fileOutputStream = null; try { OutputBuffer buffer = OutputBufferProvider.getCompatibleOutputBuffer(databaseVersion, reporter, connection); + List printStreams = new ArrayList<>(); if (reporterParameter.isFileOutput()) { - File file = new File(reporterParameter.getFileOutput()); if (!file.isAbsolute()) { file = new File(outputDirectory, reporterParameter.getFileOutput()); } if (!file.getParentFile().exists()) { - log.debug("Creating directory for reporter file " + file.getAbsolutePath()); + log.debug("Creating directory for report file " + file.getAbsolutePath()); + //noinspection ResultOfMethodCallIgnored file.getParentFile().mkdirs(); } - fout = new FileOutputStream(file); + fileOutputStream = new FileOutputStream(file); log.info(format("Writing report %s to %s", reporter.getTypeName(), file.getAbsolutePath())); - // Added to the Report - printStreams.add(new PrintStream(fout)); + printStreams.add(new PrintStream(fileOutputStream)); } if (reporterParameter.isConsoleOutput()) { log.info(format("Writing report %s to Console", reporter.getTypeName())); printStreams.add(System.out); } + buffer.printAvailable(connection, printStreams); - } catch (Exception e) { - throw new MojoExecutionException("Unexpected error opening file ouput ", e); + } finally { - if (fout != null) { - try { - fout.close(); - } catch (IOException e) { - log.info(format("Failed to closing the reporting %s", reporterParameter.getClass())); - } + if (fileOutputStream != null) { + fileOutputStream.close(); } } } diff --git a/src/main/java/org/utplsql/maven/plugin/io/ReporterAndReporterParameter.java b/src/main/java/org/utplsql/maven/plugin/io/ReporterAndReporterParameter.java new file mode 100644 index 0000000..07b72d9 --- /dev/null +++ b/src/main/java/org/utplsql/maven/plugin/io/ReporterAndReporterParameter.java @@ -0,0 +1,23 @@ +package org.utplsql.maven.plugin.io; + +import org.utplsql.api.reporter.Reporter; +import org.utplsql.maven.plugin.model.ReporterParameter; + +public class ReporterAndReporterParameter { + + private final Reporter reporter; + private final ReporterParameter reporterParameter; + + public ReporterAndReporterParameter(Reporter reporter, ReporterParameter reporterParameter) { + this.reporter = reporter; + this.reporterParameter = reporterParameter; + } + + public Reporter getReporter() { + return reporter; + } + + public ReporterParameter getReporterParameter() { + return reporterParameter; + } +} diff --git a/src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java b/src/main/java/org/utplsql/maven/plugin/io/SqlFileScanner.java similarity index 56% rename from src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java rename to src/main/java/org/utplsql/maven/plugin/io/SqlFileScanner.java index 392c850..f126769 100644 --- a/src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java +++ b/src/main/java/org/utplsql/maven/plugin/io/SqlFileScanner.java @@ -1,9 +1,10 @@ -package org.utplsql.maven.plugin.helper; +package org.utplsql.maven.plugin.io; import org.apache.maven.model.Resource; import org.codehaus.plexus.util.DirectoryScanner; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -14,12 +15,9 @@ * Utility to scan all resources * * @author Alberto Hernández + * @author Simon Martinelli */ -public class SQLScannerHelper { - - private SQLScannerHelper() { - // NA - } +public class SqlFileScanner { /** * Scans a directory looking for the matching patterns. @@ -30,11 +28,10 @@ private SQLScannerHelper() { * @param defaultFilePattern the default file pattern * @return a list of the files found */ - public static List findSQLs(File baseDir, List resources, String defaultDirectory, String defaultFilePattern) { + public List findSqlScripts(File baseDir, List resources, String defaultDirectory, String defaultFilePattern) throws IOException { List founds = new ArrayList<>(); for (Resource resource : resources) { - if (resource.getDirectory() == null) { resource.setDirectory(defaultDirectory); } @@ -49,29 +46,22 @@ public static List findSQLs(File baseDir, List resources, Stri for (String basename : scanner.getIncludedFiles()) { founds.add(baseDir.toURI().relativize(new File(scanner.getBasedir(), basename).toURI()).getPath()); } - founds.addAll(Collections.emptyList()); } return founds; } - private static DirectoryScanner buildScanner(String baseDir, Resource resource) { - - if (resource != null) { - File fileBaseDir = new File(baseDir, resource.getDirectory()); - if (!fileBaseDir.exists() || !fileBaseDir.isDirectory() || !fileBaseDir.canRead()) { - throw new IllegalArgumentException( - format("Invalid %s in resource. Check your pom.xml", resource.getDirectory())); - } - - DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir(fileBaseDir.getPath()); - scanner.setIncludes(resource.getIncludes().toArray(new String[0])); - scanner.setExcludes(resource.getExcludes().toArray(new String[0])); - return scanner; + private DirectoryScanner buildScanner(String baseDir, Resource resource) throws IOException { + File fileBaseDir = new File(baseDir, resource.getDirectory()); + if (!fileBaseDir.exists() || !fileBaseDir.isDirectory() || !fileBaseDir.canRead()) { + throw new IOException(format("Directory %s does not exist!", resource.getDirectory())); } - throw new IllegalArgumentException(); + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir(fileBaseDir.getPath()); + scanner.setIncludes(resource.getIncludes().toArray(new String[0])); + scanner.setExcludes(resource.getExcludes().toArray(new String[0])); + return scanner; } } diff --git a/src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java b/src/main/java/org/utplsql/maven/plugin/model/CustomTypeMapping.java similarity index 96% rename from src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java rename to src/main/java/org/utplsql/maven/plugin/model/CustomTypeMapping.java index 57d4080..16616b0 100644 --- a/src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java +++ b/src/main/java/org/utplsql/maven/plugin/model/CustomTypeMapping.java @@ -1,7 +1,8 @@ -package org.utplsql.maven.plugin; +package org.utplsql.maven.plugin.model; /** * Bean used by Maven to populate its model. + * * {@code * * ... diff --git a/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java b/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java index 472236d..c37aa5e 100644 --- a/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java +++ b/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java @@ -1,9 +1,10 @@ package org.utplsql.maven.plugin.model; -import org.codehaus.plexus.util.StringUtils; +import static org.utplsql.maven.plugin.util.StringUtil.isNotBlank; /** * Represents a reporter parameter in the pom file. + * * {@code * * ... @@ -11,7 +12,7 @@ * ... * * } - * + * * @author Alberto Hernández */ public class ReporterParameter { @@ -20,16 +21,9 @@ public class ReporterParameter { private String fileOutput; private Boolean consoleOutput; - /** - * Creates a new reporter parameter. - */ - public ReporterParameter() { - super(); - } - /** * Returns the reporter name. - * + * * @return the reporter name */ public String getName() { @@ -38,7 +32,7 @@ public String getName() { /** * Sets the reporter name. - * + * * @param name the reporter name */ public void setName(String name) { @@ -47,7 +41,7 @@ public void setName(String name) { /** * Returns reporter output file. - * + * * @return the output file name */ public String getFileOutput() { @@ -56,16 +50,16 @@ public String getFileOutput() { /** * Returns whether the file output is enabled or not. - * + * * @return true if the file output is enabled, false otherwise */ public boolean isFileOutput() { - return StringUtils.isNotBlank(fileOutput); + return isNotBlank(fileOutput); } /** * Sets the output file. - * + * * @param fileOutput the output file name */ public void setFileOutput(String fileOutput) { @@ -74,7 +68,7 @@ public void setFileOutput(String fileOutput) { /** * Returns the console output option. - * + * * @return the console output option */ public Boolean getConsoleOutput() { @@ -83,7 +77,7 @@ public Boolean getConsoleOutput() { /** * Returns whether the console output should be enabled or not. - * + * * @return true if console output is enable, false otherwise */ public Boolean isConsoleOutput() { @@ -92,7 +86,7 @@ public Boolean isConsoleOutput() { /** * Sets the console output option. - * + * * @param consoleOutput the console output option */ public void setConsoleOutput(boolean consoleOutput) { diff --git a/src/main/java/org/utplsql/maven/plugin/util/StringUtil.java b/src/main/java/org/utplsql/maven/plugin/util/StringUtil.java new file mode 100644 index 0000000..c351ca7 --- /dev/null +++ b/src/main/java/org/utplsql/maven/plugin/util/StringUtil.java @@ -0,0 +1,30 @@ +package org.utplsql.maven.plugin.util; + +public class StringUtil { + + private StringUtil() { + } + + public static boolean isEmpty(CharSequence cs) { + return cs == null || cs.length() == 0; + } + + public static boolean isNotEmpty(CharSequence cs) { + return !isEmpty(cs); + } + + public static boolean isBlank(CharSequence cs) { + if (cs != null && cs.length() > 0) { + for (int i = 0; i < cs.length(); ++i) { + if (!Character.isWhitespace(cs.charAt(i))) { + return false; + } + } + } + return true; + } + + public static boolean isNotBlank(CharSequence cs) { + return !isBlank(cs); + } +} diff --git a/src/test/java/org/utplsql/maven/plugin/ReportChecker.java b/src/test/java/org/utplsql/maven/plugin/ReportChecker.java new file mode 100644 index 0000000..3818674 --- /dev/null +++ b/src/test/java/org/utplsql/maven/plugin/ReportChecker.java @@ -0,0 +1,66 @@ +package org.utplsql.maven.plugin; + +import com.soebes.itf.jupiter.maven.MavenExecutionResult; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.soebes.itf.extension.assertj.MavenProjectResultAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + +public class ReportChecker { + + private ReportChecker() { + } + + /** + * Duration is set to 1 before comparing contents as it is always different. + * Path separator is set to "/" to ensure windows / linux / mac compatibility. + * \r and \n are removed to provide simpler comparison. + * + * @param result {@link MavenExecutionResult} + * @param files Files to compare + */ + public static void assertThatReportsAreGeneratedAsExpected(MavenExecutionResult result, String... files) { + for (String filename : files) { + File expectedOutputFile = new File(result.getMavenProjectResult().getTargetProjectDirectory(), "/expected-output/utplsql/" + filename); + File outputFile = new File(result.getMavenProjectResult().getTargetProjectDirectory(), "/target/utplsql/" + filename); + + assertThat(result.getMavenProjectResult()).withFile("/utplsql/" + filename).exists(); + + try (Stream stream = Files.lines(outputFile.toPath())) { + String outputContent = stream + .filter(line -> !line.contains(" line.replaceAll("(duration=\"[0-9.]*\")", "duration=\"1\"")) + .map(line -> line.replaceAll("\\\\", "/")) + .map(line -> line.replaceAll("\r", "").replaceAll("\n", "")) + .collect(Collectors.joining("\n")); + + assertEquals( + FileUtils.readFileToString(expectedOutputFile, "utf-8") + .replace("\r", "") + .replace("\n", ""), + outputContent.replace("\n", ""), "The files differ!"); + } catch (IOException e) { + fail(e); + } + } + } + + /** + * Check if the report was generated + * + * @param result {@link MavenExecutionResult} + * @param filename File Name + * @return if report exits + */ + public static boolean reportWasGenerated(MavenExecutionResult result, String filename) { + File outputFile = new File(result.getMavenProjectResult().getTargetProjectDirectory(), "/target/utplsql/" + filename); + return outputFile.exists(); + } +} diff --git a/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java new file mode 100644 index 0000000..ce2f533 --- /dev/null +++ b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java @@ -0,0 +1,100 @@ +package org.utplsql.maven.plugin; + +import com.soebes.itf.jupiter.extension.MavenGoal; +import com.soebes.itf.jupiter.extension.MavenJupiterExtension; +import com.soebes.itf.jupiter.extension.MavenTest; +import com.soebes.itf.jupiter.maven.MavenExecutionResult; + +import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat; +import static org.utplsql.maven.plugin.ReportChecker.assertThatReportsAreGeneratedAsExpected; +import static org.utplsql.maven.plugin.ReportChecker.reportWasGenerated; + +@MavenGoal("test") +@MavenJupiterExtension +class UtPlsqlMojoIT { + + @MavenTest + void minimalist(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + } + + @MavenTest + void owner_param(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void regex(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void simple(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void skip(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThat(result.getMavenLog()).info().contains("utPLSQLTests are skipped."); + + assertThat(reportWasGenerated(result, "sonar-test-report.xml")).isFalse(); + } + + @MavenTest + void tags(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml"); + } + + @MavenTest + void type_mapping(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void exclude_object(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void include_object(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void ora_stuck_timeout(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void exclude_object_expr(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + + @MavenTest + void include_object_expr(MavenExecutionResult result) { + assertThat(result).isSuccessful(); + + assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml"); + } + +} diff --git a/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java new file mode 100644 index 0000000..6315072 --- /dev/null +++ b/src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java @@ -0,0 +1,432 @@ +package org.utplsql.maven.plugin; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.testing.MojoRule; +import org.junit.Rule; +import org.junit.Test; +import org.utplsql.api.FileMapperOptions; +import org.utplsql.maven.plugin.model.ReporterParameter; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintStream; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +public class UtPlsqlMojoTest { + + @Rule + public final MojoRule rule = new MojoRule(); + + /** + * Invalid Sources Directory + *

+ * Given : a pom.xml with invalid sources' directory + * When : pom is read and buildSourcesOptions is run + * Then : it should throw a MojoExecutionException + */ + @Test + public void invalid_sources_directory() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("invalid_sources_directory"); + assertNotNull(utPlsqlMojo); + + MojoExecutionException exception = assertThrows(MojoExecutionException.class, utPlsqlMojo::execute); + + assertEquals("Directory foo does not exist!", exception.getMessage()); + } + + /** + * Invalid Tests Directory + *

+ * Given : a pom.xml with invalid tests' directory + * When : pom is read and buildTestsOptions is run + * Then : it should throw a MojoExecutionException + */ + @Test + public void invalid_tests_directory() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("invalid_tests_directory"); + assertNotNull(utPlsqlMojo); + + MojoExecutionException exception = assertThrows(MojoExecutionException.class, utPlsqlMojo::execute); + + assertEquals("Directory bar does not exist!", exception.getMessage()); + } + + /** + * Sources Tests Parameters + *

+ * Given : a pom.xml with sources and tests with a lot of parameters + * When : pom is read and buildSourcesOptions / buildTestsOptions are run + * Then : it should fill all parameters correctly + */ + @Test + public void sources_tests_parameters() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_tests_parameters"); + assertNotNull(utPlsqlMojo); + + assertEquals(2, utPlsqlMojo.reporters.size()); + + // check sources + FileMapperOptions sources = utPlsqlMojo.buildSourcesOptions(); + assertEquals(1, sources.getFilePaths().size()); + assertEquals("srcs/foo.sql", sources.getFilePaths().get(0)); + assertEquals("code_owner", sources.getObjectOwner()); + assertEquals(".*/\\w+/(\\w+)/(\\w+)\\.\\w{3}", sources.getRegexPattern()); + assertEquals(Integer.valueOf(9), sources.getNameSubExpression()); + assertEquals(Integer.valueOf(1), sources.getTypeSubExpression()); + assertEquals(Integer.valueOf(4), sources.getOwnerSubExpression()); + assertEquals(1, sources.getTypeMappings().size()); + assertEquals("bar", sources.getTypeMappings().get(0).getKey()); + assertEquals("foo", sources.getTypeMappings().get(0).getValue()); + + // check tests + FileMapperOptions tests = utPlsqlMojo.buildTestsOptions(); + assertEquals(2, tests.getFilePaths().size()); + assertTrue(tests.getFilePaths().contains("te/st/file.pkb")); + assertTrue(tests.getFilePaths().contains("te/st/spec.pks")); + assertEquals("tests_owner", tests.getObjectOwner()); + assertEquals(".*/\\w+/(\\w+)/(\\w+)\\.\\w{3}", tests.getRegexPattern()); + assertEquals(Integer.valueOf(54), tests.getNameSubExpression()); + assertEquals(Integer.valueOf(21), tests.getTypeSubExpression()); + assertEquals(Integer.valueOf(24), tests.getOwnerSubExpression()); + assertEquals(1, tests.getTypeMappings().size()); + assertEquals("def", tests.getTypeMappings().get(0).getKey()); + assertEquals("abc", tests.getTypeMappings().get(0).getValue()); + } + + /** + * Sources and Tests Parameter does not exist + *

+ * Given : a pom.xml with no sources / tests tags and default directory does not exist. + * When : pom is read and buildSourcesOptions / buildTestsOptions are run + * Then : it should not find any source files + */ + @Test + public void sources_and_tests_parameter_does_not_exist() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_does_not_exist"); + assertNotNull(utPlsqlMojo); + + // check sources + FileMapperOptions sources = utPlsqlMojo.buildSourcesOptions(); + assertEquals(0, sources.getFilePaths().size()); + + // check tests + FileMapperOptions tests = utPlsqlMojo.buildTestsOptions(); + assertEquals(0, tests.getFilePaths().size()); + } + + /** + * Sources and Tests Parameter does not exist but Default Directory exists + *

+ * Given : a pom.xml with no sources / tests tags but default directory exists. + * When : pom is read and buildSourcesOptions / buildTestsOptions are run + * Then : it should find all sources/tests files in default directories + */ + @Test + public void sources_and_tests_parameter_does_not_exist_but_default_directory_exists() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_does_not_exist_but_default_directory_exists"); + assertNotNull(utPlsqlMojo); + + // check sources + FileMapperOptions sources = utPlsqlMojo.buildSourcesOptions(); + assertEquals(2, sources.getFilePaths().size()); + assertTrue(sources.getFilePaths().contains("src/main/plsql/f1.sql")); + assertTrue(sources.getFilePaths().contains("src/main/plsql/f2.sql")); + + // check tests + FileMapperOptions tests = utPlsqlMojo.buildTestsOptions(); + assertEquals(2, tests.getFilePaths().size()); + assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.pkg")); + assertTrue(tests.getFilePaths().contains("src/test/plsql/f2.pkg")); + } + + /** + * Sources and Tests Parameter have not Directory Tag + *

+ * Given : a pom.xml with source and test tag not containing a directory tag. + * When : pom is read and buildSourcesOptions / buildTestsOptions are run + * Then : it should find all sources/tests files in default directories + */ + @Test + public void sources_and_tests_parameter_have_not_directory_tag() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_have_not_directory_tag"); + assertNotNull(utPlsqlMojo); + + // check sources + FileMapperOptions sources = utPlsqlMojo.buildSourcesOptions(); + assertEquals(2, sources.getFilePaths().size()); + assertTrue(sources.getFilePaths().contains("src/main/plsql/f1.sql")); + assertTrue(sources.getFilePaths().contains("src/main/plsql/foo/f2.sql")); + + // check tests + FileMapperOptions tests = utPlsqlMojo.buildTestsOptions(); + assertEquals(3, tests.getFilePaths().size()); + assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.pkg")); + assertTrue(tests.getFilePaths().contains("src/test/plsql/f2.pkg")); + assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.sql")); + } + + /** + * Sources and Tests Parameter have not Directory Tag + *

+ * Given : a pom.xml with source and test tag not containing a directory tag. + * When : pom is read and buildSourcesOptions / buildTestsOptions are run + * Then : it should find all sources/tests files in default directories + */ + @Test + public void sources_and_tests_parameter_have_not_includes_tag() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("sources_and_tests_parameter_have_not_includes_tag"); + assertNotNull(utPlsqlMojo); + + // check sources + FileMapperOptions sources = utPlsqlMojo.buildSourcesOptions(); + assertEquals(2, sources.getFilePaths().size()); + assertTrue(sources.getFilePaths().contains("src/main/foo/f1.sql")); + assertTrue(sources.getFilePaths().contains("src/main/foo/foo/f2.sql")); + + // check tests + FileMapperOptions tests = utPlsqlMojo.buildTestsOptions(); + assertEquals(2, tests.getFilePaths().size()); + assertTrue(tests.getFilePaths().contains("src/test/bar/foo/f1.pkg")); + assertTrue(tests.getFilePaths().contains("src/test/bar/f2.pkg")); + } + + /** + * Default Console Behaviour + *

+ * Given : a pom.xml with file and console output + * When : pom is read + * Then : it should set the correct output channels + */ + @Test + public void default_console_output_behaviour() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("default_console_output_behaviour"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + // Assert that we added only the necessary reporters to the writer. + List reporters = utPlsqlMojo.reporters; + assertEquals(3, reporters.size()); + + ReporterParameter reporterParameter1 = reporters.get(0); + assertTrue(reporterParameter1.isConsoleOutput()); + assertFalse(reporterParameter1.isFileOutput()); + + ReporterParameter reporterParameter2 = reporters.get(1); + assertFalse(reporterParameter2.isConsoleOutput()); + assertTrue(reporterParameter2.isFileOutput()); + + ReporterParameter reporterParameter3 = reporters.get(2); + assertTrue(reporterParameter3.isConsoleOutput()); + assertTrue(reporterParameter3.isFileOutput()); + } + + /** + * Default Reporter + *

+ * Given : a pom.xml without reporters + * When : pom is read + * Then : it should set the default reporter + */ + @Test + public void default_reporter() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("default_reporter"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals(1, utPlsqlMojo.reporters.size()); + assertEquals("UT_DOCUMENTATION_REPORTER", utPlsqlMojo.reporters.get(0).getName()); + } + + /** + * Default Reporter + *

+ * Given : a pom.xml with skipUtplsqlTests=true + * When : pom is read + * Then : Tests are skipped + */ + @Test + public void skip_utplsql_tests() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("skip_utplsql_tests"); + assertNotNull(utPlsqlMojo); + + final ByteArrayOutputStream console = new ByteArrayOutputStream(); + System.setOut(new PrintStream(console)); + + utPlsqlMojo.execute(); + + String standardOutput = console.toString(); + + assertTrue(standardOutput.contains("utPLSQLTests are skipped.")); + } + + /** + * Set ORA Stuck Timeout + *

+ * Given : a pom.xml with oraStuckTimeout=0 + * When : pom is read + * Then : Property is set + */ + @Test + public void ora_stuck_timeout() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("ora_stuck_timeout"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals(5, (int) utPlsqlMojo.oraStuckTimeout); + } + + /** + * Ora Stuck Timeout + *

+ * Given : a pom.xml with ora-stuck-timeout set + * When : pom is read + * Then : DBMS_OUTPUT is enabled + */ + @Test + public void dbms_output() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("dbms_output"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + } + + /** + * DB configuration from System Properties + *

+ * Given : a pom.xml without dbUrl, dbUser and dbPass configured + * When : pom is read + * Then : System Properties must be used to configure database + */ + @Test + public void db_config_using_system_properties() throws Exception { + System.setProperty("dbUrl", "jdbc:oracle:thin:@localhost:1521:xe"); + System.setProperty("dbUser", "UT3"); + System.setProperty("dbPass", "UT3"); + + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("db_config_using_system_properties"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + System.setProperty("dbUrl", ""); + System.setProperty("dbUser", ""); + System.setProperty("dbPass", ""); + } + + /** + * Exclude a list of objects + *

+ * Given : a pom.xml with a list of objects to exclude + * When : pom is read + * Then : Objects are excluded + */ + @Test + public void exclude_object() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("exclude_object"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals("app.pkg_test_me,app.test_pkg_test_me", utPlsqlMojo.excludeObject); + } + + /** + * Include a list of objects + *

+ * Given : a pom.xml with a list of objects to include + * When : pom is read + * Then : Objects are included + */ + @Test + public void include_object() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("include_object"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals("app.pkg_test_me,app.test_pkg_test_me", utPlsqlMojo.includeObject); + } + + /** + * Include an object by regex + *

+ * Given : a pom.xml with a regex to include + * When : pom is read + * Then : Objects are included + */ + @Test + public void include_object_expr() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("include_object_expr"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals("*", utPlsqlMojo.includeObjectExpr); + } + + /** + * Exclude an object by regex + *

+ * Given : a pom.xml with a regex to exclude + * When : pom is read + * Then : Objects are included + */ + @Test + public void exclude_object_expr() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("exclude_object_expr"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals("*", utPlsqlMojo.excludeObjectExpr); + } + + + /** + * Include a schema by regex + *

+ * Given : a pom.xml with a regex to include + * When : pom is read + * Then : Objects are included + */ + @Test + public void include_schema_expr() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("include_schema_expr"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals("*", utPlsqlMojo.includeSchemaExpr); + } + + /** + * Exclude a schema by regex + *

+ * Given : a pom.xml with a regex to exclude + * When : pom is read + * Then : Objects are included + */ + @Test + public void exclude_schema_expr() throws Exception { + UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("exclude_schema_expr"); + assertNotNull(utPlsqlMojo); + + utPlsqlMojo.execute(); + + assertEquals("*", utPlsqlMojo.excludeSchemaExpr); + } + + private UtPlsqlMojo createUtPlsqlMojo(String directory) throws Exception { + return (UtPlsqlMojo) rule.lookupConfiguredMojo(new File("src/test/resources/unit-tests/" + directory), "test"); + } + +} diff --git a/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoIT.java b/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoIT.java deleted file mode 100644 index c3f322a..0000000 --- a/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoIT.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.utplsql.maven.plugin.test; - -import org.apache.commons.io.FileUtils; -import org.apache.maven.it.VerificationException; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class UtPLSQLMojoIT { - - private static String pluginVersion = null; - - @BeforeClass - public static void setUp() throws VerificationException, IOException, XmlPullParserException { - MavenXpp3Reader reader = new MavenXpp3Reader(); - Model model = reader.read(new FileReader("pom.xml")); - - Verifier verifier = new Verifier(new File("").getAbsolutePath()); - - // Install Plugin - verifier.setAutoclean(false); - verifier.addCliOption("-DskipTests"); - verifier.executeGoal("install"); - - pluginVersion = model.getVersion(); - } - - @Test - public void testSimpleProject() { - try { - final String PROJECT_NAME = "simple-project"; - File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/" + PROJECT_NAME); - - Verifier verifier; - verifier = new Verifier(testProject.getAbsolutePath()); - verifier.addCliOption("-N"); - verifier.addCliOption("-Dutplsql-maven-plugin-version=" + pluginVersion); - verifier.addCliOption("-DdbUrl=" + System.getProperty("dbUrl")); - verifier.addCliOption("-DdbUser=" + System.getProperty("dbUser")); - verifier.addCliOption("-DdbPass=" + System.getProperty("dbPass")); - - verifier.executeGoal("test"); - - checkReportsGenerated(PROJECT_NAME, "utplsql/sonar-test-reporter.xml", - "utplsql/coverage-sonar-reporter.xml"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test of Definition " + e.getMessage()); - } - } - - @Test - public void testRegexProject() { - try { - final String PROJECT_NAME = "regex-project"; - File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/" + PROJECT_NAME); - - Verifier verifier; - verifier = new Verifier(testProject.getAbsolutePath()); - verifier.addCliOption("-N"); - verifier.addCliOption("-Dutplsql-maven-plugin-version=" + pluginVersion); - verifier.addCliOption("-DdbUrl=" + System.getProperty("dbUrl")); - verifier.addCliOption("-DdbUser=" + System.getProperty("dbUser")); - verifier.addCliOption("-DdbPass=" + System.getProperty("dbPass")); - - verifier.executeGoal("test"); - - checkReportsGenerated(PROJECT_NAME, "utplsql/sonar-test-reporter.xml", - "utplsql/coverage-sonar-reporter.xml"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test : " + e.getMessage()); - } - } - - @Test - public void testTypeMappingProject() { - try { - final String PROJECT_NAME = "type-mapping-project"; - File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/" + PROJECT_NAME); - - Verifier verifier; - verifier = new Verifier(testProject.getAbsolutePath()); - verifier.addCliOption("-N"); - verifier.addCliOption("-Dutplsql-maven-plugin-version=" + pluginVersion); - verifier.addCliOption("-DdbUrl=" + System.getProperty("dbUrl")); - verifier.addCliOption("-DdbUser=" + System.getProperty("dbUser")); - verifier.addCliOption("-DdbPass=" + System.getProperty("dbPass")); - - verifier.executeGoal("test"); - - checkReportsGenerated(PROJECT_NAME, "utplsql/sonar-test-reporter.xml", - "utplsql/coverage-sonar-reporter.xml"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test : " + e.getMessage()); - } - } - - @Test - public void testOwnerParameterProject() { - try { - final String PROJECT_NAME = "owner-param-project"; - File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/" + PROJECT_NAME); - - Verifier verifier; - verifier = new Verifier(testProject.getAbsolutePath()); - verifier.addCliOption("-N"); - verifier.addCliOption("-Dutplsql-maven-plugin-version=" + pluginVersion); - verifier.addCliOption("-DdbUrl=" + System.getProperty("dbUrl")); - verifier.addCliOption("-DdbUser=" + System.getProperty("dbUser")); - verifier.addCliOption("-DdbPass=" + System.getProperty("dbPass")); - - verifier.executeGoal("test"); - - checkReportsGenerated(PROJECT_NAME, "utplsql/sonar-test-reporter.xml", - "utplsql/coverage-sonar-reporter.xml"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test : " + e.getMessage()); - } - } - - @Test - public void testMinimalistProject() { - try { - final String PROJECT_NAME = "minimalist-project"; - File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/" + PROJECT_NAME); - - Verifier verifier; - verifier = new Verifier(testProject.getAbsolutePath()); - verifier.addCliOption("-N"); - verifier.addCliOption("-Dutplsql-maven-plugin-version=" + pluginVersion); - verifier.addCliOption("-DdbUrl=" + System.getProperty("dbUrl")); - verifier.addCliOption("-DdbUser=" + System.getProperty("dbUser")); - verifier.addCliOption("-DdbPass=" + System.getProperty("dbPass")); - - verifier.executeGoal("test"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test : " + e.getMessage()); - } - } - - @Test - public void testTagsProject() { - try { - final String PROJECT_NAME = "tags-project"; - File testProject = ResourceExtractor.simpleExtractResources(getClass(), "/" + PROJECT_NAME); - - Verifier verifier; - verifier = new Verifier(testProject.getAbsolutePath()); - verifier.addCliOption("-N"); - verifier.addCliOption("-Dutplsql-maven-plugin-version=" + pluginVersion); - verifier.addCliOption("-DdbUrl=" + System.getProperty("dbUrl")); - verifier.addCliOption("-DdbUser=" + System.getProperty("dbUser")); - verifier.addCliOption("-DdbPass=" + System.getProperty("dbPass")); - - verifier.executeGoal("test"); - - checkReportsGenerated(PROJECT_NAME, "utplsql/sonar-test-reporter.xml"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test of Definition " + e.getMessage()); - } - } - - private void checkReportsGenerated(String projectName, String... files) { - for (String filename : files) { - File outputFile = new File("target/test-classes/" + projectName + "/target", filename); - File expectedOutputFile = new File("target/test-classes/" + projectName + "/expected-output", filename); - - Assert.assertTrue("The reporter for " + filename + " was not generated", outputFile.exists()); - try { - // Duration is set to 1 before comparing contents as it is always different. - // Path separator is set to "/" to ensure windows / linux / mac compatibility. - Stream stream = Files - .lines(Paths.get("target", "test-classes", projectName, "target", filename)); - - String outputContent = stream - .filter(line -> !line.contains(" line.replaceAll("(duration=\"[0-9.]*\")", "duration=\"1\"")) - .map(line -> line.replaceAll("\\\\", "/")) - .map(line -> line.replaceAll("\r", "").replaceAll("\n", "")) - .collect(Collectors.joining("\n")); - - stream.close(); - Assert.assertEquals("The files differ!", - FileUtils.readFileToString(expectedOutputFile, "utf-8").replace("\r", ""), outputContent); - } catch (IOException e) { - e.printStackTrace(); - Assert.fail("Unexpected Exception running the test : " + e.getMessage()); - } - } - } -} diff --git a/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java b/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java deleted file mode 100644 index 024a672..0000000 --- a/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java +++ /dev/null @@ -1,341 +0,0 @@ -package org.utplsql.maven.plugin.test; - -import org.apache.commons.lang3.tuple.Pair; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.testing.MojoRule; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; -import org.utplsql.api.DBHelper; -import org.utplsql.api.FileMapperOptions; -import org.utplsql.api.Version; -import org.utplsql.api.reporter.Reporter; -import org.utplsql.api.reporter.ReporterFactory; -import org.utplsql.maven.plugin.UtPLSQLMojo; -import org.utplsql.maven.plugin.model.ReporterParameter; -import org.utplsql.maven.plugin.reporter.ReporterWriter; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.PrintStream; -import java.sql.Connection; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.when; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({DBHelper.class, ReporterFactory.class}) -public class UtPLSQLMojoTest { - - @Rule - public MojoRule rule = new MojoRule(); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Mock - public Connection mockConnection; - - @Mock - public Version mockVersion; - - @Mock - public ReporterFactory mockReporterFactory; - - @Before - public void setUp() throws Exception { - mockStatic(DBHelper.class); - when(DBHelper.getDatabaseFrameworkVersion(mockConnection)).thenReturn(mockVersion); - - mockStatic(ReporterFactory.class); - when(ReporterFactory.createEmpty()).thenReturn(mockReporterFactory); - } - - /** - * testInvalidSourcesDirectory. - *

- * Given : a pom.xml with invalid sources' directory When : pom is read and - * buildSourcesOptions is run Then : it should throw a MojoExecutionException - */ - @Test - public void testInvalidSourcesDirectory() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/invalidTestsSourcesDirectories/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // Expected exception - thrown.expect(MojoExecutionException.class); - // Excepted message - thrown.expectMessage("Invalid in your pom.xml"); - - Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions"); - } - - /** - * testInvalidTestsDirectory. - *

- * Given : a pom.xml with invalid tests' directory When : pom is read and - * buildTestsOptions is run Then : it should throw a MojoExecutionException - */ - @Test - public void testInvalidTestsDirectory() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/invalidTestsSourcesDirectories/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // Expected exception - thrown.expect(MojoExecutionException.class); - // Excepted message - thrown.expectMessage("Invalid in your pom.xml"); - - Whitebox.invokeMethod(utplsqlMojo, "buildTestsOptions"); - } - - /** - * testSourcesTestsParameters. - *

- * Given : a pom.xml with sources and tests with a lot of parameters When : pom - * is read and buildSourcesOptions / buildTestsOptions are run Then : it should - * fill all parameters correctly - */ - @Test - public void testSourcesTestsParameters() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/testSourcesTestsParams/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // TODO : move to another test about reporters - List reporters = Whitebox.getInternalState(utplsqlMojo, "reporters"); - assertEquals(reporters.size(), 2); - - // check sources - FileMapperOptions sources = Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions"); - assertEquals(1, sources.getFilePaths().size()); - assertEquals("srcs/foo.sql", sources.getFilePaths().get(0)); - assertEquals("code_owner", sources.getObjectOwner()); - assertEquals(".*/\\w+/(\\w+)/(\\w+)\\.\\w{3}", sources.getRegexPattern()); - assertEquals(new Integer(9), sources.getNameSubExpression()); - assertEquals(new Integer(1), sources.getTypeSubExpression()); - assertEquals(new Integer(4), sources.getOwnerSubExpression()); - assertEquals(1, sources.getTypeMappings().size()); - assertEquals("bar", sources.getTypeMappings().get(0).getKey()); - assertEquals("foo", sources.getTypeMappings().get(0).getValue()); - - // check tests - FileMapperOptions tests = Whitebox.invokeMethod(utplsqlMojo, "buildTestsOptions"); - assertEquals(2, tests.getFilePaths().size()); - assertTrue(tests.getFilePaths().contains("te/st/file.bdy")); - assertTrue(tests.getFilePaths().contains("te/st/spec.spc")); - assertEquals("tests_owner", tests.getObjectOwner()); - assertEquals(".*/\\w+/(\\w+)/(\\w+)\\.\\w{3}", tests.getRegexPattern()); - assertEquals(new Integer(54), tests.getNameSubExpression()); - assertEquals(new Integer(21), tests.getTypeSubExpression()); - assertEquals(new Integer(24), tests.getOwnerSubExpression()); - assertEquals(1, tests.getTypeMappings().size()); - assertEquals("def", tests.getTypeMappings().get(0).getKey()); - assertEquals("abc", tests.getTypeMappings().get(0).getValue()); - } - - /** - * testSourcesAndTestsParameterDoesNotExist. - *

- * Given : a pom.xml with no sources / tests tags and default directory does not - * exist. When : pom is read and buildSourcesOptions / buildTestsOptions are run - * Then : it should not find any source files - */ - @Test - public void testSourcesAndTestsParameterDoesNotExist() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule.lookupConfiguredMojo( - new File("src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // check sources - FileMapperOptions sources = Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions"); - assertEquals(0, sources.getFilePaths().size()); - - // check tests - FileMapperOptions tests = Whitebox.invokeMethod(utplsqlMojo, "buildTestsOptions"); - assertEquals(0, tests.getFilePaths().size()); - } - - /** - * testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists. - *

- * Given : a pom.xml with no sources / tests tags but default directory exists. - * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then : - * it should find all sources/tests files in default directories - */ - @Test - public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/testNoSourcesTestsParams/directoryExists/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // check sources - FileMapperOptions sources = Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions"); - assertEquals(2, sources.getFilePaths().size()); - assertTrue(sources.getFilePaths().contains("src/main/plsql/f1.sql")); - assertTrue(sources.getFilePaths().contains("src/main/plsql/f2.sql")); - - // check tests - FileMapperOptions tests = Whitebox.invokeMethod(utplsqlMojo, "buildTestsOptions"); - assertEquals(2, tests.getFilePaths().size()); - assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.pkg")); - assertTrue(tests.getFilePaths().contains("src/test/plsql/f2.pkg")); - } - - /** - * testSourcesAndTestsParameterHaveNotDirectoryTag. - *

- * Given : a pom.xml with source and test tag not containing a directory tag. - * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then : - * it should find all sources/tests files in default directories - */ - @Test - public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/partialSourceAndTestTag/missingDirectory/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // check sources - FileMapperOptions sources = Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions"); - assertEquals(2, sources.getFilePaths().size()); - assertTrue(sources.getFilePaths().contains("src/main/plsql/f1.sql")); - assertTrue(sources.getFilePaths().contains("src/main/plsql/foo/f2.sql")); - - // check tests - FileMapperOptions tests = Whitebox.invokeMethod(utplsqlMojo, "buildTestsOptions"); - assertEquals(3, tests.getFilePaths().size()); - assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.pkg")); - assertTrue(tests.getFilePaths().contains("src/test/plsql/f2.pkg")); - assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.sql")); - } - - /** - * testSourcesAndTestsParameterHaveNotDirectoryTag. - *

- * Given : a pom.xml with source and test tag not containing a directory tag. - * When : pom is read and buildSourcesOptions / buildTestsOptions are run Then : - * it should find all sources/tests files in default directories - */ - @Test - public void testSourcesAndTestsParameterHaveNotIncludesTag() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/partialSourceAndTestTag/missingIncludes/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - // check sources - FileMapperOptions sources = Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions"); - assertEquals(2, sources.getFilePaths().size()); - assertTrue(sources.getFilePaths().contains("src/main/foo/f1.sql")); - assertTrue(sources.getFilePaths().contains("src/main/foo/foo/f2.sql")); - - // check tests - FileMapperOptions tests = Whitebox.invokeMethod(utplsqlMojo, "buildTestsOptions"); - assertEquals(2, tests.getFilePaths().size()); - assertTrue(tests.getFilePaths().contains("src/test/bar/foo/f1.pkg")); - assertTrue(tests.getFilePaths().contains("src/test/bar/f2.pkg")); - } - - @Test - public void testDefaultConsoleBehaviour() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/defaultConsoleOutputBehaviour/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - List reporterList = new ArrayList<>(); - when(mockReporterFactory.createReporter(anyString())).thenAnswer(invocation -> { - Reporter mockReporter = mock(Reporter.class); - reporterList.add(mockReporter); - return mockReporter; - }); - - Whitebox.invokeMethod(utplsqlMojo, "initReporters", mockConnection, mockVersion, mockReporterFactory); - - // Assert that we called the creation reporter with the correct parameters. - verify(mockReporterFactory, times(2)).createReporter("UT_DOCUMENTATION_REPORTER"); - verify(mockReporterFactory).createReporter("UT_COVERAGE_SONAR_REPORTER"); - verify(mockReporterFactory).createReporter("UT_SONAR_TEST_REPORTER"); - verifyNoMoreInteractions(mockReporterFactory); - - // Assert that all reporters have been initialized. - for (Reporter mockReporter : reporterList) { - verify(mockReporter).init(mockConnection); - verifyNoMoreInteractions(mockReporter); - } - - // Assert that we added only the necessary reporters to the writer. - ReporterWriter reporterWritter = Whitebox.getInternalState(utplsqlMojo, "reporterWriter"); - List> listReporters = Whitebox.getInternalState(reporterWritter, "listReporters"); - assertEquals(3, listReporters.size()); - - ReporterParameter reporterParameter1 = listReporters.get(0).getRight(); - assertTrue(reporterParameter1.isConsoleOutput()); - assertFalse(reporterParameter1.isFileOutput()); - - ReporterParameter reporterParameter2 = listReporters.get(1).getRight(); - assertFalse(reporterParameter2.isConsoleOutput()); - assertTrue(reporterParameter2.isFileOutput()); - - ReporterParameter reporterParameter3 = listReporters.get(2).getRight(); - assertTrue(reporterParameter3.isConsoleOutput()); - assertTrue(reporterParameter3.isFileOutput()); - } - - @Test - public void testAddDefaultReporter() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/defaultConsoleOutputBehaviour/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - List reporterList = new ArrayList<>(); - when(mockReporterFactory.createReporter(anyString())).thenAnswer(invocation -> { - Reporter mockReporter = mock(Reporter.class); - when(mockReporter.getTypeName()).thenReturn(invocation.getArgument(0)); - reporterList.add(mockReporter); - return mockReporter; - }); - - List reporterParameters = Whitebox.getInternalState(utplsqlMojo, "reporters"); - reporterParameters.clear(); - - Whitebox.invokeMethod(utplsqlMojo, "initReporters", mockConnection, mockVersion, mockReporterFactory); - - assertEquals(1, reporterList.size()); - assertEquals("UT_DOCUMENTATION_REPORTER", reporterList.get(0).getTypeName()); - verify(reporterList.get(0)).init(mockConnection); - } - - @Test - public void testSkipUtplsqlTests() throws Exception { - UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule - .lookupConfiguredMojo(new File("src/test/resources/skipUtplsqlTests/"), "test"); - Assert.assertNotNull(utplsqlMojo); - - final ByteArrayOutputStream console = new ByteArrayOutputStream(); - System.setOut(new PrintStream(console)); - - utplsqlMojo.execute(); - - String standardOutput = console.toString(); - - Assert.assertTrue(standardOutput.contains("utPLSQLTests are skipped.")); - } -} diff --git a/src/test/java/org/utplsql/maven/plugin/util/StringUtilTest.java b/src/test/java/org/utplsql/maven/plugin/util/StringUtilTest.java new file mode 100644 index 0000000..22c60be --- /dev/null +++ b/src/test/java/org/utplsql/maven/plugin/util/StringUtilTest.java @@ -0,0 +1,73 @@ +package org.utplsql.maven.plugin.util; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.utplsql.maven.plugin.util.StringUtil.isBlank; +import static org.utplsql.maven.plugin.util.StringUtil.isEmpty; +import static org.utplsql.maven.plugin.util.StringUtil.isNotBlank; +import static org.utplsql.maven.plugin.util.StringUtil.isNotEmpty; + +class StringUtilTest { + + @Test + void isEmpty_with_empty() { + assertTrue(isEmpty("")); + } + + @Test + void isEmpty_with_null() { + assertTrue(isEmpty(null)); + } + + @Test + void isEmpty_with_string() { + assertFalse(isEmpty("abc")); + } + + @Test + void isNotEmpty_with_string() { + assertTrue(isNotEmpty("abc")); + } + + @Test + void isNotEmpty_with_empty() { + assertFalse(isNotEmpty("")); + } + + @Test + void isNotEmpty_with_blank() { + assertTrue(isNotEmpty(" ")); + } + + @Test + void isBlank_with_blank() { + assertTrue(isBlank(" ")); + } + + @Test + void isBlank_with_null() { + assertTrue(isBlank(null)); + } + + @Test + void isBlank_with_string() { + assertFalse(isBlank("abc")); + } + + @Test + void isBlank_with_whitespaces_before_string() { + assertFalse(isBlank(" abc")); + } + + @Test + void isNotBlank_with_string() { + assertTrue(isNotBlank("abc")); + } + + @Test + void isNotBlank_with_empty() { + assertFalse(isNotBlank("")); + } +} diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..cf7a48f --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,2 @@ + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/expected-output/utplsql/sonar-test-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/expected-output/utplsql/sonar-test-report.xml new file mode 100644 index 0000000..04708f1 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/expected-output/utplsql/sonar-test-report.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/pom.xml new file mode 100644 index 0000000..15411c2 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + owner-param + 1.0.0 + pom + + + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 + + + + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + + + test + + + false + + TESTS_OWNER + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-report.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + app.pkg_test_me,app.test_pkg_test_me + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..cf7a48f --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,2 @@ + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/expected-output/utplsql/sonar-test-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/expected-output/utplsql/sonar-test-report.xml new file mode 100644 index 0000000..04708f1 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/expected-output/utplsql/sonar-test-report.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/pom.xml new file mode 100644 index 0000000..22d0869 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/exclude_object_expr/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + owner-param + 1.0.0 + pom + + + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 + + + + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + + + test + + + false + + TESTS_OWNER + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-report.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + *pkg_test_me + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..0700c46 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1 @@ + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/expected-output/utplsql/sonar-test-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/expected-output/utplsql/sonar-test-report.xml new file mode 100644 index 0000000..04708f1 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/expected-output/utplsql/sonar-test-report.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/pom.xml new file mode 100644 index 0000000..ee6d13f --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + owner-param + 1.0.0 + pom + + + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 + + + + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + + + test + + + false + + TESTS_OWNER + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-report.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + app.pkg_test_me + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..2dbcb4d --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1 @@ + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/expected-output/utplsql/sonar-test-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/expected-output/utplsql/sonar-test-report.xml new file mode 100644 index 0000000..04708f1 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/expected-output/utplsql/sonar-test-report.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/pom.xml new file mode 100644 index 0000000..e807d13 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/include_object_expr/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + owner-param + 1.0.0 + pom + + + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 + + + + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + + + test + + + false + + TESTS_OWNER + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-report.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + app.* + + + + + + + diff --git a/src/test/resources/minimalist-project/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/minimalist/pom.xml similarity index 56% rename from src/test/resources/minimalist-project/pom.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/minimalist/pom.xml index 2f80480..40759d2 100644 --- a/src/test/resources/minimalist-project/pom.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/minimalist/pom.xml @@ -1,24 +1,25 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql - utplsql-maven-plugin-minimalist-test + minimalist 1.0.0 pom - utplsql-maven-plugin IT Minimalist - + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 - ${project.groupId} + org.utplsql utplsql-maven-plugin - ${utplsql-maven-plugin-version} + @project.version@ @@ -26,7 +27,6 @@ - diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..4d584c2 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/expected-output/utplsql/sonar-test-report.xml similarity index 87% rename from src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/expected-output/utplsql/sonar-test-report.xml index 1908eac..03b1ce5 100644 --- a/src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/expected-output/utplsql/sonar-test-report.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/simple-project/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/pom.xml similarity index 72% rename from src/test/resources/simple-project/pom.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/pom.xml index ee05b0b..f0c33da 100644 --- a/src/test/resources/simple-project/pom.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/pom.xml @@ -1,76 +1,69 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql - utplsql-maven-plugin-simple-test + ora-stuck-timeout 1.0.0 pom - utplsql-maven-plugin IT Simple - + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 - ${project.groupId} + org.utplsql utplsql-maven-plugin - ${utplsql-maven-plugin-version} + @project.version@ test - - + 1 false - app - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - scripts/sources - **/*bdy - **/*spc + **/**.pks + **/**.pkb - scripts/tests - **/*bdy - **/*spc + **/**.pks + **/**.pkb - - - diff --git a/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/APP.PKG_TEST_ME.pkb similarity index 99% rename from src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/APP.PKG_TEST_ME.pkb index d7f60de..331959d 100644 --- a/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/APP.PKG_TEST_ME.pkb @@ -1,5 +1,4 @@ CREATE OR REPLACE PACKAGE BODY PKG_TEST_ME IS - -- -- This -- @@ -25,4 +24,4 @@ CREATE OR REPLACE PACKAGE BODY PKG_TEST_ME IS END PR_TEST_ME; END PKG_TEST_ME; -/ \ No newline at end of file +/ diff --git a/src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/APP.PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/APP.PKG_TEST_ME.pks diff --git a/src/test/resources/owner-param-project/scripts/sources/foo/tables/TO_TEST_ME.tab b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/TO_TEST_ME.sql similarity index 100% rename from src/test/resources/owner-param-project/scripts/sources/foo/tables/TO_TEST_ME.tab rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/sources/TO_TEST_ME.sql diff --git a/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/tests/APP.TEST_PKG_TEST_ME.pkb similarity index 100% rename from src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/tests/APP.TEST_PKG_TEST_ME.pkb diff --git a/src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/tests/APP.TEST_PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/ora_stuck_timeout/scripts/tests/APP.TEST_PKG_TEST_ME.pks diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..07ab94a --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/resources/owner-param-project/expected-output/utplsql/sonar-test-reporter.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/expected-output/utplsql/sonar-test-report.xml similarity index 85% rename from src/test/resources/owner-param-project/expected-output/utplsql/sonar-test-reporter.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/expected-output/utplsql/sonar-test-report.xml index e558e2f..afefd7c 100644 --- a/src/test/resources/owner-param-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/expected-output/utplsql/sonar-test-report.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/owner-param-project/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/pom.xml similarity index 81% rename from src/test/resources/owner-param-project/pom.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/pom.xml index 1cf170c..961940b 100644 --- a/src/test/resources/owner-param-project/pom.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/pom.xml @@ -1,57 +1,54 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql - utplsql-maven-plugin-owner-parameter-test + owner-param 1.0.0 pom - utplsql-maven-plugin IT Owner Parameter - + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 - - ${project.groupId} + org.utplsql utplsql-maven-plugin - ${utplsql-maven-plugin-version} + @project.version@ test - - false - tests_owner - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - scripts/sources - **/*sql + **/**.sql + **/**.pks + **/**.pkb @@ -65,12 +62,12 @@ package_bodies - scripts/test - **/*sql + **/**.pks + **/**.pkb diff --git a/src/test/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/package_bodies/PKG_TEST_ME.pkb similarity index 99% rename from src/test/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/package_bodies/PKG_TEST_ME.pkb index 894119f..d6846b2 100644 --- a/src/test/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/package_bodies/PKG_TEST_ME.pkb @@ -1,5 +1,4 @@ CREATE OR REPLACE PACKAGE BODY CODE_OWNER.PKG_TEST_ME IS - -- -- This -- @@ -25,4 +24,4 @@ CREATE OR REPLACE PACKAGE BODY CODE_OWNER.PKG_TEST_ME IS END PR_TEST_ME; END PKG_TEST_ME; -/ \ No newline at end of file +/ diff --git a/src/test/resources/owner-param-project/scripts/sources/foo/packages/PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/packages/PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/owner-param-project/scripts/sources/foo/packages/PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/packages/PKG_TEST_ME.pks diff --git a/src/test/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/tables/TO_TEST_ME.sql similarity index 100% rename from src/test/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/sources/foo/tables/TO_TEST_ME.sql diff --git a/src/test/resources/owner-param-project/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.pkb similarity index 100% rename from src/test/resources/owner-param-project/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.pkb diff --git a/src/test/resources/owner-param-project/scripts/test/bar/packages/TEST_PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/test/bar/packages/TEST_PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/owner-param-project/scripts/test/bar/packages/TEST_PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/owner_param/scripts/test/bar/packages/TEST_PKG_TEST_ME.pks diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..a4c6cf5 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/expected-output/utplsql/sonar-test-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/expected-output/utplsql/sonar-test-report.xml new file mode 100644 index 0000000..d4acc02 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/expected-output/utplsql/sonar-test-report.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/regex-project/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/pom.xml similarity index 77% rename from src/test/resources/regex-project/pom.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/pom.xml index 0f1a41c..2620738 100644 --- a/src/test/resources/regex-project/pom.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/pom.xml @@ -1,57 +1,54 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql - utplsql-maven-plugin-regex-test + regex 1.0.0 pom - utplsql-maven-plugin IT regex - + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 - ${project.groupId} + org.utplsql utplsql-maven-plugin - ${utplsql-maven-plugin-version} + @project.version@ test - - false - app - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - scripts/sources - **/*bdy - **/*spc + **/**.sql + **/**.pks + **/**.pkb @@ -59,13 +56,12 @@ 2 6 7 - scripts/test - **/*bdy - **/*spc + **/**.pks + **/**.pkb @@ -73,7 +69,6 @@ 2 6 7 - diff --git a/src/test/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/packages/PKG_TEST_ME.pkb similarity index 99% rename from src/test/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/packages/PKG_TEST_ME.pkb index 29cea5e..8769df3 100644 --- a/src/test/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/packages/PKG_TEST_ME.pkb @@ -1,5 +1,4 @@ CREATE OR REPLACE PACKAGE BODY APP.PKG_TEST_ME IS - -- -- This -- @@ -25,4 +24,4 @@ CREATE OR REPLACE PACKAGE BODY APP.PKG_TEST_ME IS END PR_TEST_ME; END PKG_TEST_ME; -/ \ No newline at end of file +/ diff --git a/src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/packages/PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/packages/PKG_TEST_ME.pks diff --git a/src/test/resources/simple-project/scripts/sources/TO_TEST_ME.tab b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/tables/TO_TEST_ME.sql similarity index 100% rename from src/test/resources/simple-project/scripts/sources/TO_TEST_ME.tab rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/sources/app/tables/TO_TEST_ME.sql diff --git a/src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/test/app/packages/TEST_PKG_TEST_ME.pkb similarity index 100% rename from src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/test/app/packages/TEST_PKG_TEST_ME.pkb diff --git a/src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/test/app/packages/TEST_PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/regex/scripts/test/app/packages/TEST_PKG_TEST_ME.pks diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..4d584c2 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/expected-output/utplsql/sonar-test-report.xml similarity index 86% rename from src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/expected-output/utplsql/sonar-test-report.xml index 6e6fad7..03b1ce5 100644 --- a/src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/expected-output/utplsql/sonar-test-report.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/pom.xml new file mode 100644 index 0000000..c174c87 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/pom.xml @@ -0,0 +1,69 @@ + + 4.0.0 + + org.utplsql + simple + 1.0.0 + pom + + + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 + + + + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + + + test + + + false + + app + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-report.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + + + scripts/sources + + **/**.pks + **/**.pkb + + + + + + scripts/tests + + **/**.pks + **/**.pkb + + + + + + + + + + diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pkb b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pkb new file mode 100644 index 0000000..331959d --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pkb @@ -0,0 +1,27 @@ +CREATE OR REPLACE PACKAGE BODY PKG_TEST_ME IS + -- + -- This + -- + FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER IS + BEGIN + IF PPARAM1 IS NULL THEN + RETURN NULL; + ELSIF PPARAM1 = '1' THEN + RETURN 1; + ELSE + RETURN 0; + END IF; + END FC_TEST_ME; + + PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2) IS + BEGIN + IF PSNAME IS NULL THEN + NULL; + ELSE + INSERT INTO TO_TEST_ME (SNAME) VALUES (PSNAME); + COMMIT; + END IF; + END PR_TEST_ME; + +END PKG_TEST_ME; +/ diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pks b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pks new file mode 100644 index 0000000..26b2589 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/APP.PKG_TEST_ME.pks @@ -0,0 +1,8 @@ +-- +-- This package is used TO demonstrate the utPL/SQL possibilities +-- +CREATE OR REPLACE PACKAGE PKG_TEST_ME AS + FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER; + PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2); +END PKG_TEST_ME; +/ \ No newline at end of file diff --git a/src/test/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/TO_TEST_ME.sql similarity index 100% rename from src/test/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/sources/TO_TEST_ME.sql diff --git a/src/test/resources/tags-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb similarity index 100% rename from src/test/resources/tags-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pkb diff --git a/src/test/resources/tags-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/tags-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/simple/scripts/tests/APP.TEST_PKG_TEST_ME.pks diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip/pom.xml new file mode 100644 index 0000000..f9264fb --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/skip/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + + org.utplsql + skip + 1.0.0 + pom + + + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 + + + + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + + + test + + + true + + + + + + + diff --git a/src/test/resources/tags-project/expected-output/utplsql/sonar-test-reporter.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/expected-output/utplsql/sonar-test-report.xml similarity index 70% rename from src/test/resources/tags-project/expected-output/utplsql/sonar-test-reporter.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/expected-output/utplsql/sonar-test-report.xml index e8d63ee..a99f26c 100644 --- a/src/test/resources/tags-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/expected-output/utplsql/sonar-test-report.xml @@ -1,8 +1,8 @@ - + - \ No newline at end of file + diff --git a/src/test/resources/tags-project/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/pom.xml similarity index 71% rename from src/test/resources/tags-project/pom.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/pom.xml index 5974258..01150a1 100644 --- a/src/test/resources/tags-project/pom.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/pom.xml @@ -1,57 +1,52 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql - utplsql-maven-plugin-tags + tags 1.0.0 pom - utplsql-maven-plugin IT Tags - + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 - ${project.groupId} + org.utplsql utplsql-maven-plugin - ${utplsql-maven-plugin-version} + @project.version@ test - - false - app - exists cursor - UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - scripts/tests - **/*bdy - **/*spc + **/**.pks + **/**.pkb diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/scripts/tests/APP.TEST_PKG_TEST_ME.pkb b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/scripts/tests/APP.TEST_PKG_TEST_ME.pkb new file mode 100644 index 0000000..115bc15 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/scripts/tests/APP.TEST_PKG_TEST_ME.pkb @@ -0,0 +1,126 @@ +CREATE OR REPLACE PACKAGE BODY TEST_PKG_TEST_ME AS + + --------------------------------------------------------------------------- + PROCEDURE SETUP_GLOBAL IS + BEGIN + -- Put here the code which is valid for all tests and that should be + -- executed once. + NULL; + END SETUP_GLOBAL; + + --------------------------------------------------------------------------- + PROCEDURE TEARDOWN_GLOBAL IS + BEGIN + -- Put here the code that should be called only once after all the test + -- have executed + NULL; + END TEARDOWN_GLOBAL; + + --------------------------------------------------------------------------- + PROCEDURE SETUP_TEST IS + BEGIN + -- Nothing to clean up globally + NULL; + END SETUP_TEST; + + PROCEDURE TEARDOWN_TEST IS + BEGIN + -- Nothing to clean up globally + NULL; + END TEARDOWN_TEST; + + PROCEDURE TEST_FC_INPUT_1 IS + BEGIN + -- Ok this is a real test where I check that the function return 1 + -- when called with a '1' parameter + UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('1')).TO_EQUAL(1); + END; + + PROCEDURE SETUP_TEST_FC_INPUT_1 IS + BEGIN + -- Nothing to be done really + NULL; + END; + + PROCEDURE TEARDOWN_TEST_FC_INPUT_1 IS + BEGIN + -- Nothing to be done really + NULL; + END; + + PROCEDURE TEST_FC_INPUT_0 IS + BEGIN + -- Ok this is a real test where I check that the function return 0 + -- when called with a '0' parameter + UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('0')).TO_EQUAL(0); + END; + + PROCEDURE TEST_FC_INPUT_NULL IS + BEGIN + -- Ok I check that the function return NULL + -- when called with a NULL parameter + UT.EXPECT(PKG_TEST_ME.FC_TEST_ME(NULL)).TO_BE_NULL; + END TEST_FC_INPUT_NULL; + + PROCEDURE TEST_PR_TEST_ME_NULL IS + VNCOUNT1 PLS_INTEGER; + VNCOUNT2 PLS_INTEGER; + BEGIN + -- In this example I check that the procedure does + -- not insert anything when passing it a NULL parameter + SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME; + PKG_TEST_ME.PR_TEST_ME(NULL); + SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME; + UT.EXPECT(VNCOUNT1).TO_EQUAL(VNCOUNT2); + END; + + PROCEDURE TEST_PR_TEST_ME_NOT_NULL IS + VNCOUNT1 PLS_INTEGER; + VNCOUNT2 PLS_INTEGER; + VSNAME TO_TEST_ME.SNAME%TYPE; + BEGIN + -- In this test I will check that I do insert a value + -- when the parameter is not null. I futher check that + -- the procedure has inserted the value I specified. + SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME; + VSNAME := TO_CHAR(VNCOUNT1); + PKG_TEST_ME.PR_TEST_ME(VSNAME); + SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME; + + -- Check that I have inserted the value + UT.EXPECT(VNCOUNT1 + 1).TO_EQUAL(VNCOUNT2); + SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME T WHERE T.SNAME = VSNAME; + + -- Check that I inserted the one I said I would insert + UT.EXPECT(VNCOUNT2).TO_EQUAL(1); + DELETE FROM TO_TEST_ME T WHERE T.SNAME = VSNAME; + COMMIT; + END; + + PROCEDURE TEST_PR_TEST_ME_EXISTS IS + BEGIN + -- In case the value exists the procedure should fail with an exception. + BEGIN + PKG_TEST_ME.PR_TEST_ME('EXISTS'); + PKG_TEST_ME.PR_TEST_ME('EXISTS'); + EXCEPTION + WHEN OTHERS THEN + UT.FAIL('Unexpected exception raised'); + END; + END; + + PROCEDURE TEST_PR_TEST_ME_CURSOR IS + TYPE REF_CURSOR IS REF CURSOR; + VEXPECTED REF_CURSOR; + VACTUAL REF_CURSOR; + BEGIN + EXECUTE IMMEDIATE 'TRUNCATE TABLE TO_TEST_ME'; + OPEN VEXPECTED FOR + SELECT T.SNAME FROM TO_TEST_ME T; + OPEN VACTUAL FOR + SELECT T.SNAME FROM TO_TEST_ME T; + UT.EXPECT(VEXPECTED).TO_(EQUAL(VACTUAL)); + END; + +END; +/ diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/scripts/tests/APP.TEST_PKG_TEST_ME.pks b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/scripts/tests/APP.TEST_PKG_TEST_ME.pks new file mode 100644 index 0000000..8a2b852 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/tags/scripts/tests/APP.TEST_PKG_TEST_ME.pks @@ -0,0 +1,88 @@ +CREATE OR REPLACE PACKAGE TEST_PKG_TEST_ME AS + -- %suite(TEST_PKG_TEST_ME) + -- %suitepath(plsql.examples) + -- + -- This package shows all the possibilities to unit test + -- your PL/SQL package. NOTE that it is not limited to + -- testing your package. You can do that on all your + -- procedure/functions... + -- + + /** + * This two parameters are used by the test framework in + * order to identify the test suite to run + */ + + /* + * This method is invoked once before any other method. + * It should contain all the setup code that is relevant + * for all your test. It might be inserting a register, + * creating a type, etc... + */ + -- %beforeall + PROCEDURE SETUP_GLOBAL; + + /* + * This method is invoked once after all other method. + * It can be used to clean up all the resources that + * you created in your script + */ + -- %afterall + PROCEDURE TEARDOWN_GLOBAL; + + /* + * This method is called once before each test. + */ + -- %beforeeach + PROCEDURE SETUP_TEST; + + /* + * This method is called once after each test. + */ + -- %aftereach + PROCEDURE TEARDOWN_TEST; + + /** + * This is a real test. The main test can declare a setup + * and teardown method in order to setup and cleanup things + * for that specific test. + */ + -- %test + -- %displayname(Checking if function ('1') returns 1) + -- %beforetest(SETUP_TEST_FC_INPUT_1) + -- %aftertest(TEARDOWN_TEST_FC_INPUT_1) + PROCEDURE TEST_FC_INPUT_1; + PROCEDURE SETUP_TEST_FC_INPUT_1; + PROCEDURE TEARDOWN_TEST_FC_INPUT_1; + + -- %test + -- %displayname(Checking if function ('0') returns 0) + PROCEDURE TEST_FC_INPUT_0; + + -- %test + -- %displayname(Checking if function (NULL) returns NULL) + PROCEDURE TEST_FC_INPUT_NULL; + + -- %test + -- %displayname(Checking if procedure (NULL) insert) + PROCEDURE TEST_PR_TEST_ME_NULL; + + -- %test + -- %displayname(Checking if procedure (NOT NULL) insert) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_NOT_NULL; + + -- %test + -- %displayname(Checking if procedure (NOT NULL) insert while existing) + -- %rollback(manual) + -- %tags(exists) + PROCEDURE TEST_PR_TEST_ME_EXISTS; + + -- %test + -- %displayname(Demonstrating the use of cursor) + -- %rollback(manual) + -- %tags(cursor) + PROCEDURE TEST_PR_TEST_ME_CURSOR; + +END; +/ diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/expected-output/utplsql/coverage-sonar-report.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/expected-output/utplsql/coverage-sonar-report.xml new file mode 100644 index 0000000..5f0d19f --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/expected-output/utplsql/coverage-sonar-report.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/expected-output/utplsql/sonar-test-report.xml similarity index 85% rename from src/test/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/expected-output/utplsql/sonar-test-report.xml index cd174ad..d318de9 100644 --- a/src/test/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/expected-output/utplsql/sonar-test-report.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/type-mapping-project/pom.xml b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/pom.xml similarity index 80% rename from src/test/resources/type-mapping-project/pom.xml rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/pom.xml index a4d3dde..3cf0033 100644 --- a/src/test/resources/type-mapping-project/pom.xml +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/pom.xml @@ -1,32 +1,32 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql - utplsql-maven-plugin-type-mapping-test + type-mapping 1.0.0 - pom - utplsql-maven-plugin IT Type Mapping - + jdbc:oracle:thin:@localhost:1521:xe + UT3 + UT3 - ${project.groupId} + org.utplsql utplsql-maven-plugin - ${utplsql-maven-plugin-version} + @project.version@ test - + false @@ -37,12 +37,12 @@ UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true @@ -51,7 +51,9 @@ scripts/sources - **/*sql + **/**.sql + **/**.pks + **/**.pkb @@ -70,7 +72,8 @@ scripts/test - **/*sql + **/**.pks + **/**.pkb diff --git a/src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/package_bodies/PKG_TEST_ME.pkb similarity index 100% rename from src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/package_bodies/PKG_TEST_ME.pkb diff --git a/src/test/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/packages/PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/packages/PKG_TEST_ME.pks diff --git a/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/tables/TO_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/tables/TO_TEST_ME.sql new file mode 100644 index 0000000..b2e90d9 --- /dev/null +++ b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/sources/app/tables/TO_TEST_ME.sql @@ -0,0 +1,8 @@ +-- +-- This is a table used to demonstrate the UNIT test framework. +-- +CREATE TABLE TO_TEST_ME +( + SNAME VARCHAR2(10) +) +/ diff --git a/src/test/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.pkb similarity index 100% rename from src/test/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.pkb diff --git a/src/test/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql b/src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/test/app/packages/TEST_PKG_TEST_ME.pks similarity index 100% rename from src/test/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql rename to src/test/resources-its/org/utplsql/maven/plugin/UtPlsqlMojoIT/type_mapping/scripts/test/app/packages/TEST_PKG_TEST_ME.pks diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties new file mode 100644 index 0000000..f0ee14f --- /dev/null +++ b/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +junit.jupiter.displayname.generator.default=org.junit.jupiter.api.DisplayNameGenerator$ReplaceUnderscores diff --git a/src/test/resources/owner-param-project/expected-output/utplsql/coverage-sonar-reporter.xml b/src/test/resources/owner-param-project/expected-output/utplsql/coverage-sonar-reporter.xml deleted file mode 100644 index 6718aa5..0000000 --- a/src/test/resources/owner-param-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml b/src/test/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml deleted file mode 100644 index 0628e51..0000000 --- a/src/test/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml b/src/test/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml deleted file mode 100644 index 5824011..0000000 --- a/src/test/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml b/src/test/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml deleted file mode 100644 index f046682..0000000 --- a/src/test/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/unit-tests/db_config_using_system_properties/pom.xml b/src/test/resources/unit-tests/db_config_using_system_properties/pom.xml new file mode 100644 index 0000000..814c181 --- /dev/null +++ b/src/test/resources/unit-tests/db_config_using_system_properties/pom.xml @@ -0,0 +1,49 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + true + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_DOCUMENTATION_REPORTER + false + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + + + + + diff --git a/src/test/resources/defaultConsoleOutputBehaviour/pom.xml b/src/test/resources/unit-tests/dbms_output/pom.xml similarity index 59% rename from src/test/resources/defaultConsoleOutputBehaviour/pom.xml rename to src/test/resources/unit-tests/dbms_output/pom.xml index 2f23eba..4f45635 100644 --- a/src/test/resources/defaultConsoleOutputBehaviour/pom.xml +++ b/src/test/resources/unit-tests/dbms_output/pom.xml @@ -6,40 +6,30 @@ org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - - ../../../target/ - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @proj test - + true false - - :plsql + app - UT_DOCUMENTATION_REPORTER @@ -50,33 +40,14 @@ UT_COVERAGE_SONAR_REPORTER - coverage-sonar-reporter.xml + coverage-sonar-report.xml UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - - - - foo - - **/*sql - - - - - - - bar - - **/*.spc - **/*.bdy - - - diff --git a/src/test/resources/unit-tests/default_console_output_behaviour/pom.xml b/src/test/resources/unit-tests/default_console_output_behaviour/pom.xml new file mode 100644 index 0000000..ac6b14c --- /dev/null +++ b/src/test/resources/unit-tests/default_console_output_behaviour/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + + + + + diff --git a/src/test/resources/unit-tests/default_reporter/pom.xml b/src/test/resources/unit-tests/default_reporter/pom.xml new file mode 100644 index 0000000..8f03e25 --- /dev/null +++ b/src/test/resources/unit-tests/default_reporter/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + test + + + false + + app + + + + + + diff --git a/src/test/resources/unit-tests/exclude_object/pom.xml b/src/test/resources/unit-tests/exclude_object/pom.xml new file mode 100644 index 0000000..d65fde3 --- /dev/null +++ b/src/test/resources/unit-tests/exclude_object/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + app.pkg_test_me,app.test_pkg_test_me + + + + + diff --git a/src/test/resources/unit-tests/exclude_object_expr/pom.xml b/src/test/resources/unit-tests/exclude_object_expr/pom.xml new file mode 100644 index 0000000..7993e05 --- /dev/null +++ b/src/test/resources/unit-tests/exclude_object_expr/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + * + + + + + diff --git a/src/test/resources/unit-tests/exclude_schema_expr/pom.xml b/src/test/resources/unit-tests/exclude_schema_expr/pom.xml new file mode 100644 index 0000000..28df05e --- /dev/null +++ b/src/test/resources/unit-tests/exclude_schema_expr/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + * + + + + + diff --git a/src/test/resources/unit-tests/include_object/pom.xml b/src/test/resources/unit-tests/include_object/pom.xml new file mode 100644 index 0000000..f031df5 --- /dev/null +++ b/src/test/resources/unit-tests/include_object/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + app.pkg_test_me,app.test_pkg_test_me + + + + + diff --git a/src/test/resources/unit-tests/include_object_expr/pom.xml b/src/test/resources/unit-tests/include_object_expr/pom.xml new file mode 100644 index 0000000..636098b --- /dev/null +++ b/src/test/resources/unit-tests/include_object_expr/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + * + + + + + diff --git a/src/test/resources/unit-tests/include_schema_expr/pom.xml b/src/test/resources/unit-tests/include_schema_expr/pom.xml new file mode 100644 index 0000000..f953ec0 --- /dev/null +++ b/src/test/resources/unit-tests/include_schema_expr/pom.xml @@ -0,0 +1,52 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + false + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + * + + + + + diff --git a/src/test/resources/unit-tests/invalid_sources_directory/pom.xml b/src/test/resources/unit-tests/invalid_sources_directory/pom.xml new file mode 100644 index 0000000..af6643d --- /dev/null +++ b/src/test/resources/unit-tests/invalid_sources_directory/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @project.version@ + + test + + + false + + :plsql + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-report.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + + + foo + + **/*sql + + + + + + + + diff --git a/src/test/resources/invalidTestsSourcesDirectories/pom.xml b/src/test/resources/unit-tests/invalid_tests_directory/pom.xml similarity index 68% rename from src/test/resources/invalidTestsSourcesDirectories/pom.xml rename to src/test/resources/unit-tests/invalid_tests_directory/pom.xml index 5993111..c7380ef 100644 --- a/src/test/resources/invalidTestsSourcesDirectories/pom.xml +++ b/src/test/resources/unit-tests/invalid_tests_directory/pom.xml @@ -6,69 +6,47 @@ org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - - ../../../target/ - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - - false - :plsql - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - - - - foo - - **/*sql - - - - bar - **/*.spc - **/*.bdy + **/**.pks + **/**.pkb @@ -76,4 +54,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/unit-tests/ora_stuck_timeout/pom.xml b/src/test/resources/unit-tests/ora_stuck_timeout/pom.xml new file mode 100644 index 0000000..f04825c --- /dev/null +++ b/src/test/resources/unit-tests/ora_stuck_timeout/pom.xml @@ -0,0 +1,55 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-test + 3.1.0-SNAPSHOT + pom + + + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 + + + + ../../../target + + + org.utplsql + utplsql-maven-plugin + @proj + + test + + + 5 + false + + app + + + + UT_DOCUMENTATION_REPORTER + + + UT_DOCUMENTATION_REPORTER + false + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-report.xml + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-report.xml + true + + + + + + + diff --git a/src/test/resources/skipUtplsqlTests/pom.xml b/src/test/resources/unit-tests/skip_utplsql_tests/pom.xml similarity index 75% rename from src/test/resources/skipUtplsqlTests/pom.xml rename to src/test/resources/unit-tests/skip_utplsql_tests/pom.xml index 237a449..3e978d5 100644 --- a/src/test/resources/skipUtplsqlTests/pom.xml +++ b/src/test/resources/unit-tests/skip_utplsql_tests/pom.xml @@ -1,47 +1,35 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - - ../../../target/ - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - true - false - :plsql - UT_DOCUMENTATION_REPORTER @@ -52,15 +40,14 @@ UT_COVERAGE_SONAR_REPORTER - coverage-sonar-reporter.xml + coverage-sonar-report.xml UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - foo @@ -69,13 +56,12 @@ - bar - **/*.spc - **/*.bdy + **/**.pks + **/**.pkb diff --git a/src/test/resources/testNoSourcesTestsParams/directoryExists/pom.xml b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist/pom.xml similarity index 71% rename from src/test/resources/testNoSourcesTestsParams/directoryExists/pom.xml rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist/pom.xml index ba12beb..a556a7e 100644 --- a/src/test/resources/testNoSourcesTestsParams/directoryExists/pom.xml +++ b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist/pom.xml @@ -1,54 +1,43 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f - / + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - - false - :plsql - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true @@ -56,4 +45,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/pom.xml b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/pom.xml similarity index 71% rename from src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/pom.xml rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/pom.xml index 75234c4..a556a7e 100644 --- a/src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/pom.xml +++ b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/pom.xml @@ -1,55 +1,43 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - - ../../../target/ - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - - false - :plsql - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true @@ -57,4 +45,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/f1.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/main/plsql/f1.sql similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/f1.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/main/plsql/f1.sql diff --git a/src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/foo/f2.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/main/plsql/f2.sql similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/foo/f2.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/main/plsql/f2.sql diff --git a/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/f2.pkg b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/test/plsql/f2.pkg similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/f2.pkg rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/test/plsql/f2.pkg diff --git a/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.pkg b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/test/plsql/foo/f1.pkg similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.pkg rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/test/plsql/foo/f1.pkg diff --git a/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/test/plsql/foo/f1.sql similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_does_not_exist_but_default_directory_exists/src/test/plsql/foo/f1.sql diff --git a/src/test/resources/partialSourceAndTestTag/missingDirectory/pom.xml b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/pom.xml similarity index 79% rename from src/test/resources/partialSourceAndTestTag/missingDirectory/pom.xml rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/pom.xml index 06184eb..d5382b4 100644 --- a/src/test/resources/partialSourceAndTestTag/missingDirectory/pom.xml +++ b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/pom.xml @@ -1,58 +1,46 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f - / + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - - false - :plsql - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - @@ -60,12 +48,10 @@ - **/*sql - @@ -78,4 +64,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/f1.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/main/plsql/f1.sql similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/f1.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/main/plsql/f1.sql diff --git a/src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/foo/f2.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/main/plsql/foo/f2.sql similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/foo/f2.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/main/plsql/foo/f2.sql diff --git a/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/f2.pkg b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/test/plsql/f2.pkg similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/f2.pkg rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/test/plsql/f2.pkg diff --git a/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.pkg b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/test/plsql/foo/f1.pkg similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.pkg rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/test/plsql/foo/f1.pkg diff --git a/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/test/plsql/foo/f1.sql similarity index 100% rename from src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_directory_tag/src/test/plsql/foo/f1.sql diff --git a/src/test/resources/partialSourceAndTestTag/missingIncludes/pom.xml b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/pom.xml similarity index 83% rename from src/test/resources/partialSourceAndTestTag/missingIncludes/pom.xml rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/pom.xml index 3f41158..d33e917 100644 --- a/src/test/resources/partialSourceAndTestTag/missingIncludes/pom.xml +++ b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/pom.xml @@ -9,56 +9,44 @@ pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f - / + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - - false - :plsql - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - src/main/foo - src/test/bar @@ -68,4 +56,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f1.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/main/foo/f1.sql similarity index 100% rename from src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f1.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/main/foo/f1.sql diff --git a/src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f2.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/main/foo/foo/f2.sql similarity index 100% rename from src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f2.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/main/foo/foo/f2.sql diff --git a/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/f2.pkg b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/test/bar/f2.pkg similarity index 100% rename from src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/f2.pkg rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/test/bar/f2.pkg diff --git a/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.pkg b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/test/bar/foo/f1.pkg similarity index 100% rename from src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.pkg rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/test/bar/foo/f1.pkg diff --git a/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.sql b/src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/test/bar/foo/f1.sql similarity index 100% rename from src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.sql rename to src/test/resources/unit-tests/sources_and_tests_parameter_have_not_includes_tag/src/test/bar/foo/f1.sql diff --git a/src/test/resources/testSourcesTestsParams/pom.xml b/src/test/resources/unit-tests/sources_tests_parameters/pom.xml similarity index 83% rename from src/test/resources/testSourcesTestsParams/pom.xml rename to src/test/resources/unit-tests/sources_tests_parameters/pom.xml index 609a8a4..6f4c2d0 100644 --- a/src/test/resources/testSourcesTestsParams/pom.xml +++ b/src/test/resources/unit-tests/sources_tests_parameters/pom.xml @@ -1,59 +1,46 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.utplsql utplsql-maven-plugin-test 3.1.0-SNAPSHOT - pom - utplsql-maven-plugin Maven Plugin Test - - http://utplsql.org - - jdbc:oracle:thin:@180.129.3.101:1521:xe - ut3 - XNtxj8eEgA6X6b6f + jdbc:oracle:thin:@127.0.0.1:1521:xe + UT3 + UT3 - - ../../../target/ - + ../../../target org.utplsql utplsql-maven-plugin - {project.version} - + @project.version@ test - - false - :plsql - UT_COVERAGE_SONAR_REPORTER - utplsql/coverage-sonar-reporter.xml + utplsql/coverage-sonar-report.xml true UT_SONAR_TEST_REPORTER - utplsql/sonar-test-reporter.xml + utplsql/sonar-test-report.xml true - srcs @@ -62,7 +49,6 @@ - code_owner .*/\w+/(\w+)/(\w+)\.\w{3} 9 @@ -74,17 +60,15 @@ bar - te/st - **/*.spc - **/*.bdy + **/**.pks + **/**.pkb - tests_owner .*/\w+/(\w+)/(\w+)\.\w{3} 24 @@ -100,4 +84,4 @@ - \ No newline at end of file + diff --git a/src/test/resources/testSourcesTestsParams/srcs/file.bdy b/src/test/resources/unit-tests/sources_tests_parameters/srcs/file.pkb similarity index 100% rename from src/test/resources/testSourcesTestsParams/srcs/file.bdy rename to src/test/resources/unit-tests/sources_tests_parameters/srcs/file.pkb diff --git a/src/test/resources/testSourcesTestsParams/srcs/foo.sql b/src/test/resources/unit-tests/sources_tests_parameters/srcs/foo.sql similarity index 100% rename from src/test/resources/testSourcesTestsParams/srcs/foo.sql rename to src/test/resources/unit-tests/sources_tests_parameters/srcs/foo.sql diff --git a/src/test/resources/testSourcesTestsParams/srcs/spec.spc b/src/test/resources/unit-tests/sources_tests_parameters/srcs/spec.pks similarity index 100% rename from src/test/resources/testSourcesTestsParams/srcs/spec.spc rename to src/test/resources/unit-tests/sources_tests_parameters/srcs/spec.pks diff --git a/src/test/resources/testSourcesTestsParams/te/st/file.bdy b/src/test/resources/unit-tests/sources_tests_parameters/te/st/file.pkb similarity index 100% rename from src/test/resources/testSourcesTestsParams/te/st/file.bdy rename to src/test/resources/unit-tests/sources_tests_parameters/te/st/file.pkb diff --git a/src/test/resources/testSourcesTestsParams/te/st/foo.sql b/src/test/resources/unit-tests/sources_tests_parameters/te/st/foo.sql similarity index 100% rename from src/test/resources/testSourcesTestsParams/te/st/foo.sql rename to src/test/resources/unit-tests/sources_tests_parameters/te/st/foo.sql diff --git a/src/test/resources/testSourcesTestsParams/te/st/spec.spc b/src/test/resources/unit-tests/sources_tests_parameters/te/st/spec.pks similarity index 100% rename from src/test/resources/testSourcesTestsParams/te/st/spec.spc rename to src/test/resources/unit-tests/sources_tests_parameters/te/st/spec.pks