Skip to content

Commit a00fe88

Browse files
committed
Merge branch 'develop'
# Conflicts: # src/test/java/org/utplsql/maven/plugin/util/StringUtilTest.java
2 parents 0638b9d + 7d9c0fb commit a00fe88

File tree

14 files changed

+410
-7
lines changed

14 files changed

+410
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Please refer to the following usage example for the parameters descriptions:
9090
<plugin>
9191
<groupId>org.utplsql</groupId>
9292
<artifactId>utplsql-maven-plugin</artifactId>
93-
<version>3.1.7</version>
93+
<version>3.1.8</version>
9494
<executions>
9595
<execution>
9696
<goals>

pom.xml

Lines changed: 6 additions & 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.7</version>
8+
<version>3.1.8</version>
99
<packaging>maven-plugin</packaging>
1010

1111
<name>utPLSQL Maven Plugin</name>
@@ -149,6 +149,11 @@
149149

150150
<build>
151151
<plugins>
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-surefire-plugin</artifactId>
155+
<version>2.22.2</version>
156+
</plugin>
152157
<plugin>
153158
<groupId>org.apache.maven.plugins</groupId>
154159
<artifactId>maven-failsafe-plugin</artifactId>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ public void execute() throws MojoExecutionException {
174174
if (isNotBlank(includeObject)) {
175175
if (includeObject.contains(",")) {
176176
String[] includes = includeObject.split(",");
177-
runner.excludeObjects(Arrays.asList(includes));
177+
runner.includeObjects(Arrays.asList(includes));
178178
} else {
179-
runner.excludeObject(includeObject);
179+
runner.includeObject(includeObject);
180180
}
181181
}
182182

src/main/java/org/utplsql/maven/plugin/util/StringUtil.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ public static boolean isNotEmpty(CharSequence cs) {
1414
}
1515

1616
public static boolean isBlank(CharSequence cs) {
17-
int strLen;
18-
if (cs != null && (strLen = cs.length()) != 0) {
19-
for (int i = 0; i < strLen; ++i) {
17+
if (cs != null && cs.length() > 0) {
18+
for (int i = 0; i < cs.length(); ++i) {
2019
if (!Character.isWhitespace(cs.charAt(i))) {
2120
return false;
2221
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,11 @@ void exclude_object(MavenExecutionResult result) {
6868

6969
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
7070
}
71+
72+
@MavenTest
73+
void include_object(MavenExecutionResult result) {
74+
assertThat(result).isSuccessful();
75+
76+
assertThatReportsAreGeneratedAsExpected(result, "sonar-test-report.xml", "coverage-sonar-report.xml");
77+
}
7178
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.utplsql.maven.plugin.util;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
7+
import static org.utplsql.maven.plugin.util.StringUtil.isBlank;
8+
import static org.utplsql.maven.plugin.util.StringUtil.isEmpty;
9+
import static org.utplsql.maven.plugin.util.StringUtil.isNotBlank;
10+
import static org.utplsql.maven.plugin.util.StringUtil.isNotEmpty;
11+
12+
class StringUtilTest {
13+
14+
@Test
15+
void isEmpty_with_empty() {
16+
assertTrue(isEmpty(""));
17+
}
18+
19+
@Test
20+
void isEmpty_with_null() {
21+
assertTrue(isEmpty(null));
22+
}
23+
24+
@Test
25+
void isEmpty_with_string() {
26+
assertFalse(isEmpty("abc"));
27+
}
28+
29+
@Test
30+
void isNotEmpty_with_string() {
31+
assertTrue(isNotEmpty("abc"));
32+
}
33+
34+
@Test
35+
void isNotEmpty_with_empty() {
36+
assertFalse(isNotEmpty(""));
37+
}
38+
39+
@Test
40+
void isNotEmpty_with_blank() {
41+
assertTrue(isNotEmpty(" "));
42+
}
43+
44+
@Test
45+
void isBlank_with_blank() {
46+
assertTrue(isBlank(" "));
47+
}
48+
49+
@Test
50+
void isBlank_with_null() {
51+
assertTrue(isBlank(null));
52+
}
53+
54+
@Test
55+
void isBlank_with_string() {
56+
assertFalse(isBlank("abc"));
57+
}
58+
59+
@Test
60+
void isBlank_with_whitespaces_before_string() {
61+
assertFalse(isBlank(" abc"));
62+
}
63+
64+
@Test
65+
void isNotBlank_with_string() {
66+
assertTrue(isNotBlank("abc"));
67+
}
68+
69+
@Test
70+
void isNotBlank_with_empty() {
71+
assertFalse(isNotBlank(""));
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<coverage version="1"><file path="package body tests_owner.test_pkg_test_me"><lineToCover lineNumber="8" covered="true"/><lineToCover lineNumber="16" covered="true"/><lineToCover lineNumber="23" covered="true"/><lineToCover lineNumber="29" covered="true"/><lineToCover lineNumber="36" covered="true"/><lineToCover lineNumber="42" covered="true"/><lineToCover lineNumber="48" covered="true"/><lineToCover lineNumber="55" covered="true"/><lineToCover lineNumber="62" covered="true"/><lineToCover lineNumber="71" covered="true"/><lineToCover lineNumber="72" covered="true"/><lineToCover lineNumber="73" covered="true"/><lineToCover lineNumber="74" covered="true"/><lineToCover lineNumber="85" covered="true"/><lineToCover lineNumber="86" covered="true"/><lineToCover lineNumber="87" covered="true"/><lineToCover lineNumber="88" covered="true"/><lineToCover lineNumber="91" covered="true"/><lineToCover lineNumber="92" covered="true"/><lineToCover lineNumber="95" covered="true"/><lineToCover lineNumber="96" covered="true"/><lineToCover lineNumber="97" covered="true"/><lineToCover lineNumber="104" covered="true"/><lineToCover lineNumber="105" covered="true"/><lineToCover lineNumber="107" covered="false"/><lineToCover lineNumber="108" covered="false"/><lineToCover lineNumber="117" covered="true"/><lineToCover lineNumber="118" covered="true"/><lineToCover lineNumber="120" covered="true"/><lineToCover lineNumber="122" covered="true"/></file></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>
Lines 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+
<includeObject>tests_owner.test_pkg_test_me</includeObject>
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)