title: Expecting custom exception instead of null pointer exception while junit testing
body: <p>I have method in java class :</p>
  
  <pre><code>@Context
  UriInfo uriInfo;
  public void processRequest(@QueryParam ("userId") @DefaultValue("") String userId)
  {
       String baseURI = uriInfo.getBaseUri().toString();
       if(userId == null)
       {
           //UserIdNotFoundException is my custom exception which extends Exceptition
           throw new UserIdNotFoundException();
       }
   }
  </code></pre>
  
  <p>When I'm junit testing the above method expecting for UserIdNotFoundException when userId parameter is Null, I get the following Assertion error : <code>expected  an instance of UserIdNotFoundException but &lt;java.lang.NullPointerException&gt; is java.lang.NullPointerException</code>. </p>
  
  <pre><code>@Test
  public void testProcessRequest_throws_UserIdNotFoundException()
  {
       expectedException.expect(UserIdNotFoundException.class);
       processRequest(null);
  }
  </code></pre>
  
  <p>My custom exception class :</p>
  
  <pre><code>public class UserIdNotFoundException extends Exception
  {
  
       public UserIdNotFoundException()
       {
  
       }
  
       public UserIdNotFoundException(String message)
       {
            super(message);
       }
  }
  </code></pre>