aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/http
diff options
context:
space:
mode:
Diffstat (limited to 'configserver/src/test/java/com/yahoo/vespa/config/server/http')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java11
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigRequestTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java15
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java37
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java8
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java55
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java21
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java11
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java34
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java3
15 files changed, 81 insertions, 156 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java
index 3415facd714..20e52263350 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/ContentHandlerTestBase.java
@@ -11,10 +11,8 @@ import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
-import javax.annotation.Nullable;
import org.junit.Test;
-import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Collections2;
import com.yahoo.container.jdisc.HttpResponse;
@@ -37,7 +35,7 @@ public abstract class ContentHandlerTestBase extends SessionHandlerTest {
}
@Test
- public void require_that_nonexistant_file_returns_not_found() throws IOException {
+ public void require_that_nonexistant_file_returns_not_found() {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test2.txt");
assertNotNull(response);
assertThat(response.getStatus(), is(NOT_FOUND));
@@ -88,12 +86,7 @@ public abstract class ContentHandlerTestBase extends SessionHandlerTest {
protected abstract HttpResponse doRequest(HttpRequest.Method method, String path);
private String generateResultArray(String... files) {
- Collection<String> output = Collections2.transform(Arrays.asList(files), new Function<String, String>() {
- @Override
- public String apply(@Nullable String input) {
- return "\"" + baseUrl + input + "\"";
- }
- });
+ Collection<String> output = Collections2.transform(Arrays.asList(files), input -> "\"" + baseUrl + input + "\"");
StringBuilder sb = new StringBuilder();
sb.append("[");
sb.append(Joiner.on(",").join(output));
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
index 62ec451107d..d28aa804c6f 100644
--- 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
@@ -1,8 +1,6 @@
// 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;
@@ -17,7 +15,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class HttpConfigRequestTest {
@Test
@@ -39,7 +36,7 @@ public class HttpConfigRequestTest {
}
@Test
- public void require_that_request_can_be_created_with_advanced_uri() throws IOException {
+ 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));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java
index 54a3db3d94d..56391127b62 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpErrorResponseTest.java
@@ -12,7 +12,6 @@ import static com.yahoo.jdisc.http.HttpResponse.Status.*;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class HttpErrorResponseTest {
@Test
@@ -29,7 +28,7 @@ public class HttpErrorResponseTest {
}
@Test
- public void testThatHttpErrorResponseHasJsonContentType() throws IOException {
+ public void testThatHttpErrorResponseHasJsonContentType() {
HttpErrorResponse response = HttpErrorResponse.badRequest("Error doing something");
assertThat(response.getContentType(), is("application/json"));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
index a1fbbb57ce2..3ae98c1b8f2 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
@@ -6,7 +6,6 @@ import com.yahoo.config.codegen.DefParser;
import com.yahoo.config.codegen.InnerCNode;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.logging.AccessLog;
import com.yahoo.text.StringUtilities;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.ConfigPayload;
@@ -20,17 +19,14 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.HashSet;
-import java.util.concurrent.Executor;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
import static com.yahoo.jdisc.http.HttpResponse.Status.*;
-
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class HttpGetConfigHandlerTest {
private static final String configUri = "http://yahoo.com:8080/config/v1/foo.bar/myid";
@@ -41,12 +37,10 @@ public class HttpGetConfigHandlerTest {
@Before
public void setUp() {
mockRequestHandler = new MockRequestHandler();
- mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>() {{
+ mockRequestHandler.setAllConfigs(new HashSet<>() {{
add(new ConfigKey<>("bar", "myid", "foo"));
- }} );
- handler = new HttpGetConfigHandler(
- HttpGetConfigHandler.testOnlyContext(),
- mockRequestHandler);
+ }} );
+ handler = new HttpGetConfigHandler(HttpGetConfigHandler.testOnlyContext(), mockRequestHandler);
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java
index e8d4373842d..e2bd8a120e0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpHandlerTest.java
@@ -46,7 +46,7 @@ public class HttpHandlerTest {
private static class HttpTestHandler extends HttpHandler {
private RuntimeException exception;
- public HttpTestHandler(RuntimeException exception) {
+ HttpTestHandler(RuntimeException exception) {
super(HttpHandler.testOnlyContext());
this.exception = exception;
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java
index 25b9e66ceb3..9113978d58b 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.config.server.http;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
-import com.yahoo.container.logging.AccessLog;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.server.rpc.MockRequestHandler;
import com.yahoo.vespa.config.server.http.HttpListConfigsHandler.ListConfigsResponse;
@@ -13,7 +12,6 @@ import org.junit.Test;
import java.io.IOException;
import java.util.*;
-import java.util.concurrent.Executor;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
@@ -23,7 +21,6 @@ import static com.yahoo.jdisc.http.HttpRequest.Method.GET;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class HttpListConfigsHandlerTest {
@@ -34,9 +31,9 @@ public class HttpListConfigsHandlerTest {
@Before
public void setUp() {
mockRequestHandler = new MockRequestHandler();
- mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>() {{
+ mockRequestHandler.setAllConfigs(new HashSet<>() {{
add(new ConfigKey<>("bar", "conf/id/", "foo"));
- }} );
+ }} );
HttpListConfigsHandler.Context ctx = HttpListConfigsHandler.testOnlyContext();
handler = new HttpListConfigsHandler(ctx, mockRequestHandler);
namedHandler = new HttpListNamedConfigsHandler(ctx, mockRequestHandler);
@@ -51,14 +48,14 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_that_named_handler_can_be_created() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v1/foo.bar/conf/id/", GET);
- req.getJDiscRequest().parameters().put("http.path", Arrays.asList("foo.bar"));
+ req.getJDiscRequest().parameters().put("http.path", List.of("foo.bar"));
HttpResponse response = namedHandler.handle(req);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
@Test
public void require_child_listings_correct() {
- Set<ConfigKey<?>> keys = new LinkedHashSet<ConfigKey<?>>() {{
+ Set<ConfigKey<?>> keys = new LinkedHashSet<>() {{
add(new ConfigKey<>("name1", "id/1", "ns1"));
add(new ConfigKey<>("name1", "id/1", "ns1"));
add(new ConfigKey<>("name1", "id/2", "ns1"));
@@ -74,7 +71,7 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_url_building_and_mimetype_correct() {
- HttpListConfigsHandler.ListConfigsResponse resp = new ListConfigsResponse(new HashSet<ConfigKey<?>>(), null, "http://foo.com/config/v1/", true);
+ HttpListConfigsHandler.ListConfigsResponse resp = new ListConfigsResponse(new HashSet<>(), null, "http://foo.com/config/v1/", true);
assertEquals(resp.toUrl(new ConfigKey<>("myconfig", "my/id", "mynamespace"), true), "http://foo.com/config/v1/mynamespace.myconfig/my/id");
assertEquals(resp.toUrl(new ConfigKey<>("myconfig", "my/id", "mynamespace"), false), "http://foo.com/config/v1/mynamespace.myconfig/my/id/");
assertEquals(resp.getContentType(), "application/json");
@@ -96,7 +93,7 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_correct_error_response_on_no_model() throws IOException {
- mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>());
+ mockRequestHandler.setAllConfigs(new HashSet<>());
HttpResponse response = namedHandler.handle(HttpRequest.createTestRequest("http://yahoo.com:8080/config/v1/foo.bar/myid/", GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, NOT_FOUND,
HttpErrorResponse.errorCodes.NOT_FOUND,
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java
index 0381af57cc3..9a326a18dd5 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java
@@ -6,7 +6,6 @@ import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
-import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Capacity;
import com.yahoo.config.provision.ClusterSpec;
@@ -33,14 +32,13 @@ import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.session.SessionContext;
import com.yahoo.vespa.config.server.session.SessionFactory;
-import com.yahoo.vespa.config.server.session.SessionPreparer;
-import com.yahoo.vespa.config.server.session.SessionTest;
import com.yahoo.vespa.flags.InMemoryFlagSource;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Collection;
import java.util.List;
@@ -80,16 +78,13 @@ public class SessionHandlerTest {
public static String getRenderedString(HttpResponse response) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.render(baos);
- return baos.toString("UTF-8");
+ return baos.toString(StandardCharsets.UTF_8);
}
public static class MockSession extends LocalSession {
- private final InMemoryFlagSource flagSource;
public boolean doVerboseLogging = false;
public Session.Status status;
- private final SessionPreparer preparer;
- private final ApplicationPackage app;
private ConfigChangeActions actions = new ConfigChangeActions();
private long createTime = System.currentTimeMillis() / 1000;
private ApplicationId applicationId;
@@ -99,10 +94,7 @@ public class SessionHandlerTest {
}
private MockSession(long id, ApplicationPackage app, InMemoryFlagSource flagSource) {
- super(TenantName.defaultName(), id, null, new SessionContext(null, new MockSessionZKClient(MockApplicationPackage.createEmpty()), null, null, new HostRegistry<>(), flagSource));
- this.app = app;
- this.preparer = new SessionTest.MockSessionPreparer();
- this.flagSource = flagSource;
+ super(TenantName.defaultName(), id, null, new SessionContext(app, new MockSessionZKClient(app), null, null, new HostRegistry<>(), flagSource));
}
public MockSession(long sessionId, ApplicationPackage applicationPackage, long createTime) {
@@ -140,31 +132,17 @@ public class SessionHandlerTest {
@Override
public Transaction createDeactivateTransaction() {
- return new DummyTransaction().add((DummyTransaction.RunnableOperation) () -> {
- status = Status.DEACTIVATE;
- });
+ return new DummyTransaction().add((DummyTransaction.RunnableOperation) () -> status = Status.DEACTIVATE);
}
@Override
public Transaction createActivateTransaction() {
- return new DummyTransaction().add((DummyTransaction.RunnableOperation) () -> {
- status = Status.ACTIVATE;
- });
+ return new DummyTransaction().add((DummyTransaction.RunnableOperation) () -> status = Status.ACTIVATE);
}
@Override
public ApplicationFile getApplicationFile(Path relativePath, Mode mode) {
- if (mode == Mode.WRITE) {
- status = Status.NEW;
- }
- if (preparer == null) {
- return null;
- }
- ApplicationPackage pkg = app;
- if (pkg == null) {
- return null;
- }
- return pkg.getFile(relativePath);
+ return this.applicationPackage.getFile(relativePath);
}
@Override
@@ -205,8 +183,7 @@ public class SessionHandlerTest {
public File applicationPackage;
@Override
- public LocalSession createSession(File applicationDirectory, ApplicationId applicationId,
- TimeoutBudget timeoutBudget) {
+ public LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget) {
createCalled = true;
if (doThrow) {
throw new RuntimeException("foo");
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
index c6a8e1f2f9d..b7f55aa0670 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
@@ -53,17 +53,17 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
tenantRepository.addTenant(TenantBuilder.create(componentRegistry, tenantName1));
tenantRepository.addTenant(TenantBuilder.create(componentRegistry, tenantName2));
- session2 = new MockSession(2l, FilesApplicationPackage.fromFile(new File("src/test/apps/content")));
+ session2 = new MockSession(2, FilesApplicationPackage.fromFile(new File("src/test/apps/content")));
Tenant tenant1 = tenantRepository.getTenant(tenantName1);
tenant1.getLocalSessionRepo().addSession(session2);
tenant1.getApplicationRepo().createApplication(idTenant1);
- tenant1.getApplicationRepo().createPutTransaction(idTenant1, 2l).commit();
+ tenant1.getApplicationRepo().createPutTransaction(idTenant1, 2).commit();
- MockSession session3 = new MockSession(3l, FilesApplicationPackage.fromFile(new File("src/test/apps/content2")));
+ MockSession session3 = new MockSession(3, FilesApplicationPackage.fromFile(new File("src/test/apps/content2")));
Tenant tenant2 = tenantRepository.getTenant(tenantName2);
tenant2.getLocalSessionRepo().addSession(session3);
tenant2.getApplicationRepo().createApplication(idTenant2);
- tenant2.getApplicationRepo().createPutTransaction(idTenant2, 3l).commit();
+ tenant2.getApplicationRepo().createPutTransaction(idTenant2, 3).commit();
handler = new ApplicationHandler(ApplicationHandler.testOnlyContext(),
Zone.defaultZone(),
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
index bc583c64206..fb09aa99039 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
@@ -44,9 +44,9 @@ public class HttpGetConfigHandlerTest {
@Before
public void setUp() {
mockRequestHandler = new MockRequestHandler();
- mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>() {{
+ mockRequestHandler.setAllConfigs(new HashSet<>() {{
add(new ConfigKey<>("bar", "myid", "foo"));
- }} );
+ }} );
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
TenantRepository tenantRepository = new TenantRepository(componentRegistry, false);
tenantRepository.addTenant(TenantBuilder.create(componentRegistry, tenant).withRequestHandler(mockRequestHandler));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java
index 750ad1c9fc0..7789c5d88db 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java
@@ -41,9 +41,9 @@ public class HttpListConfigsHandlerTest {
@Before
public void setUp() {
mockRequestHandler = new MockRequestHandler();
- mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>() {{
+ mockRequestHandler.setAllConfigs(new HashSet<>() {{
add(new ConfigKey<>("bar", "conf/id", "foo"));
- }} );
+ }} );
TenantName tenantName = TenantName.from("mytenant");
TenantRepository tenantRepository = new TenantRepository(componentRegistry, false);
TenantBuilder tenantBuilder = TenantBuilder.create(componentRegistry, tenantName)
@@ -73,7 +73,7 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_that_named_handler_can_be_created() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/foo.bar/conf/id/", GET);
- req.getJDiscRequest().parameters().put("http.path", Arrays.asList("foo.bar"));
+ req.getJDiscRequest().parameters().put("http.path", List.of("foo.bar"));
HttpResponse response = namedHandler.handle(req);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
@@ -81,14 +81,14 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_that_named_handler_can_be_created_from_full_appid() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/environment/prod/region/myregion/instance/myinstance/foo.bar/conf/id/", GET);
- req.getJDiscRequest().parameters().put("http.path", Arrays.asList("foo.bar"));
+ req.getJDiscRequest().parameters().put("http.path", List.of("foo.bar"));
HttpResponse response = namedHandler.handle(req);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
@Test
public void require_child_listings_correct() {
- Set<ConfigKey<?>> keys = new LinkedHashSet<ConfigKey<?>>() {{
+ Set<ConfigKey<?>> keys = new LinkedHashSet<>() {{
add(new ConfigKey<>("name1", "id/1", "ns1"));
add(new ConfigKey<>("name1", "id/1", "ns1"));
add(new ConfigKey<>("name1", "id/2", "ns1"));
@@ -104,7 +104,7 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_url_building_and_mimetype_correct() {
- ListConfigsResponse resp = new ListConfigsResponse(new HashSet<ConfigKey<?>>(), null, "http://foo.com/config/v2/tenant/mytenant/application/mya/", true);
+ ListConfigsResponse resp = new ListConfigsResponse(new HashSet<>(), null, "http://foo.com/config/v2/tenant/mytenant/application/mya/", true);
assertEquals(resp.toUrl(new ConfigKey<>("myconfig", "my/id", "mynamespace"), true), "http://foo.com/config/v2/tenant/mytenant/application/mya/mynamespace.myconfig/my/id");
assertEquals(resp.toUrl(new ConfigKey<>("myconfig", "my/id", "mynamespace"), false), "http://foo.com/config/v2/tenant/mytenant/application/mya/mynamespace.myconfig/my/id/");
assertEquals(resp.toUrl(new ConfigKey<>("myconfig", "", "mynamespace"), false), "http://foo.com/config/v2/tenant/mytenant/application/mya/mynamespace.myconfig");
@@ -128,7 +128,7 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_correct_error_response_on_no_model() throws IOException {
- mockRequestHandler.setAllConfigs(new HashSet<ConfigKey<?>>());
+ mockRequestHandler.setAllConfigs(new HashSet<>());
HttpResponse response = namedHandler.handle(HttpRequest.createTestRequest("http://yahoo.com:8080/config/v2/tenant/mytenant/application/myapplication/foo.bar/myid/", GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, NOT_FOUND,
HttpErrorResponse.errorCodes.NOT_FOUND,
@@ -137,7 +137,7 @@ public class HttpListConfigsHandlerTest {
@Test
public void require_correct_configid_parent() {
- assertEquals(ListConfigsResponse.parentConfigId(null), null);
+ assertNull(ListConfigsResponse.parentConfigId(null));
assertEquals(ListConfigsResponse.parentConfigId("foo"), "");
assertEquals(ListConfigsResponse.parentConfigId(""), "");
assertEquals(ListConfigsResponse.parentConfigId("/"), "");
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
index 7fa417ea287..52ecc5e2bae 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
@@ -36,7 +36,6 @@ import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.LocalSessionRepo;
import com.yahoo.vespa.config.server.session.MockSessionZKClient;
import com.yahoo.vespa.config.server.session.RemoteSession;
-import com.yahoo.vespa.config.server.session.RemoteSessionRepo;
import com.yahoo.vespa.config.server.session.Session;
import com.yahoo.vespa.config.server.session.SessionContext;
import com.yahoo.vespa.config.server.session.SessionTest;
@@ -57,7 +56,6 @@ import org.junit.rules.TemporaryFolder;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
-import java.time.Clock;
import java.util.Collections;
import java.util.Optional;
@@ -81,7 +79,6 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
private final InMemoryFlagSource flagSource = new InMemoryFlagSource();
private Curator curator;
- private RemoteSessionRepo remoteSessionRepo;
private LocalSessionRepo localRepo;
private TenantApplications applicationRepo;
private MockProvisioner hostProvisioner;
@@ -95,7 +92,6 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Before
public void setup() {
- remoteSessionRepo = new RemoteSessionRepo(tenantName);
curator = new MockCurator();
modelFactory = new VespaModelFactory(new NullConfigModelRegistry());
componentRegistry = new TestComponentRegistry.Builder()
@@ -110,7 +106,6 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
TenantBuilder tenantBuilder = TenantBuilder.create(componentRegistry, tenantName)
.withSessionFactory(new MockSessionFactory())
.withLocalSessionRepo(localRepo)
- .withRemoteSessionRepo(remoteSessionRepo)
.withApplicationRepo(applicationRepo);
tenantRepository.addTenant(tenantBuilder);
handler = createHandler();
@@ -118,15 +113,15 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Test
public void testThatPreviousSessionIsDeactivated() throws Exception {
- RemoteSession firstSession = activateAndAssertOK(90l, 0l);
- activateAndAssertOK(91l, 90l);
+ RemoteSession firstSession = activateAndAssertOK(90, 0);
+ activateAndAssertOK(91, 90);
assertThat(firstSession.getStatus(), Is.is(Session.Status.DEACTIVATE));
}
@Test
public void testForceActivationWithActivationInBetween() throws Exception {
- activateAndAssertOK(90l, 0l);
- activateAndAssertOK(92l, 89l, "?force=true");
+ activateAndAssertOK(90, 0);
+ activateAndAssertOK(92, 89, "?force=true");
}
@Test
@@ -138,9 +133,9 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Test
public void testActivationWithBarrierTimeout() throws Exception {
// Needed so we can test that previous active session is still active after a failed activation
- activateAndAssertOK(90l, 0l);
+ activateAndAssertOK(90, 0);
((MockCurator) curator).timeoutBarrierOnEnter(true);
- ActivateRequest activateRequest = new ActivateRequest(91l, 90l, "", Clock.systemUTC()).invoke();
+ ActivateRequest activateRequest = new ActivateRequest(91, 90, "").invoke();
HttpResponse actResponse = activateRequest.getActResponse();
assertThat(actResponse.getStatus(), Is.is(INTERNAL_SERVER_ERROR));
}
@@ -153,7 +148,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
activateAndAssertOK(sessionId, 1);
sessionId++;
- ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "", componentRegistry.getClock()).invoke();
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "").invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
assertThat(message, actResponse.getStatus(), Is.is(CONFLICT));
@@ -164,7 +159,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Test
public void testAlreadyActivatedSession() throws Exception {
activateAndAssertOK(1, 0);
- HttpResponse response = handler.handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, 1l));
+ HttpResponse response = handler.handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, 1L));
String message = getRenderedString(response);
assertThat(message, response.getStatus(), Is.is(BAD_REQUEST));
assertThat(message, containsString("Session 1 is already active"));
@@ -177,8 +172,8 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Test
public void testActivationWithActivationInBetween() throws Exception {
- activateAndAssertOK(90l, 0l);
- activateAndAssertError(92l, 89l, componentRegistry.getClock(),
+ activateAndAssertOK(90, 0);
+ activateAndAssertError(92, 89,
Response.Status.CONFLICT, HttpErrorResponse.errorCodes.ACTIVATION_CONFLICT,
"tenant:" + tenantName + " app:default:default Cannot activate session 92 because the currently active session (90) has changed since session 92 was created (was 89 at creation time)");
}
@@ -186,9 +181,9 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
@Test
public void testActivationOfUnpreparedSession() throws Exception {
// Needed so we can test that previous active session is still active after a failed activation
- RemoteSession firstSession = activateAndAssertOK(90l, 0l);
+ RemoteSession firstSession = activateAndAssertOK(90, 0);
long sessionId = 91L;
- ActivateRequest activateRequest = new ActivateRequest(sessionId, 0l, Session.Status.NEW, "", componentRegistry.getClock()).invoke();
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, 0, Session.Status.NEW, "").invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
assertThat(actResponse.getStatus(), is(Response.Status.BAD_REQUEST));
@@ -209,7 +204,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
public void require_that_handler_gives_error_when_provisioner_activated_fails() throws Exception {
hostProvisioner = new FailingMockProvisioner();
hostProvisioner.activated = false;
- activateAndAssertError(1, 0, componentRegistry.getClock(), BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Cannot activate application");
+ activateAndAssertError(1, 0, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Cannot activate application");
assertFalse(hostProvisioner.activated);
}
@@ -219,9 +214,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
TenantRepository.getSessionsPath(tenantName).append(String.valueOf(sessionId)));
zkC.write(Collections.singletonMap(modelFactory.version(), new MockFileRegistry()));
zkC.write(AllocatedHosts.withHosts(Collections.emptySet()));
- RemoteSession session = new RemoteSession(tenantName, sessionId, componentRegistry, zkClient);
- remoteSessionRepo.addSession(session);
- return session;
+ return new RemoteSession(tenantName, sessionId, componentRegistry, zkClient);
}
private void addLocalSession(long sessionId, DeployData deployData, SessionZooKeeperClient zkc) throws IOException {
@@ -235,7 +228,7 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
}
private ActivateRequest activateAndAssertOKPut(long sessionId, long previousSessionId, String subPath) throws Exception {
- ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, subPath, componentRegistry.getClock());
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, subPath);
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
@@ -246,9 +239,9 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
return activateRequest;
}
- private void activateAndAssertErrorPut(long sessionId, long previousSessionId, Clock clock,
+ private void activateAndAssertErrorPut(long sessionId, long previousSessionId,
int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
- ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, "", clock);
+ ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, "");
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
@@ -275,24 +268,22 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
private DeployData deployData;
private ApplicationMetaData metaData;
private String subPath;
- private Clock clock;
- ActivateRequest(long sessionId, long previousSessionId, String subPath, Clock clock) {
- this(sessionId, previousSessionId, Session.Status.PREPARE, subPath, clock);
+ ActivateRequest(long sessionId, long previousSessionId, String subPath) {
+ this(sessionId, previousSessionId, Session.Status.PREPARE, subPath);
}
- ActivateRequest(long sessionId, long previousSessionId, Session.Status initialStatus, String subPath, Clock clock) {
+ ActivateRequest(long sessionId, long previousSessionId, Session.Status initialStatus, String subPath) {
this.sessionId = sessionId;
this.initialStatus = initialStatus;
this.deployData = new DeployData("foo",
"bar",
appName,
- 0l,
+ 0L,
false,
sessionId,
previousSessionId);
this.subPath = subPath;
- this.clock = clock;
}
public RemoteSession getSession() {
@@ -352,9 +343,9 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
assertThat(hostProvisioner.lastHosts.size(), is(1));
}
- private void activateAndAssertError(long sessionId, long previousSessionId, Clock clock, int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
+ private void activateAndAssertError(long sessionId, long previousSessionId, int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
hostProvisioner.activated = false;
- activateAndAssertErrorPut(sessionId, previousSessionId, clock, statusCode, errorCode, expectedError);
+ activateAndAssertErrorPut(sessionId, previousSessionId, statusCode, errorCode, expectedError);
assertFalse(hostProvisioner.activated);
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
index 42b3fadc0de..d4dd17ca280 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.time.Clock;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNotNull;
@@ -37,7 +36,6 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
private static final TenantName tenant = TenantName.from("contenttest");
private final TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
- private final Clock clock = componentRegistry.getClock();
private TenantRepository tenantRepository;
private SessionContentHandler handler = null;
@@ -59,10 +57,11 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
assertMkdir("/bar/brask/");
assertMkdir("/bar/brask/bram/");
assertMkdir("/brask/og/bram/");
- }// TODO: Enable when we have a predictable way of checking request body existence.
+ }
@Test
@Ignore
+ // TODO: Enable when we have a predictable way of checking request body existence.
public void require_that_mkdir_with_body_is_illegal(){
HttpResponse response = put("/foobio/", "foo");
assertNotNull(response);
@@ -70,15 +69,15 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
}
@Test
- public void require_that_nonexistant_session_returns_not_found() {
- HttpResponse response = doRequest(HttpRequest.Method.GET, "/test.txt", 2l);
+ public void require_that_nonexistent_session_returns_not_found() {
+ HttpResponse response = doRequest(HttpRequest.Method.GET, "/test.txt", 2);
assertNotNull(response);
assertThat(response.getStatus(), is(Response.Status.NOT_FOUND));
}
protected HttpResponse put(String path, String content) {
ByteArrayInputStream data = new ByteArrayInputStream(Utf8.toBytes(content));
- return doRequest(HttpRequest.Method.PUT, path, data);
+ return doRequest(HttpRequest.Method.PUT, path, 1, data);
}
@Test
@@ -95,7 +94,7 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
}
@Test
- public void require_that_nonexistant_file_returs_not_found_when_deleted() throws IOException {
+ public void require_that_nonexistent_file_returns_not_found_when_deleted() throws IOException {
assertDeleteFile(Response.Status.NOT_FOUND, "/test2.txt", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Session 1 does not contain a file 'test2.txt'\"}");
}
@@ -152,17 +151,13 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
}
protected HttpResponse doRequest(HttpRequest.Method method, String path) {
- return doRequest(method, path, 1l);
+ return doRequest(method, path, 1);
}
private HttpResponse doRequest(HttpRequest.Method method, String path, long sessionId) {
return handler.handle(SessionHandlerTest.createTestRequest(pathPrefix, method, Cmd.CONTENT, sessionId, path));
}
- private HttpResponse doRequest(HttpRequest.Method method, String path, InputStream data) {
- return doRequest(method, path, 1l, data);
- }
-
private HttpResponse doRequest(HttpRequest.Method method, String path, long sessionId, InputStream data) {
return handler.handle(SessionHandlerTest.createTestRequest(pathPrefix, method, Cmd.CONTENT, sessionId, path, data));
}
@@ -173,7 +168,7 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
new ApplicationRepository(tenantRepository,
new SessionHandlerTest.MockProvisioner(),
new OrchestratorMock(),
- clock),
+ componentRegistry.getClock()),
tenantRepository);
}
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
index 06e1c36b3f2..6d2c2d35ab9 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
@@ -26,7 +26,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.time.Clock;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -51,7 +50,6 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
private static final HashMap<String, String> postHeaders = new HashMap<>();
private final TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
- private final Clock clock = componentRegistry.getClock();
private String pathPrefix = "/application/v2/session/";
private String createdMessage = " created.\"";
@@ -179,13 +177,12 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
public void require_that_session_is_stored_in_repo() throws IOException {
File outFile = CompressedApplicationInputStreamTest.createTarFile();
createHandler().handle(post(outFile));
- assertNotNull(localSessionRepo.getSession(0l));
+ assertNotNull(localSessionRepo.getSession(0));
}
-
@Test
public void require_that_application_urls_can_be_given_as_from_parameter() throws Exception {
- localSessionRepo.addSession(new SessionHandlerTest.MockSession(2l, FilesApplicationPackage.fromFile(testApp)));
+ localSessionRepo.addSession(new SessionHandlerTest.MockSession(2, FilesApplicationPackage.fromFile(testApp)));
ApplicationId fooId = new ApplicationId.Builder()
.tenant(tenant)
.applicationName("foo")
@@ -194,7 +191,7 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
applicationRepo.createApplication(fooId);
applicationRepo.createPutTransaction(fooId, 2).commit();
assertFromParameter("3", "http://myhost:40555/application/v2/tenant/" + tenant + "/application/foo/environment/test/region/baz/instance/quux");
- localSessionRepo.addSession(new SessionHandlerTest.MockSession(5l, FilesApplicationPackage.fromFile(testApp)));
+ localSessionRepo.addSession(new SessionHandlerTest.MockSession(5, FilesApplicationPackage.fromFile(testApp)));
ApplicationId bioId = new ApplicationId.Builder()
.tenant(tenant)
.applicationName("foobio")
@@ -221,7 +218,7 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
new ApplicationRepository(tenantRepository,
new SessionHandlerTest.MockProvisioner(),
new OrchestratorMock(),
- clock),
+ componentRegistry.getClock()),
tenantRepository,
componentRegistry.getConfigserverConfig());
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
index ec64ef2e3ba..e201ce107bd 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java
@@ -46,9 +46,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import static com.yahoo.jdisc.Response.Status.*;
import static com.yahoo.jdisc.Response.Status.BAD_REQUEST;
+import static com.yahoo.jdisc.Response.Status.METHOD_NOT_ALLOWED;
import static com.yahoo.jdisc.Response.Status.NOT_FOUND;
+import static com.yahoo.jdisc.Response.Status.OK;
import static com.yahoo.vespa.config.server.http.HandlerTest.assertHttpStatusCodeErrorCodeAndMessage;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
@@ -70,7 +71,6 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
private String preparedMessage = " prepared.\"}";
private String tenantMessage = "";
- private RemoteSessionRepo remoteSessionRepo;
private TenantRepository tenantRepository;
@Before
@@ -80,11 +80,9 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
preparedMessage = " for tenant '" + tenant + "' prepared.\"";
tenantMessage = ",\"tenant\":\"" + tenant + "\"";
tenantRepository = new TenantRepository(componentRegistry, false);
- remoteSessionRepo = new RemoteSessionRepo(tenant);
TenantBuilder tenantBuilder = TenantBuilder.create(componentRegistry, tenant)
.withSessionFactory(new MockSessionFactory())
.withLocalSessionRepo(localRepo)
- .withRemoteSessionRepo(remoteSessionRepo)
.withApplicationRepo(TenantApplications.create(componentRegistry, new MockReloadHandler(), tenant));
tenantRepository.addTenant(tenantBuilder);
}
@@ -149,21 +147,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
assertThat(SessionHandlerTest.getRenderedString(response), containsString("debuglog"));
}
- /**
- * A mock remote session repo based on contents of local repo. Only works when there is just one session in local repo
- */
- // TODO: Fix this mess
- private SessionZooKeeperClient fromLocalSessionRepo(LocalSessionRepo localRepo) {
- SessionZooKeeperClient zooKeeperClient = null;
- for (LocalSession ls : localRepo.listSessions()) {
- zooKeeperClient = new MockSessionZKClient(curator, tenant, ls.getSessionId());
- if (ls.getStatus()!=null) zooKeeperClient.writeStatus(ls.getStatus());
- RemoteSession remSess = new RemoteSession(tenant, ls.getSessionId(),
- new TestComponentRegistry.Builder().curator(curator).build(),
- zooKeeperClient);
- remoteSessionRepo.addSession(remSess);
- }
- return zooKeeperClient;
+ private SessionZooKeeperClient createSessionZooKeeperClient(LocalSession session) {
+ return new MockSessionZKClient(curator, tenant, session.getSessionId());
}
@Test
@@ -173,7 +158,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
SessionHandler sessHandler = createHandler();
sessHandler.handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
session.setStatus(Session.Status.PREPARE);
- SessionZooKeeperClient zooKeeperClient = fromLocalSessionRepo(localRepo);
+ SessionZooKeeperClient zooKeeperClient = createSessionZooKeeperClient(session);
zooKeeperClient.writeStatus(Session.Status.PREPARE);
HttpResponse getResponse = sessHandler.handle(
SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.GET, Cmd.PREPARED, 1L));
@@ -187,7 +172,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
localRepo.addSession(session);
SessionHandler sessHandler = createHandler();
session.setStatus(Session.Status.NEW);
- SessionZooKeeperClient zooKeeperClient = fromLocalSessionRepo(localRepo);
+ SessionZooKeeperClient zooKeeperClient = createSessionZooKeeperClient(session);
zooKeeperClient.writeStatus(Session.Status.NEW);
HttpResponse getResponse = sessHandler.handle(
SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.GET, Cmd.PREPARED, 1L));
@@ -247,7 +232,6 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
LocalSessionRepo localRepoDefault = new LocalSessionRepo(defaultTenant, componentRegistry);
TenantBuilder defaultTenantBuilder = TenantBuilder.create(componentRegistry, defaultTenant)
.withLocalSessionRepo(localRepoDefault)
- .withRemoteSessionRepo(new RemoteSessionRepo(defaultTenant))
.withSessionFactory(new MockSessionFactory());
tenantRepository.addTenant(defaultTenantBuilder);
final SessionHandler handler = createHandler();
@@ -324,7 +308,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
}
@Test
- public void test_out_of_capacity_response() throws InterruptedException, IOException {
+ public void test_out_of_capacity_response() throws IOException {
String message = "Internal error";
SessionThrowingException session = new SessionThrowingException(new OutOfCapacityException(message));
localRepo.addSession(session);
@@ -337,7 +321,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
}
@Test
- public void test_that_nullpointerexception_gives_internal_server_error() throws InterruptedException, IOException {
+ public void test_that_nullpointerexception_gives_internal_server_error() throws IOException {
String message = "No nodes available";
SessionThrowingException session = new SessionThrowingException(new NullPointerException(message));
localRepo.addSession(session);
@@ -350,7 +334,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
}
@Test
- public void test_application_lock_failure() throws InterruptedException, IOException {
+ public void test_application_lock_failure() throws IOException {
String message = "Timed out after waiting PT1M to acquire lock '/provision/v1/locks/foo/bar/default'";
SessionThrowingException session =
new SessionThrowingException(new ApplicationLockException(new UncheckedTimeoutException(message)));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
index 6effa3359b1..9d843a1f2c6 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
@@ -6,6 +6,7 @@ import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.time.Clock;
import com.yahoo.config.provision.ApplicationId;
@@ -139,7 +140,7 @@ public class TenantHandlerTest {
private void assertResponseEquals(SessionResponse response, String payload) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.render(baos);
- assertEquals(baos.toString("UTF-8"), payload);
+ assertEquals(baos.toString(StandardCharsets.UTF_8), payload);
}
}