()
| 546 | |
| 547 | #[test] |
| 548 | fn invoke_vec() -> errors::Result<()> { |
| 549 | let jvm = create_tests_jvm()?; |
| 550 | |
| 551 | match jvm.create_instance("org.astonbitecode.j4rs.tests.MyTest", InvocationArg::empty()) { |
| 552 | Ok(i) => { |
| 553 | // Test using InvocationArgs |
| 554 | let invocation_args = vec![ |
| 555 | InvocationArg::try_from("arg1"), |
| 556 | InvocationArg::try_from("arg2"), |
| 557 | InvocationArg::try_from("arg3"), |
| 558 | InvocationArg::try_from("arg33"), |
| 559 | ]; |
| 560 | let list_instance = jvm.java_list("java.lang.String", invocation_args)?; |
| 561 | let res = jvm.invoke(&i, "list", &[InvocationArg::from(list_instance)]); |
| 562 | assert!(res.is_ok()); |
| 563 | // Test using instances |
| 564 | let instance = jvm.create_instance( |
| 565 | "java.lang.String", |
| 566 | &[InvocationArg::try_from("astring")?], |
| 567 | ); |
| 568 | let list_instance = jvm.java_list("java.lang.String", vec![instance])?; |
| 569 | let res = jvm.invoke(&i, "list", &[InvocationArg::from(list_instance)]); |
| 570 | assert!(res.is_ok()); |
| 571 | // Test other types |
| 572 | let list_instance = jvm |
| 573 | .java_list(JavaClass::String, vec!["arg1", "arg2", "arg3", "arg33"])?; |
| 574 | let res = jvm.invoke(&i, "list", &[InvocationArg::from(list_instance)]); |
| 575 | assert!(res.is_ok()); |
| 576 | } |
| 577 | Err(error) => { |
| 578 | panic!("ERROR when creating Instance: {:?}", error); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | Ok(()) |
| 583 | } |
| 584 | |
| 585 | #[test] |
| 586 | fn invoke_map() -> errors::Result<()> { |
nothing calls this directly
no test coverage detected