Skip to content

Commit fd711db

Browse files
authored
Merge pull request #653 from fabiotadashi/KTLN-612/console-app
Creating a Spring Boot Console Application with Kotlin
2 parents 5363595 + 3e58440 commit fd711db

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.consoleapp
2+
3+
import org.slf4j.LoggerFactory
4+
import org.springframework.boot.CommandLineRunner
5+
import org.springframework.core.annotation.Order
6+
import org.springframework.stereotype.Component
7+
8+
@Component
9+
@Order(0)
10+
class CommandLineFirstComponent: CommandLineRunner {
11+
12+
private val log = LoggerFactory.getLogger(CommandLineFirstComponent::class.java)
13+
14+
override fun run(vararg args: String?) {
15+
log.info(CommandLineFirstComponent::class.simpleName)
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.consoleapp
2+
3+
import org.slf4j.LoggerFactory
4+
import org.springframework.boot.CommandLineRunner
5+
import org.springframework.core.annotation.Order
6+
import org.springframework.stereotype.Component
7+
8+
@Component
9+
@Order(1)
10+
class CommandLineSecondComponent: CommandLineRunner {
11+
12+
private val log = LoggerFactory.getLogger(CommandLineSecondComponent::class.java)
13+
14+
override fun run(vararg args: String?) {
15+
log.info(CommandLineSecondComponent::class.simpleName)
16+
}
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.baeldung.consoleapp
2+
3+
import org.assertj.core.api.Assertions.assertThat
4+
import org.junit.Test
5+
import org.junit.runner.RunWith
6+
import org.springframework.beans.factory.annotation.Autowired
7+
import org.springframework.boot.test.context.SpringBootTest
8+
import org.springframework.test.context.junit4.SpringRunner
9+
10+
@RunWith(SpringRunner::class)
11+
@SpringBootTest(properties = ["spring.main.web-application-type=NONE"])
12+
class ConsoleApplicationIntegrationTest {
13+
14+
@Autowired
15+
lateinit var commandLineFirstComponent: CommandLineFirstComponent
16+
17+
@Autowired
18+
lateinit var commandLineSecondComponent: CommandLineSecondComponent
19+
20+
21+
@Test
22+
fun whenComponentsAreAvailable_thenShouldBindToProperties() {
23+
assertThat(commandLineFirstComponent).isNotNull
24+
assertThat(commandLineSecondComponent).isNotNull
25+
}
26+
27+
}

0 commit comments

Comments
 (0)