Package fitnesse.http

Examples of fitnesse.http.SimpleResponse


  }

  @Test
  public void testWithMessage() throws Exception {
    Responder responder = new ErrorResponder("error Message");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context, new MockRequest());
    String body = response.getContent();

    assertSubString("error Message", body);
  }
View Full Code Here


  }

  @Test
  public void canAddFiltersForAResponder() throws Exception {
    Responder responder = factory.makeResponder(request);
    expectedFilterResponse = new SimpleResponse();
    Response response = responder.makeResponse(context, request);

    assertSame(expectedFilterResponse, response);
  }
View Full Code Here

  }

  @Test
  public void shouldCallResponderIfFilterReturnsNull() throws Exception {
    Responder responder = factory.makeResponder(request);
    expectedResponderResponse = new SimpleResponse();
    Response response = responder.makeResponse(context, request);

    assertSame(expectedResponderResponse, response);
  }
View Full Code Here

  @Test
  public void shouldExecuteMultipleFilters() throws Exception {
    factory.addFilter("mock", new AnotherMockFilter());
    Responder responder = factory.makeResponder(request);
    expectedAnotherFilterResponse = new SimpleResponse();
    Response response = responder.makeResponse(context, request);

    assertSame(expectedAnotherFilterResponse, response);
  }
View Full Code Here

public class StopTestResponder implements SecureResponder {

  String testId = null;
 
  public Response makeResponse(FitNesseContext context, Request request) {
    SimpleResponse response = new SimpleResponse();
   
    if (request.hasInput("id")) {
      testId = request.getInput("id").toString();
    }
   
    response.setContent(html(context));

    return response;
  }
View Full Code Here

  public void testResponse() throws Exception {
    MockRequest request = new MockRequest();
    request.setResource("some page");

    Responder responder = new NotFoundResponder();
    SimpleResponse response = (SimpleResponse) responder.makeResponse(context, request);

    assertEquals(404, response.getStatus());

    String body = response.getContent();

    assertHasRegexp("<html>", body);
    assertHasRegexp("<body", body);
    assertHasRegexp("some page", body);
    assertHasRegexp("Not Found", body);
View Full Code Here

    MockRequest request = new MockRequest();
    request.setResource("PageOne.PageTwo");
    WikiPage root = InMemoryPage.makeRoot("RooT");

    Responder responder = new NotFoundResponder();
    SimpleResponse response = (SimpleResponse) responder.makeResponse(FitNesseUtil.makeTestContext(root), request);

    assertHasRegexp("\"PageOne[.]PageTwo[?]edit\"", response.getContent());
  }
View Full Code Here

  @Test
  public void testPageNamesFromRoot() throws Exception {
    WikiPageUtil.addPage(root, pageOnePath, "");
    WikiPageUtil.addPage(root, pageTwoPath, "");
    request.setResource("");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(FitNesseUtil.makeTestContext(root), request);
    assertHasRegexp(pageOneName, response.getContent());
    assertHasRegexp(pageTwoName, response.getContent());
  }
View Full Code Here

  public void testPageNamesFromASubPage() throws Exception {
    WikiPage frontPage = WikiPageUtil.addPage(root, frontPagePath, "");
    WikiPageUtil.addPage(frontPage, pageOnePath, "");
    WikiPageUtil.addPage(frontPage, pageTwoPath, "");
    request.setResource("");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(FitNesseUtil.makeTestContext(root), request);
    assertHasRegexp(frontPageName, response.getContent());
    assertDoesntHaveRegexp(pageOneName, response.getContent());
    assertDoesntHaveRegexp(pageTwoName, response.getContent());

    request.setResource(frontPageName);
    response = (SimpleResponse) responder.makeResponse(FitNesseUtil.makeTestContext(root), request);
    assertHasRegexp(pageOneName, response.getContent());
    assertHasRegexp(pageTwoName, response.getContent());
    assertDoesntHaveRegexp(frontPageName, response.getContent());
  }
View Full Code Here

  public void jsonFormat() throws Exception {
    WikiPageUtil.addPage(root, pageOnePath, "");
    WikiPageUtil.addPage(root, pageTwoPath, "");
    request.setResource("");
    request.addInput("format", "json");
    SimpleResponse response = (SimpleResponse) responder.makeResponse(FitNesseUtil.makeTestContext(root), request);
    JSONArray actual = new JSONArray(response.getContent());
    assertEquals(2, actual.length());
    Set<String> actualSet = new HashSet<String>();
    actualSet.add(actual.getString(0));
    actualSet.add(actual.getString(1));
    Set<String> expectedSet = new HashSet<String>();
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.