Skip to content

Commit

Permalink
Move servlet context to classpath and remove root-context (which just…
Browse files Browse the repository at this point in the history
… imports another)
  • Loading branch information
nealeu committed Mar 18, 2012
1 parent 7b53d0e commit 752758b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
9 changes: 0 additions & 9 deletions sample-webapp/src/main/webapp/WEB-INF/spring/root-context.xml

This file was deleted.

9 changes: 2 additions & 7 deletions sample-webapp/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,13 @@
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<!-- Location of Java @Configuration classes that configure the components that makeup this application -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>org.fuzzydb.samples.config</param-value>
</context-param>

<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<!-- <context-param> -->
<!-- <param-name>contextConfigLocation</param-name> -->
<!-- <param-value>/WEB-INF/spring/root-context.xml</param-value> -->
<!-- </context-param> -->

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
Expand All @@ -72,7 +67,7 @@
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
<param-value>classpath:spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,26 @@
import org.junit.runner.RunWith;

/**
* Test that our Spring context is set up correctly
* Test that our Spring context is set up correctly. This is not as easy as it should be. I want:
* <pre>
* {@code @ContextConfiguration}(
* locations = {"root-context.xml"},
* child = {@code @ContextConfiguration}(locations = "/WEB-INF/servlet.xml")
* )
* </pre>
* This would produce a child servlet context with a parent. It's almost impossible to correctly test
* servlet controller configurations without this.<br>
* This approach would also allow a more fine grained {@code @DirtiesContext} behaviour if also providing a
* name attribute on each context (i.e. name="root", name="servlet")
*
* In XML, <parent classes="..." or resources="..." /> would create a parent classloader. Unfortunately, parents are expected to already
* exist. siblings would be possible... no.. wait. I could create an application context, initialise it, and then register every concrete bean...
*
* @author Neale
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:fuzzy-repository-context.xml","classpath:controllers.xml"})
@ContextConfiguration(locations={"classpath:test-context.xml"})
public class SearchControllerIntegrationTest {

@Autowired
Expand Down

0 comments on commit 752758b

Please sign in to comment.