MCPcopy Create free account
hub / github.com/astonbitecode/j4rs / init_callback_channel

Function init_callback_channel

rust/src/lib.rs:222–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220
221 #[test]
222 fn init_callback_channel() -> errors::Result<()> {
223 let jvm = create_tests_jvm()?;
224 match jvm.create_instance(
225 "org.astonbitecode.j4rs.tests.MySecondTest",
226 InvocationArg::empty(),
227 ) {
228 Ok(i) => {
229 let instance_receiver_res = jvm.init_callback_channel(&i);
230 assert!(instance_receiver_res.is_ok());
231 let instance_receiver = instance_receiver_res?;
232 assert!(jvm.invoke(&i, "performCallback", InvocationArg::empty()).is_ok());
233 let res_chan = instance_receiver.rx().recv();
234 let i = res_chan?;
235 let res_to_rust = jvm.to_rust(i);
236 assert!(res_to_rust.is_ok());
237 let _: String = res_to_rust?;
238 let millis = time::Duration::from_millis(500);
239 thread::sleep(millis);
240 }
241 Err(error) => {
242 panic!("ERROR when creating Instance: {:?}", error);
243 }
244 }
245
246 Ok(())
247 }
248
249 #[test]
250 fn callback_to_channel() -> errors::Result<()> {

Callers

nothing calls this directly

Calls 5

create_tests_jvmFunction · 0.85
create_instanceMethod · 0.80
init_callback_channelMethod · 0.80
rxMethod · 0.80
to_rustMethod · 0.45

Tested by

no test coverage detected