I tried migration existing test into Spring TestContext Framework, so I changed my baseTest first. Previously it looked like:
Every test works fine in this case, then I changed to:public abstract class BaseDaoTestCase extends AbstractJpaTests {
protected String[] getConfigLocations() {
return new String[] {
"classpath:/applicationContext-resources.xml",
"classpath:/applicationContext-dao.xml",
"classpath*:/applicationContext.xml", // for modular projects
"classpath:**/applicationContext*.xml" // for web projects
};
}
...
}
I didn't change the classpath pattern, the new BaseDaoTestCase works fine for tests in the same project. For other projects, which uses BaseDaoTestCase project jar, the resource/applicationContext.xml can't be loaded, but it worked fine for the first BaseDaoTestCase.@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath:/applicationContext-resources.xml",
"classpath:/applicationContext-dao.xml",
"classpath*:applicationContext.xml", // for modular projects
"classpath:**/applicationContext*.xml" // for web projects
}, inheritLocations = true)
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
@Transactional
public abstract class BaseDaoTestCase extends TestCase {
//remove getConfigLocations method
}
Anyone has any clue?


Reply With Quote