Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 8af2737

Browse files
[resolves #2928] WeatherIntegrationTest fails due to CamelContext is stopped
1 parent 5c10c53 commit 8af2737

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

itests/standalone/extra/src/test/java/org/wildfly/camel/test/weather/WeatherIntegrationTest.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
@RunWith(Arquillian.class)
3838
public class WeatherIntegrationTest {
3939

40-
private static String OPENWEATHER_APP_ID = System.getenv("OPENWEATHER_APP_ID");
40+
private static final String OPENWEATHER_APP_ID = System.getenv("OPENWEATHER_APP_ID");
41+
private static final String GEOLOCATION_ACCESS_KEY = System.getenv("GEOLOCATION_ACCESS_KEY");
4142

4243
@Deployment
4344
public static JavaArchive createDeployment() {
@@ -49,20 +50,32 @@ public void testGetWeatherWithDefinedLocation() {
4950
Assume.assumeNotNull(OPENWEATHER_APP_ID);
5051

5152
CamelContext camelctx = new DefaultCamelContext();
52-
ProducerTemplate template = camelctx.createProducerTemplate();
53-
String response = template.requestBody("weather:foo?location=Madrid,Spain&period=7 days&appid=" + OPENWEATHER_APP_ID, null, String.class);
54-
Assert.assertNotNull(response);
55-
Assert.assertTrue("Contains ", response.contains(",\"name\":\"Madrid\","));
53+
try {
54+
camelctx.start();
55+
56+
ProducerTemplate template = camelctx.createProducerTemplate();
57+
String response = template.requestBody("weather:foo?location=Madrid,Spain&period=7 days&appid=" + OPENWEATHER_APP_ID, null, String.class);
58+
Assert.assertNotNull(response);
59+
Assert.assertTrue("Contains ", response.contains(",\"name\":\"Madrid\","));
60+
} finally {
61+
camelctx.stop();
62+
}
5663
}
5764

5865
@Test
5966
public void testGetWeatherFromGeoIpLocation() {
60-
Assume.assumeNotNull(OPENWEATHER_APP_ID);
67+
Assume.assumeNotNull(OPENWEATHER_APP_ID, GEOLOCATION_ACCESS_KEY);
6168

6269
CamelContext camelctx = new DefaultCamelContext();
63-
ProducerTemplate template = camelctx.createProducerTemplate();
64-
String response = template.requestBody("weather:foo?appid=" + OPENWEATHER_APP_ID, null, String.class);
65-
Assert.assertNotNull(response);
66-
Assert.assertTrue("Contains ", response.contains(",\"weather\":"));
70+
try {
71+
camelctx.start();
72+
73+
ProducerTemplate template = camelctx.createProducerTemplate();
74+
String response = template.requestBody("weather:foo?geolocationRequestHostIP=redhat.com&geolocationAccessKey=" + GEOLOCATION_ACCESS_KEY + "&appid=" + OPENWEATHER_APP_ID, null, String.class);
75+
Assert.assertNotNull(response);
76+
Assert.assertTrue("Contains ", response.contains(",\"weather\":"));
77+
} finally {
78+
camelctx.stop();
79+
}
6780
}
6881
}

0 commit comments

Comments
 (0)