Skip to content

Commit e49b4cd

Browse files
committed
Adds owners parameters for #5
* Adds 2 new parameters : sourcesOwner / testsOwner * Adds 1 new project sample (owner-param-project) * Refactor travis build (run tests with ut3 user) * Improve documentation
1 parent 47116e7 commit e49b4cd

File tree

16 files changed

+630
-146
lines changed

16 files changed

+630
-146
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ env:
1515
- MAVEN_HOME=/usr/local/maven
1616
- MAVEN_CFG=$HOME/.m2
1717
- DB_URL="127.0.0.1:1521:XE"
18-
- DB_USER=app
19-
- DB_PASS=app
18+
- DB_UT3_USER=ut3
19+
- DB_UT3_PASS=ut3
2020
- ORACLE_VERSION="11g-r2-xe"
2121
- DOCKER_OPTIONS="--shm-size=1g"
2222

@@ -29,14 +29,15 @@ cache:
2929
install:
3030
- bash .travis/maven_cfg.sh
3131
- bash .travis/start_db.sh
32-
- bash .travis/install_utplsql.sh
32+
- bash .travis/install_utplsql.sh $DB_UT3_USER $DB_UT3_PASS
3333
- bash .travis/install_demo_project.sh
34+
- bash .travis/install_demo_owner_project.sh
3435

3536
script:
3637
- echo "Run Unit tests"
3738
- mvn test
3839
- echo "Run Integration tests"
39-
- mvn verify -Dmaven.skip.test -DdbUser="${DB_USER}" -DdbPass="${DB_PASS}" -DdbUrl="jdbc:oracle:thin:@${DB_URL}"
40+
- mvn verify -Dmaven.skip.test -DdbUser="${DB_UT3_USER}" -DdbPass="${DB_UT3_PASS}" -DdbUrl="jdbc:oracle:thin:@${DB_URL}"
4041

4142
#before_deploy:
4243
# - bash .travis/create_release.sh

.travis/create_api_user.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
PROJECT_FILES_SRC="utplsql-maven-plugin-it/src/it/resources/owner-param-project"
5+
PROJECT_FILES="resources-owner"
6+
DB_CODE_USER=CODE_OWNER
7+
DB_TESTS_USER=TESTS_OWNER
8+
DB_PASS=pass
9+
10+
cat > demo_project.sh.tmp <<EOF
11+
sqlplus -S -L sys/oracle@//127.0.0.1:1521/xe AS SYSDBA <<SQL
12+
create user ${DB_CODE_USER} identified by ${DB_PASS} quota unlimited on USERS default tablespace USERS;
13+
grant create session, create procedure, create type, create table, create sequence, create view to ${DB_CODE_USER};
14+
15+
create user ${DB_TESTS_USER} identified by ${DB_PASS} quota unlimited on USERS default tablespace USERS;
16+
grant create session, create procedure, create type, create table, create sequence, create view, create synonym to ${DB_TESTS_USER};
17+
grant select any dictionary to ${DB_TESTS_USER};
18+
grant select any table, delete any table, drop any table to ${DB_TESTS_USER};
19+
grant execute any procedure to ${DB_TESTS_USER};
20+
exit
21+
SQL
22+
23+
cd ${PROJECT_FILES}
24+
sqlplus -S -L ${DB_CODE_USER}/${DB_PASS}@//127.0.0.1:1521/xe <<SQL
25+
whenever sqlerror exit failure rollback
26+
whenever oserror exit failure rollback
27+
28+
@scripts/sources/foo/tables/TO_TEST_ME.tab
29+
@scripts/sources/foo/packages/PKG_TEST_ME.sql
30+
@scripts/sources/foo/package_bodies/PKG_TEST_ME.sql
31+
32+
exit
33+
SQL
34+
35+
sqlplus -S -L ${DB_TESTS_USER}/${DB_PASS}@//127.0.0.1:1521/xe <<SQL
36+
whenever sqlerror exit failure rollback
37+
whenever oserror exit failure rollback
38+
39+
create synonym TO_TEST_ME for ${DB_CODE_USER}.TO_TEST_ME;
40+
create synonym PKG_TEST_ME for ${DB_CODE_USER}.PKG_TEST_ME;
41+
@scripts/test/bar/packages/TEST_PKG_TEST_ME.sql
42+
@scripts/test/bar/package_bodies/TEST_PKG_TEST_ME.sql
43+
44+
exit
45+
SQL
46+
EOF
47+
48+
docker cp ./$PROJECT_FILES_SRC $ORACLE_VERSION:/$PROJECT_FILES
49+
docker cp ./demo_project.sh.tmp $ORACLE_VERSION:/demo_project.sh
50+
docker exec $ORACLE_VERSION bash demo_project.sh

.travis/install_demo_project.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -ev
33

44
PROJECT_FILES_SRC="utplsql-maven-plugin-it/src/it/resources/simple-project"
55
PROJECT_FILES="resources"
6+
DB_USER=app
7+
DB_PASS=app
68

79
cat > demo_project.sh.tmp <<EOF
810
sqlplus -S -L sys/oracle@//127.0.0.1:1521/xe AS SYSDBA <<SQL

.travis/install_utplsql.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@ curl -L -O "https://github.com/utPLSQL/utPLSQL/releases/download/$UTPLSQL_VERSIO
1717
cat > install.sh.tmp <<EOF
1818
tar -xzf ${UTPLSQL_FILE}.tar.gz && rm ${UTPLSQL_FILE}.tar.gz
1919
cd ${UTPLSQL_FILE}/source
20-
sqlplus -S -L sys/oracle@//127.0.0.1:1521/xe AS SYSDBA @install_headless.sql ut3 ut3 users
20+
sqlplus -S -L sys/oracle@//127.0.0.1:1521/xe AS SYSDBA @install_headless.sql $1 $2 users
21+
22+
sqlplus -S -L sys/oracle@//127.0.0.1:1521/xe AS SYSDBA << SQL
23+
grant execute any procedure to $1;
24+
grant create any procedure to $1;
25+
grant execute on dbms_lob to $1;
26+
grant execute on dbms_sql to $1;
27+
grant execute on dbms_xmlgen to $1;
28+
grant execute on dbms_lock to $1;
29+
30+
31+
exit
32+
SQL
2133
EOF
2234

2335
# Copy utPLSQL files to the container and install it.
2436
docker cp ./$UTPLSQL_FILE.tar.gz $ORACLE_VERSION:/$UTPLSQL_FILE.tar.gz
2537
# docker cp ./$UTPLSQL_FILE $ORACLE_VERSION:/$UTPLSQL_FILE
2638
docker cp ./install.sh.tmp $ORACLE_VERSION:/install.sh
27-
docker cp ./create_api_user.sh $ORACLE_VERSION:/create_api_user.sh
2839

2940
# Remove temporary files.
3041
# rm $UTPLSQL_FILE.tar.gz
@@ -33,4 +44,3 @@ rm install.sh.tmp
3344

3445
# Execute the utPLSQL installation inside the container.
3546
docker exec $ORACLE_VERSION bash install.sh
36-
docker exec $ORACLE_VERSION bash create_api_user.sh

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ You have to be a fully utPLSQL environment available compatible with the Java AP
3434

3535
* `sources`
3636
* Path to project source files
37+
* `sourcesOwner`
38+
* Owner of the tested code
3739
* `sourcesRegexExpression`
3840
* utPLSQL will convert file paths into database objects using the following regular expression
3941
* `sourcesOwnerSubexpression`
@@ -47,6 +49,8 @@ You have to be a fully utPLSQL environment available compatible with the Java AP
4749

4850
* `tests`
4951
* Path to project test files
52+
* `testsOwner`
53+
* Owner of the testing code
5054
* `testsRegexExpression`
5155
* utPLSQL will convert file paths into database objects using the following regular expression
5256
* `testsOwnerSubexpression`
@@ -59,21 +63,55 @@ You have to be a fully utPLSQL environment available compatible with the Java AP
5963
* List of Custom Type Mappings
6064

6165

66+
### Comparaison with the CLI
67+
68+
| CLI short parameter | CLI long parameter | maven XML path |
69+
| --- | --- | --- |
70+
| -c | --color | |
71+
| | --failure-exit-code | |
72+
| | | ignoreFailure |
73+
| -f | --format | reporters.reporter.name |
74+
| -o | | reporters.reporter.fileOutput |
75+
| -s | | reporters.reporter.consoleOutput |
76+
| -p | --path | paths.path |
77+
| -scc | --skip-compatibility-check | skipCompatibilityCheck |
78+
| -exclude | | excludeObject |
79+
| -include | | includeObject |
80+
| | | |
81+
| -source_path | | sources.source.directory |
82+
| -owner | | sourcesOwner |
83+
| -regex_expression | | sourcesRegexExpression |
84+
| -type_mapping | | list of testsCustomTypeMapping.customTypeMapping |
85+
| -owner_subexpression | | sourcesOwnerSubexpression |
86+
| -type_subexpression | | sourcesTypeSubexpression |
87+
| -name_subexpression | | sourcesNameSubexpression |
88+
| | | |
89+
| -test_path | | tests.test.directory |
90+
| -owner | | testsOwner |
91+
| -regex_expression | | testsRegexExpression |
92+
| -type_mapping | | list of testsCustomTypeMapping.customTypeMapping |
93+
| -owner_subexpression | | testsOwnerSubexpression |
94+
| -type_subexpression | | testsTypeSubexpression |
95+
| -name_subexpression | | testsNameSubexpression |
96+
6297
### Sample of use
6398
The next snippet is a sample of declaration of the pom
6499
```xml
65100
<plugin>
66101
<groupId>org.utplsql</groupId>
67102
<artifactId>utplsql-maven-plugin</artifactId>
68-
<version>1.0.0-SNAPSHOT</version>
103+
<version>3.1.0</version>
69104
<goals>
70105
<goal>test</goal>
71106
</goals>
72107
<configuration>
73108
<dbUrl>url_of_connection</dbUrl>
74109
<dbUser>user</dbUser>
75110
<dbPass>password</dbPass>
76-
<failOnErrors>false</failOnErrors>
111+
<ignoreFailure>false</ignoreFailure>
112+
<paths>
113+
<path>schema_name</path>
114+
</paths>
77115
<reporters>
78116
<reporter>
79117
<name>UT_COVERAGE_SONAR_REPORTER</name>
@@ -115,3 +153,5 @@ More project samples are available in the src/test/resources directory :
115153
* simple-project : minimalist test project with standard project directory structure
116154
* regex-project : override project directory structure and use additional parameters (sourcesRegexExpression, testsRegexExpression, ...) to tell utPLSQL how the project files are to be mapped into database objects.
117155
* type-mapping-project : This project shows how to use regex and custom type parameters togethers.
156+
* owner-param-project : This project demonstrates how to use sourcesOwner and testsOwner parameters.
157+

0 commit comments

Comments
 (0)