Source Code Cross Referenced for CreoleToJSPWikiTranslatorTest.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » parser » 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.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ecyrd.jspwiki.parser;
002:
003:        import java.io.FileInputStream;
004:        import java.text.SimpleDateFormat;
005:        import java.util.Calendar;
006:        import java.util.Properties;
007:
008:        import junit.framework.Test;
009:        import junit.framework.TestCase;
010:        import junit.framework.TestSuite;
011:
012:        public class CreoleToJSPWikiTranslatorTest extends TestCase {
013:
014:            public static final String TEST_PROPERTIES = "tests/com/ecyrd/jspwiki/parser/creole.properties";
015:
016:            public static void main(String[] args) {
017:                junit.textui.TestRunner
018:                        .run(CreoleToJSPWikiTranslatorTest.class);
019:            }
020:
021:            protected void setUp() throws Exception {
022:                super .setUp();
023:            }
024:
025:            protected void tearDown() throws Exception {
026:                super .tearDown();
027:            }
028:
029:            public void testBold() throws Exception {
030:                String src = "This is **bold**.";
031:
032:                assertEquals("This is __bold__.", translate(src));
033:            }
034:
035:            public void testBoldVersusList() throws Exception {
036:                String src = "**This is all bold.**";
037:
038:                assertEquals("__This is all bold.__", translate(src));
039:            }
040:
041:            public void testBoldAcrossLineBreaks() throws Exception {
042:                String src = "This is **bold\nand still bold**.";
043:
044:                assertEquals("This is __bold"
045:                        + System.getProperty("line.separator")
046:                        + "and still bold__.", translate(src));
047:            }
048:
049:            public void testBoldAcrossLineParagraphs() throws Exception {
050:                String src = "This is **bold\r\n\r\nand no more bold.";
051:
052:                assertEquals("This is __bold__\r\n\r\nand no more bold.",
053:                        translate(src));
054:            }
055:
056:            public void testItalicAcrossLineBreaks() throws Exception {
057:                String src = "This is //italic\r\nand still italic//.";
058:
059:                assertEquals("This is ''italic\r\nand still italic''.",
060:                        translate(src));
061:            }
062:
063:            public void testItalicAcrossLineParagraphs() throws Exception {
064:                String src = "This is //italic\r\n\r\nnand no more italic.";
065:
066:                assertEquals("This is ''italic''\r\n\r\nnand no more italic.",
067:                        translate(src));
068:            }
069:
070:            public void testItalic() throws Exception {
071:                String src = "This is //italic//.";
072:
073:                assertEquals("This is ''italic''.", translate(src));
074:            }
075:
076:            public void testImage() throws Exception {
077:                String src = "This is {{Image}}.";
078:
079:                assertEquals("This is [{Image src='Image'}].", translate(src));
080:            }
081:
082:            public void testImageLink() throws Exception {
083:                String src = "This is [[http://www.wikicreole.org|{{Image}}]] with a link.";
084:                assertEquals(
085:                        "This is [{Image src='Image' link='http://www.wikicreole.org'}] with a link.",
086:                        translate(src));
087:            }
088:
089:            public void testImageDescription() throws Exception {
090:                String src = "This is {{Image|Description}}.";
091:                assertEquals(
092:                        "This is [{Image src='Image' caption='Description'}].",
093:                        translate(src));
094:            }
095:
096:            public void testImageLinkDescription() throws Exception {
097:                String src = "This is [[http://www.wikicreole.org|{{Image|Description}}]].";
098:
099:                assertEquals(
100:                        "This is [{Image src='Image' link='http://www.wikicreole.org' caption='Description'}].",
101:                        translate(src));
102:            }
103:
104:            public void testHyperlinks2() throws Exception {
105:                String src = "This should be a [[hyperlink]]";
106:
107:                assertEquals("This should be a [hyperlink]", translate(src));
108:            }
109:
110:            public void testHyperlinks3() throws Exception {
111:                String src = "This should be a [[hyperlink too]]";
112:
113:                assertEquals("This should be a [hyperlink too]", translate(src));
114:            }
115:
116:            public void testHyperlinks4() throws Exception {
117:                String src = "This should be a [[HyperLink]]";
118:
119:                assertEquals("This should be a [HyperLink]", translate(src));
120:            }
121:
122:            public void testHyperlinks5() throws Exception {
123:                String src = "This should be a [[HyperLink|here]]";
124:
125:                assertEquals("This should be a [here|HyperLink]",
126:                        translate(src));
127:            }
128:
129:            public void testHyperlinksNamed1() throws Exception {
130:
131:                String src = "This should be a [[HyperLink#heading|here]]";
132:
133:                assertEquals("This should be a [here|HyperLink#heading]",
134:                        translate(src));
135:            }
136:
137:            public void testHyperlinksNamed2() throws Exception {
138:                String src = "This should be a [[HyperLink#heading]]";
139:
140:                assertEquals("This should be a [HyperLink#heading]",
141:                        translate(src));
142:            }
143:
144:            //
145:            // Testing CamelCase hyperlinks
146:            //
147:
148:            public void testHyperLinks6() throws Exception {
149:
150:                String src = "[[DiscussionAboutWiki]] [[WikiMarkupDevelopment]].";
151:
152:                assertEquals("[DiscussionAboutWiki] [WikiMarkupDevelopment].",
153:                        translate(src));
154:            }
155:
156:            /** ******* Stuff not in JSPWikiMarkupParserTest ************************* */
157:            /* these are test where errors occured in the Creole Wiki */
158:
159:            public void testHeadingsCreole1() throws Exception {
160:                String src = "=====Level 4 heading";
161:
162:                assertEquals("__Level 4 heading__", translate(src));
163:            }
164:
165:            public void testHyperLinksCreole1() throws Exception {
166:
167:                String src = "Sponsored by the [Wiki Symposium|http://www.wikisym.org/] and [i3G Institute|http://www.i3g.hs-heilbronn.de].";
168:
169:                assertEquals(
170:                        "Sponsored by the [Wiki Symposium|http://www.wikisym.org/] and [i3G Institute|http://www.i3g.hs-heilbronn.de].",
171:                        translate(src));
172:            }
173:
174:            public void testHyperLinksJSPWiki() throws Exception {
175:                String src = "* [http://www.wikisym.org/cgi-bin/mailman/listinfo/wiki-research|Wiki research mailing list]";
176:                assertEquals(src, translate(src));
177:            }
178:
179:            public void testHyperLinksCreole2() throws Exception {
180:
181:                String src = "Sponsored by the [[http://www.wikisym.org/|Wiki Symposium]] and [[http://www.i3g.hs-heilbronn.de|i3G Institute]].";
182:
183:                assertEquals(
184:                        "Sponsored by the [Wiki Symposium|http://www.wikisym.org/] and [i3G Institute|http://www.i3g.hs-heilbronn.de].",
185:                        translate(src));
186:            }
187:
188:            public void testPreformattedCreole() throws Exception {
189:                String src = "{{{$$...$$}}}";
190:
191:                assertEquals(src, translate(src));
192:            }
193:
194:            public void testPreformattedCreole2() throws Exception {
195:                String src = "{{{\r\n" + "\r\n"
196:                        + "[[http://en.wikipedia.org|wikipedia]]\r\n" + "}}}";
197:                assertEquals(src, translate(src));
198:            }
199:
200:            public void testPreformattedCreole3() throws Exception {
201:                String src = "{{{\r\n" + "Guitar Chord C:\r\n" + "\r\n"
202:                        + "||---|---|---|\r\n" + "||-0-|---|---|\r\n"
203:                        + "||---|-0-|---|\r\n" + "||---|---|-0-|\r\n"
204:                        + "||---|---|---|\\n" + "}}}";
205:
206:                assertEquals(src, translate(src));
207:            }
208:
209:            public void testPreformattedCreole4() throws Exception {
210:                // don't interpret plugins
211:                String src = "{{{<<Test>>}}}";
212:
213:                assertEquals(src, translate(src));
214:            }
215:
216:            public void testPreformattedCreole5() throws Exception {
217:                String src = "{{{<<<Test>>>}}}";
218:
219:                assertEquals(src, translate(src));
220:            }
221:
222:            public void testPreformattedPlusLinks1() throws Exception {
223:                String preformatted = "{{{\r\n" + "Guitar Chord C:\r\n"
224:                        + "\r\n" + "||---|---|---|\r\n" + "||-0-|---|---|\r\n"
225:                        + "||---|-0-|---|\r\n" + "||---|---|-0-|\r\n"
226:                        + "||---|---|---|\r\n" + "}}}";
227:
228:                String src = "[[http://www.wikicreole.org|external Links]]\r\n"
229:                        + preformatted;
230:
231:                String target = "[external Links|http://www.wikicreole.org]\r\n"
232:                        + preformatted;
233:                assertEquals(target, translate(src));
234:            }
235:
236:            public void testPreformattedPlusLinks2() throws Exception {
237:                String preformatted = "{{{\r\n"
238:                        + "[[http://www.wikicreole.org]]\r\n" + "}}}";
239:                String src = "[[http://www.wikicreole.org]]\r\n" + preformatted;
240:
241:                String target = "[http://www.wikicreole.org]\r\n"
242:                        + preformatted;
243:
244:                assertEquals(target, translate(src));
245:            }
246:
247:            public void testListCreole() throws Exception {
248:                String src = "- 1\r\n" + "-- 2\r\n" + "--- 3\r\n"
249:                        + "---- 4\r\n" + "----- 5";
250:                String target = "* 1\r\n" + "** 2\r\n" + "*** 3\r\n"
251:                        + "**** 4\r\n" + "***** 5";
252:
253:                assertEquals(target, translate(src));
254:            }
255:
256:            public void testLineAmbiguity() throws Exception {
257:                String src = "Some text\r\n\r\n----\r\n\r\nMore text";
258:                assertEquals(src, translate(src));
259:            }
260:
261:            public void testSignartureAmbiguity() throws Exception {
262:                String src = "Some **text**\r\n\r\n--Steff";
263:                String target = "Some __text__\r\n\r\n--Steff";
264:                assertEquals(target, translate(src));
265:            }
266:
267:            public void disabledTestLinebreakCreole() throws Exception {
268:
269:                String src = "My contact dates:\n" + "Pone: xyz\r\n"
270:                        + "Fax: +45\n" + "Mobile: abc";
271:
272:                String target = "My contact dates:\\\\\n" + "Pone: xyz\\\\\r\n"
273:                        + "Fax: +45\\\\\n" + "Mobile: abc";
274:
275:                assertEquals(target, translate(src));
276:            }
277:
278:            public void disabledTestLinebreakCreoleShort() throws Exception {
279:
280:                String src = "a\n" + "b\n" + "c\n";
281:
282:                String target = "a\\\\\n" + "b\\\\\n" + "c\n";
283:
284:                assertEquals(target, translate(src));
285:            }
286:
287:            public void disabledTestLinebreakCreoleWithLists() throws Exception {
288:
289:                String src = "*This\n" + "*Is\n" + "*a\n" + "*list";
290:
291:                assertEquals(src, translate(src));
292:            }
293:
294:            public void testCSS() throws Exception {
295:
296:                String src = "Some test\r\n"
297:                        + "\r\n"
298:                        + "%%commentbox\r\n"
299:                        + "Aloha World!\r\n"
300:                        + "%%\r\n"
301:                        + "\r\n"
302:                        + "Does the pagefilter mess up special jspwiki css markup?";
303:
304:                assertEquals(src, translate(src));
305:            }
306:
307:            public void testSeparatorAfterHypenList() throws Exception {
308:
309:                String src = "- 1\r\n" + "-- 1.1\r\n" + "-- 1.2\r\n"
310:                        + "- 2\r\n" + "---------\r\n" + "test\r\n" + "Test";
311:
312:                String target = "* 1\r\n" + "** 1.1\r\n" + "** 1.2\r\n"
313:                        + "* 2\r\n" + "---------\r\n" + "test\r\n" + "Test";
314:
315:                assertEquals(target, translate(src));
316:            }
317:
318:            /**
319:             * This might not work, users will have to resolve this ambiguity by hand...
320:             *
321:             * @throws Exception
322:             */
323:            public void testBulletListBoldAmbiguity() throws Exception {
324:
325:                String src = "* 1\r\n" + "** 1.1\r\n" + "** 1.2\r\n"
326:                        + "* 2\r\n" + "---------\r\n" + "test";
327:                assertEquals(src, translate(src));
328:            }
329:
330:            public void testEscapeHypens() throws Exception {
331:
332:                String src = " 1\\\\\r\n" + "~- 3\\\\\r\n" + "~===\\\\\r\n"
333:                        + "~- 2\\\\";
334:
335:                String target = " 1\\\\\r\n" + "~- 3\\\\\r\n" + "~===\\\\\r\n"
336:                        + "~- 2\\\\";
337:
338:                assertEquals(target, translate(src));
339:            }
340:
341:            public void testEscapeNowiki() throws Exception {
342:
343:                String src = "{{{\r\n" + "{{{\r\n" + "{{Image}}\r\n"
344:                        + "~}}}\r\n" + "}}}\r\n" + "Test";
345:
346:                String target = "{{{\r\n" + "{{{\r\n" + "{{Image}}\r\n"
347:                        + "~}}}\r\n" + "}}}\r\n" + "Test";
348:
349:                assertEquals(target, translate(src));
350:            }
351:
352:            public void testTables1() throws Exception {
353:
354:                String src = "|a|b\r\n" + "|c|d";
355:
356:                assertEquals(src, translate(src));
357:            }
358:
359:            public void testTables2() throws Exception {
360:
361:                String src = "|a|b|\r\n" + "|c|d|";
362:
363:                String target = "|a|b\r\n" + "|c|d";
364:
365:                assertEquals(target, translate(src));
366:            }
367:
368:            public void testTables3() throws Exception {
369:
370:                String src = "before\r\n" + "|a|b|   \r\n" + "|c|d|\r\n"
371:                        + "after";
372:
373:                String target = "before\r\n" + "|a|b\r\n" + "|c|d\r\n"
374:                        + "after";
375:
376:                assertEquals(target, translate(src));
377:            }
378:
379:            public void testTables4() throws Exception {
380:
381:                String src = "before\r\n" + "|a\\\\b|b|\r\n" + "|c|d|\r\n"
382:                        + "after";
383:
384:                String target = "before\r\n" + "|a\\\\b|b\r\n" + "|c|d\r\n"
385:                        + "after";
386:
387:                assertEquals(target, translate(src));
388:            }
389:
390:            public void testTables5() throws Exception {
391:
392:                // does a empty line between two tables get lost?
393:                String src = "|a|b|\r\n" + "\r\n" + "|x|y|\r\nTest";
394:
395:                String target = "|a|b\r\n" + "\r\n" + "|x|y\r\nTest";
396:
397:                assertEquals(target, translate(src));
398:            }
399:
400:            public void testTableHeaders1() throws Exception {
401:
402:                String src = "|=a|=b|\r\n" + "|c|d|";
403:
404:                String target = "||a||b\r\n" + "|c|d";
405:                assertEquals(target, translate(src));
406:            }
407:
408:            public void testTableHeaders2() throws Exception {
409:
410:                String src = "|=a=|=b=|\r\n" + "|c|d|";
411:
412:                String target = "||a||b\r\n" + "|c|d";
413:
414:                assertEquals(target, translate(src));
415:            }
416:
417:            public void testTableHeaders3() throws Exception {
418:
419:                String src = "||a||b\r\n" + "|c|d";
420:
421:                assertEquals(src, translate(src));
422:            }
423:
424:            public void testExtensions1() throws Exception {
425:
426:                String src = "<<ImagePlugin src='abc'>>";
427:
428:                String target = "[{ImagePlugin src='abc'}]";
429:
430:                assertEquals(target, translate(src));
431:            }
432:
433:            public void testExtensions2() throws Exception {
434:
435:                String src = "[{ImagePlugin src='abc'}]";
436:
437:                assertEquals(src, translate(src));
438:            }
439:
440:            public void testExtensions3() throws Exception {
441:
442:                String src = "<This is HTML>";
443:
444:                assertEquals(src, translate(src));
445:            }
446:
447:            public void testExtensions4() throws Exception {
448:                String src = "<<FormOpen submit=\'http://www.jspwiki.org\' >>";
449:
450:                String target = "[{FormOpen submit=\'http://www.jspwiki.org\' }]";
451:
452:                assertEquals(target, translate(src));
453:            }
454:
455:            public void testExtensions5() {
456:
457:                String src = "<<Script\r\n" + "\r\n" + "//Comment\r\n"
458:                        + ">>\r\n" + "\r\n" + "[[http://www.xyz.com/]]\r\n";
459:
460:                String target = "[{Script\r\n" + "\r\n" + "//Comment\r\n"
461:                        + "}]\r\n" + "\r\n" + "[http://www.xyz.com/]";
462:
463:                System.out.println(src);
464:                System.out.println(translate(src));
465:
466:                assertEquals(target, translate(src));
467:            }
468:
469:            public void testHeaderNotAtBeginning() {
470:                String src = "Hallo==Hallo";
471:                assertEquals(src, translate(src));
472:            }
473:
474:            public void testTableLink() {
475:                String src = "|=a=|=b=|\r\n" + "|[[c]]|d|";
476:
477:                String target = "||a||b\r\n" + "|[c]|d";
478:
479:                assertEquals(target, translate(src));
480:            }
481:
482:            public void testTableImage() {
483:                String src = "|=a=|=b=|\r\n" + "|[[c]]|{{Image.png}}|";
484:
485:                String target = "||a||b\r\n" + "|[c]|[{Image src='Image.png'}]";
486:
487:                assertEquals(target, translate(src));
488:            }
489:
490:            public void testHeaderAfterLinebreak() {
491:                String src = "Hallo das ist super\r\n===Und jetzt\r\nGehts weiter";
492:
493:                String target = "Hallo das ist super\r\n!!Und jetzt\r\nGehts weiter";
494:
495:                assertEquals(target, translate(src));
496:            }
497:
498:            public void testBulletMixedEnum() {
499:                String src = "# Hallo\r\n" + "-- Hallo\r\n" + "--- Hallo\r\n"
500:                        + "Hi";
501:
502:                String target = "# Hallo\r\n" + "** Hallo\r\n"
503:                        + "*** Hallo\r\n" + "Hi";
504:                assertEquals(target, translate(src));
505:            }
506:
507:            public void testBulletMixedEnum2() {
508:                String src = "- Hallo\r\n" + "## Hallo\r\n" + "### Hallo\r\n"
509:                        + "Hi";
510:
511:                String target = "* Hallo\r\n" + "## Hallo\r\n"
512:                        + "### Hallo\r\n" + "Hi";
513:                assertEquals(target, translate(src));
514:            }
515:
516:            public void testBulletMixedEnum3() {
517:                String src = "#Headings\r\n"
518:                        + "#Links (with optional title)\r\n"
519:                        + "#Lists (like this one)\r\n"
520:                        + "--including nested lists\r\n" + "#Tables\r\n"
521:                        + "--caption\r\n" + "--headers\r\n" + "--summary\r\n"
522:                        + "#Language information\r\n"
523:                        + "#Acronyms and abbreviations\r\n"
524:                        + "#Emphasis and strong emphasis\r\n"
525:                        + "#Quotes, inline and block\r\n" + "#Images";
526:
527:                String target = "#Headings\r\n"
528:                        + "#Links (with optional title)\r\n"
529:                        + "#Lists (like this one)\r\n"
530:                        + "**including nested lists\r\n" + "#Tables\r\n"
531:                        + "**caption\r\n" + "**headers\r\n" + "**summary\r\n"
532:                        + "#Language information\r\n"
533:                        + "#Acronyms and abbreviations\r\n"
534:                        + "#Emphasis and strong emphasis\r\n"
535:                        + "#Quotes, inline and block\r\n" + "#Images";
536:
537:                assertEquals(target, translate(src));
538:            }
539:
540:            public void testSignature() {
541:                String src = "Hallo\r\n--~~~";
542:                String target = "Hallo\r\n-- [[Hanno]]";
543:                Properties props = new Properties();
544:                props.put("creole.dateFormat", "dd/MM/yyyy");
545:                assertEquals(target, new CreoleToJSPWikiTranslator()
546:                        .translateSignature(props, src, "Hanno"));
547:            }
548:
549:            public void testSignatureDate() {
550:                String src = "Hallo\r\n--~~~~";
551:                Calendar cal = Calendar.getInstance();
552:                String target = "Hallo\r\n-- [[Hanno]], "
553:                        + (new SimpleDateFormat("dd/MM/yyyy")).format(cal
554:                                .getTime());
555:                Properties props = new Properties();
556:                props.put("creole.dateFormat", "dd/MM/yyyy");
557:                assertEquals(target, new CreoleToJSPWikiTranslator()
558:                        .translateSignature(props, src, "Hanno"));
559:            }
560:
561:            public void testSignatureDate2() {
562:
563:                String format = "\n   yyyy-MM-dd HH:mm   ";
564:                String src = "Hallo\r\n--~~~~";
565:                Calendar cal = Calendar.getInstance();
566:                String target = "Hallo\r\n-- [[Hanno]], "
567:                        + (new SimpleDateFormat(format)).format(cal.getTime());
568:                Properties props = new Properties();
569:                props.put("creole.dateFormat", format);
570:                assertEquals(target, new CreoleToJSPWikiTranslator()
571:                        .translateSignature(props, src, "Hanno"));
572:            }
573:
574:            public void testHeaderAtStart() {
575:                String src = "Hallo\r\n=Hallo\r\nHallo";
576:                String target = "Hallo\r\n!!!Hallo\r\nHallo";
577:                assertEquals(target, translate(src));
578:            }
579:
580:            public void testSignatureSourceCode() {
581:                String format = "\n   yyyy-MM-dd HH:mm   ";
582:                String src = "{{{Hallo\r\n" + "--~~~~\r\n" + "Hallo\r\n"
583:                        + "}}}";
584:                Properties props = new Properties();
585:                props.put("creole.dateFormat", format);
586:                assertEquals(src, new CreoleToJSPWikiTranslator()
587:                        .translateSignature(props, src, "Hanno"));
588:            }
589:
590:            public void testTilde() {
591:                String src = "==Willkommen zum WikiWizardScript\r\n"
592:                        + "~~ sdfsdf\r\n" + "\r\n" + "now what happens?\r\n"
593:                        + "\r\n" + "- nothing I hope\r\n"
594:                        + "- maybe something\r\n" + "- we will soon see!\r\n"
595:                        + "\r\n"
596:                        + "== and this is a big title =================\r\n"
597:                        + "\r\n" + "What can we put here?\r\n" + "\r\n"
598:                        + "{{Web2.png}}";
599:                String target = "!!!Willkommen zum WikiWizardScript\r\n"
600:                        + "~~ sdfsdf\r\n" + "\r\nnow what happens?\r\n"
601:                        + "\r\n* nothing I hope\r\n" + "* maybe something\r\n"
602:                        + "* we will soon see!\r\n"
603:                        + "\r\n!!! and this is a big title ===============\r\n"
604:                        + "\r\nWhat can we put here?\r\n"
605:                        + "\r\n[{Image src='Web2.png'}]";
606:                assertEquals(target, translate(src));
607:            }
608:
609:            public void testWWWToHTTP() {
610:                String src = "Hallo\r\nHallo[[ 	www.gmx.de]]Hallo\r\nHallo";
611:                String target = "Hallo\r\nHallo[http://www.gmx.de]Hallo\r\nHallo";
612:                assertEquals(target, translate(src));
613:
614:                String src2 = "Hallo\r\nHallo[[www.gmx.de]]Hallo\r\nHallo";
615:                String target2 = "Hallo\r\nHallo[http://www.gmx.de]Hallo\r\nHallo";
616:                assertEquals(target2, translate(src2));
617:
618:                String src3 = "Hallo\r\nHallo[[www.gmx.de|GMX]]Hallo\r\nHallo";
619:                String target3 = "Hallo\r\nHallo[GMX|http://www.gmx.de]Hallo\r\nHallo";
620:                assertEquals(target3, translate(src3));
621:            }
622:
623:            public void testImageX() {
624:                String src = "Hallo {{Image.png|Caption|M,NB}}";
625:                String target = "Hallo [{ImageX src='Image.png' caption='Caption' width='250' border=0}]";
626:                Properties props = new Properties();
627:                props.put("creole.imagePlugin.para.M", "width='250'");
628:                props.put("creole.imagePlugin.para.NB", "border=0");
629:                props.put("creole.imagePlugin.name", "ImageX");
630:
631:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
632:                        props, src));
633:            }
634:
635:            public void testImageX11() {
636:                String src = "Hallo {{Image.png|Caption|250}}";
637:                String target = "Hallo [{ImageX src='Image.png' caption='Caption' width='250px'}]";
638:                Properties props = new Properties();
639:                props.put("creole.imagePlugin.name", "ImageX");
640:
641:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
642:                        props, src));
643:            }
644:
645:            public void testImageX2() {
646:                String src = "Hallo {{Image.png|Caption}}";
647:                String target = "Hallo [{ImageX src='Image.png' caption='Caption' }]";
648:                Properties props = new Properties();
649:                props.put("creole.imagePlugin.name", "ImageX");
650:
651:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
652:                        props, src));
653:            }
654:
655:            public void testImageX3() {
656:                String src = "Hallo {{Image.png|Caption|M,NB,TEST}}";
657:                String target = "Hallo [{ImageX src='Image.png' caption='Caption' width='250' border=0}]";
658:                Properties props = new Properties();
659:                props.put("creole.imagePlugin.para.M", "width='250'");
660:                props.put("creole.imagePlugin.para.NB", "border=0");
661:                props.put("creole.imagePlugin.name", "ImageX");
662:
663:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
664:                        props, src));
665:            }
666:
667:            public void testImageX4() {
668:                String src = "Hallo {{Image.png||M,NB,TEST}}";
669:                String target = "Hallo [{ImageX src='Image.png' width='250' border=0}]";
670:                Properties props = new Properties();
671:                props.put("creole.imagePlugin.para.M", "width='250'");
672:                props.put("creole.imagePlugin.para.NB", "border=0");
673:                props.put("creole.imagePlugin.name", "ImageX");
674:
675:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
676:                        props, src));
677:            }
678:
679:            public void testImageX5() {
680:                String src = "Hallo [[http://www.google.de|{{Image.png||M,NB,TEST}}]]";
681:                String target = "Hallo [{ImageX src='Image.png' link='http://www.google.de' width='250' border=0}]";
682:                Properties props = new Properties();
683:                props.put("creole.imagePlugin.para.M", "width='250'");
684:                props.put("creole.imagePlugin.para.NB", "border=0");
685:                props.put("creole.imagePlugin.name", "ImageX");
686:
687:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
688:                        props, src));
689:            }
690:
691:            public void testImageX6() throws Exception {
692:                Properties props = new Properties();
693:                props.load(new FileInputStream(TEST_PROPERTIES));
694:                String src = "Hallo {{Image.png|Caption|M,[-]}}";
695:                String target = "Hallo [{ImageX src='Image.png' caption='Caption' width='180' border=false}]";
696:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
697:                        props, src));
698:            }
699:
700:            public void testImageX7() throws Exception {
701:                Properties props = new Properties();
702:                props.load(new FileInputStream(TEST_PROPERTIES));
703:                String src = "Hallo [[http://www.gmx.de|{{Image.png||XL,+X,[-]}}]]";
704:                String target = "Hallo [{ImageX src='Image.png' link='http://www.gmx.de' width='540' float='right' border=false}]";
705:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
706:                        props, src));
707:            }
708:
709:            public void testImageX8() throws Exception {
710:                Properties props = new Properties();
711:                props.load(new FileInputStream(TEST_PROPERTIES));
712:                String src = "Hallo [[http://www.gmx.de|{{Image.png||XL,+X,X-,[-]}}]]";
713:                String target = "Hallo [{ImageX src='Image.png' link='http://www.gmx.de' width='540' float='right' align='left' border=false}]";
714:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
715:                        props, src));
716:            }
717:
718:            public void testImageX9() throws Exception {
719:                Properties props = new Properties();
720:                props.load(new FileInputStream(TEST_PROPERTIES));
721:                String src = "Hallo [[http://www.gmx.de|{{Image.png|Caption|XL,+X,X-,[-]}}]]";
722:                String target = "Hallo [{ImageX src='Image.png' link='http://www.gmx.de' caption='Caption' width='540' float='right' align='left' border=false}]";
723:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
724:                        props, src));
725:            }
726:
727:            public void testImageX10() throws Exception {
728:                Properties props = new Properties();
729:                props.load(new FileInputStream(TEST_PROPERTIES));
730:                String src = "Hallo [[http://www.gmx.de|{{Image.png|Caption|xL, +X , X-, [-]}}]]";
731:                String target = "Hallo [{ImageX src='Image.png' link='http://www.gmx.de' caption='Caption' width='540' float='right' align='left' border=false}]";
732:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
733:                        props, src));
734:            }
735:
736:            public void testImageX12() {
737:                String src = "Hallo [[http://www.google.de|{{Image.png||120px}}]]\r\n[[http://www.google.de|{{Image.png||120cm}}]]";
738:                String target = "Hallo [{ImageX src='Image.png' link='http://www.google.de' width='120'}]\r\n"
739:                        + "[{ImageX src='Image.png' link='http://www.google.de' widthInCM='120'}]";
740:                ;
741:                Properties props = new Properties();
742:                props.put("creole.imagePlugin.para.%px", "width='%'");
743:                props.put("creole.imagePlugin.para.%cm", "widthInCM='%'");
744:                props.put("creole.imagePlugin.name", "ImageX");
745:
746:                assertEquals(target, new CreoleToJSPWikiTranslator().translate(
747:                        props, src));
748:            }
749:
750:            public void testJuwi() {
751:                String src = "<<JudoScript\r\n" + "if this works then ok\r\n"
752:                        + "else improve the programm\r\n" + ">>";
753:                String target = "[{JudoScript\r\n"
754:                        + "if this works then ok\r\n"
755:                        + "else improve the programm\r\n" + "}]";
756:                assertEquals(target, translate(src));
757:            }
758:
759:            public void testPluginBold() {
760:
761:                String src = "**<<CurrentTimePlugin format='HH:mm \'am\' dd-MMM-yyyy'>>**";
762:                String tar = "__[{CurrentTimePlugin format='HH:mm \'am\' dd-MMM-yyyy'}]__";
763:
764:                assertEquals(tar, translate(src));
765:            }
766:
767:            public void testPluginLinebreakPlugin() {
768:
769:                String src = "<<CurrentTimePlugin format=zzzz>>\r\n" + "\r\n"
770:                        + "<<RecentChangesPlugin since='30'>>";
771:
772:                String tar = "[{CurrentTimePlugin format=zzzz}]\r\n" + "\r\n"
773:                        + "[{RecentChangesPlugin since='30'}]";
774:
775:                assertEquals(tar, translate(src));
776:            }
777:
778:            public void testJuwi2() {
779:                String src = "<<JudoScript\r\n"
780:                        + "if [[this]] works then ok\r\n"
781:                        + "else improve the programm\r\n" + ">>";
782:                String target = "[{JudoScript\r\n"
783:                        + "if [[this]] works then ok\r\n"
784:                        + "else improve the programm\r\n" + "}]";
785:                assertEquals(target, translate(src));
786:
787:            }
788:
789:            public void testURL() {
790:                String src = "Hallo[[https://wiki.i3g.hs-heilbronn.de]]Hallo";
791:                String target = "Hallo[https://wiki.i3g.hs-heilbronn.de]Hallo";
792:
793:                assertEquals(target, translate(src));
794:            }
795:
796:            public void testSourcePlugin() {
797:                String src = "Hallo<<Hallo{{{Test}}}Hallo>>Hallo";
798:                String target = "Hallo[{Hallo{{{Test}}}Hallo}]Hallo";
799:
800:                assertEquals(target, translate(src));
801:            }
802:
803:            public void testMultilinePlugin3() {
804:                String src = "Hallo\r\n" + "<<Hallo\r\n" + "Hallo\r\n"
805:                        + "Hallo\r\n" + ">>";
806:
807:                String target = "Hallo\r\n" + "[{Hallo\r\n" + "Hallo\r\n"
808:                        + "Hallo\r\n" + "}]";
809:
810:                assertEquals(target, translate(src));
811:            }
812:
813:            public String translate(String src) {
814:                CreoleToJSPWikiTranslator translator = new CreoleToJSPWikiTranslator();
815:
816:                return translator.translate(new Properties(), src);
817:            }
818:
819:            public static Test suite() {
820:                return new TestSuite(JSPWikiMarkupParserTest.class);
821:            }
822:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.