HttpSessionTransactionTokenStore implements TransactionTokenStore { @Override public void remove(TransactionToken token) { String key = createSessionAttributeName(token); HttpSession session = getSession(); Object mutex = getMutex(session); synchronized (mutex) { try { session.removeAttribute(key); } catch (IllegalStateException e) { logger.debug("session is already invalidated.", e); } } } HttpSessionTransactionTokenStore();  HttpSessionTransactionTokenStore(
            int transactionTokenSizePerTokenName);  HttpSessionTransactionTokenStore(
            int transactionTokenSizePerTokenName, int retryCreateTokenName);  HttpSessionTransactionTokenStore(
            final TokenStringGenerator generator,
            final int transactionTokenSizePerTokenName,
            final int retryCreateTokenName); @Override String getAndClear(TransactionToken token); @Override void remove(TransactionToken token); @Override String createAndReserveTokenKey(String tokenName); @Override void store(TransactionToken token); static final String TOKEN_HOLDER_SESSION_ATTRIBUTE_PREFIX; static final int NO_OF_TOKENS_PER_TOKEN_NAME; static final int DEFAULT_RETRY_CREATE_TOKEN_NAME; }
@Test public void testRemove() { HttpSession session = new MockHttpSession(); request.setSession(session); TransactionToken token = new TransactionToken("tokenName", "tokenKey", "tokenValue"); store = new HttpSessionTransactionTokenStore(); store.store(token); store.remove(token); assertThat(session.getAttribute( HttpSessionTransactionTokenStore.TOKEN_HOLDER_SESSION_ATTRIBUTE_PREFIX + token.getTokenName() + token.getTokenKey()), is( nullValue())); }
@Test(expected = IllegalArgumentException.class) public void testRemove_tokenIsNull() throws Exception { try { store = new HttpSessionTransactionTokenStore(); store.remove(null); } catch (Exception e) { assertThat(e.getMessage(), is("token must not be null")); throw e; } }