aboutsummaryrefslogtreecommitdiffstats
path: root/config-proxy/src/test/java/com/yahoo/vespa
diff options
context:
space:
mode:
Diffstat (limited to 'config-proxy/src/test/java/com/yahoo/vespa')
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java105
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java19
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java16
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java6
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java8
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java14
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java44
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java25
-rw-r--r--config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java32
9 files changed, 153 insertions, 116 deletions
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
index f743c0ed231..a946704234d 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java
@@ -11,17 +11,17 @@ import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Target;
import com.yahoo.jrt.Transport;
import com.yahoo.vespa.config.RawConfig;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import java.io.File;
import java.io.IOException;
import java.time.Duration;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author hmusum
@@ -34,16 +34,16 @@ public class ConfigProxyRpcServerTest {
private static TestServer server;
private static TestClient client;
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
- @BeforeClass
+ @BeforeAll
public static void setup() throws ListenFailedException {
server = new TestServer();
client = new TestClient(server.listenPort());
}
- @AfterClass
+ @AfterAll
public static void teardown() {
client.close();
server.close();
@@ -55,7 +55,7 @@ public class ConfigProxyRpcServerTest {
}
@Test
- public void basic() {
+ void basic() {
ProxyServer proxy = createTestServer(new MockConfigSource());
Spec spec = new Spec("localhost", 12345);
ConfigProxyRpcServer server = new ConfigProxyRpcServer(proxy, new Supervisor(new Transport()), spec);
@@ -66,11 +66,11 @@ public class ConfigProxyRpcServerTest {
* Tests ping RPC command
*/
@Test
- public void testRpcMethodPing() {
+ void testRpcMethodPing() {
Request req = new Request("ping");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals(0, req.returnValues().get(0).asInt32());
}
@@ -79,13 +79,13 @@ public class ConfigProxyRpcServerTest {
* Tests listCachedConfig RPC command
*/
@Test
- public void testRpcMethodListCachedConfig() throws ListenFailedException {
+ void testRpcMethodListCachedConfig() throws ListenFailedException {
reset();
Request req = new Request("listCachedConfig");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(1, req.returnValues().size());
assertEquals(0, ret.length);
@@ -94,24 +94,24 @@ public class ConfigProxyRpcServerTest {
server.proxyServer().memoryCache().update(config);
req = new Request("listCachedConfig");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
ret = req.returnValues().get(0).asStringArray();
assertEquals(1, ret.length);
assertEquals(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," +
- config.getGeneration() + "," + config.getPayloadChecksums(),
- ret[0]);
+ config.getGeneration() + "," + config.getPayloadChecksums(),
+ ret[0]);
}
/**
* Tests listCachedConfig RPC command
*/
@Test
- public void testRpcMethodListCachedConfigFull() {
+ void testRpcMethodListCachedConfigFull() {
Request req = new Request("listCachedConfigFull");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(0, ret.length);
@@ -120,25 +120,25 @@ public class ConfigProxyRpcServerTest {
server.proxyServer().memoryCache().update(config);
req = new Request("listCachedConfigFull");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
ret = req.returnValues().get(0).asStringArray();
assertEquals(1, ret.length);
assertEquals(config.getNamespace() + "." + config.getName() + "," + config.getConfigId() + "," +
- config.getGeneration() + "," + config.getPayloadChecksums() + "," + config.getPayload().getData(),
- ret[0]);
+ config.getGeneration() + "," + config.getPayloadChecksums() + "," + config.getPayload().getData(),
+ ret[0]);
}
/**
* Tests listSourceConnections RPC command
*/
@Test
- public void testRpcMethodListSourceConnections() throws ListenFailedException {
+ void testRpcMethodListSourceConnections() throws ListenFailedException {
reset();
Request req = new Request("listSourceConnections");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
final String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
@@ -150,11 +150,11 @@ public class ConfigProxyRpcServerTest {
* Tests invalidateCache RPC command
*/
@Test
- public void testRpcMethodInvalidateCache() {
+ void testRpcMethodInvalidateCache() {
Request req = new Request("invalidateCache");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
final String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
@@ -166,10 +166,10 @@ public class ConfigProxyRpcServerTest {
* Tests getMode and setMode RPC commands
*/
@Test
- public void testRpcMethodGetModeAndSetMode() {
+ void testRpcMethodGetModeAndSetMode() {
Request req = new Request("getMode");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("default", req.returnValues().get(0).asString());
@@ -177,7 +177,7 @@ public class ConfigProxyRpcServerTest {
String mode = "memorycache";
req.parameters().add(new StringValue(mode));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
String[] ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
@@ -187,7 +187,7 @@ public class ConfigProxyRpcServerTest {
req = new Request("getMode");
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals(mode, req.returnValues().get(0).asString());
@@ -197,7 +197,7 @@ public class ConfigProxyRpcServerTest {
req.parameters().add(new StringValue(mode));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
ret = req.returnValues().get(0).asStringArray();
assertEquals(2, ret.length);
assertEquals("1", ret[0]);
@@ -209,7 +209,7 @@ public class ConfigProxyRpcServerTest {
* Tests updateSources RPC command
*/
@Test
- public void testRpcMethodUpdateSources() throws ListenFailedException {
+ void testRpcMethodUpdateSources() throws ListenFailedException {
reset();
Request req = new Request("updateSources");
@@ -217,7 +217,7 @@ public class ConfigProxyRpcServerTest {
String spec2 = "tcp/b:19070";
req.parameters().add(new StringValue(spec1 + "," + spec2));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("Updated config sources to: " + spec1 + "," + spec2, req.returnValues().get(0).asString());
@@ -227,7 +227,7 @@ public class ConfigProxyRpcServerTest {
req = new Request("updateSources");
req.parameters().add(new StringValue(spec1 + "," + spec2));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("Cannot update sources when in '" + Mode.ModeName.MEMORYCACHE.name().toLowerCase() + "' mode", req.returnValues().get(0).asString());
@@ -246,12 +246,12 @@ public class ConfigProxyRpcServerTest {
* Tests dumpCache RPC command
*/
@Test
- public void testRpcMethodDumpCache() throws IOException {
+ void testRpcMethodDumpCache() throws IOException {
Request req = new Request("dumpCache");
- String path = temporaryFolder.newFolder().getAbsolutePath();
+ String path = temporaryFolder.getAbsolutePath();
req.parameters().add(new StringValue(path));
client.invoke(req);
- assertFalse(req.errorMessage(), req.isError());
+ assertFalse(req.isError(), req.errorMessage());
assertEquals(1, req.returnValues().size());
assertEquals("success", req.returnValues().get(0).asString());
}
@@ -287,6 +287,15 @@ public class ConfigProxyRpcServerTest {
supervisor.transport().shutdown().join();
rpcServer.shutdown();
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
}
private static class TestClient implements AutoCloseable {
@@ -308,5 +317,23 @@ public class ConfigProxyRpcServerTest {
target.close();
supervisor.transport().shutdown().join();
}
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+ }
+
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
}
}
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
index 8a668b34fd0..7fbd6b2e68f 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java
@@ -1,12 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-import static org.junit.Assert.assertEquals;
+import java.io.File;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
@@ -15,17 +16,17 @@ public class DelayedResponseHandlerTest {
private final MockConfigSource source = new MockConfigSource();
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
- @Before
+ @BeforeEach
public void setup() {
source.clear();
source.put(ProxyServerTest.fooConfig.getKey(), ProxyServerTest.createConfigWithNextConfigGeneration(ProxyServerTest.fooConfig, 0));
}
@Test
- public void basic() {
+ void basic() {
ConfigTester tester = new ConfigTester();
DelayedResponses delayedResponses = new DelayedResponses();
MemoryCache memoryCache = new MemoryCache();
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
index d8c03961ddb..6bb9f74105c 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseTest.java
@@ -2,13 +2,13 @@
package com.yahoo.vespa.config.proxy;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -20,7 +20,7 @@ public class DelayedResponseTest {
private static final String namespace = "bar";
@Test
- public void basic() {
+ void basic() {
ConfigTester tester = new ConfigTester();
final long returnTime = System.currentTimeMillis();
final long timeout = 1;
@@ -51,7 +51,7 @@ public class DelayedResponseTest {
}
@Test
- public void testDelayedResponse() {
+ void testDelayedResponse() {
ConfigTester tester = new ConfigTester();
final long timeout = 20000;
JRTServerConfigRequest request1 = tester.createRequest("baz", configId, namespace, timeout);
@@ -69,9 +69,9 @@ public class DelayedResponseTest {
// New request, should have larger delay than the first
JRTServerConfigRequest request2 = tester.createRequest("baz", configId, namespace, timeout);
DelayedResponse delayed2 = new DelayedResponse(request2);
- assertTrue("delayed1=" + delayed1.getReturnTime() + ", delayed2=" +
- delayed2.getReturnTime() + ": delayed2 should be greater than delayed1",
- delayed2.getReturnTime() > delayed1.getReturnTime());
+ assertTrue(delayed2.getReturnTime() > delayed1.getReturnTime(),
+ "delayed1=" + delayed1.getReturnTime() + ", delayed2=" +
+ delayed2.getReturnTime() + ": delayed2 should be greater than delayed1");
// Test compareTo() method
assertEquals(0, delayed1.compareTo(delayed1));
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
index c9e714a11a3..6d9fa668bf5 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
public class DelayedResponsesTest {
@Test
- public void basic() throws InterruptedException {
+ void basic() throws InterruptedException {
ConfigTester tester = new ConfigTester();
DelayedResponses responses = new DelayedResponses();
DelayedResponse delayedResponse = new DelayedResponse(tester.createRequest("foo", "id", "bar", 10));
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
index d243d9c6dff..ff30a5b2381 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClientTest.java
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
public class MemoryCacheConfigClientTest {
@Test
- public void basic() {
+ void basic() {
MemoryCacheConfigClient client = new MemoryCacheConfigClient(new MemoryCache());
client.memoryCache().update(ConfigTester.fooConfig);
assertEquals(ConfigTester.fooConfig, client.getConfig(ConfigTester.fooConfig, null).orElseThrow());
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
index b0cba728a0c..2732a84527e 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java
@@ -8,14 +8,14 @@ import com.yahoo.vespa.config.ConfigPayload;
import com.yahoo.vespa.config.PayloadChecksums;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.Payload;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -47,7 +47,7 @@ public class MemoryCacheTest {
private Payload payload2;
private Payload payloadDifferentMd5;
- @Before
+ @BeforeEach
public void setup() {
ArrayList<String> defContent = new ArrayList<>();
defContent.add("bar string");
@@ -74,7 +74,7 @@ public class MemoryCacheTest {
}
@Test
- public void basic() {
+ void basic() {
MemoryCache cache = new MemoryCache();
cache.update(config);
@@ -97,7 +97,7 @@ public class MemoryCacheTest {
}
@Test
- public void testSameConfigNameDifferentMd5() {
+ void testSameConfigNameDifferentMd5() {
MemoryCache cache = new MemoryCache();
cache.update(config);
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
index 0e25e62b925..0277ea60b49 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java
@@ -8,18 +8,18 @@ import com.yahoo.vespa.config.ErrorCode;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequest;
import com.yahoo.vespa.config.protocol.Payload;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import java.io.File;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hmusum
@@ -38,10 +38,10 @@ public class ProxyServerTest {
fooConfig.getPayloadChecksums(), fooConfig.getGeneration(), false,
ErrorCode.UNKNOWN_DEFINITION, fooConfig.getDefContent(), Optional.empty());
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @TempDir
+ public File temporaryFolder;
- @Before
+ @BeforeEach
public void setup() {
source.clear();
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, 0));
@@ -49,13 +49,13 @@ public class ProxyServerTest {
proxy = createTestServer(source, client);
}
- @After
+ @AfterEach
public void shutdown() {
proxy.stop();
}
@Test
- public void basic() {
+ void basic() {
assertTrue(proxy.getMode().isDefault());
assertEquals(0, proxy.memoryCache().size());
@@ -72,7 +72,7 @@ public class ProxyServerTest {
* Tests that the proxy server RPC commands for setting and getting mode works..
*/
@Test
- public void testModeSwitch() {
+ void testModeSwitch() {
ProxyServer proxy = createTestServer(source, client);
assertTrue(proxy.getMode().isDefault());
@@ -106,7 +106,7 @@ public class ProxyServerTest {
* when it is found there.
*/
@Test
- public void testGetConfigAndCaching() {
+ void testGetConfigAndCaching() {
ConfigTester tester = new ConfigTester();
MemoryCache memoryCache = proxy.memoryCache();
assertEquals(0, memoryCache.size());
@@ -127,7 +127,7 @@ public class ProxyServerTest {
* it must be updated in cache.
*/
@Test
- public void testNoCachingOfErrorRequests() {
+ void testNoCachingOfErrorRequests() {
ConfigTester tester = new ConfigTester();
// Simulate an error response
source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, ErrorCode.INTERNAL_ERROR));
@@ -163,7 +163,7 @@ public class ProxyServerTest {
* When the config has been successfully retrieved it must be updated in cache.
*/
@Test
- public void testNoCachingOfEmptyConfig() {
+ void testNoCachingOfEmptyConfig() {
ConfigTester tester = new ConfigTester();
MemoryCache cache = proxy.memoryCache();
@@ -175,8 +175,8 @@ public class ProxyServerTest {
// Simulate an empty response
RawConfig emptyConfig = new RawConfig(fooConfig.getKey(), fooConfig.getDefMd5(), Payload.from("{}"),
- fooConfig.getPayloadChecksums(), 0, false,
- 0, fooConfig.getDefContent(), Optional.empty());
+ fooConfig.getPayloadChecksums(), 0, false,
+ 0, fooConfig.getDefContent(), Optional.empty());
source.put(fooConfig.getKey(), emptyConfig);
res = proxy.resolveConfig(tester.createRequest(fooConfig)).orElseThrow();
@@ -195,7 +195,7 @@ public class ProxyServerTest {
}
@Test
- public void testReconfiguration() {
+ void testReconfiguration() {
ConfigTester tester = new ConfigTester();
RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig)).orElseThrow();
assertEquals(ConfigTester.fooPayload.toString(), res.getPayload().toString());
@@ -210,7 +210,7 @@ public class ProxyServerTest {
}
@Test
- public void testReadingSystemProperties() {
+ void testReadingSystemProperties() {
ProxyServer.Properties properties = ProxyServer.getSystemProperties();
assertEquals(1, properties.configSources.length);
assertEquals(ProxyServer.DEFAULT_PROXY_CONFIG_SOURCES, properties.configSources[0]);
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java
index ada98f4b30e..b55d6fb9e26 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java
@@ -5,12 +5,13 @@ import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.RawConfig;
import com.yahoo.vespa.config.protocol.JRTConfigRequestFactory;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-import static org.junit.Assert.assertEquals;
+import java.io.File;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author hmusum
@@ -20,18 +21,18 @@ public class RpcConfigSourceClientTest {
private ResponseHandler responseHandler;
private RpcConfigSourceClient rpcConfigSourceClient;
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
- @Before
+ @BeforeEach
public void setup() {
responseHandler = new ResponseHandler(true);
rpcConfigSourceClient = new RpcConfigSourceClient(responseHandler, new MockConfigSource());
}
@Test
- public void basic() {
+ void basic() {
final RawConfig fooConfig = ProxyServerTest.fooConfig;
configUpdatedSendResponse(fooConfig);
// Nobody asked for the config, so no response sent
@@ -48,13 +49,13 @@ public class RpcConfigSourceClientTest {
}
@Test
- public void errorResponse() {
+ void errorResponse() {
configUpdatedSendResponse(ProxyServerTest.errorConfig);
assertSentResponses(0);
}
@Test
- public void it_does_not_send_old_config_in_response() {
+ void it_does_not_send_old_config_in_response() {
RawConfig fooConfigOldGeneration = ProxyServerTest.fooConfig;
RawConfig fooConfig = createConfigWithNextConfigGeneration(fooConfigOldGeneration);
@@ -74,7 +75,7 @@ public class RpcConfigSourceClientTest {
}
@Test
- public void it_does_send_config_with_generation_0_in_response() {
+ void it_does_send_config_with_generation_0_in_response() {
RawConfig fooConfigOldGeneration = ProxyServerTest.fooConfig;
RawConfig fooConfig = createConfigWithNextConfigGeneration(fooConfigOldGeneration, 1);
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java
index 3987ba176d7..a491a7b4fc4 100644
--- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java
+++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/CachedFilesMaintainerTest.java
@@ -2,18 +2,17 @@
package com.yahoo.vespa.config.proxy.filedistribution;
import com.yahoo.io.IOUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author hmusum
@@ -24,18 +23,18 @@ public class CachedFilesMaintainerTest {
private File cachedDownloads;
private CachedFilesMaintainer cachedFilesMaintainer;
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
- @Before
+ @BeforeEach
public void setup() throws IOException {
- cachedFileReferences = tempFolder.newFolder();
- cachedDownloads = tempFolder.newFolder();
+ cachedFileReferences = newFolder(tempFolder, "cachedFileReferences");
+ cachedDownloads = newFolder(tempFolder, "cachedDownloads");
cachedFilesMaintainer = new CachedFilesMaintainer(cachedFileReferences, cachedDownloads, Duration.ofMinutes(1));
}
@Test
- public void require_old_files_to_be_deleted() throws IOException {
+ void require_old_files_to_be_deleted() throws IOException {
runMaintainerAndAssertFiles(0, 0);
File fileReference = writeFile(cachedFileReferences, "fileReference");
@@ -72,4 +71,13 @@ public class CachedFilesMaintainerTest {
return file;
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}