title: Issues in writing test case for a private method
body: <p>I am trying to write a test case for params method in the below class. </p>
  
  <p>Problems while writing a JUnit test case:</p>
  
  <p>The problem is that the method is private and inside the method it calls for super class methods. I tried using EasyMock where I will be able to supress the calls to super class constructors </p>
  
  <pre><code>CustomListener customListenerMock=createMock(CustomListener.class);
      expect(customListenerMock.getParam("CHECK_INTEGRITY")).andReturn(null);
      expect(customListenerMock.getParam("WRITE_ANSWER")).andReturn(null);    
  </code></pre>
  
  <p>The document says that I will be able to supress these methods when they are called and can give the specified output i.e null in this case.</p>
  
  <p>Now My problem is how do I invoke the private method for testing? I tried by using reflection API, but It does not work as desired. </p>
  
  <p>code: </p>
  
  <pre><code> Method InitialiseSecurityConfiguration = Listener .class.getDeclaredMethod(methodToTest, null);
      InitialiseSecurityConfiguration.setAccessible(true);
      InitialiseSecurityConfiguration.invoke(fileListenerObj);
  </code></pre>
  
  <p>When I invoke with reflection API, these methods are called just like that and super clas methods are not supressed as desired. </p>
  
  <p><strong>Note:</strong> I am using a legacy application, and not allowed to change the visibility of my methods. </p>
  
  <pre><code>class Listener extends CustomListener{
  
   /*
        Some More methods
   */
  
  private boolean params()
        {
          String integrity = "";
          String sWAnswer = "";
          try
          {
            try
            {
              integrity = super.getParam("CHECK_INTEGRITY");
              sWAnswer = super.getParam("WRITE_ANSWER");
  
  
              **Some Business Logic** 
  
            super.info("Request Directory  : " + sRequestPath);
            super.info("Response Directory : " + sResponsePath);
            super.info("Error Directory    : " + sErrorPath);
            }
          }
          catch (Exception ex)
          {
            bCheck = false;
          }
          return bCheck;
  
                }//closing the method params
  }//Closing Listener class     
  </code></pre>