aboutsummaryrefslogtreecommitdiff
path: root/app/src/test/kotlin/com/pitchedapps/frost/parsers/ParserTestHelper.kt
blob: 780504391a9dd0050235847d68d12185cead205e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.pitchedapps.frost.parsers

import com.pitchedapps.frost.Base
import java.net.URL
import java.nio.file.Paths

/**
 * Created by Allan Wang on 2017-10-06.
 */
 fun <T : Any> T.getResource(path: String): String? {
    Paths.get("src/test/resources/${path.trimStart('/')}")
    val resource: URL? = Base::class.java.classLoader.getResource(path)
    if (resource == null) {
        println("Resource at $path could not be found")
        return null
    }
    return resource.readText()
}