Code example for MockMvc

Methods: perform

0
	public void getMessages() throws Exception { 
		List<String> messages = Arrays.asList("a", "b", "c"); 
		expect(this.chatRepository.getMessages(9)).andReturn(messages); 
		replay(this.chatRepository); 
 
		this.mockMvc.perform(get("/mvc/chat").param("messageIndex", "9")) 
				.andExpect(status().isOk()) 
				.andExpect(request().asyncStarted()) 
				.andExpect(request().asyncResult(messages)); 
 
		verify(this.chatRepository); 
	} 
 
	@Test 
	public void getMessagesStartAsync() throws Exception { 
		expect(this.chatRepository.getMessages(9)).andReturn(Arrays.<String>asList()); 
		replay(this.chatRepository); 
 
		this.mockMvc.perform(get("/mvc/chat").param("messageIndex", "9")) 
				.andExpect(request().asyncStarted()); 
Experience pair programming with AI  Get Codota for Java