Skip to content

Commit

Permalink
[resolves #2928] WeatherIntegrationTest fails due to CamelContext is …
Browse files Browse the repository at this point in the history
…stopped
  • Loading branch information
jamesnetherton committed Jan 3, 2020
1 parent 5c10c53 commit 8af2737
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
@RunWith(Arquillian.class)
public class WeatherIntegrationTest {

private static String OPENWEATHER_APP_ID = System.getenv("OPENWEATHER_APP_ID");
private static final String OPENWEATHER_APP_ID = System.getenv("OPENWEATHER_APP_ID");
private static final String GEOLOCATION_ACCESS_KEY = System.getenv("GEOLOCATION_ACCESS_KEY");

@Deployment
public static JavaArchive createDeployment() {
Expand All @@ -49,20 +50,32 @@ public void testGetWeatherWithDefinedLocation() {
Assume.assumeNotNull(OPENWEATHER_APP_ID);

CamelContext camelctx = new DefaultCamelContext();
ProducerTemplate template = camelctx.createProducerTemplate();
String response = template.requestBody("weather:foo?location=Madrid,Spain&period=7 days&appid=" + OPENWEATHER_APP_ID, null, String.class);
Assert.assertNotNull(response);
Assert.assertTrue("Contains ", response.contains(",\"name\":\"Madrid\","));
try {
camelctx.start();

ProducerTemplate template = camelctx.createProducerTemplate();
String response = template.requestBody("weather:foo?location=Madrid,Spain&period=7 days&appid=" + OPENWEATHER_APP_ID, null, String.class);
Assert.assertNotNull(response);
Assert.assertTrue("Contains ", response.contains(",\"name\":\"Madrid\","));
} finally {
camelctx.stop();
}
}

@Test
public void testGetWeatherFromGeoIpLocation() {
Assume.assumeNotNull(OPENWEATHER_APP_ID);
Assume.assumeNotNull(OPENWEATHER_APP_ID, GEOLOCATION_ACCESS_KEY);

CamelContext camelctx = new DefaultCamelContext();
ProducerTemplate template = camelctx.createProducerTemplate();
String response = template.requestBody("weather:foo?appid=" + OPENWEATHER_APP_ID, null, String.class);
Assert.assertNotNull(response);
Assert.assertTrue("Contains ", response.contains(",\"weather\":"));
try {
camelctx.start();

ProducerTemplate template = camelctx.createProducerTemplate();
String response = template.requestBody("weather:foo?geolocationRequestHostIP=redhat.com&geolocationAccessKey=" + GEOLOCATION_ACCESS_KEY + "&appid=" + OPENWEATHER_APP_ID, null, String.class);
Assert.assertNotNull(response);
Assert.assertTrue("Contains ", response.contains(",\"weather\":"));
} finally {
camelctx.stop();
}
}
}

0 comments on commit 8af2737

Please sign in to comment.