blob: ea4ee07391547afd80e60e88d410ca0d5471335a (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.component;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* @author bjorncs
*/
public class BindingPatternTest {
@Test
public void parses_valid_bindings_correctly() {
assertBindingParses("http://host:1234/path");
assertBindingParses("http://host/path");
assertBindingParses("http://host/");
assertBindingParses("*://*:*/*");
assertBindingParses("http://*/*");
assertBindingParses("https://*/my/path");
assertBindingParses("https://*/path/*");
assertBindingParses("https://host:*/path/*");
assertBindingParses("https://host:1234/*");
}
@Test
public void getters_returns_correct_components() {
{
BindingPattern pattern = SystemBindingPattern.fromPattern("http://host:1234/path/*");
assertEquals("http", pattern.scheme());
assertEquals("host", pattern.host());
assertEquals("1234", pattern.port().get());
assertEquals("/path/*", pattern.path());
}
{
BindingPattern pattern = SystemBindingPattern.fromPattern("https://*/path/v1/");
assertEquals("https", pattern.scheme());
assertEquals("*", pattern.host());
assertFalse(pattern.port().isPresent());
assertEquals("/path/v1/", pattern.path());
}
}
private static void assertBindingParses(String binding) {
BindingPattern pattern = SystemBindingPattern.fromPattern(binding);
String stringRepresentation = pattern.patternString();
assertEquals(
"Expected string representation of parsed binding to match original binding string",
binding, stringRepresentation);
}
}
|