|
| 1 | +/* |
| 2 | + * Copyright (c) 2018 AsyncHttpClient Project. All rights reserved. |
| 3 | + * |
| 4 | + * This program is licensed to you under the Apache License Version 2.0, |
| 5 | + * and you may not use this file except in compliance with the Apache License Version 2.0. |
| 6 | + * You may obtain a copy of the Apache License Version 2.0 at |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0. |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, |
| 10 | + * software distributed under the Apache License Version 2.0 is distributed on an |
| 11 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. |
| 13 | + */ |
| 14 | +package org.asynchttpclient.util; |
| 15 | + |
| 16 | +import org.testng.annotations.Test; |
| 17 | + |
| 18 | +import static org.testng.Assert.assertEquals; |
| 19 | + |
| 20 | +public class Utf8UrlEncoderTest { |
| 21 | + @Test |
| 22 | + public void testBasics() { |
| 23 | + assertEquals(Utf8UrlEncoder.encodeQueryElement("foobar"), "foobar"); |
| 24 | + assertEquals(Utf8UrlEncoder.encodeQueryElement("a&b"), "a%26b"); |
| 25 | + assertEquals(Utf8UrlEncoder.encodeQueryElement("a+b"), "a%2Bb"); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testPercentageEncoding() { |
| 30 | + assertEquals(Utf8UrlEncoder.percentEncodeQueryElement("foobar"), "foobar"); |
| 31 | + assertEquals(Utf8UrlEncoder.percentEncodeQueryElement("foo*bar"), "foo%2Abar"); |
| 32 | + assertEquals(Utf8UrlEncoder.percentEncodeQueryElement("foo~b_ar"), "foo~b_ar"); |
| 33 | + } |
| 34 | +} |
0 commit comments