### Question:
AsyncEntry extends CtEntry { void cleanCurrentEntryInLocal() { if (context instanceof NullContext) { return; } Context originalContext = context; if (originalContext != null) { Entry curEntry = originalContext.getCurEntry(); if (curEntry == this) { Entry parent = this.parent; originalContext.setCurEntry(parent); if (parent != null) { ((CtEntry)parent).child = null; } } else { throw new IllegalStateException("Bad async context state"); } } } AsyncEntry(ResourceWrapper resourceWrapper, ProcessorSlot<Object> chain, Context context); Context getAsyncContext();  }### Answer:
@Test public void testCleanCurrentEntryInLocal() { final String contextName = "abc"; try { ContextUtil.enter(contextName); Context curContext = ContextUtil.getContext(); Entry previousEntry = new CtEntry(new StringResourceWrapper("entry-sync", EntryType.IN), null, curContext); AsyncEntry entry = new AsyncEntry(new StringResourceWrapper("testCleanCurrentEntryInLocal", EntryType.OUT), null, curContext); assertSame(entry, curContext.getCurEntry()); entry.cleanCurrentEntryInLocal(); assertNotSame(entry, curContext.getCurEntry()); assertSame(previousEntry, curContext.getCurEntry()); } finally { ContextTestUtil.cleanUpContext(); } }
@Test(expected = IllegalStateException.class) public void testCleanCurrentEntryInLocalError() { final String contextName = "abc"; try { ContextUtil.enter(contextName); Context curContext = ContextUtil.getContext(); AsyncEntry entry = new AsyncEntry(new StringResourceWrapper("testCleanCurrentEntryInLocal", EntryType.OUT), null, curContext); entry.cleanCurrentEntryInLocal(); entry.cleanCurrentEntryInLocal(); } finally { ContextTestUtil.cleanUpContext(); } }