@Test(expected = IllegalStateException.class)
public void testCreateAndReserveTokenKey_generate_failed() throws Exception {

    // prepare store instance
    store = new HttpSessionTransactionTokenStore(new TokenStringGenerator() {
        @Override
        public String generate(String seed) {
            // return always same value
            return "xxxxx";
        }
    }, 5, 5);
    // setup parameters
    MockHttpSession session = new MockHttpSession();
    request.setSession(session);
    session.setAttribute(
            HttpSessionTransactionTokenStore.TOKEN_HOLDER_SESSION_ATTRIBUTE_PREFIX
                    + "foo" + TransactionToken.TOKEN_STRING_SEPARATOR
                    + "xxxxx", "already in!");
    try {
        store.createAndReserveTokenKey("foo");
    } catch (Exception e) {
        assertThat(e.getMessage(), is(
                "token key generation failed within retry count 5"));
        throw e;
    }
}