Browse Source

Make this test pass on different JDK 1.4 minor versions

PR:	15250


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273972 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
e3d6119953
1 changed files with 6 additions and 12 deletions
  1. +6
    -12
      src/testcases/org/apache/tools/ant/taskdefs/optional/sitraka/ClassFileTest.java

+ 6
- 12
src/testcases/org/apache/tools/ant/taskdefs/optional/sitraka/ClassFileTest.java View File

@@ -82,14 +82,7 @@ public class ClassFileTest extends TestCase {
assertEquals(3, methods.length); assertEquals(3, methods.length);
assertHasMethod("void <init>()", 2, methods); assertHasMethod("void <init>()", 2, methods);
assertHasMethod("void testTwoLines()", 2, methods); assertHasMethod("void testTwoLines()", 2, methods);
assertHasMethod("void testOneLine()",
// in JDK 1.4 we get four lines
3 +
(JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)
|| JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
|| JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)
? 0 : 1),
methods);
assertHasMethod("void testOneLine()", 3, methods);
} }


protected void assertHasMethod(String methodsig, int line, MethodInfo[] methods) { protected void assertHasMethod(String methodsig, int line, MethodInfo[] methods) {
@@ -97,7 +90,8 @@ public class ClassFileTest extends TestCase {
for (int i = 0; i < methods.length; i++) { for (int i = 0; i < methods.length; i++) {
MethodInfo method = methods[i]; MethodInfo method = methods[i];
if (methodsig.equals(method.getFullSignature())) { if (methodsig.equals(method.getFullSignature())) {
assertEquals(methodsig, line, method.getNumberOfLines());
assertTrue(methodsig, method.getNumberOfLines() >= line);
return; return;
} }
} }
@@ -108,16 +102,16 @@ public class ClassFileTest extends TestCase {
class ClassTest { class ClassTest {


// 2 lines // 2 lines
public ClassTest() {
public ClassTest() {
} }


// 2 lines // 2 lines
public void testTwoLines() {
public void testTwoLines() {
System.out.println("This is 1 line"); System.out.println("This is 1 line");
} }


// 1 line // 1 line
public void testOneLine() {
public void testOneLine() {
try { try {
throw new Exception(); throw new Exception();
} catch (Exception e) { } catch (Exception e) {


Loading…
Cancel
Save