2020import static org .junit .Assert .assertEquals ;
2121import static org .junit .Assert .assertTrue ;
2222
23- import java .nio .charset .Charset ;
23+ import java .nio .charset .StandardCharsets ;
2424import java .util .Arrays ;
2525
2626import org .apache .commons .codec .DecoderException ;
@@ -38,7 +38,7 @@ public class PercentCodecTest {
3838 public void testBasicEncodeDecode () throws Exception {
3939 PercentCodec percentCodec = new PercentCodec ();
4040 final String input = "abcdABCD" ;
41- byte [] encoded = percentCodec .encode (input .getBytes (Charset . forName ( "UTF-8" ) ));
41+ byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets . UTF_8 ));
4242 final String encodedS = new String (encoded , "UTF-8" );
4343 byte [] decoded = percentCodec .decode (encoded );
4444 final String decodedS = new String (decoded , "UTF-8" );
@@ -51,15 +51,15 @@ public void testBasicEncodeDecode() throws Exception {
5151 public void testBasicSpace () throws Exception {
5252 PercentCodec percentCodec = new PercentCodec ();
5353 final String input = " " ;
54- byte [] encoded = percentCodec .encode (input .getBytes (Charset . forName ( "UTF-8" ) ));
55- Assert .assertArrayEquals ("%20" .getBytes (Charset . forName ( "UTF-8" ) ), encoded );
54+ byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets . UTF_8 ));
55+ Assert .assertArrayEquals ("%20" .getBytes (StandardCharsets . UTF_8 ), encoded );
5656 }
5757
5858 @ Test
5959 public void testConfigurablePercentEncoder () throws Exception {
6060 final String input = "abc123_-.*\u03B1 \u03B2 " ;
6161 PercentCodec percentCodec = new PercentCodec ("abcdef" .getBytes ("UTF-8" ), false );
62- byte [] encoded = percentCodec .encode (input .getBytes (Charset . forName ( "UTF-8" ) ));
62+ byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets . UTF_8 ));
6363 final String encodedS = new String (encoded , "UTF-8" );
6464 assertEquals ("Configurable PercentCodec encoding test" , "%61%62%63123_-.*%CE%B1%CE%B2" , encodedS );
6565 final byte [] decoded = percentCodec .decode (encoded );
@@ -117,7 +117,7 @@ public void testPercentEncoderDecoderWithNullOrEmptyInput() throws Exception {
117117 public void testPercentEncoderDecoderWithPlusForSpace () throws Exception {
118118 final String input = "a b c d" ;
119119 PercentCodec percentCodec = new PercentCodec (null , true );
120- byte [] encoded = percentCodec .encode (input .getBytes (Charset . forName ( "UTF-8" ) ));
120+ byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets . UTF_8 ));
121121 final String encodedS = new String (encoded , "UTF-8" );
122122 assertEquals ("PercentCodec plus for space encoding test" , "a+b+c+d" , encodedS );
123123 byte [] decode = percentCodec .decode (encoded );
@@ -128,7 +128,7 @@ public void testPercentEncoderDecoderWithPlusForSpace() throws Exception {
128128 public void testSafeCharEncodeDecodeObject () throws Exception {
129129 PercentCodec percentCodec = new PercentCodec (null , true );
130130 final String input = "abc123_-.*" ;
131- Object encoded = percentCodec .encode ((Object ) input .getBytes (Charset . forName ( "UTF-8" ) ));
131+ Object encoded = percentCodec .encode ((Object ) input .getBytes (StandardCharsets . UTF_8 ));
132132 final String encodedS = new String ((byte []) encoded , "UTF-8" );
133133 Object decoded = percentCodec .decode (encoded );
134134 final String decodedS = new String ((byte []) decoded , "UTF-8" );
@@ -140,7 +140,7 @@ public void testSafeCharEncodeDecodeObject() throws Exception {
140140 public void testUnsafeCharEncodeDecode () throws Exception {
141141 PercentCodec percentCodec = new PercentCodec ();
142142 final String input = "\u03B1 \u03B2 \u03B3 \u03B4 \u03B5 \u03B6 % " ;
143- byte [] encoded = percentCodec .encode (input .getBytes (Charset . forName ( "UTF-8" ) ));
143+ byte [] encoded = percentCodec .encode (input .getBytes (StandardCharsets . UTF_8 ));
144144 final String encodedS = new String (encoded , "UTF-8" );
145145 byte [] decoded = percentCodec .decode (encoded );
146146 final String decodedS = new String (decoded , "UTF-8" );
0 commit comments