Regarding how to organize all these test stubbing / mocks in a larger application ...
We create and maintain a larger enterprise application that is configured with Spring. This application runs as an EAR on JBoss Appserver. We defined our Spring context with beanRefFactory.xml
<bean id="TheMegaContext" class="org.springframework.context.support.ClassPathXmlApplicationContext"> <constructor-arg> <list> <value>BasicServices.xml</value> <value>DataAccessBeans.xml</value> <value>LoginBeans.xml</value> <value>BussinessServices.xml</value> .... </list> </constructor-arg> </bean>
To run unit tests, we simply use another beanRefFactory.xml, which exchanges basic services to use the test version. Within this test version, we can define beans with the same names as in the production version, but with a layout / stub or any other implementation (for example, the database uses the local Apache DPCP data source, and the production version uses the data source from the Application Server )
source share