### Question:
Context { public static Executor currentContextExecutor(final Executor e) { class CurrentContextExecutor implements Executor { @Override public void execute(Runnable r) { e.execute(Context.current().wrap(r)); } } return new CurrentContextExecutor(); } private  Context(PersistentHashArrayMappedTrie<Key<?>, Object> keyValueEntries, int generation); private  Context(Context parent, PersistentHashArrayMappedTrie<Key<?>, Object> keyValueEntries); static Key<T> key(String name); static Key<T> keyWithDefault(String name, T defaultValue); static Context current(); CancellableContext withCancellation(); CancellableContext withDeadlineAfter(long duration, TimeUnit unit,
                                              ScheduledExecutorService scheduler); CancellableContext withDeadline(Deadline deadline,
      ScheduledExecutorService scheduler); Context withValue(Key<V> k1, V v1); Context withValues(Key<V1> k1, V1 v1, Key<V2> k2, V2 v2); Context withValues(Key<V1> k1, V1 v1, Key<V2> k2, V2 v2, Key<V3> k3, V3 v3); Context withValues(Key<V1> k1, V1 v1, Key<V2> k2, V2 v2,
      Key<V3> k3, V3 v3, Key<V4> k4, V4 v4); Context fork(); Context attach(); void detach(Context toAttach); boolean isCancelled(); Throwable cancellationCause(); Deadline getDeadline(); void addListener(final CancellationListener cancellationListener,
                          final Executor executor); void removeListener(CancellationListener cancellationListener); void run(Runnable r); @CanIgnoreReturnValue V call(Callable<V> c); Runnable wrap(final Runnable r); Callable<C> wrap(final Callable<C> c); Executor fixedContextExecutor(final Executor e); static Executor currentContextExecutor(final Executor e); static final Context ROOT; }### Answer:
@Test public void currentContextExecutor() throws Exception { QueuedExecutor queuedExecutor = new QueuedExecutor(); Executor executor = Context.currentContextExecutor(queuedExecutor); Context base = Context.current().withValue(PET, "cat"); Context previous = base.attach(); try { executor.execute(runner); } finally { base.detach(previous); } assertEquals(1, queuedExecutor.runnables.size()); queuedExecutor.runnables.remove().run(); assertSame(base, observed); }