@Test public void testResponse() throws Exception { WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("ChildPage"), "child content"); PageData data = page.getData(); WikiPageProperties properties = data.getProperties(); properties.set(PageData.PropertySUITES, "Wiki Page tags"); page.commit(data); final MockRequest request = new MockRequest(); request.setResource("ChildPage"); final Responder responder = new WikiPageResponder(); final SimpleResponse response = (SimpleResponse) responder.makeResponse(context, request); assertEquals(200, response.getStatus()); final String body = response.getContent(); assertSubString("<html>", body); assertSubString("<body", body); assertSubString("child content", body); assertSubString("href=\"ChildPage?whereUsed\"", body); assertSubString("Cache-Control: max-age=0", response.makeHttpHeaders()); assertSubString("<h5> Wiki Page tags</h5>", body); }
private void getContentForSimpleRename() throws Exception { request.setResource("files"); request.addInput("filename", "MyFile.txt"); Responder responder = new RenameFileConfirmationResponder(htmlPageFactory); SimpleResponse response = (SimpleResponse) responder.makeResponse(request); content = response.getContent(); }
@Test public void testFitnesseLook() throws Exception { Responder responder = new RenameFileConfirmationResponder(htmlPageFactory); SimpleResponse response = (SimpleResponse) responder.makeResponse(request); String content = response.getContent(); assertSubString( "<link rel=\"stylesheet\" type=\"text/css\" href=\"/files/css/fitnesse.css\" media=\"screen\"/>", content); }
public void testHasEditLinkForWikiWords() throws Exception { 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()); }
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); }
public void testMakeReponder() throws Exception { MockRequest request = new MockRequest(); request.setResource("PageOne"); Responder responder = new VersionSelectionResponder(); SimpleResponse response = (SimpleResponse) responder.makeResponse(new FitNesseContext(root), request); String content = response.getContent(); assertSubString("<input", content); assertSubString("name=\"version\"", content); assertSubString("<form", content); assertSubString("action=\"PageOne\"", content); assertSubString("name=\"responder\"", content); assertSubString(" value=\"viewVersion\"", content); }
private WikiPage getPropertiesContentFromPage(WikiPage page) throws Exception { request = new MockRequest(); request.setResource(page.getName()); responder = new PropertiesResponder(); SimpleResponse response = (SimpleResponse) responder.makeResponse(new FitNesseContext(root), request); content = response.getContent(); return page; }
public void testResponse() throws Exception { WikiPage page = crawler.addPage(root, PathParser.parse("PageOne")); PageData data = page.getData(); data.setContent("some content"); WikiPageProperties properties = data.getProperties(); properties.set("Test", "true"); properties.set(WikiPageProperties.VIRTUAL_WIKI_ATTRIBUTE, "http://www.fitnesse.org"); page.commit(data); MockRequest request = new MockRequest(); request.setResource("PageOne"); Responder responder = new PropertiesResponder(); SimpleResponse response = (SimpleResponse) responder.makeResponse(new FitNesseContext(root), request); assertEquals("max-age=0", response.getHeader("Cache-Control")); String content = response.getContent(); assertSubString("PageOne", content); assertSubString("value=\"http://www.fitnesse.org\"", content); assertDoesntHaveRegexp("textarea name=\"extensionXml\"", content); assertHasRegexp("<input.*value=\"Save Properties\".*>", content); assertHasRegexp("<input.*value=\"saveProperties\"", content); assertSubString("<input type=\"checkbox\" name=\"Test\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Search\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Edit\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Properties\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Suite\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Prune\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Versions\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"Refactor\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"WhereUsed\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"RecentChanges\" checked=\"true\"/>", content); assertSubString("<input type=\"checkbox\" name=\"" + WikiPage.SECURE_READ + "\"/>", content); assertSubString("<input type=\"checkbox\" name=\"" + WikiPage.SECURE_WRITE + "\"/>", content); assertSubString("<input type=\"checkbox\" name=\"" + WikiPage.SECURE_TEST + "\"/>", content); }
public void testUsernameDisplayed() throws Exception { WikiPage page = getContentFromSimplePropertiesPage(); assertSubString("Last modified anonymously", content); PageData data = page.getData(); data.setAttribute(WikiPage.LAST_MODIFYING_USER, "Bill"); page.commit(data); request.setResource("SomePage"); SimpleResponse response = (SimpleResponse) responder.makeResponse(new FitNesseContext(root), request); content = response.getContent(); assertSubString("Last modified by Bill", content); }
private void assertResponderType(Class<?> expectedClass) throws Exception { Responder responder = factory.makeResponder(request); assertEquals(expectedClass, responder.getClass()); }
private SimpleResponse requestPage(String name) throws Exception { final MockRequest request = new MockRequest(); request.setResource(name); final Responder responder = new WikiPageResponder(); return (SimpleResponse) responder.makeResponse(context, request); }
private void makeResponder() { Responder responder = authenticator.authenticate(context, request, privilegedResponder); responderType = responder.getClass(); }