Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions launcher/bootstrap/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ tasks.named<Jar>("jar") {
// it's first on SK's classpath and would shadow the real frenchpress.
exclude("co/frenchpress/**")
}

dependencies {
testImplementation("junit:junit:4.13.2")
}

tasks.named<Test>("test") {
useJUnit()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.skarm.launcher.bootstrap;

import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.lang.reflect.Method;

public class NativeBridgePromptTest {

@Test
public void testInvokeWithNullMethod() throws Exception {
Method invokeMethod = NativeBridgePrompt.class.getDeclaredMethod("invoke", Method.class, Object[].class);
invokeMethod.setAccessible(true);

String result = (String) invokeMethod.invoke(null, null, new Object[0]);
assertEquals("", result);
}

@Test
public void testInvokeWithMethodThrowingException() throws Exception {
Method invokeMethod = NativeBridgePrompt.class.getDeclaredMethod("invoke", Method.class, Object[].class);
invokeMethod.setAccessible(true);

Method throwingMethod = NativeBridgePromptTest.class.getDeclaredMethod("throwingMethod");

String result = (String) invokeMethod.invoke(null, throwingMethod, new Object[0]);
assertEquals("", result);
}

@Test
public void testInvokeWithValidMethod() throws Exception {
Method invokeMethod = NativeBridgePrompt.class.getDeclaredMethod("invoke", Method.class, Object[].class);
invokeMethod.setAccessible(true);

Method validMethod = NativeBridgePromptTest.class.getDeclaredMethod("validMethod");

String result = (String) invokeMethod.invoke(null, validMethod, new Object[0]);
assertEquals("success", result);
}

@Test
public void testInvokeWithNullReturn() throws Exception {
Method invokeMethod = NativeBridgePrompt.class.getDeclaredMethod("invoke", Method.class, Object[].class);
invokeMethod.setAccessible(true);

Method nullReturnMethod = NativeBridgePromptTest.class.getDeclaredMethod("nullReturnMethod");

String result = (String) invokeMethod.invoke(null, nullReturnMethod, new Object[0]);
assertEquals("", result);
}

public static String throwingMethod() {
throw new RuntimeException("Test exception");
}

public static String validMethod() {
return "success";
}

public static String nullReturnMethod() {
return null;
}
}
Loading