Merge pull request #12471 from anuragkumawat/JAVA-13089
JAVA-13089 Verify Java Base64 Encoding and Decoding article
This commit is contained in:
commit
6f6612608d
|
@ -96,7 +96,23 @@ public class Java8EncodeDecodeUnitTest {
|
||||||
assertNotNull(decodedMime);
|
assertNotNull(decodedMime);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
@Test
|
||||||
|
public void whenEncodedStringHasValidCharacters_thenStringCanBeDecoded() {
|
||||||
|
final String encodedString = "dGVzdCMkaW5wdXQ+";
|
||||||
|
final byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||||
|
final String decodedString = new String(decodedBytes);
|
||||||
|
|
||||||
|
assertNotNull(decodedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void whenEncodedStringHasInvalidCharacters_thenIllegalArgumentException() {
|
||||||
|
final String encodedString = "dGVzdCMkaW5wdXQ#";
|
||||||
|
final byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||||
|
final String decodedString = new String(decodedBytes);
|
||||||
|
|
||||||
|
assertNotNull(decodedString);
|
||||||
|
}
|
||||||
|
|
||||||
private static StringBuilder getMimeBuffer() {
|
private static StringBuilder getMimeBuffer() {
|
||||||
final StringBuilder buffer = new StringBuilder();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
|
|
Loading…
Reference in New Issue