37
37
@ RunWith (Arquillian .class )
38
38
public class WeatherIntegrationTest {
39
39
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" );
41
42
42
43
@ Deployment
43
44
public static JavaArchive createDeployment () {
@@ -49,20 +50,32 @@ public void testGetWeatherWithDefinedLocation() {
49
50
Assume .assumeNotNull (OPENWEATHER_APP_ID );
50
51
51
52
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
+ }
56
63
}
57
64
58
65
@ Test
59
66
public void testGetWeatherFromGeoIpLocation () {
60
- Assume .assumeNotNull (OPENWEATHER_APP_ID );
67
+ Assume .assumeNotNull (OPENWEATHER_APP_ID , GEOLOCATION_ACCESS_KEY );
61
68
62
69
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
+ }
67
80
}
68
81
}
0 commit comments