added method for basic encoding without padding
This commit is contained in:
parent
f76247aaa8
commit
a5ef06c93f
|
@ -33,6 +33,28 @@ public class Java8EncodeDecode {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void whenURLIsEncoded() throws UnsupportedEncodingException {
|
public void whenURLIsEncoded() throws UnsupportedEncodingException {
|
||||||
String originalURL = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java";
|
String originalURL = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java";
|
||||||
|
|
Loading…
Reference in New Issue