title: Testing protected method with JUnit
body: <p>I am  testing a method which is <code>protected</code>. In my test case I've used <code>Reflection</code> to access the method but I am not exactly sure whether I am doing it in a right way.</p>
  
  <p>Method to be tested:</p>
  
  <pre><code>protected void checkORCondition( Map&lt;String, Message&gt; messagesMap ) throws EISClientException
  {
      Message message = containsAMessageCode(getMessageCodes(), messagesMap);
      if(message!=null)
      {
          throw new EISClientException("One of the specified message code matched returned errors." + 
                  message.getMessageCode() + ": " + message.getMessageType() + ": " + message.getMessageText());
  
      }
  }
  </code></pre>
  
  <p>JUnit test case:</p>
  
  <pre><code>@Test
  public void testcheckORCondition() throws Exception {
      Class clazz = MessageToExceptionPostProcessFilter.class;
      Object object = clazz.newInstance();
  
      Method method = clazz.getDeclaredMethod("checkORCondition", new Class[]{Map.class});
      method.setAccessible(true);
  
      String string = new String();
      string = "testing";
  
      Message message = new Message();
      message.setMessageCode("200");
  
      Map&lt;String, Message&gt; map = new HashMap&lt;String, Message&gt;();
      map.put(string, message);
  
      assertEquals("testing", string);
      assertEquals("200", message.getMessageCode());  
  }
  </code></pre>
  
  <p>My JUnit passes but not sure if it going inside the method.</p>