@Test public void testHeadersAndFooters() throws Exception { WikiPageUtil.addPage(root, PathParser.parse("NormalPage"), "normal"); WikiPageUtil.addPage(root, PathParser.parse("TestPage"), "test page"); WikiPageUtil.addPage(root, PathParser.parse("PageHeader"), "header"); WikiPageUtil.addPage(root, PathParser.parse("PageFooter"), "footer"); WikiPageUtil.addPage(root, PathParser.parse("SetUp"), "setup"); WikiPageUtil.addPage(root, PathParser.parse("TearDown"), "teardown"); WikiPageUtil.addPage(root, PathParser.parse("SuiteSetUp"), "suite setup"); WikiPageUtil.addPage(root, PathParser.parse("SuiteTearDown"), "suite teardown"); SimpleResponse response = requestPage("NormalPage"); String content = response.getContent(); assertHasRegexp("header", content); assertHasRegexp("normal", content); assertHasRegexp("footer", content); assertDoesntHaveRegexp("setup", content); assertDoesntHaveRegexp("teardown", content); assertDoesntHaveRegexp("suite setup", content); assertDoesntHaveRegexp("suite teardown", content); response = requestPage("TestPage"); content = response.getContent(); assertHasRegexp("header", content); assertHasRegexp("test page", content); assertHasRegexp("footer", content); assertHasRegexp("setup", content); assertHasRegexp("teardown", content); assertHasRegexp("suite setup", content); assertHasRegexp("suite teardown", content); }
@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(); }
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; }
@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 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); }
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); }
@Test public void testAttributeButtons() throws Exception { WikiPageUtil.addPage(root, PathParser.parse("NormalPage"), ""); final WikiPage noButtonsPage = WikiPageUtil.addPage(root, PathParser.parse("NoButtonPage"), ""); for (final String attribute : PageData.NON_SECURITY_ATTRIBUTES) { final PageData data = noButtonsPage.getData(); data.removeAttribute(attribute); noButtonsPage.commit(data); } SimpleResponse response = requestPage("NormalPage"); assertSubString(">Edit</a>", response.getContent()); assertSubString(">Search</a>", response.getContent()); assertSubString(">Versions</a>", response.getContent()); assertNotSubString(">Suite</a>", response.getContent()); assertNotSubString(">Test</a>", response.getContent()); response = requestPage("NoButtonPage"); assertNotSubString(">Edit</a>", response.getContent()); assertNotSubString(">Search</a>", response.getContent()); assertNotSubString(">Versions</a>", response.getContent()); assertNotSubString(">Suite</a>", response.getContent()); assertNotSubString(">Test</a>", response.getContent()); }
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); }