Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #100 from kurthuwig/utf8-for-multi-messages
Browse files Browse the repository at this point in the history
Use UTF-8 encoding for multi-messages
  • Loading branch information
kroikie committed Sep 18, 2015
2 parents 545e15b + a5bd0aa commit b4b04f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ protected HttpURLConnection post(String url, String contentType, String body)
}
logger.fine("Sending POST to " + url);
logger.finest("POST body: " + body);
byte[] bytes = body.getBytes();
byte[] bytes = body.getBytes(UTF8);
HttpURLConnection conn = getConnection(url);
conn.setDoOutput(true);
conn.setUseCaches(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,14 @@ public void testPost_noBody() throws Exception {

@Test
public void testPost() throws Exception {
String requestBody = "req";
String requestBody = "マルチバイト文字";
String responseBody = "resp";
setResponseExpectations(200, responseBody);
HttpURLConnection response =
sender.post(Constants.GCM_SEND_ENDPOINT, requestBody);
assertEquals(requestBody, new String(outputStream.toByteArray()));
verify(mockedConn).setRequestMethod("POST");
verify(mockedConn).setFixedLengthStreamingMode(requestBody.length());
verify(mockedConn).setFixedLengthStreamingMode(requestBody.getBytes("UTF-8").length);
verify(mockedConn).setRequestProperty("Content-Type",
"application/x-www-form-urlencoded;charset=UTF-8");
verify(mockedConn).setRequestProperty("Authorization", "key=" + authKey);
Expand All @@ -748,14 +748,14 @@ public void testPost() throws Exception {

@Test
public void testPost_customType() throws Exception {
String requestBody = "req";
String requestBody = "マルチバイト文字";
String responseBody = "resp";
setResponseExpectations(200, responseBody);
HttpURLConnection response =
sender.post(Constants.GCM_SEND_ENDPOINT, "stuff", requestBody);
assertEquals(requestBody, new String(outputStream.toByteArray()));
verify(mockedConn).setRequestMethod("POST");
verify(mockedConn).setFixedLengthStreamingMode(requestBody.length());
verify(mockedConn).setFixedLengthStreamingMode(requestBody.getBytes("UTF-8").length);
verify(mockedConn).setRequestProperty("Content-Type", "stuff");
verify(mockedConn).setRequestProperty("Authorization", "key=" + authKey);
assertEquals(200, response.getResponseCode());
Expand Down

0 comments on commit b4b04f1

Please sign in to comment.