Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 87b6710

Browse filesBrowse files
committed
Merge branch 'develop'
# Conflicts: # README.md
2 parents adbb375 + c2f33ad commit 87b6710
Copy full SHA for 87b6710

File tree

17 files changed

+365
-12
lines changed
Filter options

17 files changed

+365
-12
lines changed

‎.github/workflows/build.yml

Copy file name to clipboardExpand all lines: .github/workflows/build.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
services:
1717
oracle:
18-
image: gvenzl/oracle-xe:18.4.0-slim
18+
image: gvenzl/oracle-xe:21-slim
1919
env:
2020
ORACLE_PASSWORD: oracle
2121
ports:

‎.github/workflows/release.yml

Copy file name to clipboardExpand all lines: .github/workflows/release.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
services:
1313
oracle:
14-
image: gvenzl/oracle-xe:18.4.0-slim
14+
image: gvenzl/oracle-xe:21-slim
1515
env:
1616
ORACLE_PASSWORD: oracle
1717
ports:

‎README.md

Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Please refer to the following usage example for the parameters descriptions:
100100
<!-- REQUIRED PARAMETERS -->
101101

102102
<!-- A list of tests suite paths. -->
103+
103104
<!-- The path(s) can be in one of the following formats: -->
104105
<!-- schema[.package[.procedure]] -->
105106
<!-- schema:suite[.suite[.suite][...]][.procedure] -->

‎pom.xml

Copy file name to clipboardExpand all lines: pom.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.utplsql</groupId>
77
<artifactId>utplsql-maven-plugin</artifactId>
8-
<version>3.1.6</version>
8+
<version>3.1.7</version>
99
<packaging>maven-plugin</packaging>
1010

1111
<name>utPLSQL Maven Plugin</name>

‎scripts/0_start_db.sh

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docker run -d --name ora-utplsql -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-xe:18.4.0-slim
1+
docker run -d --name ora-utplsql -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-xe:21-slim

‎src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java

Copy file name to clipboardExpand all lines: src/main/java/org/utplsql/maven/plugin/UtPlsqlMojo.java
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.sql.Connection;
3131
import java.sql.SQLException;
3232
import java.util.ArrayList;
33+
import java.util.Arrays;
3334
import java.util.Collections;
3435
import java.util.LinkedHashSet;
3536
import java.util.List;
@@ -162,10 +163,21 @@ public void execute() throws MojoExecutionException {
162163
.failOnErrors(!ignoreFailure);
163164

164165
if (isNotBlank(excludeObject)) {
165-
runner.excludeObject(excludeObject);
166+
if (excludeObject.contains(",")) {
167+
String[] excludes = excludeObject.split(",");
168+
runner.excludeObjects(Arrays.asList(excludes));
169+
} else {
170+
runner.excludeObject(excludeObject);
171+
}
172+
166173
}
167174
if (isNotBlank(includeObject)) {
168-
runner.includeObject(includeObject);
175+
if (includeObject.contains(",")) {
176+
String[] includes = includeObject.split(",");
177+
runner.excludeObjects(Arrays.asList(includes));
178+
} else {
179+
runner.excludeObject(includeObject);
180+
}
169181
}
170182

171183
runner.run(connection);

‎src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java

Copy file name to clipboardExpand all lines: src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoIT.java
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ void type_mapping(MavenExecutionResult result) {
6161

6262
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
6363
}
64+
65+
@MavenTest
66+
void exclude_object(MavenExecutionResult result) {
67+
assertThat(result).isSuccessful();
68+
69+
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
70+
}
6471
}

‎src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/utplsql/maven/plugin/UtPlsqlMojoTest.java
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,13 @@ public void db_config_using_system_properties() throws Exception {
313313
* Then : System Properties must be used to configure database
314314
*/
315315
@Test
316-
public void include_and_exclude_objects() throws Exception {
317-
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("include_and_exclude_objects");
316+
public void exclude_object() throws Exception {
317+
UtPlsqlMojo utPlsqlMojo = createUtPlsqlMojo("exclude_object");
318318
assertNotNull(utPlsqlMojo);
319319

320320
utPlsqlMojo.execute();
321321

322-
assertEquals("abc", utPlsqlMojo.includeObject);
323-
assertEquals("xyz", utPlsqlMojo.excludeObject);
322+
assertEquals("app.pkg_test_me,app.test_pkg_test_me", utPlsqlMojo.excludeObject);
324323
}
325324

326325
private UtPlsqlMojo createUtPlsqlMojo(String directory) throws Exception {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<coverage version="1">
2+
</coverage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<testExecutions version="1">
2+
<file path="plsql.examples.test_pkg_test_me">
3+
<testCase name="test_fc_input_1" duration="1" ></testCase>
4+
<testCase name="test_fc_input_0" duration="1" ></testCase>
5+
<testCase name="test_fc_input_null" duration="1" ></testCase>
6+
<testCase name="test_pr_test_me_null" duration="1" ></testCase>
7+
<testCase name="test_pr_test_me_not_null" duration="1" ></testCase>
8+
<testCase name="test_pr_test_me_exists" duration="1" ></testCase>
9+
<testCase name="test_pr_test_me_cursor" duration="1" ></testCase>
10+
</file>
11+
</testExecutions>
+52Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.utplsql</groupId>
7+
<artifactId>owner-param</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>pom</packaging>
10+
11+
<properties>
12+
<dbUrl>jdbc:oracle:thin:@localhost:1521:xe</dbUrl>
13+
<dbUser>UT3</dbUser>
14+
<dbPass>UT3</dbPass>
15+
</properties>
16+
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.utplsql</groupId>
21+
<artifactId>utplsql-maven-plugin</artifactId>
22+
<version>@project.version@</version>
23+
<executions>
24+
<execution>
25+
<goals>
26+
<goal>test</goal>
27+
</goals>
28+
<configuration>
29+
<ignoreFailure>false</ignoreFailure>
30+
<paths>
31+
<path>TESTS_OWNER</path>
32+
</paths>
33+
<reporters>
34+
<reporter>
35+
<name>UT_COVERAGE_SONAR_REPORTER</name>
36+
<fileOutput>utplsql/coverage-sonar-report.xml</fileOutput>
37+
<consoleOutput>true</consoleOutput>
38+
</reporter>
39+
<reporter>
40+
<name>UT_SONAR_TEST_REPORTER</name>
41+
<fileOutput>utplsql/sonar-test-report.xml</fileOutput>
42+
<consoleOutput>true</consoleOutput>
43+
</reporter>
44+
</reporters>
45+
<excludeObject>tests_owner.test_pkg_test_me</excludeObject>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE OR REPLACE PACKAGE BODY CODE_OWNER.PKG_TEST_ME IS
2+
--
3+
-- This
4+
--
5+
FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER IS
6+
BEGIN
7+
IF PPARAM1 IS NULL THEN
8+
RETURN NULL;
9+
ELSIF PPARAM1 = '1' THEN
10+
RETURN 1;
11+
ELSE
12+
RETURN 0;
13+
END IF;
14+
END FC_TEST_ME;
15+
16+
PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2) IS
17+
BEGIN
18+
IF PSNAME IS NULL THEN
19+
NULL;
20+
ELSE
21+
INSERT INTO TO_TEST_ME (SNAME) VALUES (PSNAME);
22+
COMMIT;
23+
END IF;
24+
END PR_TEST_ME;
25+
26+
END PKG_TEST_ME;
27+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--
2+
-- This package is used TO demonstrate the utPL/SQL possibilities
3+
--
4+
CREATE OR REPLACE PACKAGE CODE_OWNER.PKG_TEST_ME AS
5+
FUNCTION FC_TEST_ME(PPARAM1 IN VARCHAR2) RETURN NUMBER;
6+
PROCEDURE PR_TEST_ME(PSNAME IN VARCHAR2);
7+
END PKG_TEST_ME;
8+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--
2+
-- This is a table used to demonstrate the UNIT test framework.
3+
--
4+
CREATE TABLE TO_TEST_ME
5+
(
6+
SNAME VARCHAR2(10)
7+
)
8+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
CREATE OR REPLACE PACKAGE BODY TESTS_OWNER.TEST_PKG_TEST_ME AS
2+
3+
---------------------------------------------------------------------------
4+
PROCEDURE SETUP_GLOBAL IS
5+
BEGIN
6+
-- Put here the code which is valid for all tests and that should be
7+
-- executed once.
8+
NULL;
9+
END SETUP_GLOBAL;
10+
11+
---------------------------------------------------------------------------
12+
PROCEDURE TEARDOWN_GLOBAL IS
13+
BEGIN
14+
-- Put here the code that should be called only once after all the test
15+
-- have executed
16+
NULL;
17+
END TEARDOWN_GLOBAL;
18+
19+
---------------------------------------------------------------------------
20+
PROCEDURE SETUP_TEST IS
21+
BEGIN
22+
-- Nothing to clean up globally
23+
NULL;
24+
END SETUP_TEST;
25+
26+
PROCEDURE TEARDOWN_TEST IS
27+
BEGIN
28+
-- Nothing to clean up globally
29+
NULL;
30+
END TEARDOWN_TEST;
31+
32+
PROCEDURE TEST_FC_INPUT_1 IS
33+
BEGIN
34+
-- Ok this is a real test where I check that the function return 1
35+
-- when called with a '1' parameter
36+
UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('1')).TO_EQUAL(1);
37+
END;
38+
39+
PROCEDURE SETUP_TEST_FC_INPUT_1 IS
40+
BEGIN
41+
-- Nothing to be done really
42+
NULL;
43+
END;
44+
45+
PROCEDURE TEARDOWN_TEST_FC_INPUT_1 IS
46+
BEGIN
47+
-- Nothing to be done really
48+
NULL;
49+
END;
50+
51+
PROCEDURE TEST_FC_INPUT_0 IS
52+
BEGIN
53+
-- Ok this is a real test where I check that the function return 0
54+
-- when called with a '0' parameter
55+
UT.EXPECT(PKG_TEST_ME.FC_TEST_ME('0')).TO_EQUAL(0);
56+
END;
57+
58+
PROCEDURE TEST_FC_INPUT_NULL IS
59+
BEGIN
60+
-- Ok I check that the function return NULL
61+
-- when called with a NULL parameter
62+
UT.EXPECT(PKG_TEST_ME.FC_TEST_ME(NULL)).TO_BE_NULL;
63+
END TEST_FC_INPUT_NULL;
64+
65+
PROCEDURE TEST_PR_TEST_ME_NULL IS
66+
VNCOUNT1 PLS_INTEGER;
67+
VNCOUNT2 PLS_INTEGER;
68+
BEGIN
69+
-- In this example I check that the procedure does
70+
-- not insert anything when passing it a NULL parameter
71+
SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME;
72+
PKG_TEST_ME.PR_TEST_ME(NULL);
73+
SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME;
74+
UT.EXPECT(VNCOUNT1).TO_EQUAL(VNCOUNT2);
75+
END;
76+
77+
PROCEDURE TEST_PR_TEST_ME_NOT_NULL IS
78+
VNCOUNT1 PLS_INTEGER;
79+
VNCOUNT2 PLS_INTEGER;
80+
VSNAME TO_TEST_ME.SNAME%TYPE;
81+
BEGIN
82+
-- In this test I will check that I do insert a value
83+
-- when the parameter is not null. I futher check that
84+
-- the procedure has inserted the value I specified.
85+
SELECT COUNT(1) INTO VNCOUNT1 FROM TO_TEST_ME;
86+
VSNAME := TO_CHAR(VNCOUNT1);
87+
PKG_TEST_ME.PR_TEST_ME(VSNAME);
88+
SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME;
89+
90+
-- Check that I have inserted the value
91+
UT.EXPECT(VNCOUNT1 + 1).TO_EQUAL(VNCOUNT2);
92+
SELECT COUNT(1) INTO VNCOUNT2 FROM TO_TEST_ME T WHERE T.SNAME = VSNAME;
93+
94+
-- Check that I inserted the one I said I would insert
95+
UT.EXPECT(VNCOUNT2).TO_EQUAL(1);
96+
DELETE FROM TO_TEST_ME T WHERE T.SNAME = VSNAME;
97+
COMMIT;
98+
END;
99+
100+
PROCEDURE TEST_PR_TEST_ME_EXISTS IS
101+
BEGIN
102+
-- In case the value exists the procedure should fail with an exception.
103+
BEGIN
104+
PKG_TEST_ME.PR_TEST_ME('EXISTS');
105+
PKG_TEST_ME.PR_TEST_ME('EXISTS');
106+
EXCEPTION
107+
WHEN OTHERS THEN
108+
UT.FAIL('Unexpected exception raised');
109+
END;
110+
END;
111+
112+
PROCEDURE TEST_PR_TEST_ME_CURSOR IS
113+
TYPE REF_CURSOR IS REF CURSOR;
114+
VEXPECTED REF_CURSOR;
115+
VACTUAL REF_CURSOR;
116+
BEGIN
117+
EXECUTE IMMEDIATE 'TRUNCATE TABLE CODE_OWNER.TO_TEST_ME';
118+
OPEN VEXPECTED FOR
119+
SELECT T.SNAME FROM TO_TEST_ME T;
120+
OPEN VACTUAL FOR
121+
SELECT T.SNAME FROM TO_TEST_ME T;
122+
UT.EXPECT(VEXPECTED).TO_(EQUAL(VACTUAL));
123+
END;
124+
125+
END;
126+
/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.