@Test
public void testShouldThrowExceptionWhenHTTPRequestFails()
    throws Exception
{

    when( metadataSystemSettingService.getRemoteInstanceUserName() ).thenReturn( username );
    when( metadataSystemSettingService.getRemoteInstancePassword() ).thenReturn( password );
    AvailabilityStatus availabilityStatus = new AvailabilityStatus( true, "testMessage", null );
    when( metadataSystemSettingService.getVersionDetailsUrl( "testVersion" ) ).thenReturn( versionUrl );
    when( synchronizationManager.isRemoteServerAvailable() ).thenReturn( availabilityStatus );
    PowerMockito.when( HttpUtils.httpGET( versionUrl, true, username, password, null, VERSION_TIMEOUT, true ) )
        .thenThrow( new Exception( "" ) );
    expectedException.expect( MetadataVersionServiceException.class );
    target.getRemoteMetadataVersion( "testVersion" );
}