⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmlstringtowikitranslatortest.java

📁 jspwiki source code,jspwiki source code
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public void testCenter() throws Exception    {        assertEquals( "\n%%( text-align: center; )\nHello \\\\\nWorld!\n%%\n", html2wiki                      .translate( "<div style=\"text-align: center;\">Hello<br>World!</div>" ) );              assertEquals( "__%%( text-align: center; display: block; )Hello \\\\World!%%__", html2wiki                      .translate( "<span style=\"font-weight: bold; text-align: center; display: block;\">Hello<br>World!</span>" ) );            }    public void testImage() throws Exception    {        assertEquals(                     "[{Image src='Homunkulus/homunculus4.jpg' align='left'}]",                     html2wiki                             .translate( "<table class=\"imageplugin\" align=\"left\" border=\"0\"> <tbody><tr><td><img src=\"attach?page=Homunkulus%2Fhomunculus4.jpg\"></td></tr> </tbody></table>" ) );       assertEquals( "[{Image src=\'AbenteuerQuilpins/Quilpins.jpg\' align=\'left\'}]", html2wiki               .translate( "<table class=\"imageplugin\" align=\"left\" border=\"0\">\r\n"                           + "<tbody><tr><td><img src=\"attach?page=AbenteuerQuilpins%2FQuilpins.jpg\"></td></tr>\r\n</tbody>"                           + "</table>" ) );       assertEquals(                     "[{Image src=\'AbenteuerQuilpins/Quilpins.jpg\' caption=\'Testing Image\' style=\'font-size: 120%; color: green;\'}]",                     html2wiki                             .translate( "<table class=\"imageplugin\" style=\"font-size: 120%; color: green;\" border=\"0\">\r\n"                                         + "<caption align=\"bottom\">Testing Image</caption>\r\n"                                         + "<tbody><tr><td><img src=\"attach?page=AbenteuerQuilpins%2FQuilpins.jpg\"></td></tr>\r\n</tbody>"                                         + "</table>" ) );       assertEquals(                     "[{Image src=\'http://opi.yahoo.com/online?u=YahooUser1234&m=g&t=2\' link=\'http://edit.yahoo.com/config/send_webmesg?.target=YahooUser1234&.src=pg\'}]",                     html2wiki                             .translate( "<table class=\"imageplugin\" border=\"0\">\r\n"                                         + "<tbody><tr><td>"                                         + "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=YahooUser1234&amp;.src=pg\">"                                         + "<img src=\"http://opi.yahoo.com/online?u=YahooUser1234&amp;m=g&amp;t=2\">"                                         + "</a></td></tr>\r\n" + "</tbody>" + "</table>" ) );       assertEquals(                     "[{Image src=\'homunculus4.jpg\' align=\'left\' height=\'100px\' width=\'100px\' alt=\'alt text\' caption=\'caption text\' link=\'http://google.de\' border=\'1\'}]",                     html2wiki                             .translate( "<table class=\"imageplugin\" align=\"left\" border=\"0\"> \r\n"                                         + "  <caption align=\"bottom\">caption text</caption> \r\n"                                         + "  <tbody><tr><td>\r\n"                                         + "    <a href=\"http://google.de\"><img src=\"homunculus4.jpg\" alt=\"alt text\" border=\"1\" height=\"100px\" width=\"100px\">\r\n"                                         + "    </a></td></tr> \r\n" + "  </tbody>  \r\n" + "</table>" ) );       assertEquals(                     "[{Image src=\'http://opi.yahoo.com/online?u=YahooUser1234&m=g&t=2\' link=\'http://edit.yahoo.com/config/send_webmesg?.target=YahooUser1234&.src=pg\'}]",                     html2wiki                             .translate( "  <a href=\"http://edit.yahoo.com/config/send_webmesg?.target=YahooUser1234&amp;.src=pg\">\r\n"                                         + "  <img src=\"http://opi.yahoo.com/online?u=YahooUser1234&amp;m=g&amp;t=2\">\r\n"                                         + "  </a" ) );            }        public void testPlugin() throws Exception    {        assertEquals( "This is a private homepage done by\n" + "----\n"                      + "Dies ist eine private, nicht-kommerzielle Homepage von\n"                      + "[{Text2gif width=\'150\' height=\'100\' \n" + " \n" + "Sebastian L. Baltes \n" + "Lange Str. 53 \n"                      + "44137 Dortmund \n" + " \n" + "email: info@sorokan.de \n" + "}]\n", html2wiki                .translate( "This is a private homepage done by\n" + "<hr>\n"                            + "Dies ist eine private, nicht-kommerzielle Homepage von\n" + "<p>\n"                            + "[{Text2gif width=\'150\' height=\'100\'\n" + "<br> <br>Sebastian L. Baltes\n"                            + "<br>Lange Str. 53\n" + "<br>44137 Dortmund\n" + "<br> <br>email: info@sorokan.de\n" + "<br>}]\n"                            + "</p><p>" ) );            }    public void testCSS() throws Exception    {        assertEquals( "%%( color: rgb(255, 0, 0); )Und niemand wird sie sehen%%, die", html2wiki                      .translate( "<span style=\"color: rgb(255, 0, 0);\">Und niemand wird sie sehen</span>, die" ) );        assertEquals( "\n%%information\nCSS class here\n%%\n\nFont %%( color: #ff9900; font-family: arial; font-size: large; )styling here.%% Some %%( background-color: #ffff00; )more here%%.\n",                       html2wiki.translate( "<div class=\"information\">CSS class here</div>\n"                                  + "<p>Font <font face=\"Arial\" color=\"#ff9900\" size=\"5\">styling here.</font>"                                  + " Some <font style=\"background-color: #ffff00\">more here</font>.</p>" ) );                assertEquals( "\n\n%%( text-align: center; )\nsome leading text %%strike line through this text%% some trailing text\n%%\n\n",                      html2wiki.translate( "<p align=\"center\">some leading text <strike>line through this text</strike> some trailing text</p>" ) );    }    public void testParsing() throws Exception    {        assertEquals( "Hello World!", html2wiki.translate( "Hello World!" ) );        assertEquals( "a", html2wiki.translate( "a" ) );        assertEquals( "a \\\\b", html2wiki.translate( "a<br/>b" ) );        assertEquals( "\\\\\\", html2wiki.translate( "\\\\\\" ) );        assertEquals( "[{Test\nHello World!}]", html2wiki.translate( "[{Test\\\\Hello World!}]" ) );        assertEquals( "{{{[{Test\\\\Hello World!}]}}}", html2wiki.translate( "{{{[{Test\\\\Hello World!}]}}}" ) );        assertEquals(                      "{{{[{Test\\\\Hello World!}]}}}{{{[{Test\\\\\\\\Hello World!}]}}}[{Test\n\nHello World!}][{Test\n\nHello World!}]",                      html2wiki                              .translate( "{{{[{Test\\\\Hello World!}]}}}{{{[{Test\\\\\\\\Hello World!}]}}}[{Test\\\\\\\\Hello World!}][{Test\\\\\\\\Hello World!}]" ) );    }    public void testBoldAndItalic()        throws Exception    {        assertEquals(                     "Dies ist __bold__, ''italic'' und __''both''__.",                     html2wiki.translate( "Dies ist <span style=\"font-weight: bold;\">bold</span>, <span style=\"font-style: italic;\">italic</span> und <span style=\"font-style: italic; font-weight: bold;\">both</span>." ) );        assertEquals(                     "Dies ist __bold__, ''italic'' und __''both''__ 2.",                     html2wiki.translate( "Dies ist <b>bold</b>, <i>italic</i> und <b><i>both</i></b> 2." ) );        assertEquals(                     "Dies ist __bold__, ''italic'' und __''both''__ 3.",                     html2wiki.translate( "Dies ist <strong>bold</strong>, <em>italic</em> und <strong><em>both</em></strong> 3." ) );        assertEquals( "Wilma: ''Ich m\u00f6chte hiermal in allerDeutlichkeit sagen! ''", html2wiki                      .translate( "Wilma: <i>Ich             m\u00f6chte hier\nmal in aller\nDeutlichkeit sagen! </i>" ) );    }        public void testHeading() throws Exception    {        assertEquals( "\n!!! Heading 1 should be translated to large heading.\n",                     html2wiki.translate( "<h1>Heading 1 should be translated to large heading.</h1>" ) );                assertEquals( "\n!!! Heading 2 should be translated to large heading.\n",                      html2wiki.translate( "<h2>Heading 2 should be translated to large heading.</h2>" ) );                assertEquals( "\n!! Heading 3 should be translated to medium heading.\n",                      html2wiki.translate( "<h3>Heading 3 should be translated to medium heading.</h3>" ) );                assertEquals( "\n! Heading 4 should be translated to small heading.\n",                      html2wiki.translate( "<h4>Heading 4 should be translated to small heading.</h4>" ) );            }        public void testForm() throws Exception    {        assertEquals( "\n[{FormOpen form='myForm'}]\n\n[{FormClose}]\n",                      html2wiki.translate( "<div class=\"wikiform\">\n<form name=\"myForm\"><input name=\"formname\" value=\"myForm\" type=\"hidden\">\n</div>" ) );                assertEquals( "[{FormInput type='hidden' name='myHiddenField' value='myHiddenField'}]myHiddenField",                      html2wiki.translate( "<input name=\"nbf_myHiddenField\" value=\"myHiddenField\" type=\"hidden\">myHiddenField" ) );                assertEquals( "[{FormInput type='checkbox' name='myCheckbox' value='myCheckbox' checked='checked'}]myCheckbox",                      html2wiki.translate( "<input checked=\"checked\" value=\"myCheckbox\" name=\"nbf_myCheckbox\" type=\"checkbox\">myCheckbox" ) );                assertEquals( "[{FormInput type='radio' name='myRadioButton' value='myRadioButton'}]myRadioButton",                      html2wiki.translate( "<input name=\"nbf_myRadioButton\" value=\"myRadioButton\" type=\"radio\">myRadioButton" ) );                assertEquals( "[{FormInput type='button' name='myButton' value='myButton'}]myButton",                      html2wiki.translate( "<input name=\"nbf_myButton\" value=\"myButton\" type=\"button\">myButton" ) );        assertEquals( "[{FormTextarea name='myTextarea' rows='6' cols='50'}]myTextarea",                      html2wiki.translate( "<textarea cols=\"50\" name=\"nbf_myTextarea\" rows=\"6\"></textarea>myTextarea" ) );                assertEquals( "[{FormSelect name='mySelectionList' value='apple;*orange;pear'}]mySelectList",                      html2wiki.translate( "<select name=\"nbf_mySelectionList\">\n"                                           + "<option value=\"apple\">apple</option>\n"                                           + "<option selected=\"selected\" value=\"orange\">orange</option>\n"                                           + "<option value=\"pear\">pear</option>\n"                                           + "</select>mySelectList" ) );            }        public void testDefinitionList() throws Exception    {        assertEquals( "\n;__Priority__:High\n\n;__TODO Name__:Initialization\n\n;__Requester__:John Smith\n",                      html2wiki.translate( "<dl><dt><b>Priority</b></dt><dd>High</dd></dl>\n"                                           + "<dl><dt><b>TODO Name</b></dt><dd>Initialization</dd></dl>\n"                                           + "<dl><dt><b>Requester</b></dt><dd>John Smith</dd></dl>\n" ) );                assertEquals( "Some text here\n;:(A)indented comment here\n\n;:(B)another comment here\n",                      html2wiki.translate( "Some text here\n<dl><dt></dt><dd>(A)indented comment here</dd></dl>\n"                                           + "<dl><dt></dt><dd>(B)another comment here</dd></dl>\n" ) );        assertEquals( "\n;__New Page Name__:[{FormInput type='text' name='newPageName'}]\n",                      html2wiki.translate( "\n<dl><dt><b>New Page Name</b></dt><dd><input name=\"nbf_newPageName\" type=\"text\"></dd></dl>\n" ) );    }        public static Test suite()    {        return new TestSuite( HtmlStringToWikiTranslatorTest.class );    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -