|
52 | 52 | import java.net.URI;
|
53 | 53 | import java.net.URISyntaxException;
|
54 | 54 | import java.net.URL;
|
55 |
| -import java.nio.charset.Charset; |
56 | 55 | import java.util.ArrayList;
|
57 | 56 | import java.util.Arrays;
|
58 | 57 | import java.util.List;
|
@@ -131,7 +130,7 @@ private File getClasspathFile(String file) throws FileNotFoundException {
|
131 | 130 | /**
|
132 | 131 | * Tests that the streaming of a file works.
|
133 | 132 | */
|
134 |
| - @Test (enabled = false) |
| 133 | + @Test (enabled = true) |
135 | 134 | public void testSendingSmallFilesAndByteArray() {
|
136 | 135 | String expectedContents = "filecontent: hello";
|
137 | 136 | String expectedContents2 = "gzipcontent: hello";
|
@@ -187,7 +186,7 @@ public void testSendingSmallFilesAndByteArray() {
|
187 | 186 | try {
|
188 | 187 | tmpFile = File.createTempFile("textbytearray", ".txt");
|
189 | 188 | os = new FileOutputStream(tmpFile);
|
190 |
| - IOUtils.write(expectedContents.getBytes(), os); |
| 189 | + IOUtils.write(expectedContents.getBytes("UTF-8"), os); |
191 | 190 | tmpFileCreated = true;
|
192 | 191 |
|
193 | 192 | testFiles.add(tmpFile);
|
@@ -233,7 +232,7 @@ public void testSendingSmallFilesAndByteArray() {
|
233 | 232 | builder.addBodyPart(new StringPart("Height", "shrimplike", AsyncHttpProviderUtils.DEFAULT_CHARSET));
|
234 | 233 | builder.addBodyPart(new StringPart("Hair", "ridiculous", AsyncHttpProviderUtils.DEFAULT_CHARSET));
|
235 | 234 |
|
236 |
| - builder.addBodyPart(new ByteArrayPart("file4", "bytearray.txt", expectedContents.getBytes(), "text/plain", Charset.defaultCharset().toString())); |
| 235 | + builder.addBodyPart(new ByteArrayPart("file4", "bytearray.txt", expectedContents.getBytes("UTF-8") ,"text/plain", "UTF-8")); |
237 | 236 |
|
238 | 237 |
|
239 | 238 | com.ning.http.client.Request r = builder.build();
|
@@ -267,13 +266,13 @@ private void testSentFile(List<String> expectedContents, List<File> sourceFiles,
|
267 | 266 | String content = null;
|
268 | 267 | try {
|
269 | 268 | content = r.getResponseBody();
|
270 |
| - assertNotNull("Content Should not have been null", content); |
| 269 | + assertNotNull("===>" + content); |
271 | 270 | System.out.println(content);
|
272 | 271 | } catch (IOException e) {
|
273 | 272 | fail("Unable to obtain content");
|
274 | 273 | }
|
275 | 274 |
|
276 |
| - String[] contentArray = content.split(":"); |
| 275 | + String[] contentArray = content.split("\\|\\|"); |
277 | 276 | // TODO: this fail on win32
|
278 | 277 | assertEquals(2, contentArray.length);
|
279 | 278 |
|
@@ -465,15 +464,15 @@ public void service(HttpServletRequest request, HttpServletResponse response)
|
465 | 464 | w.write(Integer.toString(getFilesProcessed()));
|
466 | 465 | resetFilesProcessed();
|
467 | 466 | resetStringsProcessed();
|
468 |
| - w.write(':'); |
| 467 | + w.write("||"); |
469 | 468 | w.write(files.toString());
|
470 | 469 | w.close();
|
471 | 470 | } else {
|
472 | 471 | Writer w = response.getWriter();
|
473 | 472 | w.write(Integer.toString(getFilesProcessed()));
|
474 | 473 | resetFilesProcessed();
|
475 | 474 | resetStringsProcessed();
|
476 |
| - w.write(':'); |
| 475 | + w.write("||"); |
477 | 476 | w.close();
|
478 | 477 | }
|
479 | 478 |
|
|
0 commit comments