diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..334af0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Eclipse +.classpath +.project +.settings/ + +# Intellij +.idea/ +*.iml +*.iws + +# Mac +.DS_Store + +# Bash +*.swp + +# Maven +log/ +target/ +.mvn +log.txt +**/pom.xml.versionsBackup + +# Docs +doc/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2637680 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,73 @@ +sudo: required +language: java + +services: + - docker + +jdk: + - oraclejdk8 + +addons: + sonarcloud: + organization: utplsql + token: + secure: ${SONAR_TOKEN} + +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 $DB_UT3_USER $DB_UT3_PASS + - bash .travis/install_demo_project.sh + - bash .travis/install_demo_owner_project.sh + +script: + - echo "Run Unit tests" + - mvn org.jacoco:jacoco-maven-plugin:prepare-agent test + - echo "Run Integration tests" + - mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify -Dmaven.skip.test -DdbUser="${DB_UT3_USER}" -DdbPass="${DB_UT3_PASS}" -DdbUrl="jdbc:oracle:thin:@${DB_URL}" + - mvn sonar:sonar + +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: master + tags: true + +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 new file mode 100755 index 0000000..e8c0124 --- /dev/null +++ b/.travis/deploy_release.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -ev + +VERSION=$(tr -d "/v/" <<<${TRAVIS_TAG}) +mvn org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion=${VERSION} + +cd utplsql-maven-plugin +mvn deploy -DskipTests -U -Prelease diff --git a/.travis/deploy_snapshot.sh b/.travis/deploy_snapshot.sh new file mode 100755 index 0000000..c5cbf3e --- /dev/null +++ b/.travis/deploy_snapshot.sh @@ -0,0 +1,13 @@ +#!/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} + +cd utplsql-maven-plugin +mvn deploy -DskipTests -U -Prelease diff --git a/.travis/install_demo_owner_project.sh b/.travis/install_demo_owner_project.sh new file mode 100644 index 0000000..1f39308 --- /dev/null +++ b/.travis/install_demo_owner_project.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -ev + +PROJECT_FILES_SRC="utplsql-maven-plugin-it/src/it/resources/owner-param-project" +PROJECT_FILES="resources-owner" +DB_CODE_USER=CODE_OWNER +DB_TESTS_USER=TESTS_OWNER +DB_PASS=pass + +cat > demo_project.sh.tmp < demo_project.sh.tmp < install.sh.tmp < + + + + + ossrh + + true + + + ${env.GPG_EXECUTABLE} + ${env.GPG_PASSPHRASE} + + + + + + + ossrh + ${env.SONATYPE_USERNAME} + ${env.SONATYPE_PASSWORD} + + + maven.oracle.com + ${env.ORACLE_OTN_USER} + ${env.ORACLE_OTN_PASSWORD} + + + ANY + ANY + OAM 11g + + + + + + http.protocol.allow-circular-redirects + %b,true + + + + + + + + + diff --git a/.travis/start_db.sh b/.travis/start_db.sh new file mode 100644 index 0000000..2367d64 --- /dev/null +++ b/.travis/start_db.sh @@ -0,0 +1,14 @@ +#!/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 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 b681574..76bd880 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,221 @@ +[![Build status](https://travis-ci.org/utPLSQL/utPLSQL-maven-plugin.svg?branch=develop)](https://travis-ci.org/utPLSQL/utPLSQL-maven-plugin) +[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=org.utplsql%3Autplsql-maven-plugin-parent&metric=alert_status)](https://sonarcloud.io/dashboard?id=org.utplsql%3Autplsql-maven-plugin-parent) + # utPLSQL-maven-plugin -A maven plugin for running Unit Tests with utPLSQL v3+ +* A maven plugin for running Unit Tests with utPLSQL v3+. + +### Compatibility +* This plugin is compatible with the utPLSQL Java API 3.1.0. + +### Prerequisites +* Java SE Runtime Environment 8 +* Maven Version 3.5+ +* You need to have a compatible version utPLSQL framework installed in the database. Please refer to the Java API documentation for compatibility checks. + +The plugin relies on the Java API for database operations, which has the OJDBC as a maven dependency. To be able to download the Oracle dependencies, you need to configure your access to Oracle's Maven Repository: + +http://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9010 + +Sections 6.1 and 6.5 are the more important ones, and the only ones you need if you're using the latest Maven version. + +### Usage + +Please refer to the following usage example for the parameters descriptions. + +```xml + + 4.0.0 + + org.my_org + my-artifact-name + 1.0.0 + + + + + + url_of_connection + + + user + + + password + + + + + + org.utplsql + utplsql-maven-plugin + 3.1.0 + + + + test + + + + + + + + + + + + + + schema_name + + + + + + src/test/resources/scripts/sources + + + **/*pkg + **/*pkb + + + + + + + + src/test/resources/scripts/test + + + **/*pkg + **/*pkb + + + + + + + + + false + + + + false + + + + + app.test1,app.test2 + + + + + app.test1,app.test2 + + + + + + + + + + + + + + + + + UT_COVERAGE_SONAR_REPORTER + + utplsql/coverage-sonar-reporter.xml + + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + false + + + UT_TEAMCITY_REPORTER + + + + + + code_owner + .*/\w+/(\w+)/(\w+)\.\w{3} + app + 2 + 1 + + + package body + package_bodies + + + + + + tests_owner + .*/\w+/(\w+)/(\w+)\.\w{3} + test + 2 + 1 + + + package body + package_bodies + + + + + + + + + + +``` + +More project samples are available in the src/test/resources 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. +* **type-mapping-project:** this project shows how to use regex and custom type parameters together. +* **owner-param-project:** this project demonstrates how to use sourcesOwner and testsOwner parameters. + +### Comparaison with the CLI + +| CLI short parameter | CLI long parameter | maven XML path | +| --- | --- | --- | +| -c | --color | | +| | --failure-exit-code | | +| | | ignoreFailure | +| -f | --format | reporters.reporter.name | +| -o | | reporters.reporter.fileOutput | +| -s | | reporters.reporter.consoleOutput | +| -p | --path | paths.path | +| -scc | --skip-compatibility-check | skipCompatibilityCheck | +| -exclude | | excludeObject | +| -include | | includeObject | +| | | | +| -source_path | | sources.source.directory | +| -owner | | sourcesOwner | +| -regex_expression | | sourcesRegexExpression | +| -type_mapping | | list of testsCustomTypeMapping.customTypeMapping | +| -owner_subexpression | | sourcesOwnerSubexpression | +| -type_subexpression | | sourcesTypeSubexpression | +| -name_subexpression | | sourcesNameSubexpression | +| | | | +| -test_path | | tests.test.directory | +| -owner | | testsOwner | +| -regex_expression | | testsRegexExpression | +| -type_mapping | | list of testsCustomTypeMapping.customTypeMapping | +| -owner_subexpression | | testsOwnerSubexpression | +| -type_subexpression | | testsTypeSubexpression | +| -name_subexpression | | testsNameSubexpression | diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..e96ccd5 --- /dev/null +++ b/mvnw @@ -0,0 +1,227 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100755 index 0000000..019bd74 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,143 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@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_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 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@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' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +: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 + +%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 + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/nil b/nil new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9f57100 --- /dev/null +++ b/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-parent + 3.1.0-SNAPSHOT + pom + + utplsql-maven-plugin Parent + + https://github.com/utPLSQL/utPLSQL-maven-plugin + + + UTF-8 + 3.5.0 + + + + utplsql-maven-plugin + utplsql-maven-plugin-it + + diff --git a/utplsql-maven-plugin-it/pom.xml b/utplsql-maven-plugin-it/pom.xml new file mode 100644 index 0000000..658fed4 --- /dev/null +++ b/utplsql-maven-plugin-it/pom.xml @@ -0,0 +1,135 @@ + + 4.0.0 + + + org.utplsql + utplsql-maven-plugin-parent + 3.1.0-SNAPSHOT + + utplsql-maven-plugin Integration tests + utplsql-maven-plugin-it + jar + + + UTF-8 + 1.8 + + + + + org.apache.maven + maven-model + 3.0.2 + + + commons-io + commons-io + 2.5 + + + org.apache.maven.shared + maven-verifier + 1.6 + + + junit + junit + 4.12 + test + + + + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + true + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + add-it-resource + process-resources + + add-test-resource + + + + + src/it/resources + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + add-it-source + process-resources + + add-test-source + + + + src/it/java + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.0 + + + integration-test + + integration-test + + + + verify + + verify + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/java/org/utpsql/maven/plugin/test/UtPLSQLMojoIT.java b/utplsql-maven-plugin-it/src/it/java/org/utpsql/maven/plugin/test/UtPLSQLMojoIT.java new file mode 100644 index 0000000..4978e01 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/java/org/utpsql/maven/plugin/test/UtPLSQLMojoIT.java @@ -0,0 +1,194 @@ +package org.utpsql.maven.plugin.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; + +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; + +public class UtPLSQLMojoIT { + + private static String pluginVersion = null; + + @BeforeClass + public static void setUp() throws VerificationException, IOException, XmlPullParserException { + // Read plugin pom file + MavenXpp3Reader reader = new MavenXpp3Reader(); + Model model = reader.read(new FileReader("../pom.xml")); + + File pomFile = new File("../"); + Verifier verifier = new Verifier(pomFile.getAbsolutePath()); + + // install plugin + verifier.setAutoclean(false); + verifier.addCliOption("-Dmaven.skip.test=true"); + verifier.addCliOption("-DskipITs"); + verifier.executeGoal("install"); + + pluginVersion = model.getVersion(); + } + + @Test + public void testSimpleProject() throws Exception { + + 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() throws Exception { + 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() throws Exception { + 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() throws Exception { + 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() throws Exception { + 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()); + } + } + + /** + * + * @param files + */ + 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 + .map(line -> line.replaceAll("(encoding=\"[^\"]*\")", "encoding=\"WINDOWS-1252\"")) + .map(line -> 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) { + // TODO Auto-generated catch block + e.printStackTrace(); + Assert.fail("Unexpected Exception running the test : " + e.getMessage()); + } + } + } +} diff --git a/utplsql-maven-plugin-it/src/it/resources/minimalist-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/minimalist-project/pom.xml new file mode 100644 index 0000000..2f80480 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/minimalist-project/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-minimalist-test + 1.0.0 + pom + + utplsql-maven-plugin IT Minimalist + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + + + + diff --git a/utplsql-maven-plugin-it/src/it/resources/owner-param-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/expected-output/utplsql/coverage-sonar-reporter.xml new file mode 100644 index 0000000..6718aa5 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/owner-param-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/expected-output/utplsql/sonar-test-reporter.xml new file mode 100644 index 0000000..e558e2f --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/expected-output/utplsql/sonar-test-reporter.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/owner-param-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/pom.xml new file mode 100644 index 0000000..1cf170c --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/pom.xml @@ -0,0 +1,93 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-owner-parameter-test + 1.0.0 + pom + + utplsql-maven-plugin IT Owner Parameter + + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + tests_owner + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*sql + + + + code_owner + .*/\w+/(\w+)/(\w+)\.\w{3} + 2 + 1 + + + package body + package_bodies + + + + + + scripts/test + + **/*sql + + + + tests_owner + .*/\w+/(\w+)/(\w+)\.\w{3} + 2 + 1 + + + package body + package_bodies + + + + + + + + + diff --git a/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql new file mode 100644 index 0000000..894119f --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/package_bodies/PKG_TEST_ME.sql @@ -0,0 +1,28 @@ +CREATE OR REPLACE PACKAGE BODY CODE_OWNER.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; +/ \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/packages/PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/packages/PKG_TEST_ME.sql new file mode 100644 index 0000000..959b122 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/packages/PKG_TEST_ME.sql @@ -0,0 +1,8 @@ +-- +-- This package is used TO demonstrate the utPL/SQL possibilities +-- +CREATE OR REPLACE PACKAGE CODE_OWNER.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/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/tables/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/tables/TO_TEST_ME.tab new file mode 100644 index 0000000..b2e90d9 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/sources/foo/tables/TO_TEST_ME.tab @@ -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/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql new file mode 100644 index 0000000..1b34f08 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql @@ -0,0 +1,126 @@ +CREATE OR REPLACE PACKAGE BODY TESTS_OWNER.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 CODE_OWNER.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/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/test/bar/packages/TEST_PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/test/bar/packages/TEST_PKG_TEST_ME.sql new file mode 100644 index 0000000..b0cdf54 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/owner-param-project/scripts/test/bar/packages/TEST_PKG_TEST_ME.sql @@ -0,0 +1,86 @@ +CREATE OR REPLACE PACKAGE TESTS_OWNER.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) + PROCEDURE TEST_PR_TEST_ME_EXISTS; + + -- %test + -- %displayname(Demonstrating the use of cursor) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_CURSOR; + +END; +/ diff --git a/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml new file mode 100644 index 0000000..0628e51 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml new file mode 100644 index 0000000..6e6fad7 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/regex-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/regex-project/pom.xml new file mode 100644 index 0000000..0f1a41c --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/pom.xml @@ -0,0 +1,83 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-regex-test + 1.0.0 + pom + + utplsql-maven-plugin IT regex + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + app + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*bdy + **/*spc + + + + .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)(\w+).(\w{3}) + 2 + 6 + 7 + + + + scripts/test + + **/*bdy + **/*spc + + + + .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)(\w+).(\w{3}) + 2 + 6 + 7 + + + + + + + + diff --git a/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy new file mode 100644 index 0000000..29cea5e --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy @@ -0,0 +1,28 @@ +CREATE OR REPLACE PACKAGE BODY APP.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; +/ \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc new file mode 100644 index 0000000..e23c420 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.spc @@ -0,0 +1,8 @@ +-- +-- This package is used TO demonstrate the utPL/SQL possibilities +-- +CREATE OR REPLACE PACKAGE app.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/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab new file mode 100644 index 0000000..b2e90d9 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/sources/app/tables/TO_TEST_ME.tab @@ -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/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy new file mode 100644 index 0000000..32d6b35 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy @@ -0,0 +1,126 @@ +CREATE OR REPLACE PACKAGE BODY app.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/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc new file mode 100644 index 0000000..f22deac --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.spc @@ -0,0 +1,86 @@ +CREATE OR REPLACE PACKAGE app.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) + PROCEDURE TEST_PR_TEST_ME_EXISTS; + + -- %test + -- %displayname(Demonstrating the use of cursor) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_CURSOR; + +END; +/ diff --git a/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml new file mode 100644 index 0000000..5824011 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml new file mode 100644 index 0000000..1908eac --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/simple-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/simple-project/pom.xml new file mode 100644 index 0000000..ee05b0b --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/pom.xml @@ -0,0 +1,77 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-simple-test + 1.0.0 + pom + + utplsql-maven-plugin IT Simple + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + app + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*bdy + **/*spc + + + + + + + scripts/tests + + **/*bdy + **/*spc + + + + + + + + + + + + + diff --git a/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy new file mode 100644 index 0000000..d7f60de --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy @@ -0,0 +1,28 @@ +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; +/ \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc new file mode 100644 index 0000000..26b2589 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.spc @@ -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/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/TO_TEST_ME.tab new file mode 100644 index 0000000..b2e90d9 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/sources/TO_TEST_ME.tab @@ -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/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy new file mode 100644 index 0000000..115bc15 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy @@ -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/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc new file mode 100644 index 0000000..e2c82fa --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.spc @@ -0,0 +1,86 @@ +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) + PROCEDURE TEST_PR_TEST_ME_EXISTS; + + -- %test + -- %displayname(Demonstrating the use of cursor) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_CURSOR; + +END; +/ diff --git a/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml new file mode 100644 index 0000000..f046682 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/coverage-sonar-reporter.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml new file mode 100644 index 0000000..cd174ad --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/expected-output/utplsql/sonar-test-reporter.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/pom.xml b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/pom.xml new file mode 100644 index 0000000..a4d3dde --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/pom.xml @@ -0,0 +1,93 @@ + + 4.0.0 + + org.utplsql + utplsql-maven-plugin-type-mapping-test + 1.0.0 + + pom + + utplsql-maven-plugin IT Type Mapping + + + + + + + + ${project.groupId} + utplsql-maven-plugin + ${utplsql-maven-plugin-version} + + + + test + + + + + false + + + app + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + scripts/sources + + **/*sql + + + + .*/(\w+)/(\w+)/(\w+)\.\w{3} + 1 + 3 + 2 + + + package body + package_bodies + + + + + + scripts/test + + **/*sql + + + + .*/(\w+)/(\w+)/(\w+)\.\w{3} + 1 + 3 + 2 + + + package body + package_bodies + + + + + + + + + diff --git a/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql new file mode 100644 index 0000000..29cea5e --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/package_bodies/PKG_TEST_ME.sql @@ -0,0 +1,28 @@ +CREATE OR REPLACE PACKAGE BODY APP.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; +/ \ No newline at end of file diff --git a/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql new file mode 100644 index 0000000..e23c420 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/packages/PKG_TEST_ME.sql @@ -0,0 +1,8 @@ +-- +-- This package is used TO demonstrate the utPL/SQL possibilities +-- +CREATE OR REPLACE PACKAGE app.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/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab new file mode 100644 index 0000000..b2e90d9 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/sources/app/tables/TO_TEST_ME.tab @@ -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/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql new file mode 100644 index 0000000..32d6b35 --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/package_bodies/TEST_PKG_TEST_ME.sql @@ -0,0 +1,126 @@ +CREATE OR REPLACE PACKAGE BODY app.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/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql new file mode 100644 index 0000000..f22deac --- /dev/null +++ b/utplsql-maven-plugin-it/src/it/resources/type-mapping-project/scripts/test/app/packages/TEST_PKG_TEST_ME.sql @@ -0,0 +1,86 @@ +CREATE OR REPLACE PACKAGE app.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) + PROCEDURE TEST_PR_TEST_ME_EXISTS; + + -- %test + -- %displayname(Demonstrating the use of cursor) + -- %rollback(manual) + PROCEDURE TEST_PR_TEST_ME_CURSOR; + +END; +/ diff --git a/utplsql-maven-plugin/pom.xml b/utplsql-maven-plugin/pom.xml new file mode 100644 index 0000000..b90151e --- /dev/null +++ b/utplsql-maven-plugin/pom.xml @@ -0,0 +1,247 @@ + + 4.0.0 + + + org.utplsql + utplsql-maven-plugin-parent + 3.1.0-SNAPSHOT + + + utplsql-maven-plugin + maven-plugin + + utplsql-maven-plugin Maven Plugin + A maven plugin for running Unit Tests with utPLSQL v3+. + https://github.com/utPLSQL/utPLSQL-maven-plugin + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + Vinicius Avellar Moreira + utPLSQL.org + http://utplsql.org + + + + + scm:git:https://github.com/utPLSQL/utPLSQL-maven-plugin.git + https://github.com/utPLSQL/utPLSQL-maven-plugin + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + UTF-8 + 1.8 + 1.7.4 + + + + + org.utplsql + java-api + 3.1.1 + + + + org.apache.maven + maven-core + 3.5.2 + + + + org.apache.maven + maven-model + 3.0.2 + + + + org.apache.maven + maven-plugin-api + 3.5.2 + + + + org.codehaus.plexus + plexus-utils + 3.0.8 + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.5 + provided + + + + + org.apache.maven + maven-compat + 3.5.2 + test + + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + + org.powermock + powermock-api-mockito2 + ${powermock.version} + test + + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 3.3.0 + test + + + + org.assertj + assertj-core + 3.8.0 + test + + + + junit + junit + 4.12 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.5 + + utplsql + true + + + + mojo-descriptor + + descriptor + + + + help-goal + + helpmojo + + + + + + + + + + release + + + + release + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + verify + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + utplsql-java-api + https://packagecloud.io/utplsql/utplsql-java-api/maven2 + + true + + + true + + + + + diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java new file mode 100644 index 0000000..57d4080 --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/CustomTypeMapping.java @@ -0,0 +1,59 @@ +package org.utplsql.maven.plugin; + +/** + * Bean used by Maven to populate its model. + * {@code + * + * ... + * ... + * + * } + */ +public class CustomTypeMapping { + + /** + * Object type. + */ + private String type; + + /** + * Custom mapping value. + */ + private String customMapping; + + /** + * Returns the Object type. + * + * @return The Object type + */ + public String getType() { + return type; + } + + /** + * Sets the Object type + * + * @param type the Object type + */ + public void setType(final String type) { + this.type = type; + } + + /** + * Returns the custom mapping value. + * + * @return the custom mapping value + */ + public String getCustomMapping() { + return customMapping; + } + + /** + * Sets the custom mapping value + * + * @param customMapping the custom mapping value + */ + public void setCustomMapping(final String customMapping) { + this.customMapping = customMapping; + } +} diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java new file mode 100644 index 0000000..b023f72 --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java @@ -0,0 +1,349 @@ +package org.utplsql.maven.plugin; + +import java.io.File; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +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.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; + +/** + * This class expose the {@link TestRunner} interface to Maven. + * + * @author Alberto Hernández + */ +@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(defaultValue = "${project.build.directory}", readonly = true) + protected String targetDir; + + @Parameter(defaultValue = "${maven.test.failure.ignore}") + protected boolean ignoreFailure; + + // Color in the console, bases on Maven logging configuration. + private boolean colorConsole = MessageUtils.isColorEnabled(); + + private ReporterWriter reporterWriter; + + /** + * Executes the plugin. + */ + @Override + public void execute() throws MojoExecutionException { + + getLog().debug("Java Api Version = " + JavaApiVersionInfo.getVersion()); + loadConfFromEnvironment(); + + Connection connection = null; + try { + FileMapperOptions sourceMappingOptions = buildSourcesOptions(); + FileMapperOptions testMappingOptions = buildTestsOptions(); + + connection = DriverManager.getConnection(url, user, password); + + Version utlVersion = DBHelper.getDatabaseFrameworkVersion(connection); + getLog().info("utPLSQL Version = " + utlVersion); + + List reporterList = initReporters(connection, utlVersion, ReporterFactory.createEmpty()); + + logParameters(sourceMappingOptions, testMappingOptions, reporterList); + + TestRunner runner = new TestRunner() + .addPathList(paths) + .addReporterList(reporterList) + .sourceMappingOptions(sourceMappingOptions) + .testMappingOptions(testMappingOptions) + .skipCompatibilityCheck(skipCompatibilityCheck) + .colorConsole(colorConsole) + .failOnErrors(!ignoreFailure); + + if (StringUtils.isNotBlank(excludeObject)) { + runner.excludeObject(excludeObject); + } + if (StringUtils.isNotBlank(includeObject)) { + runner.includeObject(includeObject); + } + + runner.run(connection); + + } catch (SomeTestsFailedException e) { + getLog().error(e); + throw new MojoExecutionException(e.getMessage()); + } catch (SQLException e) { + getLog().error(e); + throw new MojoExecutionException(e.getMessage(), e); + } finally { + try { + if (null != connection) { + reporterWriter.writeReporters(connection); + } + } 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); + + 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); + } +} \ No newline at end of file diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java new file mode 100644 index 0000000..a4c2ba4 --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java @@ -0,0 +1,63 @@ +package org.utplsql.maven.plugin.helper; + +import java.util.Arrays; + +import org.apache.maven.model.Resource; + +/** + * 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(Arrays.asList(includes)); + return resource; + } +} diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java new file mode 100644 index 0000000..208827f --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/ReporterDefault.java @@ -0,0 +1,32 @@ +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}. + * It further more 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 String outputFile; + + private ReporterDefault(String outputFile) { + this.outputFile = outputFile; + } + + public String getOutputFile() { + return outputFile; + } +} diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java new file mode 100644 index 0000000..07e16f9 --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/SQLScannerHelper.java @@ -0,0 +1,79 @@ +package org.utplsql.maven.plugin.helper; + +import static java.lang.String.format; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.maven.model.Resource; +import org.codehaus.plexus.util.DirectoryScanner; + +/** + * Utility to scan all resources + * + * @author Alberto Hernández + */ +public class SQLScannerHelper { + + private SQLScannerHelper() { + // NA + } + + /** + * Scans a directory looking for the matching patterns. + * + * @param baseDir the base directory + * @param resources a list of resources + * @param defaultDirectory the default search directory + * @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) { + + List founds = new ArrayList(); + + for (Resource resource : resources) { + + if (resource.getDirectory() == null) { + resource.setDirectory(defaultDirectory); + } + + if (resource.getIncludes().isEmpty()) { + resource.getIncludes().add(defaultFilePattern); + } + + DirectoryScanner scanner = buildScanner(baseDir.getPath(), resource); + scanner.scan(); + + for (String basename : scanner.getIncludedFiles()) { + founds.add(baseDir.toURI().relativize(new File(scanner.getBasedir(), basename).toURI()).getPath()); + } + + founds.addAll(Arrays.asList()); + } + + 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; + } + + throw new IllegalArgumentException(); + } +} diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java new file mode 100644 index 0000000..4f04bde --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/model/ReporterParameter.java @@ -0,0 +1,101 @@ +package org.utplsql.maven.plugin.model; + +import org.codehaus.plexus.util.StringUtils; + +/** + * Represents a reporter parameter in the pom file. + * {@code + * + * ... + * ... + * ... + * + * } + * + * @author Alberto Hernández + */ +public class ReporterParameter { + + private String name; + 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() { + return name; + } + + /** + * Sets the reporter name. + * + * @param name the reporter name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns reporter output file. + * + * @return the output file name + */ + public String getFileOutput() { + return fileOutput; + } + + /** + * 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); + } + + /** + * Sets the output file. + * + * @param fileOutput the output file name + */ + public void setFileOutput(String fileOutput) { + this.fileOutput = fileOutput; + } + + /** + * Returns the console output option. + * + * @return the console output option + */ + public Boolean getConsoleOutput() { + return consoleOutput; + } + + /** + * Returns whether the console output should be enabled or not. + * + * @return true if console output is enable, false otherwise + */ + public Boolean isConsoleOutput() { + return null != consoleOutput && consoleOutput; + } + + /** + * Sets the console output option. + * + * @param consoleOutput the console output option + */ + public void setConsoleOutput(boolean consoleOutput) { + this.consoleOutput = consoleOutput; + } +} diff --git a/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java new file mode 100644 index 0000000..bc03ab7 --- /dev/null +++ b/utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/reporter/ReporterWriter.java @@ -0,0 +1,113 @@ +package org.utplsql.maven.plugin.reporter; + +import static java.lang.String.format; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; + +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; +import org.utplsql.api.reporter.Reporter; +import org.utplsql.maven.plugin.model.ReporterParameter; + +public class ReporterWriter { + + private static final Log LOG = new SystemStreamLog(); + + private List> listReporters; + + private String outputDirectory; + + private Version databaseVersion; + + /** + * Constructor of the reporter writer. + * + * @param outputDirectory the reporter output directory + * @param databaseVersion the utPLSQL framework version + */ + public ReporterWriter(String outputDirectory, Version databaseVersion) { + this.listReporters = new ArrayList<>(); + this.outputDirectory = outputDirectory; + this.databaseVersion = databaseVersion; + + } + + /** + * Adds a new reporter to the writter. + * + * @param parameter the reporter parameter + * @param reporter the reporter Object + */ + public void addReporter(ReporterParameter parameter, Reporter reporter) { + listReporters.add(Pair.of(reporter, parameter)); + } + + /** + * Writes the reporters to the output. + * + * @param connection the database connection + */ + public void writeReporters(Connection connection) throws MojoExecutionException { + for (Pair pair : listReporters) { + writeReports(connection, pair.getLeft(), pair.getRight()); + } + } + + private void writeReports(Connection connection, Reporter reporter, ReporterParameter reporterParameter) + throws MojoExecutionException { + List printStreams = new ArrayList<>(); + FileOutputStream fout = null; + + // + try { + OutputBuffer buffer = OutputBufferProvider.getCompatibleOutputBuffer(databaseVersion, reporter, connection); + + 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()); + file.getParentFile().mkdirs(); + } + + fout = new FileOutputStream(file); + LOG.info(format("Writing report %s to %s", reporter.getTypeName(), file.getAbsolutePath())); + + // Added to the Report + printStreams.add(new PrintStream(fout)); + } + + 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())); + } + } + } + + } +} diff --git a/utplsql-maven-plugin/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java b/utplsql-maven-plugin/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java new file mode 100644 index 0000000..4c3f8f6 --- /dev/null +++ b/utplsql-maven-plugin/src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java @@ -0,0 +1,327 @@ +package org.utplsql.maven.plugin.test; + +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; + +import java.io.File; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; + +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; + +@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 create 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); + } +} diff --git a/utplsql-maven-plugin/src/test/resources/defaultConsoleOutputBehaviour/pom.xml b/utplsql-maven-plugin/src/test/resources/defaultConsoleOutputBehaviour/pom.xml new file mode 100644 index 0000000..2f23eba --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/defaultConsoleOutputBehaviour/pom.xml @@ -0,0 +1,84 @@ + + 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 + + + + + ../../../target/ + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + false + + + :plsql + + + + + UT_DOCUMENTATION_REPORTER + + + UT_DOCUMENTATION_REPORTER + false + + + UT_COVERAGE_SONAR_REPORTER + coverage-sonar-reporter.xml + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + foo + + **/*sql + + + + + + + bar + + **/*.spc + **/*.bdy + + + + + + + + diff --git a/utplsql-maven-plugin/src/test/resources/invalidTestsSourcesDirectories/pom.xml b/utplsql-maven-plugin/src/test/resources/invalidTestsSourcesDirectories/pom.xml new file mode 100644 index 0000000..5993111 --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/invalidTestsSourcesDirectories/pom.xml @@ -0,0 +1,79 @@ + + 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 + + + + + ../../../target/ + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + + false + + + :plsql + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + foo + + **/*sql + + + + + + + bar + + **/*.spc + **/*.bdy + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/pom.xml b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/pom.xml new file mode 100644 index 0000000..06184eb --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/pom.xml @@ -0,0 +1,81 @@ + + 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 + / + + + + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + + false + + + :plsql + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + + **/*sql + + + + + + + + **/*sql + + + + + + **/*.pkg + + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/f1.sql b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/f1.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/foo/f2.sql b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/main/plsql/foo/f2.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/f2.pkg b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/f2.pkg new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.pkg b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.pkg new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.sql b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingDirectory/src/test/plsql/foo/f1.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/pom.xml b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/pom.xml new file mode 100644 index 0000000..3f41158 --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/pom.xml @@ -0,0 +1,71 @@ + + 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 + / + + + + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + + false + + + :plsql + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + src/main/foo + + + + + + src/test/bar + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/f1.sql b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/f1.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/foo/f2.sql b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/main/foo/foo/f2.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/f2.pkg b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/f2.pkg new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.pkg b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.pkg new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.sql b/utplsql-maven-plugin/src/test/resources/partialSourceAndTestTag/missingIncludes/src/test/bar/foo/f1.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/pom.xml b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/pom.xml new file mode 100644 index 0000000..75234c4 --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryDoesNotExist/pom.xml @@ -0,0 +1,60 @@ + + 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 + + + + + ../../../target/ + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + + false + + + :plsql + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/pom.xml b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/pom.xml new file mode 100644 index 0000000..ba12beb --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/pom.xml @@ -0,0 +1,59 @@ + + 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 + / + + + + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + + false + + + :plsql + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f1.sql b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f1.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f2.sql b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/main/plsql/f2.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/f2.pkg b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/f2.pkg new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.pkg b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.pkg new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.sql b/utplsql-maven-plugin/src/test/resources/testNoSourcesTestsParams/directoryExists/src/test/plsql/foo/f1.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/pom.xml b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/pom.xml new file mode 100644 index 0000000..609a8a4 --- /dev/null +++ b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/pom.xml @@ -0,0 +1,103 @@ + + 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 + + + + + ../../../target/ + + + + org.utplsql + utplsql-maven-plugin + {project.version} + + + test + + + + + false + + + :plsql + + + + + UT_COVERAGE_SONAR_REPORTER + utplsql/coverage-sonar-reporter.xml + true + + + UT_SONAR_TEST_REPORTER + utplsql/sonar-test-reporter.xml + true + + + + + + srcs + + **/*sql + + + + + code_owner + .*/\w+/(\w+)/(\w+)\.\w{3} + 9 + 1 + 4 + + + foo + bar + + + + + + te/st + + **/*.spc + **/*.bdy + + + + + tests_owner + .*/\w+/(\w+)/(\w+)\.\w{3} + 24 + 54 + 21 + + + abc + def + + + + + + + \ No newline at end of file diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/srcs/file.bdy b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/srcs/file.bdy new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/srcs/foo.sql b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/srcs/foo.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/srcs/spec.spc b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/srcs/spec.spc new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/te/st/file.bdy b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/te/st/file.bdy new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/te/st/foo.sql b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/te/st/foo.sql new file mode 100644 index 0000000..e69de29 diff --git a/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/te/st/spec.spc b/utplsql-maven-plugin/src/test/resources/testSourcesTestsParams/te/st/spec.spc new file mode 100644 index 0000000..e69de29