Tag: test spring mvc

ContextConfiguration RunWith WebAppConfiguration注释

我有一个注释这些注释的类: @ContextConfiguration(locations = { “classpath:pathToXml.xml” }) @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration 你能解释一下我在课堂上添加这些注释后的function吗?

Spring mvc 3.1集成测试,支持会话

我正在使用3.1版本中的新spring-test来运行集成测试。 它工作得很好,但我不能使会话工作。 我的代码: @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration(“src/main/webapp”) @ContextConfiguration({“classpath:applicationContext-dataSource.xml”, “classpath:applicationContext.xml”, “classpath:applicationContext-security-roles.xml”, “classpath:applicationContext-security-web.xml”, “classpath:applicationContext-web.xml”}) public class SpringTestBase { @Autowired private WebApplicationContext wac; @Autowired private FilterChainProxy springSecurityFilterChain; @Autowired private SessionFactory sessionFactory; protected MockMvc mock; protected MockHttpSession mockSession; @Before public void setUp() throws Exception { initDataSources(“dataSource.properties”); mock = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build(); mockSession = new MockHttpSession(wac.getServletContext(), UUID.randomUUID().toString()); } @Test public void testLogin() throws Exception […]