UrlEncoder implements TextEncoder, TextDecoder { public UrlEncoder setSlashEncoded( boolean slashEncoded ) { this.slashEncoded = slashEncoded; return this; }  @Override String encode( String text ); @Override String decode( String encodedText ); boolean isSlashEncoded(); UrlEncoder setSlashEncoded( boolean slashEncoded ); static final char ESCAPE_CHARACTER; }
@Test public void shouldNotEncodeForwardSlashByDefault() { checkEncoding("/", "%2f"); this.encoder.setSlashEncoded(false); checkForNoEncoding("/"); }
@Test public void shouldEncodePercent() { checkEncoding("%", "%25"); this.encoder.setSlashEncoded(false); checkEncoding("%", "%25"); }
@Test public void shouldNotEncodeAlphabeticCharacters() { checkForNoEncoding("abcdefghijklmnopqrstuvwxyz"); checkForNoEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); this.encoder.setSlashEncoded(false); checkForNoEncoding("abcdefghijklmnopqrstuvwxyz"); checkForNoEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); }
@Test public void shouldNotEncodeNumericCharacters() { checkForNoEncoding("0123456789"); this.encoder.setSlashEncoded(false); checkForNoEncoding("0123456789"); }
@Test public void shouldNotEncodeReservedPunctuationCharacters() { checkForNoEncoding("-_.!~*\'()"); this.encoder.setSlashEncoded(false); checkForNoEncoding("-_.!~*\'()"); }
@Test public void shouldEncodeAndDecodeUrlsCorrectly() { this.encoder.setSlashEncoded(false); checkEncoding("http: }
@Test @FixFor( "MODE-2258" ) public void shouldEncodeNonReservedNonAsciiCharacter() { this.encoder.setSlashEncoded(false); checkEncoding(":Тест:的", "%3a%d0%a2%d0%b5%d1%81%d1%82%3a%e7%9a%84"); }