Changed the test case to test each of the log traces in the array list.

This commit is contained in:
weingartner 2015-08-31 07:51:01 -03:00
parent 89bac529cc
commit b49d681598
1 changed files with 8 additions and 5 deletions

View File

@ -21,6 +21,7 @@ package com.cloud.utils.log;
import java.lang.reflect.Method;
import org.apache.commons.lang.StringUtils;
import org.junit.Assert;
import org.junit.Test;
@ -39,18 +40,20 @@ public class CglibThrowableRendererTest {
sampleClass.theFirstMethodThatCapturesAnException();
} catch (Exception e) {
String[] exceptions = cglibThrowableRenderer.doRender(e);
dumpExceptions(exceptions);
Assert.assertEquals(40, exceptions.length);
assertThatTheTraceListDoesNotContainsCgLibLogs(exceptions);
}
}
private void dumpExceptions(String[] exceptions) {
System.out.println("Dumping exception for debugging purposes");
private void assertThatTheTraceListDoesNotContainsCgLibLogs(String[] exceptions) {
for (String s : exceptions) {
System.out.println(s);
Assert.assertEquals(false, isCgLibLogTrace(s));
}
}
private boolean isCgLibLogTrace(String s) {
return StringUtils.contains(s, "net.sf.cglib.proxy");
}
static class SampleClass {
public void theFirstMethodThatCapturesAnException() {
try {