added method for basic encoding without padding
This commit is contained in:
parent
f76247aaa8
commit
a5ef06c93f
|
@ -32,6 +32,28 @@ public class Java8EncodeDecode {
|
|||
assertEquals(originalInput, decodedString);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncodedWithoutPadding() throws UnsupportedEncodingException {
|
||||
String originalInput = "test input";
|
||||
String encodedString = Base64.getEncoder().withoutPadding().encodeToString(originalInput.getBytes());
|
||||
assertNotNull(encodedString);
|
||||
assertNotEquals(originalInput, encodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncodedWithoutPadding_thenStringCanBeDecoded() throws UnsupportedEncodingException {
|
||||
String originalInput = "test input";
|
||||
String encodedString = Base64.getEncoder().withoutPadding().encodeToString(originalInput.getBytes());
|
||||
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||
String decodedString = new String(decodedBytes);
|
||||
|
||||
assertNotNull(decodedString);
|
||||
assertEquals(originalInput, decodedString);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenURLIsEncoded() throws UnsupportedEncodingException {
|
||||
|
|
Loading…
Reference in New Issue