davpathtest.java

来自「JSP 的一个wiki 系统」· Java 代码 · 共 137 行

JAVA
137
字号
/* * (C) Janne Jalkanen 2005 *  */package com.ecyrd.jspwiki.dav;import junit.framework.Test;import junit.framework.TestCase;import junit.framework.TestSuite;public class DavPathTest extends TestCase{    public void testCreate1()    {        String src = "/";                DavPath dp = new DavPath( src );                assertEquals( "path", "/", dp.pathPart() );        assertEquals( "file", "", dp.filePart() );    }    public void testCreate2()    {        String src = "/test/foo/bar.txt";                DavPath dp = new DavPath( src );                assertEquals( "path", "/test/foo/", dp.pathPart() );        assertEquals( "file", "bar.txt", dp.filePart() );            }    public void testCreate3()    {        String src = "/test/foo/";                DavPath dp = new DavPath( src );                assertEquals( "path", "/test/foo/", dp.pathPart() );        assertEquals( "file", "", dp.filePart() );            }    public void testCreate4()    {        String src = "";                DavPath dp = new DavPath( src );                assertEquals( "path", "/", dp.pathPart() );        assertEquals( "file", "", dp.filePart() );            }        public void testSubPath()    {        String src = "/foo/bar/goo/blot";                DavPath dp = new DavPath( src );                DavPath subdp = dp.subPath( 2 );                assertEquals( "goo/blot", subdp.getPath() );    }    public void testSubPath2()    {        String src = "/foo/bar/goo/blot";                DavPath dp = new DavPath( src );                DavPath subdp = dp.subPath( 0 );                assertEquals( "/foo/bar/goo/blot", subdp.getPath() );    }    public void testSubPath3()    {        String src = "/foo/bar/goo/blot";                DavPath dp = new DavPath( src );                DavPath subdp = dp.subPath( 3 );                assertEquals( "blot", subdp.getPath() );    }    public void testGetPath()    {        String src = "/foo/bar/goo/blot";                DavPath dp = new DavPath( src );                        assertEquals( "/foo/bar/goo/blot", dp.getPath() );    }    public void testRoot1()    {        String src = "";                DavPath dp = new DavPath( src );                        assertTrue( dp.isRoot() );    }    public void testRoot2()    {        String src = "/";                DavPath dp = new DavPath( src );                        assertTrue( dp.isRoot() );    }    public void testRoot3()    {        String src = "foo";                DavPath dp = new DavPath( src );                        assertFalse( dp.isRoot() );    }    public void testRoot4()    {        String src = "/foo";                DavPath dp = new DavPath( src );                        assertFalse( dp.isRoot() );    }        public static Test suite()    {        return new TestSuite( DavPathTest.class );    }}

⌨️ 快捷键说明

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