Skip to content

Commit 7c82511

Browse files
committed
Replaced VerifierIT with UtPlsqlMojoIT that uses maven-it-extension
1 parent 4d0b557 commit 7c82511

File tree

43 files changed

+227
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+227
-254
lines changed

pom.xml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,23 @@
5555
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5656
<maven.version>3.5.2</maven.version>
5757
<jaxb.version>2.3.1</jaxb.version>
58-
<powermock.version>2.0.9</powermock.version>
58+
<itf.version>0.11.0</itf.version>
5959
<sonar.organization>utplsql</sonar.organization>
6060
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
6161
</properties>
6262

63+
<dependencyManagement>
64+
<dependencies>
65+
<dependency>
66+
<groupId>org.junit</groupId>
67+
<artifactId>junit-bom</artifactId>
68+
<version>5.8.1</version>
69+
<type>pom</type>
70+
<scope>import</scope>
71+
</dependency>
72+
</dependencies>
73+
</dependencyManagement>
74+
6375
<dependencies>
6476
<dependency>
6577
<groupId>com.sun.xml.bind</groupId>
@@ -130,10 +142,22 @@
130142
<version>3.3.0</version>
131143
<scope>test</scope>
132144
</dependency>
145+
146+
<dependency>
147+
<groupId>org.junit.jupiter</groupId>
148+
<artifactId>junit-jupiter-engine</artifactId>
149+
<scope>test</scope>
150+
</dependency>
151+
<dependency>
152+
<groupId>com.soebes.itf.jupiter.extension</groupId>
153+
<artifactId>itf-jupiter-extension</artifactId>
154+
<version>${itf.version}</version>
155+
<scope>test</scope>
156+
</dependency>
133157
<dependency>
134-
<groupId>org.apache.maven.shared</groupId>
135-
<artifactId>maven-verifier</artifactId>
136-
<version>1.6</version>
158+
<groupId>com.soebes.itf.jupiter.extension</groupId>
159+
<artifactId>itf-assertj</artifactId>
160+
<version>${itf.version}</version>
137161
<scope>test</scope>
138162
</dependency>
139163

@@ -173,6 +197,21 @@
173197
</execution>
174198
</executions>
175199
</plugin>
200+
<plugin>
201+
<groupId>com.soebes.itf.jupiter.extension</groupId>
202+
<artifactId>itf-maven-plugin</artifactId>
203+
<version>${itf.version}</version>
204+
<executions>
205+
<execution>
206+
<id>installing</id>
207+
<phase>pre-integration-test</phase>
208+
<goals>
209+
<goal>install</goal>
210+
<goal>resources-its</goal>
211+
</goals>
212+
</execution>
213+
</executions>
214+
</plugin>
176215
<plugin>
177216
<groupId>org.apache.maven.plugins</groupId>
178217
<artifactId>maven-shade-plugin</artifactId>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.utplsql.maven.plugin;
2+
3+
import org.apache.commons.io.FileUtils;
4+
import org.junit.jupiter.api.Assertions;
5+
6+
import java.io.File;
7+
import java.io.IOException;
8+
import java.nio.file.Files;
9+
import java.util.stream.Collectors;
10+
import java.util.stream.Stream;
11+
12+
import static org.junit.jupiter.api.Assertions.assertTrue;
13+
14+
public class ReportChecker {
15+
16+
private ReportChecker() {
17+
}
18+
19+
/**
20+
* Duration is set to 1 before comparing contents as it is always different.
21+
* Path separator is set to "/" to ensure windows / linux / mac compatibility.
22+
* \r and \n are removed to provide simpler comparison.
23+
*
24+
* @param testClass Class under test
25+
* @param testFolder Folder name
26+
* @param files Files to compare
27+
*/
28+
public static void checkReports(Class<?> testClass, String testFolder, String... files) throws IOException {
29+
String fullyQualifiedClassNameDirectory = testClass.getName().replace(".", "/");
30+
31+
for (String filename : files) {
32+
File expectedOutputFile = new File("target/maven-it/" + fullyQualifiedClassNameDirectory + "/" + testFolder + "/project/expected-output/utplsql", filename);
33+
File outputFile = new File("target/maven-it/" + fullyQualifiedClassNameDirectory + "/" + testFolder + "/project/target/utplsql", filename);
34+
assertTrue(outputFile.exists(), "The report " + outputFile.getPath() + " was not generated");
35+
36+
try (Stream<String> stream = Files.lines(outputFile.toPath())) {
37+
String outputContent = stream
38+
.filter(line -> !line.contains("<?xml"))
39+
.map(line -> line.replaceAll("(duration=\"[0-9.]*\")", "duration=\"1\""))
40+
.map(line -> line.replaceAll("\\\\", "/"))
41+
.map(line -> line.replaceAll("\r", "").replaceAll("\n", ""))
42+
.collect(Collectors.joining("\n"));
43+
44+
Assertions.assertEquals(
45+
FileUtils.readFileToString(expectedOutputFile, "utf-8")
46+
.replace("\r", "")
47+
.replace("\n", ""),
48+
outputContent.replace("\n", ""), "The files differ!");
49+
}
50+
}
51+
}
52+
53+
/**
54+
* Check if a report file exits
55+
*
56+
* @param testClass Class under test
57+
* @param testFolder Folder name
58+
* @param filename File Name
59+
* @return true or false
60+
*/
61+
public static boolean reportExists(Class<?> testClass, String testFolder, String filename) {
62+
String fullyQualifiedClassNameDirectory = testClass.getName().replace(".", "/");
63+
64+
File outputFile = new File("target/maven-it/" + fullyQualifiedClassNameDirectory + "/" + testFolder + "/project/target/utplsql", filename);
65+
return outputFile.exists();
66+
}
67+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.utplsql.maven.plugin;
2+
3+
import com.soebes.itf.jupiter.extension.MavenJupiterExtension;
4+
import com.soebes.itf.jupiter.extension.MavenTest;
5+
import com.soebes.itf.jupiter.maven.MavenExecutionResult;
6+
7+
import java.io.IOException;
8+
9+
import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;
10+
import static org.junit.jupiter.api.Assertions.assertFalse;
11+
import static org.utplsql.maven.plugin.ReportChecker.checkReports;
12+
import static org.utplsql.maven.plugin.ReportChecker.reportExists;
13+
14+
@MavenJupiterExtension
15+
public class UtPlsqlMojoIT {
16+
17+
@MavenTest
18+
void minimalist(MavenExecutionResult result) {
19+
assertThat(result).isSuccessful();
20+
}
21+
22+
@MavenTest
23+
void owner_param(MavenExecutionResult result) throws IOException {
24+
assertThat(result).isSuccessful();
25+
26+
checkReports(this.getClass(), "owner_param", "sonar-test-report.xml", "coverage-sonar-report.xml");
27+
}
28+
29+
@MavenTest
30+
void regex(MavenExecutionResult result) throws IOException {
31+
assertThat(result).isSuccessful();
32+
33+
checkReports(this.getClass(), "regex", "sonar-test-report.xml", "coverage-sonar-report.xml");
34+
}
35+
36+
@MavenTest
37+
void simple(MavenExecutionResult result) throws IOException {
38+
assertThat(result).isSuccessful();
39+
40+
checkReports(this.getClass(), "simple", "sonar-test-report.xml", "coverage-sonar-report.xml");
41+
}
42+
43+
@MavenTest
44+
void skip(MavenExecutionResult result) throws IOException {
45+
assertThat(result).isSuccessful();
46+
47+
assertFalse(reportExists(this.getClass(), "skip", "sonar-test-report.xml"));
48+
}
49+
50+
@MavenTest
51+
void tags(MavenExecutionResult result) throws IOException {
52+
assertThat(result).isSuccessful();
53+
54+
checkReports(this.getClass(), "tags", "sonar-test-report.xml");
55+
}
56+
57+
@MavenTest
58+
void type_mapping(MavenExecutionResult result) throws IOException {
59+
assertThat(result).isSuccessful();
60+
61+
checkReports(this.getClass(), "type_mapping", "sonar-test-report.xml", "coverage-sonar-report.xml");
62+
}
63+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import org.apache.maven.plugin.MojoExecutionException;
44
import org.apache.maven.project.MavenProject;
5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66
import org.utplsql.api.reporter.CoreReporters;
77
import org.utplsql.maven.plugin.model.ReporterParameter;
88

99
import java.io.ByteArrayOutputStream;
1010
import java.io.File;
1111
import java.io.PrintStream;
1212

13-
import static org.junit.Assert.assertTrue;
13+
import static org.junit.jupiter.api.Assertions.assertTrue;
1414

1515
public class UtPlsqlMojoTest {
1616

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

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)