aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
blob: f1be638468e58fb223a363dd45c1f1b8f1337ba4 (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
33
34
35
36
37
38
39
40
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.http;

import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.vespa.config.ConfigKey;

import org.junit.Test;

import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * @author Ulf Lilleengen
 */
public class HttpConfigRequestTest {
    @Test
    public void require_that_request_can_be_created() {
        final ConfigKey<?> configKey = new ConfigKey<>("foo", "myid", "bar");

        HttpConfigRequest request = HttpConfigRequest.createFromRequestV1(HttpRequest.createTestRequest("http://example.yahoo.com:8080/config/v1/" +
                configKey.getNamespace() + "." + configKey.getName() + "/" + configKey.getConfigId(), GET));
        assertEquals(configKey, request.getConfigKey());
        assertTrue(request.getDefContent().isEmpty());
    }

    @Test
    public void require_namespace_can_have_dots() {
        final ConfigKey<?> configKey = new ConfigKey<>("foo", "myid", "bar.baz");
        HttpConfigRequest request = HttpConfigRequest.createFromRequestV1(HttpRequest.createTestRequest("http://example.yahoo.com:8080/config/v1/" +
                configKey.getNamespace() + "." + configKey.getName() + "/" + configKey.getConfigId(), GET));
        assertEquals(request.getConfigKey().getNamespace(), "bar.baz");
    }

    @Test
    public void require_that_request_can_be_created_with_advanced_uri() {
        HttpConfigRequest.createFromRequestV1(HttpRequest.createTestRequest(
                "http://example.yahoo.com:19071/config/v1/vespa.config.cloud.sentinel/host-01.example.yahoo.com", GET));
    }
}