spring-boot-kotlin refactor (#1979)
This commit is contained in:
parent
5b0302524f
commit
73971c4d01
@ -93,6 +93,20 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||||
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
|
<exclude>**/JdbcTest.java</exclude>
|
||||||
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@ package springbootkotlin
|
|||||||
|
|
||||||
import com.baeldung.springbootkotlin.HelloDto
|
import com.baeldung.springbootkotlin.HelloDto
|
||||||
import com.baeldung.springbootkotlin.KotlinDemoApplication
|
import com.baeldung.springbootkotlin.KotlinDemoApplication
|
||||||
import org.junit.Assert
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
@ -13,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner
|
|||||||
|
|
||||||
@RunWith(SpringRunner::class)
|
@RunWith(SpringRunner::class)
|
||||||
@SpringBootTest(classes = arrayOf(KotlinDemoApplication::class), webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(classes = arrayOf(KotlinDemoApplication::class), webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
class KotlinDemoApplicationTests {
|
class KotlinDemoApplicationIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
val testRestTemplate: TestRestTemplate? = null
|
val testRestTemplate: TestRestTemplate? = null
|
||||||
@ -26,27 +27,27 @@ class KotlinDemoApplicationTests {
|
|||||||
fun testHelloController() {
|
fun testHelloController() {
|
||||||
val result = testRestTemplate?.getForEntity("/hello", String::class.java)
|
val result = testRestTemplate?.getForEntity("/hello", String::class.java)
|
||||||
|
|
||||||
Assert.assertNotNull(result)
|
assertNotNull(result)
|
||||||
Assert.assertEquals(result?.statusCode, HttpStatus.OK)
|
assertEquals(result?.statusCode, HttpStatus.OK)
|
||||||
Assert.assertEquals(result?.body, "hello world")
|
assertEquals(result?.body, "hello world")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testHelloService() {
|
fun testHelloService() {
|
||||||
val result = testRestTemplate?.getForEntity("/hello-service", String::class.java)
|
val result = testRestTemplate?.getForEntity("/hello-service", String::class.java)
|
||||||
|
|
||||||
Assert.assertNotNull(result)
|
assertNotNull(result)
|
||||||
Assert.assertEquals(result?.statusCode, HttpStatus.OK)
|
assertEquals(result?.statusCode, HttpStatus.OK)
|
||||||
Assert.assertEquals(result?.body, "hello service")
|
assertEquals(result?.body, "hello service")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testHelloDto() {
|
fun testHelloDto() {
|
||||||
val result = testRestTemplate?.getForEntity("/hello-dto", HelloDto::class.java)
|
val result = testRestTemplate?.getForEntity("/hello-dto", HelloDto::class.java)
|
||||||
|
|
||||||
Assert.assertNotNull(result)
|
assertNotNull(result)
|
||||||
Assert.assertEquals(result?.statusCode, HttpStatus.OK)
|
assertEquals(result?.statusCode, HttpStatus.OK)
|
||||||
Assert.assertEquals(result?.body, HelloDto("Hello from the dto"))
|
assertEquals(result?.body, HelloDto("Hello from the dto"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user