### Question:
TraceeMessageListener { @AroundInvoke public Object intercept(final InvocationContext ctx) throws Exception { final boolean isMdbInvocation = isMessageListenerOnMessageMethod(ctx.getMethod()); try { if (isMdbInvocation) { beforeProcessing(extractMessageParameter(ctx.getParameters())); } return ctx.proceed(); } finally { if (isMdbInvocation) { cleanUp(); } } } TraceeMessageListener(TraceeBackend backend); @SuppressWarnings("unused")  TraceeMessageListener(); @AroundInvoke Object intercept(final InvocationContext ctx); @SuppressWarnings("unchecked") void beforeProcessing(final Message message);  }### Answer:
@Test public void testDecodesFromMessage() throws Exception { encodedContext.put("contextFromMessage", "yes"); encodedContext.put(INVOCATION_ID_KEY, "an invocationId"); unit.intercept(invocationContext); assertThat(backend.getValuesBeforeLastClear(), hasEntry(INVOCATION_ID_KEY, "an invocationId")); assertThat(backend.getValuesBeforeLastClear(), hasEntry("contextFromMessage", "yes")); verify(mdbLike).onMessage(message); }
@Test public void testCleansUpContextAfterProcessing() throws Exception { encodedContext.put("contextFromMessage", "yes"); unit.intercept(invocationContext); assertThat(backend.isEmpty(), is(true)); verify(mdbLike).onMessage(message); }
@Test public void testInvocationIdGeneratedIfAbsent() throws Exception { encodedContext.put("contextFromMessage", "yes"); unit.intercept(invocationContext); assertThat(backend.getValuesBeforeLastClear(), hasEntry(is(INVOCATION_ID_KEY), notNullValue())); verify(mdbLike).onMessage(message); }
@Test public void readContextWithoutUsingObjectMethods_issue168() throws Exception { encodedContext.put("contextFromMessage", "yes"); unit.intercept(invocationContext); verify(message, never()).getObjectProperty(anyString()); }