Package fitnesse.http

Examples of fitnesse.http.Response


  @Test
  public void testAuthenticationGetsCalled() throws Exception {
    context = FitNesseUtil.makeTestContext(context.root, new StoneWallAuthenticator());
    expediter = new FitNesseExpediter(socket, context);
    MockRequest request = new MockRequest();
    Response response = expediter.createGoodResponse(request);
    assertEquals(401, response.getStatus());
  }
View Full Code Here


  @Test
  public void testClosedSocketMidResponse() throws Exception {
    try {
      MockRequest request = new MockRequest();
      Response response = expediter.createGoodResponse(request);
      socket.close();
      response.sendTo(expediter);
    }
    catch (IOException e) {
      fail("no IOException should be thrown");
    }
  }
View Full Code Here

  }

  public void executeSingleCommand(String command, OutputStream out) throws Exception {
    Request request = new MockRequestBuilder(command).noChunk().build();
    FitNesseExpediter expediter = new FitNesseExpediter(new MockSocket(), context);
    Response response = expediter.createGoodResponse(request);
    response.withoutHttpHeaders();
    MockResponseSender sender = new MockResponseSender.OutputStreamSender(out);
    sender.doSending(response);
  }
View Full Code Here

      return saveEdits(context, request, page);
    }
  }

  private Response saveEdits(FitNesseContext context, Request request, WikiPage page) {
    Response response = new SimpleResponse();
    setData();
    VersionInfo commitRecord = page.commit(data);
    if (commitRecord != null) {
      response.addHeader("Current-Version", commitRecord.getName());
    }
    context.recentChanges.updateRecentChanges(page);

    if (request.hasInput("redirect"))
      response.redirect("", request.getInput("redirect").toString());
    else
      response.redirect(context.contextRoot, request.getResource());

    return response;
  }
View Full Code Here

public class DeleteFileResponder implements SecureResponder {
  public String resource;

  public Response makeResponse(FitNesseContext context, final Request request) throws IOException {
    Response response = new SimpleResponse();
    resource = request.getResource();
    String filename = (String) request.getInput("filename");

    final File pathName = new File(new File(context.getRootPagePath(), resource), filename);

    if (!FileResponder.isInFilesDirectory(new File(context.getRootPagePath()), pathName)) {
      return new ErrorResponder("Invalid path: " + pathName.getName()).makeResponse(context, request);
    }

    context.versionsController.delete(new FileVersion() {
      @Override
      public File getFile() {
        return pathName;
      }

      @Override
      public InputStream getContent() throws IOException {
        return null;
      }

      @Override
      public String getAuthor() {
        String user = request.getAuthorizationUsername();
        return user != null ? user : "";
      }

      @Override
      public Date getLastModificationTime() {
        return new Date();
      }
    });

    response.redirect(context.contextRoot, resource);
    return response;
  }
View Full Code Here

public abstract class BasicResponder implements SecureResponder {

  public Response makeResponse(FitNesseContext context, Request request) {
    WikiPage requestedPage = getRequestedPage(request, context);

    Response response;
    if (requestedPage == null)
      response = pageNotFoundResponse(context, request);
    else
      response = responseWith(contentFrom(context, request, requestedPage));
View Full Code Here

    this.responder = responder;
  }

  @Override
  public Response makeResponse(FitNesseContext context, Request request) throws Exception {
    Response response;
    for (Responder filter : filters) {
      response = filter.makeResponse(context, request);
      if (response != null) {
        return response;
      }
View Full Code Here

    }
    return false;
  }

  private Response createNotModifiedResponse() {
    Response response = new SimpleResponse();
    response.notModified(lastModifiedDate, Clock.currentDate());
    return response;
  }
View Full Code Here

import fitnesse.wiki.fs.FileVersion;

public class RenameFileResponder implements SecureResponder {

  public Response makeResponse(FitNesseContext context, final Request request) throws IOException {
    Response response = new SimpleResponse();
    String resource = request.getResource();
    File rootPath = new File(context.getRootPagePath());
    final File pathName = new File(rootPath, resource);

    if (!FileResponder.isInFilesDirectory(rootPath, pathName)) {
      return new ErrorResponder("Invalid path: " + resource).makeResponse(context, request);
    }

    final String oldFileName = (String) request.getInput("filename");
    final String newFileName = ((String) request.getInput("newName")).trim();

    final File oldFile = new File(pathName, oldFileName);
    final File newFile = new File(pathName, newFileName);

    if (!FileResponder.isInFilesDirectory(rootPath, oldFile)) {
      return new ErrorResponder("Invalid path: " + oldFileName).makeResponse(context, request);
    }

    if (!FileResponder.isInFilesDirectory(rootPath, newFile)) {
      return new ErrorResponder("Invalid path: " + newFileName).makeResponse(context, request);
    }

    context.versionsController.rename(new FileVersion() {

      @Override
      public File getFile() {
        return newFile;
      }

      @Override
      public InputStream getContent() throws IOException {
        return null;
      }

      @Override
      public String getAuthor() {
        String user = request.getAuthorizationUsername();
        return user != null ? user : "";
      }

      @Override
      public Date getLastModificationTime() {
        return new Date();
      }
    }, oldFile);

    response.redirect(context.contextRoot, resource);
    return response;
  }
View Full Code Here

        context.rootDirectoryName = FITNESSE_ROOT_PAGE;
        context.rootPath = SRC;
        context.doNotChunk = true;
        context.setRootPagePath();
        VelocityFactory.makeVelocityFactory(context);
        Response response = responder.makeResponse(context, request);
        final StringBuffer sb = new StringBuffer();
        ResponseSender sender = new ResponseSender() {

            @Override
            public void send(byte[] bytes) {
                sb.append(new String(bytes));
            }

            @Override
            public void close() {
            }

            @Override
            public Socket getSocket() {
                return null;
            }

        };
        response.readyToSend(sender);
        System.out.println();
        for (int i = 0; i < 20; i++) {
            // System.out.print(".");
            System.out.print(sb.toString());
            Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of fitnesse.http.Response

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.