コード例 #1
0
 private boolean isValidLinkPathName(String linkPath) throws Exception {
   if (isFilePath(linkPath) && !isValidDirectoryPath(linkPath)) {
     String message =
         "Cannot create link to the file system path '"
             + linkPath
             + "'."
             + " The canonical file system path used was ;"
             + createFileFromPath(linkPath).getCanonicalPath()
             + "'."
             + " Either it doesn't exist or it's not a directory.";
     response = new ErrorResponder(message).makeResponse(context, null);
     response.setStatus(404);
     return false;
   } else if (!isFilePath(linkPath) && isInternalPageThatDoesntExist(linkPath)) {
     response =
         new ErrorResponder(
                 "The page to which you are attempting to link, "
                     + HtmlUtil.escapeHTML(linkPath)
                     + ", doesn't exist.")
             .makeResponse(context, null);
     response.setStatus(404);
     return false;
   }
   return true;
 }
コード例 #2
0
  @Test
  public void testRenameFailWhenNonSym() throws Exception {
    prepareSymlinkOnPageOne();
    request.addInput("newname", "ChildOne");
    Response response = invokeResponder();

    assertEquals(412, response.getStatus());
  }
コード例 #3
0
  public void testSuccess() throws Exception {
    int ticket = dealer.seekingSocket(seeker);
    request.addInput("ticket", ticket + "");
    Response response = responder.makeResponse(context, request);
    response.sendTo(sender);

    assertEquals("", sender.sentData());
  }
コード例 #4
0
  public void testMissingSeeker() throws Exception {
    request.addInput("ticket", "123");
    Response response = responder.makeResponse(context, request);
    response.sendTo(sender);

    assertHasRegexp(
        "There are no clients waiting for a socket with ticketNumber 123", sender.sentData());
    assertTrue(sender.isClosed());
    assertEquals(404, response.getStatus());
  }
コード例 #5
0
  @Test
  public void linkNameShouldBeAValidWikiWordWhenRenaming() throws Exception {
    prepareSymlinkOnPageOne();
    request.addInput("newname", "New+link");
    Response response = invokeResponder();

    assertEquals(412, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString("WikiWord", content);
  }
コード例 #6
0
  @Test
  public void linkNameShouldBeAValidWikiWord() throws Exception {
    request.addInput("linkName", "Sym+link");
    request.addInput("linkPath", "PageTwo");
    Response response = invokeResponder();

    assertEquals(412, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString("WikiWord", content);
  }
コード例 #7
0
  @Test
  public void testNoPageAtPath() throws Exception {
    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "NonExistingPage");
    Response response = invokeResponder();

    assertEquals(404, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString("doesn't exist", content);
    assertSubString("Error Occurred", content);
  }
コード例 #8
0
  @Test
  public void testAddFailWhenLinkPathIsInvalid() throws Exception {
    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "PageOne PageTwo");
    Response response = invokeResponder();

    assertEquals(404, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString("doesn't exist", content);
    assertSubString("Error Occurred", content);
  }
コード例 #9
0
  @Test
  public void testSubmitFormForLinkToExternalRootThatsMissing() throws Exception {
    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "file:/testDir/ExternalRoot");
    Response response = invokeResponder();

    assertEquals(404, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString(
        "Cannot create link to the file system path 'file:/testDir/ExternalRoot'.", content);
    assertSubString("Error Occurred", content);
  }
コード例 #10
0
  @Test
  public void testAddFailWhenPageAlreadyHasNonSymChild() throws Exception {
    WikiPageUtil.addPage(pageOne, PathParser.parse("SymLink"), "");

    request.addInput("linkName", "SymLink");
    request.addInput("linkPath", "PageTwo");
    Response response = invokeResponder();

    assertEquals(412, response.getStatus());
    String content = ((SimpleResponse) response).getContent();
    assertSubString("already has a child named SymLink", content);
    assertSubString("Error Occurred", content);
  }
コード例 #11
0
 private boolean isValidWikiPageName(String linkName, WikiPageProperty symLinks) throws Exception {
   if (page.hasChildPage(linkName) && !symLinks.has(linkName)) {
     response =
         new ErrorResponder(resource + " already has a child named " + linkName + ".")
             .makeResponse(context, null);
     response.setStatus(412);
     return false;
   } else if (!PathParser.isSingleWikiWord(linkName)) {
     response =
         new ErrorResponder(linkName + " is not a valid WikiWord.").makeResponse(context, null);
     response.setStatus(412);
     return false;
   }
   return true;
 }
コード例 #12
0
  @Test
  public void testResponse() throws Exception {
    MockRequest request = new MockRequest();
    request.setResource("PageOne");
    WhereUsedResponder responder =
        new WhereUsedResponder(htmlPageFactory, root, runningTestingTracker, isChunkingEnabled());

    Response response = responder.makeResponse(request);
    MockResponseSender sender = new MockResponseSender();
    response.readyToSend(sender);
    sender.waitForClose(5000);

    String content = sender.sentData();
    assertEquals(200, response.getStatus());
    assertHasRegexp("Where Used", content);
    assertHasRegexp(">PageOne<", content);
    assertHasRegexp(">PageTwo<", content);
    assertHasRegexp(">PageTwo\\.ChildPage<", content);
  }
コード例 #13
0
 private void checkChildTwoRedirectToProperties(Response response) {
   assertEquals(303, response.getStatus());
   assertEquals(response.getHeader("Location"), "/PageTwo.ChildTwo?properties#symbolics");
 }
コード例 #14
0
ファイル: ResponseTest.java プロジェクト: BenediktSt/fitnesse
 @Test
 public void defaultFormat() throws Exception {
   Response response = new MockResponse("");
   assertTrue(response.isHtmlFormat());
 }
コード例 #15
0
 private void setRedirect(String resource) {
   response.redirect(context.contextRoot, resource + "?properties#symbolics");
 }
コード例 #16
0
 @Test
 public void shouldMakeErrorResponseWhenItGetsInvalidTypeForNumberOfDays() throws Exception {
   request.addInput("days", "bob");
   Response response = responder.makeResponse(context, request);
   assertEquals(400, response.getStatus());
 }
コード例 #17
0
ファイル: ResponseTest.java プロジェクト: BenediktSt/fitnesse
 @Test
 public void shouldHaveHeadersIfXml() throws Exception {
   Response response = new MockResponse("xml");
   assertTrue(response.makeHttpHeaders().contains("HTTP/1.1 200 OK"));
 }
コード例 #18
0
ファイル: ResponseTest.java プロジェクト: BenediktSt/fitnesse
 private void checkPhrase(int reasonCode, String reasonPhrase) {
   assertEquals(reasonPhrase, Response.getReasonPhrase(reasonCode));
 }
コード例 #19
0
ファイル: ResponseTest.java プロジェクト: BenediktSt/fitnesse
 @Test
 public void xmlFormat() throws Exception {
   Response response = new MockResponse("xml");
   assertTrue(response.isXmlFormat());
 }
コード例 #20
0
ファイル: ResponseTest.java プロジェクト: BenediktSt/fitnesse
 @Test
 public void textFormat() throws Exception {
   Response response = new MockResponse("text");
   assertTrue(response.isTextFormat());
 }
コード例 #21
0
ファイル: ResponseTest.java プロジェクト: BenediktSt/fitnesse
 @Test
 public void shouldNotHaveHeadersIfText() throws Exception {
   Response response = new MockResponse("text");
   assertEquals("", response.makeHttpHeaders());
 }