Configuration

Note:
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;

spring-mvc-test-framework

ApplicationContextTest.java

package example.u2ware.springfield;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.context.WebApplicationContext;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;


@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(
 locations="classpath:example/u2ware/springfield/application-context.xml")
public class ApplicationContextTest {

        protected final Log logger = LogFactory.getLog(getClass());
        
        protected @Autowired WebApplicationContext applicationContext;
        protected MockMvc mockMvc;

        @Before
        public void setup() throws Exception {
                logger.info("====================================================");
                if(applicationContext != null){
                        for(String name : applicationContext.getBeanDefinitionNames()){
                                logger.info(name+"="+applicationContext.getType(name));
                        }
                }
                logger.info("====================================================");

                this.mockMvc = MockMvcBuilders.webAppContextSetup(applicationContext).build();
        }
        
        /*
        @Test
        public void testMvc() throws Exception{
                this.mockMvc.perform(
                                post("/part1/step3.do"))
                        .andDo(print())
                        .andExpect(status().isOk());
        }
        */
}