Skip to content

Commit b49d681

Browse files
Changed the test case to test each of the log traces in the array list.
1 parent 89bac52 commit b49d681

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

utils/src/test/java/com/cloud/utils/log/CglibThrowableRendererTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.lang.reflect.Method;
2323

24+
import org.apache.commons.lang.StringUtils;
2425
import org.junit.Assert;
2526
import org.junit.Test;
2627

@@ -39,18 +40,20 @@ public void testDoRendere() {
3940
sampleClass.theFirstMethodThatCapturesAnException();
4041
} catch (Exception e) {
4142
String[] exceptions = cglibThrowableRenderer.doRender(e);
42-
dumpExceptions(exceptions);
43-
Assert.assertEquals(40, exceptions.length);
43+
assertThatTheTraceListDoesNotContainsCgLibLogs(exceptions);
4444
}
4545
}
4646

47-
private void dumpExceptions(String[] exceptions) {
48-
System.out.println("Dumping exception for debugging purposes");
47+
private void assertThatTheTraceListDoesNotContainsCgLibLogs(String[] exceptions) {
4948
for (String s : exceptions) {
50-
System.out.println(s);
49+
Assert.assertEquals(false, isCgLibLogTrace(s));
5150
}
5251
}
5352

53+
private boolean isCgLibLogTrace(String s) {
54+
return StringUtils.contains(s, "net.sf.cglib.proxy");
55+
}
56+
5457
static class SampleClass {
5558
public void theFirstMethodThatCapturesAnException() {
5659
try {

0 commit comments

Comments
 (0)