Springockito how?

I want to make fun of a DAO bean using Springockito in one of my IT. In my IT, I have to use spring context.xml to autosave some services, as well as mockApplication.xml to mock DAO. So how can I use both xml configuration files at the same time?

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = SpringockitoContextLoader.class, locations = {"classpath*:/MockApplicationContext.xml"})
public class PayRollComponentFacadeIT {
    @Autowired
    IPayRollComponentFacade payRollComponentFacade;
    @ReplaceWithMock
    @Autowired
    IPayRollPersistenceManager payRollPersistenceManager;

I included mock context as @ContextConfiguration(loader = SpringockitoContextLoader.class, locations = {"classpath*:/MockApplicationContext.xml"})

But I have to include the spring context as well @ContextConfiguration(locations = {"classpath*:/testApplicationContext.xml"})

Rajib Relations

+4
source share
2 answers

ContextConfiguration.locations - this is an array, so you can specify which location you want.

@ContextConfiguration(
       loader = SpringockitoContextLoader.class,
       locations = {"classpath*:/MockApplicationContext.xml",
                    "classpath*:/testApplicationContext.xml"}
)

BTW: ( , , , - ) - , , spring ( ). , inculde . (@see fooobar.com/questions/393238/...)

+1

Springckito- .

DAO, :

@ReplaceWithMock
DAO dao;

dao . bean.

+4

All Articles