blob: f262821a638741da451cc9a6c2170a08b2c4be82 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.dns;
import com.yahoo.config.provision.zone.ZoneId;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author freva
*/
class DirectTargetTest {
@Test
void packing() {
List<DirectTarget> tests = List.of(
new LatencyDirectTarget(RecordData.from("foo.example.com"), ZoneId.from("prod.us-north-1")),
new WeightedDirectTarget(RecordData.from("bar.example.com"), ZoneId.from("prod.us-north-2"), 50));
for (var target : tests) {
DirectTarget unpacked = DirectTarget.unpack(target.pack());
assertEquals(target, unpacked);
}
List<RecordData> invalidData = List.of(RecordData.from(""), RecordData.from("foobar"));
for (var data : invalidData) {
try {
DirectTarget.unpack(data);
fail("Expected exception");
} catch (IllegalArgumentException ignored) { }
}
}
}
|