Package fitnesse.http

Examples of fitnesse.http.SimpleResponse


    root = InMemoryPage.makeRoot("RooT");
  }

  @Test
  public void shouldBeAbleToMakeASimpleResponse() throws Exception {
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context,
        request);
    assertEquals(200, response.getStatus());
  }
View Full Code Here


    assertEquals(200, response.getStatus());

    request.setResource(resource);
    request.addHeader("If-Modified-Since", tomorrow);
    responder = (FileResponder) FileResponder.makeResponder(request, context.getRootPagePath());
    SimpleResponse notModifiedResponse = (SimpleResponse) responder.makeResponse(context, request);
    assertEquals(304, notModifiedResponse.getStatus());
    assertEquals("", notModifiedResponse.getContent());
    assertMatches(HTTP_DATE_REGEXP, notModifiedResponse.getHeader("Date"));
    assertNotNull(notModifiedResponse.getHeader("Cache-Control"));
    assertNull(notModifiedResponse.getHeader("Content-Type"));
  }
View Full Code Here

  @Test
  public void shouldReturnErrorPageIfCompareFails() throws Exception {
    when(mockedComparer.compare(firstFilePath, secondFilePath)).thenReturn(
        false);
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context,
        request);
    assertEquals(400, response.getStatus());
    assertHasRegexp(
        "These files could not be compared.  They might be suites, or something else might be wrong.",
        response.getContent());
  }
View Full Code Here

  @Test
  public void testNotFoundFile() throws Exception {
    request.setResource("files/something/that/aint/there");
    Responder notFoundResponder = FileResponder.makeResponder(request, context.getRootPagePath());
    SimpleResponse response = (SimpleResponse) notFoundResponder.makeResponse(context, request);
    assertEquals(404, response.getStatus());
    assertHasRegexp("files/something/that/aint/there", response.getContent());
  }
View Full Code Here

  public void shouldReturnErrorPageIfFilesAreInvalid() throws Exception {
    request = new MockRequest();
    request.addInput("TestResult_firstFile", "");
    request.addInput("TestResult_secondFile", "");
    request.setResource("TestFolder");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context,
        request);
    assertEquals(400, response.getStatus());
    assertHasRegexp("Compare Failed because the files were not found.",
        response.getContent());
  }
View Full Code Here

  public void shouldReturnErrorPageIfThereAreTooFewInputFiles()
      throws Exception {
    request = new MockRequest();
    request.addInput("TestResult_firstFile", "");
    request.setResource("TestFolder");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context,
        request);
    assertEquals(400, response.getStatus());
    assertHasRegexp(
        "Compare Failed because the wrong number of Input Files were given. Select two please.",
        response.getContent());
  }
View Full Code Here

  @Test
  public void shouldReturnErrorPageIfThereAreTooManyInputFiles()
      throws Exception {
    request.addInput("TestResult_thirdFakeFile", "");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context,
        request);
    assertEquals(400, response.getStatus());
    assertHasRegexp(
        "Compare Failed because the wrong number of Input Files were given. Select two please.",
        response.getContent());
  }
View Full Code Here

  @Test
  public void testContentOfPage() throws Exception {
    request.setResource("files");
    request.addInput("filename", "MyFile.txt");
    Responder responder = new DeleteConfirmationResponder();
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context, request);
    String content = response.getContent();

    assertSubString("deleteFile", content);
    assertSubString("Delete File", content);
    assertSubString("MyFile.txt", content);
  }
View Full Code Here

        response.getContent());
  }

  @Test
  public void shouldReturnAResponseWithResultContent() throws Exception {
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context,
        request);
    verify(mockedComparer).getResultContent();
    assertHasRegexp("This is the content", response.getContent());
  }
View Full Code Here

  }

  @Test
  public void testResponse() throws Exception {
    Responder responder = new ErrorResponder(new Exception("some error message"));
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context, new MockRequest());

    assertEquals(400, response.getStatus());

    String body = response.getContent();

    assertHasRegexp("<html>", body);
    assertHasRegexp("<body", body);
    assertHasRegexp("java.lang.Exception: some error message", body);
  }
View Full Code Here

TOP

Related Classes of fitnesse.http.SimpleResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.