JAVA-30522 :- Fix spring-mvc-basics runtime error for JSTL (#15680)

This commit is contained in:
Amit Pandey 2024-02-01 18:19:32 +05:30 committed by GitHub
parent fd59ccd374
commit 19aaa777d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 3 deletions

View File

@ -26,9 +26,14 @@
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl-version}</version>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>${jakarta.servlet.jsp.jstl.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>${jakarta.servlet.jsp.jstl.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
@ -67,6 +72,7 @@
<jaxb-runtime.version>4.0.1</jaxb-runtime.version>
<rest-assured-version>5.4.0</rest-assured-version>
<jstl-version>1.2</jstl-version>
<jakarta.servlet.jsp.jstl.version>2.0.0</jakarta.servlet.jsp.jstl.version>
</properties>
</project>

View File

@ -0,0 +1,31 @@
package com.baeldung.web.controller;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@SpringBootTest
@AutoConfigureMockMvc
public class SampleControllerIntegrationTest {
@Autowired
private MockMvc mockMvc;
@Test
public void givenBookId_whenMockMVC_thenVerifyResponse() throws Exception {
// Verifies that the controller can be invoked without any error.
this.mockMvc
.perform(get("/sample"))
.andExpect(status().isOk());
}
}