1
- package analyzers
1
+ package org.utbot.spring. analyzers
2
2
3
- import application .utils.FakeFileManager
4
- import application .configurators.PropertiesConfigurator
5
- import application .configurators.XmlFilesConfigurator
6
- import config.TestApplicationConfiguration
3
+ import org.utbot.spring .utils.FakeFileManager
4
+ import org.utbot.spring .configurators.PropertiesConfigurator
5
+ import org.utbot.spring .configurators.XmlFilesConfigurator
6
+ import org.utbot.spring. config.TestApplicationConfiguration
7
7
import org.springframework.boot.builder.SpringApplicationBuilder
8
- import org.springframework.context.ApplicationContextException
9
- import utils.ConfigurationManager
8
+ import org.utbot.spring.postProcessors.UtBotSpringShutdownException
9
+ import org.utbot.spring. utils.ConfigurationManager
10
10
import java.net.URL
11
11
import java.net.URLClassLoader
12
- import java.nio.file.Path
13
12
14
13
15
14
class SpringApplicationAnalyzer (
16
- private val applicationPath : String ,
15
+ private val applicationUrl : URL ,
17
16
private val configurationClassFqn : String ,
18
17
private val propertyFilesPaths : List <String >,
19
18
private val xmlConfigurationPaths : List <String >,
20
19
) {
21
20
22
- private val applicationUrl: URL
23
- get() = Path .of(applicationPath).toUri().toURL()
24
-
25
21
fun analyze () {
26
22
val fakeFileManager = FakeFileManager (propertyFilesPaths + xmlConfigurationPaths)
27
- fakeFileManager.createFakeFiles ()
23
+ fakeFileManager.createTempFiles ()
28
24
29
25
val classLoader: ClassLoader = URLClassLoader (arrayOf(applicationUrl))
30
26
val userConfigurationClass = classLoader.loadClass(configurationClassFqn)
@@ -45,10 +41,10 @@ class SpringApplicationAnalyzer(
45
41
try {
46
42
app.build()
47
43
app.run ()
48
- } catch (e: ApplicationContextException ) {
44
+ } catch (e: UtBotSpringShutdownException ) {
49
45
println (" Bean analysis finished successfully" )
50
46
}finally {
51
- fakeFileManager.deleteFakeFiles ()
47
+ fakeFileManager.deleteTempFiles ()
52
48
}
53
49
}
54
50
}
0 commit comments