1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ public class HandlerResultHandlerTests {
51
51
52
52
53
53
@ Test
54
- public void usesContentTypeResolver () throws Exception {
54
+ void usesContentTypeResolver () {
55
55
TestResultHandler resultHandler = new TestResultHandler (new FixedContentTypeResolver (IMAGE_GIF ));
56
56
List <MediaType > mediaTypes = Arrays .asList (IMAGE_JPEG , IMAGE_GIF , IMAGE_PNG );
57
57
MockServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .get ("/path" ));
@@ -61,7 +61,7 @@ public void usesContentTypeResolver() throws Exception {
61
61
}
62
62
63
63
@ Test
64
- public void producibleMediaTypesRequestAttribute () throws Exception {
64
+ void producibleMediaTypesRequestAttribute () {
65
65
MockServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .get ("/path" ));
66
66
exchange .getAttributes ().put (HandlerMapping .PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE , Collections .singleton (IMAGE_GIF ));
67
67
@@ -72,7 +72,7 @@ public void producibleMediaTypesRequestAttribute() throws Exception {
72
72
}
73
73
74
74
@ Test // SPR-9160
75
- public void sortsByQuality () throws Exception {
75
+ void sortsByQuality () {
76
76
MockServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .get ("/path" )
77
77
.header ("Accept" , "text/plain; q=0.5, application/json" ));
78
78
@@ -83,7 +83,7 @@ public void sortsByQuality() throws Exception {
83
83
}
84
84
85
85
@ Test
86
- public void charsetFromAcceptHeader () throws Exception {
86
+ void charsetFromAcceptHeader () {
87
87
MediaType text8859 = MediaType .parseMediaType ("text/plain;charset=ISO-8859-1" );
88
88
MediaType textUtf8 = MediaType .parseMediaType ("text/plain;charset=UTF-8" );
89
89
MockServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .get ("/path" ).accept (text8859 ));
@@ -93,14 +93,25 @@ public void charsetFromAcceptHeader() throws Exception {
93
93
}
94
94
95
95
@ Test // SPR-12894
96
- public void noConcreteMediaType () throws Exception {
96
+ void noConcreteMediaType () {
97
97
List <MediaType > producible = Collections .singletonList (ALL );
98
98
MockServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .get ("/path" ));
99
99
MediaType actual = this .resultHandler .selectMediaType (exchange , () -> producible );
100
100
101
101
assertThat (actual ).isEqualTo (APPLICATION_OCTET_STREAM );
102
102
}
103
103
104
+ @ Test
105
+ void removeQualityParameter () {
106
+ MockServerWebExchange exchange = MockServerWebExchange .from (MockServerHttpRequest .get ("/path" )
107
+ .header ("Accept" , "text/plain; q=0.5" ));
108
+
109
+ List <MediaType > mediaTypes = Arrays .asList (APPLICATION_JSON , TEXT_PLAIN );
110
+ MediaType actual = this .resultHandler .selectMediaType (exchange , () -> mediaTypes );
111
+
112
+ assertThat (actual ).isEqualTo (TEXT_PLAIN );
113
+ }
114
+
104
115
105
116
@ SuppressWarnings ("WeakerAccess" )
106
117
private static class TestResultHandler extends HandlerResultHandlerSupport {
0 commit comments