mirror of https://github.com/apache/cloudstack.git
Changed the test case to test each of the log traces in the array list.
This commit is contained in:
parent
89bac529cc
commit
b49d681598
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue