MCPcopy Create free account
hub / github.com/grpc/grpc-java / testWrapRunnable

Method testWrapRunnable

api/src/test/java/io/grpc/ContextTest.java:485–514  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

483 }
484
485 @Test
486 public void testWrapRunnable() {
487 Context base = Context.current().withValue(PET, "cat");
488 Context current = Context.current().withValue(PET, "fish");
489 current.attach();
490
491 base.wrap(runner).run();
492 assertSame(base, observed);
493 assertSame(current, Context.current());
494
495 current.wrap(runner).run();
496 assertSame(current, observed);
497 assertSame(current, Context.current());
498
499 final TestError err = new TestError();
500 try {
501 base.wrap(new Runnable() {
502 @Override
503 public void run() {
504 throw err;
505 }
506 }).run();
507 fail("Expected exception");
508 } catch (TestError ex) {
509 assertSame(err, ex);
510 }
511 assertSame(current, Context.current());
512
513 current.detach(Context.ROOT);
514 }
515
516 @Test
517 public void testWrapCallable() throws Exception {

Callers

nothing calls this directly

Calls 7

currentMethod · 0.95
attachMethod · 0.95
wrapMethod · 0.95
detachMethod · 0.95
withValueMethod · 0.80
runMethod · 0.65
failMethod · 0.45

Tested by

no test coverage detected