forked from ucsd-cse15l-f22/skill-demo1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDocSearch.java
27 lines (25 loc) · 1.07 KB
/
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
24
25
26
27
import static org.junit.Assert.*;
import org.junit.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class TestDocSearch {
@Test
public void testIndex() throws URISyntaxException, IOException {
Handler h = new Handler("./technical/");
URI rootPath = new URI("http://localhost/");
assertEquals("There are 1 total files to search.", h.handleRequest(rootPath));
}
@Test
public void testSearch() throws URISyntaxException, IOException {
Handler h = new Handler("./technical/");
URI rootPath = new URI("http://localhost/search?q=taxation");
Path path1 = Paths.get("./technical/biomed/1471-2296-3-3.txt");
Path path2 = Paths.get("./technical/government/Gen_Account_Office/d01591sp.txt");
Path path3 = Paths.get("./technical/plos/journal.pbio.0020052.txt");
String expect = String.format("Found 3 paths:\n%s\n%s\n%s", path1, path2, path3);
assertEquals(expect, h.handleRequest(rootPath));
}
}