31
31
import org .junit .jupiter .api .Test ;
32
32
33
33
import static BehaviorTests .TestUtil .rezFile ;
34
+ import static org .assertj .core .api .Assertions .assertThat ;
34
35
import static org .junit .jupiter .api .Assertions .*;
35
36
36
37
class BodyLogSummaryTest extends BddTest {
@@ -45,7 +46,7 @@ void forSimpleGets() {
45
46
.asString ();
46
47
47
48
assertEquals ("GET http://somewhere/beans?fruit=apple\n " +
48
- "Accept= image/raw\n " +
49
+ "Accept: image/raw\n " +
49
50
"===================================" , log );
50
51
}
51
52
@@ -60,7 +61,7 @@ void forSimpleBodies() {
60
61
.asString ();
61
62
62
63
assertEquals ("POST http://somewhere/beans?fruit=apple\n " +
63
- "Accept= image/raw\n " +
64
+ "Accept: image/raw\n " +
64
65
"===================================\n " +
65
66
"this is the body" , log );
66
67
}
@@ -76,7 +77,7 @@ void forJsonBodies() {
76
77
.asString ();
77
78
78
79
assertEquals ("POST http://somewhere/beans?fruit=apple\n " +
79
- "Accept= image/raw\n " +
80
+ "Accept: image/raw\n " +
80
81
"===================================\n " +
81
82
"{\" muppet\" :\" Gonzo\" }" , log );
82
83
}
@@ -92,7 +93,7 @@ void forObjectBodies() {
92
93
.asString ();
93
94
94
95
assertEquals ("POST http://somewhere/beans?fruit=apple\n " +
95
- "Accept= image/raw\n " +
96
+ "Accept: image/raw\n " +
96
97
"===================================\n " +
97
98
"{\" bar\" :\" zip\" }" , log );
98
99
}
@@ -109,36 +110,44 @@ void simpleFormBody() {
109
110
.asString ();
110
111
111
112
assertEquals ("POST http://somewhere/beans?fruit=apple\n " +
112
- "Accept= image/raw\n " +
113
+ "Accept: image/raw\n " +
113
114
"===================================\n " +
114
115
"album=77&band=Talking+Heads" , log );
115
116
}
116
117
117
- @ Test @ Disabled
118
+ @ Test
118
119
void multiPart () {
120
+ String boundary = "ABC-123-BOUNDARY" ;
119
121
String body = Unirest .post (MockServer .ECHO_RAW )
120
122
.header ("Accept" , "image/raw" )
121
123
.field ("band" , "Talking Heads" )
122
124
.field ("album" , "77" )
123
125
.field ("file" , rezFile ("/test.txt" ))
126
+ .boundary (boundary )
124
127
.toSummary ()
125
128
.asString ();
126
129
127
- assertEquals ("POST http://localhost:4567/raw\n " +
128
- "Accept=image/raw\n " +
129
- "===================================\n " +
130
- "--5798a3ff-ed92-4e9e-a9fe-bd7853cea758\n " +
131
- "Content-Disposition: form-data; name:\" album\" \n " +
132
- "77\n " +
133
- "\n " +
134
- "--0ad6dbf7-c5b6-453e-a28c-4a3a8fab7017\n " +
135
- "Content-Disposition: form-data; name:\" band\" \n " +
136
- "Talking Heads\n " +
137
- "\n " +
138
- "--453a52b3-2811-4bf6-8950-6395efe72ef7\n " +
139
- "Content-Disposition: form-data; name=\" file\" ; filename=\" null\" \n " +
140
- "Content-Type: application/octet-stream\n " +
141
- "<BINARY DATA>\n " , body );
130
+ assertThat (body ).isEqualTo (
131
+ "POST http://localhost:4567/raw\n " +
132
+ "Accept: image/raw\n " +
133
+ "Content-Type: multipart/form-data; boundary=ABC-123-BOUNDARY;charset=UTF-8\" \n " +
134
+ "===================================\n " +
135
+ "--ABC-123-BOUNDARY\n " +
136
+ "Content-Disposition: form-data; name:\" album\" \n " +
137
+ "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\n " +
138
+ "77\n " +
139
+ "\n " +
140
+ "--ABC-123-BOUNDARY\n " +
141
+ "Content-Disposition: form-data; name:\" band\" \n " +
142
+ "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\n " +
143
+ "Talking Heads\n " +
144
+ "\n " +
145
+ "--ABC-123-BOUNDARY\n " +
146
+ "Content-Disposition: form-data; name=\" file\" ; filename=\" test.txt\" \n " +
147
+ "Content-Type: application/octet-stream\n " +
148
+ "<BINARY DATA>\n "
149
+ );
150
+
142
151
}
143
152
144
153
0 commit comments