• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / jmockit1 / 85

26 Apr 2025 06:37PM UTC coverage: 73.285% (-0.02%) from 73.308%
85

push

github

web-flow
Merge pull request #327 from hazendaz/paths

Use nio more per modernizer and update more tests to junit 5

5625 of 8178 branches covered (68.78%)

Branch coverage included in aggregate %.

5 of 43 new or added lines in 14 files covered. (11.63%)

3 existing lines in 3 files now uncovered.

11885 of 15715 relevant lines covered (75.63%)

0.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/main/src/main/java/mockit/coverage/reporting/StaticFiles.java
1
/*
2
 * Copyright (c) 2006 JMockit developers
3
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
4
 */
5
package mockit.coverage.reporting;
6

7
import edu.umd.cs.findbugs.annotations.NonNull;
8

9
import java.io.BufferedInputStream;
10
import java.io.BufferedOutputStream;
11
import java.io.File;
12
import java.io.IOException;
13
import java.io.InputStream;
14
import java.io.OutputStream;
15
import java.nio.file.Files;
16
import java.nio.file.Path;
17
import java.security.CodeSource;
18

19
import mockit.internal.util.Utilities;
20

21
final class StaticFiles {
22
    @NonNull
23
    private final String outputDir;
24
    private long lastModifiedTimeOfCoverageJar;
25

26
    StaticFiles(@NonNull String outputDir) {
×
27
        this.outputDir = outputDir;
×
28
    }
×
29

30
    void copyToOutputDir(boolean withSourceFilePages) throws IOException {
31
        copyFile("index.css");
×
32
        copyFile("coverage.js");
×
33
        copyFile("logo.png");
×
34
        copyFile("package.png");
×
35
        copyFile("class.png");
×
36
        copyFile("abstractClass.png");
×
37
        copyFile("interface.png");
×
38
        copyFile("annotation.png");
×
39
        copyFile("exception.png");
×
40
        copyFile("enum.png");
×
41

42
        if (withSourceFilePages) {
×
43
            copyFile("source.css");
×
44
            copyFile("prettify.js");
×
45
        }
46
    }
×
47

48
    private void copyFile(@NonNull String fileName) throws IOException {
NEW
49
        File outputFile = Path.of(outputDir, fileName).toFile();
×
50

51
        if (outputFile.exists() && outputFile.lastModified() > getLastModifiedTimeOfCoverageJar()) {
×
52
            return;
×
53
        }
54

NEW
55
        try (OutputStream output = new BufferedOutputStream(Files.newOutputStream(outputFile.toPath()));
×
56
                InputStream input = new BufferedInputStream(StaticFiles.class.getResourceAsStream(fileName))) {
×
57
            int b;
58

59
            while ((b = input.read()) != -1) {
×
60
                output.write(b);
×
61
            }
62
        }
63
    }
×
64

65
    private long getLastModifiedTimeOfCoverageJar() {
66
        if (lastModifiedTimeOfCoverageJar == 0) {
×
67
            CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
×
68

69
            if (codeSource == null) {
×
70
                lastModifiedTimeOfCoverageJar = -1;
×
71
            } else {
72
                String pathToThisJar = Utilities.getClassFileLocationPath(codeSource);
×
NEW
73
                lastModifiedTimeOfCoverageJar = Path.of(pathToThisJar).toFile().lastModified();
×
74
            }
75
        }
76

77
        return lastModifiedTimeOfCoverageJar;
×
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc