-
Notifications
You must be signed in to change notification settings - Fork 17
/
HtmlTests.kt
43 lines (36 loc) · 1.7 KB
/
HtmlTests.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package io.spring.deepdive
import kotlinx.coroutines.experimental.runBlocking
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.*
import org.springframework.boot.web.server.LocalServerPort
import org.springframework.test.context.junit.jupiter.SpringExtension
import org.springframework.web.coroutine.function.client.body
import org.springframework.web.coroutine.function.client.DefaultCoroutineWebClient
import org.springframework.web.reactive.function.client.WebClient
@ExtendWith(SpringExtension::class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class HtmlTests(@LocalServerPort val port: Int) {
private val client = DefaultCoroutineWebClient(WebClient.create("http://localhost:$port"))
@Test
fun `Assert content on blog page`() = runBlocking<Unit> {
val body = client.get().uri("/").retrieve().body<String>()
assertThat(body)
.contains("Reactor Bismuth is out")
.contains("September 28th")
.contains("Sebastien")
.doesNotContain("brand-new generation")
}
@Test
fun `Assert content on blog article page`() = runBlocking<Unit> {
val body = client.get().uri("/article/spring-framework-5-0-goes-ga").retrieve().body<String>()
assertThat(body)
.contains("Spring Framework 5.0 goes GA")
.contains("Dear Spring community")
.contains("brand-new generation")
.contains("Juergen")
.doesNotContain("Sebastien")
}
}