Commit 4652d3e6 authored by TheBeggs's avatar TheBeggs

Add WebServer tests

parent f0628985
......@@ -2,8 +2,8 @@ package ic.doc;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
public class QueryProcessorTest {
......
package ic.doc;
import org.junit.Test;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import static org.mockito.Mockito.*;
public class WebServerTest {
@Test
public void returnsCorrectFormat() throws Exception {
HttpServletRequest mockedReq = mock(HttpServletRequest.class);
HttpServletResponse mockedResp = mock(HttpServletResponse.class);
PrintWriter mockedWriter = mock(PrintWriter.class);
when(mockedReq.getParameter("q")).thenReturn("test search query");
when(mockedReq.getParameter("format")).thenReturn("Markdown");
when(mockedResp.getWriter()).thenReturn(mockedWriter);
WebServer.Website testSite = new WebServer.Website();
testSite.doGet(mockedReq, mockedResp);
verify(mockedResp, times(1)).setContentType("text/markdown");
verify(mockedResp, times(1)).setHeader("Content-Disposition", "attachment;filename=result.md");
verify(mockedResp, times(1)).getWriter();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment