Issue Details (XML | Word | Printable)

Key: SPR-4759
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Duplicate
Priority: Major Major
Assignee: Sam Brannen
Reporter: Yaozong Zhu
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Make Spring ContextTest annotation support WebApplicationContext

Created: 28/Apr/08 10:01 AM   Updated: 08/Jul/09 03:53 PM   Resolved: 30/Oct/08 11:16 AM
Component/s: SpringTEST
Affects Version/s: 2.5.2
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Duplicate
 

Virtual Machine: Sun JVM - 1.6
Platform: Jetty - 6.1


 Description  « Hide

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)
...



Juergen Hoeller added a comment - 30/Oct/08 11:16 AM

See SPR-5243.