@@ -41,9 +41,9 @@ public void testBasicEncodeDecode() throws Exception {
4141 final PercentCodec percentCodec = new PercentCodec ();
4242 final String input = "abcdABCD" ;
4343 final byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets .UTF_8 ));
44- final String encodedS = new String (encoded , "UTF-8" );
44+ final String encodedS = new String (encoded , StandardCharsets . UTF_8 );
4545 final byte [] decoded = percentCodec .decode (encoded );
46- final String decodedS = new String (decoded , "UTF-8" );
46+ final String decodedS = new String (decoded , StandardCharsets . UTF_8 );
4747 assertEquals ("Basic PercentCodec encoding test" , input , encodedS );
4848 assertEquals ("Basic PercentCodec decoding test" , input , decodedS );
4949 }
@@ -60,19 +60,19 @@ public void testBasicSpace() throws Exception {
6060 @ Test
6161 public void testConfigurablePercentEncoder () throws Exception {
6262 final String input = "abc123_-.*\u03B1 \u03B2 " ;
63- final PercentCodec percentCodec = new PercentCodec ("abcdef" .getBytes ("UTF-8" ), false );
63+ final PercentCodec percentCodec = new PercentCodec ("abcdef" .getBytes (StandardCharsets . UTF_8 ), false );
6464 final byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets .UTF_8 ));
65- final String encodedS = new String (encoded , "UTF-8" );
65+ final String encodedS = new String (encoded , StandardCharsets . UTF_8 );
6666 assertEquals ("Configurable PercentCodec encoding test" , "%61%62%63123_-.*%CE%B1%CE%B2" , encodedS );
6767 final byte [] decoded = percentCodec .decode (encoded );
68- assertEquals ("Configurable PercentCodec decoding test" , new String (decoded , "UTF-8" ), input );
68+ assertEquals ("Configurable PercentCodec decoding test" , new String (decoded , StandardCharsets . UTF_8 ), input );
6969 }
7070
7171 @ Test
7272 public void testDecodeInvalidEncodedResultDecoding () throws Exception {
7373 final String inputS = "\u03B1 \u03B2 " ;
7474 final PercentCodec percentCodec = new PercentCodec ();
75- final byte [] encoded = percentCodec .encode (inputS .getBytes ("UTF-8" ));
75+ final byte [] encoded = percentCodec .encode (inputS .getBytes (StandardCharsets . UTF_8 ));
7676 try {
7777 percentCodec .decode (Arrays .copyOf (encoded , encoded .length -1 )); //exclude one byte
7878 } catch (final Exception e ) {
@@ -110,7 +110,7 @@ public void testPercentEncoderDecoderWithNullOrEmptyInput() throws Exception {
110110 final PercentCodec percentCodec = new PercentCodec (null , true );
111111 assertNull ("Null input value encoding test" , percentCodec .encode (null ));
112112 assertNull ("Null input value decoding test" , percentCodec .decode (null ));
113- final byte [] emptyInput = "" .getBytes ("UTF-8" );
113+ final byte [] emptyInput = "" .getBytes (StandardCharsets . UTF_8 );
114114 assertEquals ("Empty input value encoding test" , percentCodec .encode (emptyInput ), emptyInput );
115115 assertArrayEquals ("Empty input value decoding test" , percentCodec .decode (emptyInput ), emptyInput );
116116 }
@@ -120,20 +120,20 @@ public void testPercentEncoderDecoderWithPlusForSpace() throws Exception {
120120 final String input = "a b c d" ;
121121 final PercentCodec percentCodec = new PercentCodec (null , true );
122122 final byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets .UTF_8 ));
123- final String encodedS = new String (encoded , "UTF-8" );
123+ final String encodedS = new String (encoded , StandardCharsets . UTF_8 );
124124 assertEquals ("PercentCodec plus for space encoding test" , "a+b+c+d" , encodedS );
125125 final byte [] decode = percentCodec .decode (encoded );
126- assertEquals ("PercentCodec plus for space decoding test" , new String (decode , "UTF-8" ), input );
126+ assertEquals ("PercentCodec plus for space decoding test" , new String (decode , StandardCharsets . UTF_8 ), input );
127127 }
128128
129129 @ Test
130130 public void testSafeCharEncodeDecodeObject () throws Exception {
131131 final PercentCodec percentCodec = new PercentCodec (null , true );
132132 final String input = "abc123_-.*" ;
133133 final Object encoded = percentCodec .encode ((Object ) input .getBytes (StandardCharsets .UTF_8 ));
134- final String encodedS = new String ((byte []) encoded , "UTF-8" );
134+ final String encodedS = new String ((byte []) encoded , StandardCharsets . UTF_8 );
135135 final Object decoded = percentCodec .decode (encoded );
136- final String decodedS = new String ((byte []) decoded , "UTF-8" );
136+ final String decodedS = new String ((byte []) decoded , StandardCharsets . UTF_8 );
137137 assertEquals ("Basic PercentCodec safe char encoding test" , input , encodedS );
138138 assertEquals ("Basic PercentCodec safe char decoding test" , input , decodedS );
139139 }
@@ -143,9 +143,9 @@ public void testUnsafeCharEncodeDecode() throws Exception {
143143 final PercentCodec percentCodec = new PercentCodec ();
144144 final String input = "\u03B1 \u03B2 \u03B3 \u03B4 \u03B5 \u03B6 % " ;
145145 final byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets .UTF_8 ));
146- final String encodedS = new String (encoded , "UTF-8" );
146+ final String encodedS = new String (encoded , StandardCharsets . UTF_8 );
147147 final byte [] decoded = percentCodec .decode (encoded );
148- final String decodedS = new String (decoded , "UTF-8" );
148+ final String decodedS = new String (decoded , StandardCharsets . UTF_8 );
149149 assertEquals ("Basic PercentCodec unsafe char encoding test" , "%CE%B1%CE%B2%CE%B3%CE%B4%CE%B5%CE%B6%25 " , encodedS );
150150 assertEquals ("Basic PercentCodec unsafe char decoding test" , input , decodedS );
151151 }
0 commit comments