title: junit test case for a method with hibernate fetch
body: <p>I have a <code>User</code> table and in <code>UserController.java</code> I have a method <code>userList();</code> which returns all users from database using hibernate.</p>
  
  <p>How can I write a <code>JUnit</code> test case for this piece of code. I am new to JUnit`.</p>
  
  <p>Please help.</p>
  
  <pre><code>public List&lt;User&gt; userList() {      
      try
      {       
            List &lt;User&gt; result =  hibernateTemplate.find("from User");        
            return result;
      }
      finally { 
          //close the session and user-supplied JDBC connection 
      }
  }
  </code></pre>