title: JUnit test on URLConnection, use EasyMock?
body: <p>Hey, have been trying to work this out for last day or so but hitting brick wall. Trying to unit test this bit of code. But not sure if need to use EasyMock or not?? Seem few examples online but seem to be using older techniques.</p>
  
  <pre><code>public boolean verifyConnection(final String url) {
      boolean result;
  
      final int timeout = getConnectionTimeout();
      if (timeout &lt; 0) {
          log.info("No need to verify connection to client. Supplied timeout = {}", timeout);
          result = true;
      } else {
          try {
              log.debug("URL: {} Timeout: {} ", url, timeout);
  
              final URL targetUrl = new URL(url);
              final HttpURLConnection connection = (HttpURLConnection) targetUrl.openConnection();
  
              connection.setConnectTimeout(timeout);
              connection.connect();
              result = true;
          } catch (ConnectException e) {
              log.warn("Could not connect to client supplied url: " + url, e);
              result = false;
          } catch (MalformedURLException e) {
              log.error("Malformed client supplied url: " + url, e);
              result = false;
          } catch (IOException e) {
              log.warn("Could not connect to client supplied url: " + url, e);
              result = false;
          }
      }
      return result;
  }
  </code></pre>
  
  <p>It just take's in a url checks its valid and returns T or F.  </p>