I was loosely following the tutorial under: http://spring.io/guides/tutorials/rest/ and can't seem to make my integration test for my MVCConfig pass.
It throws the following Exception:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
Full stack trace here: http://pastebin.com/B3tWS3hH
I tried running the tests in the completed tutorial, and it also fails.
Integration Test:
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = MVCConfig.class)
public class RestDomainIntegrationTest {
@Autowired
WebApplicationContext wac;
MockMvc mockMvc;
@Before
public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void thatRestDomainCanBeAccessed() throws Exception {
mockMvc.perform(get("/")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
}
}
MVCConfig
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"com.scrumster.rest.controller"})
public class MVCConfig { }
Am I missing anything? I searched some related questions, but can't seem to find anything that fits the bill.