package com.maxbox.test;

import com.maxbox.common.FastApplicationTests;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

public class TestWorldController extends FastApplicationTests {

    @Test
    public void getHello() throws Exception {
    //验证controller是否正常响应并打印返回结果
    /*mvc.perform(MockMvcRequestBuilders.get("/test/world").param("name","1234").accept(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(MockMvcResultMatchers.status().isOk())
        .andDo(MockMvcResultHandlers.print()).andReturn();*/
      //验证controller是否正常响应并判断返回结果是否正确
      mvc.perform(MockMvcRequestBuilders.get("/test/world").
                param("name", "1234").accept(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().string(("success")));
    }

}
