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

kit-data-manager / ro-crate-java / #480

06 Jun 2025 01:09PM UTC coverage: 90.804% (+0.09%) from 90.716%
#480

push

github

web-flow
Merge pull request #264 from kit-data-manager/development

Next Version (2.1.0 | 2.1.0-rc3)

90 of 93 new or added lines in 9 files covered. (96.77%)

3 existing lines in 1 file now uncovered.

2044 of 2251 relevant lines covered (90.8%)

0.91 hits per line

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

81.25
/src/main/java/edu/kit/datamanager/ro_crate/util/ClasspathPropertiesVersionProvider.java
1
package edu.kit.datamanager.ro_crate.util;
2

3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.net.URL;
6
import java.util.Properties;
7

8
public class ClasspathPropertiesVersionProvider implements VersionProvider {
1✔
9
    public static final String VERSION_PROPERTIES = "version.properties";
10

11
    /**
12
     * Cached version to avoid repeated file/resource reads.
13
     */
14
    private String cachedVersion = null;
1✔
15

16
    /**
17
     * Constructs a ClasspathPropertiesVersionProvider that reads the version from a properties file in the classpath.
18
     */
19
    public ClasspathPropertiesVersionProvider() {
1✔
20
        // Lazy initialization - version loaded on first access
21
    }
1✔
22

23
    @Override
24
    public String getVersion() {
25
        if (cachedVersion != null) {
1✔
NEW
26
            return cachedVersion;
×
27
        }
28

29
        URL resource = this.getClass().getResource("/" + VERSION_PROPERTIES);
1✔
30
        assert resource != null : VERSION_PROPERTIES + " not found in classpath";
1✔
31

32
        try (InputStream input = resource.openStream()) {
1✔
33
            Properties properties = new Properties();
1✔
34
            properties.load(input);
1✔
35
            String version = properties.getProperty("version");
1✔
36
            assert version != null : "Version property not found in " + VERSION_PROPERTIES;
1✔
37
            return version.trim();
1✔
NEW
38
        } catch (IOException e) {
×
NEW
39
            throw new IllegalStateException("Failed to read version from properties file", e);
×
40
        }
41
    }
42
}
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

© 2025 Coveralls, Inc