Skip to content

Commit af85a94

Browse files
committed
Fix win32 failures
1 parent 9dc49d5 commit af85a94

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/test/java/com/ning/http/client/async/MultipartUploadTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import java.net.URI;
5353
import java.net.URISyntaxException;
5454
import java.net.URL;
55-
import java.nio.charset.Charset;
5655
import java.util.ArrayList;
5756
import java.util.Arrays;
5857
import java.util.List;
@@ -131,7 +130,7 @@ private File getClasspathFile(String file) throws FileNotFoundException {
131130
/**
132131
* Tests that the streaming of a file works.
133132
*/
134-
@Test (enabled = false)
133+
@Test (enabled = true)
135134
public void testSendingSmallFilesAndByteArray() {
136135
String expectedContents = "filecontent: hello";
137136
String expectedContents2 = "gzipcontent: hello";
@@ -187,7 +186,7 @@ public void testSendingSmallFilesAndByteArray() {
187186
try {
188187
tmpFile = File.createTempFile("textbytearray", ".txt");
189188
os = new FileOutputStream(tmpFile);
190-
IOUtils.write(expectedContents.getBytes(), os);
189+
IOUtils.write(expectedContents.getBytes("UTF-8"), os);
191190
tmpFileCreated = true;
192191

193192
testFiles.add(tmpFile);
@@ -233,7 +232,7 @@ public void testSendingSmallFilesAndByteArray() {
233232
builder.addBodyPart(new StringPart("Height", "shrimplike", AsyncHttpProviderUtils.DEFAULT_CHARSET));
234233
builder.addBodyPart(new StringPart("Hair", "ridiculous", AsyncHttpProviderUtils.DEFAULT_CHARSET));
235234

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"));
237236

238237

239238
com.ning.http.client.Request r = builder.build();
@@ -267,13 +266,13 @@ private void testSentFile(List<String> expectedContents, List<File> sourceFiles,
267266
String content = null;
268267
try {
269268
content = r.getResponseBody();
270-
assertNotNull("Content Should not have been null", content);
269+
assertNotNull("===>" + content);
271270
System.out.println(content);
272271
} catch (IOException e) {
273272
fail("Unable to obtain content");
274273
}
275274

276-
String[] contentArray = content.split(":");
275+
String[] contentArray = content.split("\\|\\|");
277276
// TODO: this fail on win32
278277
assertEquals(2, contentArray.length);
279278

@@ -465,15 +464,15 @@ public void service(HttpServletRequest request, HttpServletResponse response)
465464
w.write(Integer.toString(getFilesProcessed()));
466465
resetFilesProcessed();
467466
resetStringsProcessed();
468-
w.write(':');
467+
w.write("||");
469468
w.write(files.toString());
470469
w.close();
471470
} else {
472471
Writer w = response.getWriter();
473472
w.write(Integer.toString(getFilesProcessed()));
474473
resetFilesProcessed();
475474
resetStringsProcessed();
476-
w.write(':');
475+
w.write("||");
477476
w.close();
478477
}
479478

0 commit comments

Comments
 (0)