File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
kubernetes/src/test/java/io/kubernetes/client Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .kubernetes .client ;
2+
3+ import okio .ByteString ;
4+ import org .junit .Test ;
5+
6+ import static org .hamcrest .CoreMatchers .is ;
7+ import static org .junit .Assert .*;
8+
9+ public class JSONTest {
10+
11+ @ Test
12+ public void testSerializeByteArray () {
13+ final JSON json = new JSON ();
14+ final String plainText = "string that contains '=' when encoded" ;
15+ final String base64String = json .serialize (plainText .getBytes ());
16+ //serialize returns string surrounded by quotes: "\"[base64]\""
17+ final String pureString = base64String .replaceAll ("^\" |\" $" , "" );
18+ final ByteString byteStr = ByteString .decodeBase64 (pureString );
19+
20+ //Check encoded to valid base64
21+ assertNotNull (byteStr );
22+
23+ //Check encoded string correctly
24+ final String decodedText =new String (byteStr .toByteArray ());
25+ assertThat (decodedText , is (plainText ));
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments