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
57
58
59
60
61
62
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.client.config;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
* @since 5.1.22
*/
public class EndpointTest {
@Test
public void testBasic() {
Endpoint endpoint = Endpoint.create("foo");
assertThat(endpoint.getHostname(), equalTo("foo"));
assertThat(endpoint.getPort(), equalTo(4080));
assertThat(endpoint.isUseSsl(), is(false));
}
@Test
public void testBasicWithHttpProtocolPrefix() {
Endpoint endpoint = Endpoint.create("http://foo");
assertThat(endpoint.getHostname(), equalTo("foo"));
}
@Test(expected = RuntimeException.class)
public void testBasicWithHttpsProtocolPrefix() {
Endpoint.create("https://foo");
}
@Test
public void testAdvanced() {
Endpoint endpoint = Endpoint.create("bar", 1234, true);
assertThat(endpoint.getHostname(), equalTo("bar"));
assertThat(endpoint.getPort(), equalTo(1234));
assertThat(endpoint.isUseSsl(), is(true));
}
@Test
public void testMethods() {
Endpoint a = Endpoint.create("a");
Endpoint b = Endpoint.create("b");
assertThat(a, not(equalTo(b)));
assertThat(a.hashCode(), not(equalTo(b.hashCode())));
Endpoint a2 = Endpoint.create("a");
assertThat(a, equalTo(a2));
assertThat(a.hashCode(), equalTo(a2.hashCode()));
a.toString();
}
}
|