forked from ucsd-cse15l-s23/docsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDocSearch.java
24 lines (22 loc) · 888 Bytes
/
TestDocSearch.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import static org.junit.Assert.*;
import java.io.File;
import org.junit.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.IOException;
public class TestDocSearch {
@Test
public void testIndex() throws URISyntaxException, IOException {
Handler h = new Handler("./technical/");
URI rootPath = new URI("http://localhost/");
assertEquals("There are 1391 total files to search.", h.handleRequest(rootPath));
}
@Test
public void testSearch() throws URISyntaxException, IOException {
Handler h = new Handler("./technical/");
String sep = File.separator;
URI rootPath = new URI("http://localhost/search?q=Resonance");
String expect = String.format("Found 2 paths:\n.%stechnical%sbiomed%sar615.txt\n.%stechnical%splos%sjournal.pbio.0020150.txt", sep, sep, sep, sep, sep, sep);
assertEquals(expect, h.handleRequest(rootPath));
}
}