Add contentTypeCompatibleWith option to Spring MVC Test
An expectation such as content().contentType(MediaType.TEXT_PLAIN) fails if the actual media type contains a charset or another parameter. A new method allows comparing the media type and subtype only via content().contentTypeCompatibleWith(MediaType.TEXT_PLAIN). Issue: SPR-10165
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -62,7 +62,9 @@ public class ContentAssertionTests {
|
||||
|
||||
this.mockMvc.perform(get("/handleUtf8"))
|
||||
.andExpect(content().contentType(MediaType.valueOf("text/plain;charset=UTF-8")))
|
||||
.andExpect(content().contentType("text/plain;charset=UTF-8"));
|
||||
.andExpect(content().contentType("text/plain;charset=UTF-8"))
|
||||
.andExpect(content().contentTypeCompatibleWith("text/plan"))
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_PLAIN));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user