Skip to content

Commit dc90d9f

Browse files
committed
For dynamically created Spring resources replace "classpath:" resource-loading prefix with "file:"
1 parent d26e3d4 commit dc90d9f

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/utils/ConfigurationManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class ConfigurationManager(private val classLoader: ClassLoader, private val use
1414
fun clearImportResourceAnnotation() = patchAnnotation(ImportResource::class, null)
1515

1616
fun patchPropertySourceAnnotation(userPropertiesFileName: Path) =
17-
patchAnnotation(PropertySource::class, String.format("classpath:%s", "fake_$userPropertiesFileName"))
17+
patchAnnotation(PropertySource::class, String.format("file:%s", "fake_$userPropertiesFileName"))
1818

1919
fun patchImportResourceAnnotation(userXmlFilePath: Path) =
20-
patchAnnotation(ImportResource::class, String.format("classpath:%s", "fake_$userXmlFilePath"))
20+
patchAnnotation(ImportResource::class, String.format("file:%s", "fake_$userXmlFilePath"))
2121

2222
private fun patchAnnotation(annotationClass: KClass<*>, newValue: String?) {
2323
val proxyClass = classLoader.loadClass("java.lang.reflect.Proxy")
@@ -53,4 +53,4 @@ class ConfigurationManager(private val classLoader: ClassLoader, private val use
5353
memberValues["value"] = list.toTypedArray()
5454
}
5555
}
56-
}
56+
}

utbot-spring-analyzer/src/main/kotlin/org/utbot/spring/utils/PathsUtils.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,5 @@ import kotlin.io.path.Path
66
object PathsUtils {
77
const val EMPTY_PATH = ""
88

9-
fun createFakeFilePath(fileName: String): String =
10-
Path(buildResourcesPath, "fake_${Path(fileName).fileName}").toString()
11-
12-
private val buildResourcesPath: String
13-
get() {
14-
val resourcesMarker =
15-
this.javaClass.classLoader.getResource("resources_marker.txt")
16-
?: error("Resources marker file is not found")
17-
18-
return Path(File(resourcesMarker.toURI()).path).parent.toString()
19-
}
20-
21-
}
9+
fun createFakeFilePath(fileName: String): String = "fake_${Path(fileName).fileName}"
10+
}

utbot-spring-analyzer/src/main/resources/resources_marker.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)