{"id":1772,"date":"2012-09-25T13:00:00","date_gmt":"2012-09-25T13:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/spring-testing-support-and-context-caching.html"},"modified":"2012-10-22T06:44:28","modified_gmt":"2012-10-22T06:44:28","slug":"spring-testing-support-and-context","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html","title":{"rendered":"Spring Testing Support and Context caching"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Spring provides a comprehensive support for unit and integration testing &#8211; through annotations to load up a Spring application context, integrate with unit testing frameworks like JUnit and TestNG. Since loading up a large application context for every test takes time, Spring intelligently caches the application context for a test suite &#8211; typically when we execute tests for a project, say through ant or maven, a suite is created encompassing all the tests in the project. <\/p>\n<p>There are a few points to note with caching which is what I intend to cover here, this is not likely to be comprehensive but is based on some situations which I have encountered:                    <\/p>\n<p>1. Caching is based on the locations of Spring application context files                    <\/p>\n<p>Consider a sample Spring configuration file:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version='1.0' encoding='UTF-8' standalone='no'?&gt;\r\n&lt;beans xmlns='http:\/\/www.springframework.org\/schema\/beans'\r\n xmlns:context='http:\/\/www.springframework.org\/schema\/context'\r\n xmlns:xsi='http:\/\/www.w3.org\/2001\/XMLSchema-instance'\r\n xmlns:p='http:\/\/www.springframework.org\/schema\/p'\r\n xsi:schemaLocation='\r\n  http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd\r\n  http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context.xsd'&gt;\r\n \r\n &lt;bean id='user1'  class='org.bk.lmt.domain.TaskUser' p:username='user1' p:fullname='testUser1' \/&gt;\r\n &lt;bean name='user2' class='org.bk.lmt.domain.TaskUser' p:username='user2' p:fullname='testUser' \/&gt;\r\n \r\n &lt;bean class='org.bk.contextcaching.DelayBean'\/&gt;\r\n \r\n&lt;\/beans&gt;\r\n<\/pre>\n<p>And a sample test to load up this context file and verify something.:<\/p>\n<pre class=\"brush:java\">@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(locations = { 'contexttest.xml' })\r\npublic class Test1 {\r\n @Autowired Map&lt;String, TaskUser&gt; usersMap;\r\n\r\n @Test\r\n public void testGetAUser() {\r\n  TaskUser user = usersMap.get('user1');\r\n  assertThat(user.getFullname(), is('testUser1'));\r\n }\r\n}<\/pre>\n<p>I have deliberately adding in a bean(DelayBean) which takes about 2 seconds to instantiate, to simulate Spring Application Contexts which are slow to load up.                    <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>If I now run a small test suite with two tests, both using the same application context, the behavior is that the first test takes about 2 seconds to run through, but the second test runs through quickly because of context caching.                    <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-r6qaBOzwYFA\/UGC7LPSBVcI\/AAAAAAAACZk\/lBuWskr_Cg8\/s1600\/springcontextcaching1.jpg\"><img decoding=\"async\" border=\"0\" height=\"107\" src=\"http:\/\/2.bp.blogspot.com\/-r6qaBOzwYFA\/UGC7LPSBVcI\/AAAAAAAACZk\/lBuWskr_Cg8\/s320\/springcontextcaching1.jpg\" width=\"320\" \/><\/a><\/div>\n<p>If there were a third test using a different application context, this test would again take time to run through as the new application context has to be loaded up:<\/p>\n<pre class=\"brush:java\">@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(locations = { 'contexttest2.xml' })\r\npublic class Test3 {\r\n...\r\n}<\/pre>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-fev87rZHoCE\/UGC7UFs0WsI\/AAAAAAAACZs\/bla51jLLe7M\/s1600\/springcontextcaching2.jpg\"><img decoding=\"async\" border=\"0\" height=\"105\" src=\"http:\/\/4.bp.blogspot.com\/-fev87rZHoCE\/UGC7UFs0WsI\/AAAAAAAACZs\/bla51jLLe7M\/s320\/springcontextcaching2.jpg\" width=\"320\" \/><\/a><\/div>\n<p>2. Caching of application contexts respects the active profile under which the test is run &#8211; essentially the profile is also part of the internal key that Spring uses to cache the context, so if two tests use the exact same application context, but different profiles are active for each of the tests, then the cached application context will not be used for the second test:                    <\/p>\n<pre class=\"brush:java\">@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(locations = { 'contexttest.xml' })\r\n@ActiveProfiles('dev1')\r\npublic class Test1 {\r\n....\r\n@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(locations = { 'contexttest.xml' })\r\n@ActiveProfiles('dev2')\r\npublic class Test2 {\r\n....<\/pre>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-n4O89fyA420\/UGC7absUU8I\/AAAAAAAACZ0\/iTQuEON63yo\/s1600\/springcontextcaching3.jpg\"><img decoding=\"async\" border=\"0\" height=\"99\" src=\"http:\/\/4.bp.blogspot.com\/-n4O89fyA420\/UGC7absUU8I\/AAAAAAAACZ0\/iTQuEON63yo\/s320\/springcontextcaching3.jpg\" width=\"320\" \/><\/a><\/div>\n<p>3. Caching of application context applies even with the new @Configuration style of defining a application context and using it in tests:<\/p>\n<pre class=\"brush:java\">@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(classes={TestConfiguration.class})\r\npublic class Test1 {\r\n...\r\n@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(classes={TestConfiguration.class})\r\npublic class Test2 {\r\n....\r\n<\/pre>\n<p>One implication of caching is that if a test class modifies the state of a bean, then another class in the test suite which uses the cached application context will end up seeing the modified bean instead of the bean the way it was defined in the application context:                    <\/p>\n<p>For eg. consider two tests, both of which modify a bean in the context, but are asserting on a state the way it is defined in the application context &#8211; Here one of the tests would end up failing(based on the order in which Junit executes the tests):<\/p>\n<pre class=\"brush:java\">@RunWith(SpringJUnit4ClassRunner.class)\r\n@ContextConfiguration(classes={TestConfiguration.class})\r\npublic class Test1 {\r\n @Autowired Map&lt;String, TaskUser&gt; usersMap;\r\n\r\n\r\n @Test\r\n public void testGetAUser1() {\r\n  TaskUser user = usersMap.get('user1');\r\n  assertThat(user.getFullname(), is('testUser1'));\r\n  user.setFullname('New Name');\r\n }\r\n \r\n @Test\r\n public void testGetAUser2() {\r\n  TaskUser user = usersMap.get('user1');\r\n  assertThat(user.getFullname(), is('testUser1'));\r\n  user.setFullname('New Name');\r\n }\r\n}<\/pre>\n<p>The fix is to instruct Spring test support that the application context is now dirty and needs to be reloaded for other tests, and this is done with @DirtiesContext annotation which can specified at the test class level or test method level.<\/p>\n<pre class=\"brush:java\">@Test\r\n@DirtiesContext\r\npublic void testGetAUser2() {\r\n...\r\n<\/pre>\n<p>Happy coding and don&#8217;t forget to share!<\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/www.java-allandsundry.com\/2012\/09\/spring-testing-support-and-context.html\">Spring Testing Support and Context caching<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Biju Kunjummen at the <a href=\"http:\/\/www.java-allandsundry.com\/\">all and sundry<\/a> blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Spring provides a comprehensive support for unit and integration testing &#8211; through annotations to load up a Spring application context, integrate with unit testing frameworks like JUnit and TestNG. Since loading up a large application context for every test takes time, Spring intelligently caches the application context for a test suite &#8211; typically when we &hellip;<\/p>\n","protected":false},"author":236,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[274,30,273],"class_list":["post-1772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-junit","tag-spring","tag-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Testing Support and Context caching - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Testing Support and Context caching - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-09-25T13:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-22T06:44:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Biju Kunjummen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Biju Kunjummen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html\"},\"author\":{\"name\":\"Biju Kunjummen\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/802eedfe6f17c3c13fa656af46b6b0e5\"},\"headline\":\"Spring Testing Support and Context caching\",\"datePublished\":\"2012-09-25T13:00:00+00:00\",\"dateModified\":\"2012-10-22T06:44:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html\"},\"wordCount\":495,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"JUnit\",\"Spring\",\"Testing\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html\",\"name\":\"Spring Testing Support and Context caching - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2012-09-25T13:00:00+00:00\",\"dateModified\":\"2012-10-22T06:44:28+00:00\",\"description\":\"Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/09\\\/spring-testing-support-and-context.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Testing Support and Context caching\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/802eedfe6f17c3c13fa656af46b6b0e5\",\"name\":\"Biju Kunjummen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/66af1504c76f011746c89812efce168850f07dce91ce881e62795e10c99d30b3?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/66af1504c76f011746c89812efce168850f07dce91ce881e62795e10c99d30b3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/66af1504c76f011746c89812efce168850f07dce91ce881e62795e10c99d30b3?s=96&d=mm&r=g\",\"caption\":\"Biju Kunjummen\"},\"sameAs\":[\"http:\\\/\\\/biju-allandsundry.blogspot.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Biju-Kunjummen\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Testing Support and Context caching - Java Code Geeks","description":"Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html","og_locale":"en_US","og_type":"article","og_title":"Spring Testing Support and Context caching - Java Code Geeks","og_description":"Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with","og_url":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-09-25T13:00:00+00:00","article_modified_time":"2012-10-22T06:44:28+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Biju Kunjummen","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Biju Kunjummen","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html"},"author":{"name":"Biju Kunjummen","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/802eedfe6f17c3c13fa656af46b6b0e5"},"headline":"Spring Testing Support and Context caching","datePublished":"2012-09-25T13:00:00+00:00","dateModified":"2012-10-22T06:44:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html"},"wordCount":495,"commentCount":5,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["JUnit","Spring","Testing"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html","url":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html","name":"Spring Testing Support and Context caching - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2012-09-25T13:00:00+00:00","dateModified":"2012-10-22T06:44:28+00:00","description":"Spring provides a comprehensive support for unit and integration testing - through annotations to load up a Spring application context, integrate with","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/09\/spring-testing-support-and-context.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Testing Support and Context caching"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/802eedfe6f17c3c13fa656af46b6b0e5","name":"Biju Kunjummen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/66af1504c76f011746c89812efce168850f07dce91ce881e62795e10c99d30b3?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/66af1504c76f011746c89812efce168850f07dce91ce881e62795e10c99d30b3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/66af1504c76f011746c89812efce168850f07dce91ce881e62795e10c99d30b3?s=96&d=mm&r=g","caption":"Biju Kunjummen"},"sameAs":["http:\/\/biju-allandsundry.blogspot.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/Biju-Kunjummen"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/236"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1772"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1772\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}