83 } 84 85 if (compareClassNames && !tf.className().equals(sf.getClassName())) { 86 throw new RuntimeException("Expected class name: " + tf.className() + 87 ", but got: " + sf.getClassName()); 88 } 89 if (compareMethodNames && !tf.methodName.equals(sf.getMethodName())) { 90 throw new RuntimeException("Expected method name: " + tf.methodName + 91 ", but got: " + sf.getMethodName()); 92 } 93 if (compareSTEs) { 94 StackTraceElement ste = sf.toStackTraceElement(); 95 if (!(ste.getClassName().equals(tf.className()) && 96 ste.getMethodName().equals(tf.methodName)) && 97 ste.getFileName().equals(tf.fileName)) { 98 throw new RuntimeException("Expected StackTraceElement info: " + 99 tf + ", but got: " + ste); 100 } 101 if (!Objects.equals(ste.getClassName(), sf.getClassName()) 102 || !Objects.equals(ste.getMethodName(), sf.getMethodName()) 103 || !Objects.equals(ste.getFileName(), sf.getFileName().orElse(null)) 104 || !Objects.equals(ste.getLineNumber(), sf.getLineNumber().orElse(-1)) 105 || !Objects.equals(ste.isNativeMethod(), sf.isNativeMethod())) { 106 throw new RuntimeException("StackFrame and StackTraceElement differ: " + 107 "sf=" + sf + ", ste=" + ste); 108 } 109 } 110 } 111 112 public Iterator<TestFrame> iterator() { 113 return testFrames.iterator(); 114 } 115 116 /** 117 * Class used to record stack frame information. 118 */ 119 public static class TestFrame { 120 public Class declaringClass; 121 public String methodName; 122 public String fileName = null; 123 124 public TestFrame (Class declaringClass, String methodName, String fileName) { | 83 } 84 85 if (compareClassNames && !tf.className().equals(sf.getClassName())) { 86 throw new RuntimeException("Expected class name: " + tf.className() + 87 ", but got: " + sf.getClassName()); 88 } 89 if (compareMethodNames && !tf.methodName.equals(sf.getMethodName())) { 90 throw new RuntimeException("Expected method name: " + tf.methodName + 91 ", but got: " + sf.getMethodName()); 92 } 93 if (compareSTEs) { 94 StackTraceElement ste = sf.toStackTraceElement(); 95 if (!(ste.getClassName().equals(tf.className()) && 96 ste.getMethodName().equals(tf.methodName)) && 97 ste.getFileName().equals(tf.fileName)) { 98 throw new RuntimeException("Expected StackTraceElement info: " + 99 tf + ", but got: " + ste); 100 } 101 if (!Objects.equals(ste.getClassName(), sf.getClassName()) 102 || !Objects.equals(ste.getMethodName(), sf.getMethodName()) 103 || !Objects.equals(ste.isNativeMethod(), sf.isNativeMethod())) { 104 throw new RuntimeException("StackFrame and StackTraceElement differ: " + 105 "sf=" + sf + ", ste=" + ste); 106 } 107 } 108 } 109 110 public Iterator<TestFrame> iterator() { 111 return testFrames.iterator(); 112 } 113 114 /** 115 * Class used to record stack frame information. 116 */ 117 public static class TestFrame { 118 public Class declaringClass; 119 public String methodName; 120 public String fileName = null; 121 122 public TestFrame (Class declaringClass, String methodName, String fileName) { |