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