1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.altindag.ssl.util;
18
19 import org.junit.jupiter.api.Test;
20 import java.net.URI;
21
22 import static org.assertj.core.api.Assertions.assertThatThrownBy;
23
24
25
26
27 class UriUtilsShould {
28
29 @Test
30 void throwExceptionWhenNullIsProvidedWhenValidateIsCalled() {
31 assertThatThrownBy(() -> UriUtils.validate(null))
32 .isInstanceOf(IllegalArgumentException.class)
33 .hasMessage("Host should be present");
34 }
35
36 @Test
37 void throwExceptionWhenHostIsProvidedWithoutAValidPortIsProvidedWhenValidateIsCalled() {
38 URI host = URI.create("https://localhost/");
39 assertThatThrownBy(() -> UriUtils.validate(host))
40 .isInstanceOf(IllegalArgumentException.class)
41 .hasMessage("Port should be defined for the given input: [https://localhost/]");
42 }
43
44 @Test
45 void throwExceptionWhenHostIsProvidedWithoutAValidHostnameIsProvidedWhenValidateIsCalled() {
46 URI host = URI.create("https:/");
47 assertThatThrownBy(() -> UriUtils.validate(host))
48 .isInstanceOf(IllegalArgumentException.class)
49 .hasMessage("Hostname should be defined for the given input: [https:/]");
50 }
51
52 }