From 2da2da67468471ae5ae6710a3e5cabe4d9675153 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 20 Feb 2024 15:55:10 +0100 Subject: [PATCH] add unit tests --- .../common/IntegrationsLoaderTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/test/java/org/cryptomator/integrations/common/IntegrationsLoaderTest.java b/src/test/java/org/cryptomator/integrations/common/IntegrationsLoaderTest.java index 5c7c41a..1fbc614 100644 --- a/src/test/java/org/cryptomator/integrations/common/IntegrationsLoaderTest.java +++ b/src/test/java/org/cryptomator/integrations/common/IntegrationsLoaderTest.java @@ -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 + } } @@ -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())); + } + } } \ No newline at end of file