Add code for issue BAEL-2574 (#6249)

* Add code for issue BAEL-2574

This is a code for article "Access Spring MVC Model object in JS"

Set up the project

Add a test

* Rename the test class
This commit is contained in:
Andrey Shcherbakov
2019-02-01 07:19:07 +01:00
committed by maibin
parent 56a832273e
commit 191039ffc6
10 changed files with 131 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
package com.baeldung.accessparamsjs;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.Test;
import org.junit.runner.RunWith;
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.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class ControllerUnitTest {
@Autowired
private MockMvc mvc;
@Test
public void whenRequestIndex_thenStatusOk() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/index")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
}