private int invokeUrl ( TestContext context ) { URL contextUrl = getUrl ( context ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Probing Http request url '%s'" , contextUrl . toExternalForm ( ) ) ) ; } int responseCode = - 1 ; HttpURLConnection httpURLConnection = null ; try { httpURLConnection = openConnection ( contextUrl ) ; httpURLConnection . setConnectTimeout ( getTimeout ( context ) ) ; httpURLConnection . setRequestMethod ( context . resolveDynamicValue ( method ) ) ; responseCode = httpURLConnection . getResponseCode ( ) ; } catch ( IOException e ) { log . warn ( String . format ( "Could not access Http url '%s' - %s" , contextUrl . toExternalForm ( ) , e . getMessage ( ) ) ) ; } finally { if ( httpURLConnection != null ) { httpURLConnection . disconnect ( ) ; } } return responseCode ; }
Invokes Http request URL and returns response code .