001: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002: // Released under the terms of the GNU General Public License version 2 or later.
003:
004: package fitnesse.wiki;
005:
006: import java.util.ArrayList;
007: import java.util.Date;
008: import java.util.List;
009:
010: public class MockWikiPage implements WikiPage {
011:
012: private static final long serialVersionUID = 1L;
013:
014: public String name;
015:
016: protected String location;
017:
018: private PageData pageData;
019:
020: private WikiPage parent;
021:
022: public static final int daysTillVersionsExpire = 14;
023:
024: public MockWikiPage(String name, String content) throws Exception {
025: this .name = name;
026: pageData = new PageData(this , content);
027: }
028:
029: public MockWikiPage(String location) {
030: this .location = location;
031: name = "Default";
032: }
033:
034: public MockWikiPage() {
035: location = null;
036: name = "Default";
037: }
038:
039: public String getName() {
040: return name;
041: }
042:
043: public WikiPage getParent() {
044: return parent;
045: }
046:
047: public void setParent(WikiPage parent) {
048: this .parent = parent;
049: }
050:
051: public PageData getData() throws Exception {
052: return pageData;
053: }
054:
055: public VersionInfo commit(PageData data) throws Exception {
056: pageData = data;
057: return new VersionInfo("mockVersionName", "mockAuthor",
058: new Date());
059: }
060:
061: public List getChildren() {
062: return new ArrayList();
063: }
064:
065: public int compareTo(Object o) {
066: return 0;
067: }
068:
069: public PageData getDataVersion(String versionName) throws Exception {
070: return null;
071: }
072:
073: public void removeChildPage(String name) throws Exception {
074: }
075:
076: public PageCrawler getPageCrawler() {
077: return new PageCrawlerImpl();
078: }
079:
080: public WikiPage addChildPage(String name) throws Exception {
081: return null;
082: }
083:
084: public boolean hasChildPage(String name) throws Exception {
085: return false;
086: }
087:
088: public WikiPage getChildPage(String name) throws Exception {
089: return null;
090: }
091:
092: public boolean hasExtension(String extensionName) {
093: return false;
094: }
095:
096: public Extension getExtension(String extensionName) {
097: return null;
098: }
099:
100: protected boolean isOfType(String pageType) {
101: try {
102: return getData().getProperties().is(pageType);
103: } catch (Exception e) {
104: // property doesn't exist, fall through to false result
105: }
106: return false;
107: }
108:
109: protected boolean containsWidget(String widgetTag) {
110: try {
111: return getData().getContent().indexOf("!" + widgetTag) != -1;
112: } catch (Exception ex) {
113: return false;
114: }
115: }
116:
117: public boolean isSTIQTest() {
118: return isOfType(WikiPage.STIQ_TEST);
119: }
120:
121: public boolean isSTIQTestComponent() {
122: return isOfType(WikiPage.STIQ_COMPONENT);
123: }
124:
125: public boolean isSTIQBranch() {
126: return containsWidget("STIQsuite")
127: || containsWidget("STIQtestcomponents")
128: || containsWidget("seleniumsuite");
129: }
130:
131: }
|