hooliooo
04/14/2020, 10:46 AMJohannes Zick
04/14/2020, 12:00 PMJohannes Zick
04/14/2020, 12:00 PMmain
is included in test
hooliooo
04/14/2020, 3:05 PMval t = ClassPathResource("$fileName.csv")
val u = t.inputStream
val reader = BufferedReader(u.reader())
var content: String = ""
reader.use { reader ->
content = reader.readText()
}
println(content)
<http://java.io|java.io>.FileNotFoundException: class path resource [material_surcharges.csv] cannot be opened because it does not exist
In my unit test.
I had to use:
val path = Paths.get("src", "main", "resources", "csv", "$fileName.csv")
val stream = Files.newInputStream(path)
Johannes Zick
04/14/2020, 3:31 PMgetResource("/$fileName.csv")
version? It needs the additional slash to make it an absolut path, but should work. Resources from main should be available in test. Otherwise neither your default application.yaml config file nor logging would be available.hooliooo
04/14/2020, 4:10 PMval url = javaClass.classLoader.getResource("/$fileName.csv")
yields nullJohannes Zick
04/14/2020, 4:13 PMJohannes Zick
04/14/2020, 4:25 PMsourceSets {
test {
resources {
srcDirs("src/main/resources")
}
}
}
nfrankel
04/14/2020, 4:44 PM