Pregunta

im trying to do some 'integration' tests using MockMvc class

I use:

this.mockMvc.perform(
            get("/admin"))
                    .andExpect(status().isOk())
                    .andDo(print());

but freemarker which is responsible for generating page is using security taglib

 <#assign security=JspTaglibs["http://www.springframework.org/security/tags"] />

maven dependency:

  <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>3.2.0.RELEASE</version>
    </dependency>

which seems to be not available while testing.. exception:

The following has evaluated to null or missing:
==> security  [in template "lib/abc.ftl" at line 170, column 19]

application itself is working, but I have to use mvn tomcat:run-war instead mvn tomcat:run to get taglib in place.

¿Fue útil?

Solución

I had to copy

~/.m2/repository/org/springframework/security/spring-security-taglibs/3.2.0.RELEASE/spring-security-taglibs-3.2.0.RELEASE.jar 

to my WEB-INF/lib folder. Then I get another issue about missiong 'Tag' class so I had to add

 <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.2</version>
    </dependency>

copy paste that jar file seems to be dirty workaround.. please let me know if there is any better solution.

edit

there is a way to run it using mvn tomcat7:run instead run-war, so taglibs are loaded and template files refreshed without server restart. Just add

<jarScanAllDirectoriescontextReloadable>true</jarScanAllDirectoriescontextReloadable>
<contextReloadable>true</contextReloadable>

to your tomcat7-maven-plugin in pom.xml

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top