Skip to content

Commit 51b0451

Browse files
author
Phillip Webb
committed
Fix broken test due to random port change
1 parent 4119ef5 commit 51b0451

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spring-boot-cli/samples/http.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ import groovyx.net.http.*
66
@Controller
77
class Example implements CommandLineRunner {
88

9+
@Autowired
10+
ApplicationContext context;
11+
912
@RequestMapping("/")
1013
@ResponseBody
1114
public String helloWorld() {
1215
return "World!"
1316
}
1417

1518
void run(String... args) {
16-
def world = new RESTClient("http://localhost:8080").get(path:"/").data.text
19+
def port = context.embeddedServletContainer.port;
20+
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
1721
print "Hello " + world
1822
}
1923
}

0 commit comments

Comments
 (0)