2 * Copyright (c) 2016, 2017 Inocybe Technologies. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.aaa.datastore.h2;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
14 import org.junit.After;
15 import org.junit.Test;
16 import org.opendaylight.aaa.api.Authentication;
17 import org.opendaylight.aaa.shiro.tokenauthrealm.auth.AuthenticationBuilder;
18 import org.opendaylight.aaa.shiro.tokenauthrealm.auth.ClaimBuilder;
21 * Unit Test for H2TokenStore.
25 public class H2TokenStoreTest {
27 private final H2TokenStore h2TokenStore = new H2TokenStore(36000, 3600);
30 public void teardown() throws Exception {
35 public void testTokenStore() throws InterruptedException {
36 final String fooToken = "foo_token";
37 Authentication auth = new AuthenticationBuilder(
38 new ClaimBuilder().setUser("foo").setUserId("1234").addRole("admin").build()).build();
39 h2TokenStore.put(fooToken, auth);
40 assertEquals(auth, h2TokenStore.get(fooToken));
41 h2TokenStore.delete(fooToken);
42 assertNull(h2TokenStore.get(fooToken));