@@ -33,6 +33,7 @@ public class EdgeServiceIntegrationTests {
3333 private static String tripQueryURL ;
3434 private static String gmapsAdapterURL ;
3535 private static String calculationServiceURL ;
36+ private static String userServiceURL ;
3637
3738 //Wait for all services to have ports open
3839 @ ClassRule
@@ -44,8 +45,6 @@ public class EdgeServiceIntegrationTests {
4445 .waitingForService ("gmapsadapter" , HealthChecks .toHaveAllPortsOpen ())
4546 .waitingForService ("calculationservice" , HealthChecks .toHaveAllPortsOpen ())
4647 .waitingForService ("discovery-service" , HealthChecks .toHaveAllPortsOpen ())
47- .waitingForService ("userservice" , HealthChecks .toRespondOverHttp (8091 ,
48- (port ) -> port .inFormat ("http://localhost:8091" )))
4948 .waitingForService ("discovery-service" , HealthChecks .toRespondOverHttp (8761 ,
5049 (port ) -> port .inFormat ("http://localhost:8761" )))
5150 .build ();
@@ -77,6 +76,16 @@ public static void initialize() {
7776 calculationServiceURL = String .format ("http://%s:%s" , calculationService .getIp (),
7877 calculationService .getExternalPort ());
7978 LOG .info ("Calculation Service endpoint found: " + calculationServiceURL );
79+
80+ DockerPort userService = docker .containers ().container ("userservice" )
81+ .port (8080 );
82+ userServiceURL = String .format ("http://%s:%s" , userService .getIp (),
83+ userService .getExternalPort ());
84+ while (!docker .containers ().container ("userservice" ).portIsListeningOnHttp (8080 ,
85+ (port ) -> port .inFormat (userServiceURL )).succeeded ()) {
86+ LOG .info ("Waiting for user service to respond over HTTP" );
87+ }
88+ LOG .info ("User Service endpoint found: " + userServiceURL );
8089 }
8190
8291 private TestRestTemplate restTemplate = new TestRestTemplate ();
@@ -85,6 +94,8 @@ public static void initialize() {
8594
8695 @ Before
8796 public void setUp () throws JSONException {
97+
98+
8899 String plainCreds = "eagleeye:thisissecret" ;
89100 byte [] plainCredsBytes = plainCreds .getBytes ();
90101 byte [] base64CredsBytes = Base64 .getEncoder ().encode (plainCredsBytes );
@@ -101,7 +112,7 @@ public void setUp() throws JSONException {
101112 HttpEntity <String > request = new HttpEntity <>(body , headers );
102113
103114 //when:
104- ResponseEntity <String > response = restTemplate .postForEntity ("http://localhost:8091 /auth/oauth/token" ,
115+ ResponseEntity <String > response = restTemplate .postForEntity (userServiceURL + " /auth/oauth/token" ,
105116 request , String .class , parameters );
106117
107118 //then:
0 commit comments