forked from ucsd-cse15l-f23/chat-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandlerTests.java
More file actions
26 lines (24 loc) · 881 Bytes
/
HandlerTests.java
File metadata and controls
26 lines (24 loc) · 881 Bytes
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
import static org.junit.Assert.*;
import org.junit.*;
import java.net.URI;
public class HandlerTests {
@Test
public void handleRequest1() throws Exception {
ChatHandler h = new ChatHandler();
String url = "http://localhost:4000/chat?user=joe&message=hi";
URI input = new URI(url);
String expected = "joe: hi\n\n";
assertEquals(expected, h.handleRequest(input));
}
@Test
public void handleRequestMulti() throws Exception {
ChatHandler h = new ChatHandler();
String url1 = "http://localhost:4000/chat?user=onat&message=good%20luck";
String url2 = "http://localhost:4000/chat?user=edwin&message=with%20your%20demo!";
URI input1 = new URI(url1);
URI input2 = new URI(url2);
String expected = "onat: good luck\n\nedwin: with your demo!\n\n";
h.handleRequest(input1);
assertEquals(expected, h.handleRequest(input2));
}
}