package com.atlassian.stash.internal.web.util;

import org.junit.Test;

import java.net.URISyntaxException;

import static org.junit.Assert.assertEquals;

public class UriEncodingUtilsTest {
    @Test
    public void testEncodeURLComponent() throws URISyntaxException {
        assertEquals("a%5E%25%24%23%40bcdef_-_hi", UriEncodingUtils.encodeURIComponent("a^%$#@bcdef_-_hi", "UTF-8"));
        assertEquals("%E9%B2%81%E8%BF%85", UriEncodingUtils.encodeURIComponent("鲁迅", "UTF-8"));
    }

    @Test
    public void testEncodeComponentForCLI() throws URISyntaxException {
        assertEquals("a-b_c.d~e", UriEncodingUtils.encodeURIComponent("a-b_c.d~e", "UTF-8"));
        assertEquals("a%5E%25%24%23%40bcdef_-_hi", UriEncodingUtils.encodeURIComponent("a^%$#@bcdef_-_hi", "UTF-8"));
        assertEquals("%E9%B2%81%E8%BF%85", UriEncodingUtils.encodeURIComponent("鲁迅", "UTF-8"));
    }
}
