Skip to content

Commit def8765

Browse files
committed
Switched to JUnit 5 and started with UnitTest for writeReportAssetsTo
1 parent facc6b5 commit def8765

File tree

3 files changed

+119
-1
lines changed

3 files changed

+119
-1
lines changed

pom.xml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
17+
<junit.platform.version>1.0.3</junit.platform.version>
18+
<junit.jupiter.version>5.0.3</junit.jupiter.version>
1719
</properties>
1820

1921
<dependencies>
@@ -29,11 +31,29 @@
2931
<version>12.2.0.1</version>
3032
<scope>compile</scope>
3133
</dependency>
32-
<dependency>
34+
<!--<dependency>
3335
<groupId>junit</groupId>
3436
<artifactId>junit</artifactId>
3537
<version>4.12</version>
3638
<scope>test</scope>
39+
</dependency>-->
40+
<dependency>
41+
<groupId>org.junit.jupiter</groupId>
42+
<artifactId>junit-jupiter-api</artifactId>
43+
<version>${junit.jupiter.version}</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter-engine</artifactId>
49+
<version>${junit.jupiter.version}</version>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-migrationsupport</artifactId>
55+
<version>${junit.jupiter.version}</version>
56+
<scope>test</scope>
3757
</dependency>
3858
</dependencies>
3959

@@ -76,6 +96,13 @@
7696
<exclude>**/*IT.java</exclude>
7797
</excludes>
7898
</configuration>
99+
<dependencies>
100+
<dependency>
101+
<groupId>org.junit.platform</groupId>
102+
<artifactId>junit-platform-surefire-provider</artifactId>
103+
<version>${junit.platform.version}</version>
104+
</dependency>
105+
</dependencies>
79106
</plugin>
80107
<plugin>
81108
<groupId>org.apache.maven.plugins</groupId>
@@ -89,6 +116,13 @@
89116
</goals>
90117
</execution>
91118
</executions>
119+
<dependencies>
120+
<dependency>
121+
<groupId>org.junit.platform</groupId>
122+
<artifactId>junit-platform-surefire-provider</artifactId>
123+
<version>${junit.platform.version}</version>
124+
</dependency>
125+
</dependencies>
92126
</plugin>
93127
</plugins>
94128
</build>

src/main/java/org/utplsql/api/reporter/CoverageHTMLReporter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import org.utplsql.api.CustomTypes;
44

5+
import java.io.IOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Path;
8+
import java.nio.file.Paths;
59
import java.sql.SQLException;
610
import java.sql.SQLInput;
711
import java.sql.SQLOutput;
@@ -59,4 +63,9 @@ public void writeSQL(SQLOutput stream) throws SQLException {
5963
stream.writeString(getAssetsPath());
6064
}
6165

66+
public static void writeReportAssetsTo(Path targetDirectory) throws IOException {
67+
68+
Files.createDirectories(targetDirectory);
69+
70+
}
6271
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package org.utplsql.api.reporter;
2+
3+
import org.junit.jupiter.api.AfterAll;
4+
import org.junit.jupiter.api.Test;
5+
import static org.junit.jupiter.api.Assertions.*;
6+
7+
import java.io.File;
8+
import java.io.IOException;
9+
import java.nio.file.Files;
10+
import java.nio.file.Path;
11+
import java.nio.file.Paths;
12+
13+
public class CoverageHTMLReporterAssetTest {
14+
15+
private static final String TEST_FOLDER = "__testAssets";
16+
17+
private void testFileExists( Path filePath )
18+
{
19+
File f = new File( filePath.toUri() );
20+
21+
assertTrue(f.exists(), () -> "File " + f.toString() + " does not exist");
22+
}
23+
24+
@Test
25+
public void writeReporterAssetsTo()
26+
{
27+
try {
28+
Path targetPath = Paths.get(TEST_FOLDER);
29+
30+
// Act
31+
CoverageHTMLReporter.writeReportAssetsTo(targetPath);
32+
33+
testFileExists(targetPath.resolve(Paths.get("colorbox", "border.png")));
34+
testFileExists(targetPath.resolve(Paths.get("colorbox", "controls.png")));
35+
testFileExists(targetPath.resolve(Paths.get("colorbox", "loading.gif")));
36+
testFileExists(targetPath.resolve(Paths.get("colorbox", "loading_background.png")));
37+
38+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_0_aaaaaa_40x100.png")));
39+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_flat_75_ffffff_40x100.png")));
40+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_55_fbf9ee_1x400.png")));
41+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_65_ffffff_1x400.png")));
42+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_dadada_1x400.png")));
43+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_75_e6e6e6_1x400.png")));
44+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_glass_95_fef1ec_1x400.png")));
45+
testFileExists(targetPath.resolve(Paths.get("images", "ui-bg_highlight-soft_75_cccccc_1x100.png")));
46+
testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_2e83ff_256x240.png")));
47+
testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_222222_256x240.png")));
48+
testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_454545_256x240.png")));
49+
testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_888888_256x240.png")));
50+
testFileExists(targetPath.resolve(Paths.get("images", "ui-icons_cd0a0a_256x240.png")));
51+
52+
testFileExists(targetPath.resolve(Paths.get("application.css")));
53+
testFileExists(targetPath.resolve(Paths.get("application.js")));
54+
testFileExists(targetPath.resolve(Paths.get("favicon_green.png")));
55+
testFileExists(targetPath.resolve(Paths.get("favicon_red.png")));
56+
testFileExists(targetPath.resolve(Paths.get("favicon_yellow.png")));
57+
testFileExists(targetPath.resolve(Paths.get("loading.gif")));
58+
testFileExists(targetPath.resolve(Paths.get("magnify.png")));
59+
}
60+
catch ( IOException e )
61+
{
62+
fail(e.getMessage());
63+
}
64+
65+
}
66+
67+
@AfterAll
68+
public static void clearTestAssetsFolder() {
69+
try {
70+
Files.deleteIfExists(Paths.get(TEST_FOLDER));
71+
} catch (IOException e) {
72+
e.printStackTrace();
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)