Advertisement
aaa4Alex

RestControllerTest

Feb 5th, 2021
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1.    
  2. @SpringBootTest
  3. @AutoConfigureMockMvc
  4. public class MessageControllerTest {
  5.  
  6.     @Autowired
  7.     private MockMvc mockMvc;
  8.     private String postUrl = "http://localhost:8081/api/messages?text=text1";
  9.  
  10.     @Test
  11.     public void testPostMessage() throws Exception{
  12.         mockMvc.perform(post(postUrl))
  13.                 .andDo(print())
  14.                 .andExpect(status().isOk())
  15.                 .andExpect(content().string(containsString("{\"id\": 0}")));//  fixme how to test this case?
  16.  
  17.     }
  18.  
  19. }
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement