Question

So the thing is I want to load a set of application contexts that follow the regular expression that is anything follow by -context.xml, ok?

This saves me a lot of time since I don't need to add a lot of application contexts one by one. Now, one of those application context is giving me trouble and I want it to not be included in the context configuration. Can I add something to the @ContextConfiguration annotation that removes a particular application context from the previous locations?

Is not a big nuisance, but I'm curious... Here's some code if this helps you:

@RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {
            "classpath*:resources/*-context.xml"
            })
    public class Tests{
    ...
    }
Was it helpful?

Solution

Context exclusion is not possible in Spring. You can declare which contexts to use by using Spring Profiles. In each test you can select which profile will be used, so in turn which beans will be loaded to context.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top