| 105 | } |
| 106 | |
| 107 | @Test |
| 108 | public void defaultContext() throws Exception { |
| 109 | final SettableFuture<Context> contextOfNewThread = SettableFuture.create(); |
| 110 | Context contextOfThisThread = Context.ROOT.withValue(PET, "dog"); |
| 111 | Context toRestore = contextOfThisThread.attach(); |
| 112 | new Thread(new Runnable() { |
| 113 | @Override |
| 114 | public void run() { |
| 115 | contextOfNewThread.set(Context.current()); |
| 116 | } |
| 117 | }).start(); |
| 118 | assertNotNull(contextOfNewThread.get(5, TimeUnit.SECONDS)); |
| 119 | assertNotSame(contextOfThisThread, contextOfNewThread.get()); |
| 120 | assertSame(contextOfThisThread, Context.current()); |
| 121 | contextOfThisThread.detach(toRestore); |
| 122 | } |
| 123 | |
| 124 | @Test |
| 125 | public void rootCanBeAttached() { |