Merge pull request #238 from vrajeshjayswal/master

added method for basic encoding without padding
This commit is contained in:
Eugen 2015-08-19 15:07:07 -07:00
commit 722b3dc99b
1 changed files with 22 additions and 0 deletions

View File

@ -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 {