Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Feb 20, 2024
1 parent 928c9a1 commit 2da2da6
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ class C2 extends StaticFalse {
Assertions.assertFalse(IntegrationsLoader.passesStaticAvailabilityCheck(C3.class));
}

@Test
@DisplayName("throwing @CheckAvailability methods are treated as false")
public void testPassesAvailabilityCheckThrowing() {

@CheckAvailability class C1 {
@CheckAvailability public static boolean test() { throw new RuntimeException("FAIL"); }
}

Assertions.assertFalse(IntegrationsLoader.passesStaticAvailabilityCheck(C1.class));
Assertions.assertFalse(IntegrationsLoader.passesStaticAvailabilityCheck(InitExceptionTestClass.class));
Assertions.assertFalse(IntegrationsLoader.passesStaticAvailabilityCheck(InitExceptionTestClass.class)); //NoClassDefFoundError due to repated call
}

}

Expand Down Expand Up @@ -190,6 +202,26 @@ class C2 extends InstanceFalse {
Assertions.assertFalse(IntegrationsLoader.passesInstanceAvailabilityCheck(new C3()));
}


@Test
@DisplayName("throwing @CheckAvailability methods are treated as false")
public void testPassesAvailabilityCheckThrowing() {

@CheckAvailability
class C1 {
@CheckAvailability public boolean test1() { throw new RuntimeException("FAIL"); }
}

@CheckAvailability
class C2 {
@CheckAvailability public boolean test1() { return true; }
@CheckAvailability public boolean test2() { throw new RuntimeException("FAIL"); }
}

Assertions.assertFalse(IntegrationsLoader.passesInstanceAvailabilityCheck(new C1()));
Assertions.assertFalse(IntegrationsLoader.passesInstanceAvailabilityCheck(new C2()));
}

}

}

0 comments on commit 2da2da6

Please sign in to comment.