Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Spring ContextTest annotation support WebApplicationContext [SPR-4759] #9436

Closed
spring-issuemaster opened this issue Apr 28, 2008 · 1 comment

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Apr 28, 2008

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:

  • #9917 Support loading WebApplicationContexts with the TestContext Framework ("duplicates")

1 votes, 1 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 30, 2008

Juergen Hoeller commented

See #9917.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.