Last active
May 26, 2020 06:39
-
-
Save lucapiccinelli/b3b97a9010725df64115c76fe96549a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloTests { | |
@Test | |
fun `GIVEN springboot in certain state WHEN a restart happens THEN it should preserve the state`(){ | |
val restTemplate = TestRestTemplate() | |
val webserverPort = Random.nextInt(10000, 10100) | |
val appContext = SpringApplication.run(MainApplication::class.java, "--server.port=$webserverPort") | |
restTemplate.getForObject<String>("http://localhost:$webserverPort/hello") shouldBe "Ok 0" | |
appContext.close() | |
val newContext = SpringApplication.run(MainApplication::class.java, "--server.port=$webserverPort") | |
restTemplate.getForObject<String>("http://localhost:$webserverPort/hello") shouldBe "Ok 1" | |
newContext.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment