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"));
これはうまくいきました。
ここで、キャッシュ イメージを特定の範囲でランダムになるように変更しました。たとえば、代わり3600
に3500-3700
. このパターンのandExpect
.