blob: ac2db906825d5ff50a28efe507d21e8ffdc5d787 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing;
import com.yahoo.cloud.config.LbServicesConfig;
import com.yahoo.config.subscription.CfgConfigPayloadBuilder;
import com.yahoo.yolean.Exceptions;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
/**
* @author mpolden
*/
public class TestUtil {
private static final Path testData = Paths.get("src/test/resources/");
public static RoutingTable readRoutingTable(String filename) {
List<String> lines = Exceptions.uncheck(() -> Files.readAllLines(testFile(filename),
StandardCharsets.UTF_8));
LbServicesConfig lbServicesConfig = new CfgConfigPayloadBuilder().deserialize(lines)
.toInstance(LbServicesConfig.class, "*");
return RoutingTable.from(lbServicesConfig, 42);
}
public static Path testFile(String filename) {
return testData.resolve(filename);
}
}
|