### Question:
JndiUtil { public static void rebindSessionManager(final SessionManager sessionManager, final String jndiName) { LOG.info("Binding Hibersap SessionManager '" + sessionManager.getConfig().getName() + "' to JNDI name '" + jndiName + "'"); try { Context ctx = new InitialContext(); ctx.rebind(jndiName, sessionManager); } catch (NamingException e) { throw new HibersapException("Failed binding Hibersap SessionManager to JNDI name [" + jndiName + "]", e); } } private  JndiUtil(); static void rebindSessionManager(final SessionManager sessionManager, final String jndiName); static void unbindSessionManager(final String jndiName);  }### Answer:
@Test public void rebindSessionManagerActuallyBindsItToJndi() throws Exception { JndiUtil.rebindSessionManager(sessionManager, JNDI_NAME); verify(initialCtx).rebind(JNDI_NAME, sessionManager); }
@Test(expected = HibersapException.class) public void rebindSessionManagerWithNamingExceptionThrowsHibersapException() throws Exception { doThrow(new NamingException()).when(initialCtx).rebind(JNDI_NAME, sessionManager); JndiUtil.rebindSessionManager(sessionManager, JNDI_NAME); }