Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ private static void generateVulnerabilityScorecards(
+ commercialAveragesTable.filename());
// Resources in a jar file have to be loaded as streams. Not directly as Files.
InputStream vulnTemplateStream =
CL.getResourceAsStream(scoreCardDir + "/commercialAveTemplate.html");
CL.getResourceAsStream(SCORECARDDIRNAME + "/commercialAveTemplate.html");
String html = IOUtils.toString(vulnTemplateStream, StandardCharsets.UTF_8);
html = html.replace("${testsuite}", BenchmarkScore.TESTSUITENAME.fullName());
html = html.replace("${version}", TESTSUITEVERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
package org.owasp.benchmarkutils.score;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -109,4 +111,16 @@ void throwsExceptionAndInformsAboutUsageOnTwoElementsArraySecondNull() {

expectUsageMessage();
}

@Test
void commercialAveTemplateResolvesViaClasspathConstant() {
String resourcePath =
BenchmarkScore.SCORECARDDIRNAME + "/commercialAveTemplate.html";
InputStream stream =
BenchmarkScore.class.getClassLoader().getResourceAsStream(resourcePath);

assertNotNull(
stream,
"commercialAveTemplate.html must be loadable via SCORECARDDIRNAME classpath lookup");
}
}