This commit is contained in:
redkale
2023-12-24 21:08:57 +08:00
parent ae03bdecad
commit 88392fd5dd
6 changed files with 115 additions and 13 deletions

View File

@@ -5,9 +5,10 @@
*/
package org.redkale.test.util;
import org.redkale.util.Invoker;
import java.io.IOException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.redkale.util.Invoker;
/**
*
@@ -15,6 +16,17 @@ import org.junit.jupiter.api.Test;
*/
public class InvokerTest {
public static void main(String[] args) throws Throwable {
InvokerTest test = new InvokerTest();
test.run1();
test.run2();
test.run3();
test.run4();
test.run5();
test.run6();
test.run7();
}
@Test
public void run1() {
Invoker<String, String> invoker = Invoker.create(String.class, "toLowerCase");
@@ -34,4 +46,53 @@ public class InvokerTest {
System.out.println(str);
Assertions.assertEquals(str, invoker.invoke(null, str).toString());
}
@Test
public void run4() {
Invoker<Action, Void> invoker = Invoker.create(Action.class, "test1");
Action action = new Action();
invoker.invoke(action);
}
@Test
public void run5() {
Invoker<Action, Void> invoker = Invoker.create(Action.class, "test2", String.class);
Action action = new Action();
invoker.invoke(action, "name");
}
@Test
public void run6() {
Invoker<Action, Integer> invoker = Invoker.create(Action.class, "test3", String.class, int.class);
Action action = new Action();
int rs = invoker.invoke(action, "name", 1);
System.out.println(rs);
Assertions.assertEquals(3, rs);
}
@Test
public void run7() {
Invoker<Action, Integer> invoker = Invoker.create(Action.class, "test4", String.class, int.class);
Action action = new Action();
int rs = invoker.invoke(action, "name", 1);
System.out.println(rs);
Assertions.assertEquals(4, rs);
}
public static class Action {
public void test1() {
}
public void test2(String name) throws IOException {
}
public int test3(String name, int id) {
return 3;
}
public int test4(String name, int id) throws IOException {
return 4;
}
}
}