blob: f724516cd10b572ebd03d46ca093a28bbe2ba837 (
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
41
42
43
44
45
46
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.http;
import java.io.IOException;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.vespa.config.ConfigKey;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
import static org.junit.Assert.assertTrue;
/**
* @author lulf
* @since 5.1
*/
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));
assertThat(request.getConfigKey(), is(configKey));
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() throws IOException {
HttpConfigRequest.createFromRequestV1(HttpRequest.createTestRequest(
"http://example.yahoo.com:19071/config/v1/vespa.config.cloud.sentinel/host-01.example.yahoo.com", GET));
}
}
|