-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathHttpVersionTest.java
More file actions
42 lines (35 loc) · 1.05 KB
/
HttpVersionTest.java
File metadata and controls
42 lines (35 loc) · 1.05 KB
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
package com.coderfromscratch.http;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class HttpVersionTest {
@Test
void getBestCompatibleVersionExactMatch() {
HttpVersion version = null;
try {
version = HttpVersion.getBestCompatibleVersion("HTTP/1.1");
} catch (BadHttpVersionException e) {
fail();
}
assertNotNull(version);
assertEquals(HttpVersion.HTTP_1_1, version);
}
@Test
void getBestCompatibleVersionBadFormat() {
try {
HttpVersion.getBestCompatibleVersion("http/1.1");
fail();
} catch (BadHttpVersionException e) {
}
}
@Test
void getBestCompatibleVersionHigherVersion() {
HttpVersion version = null;
try {
version = HttpVersion.getBestCompatibleVersion("HTTP/1.2");
assertNotNull(version);
assertEquals(HttpVersion.HTTP_1_1, version);
} catch (BadHttpVersionException e) {
fail();
}
}
}