summaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
new file mode 100644
index 00000000000..8525a152403
--- /dev/null
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java
@@ -0,0 +1,46 @@
+// Copyright 2016 Yahoo Inc. 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));
+ }
+}