aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/restapi/HttpURLTest.java
blob: 00da850d739abd717bddfe32979d22fc2bc1fa16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.restapi;

import org.junit.jupiter.api.Test;

import java.net.URI;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author jonmv
 */
class HttpURLTest {

    @Test
    void testConversion() {
        for (String uri : List.of("http://minimal",
                                  "http://empty.query?",
                                  "http://zero-port:0?no=path",
                                  "http://only-path/",
                                  "https://strange/queries?=&foo",
                                  "https://weirdness?=foo",
                                  "https://encoded/%3F%3D%26%2F?%3F%3D%26%2F=%3F%3D%26%2F",
                                  "https://host.at.domain:123/one/two/?three=four&five"))
            assertEquals(uri, HttpURL.from(URI.create(uri)).asURI().toString(),
                         "uri '" + uri + "' should be returned unchanged");
    }

}