I found some similar problems but in this case I think my application context is very different.
So, I am trying to make an application context just for testing purposes.
What I basically have is this.
@WebAppConfiguration
@SuppressWarnings("UnusedDeclaration")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
{
"classpath:applicationContext-web-test.xml",
"classpath:applicationContext-security-test.xml"
}
)
public class URLTesting {
@Autowired
private WebApplicationContext webApplicationContext;
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
protected FilterChainProxy springSecurityFilterChain;
private MockMvc mockMvc;
@Test
public void testFindTransfer() throws Exception {
//I couldnt do this on a @Before, I was reading is not supported yet and throws a NPE
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.addFilter(springSecurityFilterChain)
.build();
mockMvc.perform(get("/"))
.andExpect(status().isOk());
}
}
At the moment I get as return a 404 instead a 200.
My applicationContext-security-test.xml has the following:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://ift.tt/1c8inpe"
xmlns:beans="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1cnl1uo
http://ift.tt/1c8inpe http://ift.tt/1epvZ6L">
<!-- HTTP security configurations -->
<http auto-config="true" use-expressions="true" >
<logout logout-url="/resources/j_spring_security_logout"/>
<intercept-url pattern="/" access="permitAll"/>
<intercept-url pattern="/home" access="permitAll"/>
<intercept-url pattern="/url-to-test/**" access="permitAll"/>
<intercept-url pattern="/**" access="permitAll"/>
</http>
</beans:beans>
My web-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/18sW2ax">
<bean id="springSecurityFilterChain"
class="org.springframework.security.web.FilterChainProxy">
</bean>
<bean id="webApplicationContext"
class="org.springframework.web.context.ContextLoaderListener">
</bean>
</beans>
But no success so far, any idea what could be wrong?
Thanks.
Aucun commentaire:
Enregistrer un commentaire