@Test public void testRenameFailWhenNonSym() throws Exception { prepareSymlinkOnPageOne(); request.addInput("newname", "ChildOne"); Response response = invokeResponder(); assertEquals(412, response.getStatus()); }
@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); }
@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); }
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()); }
@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); }
@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); }
@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); }
@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); }
@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); }
private void checkChildTwoRedirectToProperties(Response response) { assertEquals(303, response.getStatus()); assertEquals(response.getHeader("Location"), "/PageTwo.ChildTwo?properties#symbolics"); }
@Test public void shouldMakeErrorResponseWhenItGetsInvalidTypeForNumberOfDays() throws Exception { request.addInput("days", "bob"); Response response = responder.makeResponse(context, request); assertEquals(400, response.getStatus()); }