File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed
main/kotlin/com/baeldung/consoleapp
test/kotlin/com/baeldung/consoleapp Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments