title: Asserting Exceptions for private method in JUnit
body: <pre><code>private static String getToken(HttpClient clientInstance) throws badcredentailsexception{
  try{
      // some process here throws IOException
      }
  catch(IOexception e){
      throw new badcredentailsexception(message, e)
     }
  }
  </code></pre>
  
  <p>Now I need to write Junit test for the above method, My Junit code for above function is below</p>
  
  <pre><code>@Test(expected = badcredentailsexception.class)
  public void testGetTokenForExceptions() throws ClientProtocolException, IOException, NoSuchMethodException, SecurityException, IllegalAccessException, 
                          IllegalArgumentException, InvocationTargetException {
  
    Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))).thenThrow(IOException.class);
   // mocked mockHttpClient to throw IOException
  
      final Method method = Client.class.getDeclaredMethod("getToken", HttpClient.class);
      method.setAccessible(true);
      Object actual = method.invoke(null, mockHttpClient);
      }
  </code></pre>
  
  <p>But this test is not being passed, any improvements??</p>
  
  <p>Can we check the exception thrown by private method from junit ??</p>