Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
if (in == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
response.setStatus(200);
response.setStatus(HttpServletResponse.SC_OK);
ByteStreams.copy(in, response.getOutputStream());
}
} else {
Expand All @@ -116,10 +116,14 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
new BufferedReader(new InputStreamReader(in, "UTF-8")).lines().collect(Collectors.joining("\n"));
final String updatedTemplate =
htmlTemplate.replace(HELPER_SERVLET_TEMPLATE_CONFIG_JSON_VAR, json);
if (resource.equals("/")) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}

response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.setStatus(200);
response.getOutputStream().print(updatedTemplate);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.grid.web.servlet.console.ConsoleServlet;
import org.openqa.testing.FakeHttpServletResponse;
import org.seleniumhq.jetty9.server.handler.ContextHandler;
Expand Down Expand Up @@ -77,11 +74,16 @@ public void testGetHelpPageAsset() throws IOException, ServletException {
assertTrue(response.getBody().contains("#help-heading #logo"));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void testNoSuchAsset() throws IOException, ServletException {
// will result in a call to sendError ..
// FakeHttpServlet will then turn that into an UnsupportedOperationException
sendCommand("GET", "/assets/foo.bar");
FakeHttpServletResponse response = sendCommand("GET", "/assets/foo.bar");
assertEquals(HttpServletResponse.SC_NOT_FOUND, response.getStatus());
}

@Test
public void testAccessRoot() throws IOException, ServletException {
FakeHttpServletResponse response = sendCommand("GET", "/");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void sendError(int i, String s) {
}

public void sendError(int i) {
throw new UnsupportedOperationException();
setStatus(i);
}

public void sendRedirect(String s) {
Expand Down