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

📄 wikienginetest.java

📁 我想下载一个东西
💻 JAVA
字号:
package com.ecyrd.jspwiki;import junit.framework.*;import java.io.*;import java.util.*;import com.ecyrd.jspwiki.providers.*;import com.ecyrd.jspwiki.attachment.*;public class WikiEngineTest extends TestCase{    public static final String NAME1 = "Test1";    Properties props = new Properties();    TestEngine m_engine;    public WikiEngineTest( String s )    {        super( s );    }    public static Test suite()    {        return new TestSuite( WikiEngineTest.class );    }    public static void main(String[] args)    {        junit.textui.TestRunner.main(new String[] { WikiEngineTest.class.getName() } );    }    public void setUp()        throws Exception    {        props.load( TestEngine.findTestProperties() );        m_engine = new TestEngine(props);    }    public void tearDown()    {        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );        File f = new File( files, NAME1+FileSystemProvider.FILE_EXT );        f.delete();    }    public void testNonExistantDirectory()        throws Exception    {        String tmpdir = System.getProperties().getProperty("java.tmpdir");        String dirname = "non-existant-directory";        String newdir = tmpdir + File.separator + dirname;        props.setProperty( FileSystemProvider.PROP_PAGEDIR,                            newdir );        try        {            WikiEngine test = new TestEngine( props );            File f = new File( newdir );            assertTrue( "No dir created!", f.exists() && f.isDirectory() );        }        catch( WikiException e )        {            fail( "Wrong error!" );        }        finally        {            File f = new File( newdir );            f.delete();        }    }    public void testNonExistantDirProperty()        throws Exception    {        props.remove( FileSystemProvider.PROP_PAGEDIR );        try        {            WikiEngine test = new TestEngine( props );            fail( "Wiki did not warn about missing property." );        }        catch( WikiException e )        {            // This is okay.        }    }    /**     *  Check that calling pageExists( String ) works.     */    public void testNonExistantPage()        throws Exception    {        String pagename = "Test1";        assertEquals( "Page already exists",                      false,                      m_engine.pageExists( pagename ) );    }    /**     *  Check that calling pageExists( WikiPage ) works.     */    public void testNonExistantPage2()        throws Exception    {        WikiPage page = new WikiPage("Test1");        assertEquals( "Page already exists",                      false,                      m_engine.pageExists( page ) );    }    public void testPutPage()    {        String text = "Foobar.\r\n";        String name = NAME1;        m_engine.saveText( name, text );        assertEquals( "page does not exist",                      true,                      m_engine.pageExists( name ) );        assertEquals( "wrong content",                      text,                      m_engine.getText( name ) );    }    public void testPutPageEntities()    {        String text = "Foobar. &quot;\r\n";        String name = NAME1;        m_engine.saveText( name, text );        assertEquals( "page does not exist",                      true,                      m_engine.pageExists( name ) );        assertEquals( "wrong content",                      "Foobar. &amp;quot;\r\n",                      m_engine.getText( name ) );    }    /**     *  Cgeck that basic " is changed.     */    public void testPutPageEntities2()    {        String text = "Foobar. \"\r\n";        String name = NAME1;        m_engine.saveText( name, text );        assertEquals( "page does not exist",                      true,                      m_engine.pageExists( name ) );        assertEquals( "wrong content",                      "Foobar. &quot;\r\n",                      m_engine.getText( name ) );    }    public void testGetHTML()    {        String text = "''Foobar.''";        String name = NAME1;        m_engine.saveText( name, text );        String data = m_engine.getHTML( name );        assertEquals( "<I>Foobar.</I>\n",                       data );    }    public void testEncodeNameLatin1()    {        String name = "abc邃

⌨️ 快捷键说明

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