title: Catch unknown host exception in unit test
body: <p>I am writing some unit tests and try to cover as much as posible from my code. Now I want to write a test that verifies the name of the local host.</p>
  
  <p>The method looks like this:</p>
  
  <pre><code>public static String getLocalhostName() {
        try {
           return InetAddress.getLocalHost().getHostName();
        }
        catch ( final UnknownHostException e ) {
           throw new RuntimeException( e.getMessage() );
        }
     }
  </code></pre>
  
  <p>and my test:</p>
  
  <pre><code>@Test
  public void testGetLocalhostName() {
    final String host = getLocalhostName();
    Assert.assertEquals( "mycomputer", host );
  }
  </code></pre>
  
  <p>The question is how can I refactor this in order to cover also the <code>catch</code> block from the main method?</p>