objectiddictionarytest.java

来自「xstream是一个把java object序列化成xml文件的开源库,轻便好用」· Java 代码 · 共 30 行

JAVA
30
字号
package com.thoughtworks.xstream.core.util;import junit.framework.TestCase;public class ObjectIdDictionaryTest extends TestCase {    public void testMapsIdsToObjectReferences() {        ObjectIdDictionary dict = new ObjectIdDictionary();        Object a = new Object();        Object b = new Object();        Object c = new Object();        dict.associateId(a, "id a");        dict.associateId(b, "id b");        dict.associateId(c, "id c");        assertEquals("id a", dict.lookupId(a));        assertEquals("id b", dict.lookupId(b));        assertEquals("id c", dict.lookupId(c));    }    public void testTreatsObjectsThatAreEqualButNotSameInstanceAsDifferentReference() {        ObjectIdDictionary dict = new ObjectIdDictionary();        Integer a = new Integer(3);        Integer b = new Integer(3);        dict.associateId(a, "id a");        dict.associateId(b, "id b");        assertEquals("id a", dict.lookupId(a));        assertEquals("id b", dict.lookupId(b));    }}

⌨️ 快捷键说明

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