📄 jspwikimarkupparsertest.java
字号:
"</ol>", result ); } /** * <pre> * * bullet A * ** bullet A_1 * *# number A_1 * * bullet B * </pre> * * would come out as: * * <ul> * <li>bullet A * <ul> * <li>bullet A_1</li> * </ul> * <ol> * <li>number A_1</li> * </ol> * </li> * <li>bullet B</li> * </ul> * */ public void testMixedListOnSameLevel() throws Exception { String src="* bullet A\n** bullet A_1\n*# number A_1\n* bullet B\n"; String result = translate(src); // Remove newlines for easier parsing. result = TextUtil.replaceString( result, "\n", "" ); assertEquals( "<ul>"+ "<li>bullet A"+ "<ul>"+ "<li>bullet A_1</li>"+ "</ul>"+ "<ol>"+ "<li>number A_1</li>"+ "</ol>"+ "</li>"+ "<li>bullet B</li>"+ "</ul>" , result ); } /** * <pre> * * bullet A * ** bullet A_1 * ## number A_1 * * bullet B * </pre> * * would come out as: * * <ul> * <li>bullet A * <ul> * <li>bullet A_1</li> * </ul> * <ol> * <li>number A_1</li> * </ol> * </li> * <li>bullet B</li> * </ul> * */ public void testMixedListOnSameLevel2() throws Exception { String src="* bullet A\n** bullet A_1\n## number A_1\n* bullet B\n"; String result = translate(src); // Remove newlines for easier parsing. result = TextUtil.replaceString( result, "\n", "" ); assertEquals( "<ul>"+ "<li>bullet A"+ "<ul>"+ "<li>bullet A_1</li>"+ "</ul>"+ "<ol>"+ "<li>number A_1</li>"+ "</ol>"+ "</li>"+ "<li>bullet B</li>"+ "</ul>" , result ); } /** * <pre> * * bullet 1 * ## number 2 * ** bullet 3 * ## number 4 * * bullet 5 * </pre> * * would come out as: * * <ul> * <li>bullet 1 * <ol><li>number 2</li></ol> * <ul><li>bullet 3</li></ul> * <ol><li>number 4</li></ol> * </li> * <li>bullet 5</li> * </ul> * */ public void testMixedListOnSameLevel3() throws Exception { String src="* bullet 1\n## number 2\n** bullet 3\n## number 4\n* bullet 5\n"; String result = translate(src); // Remove newlines for easier parsing. result = TextUtil.replaceString( result, "\n", "" ); assertEquals( "<ul>"+ "<li>bullet 1"+ "<ol><li>number 2</li></ol>"+ "<ul><li>bullet 3</li></ul>"+ "<ol><li>number 4</li></ol>"+ "</li>"+ "<li>bullet 5</li>"+ "</ul>" , result ); } /** * <pre> * # number 1 * ** bullet 2 * ## number 3 * ** bullet 4 * # number 5 * </pre> * * would come out as: * * <ol> * <li>number 1 * <ul><li>bullet 2</li></ul> * <ol><li>number 3</li></ol> * <ul><li>bullet 4</li></ul> * </li> * <li>number 5</li> * </ol> * */ public void testMixedListOnSameLevel4() throws Exception { String src="# number 1\n** bullet 2\n## number 3\n** bullet 4\n# number 5\n"; String result = translate(src); // Remove newlines for easier parsing. result = TextUtil.replaceString( result, "\n", "" ); assertEquals( "<ol>"+ "<li>number 1"+ "<ul><li>bullet 2</li></ul>"+ "<ol><li>number 3</li></ol>"+ "<ul><li>bullet 4</li></ul>"+ "</li>"+ "<li>number 5</li>"+ "</ol>" , result ); } public void testNestedList() throws Exception { String src="*Item A\n**Numbered 1\n**Numbered 2\n*Item B\n"; String result = translate(src); // Remove newlines for easier parsing. result = TextUtil.replaceString( result, "\n", "" ); assertEquals( "<ul><li>Item A"+ "<ul><li>Numbered 1</li>"+ "<li>Numbered 2</li>"+ "</ul></li>"+ "<li>Item B</li>"+ "</ul>", result ); } public void testNestedList2() throws Exception { String src="*Item A\n**Numbered 1\n**Numbered 2\n***Numbered3\n*Item B\n"; String result = translate(src); // Remove newlines for easier parsing. result = TextUtil.replaceString( result, "\n", "" ); assertEquals( "<ul><li>Item A"+ "<ul><li>Numbered 1</li>"+ "<li>Numbered 2"+ "<ul><li>Numbered3</li>"+ "</ul></li>"+ "</ul></li>"+ "<li>Item B</li>"+ "</ul>", result ); } public void testPluginInsert() throws Exception { String src="[{INSERT com.ecyrd.jspwiki.plugin.SamplePlugin WHERE text=test}]"; assertEquals( "test", translate(src) ); } public void testPluginHTMLInsert() throws Exception { String src="[{INSERT com.ecyrd.jspwiki.plugin.SamplePlugin WHERE text='<b>Foo</b>'}]"; assertEquals( "<b>Foo</b>", translate(src) ); } public void testPluginNoInsert() throws Exception { String src="[{SamplePlugin text=test}]"; assertEquals( "test", translate(src) ); } public void testPluginInsertJS() throws Exception { String src="Today: [{INSERT JavaScriptPlugin}] ''day''."; assertEquals( "Today: <script language=\"JavaScript\"><!--\nfoo='';\n--></script>\n <i>day</i>.", translate(src) ); } public void testShortPluginInsert() throws Exception { String src="[{INSERT SamplePlugin WHERE text=test}]"; assertEquals( "test", translate(src) ); } /** * Test two plugins on same row. */ public void testShortPluginInsert2() throws Exception { String src="[{INSERT SamplePlugin WHERE text=test}] [{INSERT SamplePlugin WHERE text=test2}]"; assertEquals( "test test2", translate(src) ); } public void testPluginQuotedArgs() throws Exception { String src="[{INSERT SamplePlugin WHERE text='test me now'}]"; assertEquals( "test me now", translate(src) ); } public void testPluginDoublyQuotedArgs() throws Exception { String src="[{INSERT SamplePlugin WHERE text='test \\'me too\\' now'}]"; assertEquals( "test 'me too' now", translate(src) ); } public void testPluginQuotedArgs2() throws Exception { String src="[{INSERT SamplePlugin WHERE text=foo}] [{INSERT SamplePlugin WHERE text='test \\'me too\\' now'}]"; assertEquals( "foo test 'me too' now", translate(src) ); } /** * Plugin output must not be parsed as Wiki text. */ public void testPluginWikiText() throws Exception { String src="[{INSERT SamplePlugin WHERE text=PageContent}]"; assertEquals( "PageContent", translate(src) ); } /** * Nor should plugin input be interpreted as wiki text. */ public void testPluginWikiText2() throws Exception { String src="[{INSERT SamplePlugin WHERE text='----'}]"; assertEquals( "----", translate(src) ); } public void testMultilinePlugin1() throws Exception { String src="Test [{INSERT SamplePlugin WHERE\n text=PageContent}]"; assertEquals( "Test PageContent", translate(src) ); } public void testMultilinePluginBodyContent() throws Exception { String src="Test [{INSERT SamplePlugin\ntext=PageContent\n\n123\n456\n}]"; assertEquals( "Test PageContent (123+456+)", translate(src) ); } public void testMultilinePluginBodyContent2() throws Exception { String src="Test [{INSERT SamplePlugin\ntext=PageContent\n\n\n123\n456\n}]"; assertEquals( "Test PageContent (+123+456+)", translate(src) ); } public void testMultilinePluginBodyContent3() throws Exception { String src="Test [{INSERT SamplePlugin\n\n123\n456\n}]"; assertEquals( "Test (123+456+)", translate(src) ); } /** * Has an extra space after plugin name. */ public void testMultilinePluginBodyContent4() throws Exception { String src="Test [{INSERT SamplePlugin \n\n123\n456\n}]"; assertEquals( "Test (123+456+)", translate(src) ); } /** * Check that plugin end is correctly recognized. */ public void testPluginEnd() throws Exception { String src="Test [{INSERT SamplePlugin text=']'}]"; assertEquals( "Test ]", translate(src) ); } public void testPluginEnd2() throws Exception { String src="Test [{INSERT SamplePlugin text='a[]+b'}]"; assertEquals( "Test a[]+b", translate(src) ); } public void testPluginEnd3() throws Exception { String src="Test [{INSERT SamplePlugin\n\na[]+b\n}]"; assertEquals( "Test (a[]+b+)", translate(src) ); } public void testPluginEnd4() throws Exception { String src="Test [{INSERT SamplePlugin text='}'}]"; assertEquals( "Test }", translate(src) ); } public void testPluginEnd5() throws Exception { String src="Test [{INSERT SamplePlugin\n\na[]+b{}\nGlob.\n}]"; assertEquals( "Test (a[]+b{}+Glob.+)", translate(src) ); } public void testPluginEnd6() throws Exception { String src="Test [{INSERT SamplePlugin\n\na[]+b{}\nGlob.\n}}]"; assertEquals( "Test (a[]+b{}+Glob.+})", translate(src) ); } public void testNestedPlugin1() throws Exception { String src="Test [{INSERT SamplePlugin\n\n[{SamplePlugin}]\nGlob.\n}}]"; assertEquals( "Test ([{SamplePlugin}]+Glob.+})", translate(src) ); } public void testNestedPlugin2() throws Exception { String src="[{SET foo='bar'}]Test [{INSERT SamplePlugin\n\n[{SamplePlugin text='[{$foo}]'}]\nGlob.\n}}]"; assertEquals( "Test ([{SamplePlugin text='[bar]'}]+Glob.+})", translate(src) ); } // FIXME: I am not entirely certain if this is the right result // Perhaps some sort of an error should be checked? public void testPluginNoEnd() throws Exception { String src="Test [{INSERT SamplePlugin\n\na+b{}\nGlob.\n}"; assertEquals( "Test {INSERT SamplePlugin\n\na+b{}\nGlob.\n}", translate(src) ); } public void testVariableInsert() throws Exception {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -