From 7f845f7b5e6031aee2f1dc37f0965a5be4442a34 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 23 Mar 2015 18:50:32 +0100 Subject: [PATCH] Fix failing HeaderAssertionTests Since SPR-11792, Last-Modified and ETag headers are also written in `HTTP 304 Not Modified` responses. This is expected as per https://tools.ietf.org/html/rfc7232#section-4.1 . Those tests expected "Last-Modified" to be missing in case of HTTP 304 responses, which is not the case anymore since 953608ec . Issue: SPR-11792 --- .../resultmatchers/HeaderAssertionTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java index 004d20cc3b..5c46ab540a 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HeaderAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,14 +84,14 @@ public class HeaderAssertionTests { public void stringWithMissingResponseHeader() throws Exception { this.mockMvc.perform(get("/persons/1").header(IF_MODIFIED_SINCE, currentTime))// .andExpect(status().isNotModified())// - .andExpect(header().string(LAST_MODIFIED, (String) null)); + .andExpect(header().string("X-Custom-Header", (String) null)); } @Test public void stringWithMatcherAndMissingResponseHeader() throws Exception { this.mockMvc.perform(get("/persons/1").header(IF_MODIFIED_SINCE, currentTime))// .andExpect(status().isNotModified())// - .andExpect(header().string(LAST_MODIFIED, nullValue())); + .andExpect(header().string("X-Custom-Header", nullValue())); } @Test @@ -99,7 +99,7 @@ public class HeaderAssertionTests { try { this.mockMvc.perform(get("/persons/1").header(IF_MODIFIED_SINCE, currentTime))// .andExpect(status().isNotModified())// - .andExpect(header().longValue(LAST_MODIFIED, 99L)); + .andExpect(header().longValue("X-Custom-Header", 99L)); fail(EXPECTED_ASSERTION_ERROR_MSG); } @@ -107,7 +107,7 @@ public class HeaderAssertionTests { if (EXPECTED_ASSERTION_ERROR_MSG.equals(e.getMessage())) { throw e; } - assertEquals("Response does not contain header " + LAST_MODIFIED, e.getMessage()); + assertEquals("Response does not contain header " + "X-Custom-Header", e.getMessage()); } }