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

📄 aliastest.java

📁 xstream是一个把java object序列化成xml文件的开源库,轻便好用
💻 JAVA
字号:
package com.thoughtworks.acceptance;import com.thoughtworks.acceptance.someobjects.X;import com.thoughtworks.xstream.alias.CannotResolveClassException;/** * @author Paul Hammant */public class AliasTest extends AbstractAcceptanceTest {    public void testBarfsIfAliasDoesNotExist() {        String xml = "" +                "<X-array>\n" +                "  <X>\n" +                "    <anInt>0</anInt>\n" +                "  </X>\n" +                "</X-array>";        // now change the alias        xstream.alias("Xxxxxxxx", X.class);        try {            xstream.fromXML(xml);            fail("ShouldCannotResolveClassException expected");        } catch (CannotResolveClassException expectedException) {            // expected        }    }    public void testAliasWithUnderscore() {        String xml = "" +                "<X_alias>\n" +                "  <anInt>0</anInt>\n" +                "</X_alias>";        // now change the alias        xstream.alias("X_alias", X.class);        X x = new X(0);        try {            assertBothWays(x, xml);            fail("CannotResolveClassException expected");        } catch (CannotResolveClassException e) {            //expected - marshalling works but not unmarshalling        }    }}

⌨️ 快捷键说明

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