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
54
55
56
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.application;
import org.junit.jupiter.api.Test;
import java.net.URI;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
*/
public class BindingMatchTestCase {
@Test
void requireThatAccessorsWork() {
Object obj = new Object();
UriPattern pattern = new UriPattern("http://*/*");
BindingMatch<Object> match = new BindingMatch<>(
pattern.match(URI.create("http://localhost:69/status.html")),
obj, pattern);
assertSame(obj, match.target());
assertEquals(3, match.groupCount());
assertEquals("localhost", match.group(0));
assertEquals("69", match.group(1));
assertEquals("status.html", match.group(2));
assertEquals(pattern, match.matched());
}
@Test
void requireThatConstructorArgumentsCanNotBeNull() {
try {
new BindingMatch<>(null, null, null);
fail();
} catch (NullPointerException e) {
}
try {
UriPattern pattern = new UriPattern("http://*/*");
new BindingMatch<>(pattern.match(URI.create("http://localhost/")), null, pattern);
fail();
} catch (NullPointerException e) {
}
try {
UriPattern pattern = new UriPattern("http://*/*");
new BindingMatch<>(null, new Object(), pattern);
fail();
} catch (NullPointerException e) {
}
}
}
|