Description
Yaozong Zhu opened SPR-4759 and commented
I am trying to integrate my tests into Spring 2.5 availing of TestContext annotations. But I met a support issue. The followings are relevant codes:
@RunWith
(SpringJUnit4ClassRunner.class)
@TestExecutionListeners
(value = {
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class
})
@ContextConfiguration
(locations = {
"classpath:/applicationContext-resources.xml",
"classpath*:/applicationContext.xml"
}, inheritLocations = true)
@TransactionConfiguration
(transactionManager = "transactionManager", defaultRollback = true)
@Transactional
public abstract class BaseTestCase extends AbstractJUnit4SpringContextTests {...}
@ContextConfiguration
(locations = {
"classpath:/applicationContext-jmx.xml",
"/WEB-INF/applicationContext*.xml",
"/WEB-INF/dispatcher-servlet.xml"
}, inheritLocations = true)
public abstract class BaseWebControllerTestCase extends BaseTestCase{...}
public class UserFormControllerTest extends BaseWebControllerTestCase{
@Autowired
private UserFormController c = null;
@Test
...
}
java.lang.IllegalStateException: WebApplicationObjectSupport instance [xxx.UserFormController@123961b] does not run in a WebApplicationContext but in: org.springframework.context.support.GenericApplicationContext@1fc2fb: display name [org.springframework.context.support.GenericApplicationContext@1fc2fb]; startup date [Mon Apr 28 15:35:37 BST 2008]; root of context hierarchy
at org.springframework.web.context.support.WebApplicationObjectSupport.getWebApplicationContext(WebApplicationObjectSupport.java:101)
at org.springframework.web.context.support.WebApplicationObjectSupport.getServletContext(WebApplicationObjectSupport.java:115)
...
Affects: 2.5.2
Issue Links:
- Support loading WebApplicationContexts with the TestContext Framework [SPR-5243] #9917 Support loading WebApplicationContexts with the TestContext Framework ("duplicates")
1 votes, 1 watchers