Skip to content

Instantly share code, notes, and snippets.

@jwalgemoed jwalgemoed/DslDemoApplicationTests.kt Secret
Last active Dec 28, 2017

Embed
What would you like to do?
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class DslDemoApplicationTests {
@Autowired
private lateinit var testRestTemplate: TestRestTemplate
@Test
fun `Test 'Hello' endpoint using a valid name`() {
val headers = HttpHeaders()
headers.put("Accept", listOf("application/json"))
val entity = HttpEntity<Any>(headers)
val response = testRestTemplate.exchange(
"/api/hello/Jarno", HttpMethod.GET, entity, String::class.java)
assertEquals(HttpStatus.OK, response.statusCode)
assertJsonEquals("{ \"message\": \"Hi, Jarno!\" }", response.body)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.