@@ -122,13 +122,20 @@ protected void pingApp(String expectedText) throws Exception {
122122 URL url = app .getBaseUrl ();
123123 url = new URL (url .toExternalForm () + relativeURL );
124124 HttpUtil .HttpResult result = HttpUtil .get (url .toURI ());
125+ for (int i = 0 ; i < 15 && !result .isGoodResponse ; i ++) {
126+ Thread .sleep (1000 );
127+ result = HttpUtil .get (url .toURI ());
128+ }
125129 assertTrue ("The response code should be 200: " + result .responseCode , result .responseCode == 200 );
126130 assertTrue ("The response should contain the expected text: " + expectedText , result .response != null && result .response .contains (expectedText ));
127131 }
128132
129133 protected void checkMode (StartMode mode ) throws Exception {
130134 MicroclimateApplication app = connection .getAppByName (projectName );
131- assertTrue ("App should be in mode: " + mode , app .getStartMode () == mode );
135+ for (int i = 0 ; i < 5 && app .getStartMode () != mode ; i ++) {
136+ Thread .sleep (1000 );
137+ }
138+ assertTrue ("App is in " + app .getStartMode () + " when it should be in " + mode + " mode." , app .getStartMode () == mode );
132139 ILaunch launch = ((MCEclipseApplication )app ).getLaunch ();
133140 if (StartMode .DEBUG_MODES .contains (mode )) {
134141 assertNotNull ("There should be a launch for the app" , launch );
@@ -145,7 +152,7 @@ protected void switchMode(StartMode mode) throws Exception {
145152 connection .requestProjectRestart (app , mode .startMode );
146153 // For Java builds the states can go by quickly so don't do an assert on this
147154 MicroclimateUtil .waitForAppState (app , AppState .STOPPED , 30 , 1 );
148- assertTrue ("App should be in started state" , MicroclimateUtil .waitForAppState (app , AppState .STARTED , 120 , 1 ));
155+ assertTrue ("App should be in started state instead of: " + app . getAppState () , MicroclimateUtil .waitForAppState (app , AppState .STARTED , 120 , 1 ));
149156 checkMode (mode );
150157 }
151158
0 commit comments