Methods Summary |
---|
public void | testCarriageReturn()Test capturing stack trace from throwable that just has a carriage return.
ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\r"));
String[] rep = ti.getThrowableStrRep();
assertEquals(1, rep.length);
assertEquals("", rep[0]);
|
public void | testEmpty()Test capturing stack trace from a throwable that
does nothing on a call to printStackTrace.
ThrowableInformation ti = new ThrowableInformation(new EmptyThrowable());
String[] rep = ti.getThrowableStrRep();
assertEquals(0, rep.length);
|
public void | testGetThrowable()Test that getThrowable returns the throwable provided to the constructor.
Throwable t = new StringThrowable("Hello, World");
ThrowableInformation ti = new ThrowableInformation(t);
assertSame(t, ti.getThrowable());
|
public void | testLineFeed()Test capturing stack trace from throwable that just has a line feed.
ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\n"));
String[] rep = ti.getThrowableStrRep();
assertEquals(1, rep.length);
assertEquals("", rep[0]);
|
public void | testLineFeedBlank()Test capturing stack trace from throwable that a line feed followed by blank.
ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\n "));
String[] rep = ti.getThrowableStrRep();
assertEquals(2, rep.length);
assertEquals("", rep[0]);
assertEquals(" ", rep[1]);
|
public void | testNotOverriddenBehavior()Test capturing stack trace from a throwable that uses the
PrintWriter methods not overridden in log4j 1.2.14 and earlier.
ThrowableInformation ti = new ThrowableInformation(new NotOverriddenThrowable());
String[] rep = ti.getThrowableStrRep();
assertEquals(7, rep.length);
StringBuffer buf = new StringBuffer(String.valueOf(true));
buf.append('a");
buf.append(String.valueOf(1));
buf.append(String.valueOf(2L));
buf.append(String.valueOf(Float.MAX_VALUE));
buf.append(String.valueOf(Double.MIN_VALUE));
buf.append(String.valueOf(true));
assertEquals(buf.toString(), rep[0]);
assertEquals("a", rep[1]);
assertEquals(String.valueOf(1), rep[2]);
assertEquals(String.valueOf(2L), rep[3]);
assertEquals(String.valueOf(Float.MAX_VALUE), rep[4]);
assertEquals(String.valueOf(Double.MIN_VALUE), rep[5]);
assertEquals("C", rep[6]);
|
public void | testNull()Test capturing stack trace from a throwable that passes
null to PrintWriter methods.
ThrowableInformation ti = new ThrowableInformation(new NullThrowable());
String[] rep = ti.getThrowableStrRep();
assertEquals(2, rep.length);
String nullStr = String.valueOf((Object) null);
assertEquals(nullStr + nullStr + nullStr, rep[0]);
assertEquals(nullStr, rep[1]);
|
public void | testOverriddenBehavior()Test capturing stack trace from a throwable that only uses the
PrintWriter methods overridden in log4j 1.2.14 and earlier.
ThrowableInformation ti = new ThrowableInformation(new OverriddenThrowable());
String[] rep = ti.getThrowableStrRep();
assertEquals(4, rep.length);
assertEquals("print(Object)print(char[])print(String)println(Object)", rep[0]);
assertEquals("println(char[])", rep[1]);
assertEquals("println(String)", rep[2]);
assertEquals("write(char[])ite(charite(Stri", rep[3]);
|
public void | testParsing()Test parsing of line breaks.
ThrowableInformation ti = new ThrowableInformation(
new StringThrowable("Line1\rLine2\nLine3\r\nLine4\n\rLine6"));
String[] rep = ti.getThrowableStrRep();
assertEquals(6, rep.length);
assertEquals("Line1", rep[0]);
assertEquals("Line2", rep[1]);
assertEquals("Line3", rep[2]);
assertEquals("Line4", rep[3]);
assertEquals("", rep[4]);
assertEquals("Line6", rep[5]);
|