-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVEXP-536: Fix UTF-8 encoding for body payloads (#121)
* fix (HttpClientApache): Defaulting to send UTF-8 encoded payload
- Loading branch information
Showing
4 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
core/src/test/java/com/sinch/sdk/core/http/HttpContentTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.sinch.sdk.core.http; | ||
|
||
import java.util.Optional; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class HttpContentTypeTest { | ||
|
||
@Test | ||
void getCharsetValueDefaultEmpty() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue("")).isEqualTo(Optional.empty()); | ||
} | ||
|
||
@Test | ||
void getCharsetValueNullEmpty() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue(null)).isEqualTo(Optional.empty()); | ||
} | ||
|
||
@Test | ||
void getCharsetValueNoCharset() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue("text/html")).isEqualTo(Optional.empty()); | ||
} | ||
|
||
@Test | ||
void getCharsetValueNoCharsetWithSemiColon() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue("text/html;")) | ||
.isEqualTo(Optional.empty()); | ||
} | ||
|
||
@Test | ||
void getCharsetValueStartOfString() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue(" charset=utf-16; text/html")) | ||
.isEqualTo(Optional.of("utf-16")); | ||
} | ||
|
||
@Test | ||
void getCharsetValueStartOfStringWithSemiColon() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue(" charset=utf-16; text/html;")) | ||
.isEqualTo(Optional.of("utf-16")); | ||
} | ||
|
||
@Test | ||
void getCharsetValueEndOfString() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue("text/html; charset=utf-16")) | ||
.isEqualTo(Optional.of("utf-16")); | ||
} | ||
|
||
@Test | ||
void getCharsetValueEndOfStringWithSemiColon() { | ||
Assertions.assertThat(HttpContentType.getCharsetValue("text/html; charset=utf-16;")) | ||
.isEqualTo(Optional.of("utf-16")); | ||
} | ||
|
||
@Test | ||
void getCharsetValue() { | ||
Assertions.assertThat( | ||
HttpContentType.getCharsetValue( | ||
"multipart/form-data; charset=utf-16; boundary=ExampleBoundaryString")) | ||
.isEqualTo(Optional.of("utf-16")); | ||
} | ||
|
||
@Test | ||
void getCharsetValueWithSemiColon() { | ||
Assertions.assertThat( | ||
HttpContentType.getCharsetValue( | ||
"multipart/form-data; charset=utf-16; boundary=ExampleBoundaryString;")) | ||
.isEqualTo(Optional.of("utf-16")); | ||
} | ||
} |