Source Code Cross Referenced for TableOfContentsTest.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » plugin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.plugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (C) Janne Jalkanen 2005
003:         * 
004:         */
005:        package com.ecyrd.jspwiki.plugin;
006:
007:        import java.util.Properties;
008:
009:        import com.ecyrd.jspwiki.TestEngine;
010:
011:        import junit.framework.Test;
012:        import junit.framework.TestCase;
013:        import junit.framework.TestSuite;
014:
015:        /**
016:         *  @author jalkanen
017:         *
018:         *  @since 
019:         */
020:        public class TableOfContentsTest extends TestCase {
021:            TestEngine testEngine;
022:
023:            /*
024:             * @see TestCase#setUp()
025:             */
026:            protected void setUp() throws Exception {
027:                super .setUp();
028:
029:                Properties props = new Properties();
030:
031:                props.load(TestEngine.findTestProperties());
032:
033:                testEngine = new TestEngine(props);
034:            }
035:
036:            /*
037:             * @see TestCase#tearDown()
038:             */
039:            protected void tearDown() throws Exception {
040:                super .tearDown();
041:
042:                testEngine.deletePage("Test");
043:            }
044:
045:            public void testHeadingVariables() throws Exception {
046:                String src = "[{SET foo=bar}]\n\n[{TableOfContents}]\n\n!!!Heading [{$foo}]";
047:
048:                testEngine.saveText("Test", src);
049:
050:                String res = testEngine.getHTML("Test");
051:
052:                // FIXME: The <p> should not be here.
053:                assertEquals(
054:                        "<p><div class=\"toc\">\n<div class=\"collapsebox\">\n"
055:                                + "<h4>Table of Contents</h4>\n"
056:                                + "<ul>\n"
057:                                + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-HeadingBar\">Heading bar</a></li>\n"
058:                                + "</ul>\n</div>\n</div>\n\n</p>"
059:                                + "\n<h2 id=\"section-Test-HeadingBar\">Heading bar</h2>\n",
060:                        res);
061:            }
062:
063:            public void testNumberedItems() throws Exception {
064:                String src = "[{SET foo=bar}]\n\n[{INSERT TableOfContents WHERE numbered=true,start=3}]\n\n!!!Heading [{$foo}]\n\n!!Subheading\n\n!Subsubheading";
065:
066:                testEngine.saveText("Test", src);
067:
068:                String res = testEngine.getHTML("Test");
069:
070:                // FIXME: The <p> should not be here.
071:                String expecting = "<p><div class=\"toc\">\n<div class=\"collapsebox\">\n"
072:                        + "<h4>Table of Contents</h4>\n"
073:                        + "<ul>\n"
074:                        + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-HeadingBar\">3 Heading bar</a></li>\n"
075:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading\">3.1 Subheading</a></li>\n"
076:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading\">3.1.1 Subsubheading</a></li>\n"
077:                        + "</ul>\n</div>\n</div>\n\n</p>"
078:                        + "\n<h2 id=\"section-Test-HeadingBar\">Heading bar</h2>"
079:                        + "\n<h3 id=\"section-Test-Subheading\">Subheading</h3>"
080:                        + "\n<h4 id=\"section-Test-Subsubheading\">Subsubheading</h4>\n";
081:
082:                assertEquals(expecting, res);
083:            }
084:
085:            public void testNumberedItemsComplex() throws Exception {
086:                String src = "[{SET foo=bar}]\n\n[{INSERT TableOfContents WHERE numbered=true,start=3}]\n\n!!!Heading [{$foo}]\n\n!!Subheading\n\n!Subsubheading\n\n!Subsubheading2\n\n!!Subheading2\n\n!Subsubheading3\n\n!!!Heading\n\n!!Subheading3";
087:
088:                testEngine.saveText("Test", src);
089:
090:                String res = testEngine.getHTML("Test");
091:
092:                // FIXME: The <p> should not be here.
093:                String expecting = "<p><div class=\"toc\">\n<div class=\"collapsebox\">\n"
094:                        + "<h4>Table of Contents</h4>\n"
095:                        + "<ul>\n"
096:                        + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-HeadingBar\">3 Heading bar</a></li>\n"
097:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading\">3.1 Subheading</a></li>\n"
098:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading\">3.1.1 Subsubheading</a></li>\n"
099:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading2\">3.1.2 Subsubheading2</a></li>\n"
100:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading2\">3.2 Subheading2</a></li>\n"
101:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading3\">3.2.1 Subsubheading3</a></li>\n"
102:                        + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Heading\">4 Heading</a></li>\n"
103:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading3\">4.1 Subheading3</a></li>\n"
104:                        + "</ul>\n</div>\n</div>\n\n</p>"
105:                        + "\n<h2 id=\"section-Test-HeadingBar\">Heading bar</h2>"
106:                        + "\n<h3 id=\"section-Test-Subheading\">Subheading</h3>"
107:                        + "\n<h4 id=\"section-Test-Subsubheading\">Subsubheading</h4>"
108:                        + "\n<h4 id=\"section-Test-Subsubheading2\">Subsubheading2</h4>"
109:                        + "\n<h3 id=\"section-Test-Subheading2\">Subheading2</h3>"
110:                        + "\n<h4 id=\"section-Test-Subsubheading3\">Subsubheading3</h4>"
111:                        + "\n<h2 id=\"section-Test-Heading\">Heading</h2>"
112:                        + "\n<h3 id=\"section-Test-Subheading3\">Subheading3</h3>\n";
113:
114:                assertEquals(expecting, res);
115:            }
116:
117:            public void testNumberedItemsComplex2() throws Exception {
118:                String src = "[{SET foo=bar}]\n\n[{INSERT TableOfContents WHERE numbered=true,start=3}]\n\n!!Subheading0\n\n!!!Heading [{$foo}]\n\n!!Subheading\n\n!Subsubheading\n\n!Subsubheading2\n\n!!Subheading2\n\n!Subsubheading3\n\n!!!Heading\n\n!!Subheading3";
119:
120:                testEngine.saveText("Test", src);
121:
122:                String res = testEngine.getHTML("Test");
123:
124:                // FIXME: The <p> should not be here.
125:                String expecting = "<p><div class=\"toc\">\n<div class=\"collapsebox\">\n"
126:                        + "<h4>Table of Contents</h4>\n"
127:                        + "<ul>\n"
128:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading0\">3.1 Subheading0</a></li>\n"
129:                        + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-HeadingBar\">4 Heading bar</a></li>\n"
130:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading\">4.1 Subheading</a></li>\n"
131:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading\">4.1.1 Subsubheading</a></li>\n"
132:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading2\">4.1.2 Subsubheading2</a></li>\n"
133:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading2\">4.2 Subheading2</a></li>\n"
134:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading3\">4.2.1 Subsubheading3</a></li>\n"
135:                        + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Heading\">5 Heading</a></li>\n"
136:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading3\">5.1 Subheading3</a></li>\n"
137:                        + "</ul>\n</div>\n</div>\n\n</p>"
138:                        + "\n<h3 id=\"section-Test-Subheading0\">Subheading0</h3>"
139:                        + "\n<h2 id=\"section-Test-HeadingBar\">Heading bar</h2>"
140:                        + "\n<h3 id=\"section-Test-Subheading\">Subheading</h3>"
141:                        + "\n<h4 id=\"section-Test-Subsubheading\">Subsubheading</h4>"
142:                        + "\n<h4 id=\"section-Test-Subsubheading2\">Subsubheading2</h4>"
143:                        + "\n<h3 id=\"section-Test-Subheading2\">Subheading2</h3>"
144:                        + "\n<h4 id=\"section-Test-Subsubheading3\">Subsubheading3</h4>"
145:                        + "\n<h2 id=\"section-Test-Heading\">Heading</h2>"
146:                        + "\n<h3 id=\"section-Test-Subheading3\">Subheading3</h3>\n";
147:
148:                assertEquals(expecting, res);
149:            }
150:
151:            public void testNumberedItemsWithPrefix() throws Exception {
152:                String src = "[{SET foo=bar}]\n\n[{INSERT TableOfContents WHERE numbered=true,start=3,prefix=FooBar-}]\n\n!!!Heading [{$foo}]\n\n!!Subheading\n\n!Subsubheading";
153:
154:                testEngine.saveText("Test", src);
155:
156:                String res = testEngine.getHTML("Test");
157:
158:                // FIXME: The <p> should not be here.
159:                String expecting = "<p><div class=\"toc\">\n<div class=\"collapsebox\">\n"
160:                        + "<h4>Table of Contents</h4>\n"
161:                        + "<ul>\n"
162:                        + "<li class=\"toclevel-1\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-HeadingBar\">FooBar-3 Heading bar</a></li>\n"
163:                        + "<li class=\"toclevel-2\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subheading\">FooBar-3.1 Subheading</a></li>\n"
164:                        + "<li class=\"toclevel-3\"><a class=\"wikipage\" href=\"/Wiki.jsp?page=Test#section-Test-Subsubheading\">FooBar-3.1.1 Subsubheading</a></li>\n"
165:                        + "</ul>\n</div>\n</div>\n\n</p>"
166:                        + "\n<h2 id=\"section-Test-HeadingBar\">Heading bar</h2>"
167:                        + "\n<h3 id=\"section-Test-Subheading\">Subheading</h3>"
168:                        + "\n<h4 id=\"section-Test-Subsubheading\">Subsubheading</h4>\n";
169:
170:                assertEquals(expecting, res);
171:            }
172:
173:            /**
174:             *  Tests BugTableOfContentsCausesHeapdump
175:             *  
176:             * @throws Exception
177:             */
178:            public void testSelfReference() throws Exception {
179:                String src = "!!![{TableOfContents}]";
180:
181:                testEngine.saveText("Test", src);
182:
183:                String res = testEngine.getHTML("Test");
184:
185:                assertTrue(res.indexOf("Table of Contents") != -1);
186:            }
187:
188:            public void testHTML() throws Exception {
189:                String src = "[{TableOfContents}]\n\n!<i>test</i>";
190:
191:                testEngine.saveText("Test", src);
192:
193:                String res = testEngine.getHTML("Test");
194:
195:                assertTrue("<i>", res.indexOf("<i>") == -1); // Check that there is no HTML left
196:                assertTrue("</i>", res.indexOf("</i>") == -1); // Check that there is no HTML left
197:
198:            }
199:
200:            public static Test suite() {
201:                return new TestSuite(TableOfContentsTest.class);
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.