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

📄 pathtrackertest.java

📁 xstream是一个把java object序列化成xml文件的开源库,轻便好用
💻 JAVA
字号:
package com.thoughtworks.xstream.io.path;import junit.framework.TestCase;public class PathTrackerTest extends TestCase {    private PathTracker pathTracker;    protected void setUp() throws Exception {        super.setUp();        // small initial capacity to ensure resizing works        pathTracker = new PathTracker(1);    }    public void testExposesXpathLikeExpressionOfLocationInWriter() {        assertEquals(new Path(""), pathTracker.getPath());        // <root>        pathTracker.pushElement("root");        assertEquals(new Path("/root"), pathTracker.getPath());        //   <childA>        pathTracker.pushElement("childA");        assertEquals(new Path("/root/childA"), pathTracker.getPath());        //   </childA>        pathTracker.popElement();        assertEquals(new Path("/root"), pathTracker.getPath());        //   <childB>        pathTracker.pushElement("childB");        assertEquals(new Path("/root/childB"), pathTracker.getPath());        //     <grandchild>        pathTracker.pushElement("grandchild");        assertEquals(new Path("/root/childB/grandchild"), pathTracker.getPath());        //     </grandchild>        pathTracker.popElement();        assertEquals(new Path("/root/childB"), pathTracker.getPath());        //   </childB>        pathTracker.popElement();        assertEquals(new Path("/root"), pathTracker.getPath());        // </root>        pathTracker.popElement();        assertEquals(new Path(""), pathTracker.getPath());    }    public void testAddsIndexIfSiblingOfSameTypeAlreadyExists() {        // <root>        pathTracker.pushElement("root");        //   <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child"), pathTracker.getPath());        //   </child>        pathTracker.popElement();        //   <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child[2]"), pathTracker.getPath());        //   </child>        pathTracker.popElement();        //   <another>        pathTracker.pushElement("another");        assertEquals(new Path("/root/another"), pathTracker.getPath());        //   </another>        pathTracker.popElement();        //   <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child[3]"), pathTracker.getPath());        //   </child>        pathTracker.popElement();        // ...    }    public void testAssociatesIndexOnlyWithDirectParent() {        // <root>        pathTracker.pushElement("root");        //   <child>        pathTracker.pushElement("child");        //     <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child/child"), pathTracker.getPath());        //     </child>        pathTracker.popElement();        //     <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child/child[2]"), pathTracker.getPath());        //     </child>        pathTracker.popElement();        //   </child>        pathTracker.popElement();        //   <child>        pathTracker.pushElement("child");        //     <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child[2]/child"), pathTracker.getPath());        //     </child>        pathTracker.popElement();        //     <child>        pathTracker.pushElement("child");        assertEquals(new Path("/root/child[2]/child[2]"), pathTracker.getPath());        // ...    }}

⌨️ 快捷键说明

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