24
24
import javax .servlet .http .HttpServletRequest ;
25
25
import javax .servlet .http .HttpServletResponse ;
26
26
import java .io .*;
27
- import java .util .concurrent .ExecutionException ;
28
27
29
28
import static java .nio .charset .StandardCharsets .UTF_8 ;
30
29
import static org .asynchttpclient .Dsl .asyncHttpClient ;
@@ -60,71 +59,30 @@ public void handle(String target, Request baseRequest, HttpServletRequest req, H
60
59
};
61
60
}
62
61
63
- @ Test (expectedExceptions = ExecutionException .class )
64
- public void testPutImageFileThrowsExecutionException () throws Exception {
65
- // Should throw ExecutionException when zero-copy is enabled
66
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
67
- InputStream inputStream = new BufferedInputStream (new FileInputStream (LARGE_IMAGE_FILE ));
68
- client .preparePut (getTargetUrl ()).addBodyPart (new InputStreamPart ("test" , inputStream , LARGE_IMAGE_FILE .getName (), LARGE_IMAGE_FILE .length (), "application/octet-stream" , UTF_8 )).execute ().get ();
69
- }
70
- }
71
-
72
- @ Test (expectedExceptions = ExecutionException .class )
73
- public void testPutImageFileUnknownSizeThrowsExecutionException () throws Exception {
74
- // Should throw ExecutionException when zero-copy is enabled
75
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
76
- InputStream inputStream = new BufferedInputStream (new FileInputStream (LARGE_IMAGE_FILE ));
77
- client .preparePut (getTargetUrl ()).addBodyPart (new InputStreamPart ("test" , inputStream , LARGE_IMAGE_FILE .getName (), -1 , "application/octet-stream" , UTF_8 )).execute ().get ();
78
- }
79
- }
80
-
81
62
@ Test
82
63
public void testPutImageFile () throws Exception {
83
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ). setDisableZeroCopy ( true ) )) {
64
+ try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
84
65
InputStream inputStream = new BufferedInputStream (new FileInputStream (LARGE_IMAGE_FILE ));
85
- client .preparePut (getTargetUrl ()).addBodyPart (new InputStreamPart ("test" , inputStream , LARGE_IMAGE_FILE .getName (), LARGE_IMAGE_FILE .length (), "application/octet-stream" , UTF_8 )).execute ().get ();
66
+ Response response = client .preparePut (getTargetUrl ()).addBodyPart (new InputStreamPart ("test" , inputStream , LARGE_IMAGE_FILE .getName (), LARGE_IMAGE_FILE .length (), "application/octet-stream" , UTF_8 )).execute ().get ();
67
+ assertEquals (response .getStatusCode (), 200 );
86
68
}
87
69
}
88
70
89
71
@ Test
90
72
public void testPutImageFileUnknownSize () throws Exception {
91
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ). setDisableZeroCopy ( true ) )) {
73
+ try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
92
74
InputStream inputStream = new BufferedInputStream (new FileInputStream (LARGE_IMAGE_FILE ));
93
75
Response response = client .preparePut (getTargetUrl ()).addBodyPart (new InputStreamPart ("test" , inputStream , LARGE_IMAGE_FILE .getName (), -1 , "application/octet-stream" , UTF_8 )).execute ().get ();
94
76
assertEquals (response .getStatusCode (), 200 );
95
77
}
96
78
}
97
79
98
- @ Test (expectedExceptions = ExecutionException .class )
99
- public void testPutLargeTextFileThrowsExecutionException () throws Exception {
100
- File file = createTempFile (1024 * 1024 );
101
- InputStream inputStream = new BufferedInputStream (new FileInputStream (file ));
102
-
103
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
104
- Response response = client .preparePut (getTargetUrl ())
105
- .addBodyPart (new InputStreamPart ("test" , inputStream , file .getName (), file .length (), "application/octet-stream" , UTF_8 )).execute ().get ();
106
- assertEquals (response .getStatusCode (), 200 );
107
- }
108
- }
109
-
110
- @ Test (expectedExceptions = ExecutionException .class )
111
- public void testPutLargeTextFileUnknownSizeThrowsExecutionException () throws Exception {
112
- File file = createTempFile (1024 * 1024 );
113
- InputStream inputStream = new BufferedInputStream (new FileInputStream (file ));
114
-
115
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
116
- Response response = client .preparePut (getTargetUrl ())
117
- .addBodyPart (new InputStreamPart ("test" , inputStream , file .getName (), -1 , "application/octet-stream" , UTF_8 )).execute ().get ();
118
- assertEquals (response .getStatusCode (), 200 );
119
- }
120
- }
121
-
122
80
@ Test
123
81
public void testPutLargeTextFile () throws Exception {
124
82
File file = createTempFile (1024 * 1024 );
125
83
InputStream inputStream = new BufferedInputStream (new FileInputStream (file ));
126
84
127
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ). setDisableZeroCopy ( true ) )) {
85
+ try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
128
86
Response response = client .preparePut (getTargetUrl ())
129
87
.addBodyPart (new InputStreamPart ("test" , inputStream , file .getName (), file .length (), "application/octet-stream" , UTF_8 )).execute ().get ();
130
88
assertEquals (response .getStatusCode (), 200 );
@@ -136,7 +94,7 @@ public void testPutLargeTextFileUnknownSize() throws Exception {
136
94
File file = createTempFile (1024 * 1024 );
137
95
InputStream inputStream = new BufferedInputStream (new FileInputStream (file ));
138
96
139
- try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ). setDisableZeroCopy ( true ) )) {
97
+ try (AsyncHttpClient client = asyncHttpClient (config ().setRequestTimeout (100 * 6000 ))) {
140
98
Response response = client .preparePut (getTargetUrl ())
141
99
.addBodyPart (new InputStreamPart ("test" , inputStream , file .getName (), -1 , "application/octet-stream" , UTF_8 )).execute ().get ();
142
100
assertEquals (response .getStatusCode (), 200 );
0 commit comments