mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Remove multi config runApplication extension
Closes gh-10511
This commit is contained in:
parent
944216e11f
commit
e28b98c59d
@ -42,16 +42,3 @@ inline fun <reified T : Any> runApplication(vararg args: String): ConfigurableAp
|
||||
*/
|
||||
inline fun <reified T : Any> runApplication(vararg args: String, init: SpringApplication.() -> Unit): ConfigurableApplicationContext =
|
||||
SpringApplication(T::class.java).apply(init).run(*args)
|
||||
|
||||
|
||||
/**
|
||||
* Top level function acting as a Kotlin shortcut allowing to write
|
||||
* `runApplication(arrayOf(FooApplication::class, FooConfiguration::class), arg1, arg2) { // Optional SpringApplication customization ... }`
|
||||
* instead of instantiating `SpringApplication` class, customize it and then invoking
|
||||
* `run(arrayOf(arg1, arg2))`.`
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 2.0.0
|
||||
*/
|
||||
fun runApplication(primarySources: Array<KClass<*>>, vararg args: String, init: SpringApplication.() -> Unit = {}): ConfigurableApplicationContext =
|
||||
SpringApplication(*primarySources.map { it.java }.toTypedArray()).apply(init).run(*args)
|
||||
|
@ -70,42 +70,6 @@ class SpringApplicationExtensionsTests {
|
||||
assertEquals(environment, context.environment)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Kotlin runApplication(array of KClass) top level function`() {
|
||||
val context = runApplication(arrayOf(ExampleConfig::class, ExampleWebConfig::class))
|
||||
assertNotNull(context)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Kotlin runApplication(array of KClass) top level function with a custom environment`() {
|
||||
val environment = StandardEnvironment()
|
||||
val context = runApplication(arrayOf(ExampleConfig::class, ExampleWebConfig::class)) {
|
||||
setEnvironment(environment)
|
||||
}
|
||||
assertNotNull(context)
|
||||
assertEquals(environment, context.environment)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Kotlin runApplication(array of KClass, arg1, arg2) top level function`() {
|
||||
val context = runApplication(arrayOf(ExampleConfig::class, ExampleWebConfig::class), "--debug", "spring", "boot")
|
||||
val args = context.getBean<ApplicationArguments>()
|
||||
assertArrayEquals(arrayOf("spring", "boot"), args.nonOptionArgs.toTypedArray())
|
||||
assertTrue(args.containsOption("debug"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Kotlin runApplication(array of KClass, arg1, arg2) top level function with a custom environment`() {
|
||||
val environment = StandardEnvironment()
|
||||
val context = runApplication(arrayOf(ExampleConfig::class, ExampleWebConfig::class), "--debug", "spring", "boot") {
|
||||
setEnvironment(environment)
|
||||
}
|
||||
val args = context.getBean<ApplicationArguments>()
|
||||
assertArrayEquals(arrayOf("spring", "boot"), args.nonOptionArgs.toTypedArray())
|
||||
assertTrue(args.containsOption("debug"))
|
||||
assertEquals(environment, context.environment)
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
internal open class ExampleConfig
|
||||
|
Loading…
Reference in New Issue
Block a user