Spring testing using @ContextConfiguration or @ContextHierarchy

0

In order to provide Spring testing functionality to standard JUnit tests, we need to first make sure to run the test class with @RunWithannotation set to SpringJUnit4ClassRunner.

Spring test context manager machinery is created during the phase when JUnit tries to create the spring runner provided.

The test machinery looks for classes and composed annotation annotated with either @ContextConfiguration or @ContextHierarchy to build a consolidated context configuration details. Its the responsibility of spring test context manager to create the instance of the test class and then call on each configured test execution listener to prepare the test instance. For example, one of the test execution listener’s job is to auto-wire the test class members. This is the phase when the application context is built using the merged context configuration details.
In this article, we will see several possibilities of providing context configuration details.

Annotate test class with @ContextConfiguration or @ContextHierarchy

You must annotate the test classes with either @ContextConfiguration or @ContextHierarchy else the test will fail with a fatal error.

SpringTestWithNoContextConfigurationOrContextHierarchy:

package com.javarticles.spring;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
public class SpringTestWithNoContextConfigurationOrContextHierarchy {

    @Autowired
    private A beanA;
    
    @Test
    public void verifyBeanAConfigured() {
        assertNotNull(beanA);
    }
    
    @Configuration
    static class Config {
        @Bean
        A beanA() {
            return new A();
        }
    }
}

If we don’t make use of @ContextConfiguration or @ContextHierarch to identify the spring configured beans then spring won’t be able to create an application context and will fail during the phase when it tries to auto-wire the dependencies.

Output:

java.lang.IllegalStateException: Failed to load ApplicationContext
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.IllegalArgumentException: Cannot load an ApplicationContext with a NULL 'contextLoader'. Consider annotating your test class with @ContextConfiguration or @ContextHierarchy.
	at org.springframework.util.Assert.notNull(Assert.java:115)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:91)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
	... 25 more

Spring Tests with @ContextConfiguration

Let’s now annotate the test class with an empty @ContextConfiguration. Test class contains a @Configuration¬†annotated static inner class which in turn contains bean definition beanA() annotated with @Bean. We auto-wire the “beanA” and test verifyBeanAConfigured() verifies whether the bean is auto-wired.

SpringTestWithContextConfiguration:

package com.javarticles.spring;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SpringTestWithContextConfiguration {

    @Autowired
    private Config config;
    
    @Test
    public void verifyBeansConfigured() {
        assertNotNull(config);
    }
    
    @Configuration
    static class Config {
        
    }
}

Since we have not specified the classes or locations attribute, spring will look for the default XML file {test class}-Context.xml, in our case SpringTestWithContextConfiguration-Context.xml or any inner static classes annotated with @Configuration. In this case, we haven’t provided the default XML context file but there is an annotated @Configuration inner static class.

Output:

Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations
INFO: Could not detect default resource locations for test class [com.javarticles.spring.SpringTestWithContextConfiguration]: no resource found for suffixes {-context.xml}.
Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.AbstractDelegatingSmartContextLoader processContextConfiguration
INFO: AnnotationConfigContextLoader detected default configuration classes for context configuration [[email protected] declaringClass = 'com.javarticles.spring.SpringTestWithContextConfiguration', classes = '{class com.javarticles.spring.SpringTestWithContextConfiguration$Config}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
INFO: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
Mar 02, 2016 1:01:41 AM org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
INFO: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeMode[email protected], [email protected][email protected], [email protected][email protected]]
Mar 02, 2016 1:01:41 AM org.springframework.context.support.GenericApplicationContext prepareRefresh
INFO: Refreshing [email protected]e8792: startup date [Wed Mar 02 01:01:41 PST 2016]; root of context hierarchy
Mar 02, 2016 1:01:41 AM org.springframework.context.support.GenericApplicationContext doClose
INFO: Closing [email protected]e8792: startup date [Wed Mar 02 01:01:41 PST 2016]; root of context hierarchy

Spring test with default XML context file

In the below example, we will use the default XML context file to load the beans instead of inner static @Configuration classes.

SpringTestWithDefaultXMLContext:

package com.javarticles.spring;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SpringTestWithDefaultXMLContext {

    @Autowired
    private A beanA;
    
    @Test
    public void verifyBeansConfigured() {
        assertNotNull(beanA);        
    }    
}

Here is the default XML file.

com/javarticles/spring/SpringTestWithDefaultXMLContext-Context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
				http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <bean id="beanA" class="com.javarticles.spring.A"/>

</beans>

Output:

Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations
INFO: Detected default resource location "classpath:com/javarticles/spring/SpringTestWithDefaultXMLContext-context.xml" for test class [com.javarticles.spring.SpringTestWithDefaultXMLContext]
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.AbstractDelegatingSmartContextLoader processContextConfiguration
INFO: GenericXmlContextLoader detected default locations for context configuration [[email protected] declaringClass = 'com.javarticles.spring.SpringTestWithDefaultXMLContext', classes = '{}', locations = '{classpath:com/javarticles/spring/SpringTestWithDefaultXMLContext-context.xml}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.AnnotationConfigContextLoaderUtils detectDefaultConfigurationClasses
INFO: Could not detect default configuration classes for test class [com.javarticles.spring.SpringTestWithDefaultXMLContext]: SpringTestWithDefaultXMLContext does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
INFO: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
Mar 02, 2016 1:04:19 AM org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
INFO: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeMode[email protected], [email protected][email protected], [email protected][email protected]]
Mar 02, 2016 1:04:19 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [com/javarticles/spring/SpringTestWithDefaultXMLContext-context.xml]
Mar 02, 2016 1:04:19 AM org.springframework.context.support.GenericApplicationContext prepareRefresh
INFO: Refreshing [email protected]4753a: startup date [Wed Mar 02 01:04:19 PST 2016]; root of context hierarchy

Spring test with both annotated class and default XML file

You can’t use both XML context file and @Configuration annotated classes.

SpringFailureTest:

package com.javarticles.spring;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SpringFailureTest {

    @Autowired
    private A beanA;
    
    @Autowired
    private Config config;
    
    @Test
    public void verifyBeansConfigured() {
        assertNotNull(beanA);
        assertNotNull(config);
    }
    
    @Configuration
    static class Config {
        
    }
}

We will also use a default XML context file.

com/javarticles/spring/SpringFailureTest-Context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
				http://www.springframework.org/schema/aop 

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <bean id="beanA" class="com.javarticles.spring.A"/>

</beans>

Spring will use either the annotated class or XML context file. If it finds both then it is going to fail.

Error Output:

java.lang.IllegalStateException: Configuration error: both default locations AND default configuration classes were detected for context configuration [[email protected] declaringClass = 'com.javarticles.spring.SpringFailureTest', classes = '{class com.javarticles.spring.SpringFailureTest$Config}', locations = '{classpath:com/javarticles/spring/SpringFailureTest-context.xml}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader']; configure one or the other, but not both.
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.processContextConfiguration(AbstractDelegatingSmartContextLoader.java:220)
	at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:351)
	at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:308)
	at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildTestContext(AbstractTestContextBootstrapper.java:110)
	at org.springframework.test.context.TestContextManager.(TestContextManager.java:120)
	at org.springframework.test.context.TestContextManager.(TestContextManager.java:105)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:154)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.(SpringJUnit4ClassRunner.java:145)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
	at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Spring Tests with @ContextHierarchy

Spring test framework can also be used using @ContextHierarchy annotation. You can see more examples of spring @ContextHierarchy here.

SpringTestWithContextHierarchy:

package com.javarticles.spring;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextHierarchy(@ContextConfiguration)
public class SpringTestWithContextHierarchy {

    @Autowired
    private A beanA;
    
    @Test
    public void verifyBeanAConfigured() {
        assertNotNull(beanA);
    }
    
    @Configuration
    static class Config {
        @Bean
        A beanA() {
            return new A();
        }
    }
}

Output:

Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations
INFO: Could not detect default resource locations for test class [com.javarticles.spring.SpringTestWithContextHierarchy]: no resource found for suffixes {-context.xml}.
Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.AbstractDelegatingSmartContextLoader processContextConfiguration
INFO: AnnotationConfigContextLoader detected default configuration classes for context configuration [[email protected] declaringClass = 'com.javarticles.spring.SpringTestWithContextHierarchy', classes = '{class com.javarticles.spring.SpringTestWithContextHierarchy$Config}', locations = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
INFO: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.DefaultTestContextBootstrapper instantiateListeners
INFO: Could not instantiate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
Mar 02, 2016 2:29:29 AM org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
INFO: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeMode[email protected], [email protected][email protected], [email protected][email protected]]
Mar 02, 2016 2:29:30 AM org.springframework.context.support.GenericApplicationContext prepareRefresh
INFO: Refreshing [email protected]e6d5e: startup date [Wed Mar 02 02:29:30 PST 2016]; root of context hierarchy

Download the source code

This was an example about using spring annotation @ContextConfiguration or @ContextHierarchy.

You can download the source code here: springContextExamples.zip

About Author

Ram's expertise lies in test driven development and re-factoring. He is passionate about open source technologies and loves blogging on various java and open-source technologies like spring. You can reach him at [email protected]

Comments are closed.