@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2019 the original author or authors .
* Copyright 2002 - 2020 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 .
@ -51,7 +51,7 @@ public class HandlerResultHandlerTests {
@@ -51,7 +51,7 @@ public class HandlerResultHandlerTests {
@Test
public void usesContentTypeResolver ( ) throws Exception {
void usesContentTypeResolver ( ) {
TestResultHandler resultHandler = new TestResultHandler ( new FixedContentTypeResolver ( IMAGE_GIF ) ) ;
List < MediaType > mediaTypes = Arrays . asList ( IMAGE_JPEG , IMAGE_GIF , IMAGE_PNG ) ;
MockServerWebExchange exchange = MockServerWebExchange . from ( MockServerHttpRequest . get ( "/path" ) ) ;
@ -61,7 +61,7 @@ public class HandlerResultHandlerTests {
@@ -61,7 +61,7 @@ public class HandlerResultHandlerTests {
}
@Test
public void producibleMediaTypesRequestAttribute ( ) throws Exception {
void producibleMediaTypesRequestAttribute ( ) {
MockServerWebExchange exchange = MockServerWebExchange . from ( MockServerHttpRequest . get ( "/path" ) ) ;
exchange . getAttributes ( ) . put ( HandlerMapping . PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE , Collections . singleton ( IMAGE_GIF ) ) ;
@ -72,7 +72,7 @@ public class HandlerResultHandlerTests {
@@ -72,7 +72,7 @@ public class HandlerResultHandlerTests {
}
@Test // SPR-9160
public void sortsByQuality ( ) throws Exception {
void sortsByQuality ( ) {
MockServerWebExchange exchange = MockServerWebExchange . from ( MockServerHttpRequest . get ( "/path" )
. header ( "Accept" , "text/plain; q=0.5, application/json" ) ) ;
@ -83,7 +83,7 @@ public class HandlerResultHandlerTests {
@@ -83,7 +83,7 @@ public class HandlerResultHandlerTests {
}
@Test
public void charsetFromAcceptHeader ( ) throws Exception {
void charsetFromAcceptHeader ( ) {
MediaType text8859 = MediaType . parseMediaType ( "text/plain;charset=ISO-8859-1" ) ;
MediaType textUtf8 = MediaType . parseMediaType ( "text/plain;charset=UTF-8" ) ;
MockServerWebExchange exchange = MockServerWebExchange . from ( MockServerHttpRequest . get ( "/path" ) . accept ( text8859 ) ) ;
@ -93,7 +93,7 @@ public class HandlerResultHandlerTests {
@@ -93,7 +93,7 @@ public class HandlerResultHandlerTests {
}
@Test // SPR-12894
public void noConcreteMediaType ( ) throws Exception {
void noConcreteMediaType ( ) {
List < MediaType > producible = Collections . singletonList ( ALL ) ;
MockServerWebExchange exchange = MockServerWebExchange . from ( MockServerHttpRequest . get ( "/path" ) ) ;
MediaType actual = this . resultHandler . selectMediaType ( exchange , ( ) - > producible ) ;
@ -101,6 +101,17 @@ public class HandlerResultHandlerTests {
@@ -101,6 +101,17 @@ public class HandlerResultHandlerTests {
assertThat ( actual ) . isEqualTo ( APPLICATION_OCTET_STREAM ) ;
}
@Test
void removeQualityParameter ( ) {
MockServerWebExchange exchange = MockServerWebExchange . from ( MockServerHttpRequest . get ( "/path" )
. header ( "Accept" , "text/plain; q=0.5" ) ) ;
List < MediaType > mediaTypes = Arrays . asList ( APPLICATION_JSON , TEXT_PLAIN ) ;
MediaType actual = this . resultHandler . selectMediaType ( exchange , ( ) - > mediaTypes ) ;
assertThat ( actual ) . isEqualTo ( TEXT_PLAIN ) ;
}
@SuppressWarnings ( "WeakerAccess" )
private static class TestResultHandler extends HandlerResultHandlerSupport {