blob: 58900174ee2fbc1673b12367af963cd8fbec3241 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;
import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.test.TestDriver;
import org.junit.Test;
import java.net.URI;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
*/
public class BindingNotFoundTestCase {
@Test
public void requireThatAccessorsWork() {
URI uri = URI.create("http://host/path");
BindingNotFoundException e = new BindingNotFoundException(uri);
assertEquals(uri, e.uri());
}
@Test
public void requireThatBindingNotFoundIsThrown() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
driver.activateContainer(driver.newContainerBuilder());
Request request = new Request(driver, URI.create("http://host/path"));
try {
request.connect(new MyResponseHandler());
fail();
} catch (BindingNotFoundException e) {
assertEquals(request.getUri(), e.uri());
}
request.release();
driver.close();
}
private class MyResponseHandler implements ResponseHandler {
@Override
public ContentChannel handleResponse(Response response) {
return null;
}
}
}
|