Provided you've configured ContextLoaderListener in web.xml you can let one of your classes implement the
org.springframework.web.context.ServletContextAwar e interface and configure it in the Spring Application Context. On startup the Spring Container will call the setServletContext() method and pass the ServletContext object.
You should be aware however (no pun intended) that you bind your code to the API of the Spring Framework by doing so. You can use
org.springframework.mock.web.MockServletContext in your test cases.