KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > converters > extended > StackTraceElementConverterTest


1 package com.thoughtworks.xstream.converters.extended;
2
3 import com.thoughtworks.xstream.XStream;
4 import com.thoughtworks.xstream.converters.MarshallingContext;
5 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
6 import com.thoughtworks.acceptance.AbstractAcceptanceTest;
7 import junit.framework.TestCase;
8 import com.thoughtworks.xstream.converters.extended.StackTraceElementConverter;
9
10 /**
11  * @author <a HREF="mailto:boxley@thoughtworks.com">B. K. Oxley (binkley)</a>
12  * @author Joe Walnes
13  */

14 public class StackTraceElementConverterTest extends AbstractAcceptanceTest {
15
16     private StackTraceElementFactory factory = new StackTraceElementFactory();
17
18     public void testSerializesStackTraceElement() {
19         StackTraceElement JavaDoc trace = factory.unknownSourceElement("com.blah.SomeClass", "someMethod");
20         String JavaDoc expectedXml = "<trace>com.blah.SomeClass.someMethod(Unknown Source)</trace>";
21         assertBothWays(trace, expectedXml);
22     }
23
24     public void testIncludesDebugInformation() {
25         StackTraceElement JavaDoc trace = factory.element("com.blah.SomeClass", "someMethod", "SomeClass.java", 22);
26         String JavaDoc expectedXml = "<trace>com.blah.SomeClass.someMethod(SomeClass.java:22)</trace>";
27         assertBothWays(trace, expectedXml);
28     }
29
30     public void testIncludesPartialDebugInformation() {
31         StackTraceElement JavaDoc trace = factory.element("com.blah.SomeClass", "someMethod", "SomeClass.java");
32         String JavaDoc expectedXml = "<trace>com.blah.SomeClass.someMethod(SomeClass.java)</trace>";
33         assertBothWays(trace, expectedXml);
34     }
35
36     public void testIncludesNativeMethods() {
37         StackTraceElement JavaDoc trace = factory.nativeMethodElement("com.blah.SomeClass", "someMethod");
38         String JavaDoc expectedXml = "<trace>com.blah.SomeClass.someMethod(Native Method)</trace>";
39         assertBothWays(trace, expectedXml);
40     }
41
42     public void testSupportsInnerClasses() {
43         StackTraceElement JavaDoc trace = factory.unknownSourceElement("com.blah.SomeClass$Inner$2", "someMethod");
44         String JavaDoc expectedXml = "<trace>com.blah.SomeClass$Inner$2.someMethod(Unknown Source)</trace>";
45         assertBothWays(trace, expectedXml);
46     }
47
48 }
49
Popular Tags