MCPcopy Index your code
hub / github.com/cloudevents/sdk-java / TestUtils

Class TestUtils

formats/xml/src/test/java/io/cloudevents/xml/TestUtils.java:28–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26import static org.assertj.core.api.Assertions.assertThat;
27
28class TestUtils {
29
30 /**
31 * Get a File forn item in the resource path.
32 *
33 * @param filename
34 * @return
35 * @throws IOException
36 */
37 static File getFile(String filename) throws IOException {
38 URL file = Thread.currentThread().getContextClassLoader().getResource(filename);
39 assertThat(file).isNotNull();
40 File dataFile = new File(file.getFile());
41 assertThat(dataFile).isNotNull();
42 return dataFile;
43 }
44
45 static Reader getReader(String filename) throws IOException {
46 File dataFile = getFile(filename);
47 return new FileReader(dataFile);
48 }
49
50 static byte[] getData(File dataFile) throws IOException {
51 return Files.readAllBytes(dataFile.toPath());
52 }
53
54 static byte[] getData(String filename) throws IOException {
55 File f = getFile(filename);
56 return getData(f);
57 }
58}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected