KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > acceptance > AliasTest


1 package com.thoughtworks.acceptance;
2
3 import com.thoughtworks.acceptance.someobjects.X;
4 import com.thoughtworks.xstream.alias.CannotResolveClassException;
5
6 /**
7  * @author Paul Hammant
8  */

9 public class AliasTest extends AbstractAcceptanceTest {
10
11    public void testBarfsIfAliasDoesNotExist() {
12
13        String JavaDoc xml = "" +
14                "<X-array>\n" +
15                " <X>\n" +
16                " <anInt>0</anInt>\n" +
17                " </X>\n" +
18                "</X-array>";
19
20        // now change the alias
21
xstream.alias("Xxxxxxxx", X.class);
22        try {
23            xstream.fromXML(xml);
24            fail("Should have barfed");
25        } catch (CannotResolveClassException expectedException) {
26            // expected
27
}
28    }
29
30 }
31
Popular Tags