### Question:
HibersapSessionInterceptor { @AroundInvoke public Object injectSessionsIntoEjb(final InvocationContext ctx) throws Exception { Set<Field> sessionFields = getHibersapSessionFields(ctx.getTarget()); Map<Session, String> sessionsCreated = new HashMap<>(); try { for (Field sessionField : sessionFields) { String jndiName = getSessionManagerJndiName(sessionField); String key = HIBERSAP_SESSION_PREFIX + jndiName; Session session = (Session) ctx.getContextData().get(key); if (session == null) { LOGGER.debug("Create Hibersap session for SessionManager " + jndiName); session = openSession(jndiName); sessionsCreated.put(session, jndiName); ctx.getContextData().put(key, session); } injectSessionIntoTarget(ctx.getTarget(), sessionField, session); } return ctx.proceed(); } finally { closeSessions(sessionsCreated, ctx.getContextData()); } }  @AroundInvoke Object injectSessionsIntoEjb(final InvocationContext ctx);  }### Answer:
@Test public void injectsTwoSessionsIntoBeanInstanceWhereOneIsAlreadyInInjectionContextAndTheOtherGetsCreated() throws Exception { Session session2 = mock(Session.class); contextData.put("hibersap.session.jndiName2", session2); when(initialCtx.lookup("jndiName1")).thenReturn(sessionManager); interceptor.injectSessionsIntoEjb(invocationContext); assertThat(targetBean.session1).isSameAs(session); assertThat(targetBean.session2).isSameAs(session2); }
@Test public void removesTheCreatedSessionFromInvocationContextAndKeepsTheOtherOne() throws Exception { contextData.put("hibersap.session.jndiName1", mock(Session.class)); when(initialCtx.lookup("jndiName2")).thenReturn(sessionManager); interceptor.injectSessionsIntoEjb(invocationContext); assertThat(contextData).hasSize(1); }