Mock any Spring Bean in Test Class
<p>I have Test class which I am using to test some mongo queries. 
My applicationContext-mongoclient.xml contents mongodb connection string.</p>

<p>I have my dao class which is annotated as <code>@component</code> and this mongoDatadase is autowired to dao</p>

<pre><code>@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-mongoclient.xml" })
public class ApplicationContextInitTest {

    @Autowired
    MongoDatabase mongoDatabase;

    MyDao myDao;
    @Before
    public void setMyDao(){
      estimateServicesLookup = Mockito.mock(EstimateServicesLookup.class);
    ReflectionTestUtils.setField(estimateServicesLookup,"mongoDatabase",mongoDatabase);
  //@Test code here which is taking results from myDao and asserting. 


}
}
</code></pre>

<p>Above code is not working and looks like I am not getting mongoDatabase in my dao.
Can anyone suggest how we can do it?</p>