23

spring-test-mvc次のようなものを使用して、MVC サービスをテストしています。

MockMvc mockMvc = standaloneSetup(controller).build();
mockMvc.perform(get("<my-url>")).andExpect(content().bytes(expectedBytes)).andExpect(content().type("image/png"))
       .andExpect(header().string("cache-control", "max-age=3600"));

これはうまくいきました。

ここで、キャッシュ イメージを特定の範囲でランダムになるように変更しました。たとえば、代わり36003500-3700. このパターンのandExpect.

4

3 に答える 3

30

おそらく、あなたはこのようなことを意味します。

    MvcResult mvcResult = mvc.perform(get("/")).andReturn();
    String headerValue = mvcResult.getResponse().getHeader("headerName");
于 2013-09-30T14:17:48.603 に答える