39
39
import org .springframework .util .LinkedMultiValueMap ;
40
40
import org .springframework .util .MultiValueMap ;
41
41
42
- import static java .util .Collections .emptyMap ;
43
- import static org .junit .Assert .assertEquals ;
44
- import static org .junit .Assert .assertFalse ;
45
- import static org .junit .Assert .assertTrue ;
46
- import static org .springframework .core .ResolvableType .forClassWithGenerics ;
47
- import static org .springframework .http .HttpHeaders .CONTENT_LENGTH ;
48
- import static org .springframework .http .HttpHeaders .CONTENT_TYPE ;
49
- import static org .springframework .http .MediaType .MULTIPART_FORM_DATA ;
50
-
42
+ import static java .util .Collections .*;
43
+ import static org .junit .Assert .*;
44
+ import static org .springframework .http .HttpHeaders .*;
45
+ import static org .springframework .http .MediaType .*;
51
46
52
47
/**
53
48
* @author Sebastien Deleuze
54
49
*/
55
50
public class SynchronossMultipartHttpMessageReaderTests {
56
51
57
- private final HttpMessageReader <MultiValueMap <String , Part >> reader =
58
- new SynchronossMultipartHttpMessageReader ();
52
+ private final HttpMessageReader <MultiValueMap <String , Part >> reader = new SynchronossMultipartHttpMessageReader ();
59
53
60
54
61
55
@ Test
@@ -84,7 +78,7 @@ public void canRead() {
84
78
@ Test
85
79
public void resolveParts () throws IOException {
86
80
ServerHttpRequest request = generateMultipartRequest ();
87
- ResolvableType elementType = forClassWithGenerics (MultiValueMap .class , String .class , Part .class );
81
+ ResolvableType elementType = ResolvableType . forClassWithGenerics (MultiValueMap .class , String .class , Part .class );
88
82
MultiValueMap <String , Part > parts = this .reader .readMono (elementType , request , emptyMap ()).block ();
89
83
assertEquals (2 , parts .size ());
90
84
@@ -98,7 +92,7 @@ public void resolveParts() throws IOException {
98
92
assertEquals (12 , buffer .readableByteCount ());
99
93
byte [] byteContent = new byte [12 ];
100
94
buffer .read (byteContent );
101
- assertEquals ("Lorem\n Ipsum \n " , new String (byteContent ));
95
+ assertEquals ("Lorem Ipsum. " , new String (byteContent ));
102
96
103
97
assertTrue (parts .containsKey ("barPart" ));
104
98
part = parts .getFirst ("barPart" );
@@ -111,10 +105,11 @@ public void resolveParts() throws IOException {
111
105
@ Test
112
106
public void bodyError () {
113
107
ServerHttpRequest request = generateErrorMultipartRequest ();
114
- ResolvableType elementType = forClassWithGenerics (MultiValueMap .class , String .class , Part .class );
108
+ ResolvableType elementType = ResolvableType . forClassWithGenerics (MultiValueMap .class , String .class , Part .class );
115
109
StepVerifier .create (this .reader .readMono (elementType , request , emptyMap ())).verifyError ();
116
110
}
117
111
112
+
118
113
private ServerHttpRequest generateMultipartRequest () throws IOException {
119
114
HttpHeaders fooHeaders = new HttpHeaders ();
120
115
fooHeaders .setContentType (MediaType .TEXT_PLAIN );
0 commit comments