示例#1
0
  @Test
  public void testRespondsCorrectlyToQueryString() throws IOException {
    String request = "GET /parameters?variable_1=Operators%20%3C HTTP/1.1\r\n\r\n";
    HashMap state = null;

    BufferedReader bufferedReader = new BufferedReader(new StringReader(request));
    RequestHandler requestHandler = new RequestHandler(bufferedReader, state);

    requestHandler.respondToRequest();

    assertEquals("variable_1 = Operators <", new String(requestHandler.getBody()));
  }
示例#2
0
  @Test
  public void testParsesQueryString() throws IOException {
    String request = "GET /parameters?variable_1=Operators%20%3C HTTP/1.1";
    HashMap state = null;

    BufferedReader bufferedReader = new BufferedReader(new StringReader(request));
    RequestHandler requestHandler = new RequestHandler(bufferedReader, state);

    requestHandler.parseRoute("/parameters?variable_1=Operators%20%3C");

    assertEquals("/parameters", requestHandler.getRoute());
    assertEquals("variable_1=Operators%20%3C", requestHandler.getQueryString());

    requestHandler.parseQueryString(requestHandler.getQueryString());

    assertEquals("variable_1 = Operators <", new String(requestHandler.getBody()));
  }