File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
core-java-8/src/main/java/com/demo/encoding Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,28 @@ public void whenStringIsEncoded_thenStringCanBeDecoded() throws UnsupportedEncod
3232 assertEquals (originalInput , decodedString );
3333
3434 }
35+
36+ @ Test
37+ public void whenStringIsEncodedWithoutPadding () throws UnsupportedEncodingException {
38+ String originalInput = "test input" ;
39+ String encodedString = Base64 .getEncoder ().withoutPadding ().encodeToString (originalInput .getBytes ());
40+ assertNotNull (encodedString );
41+ assertNotEquals (originalInput , encodedString );
42+ }
43+
44+ @ Test
45+ public void whenStringIsEncodedWithoutPadding_thenStringCanBeDecoded () throws UnsupportedEncodingException {
46+ String originalInput = "test input" ;
47+ String encodedString = Base64 .getEncoder ().withoutPadding ().encodeToString (originalInput .getBytes ());
48+
49+ byte [] decodedBytes = Base64 .getDecoder ().decode (encodedString );
50+ String decodedString = new String (decodedBytes );
51+
52+ assertNotNull (decodedString );
53+ assertEquals (originalInput , decodedString );
54+
55+ }
56+
3557
3658 @ Test
3759 public void whenURLIsEncoded () throws UnsupportedEncodingException {
You can’t perform that action at this time.
0 commit comments