Split out datastore implementation from aaa-shiro
[aaa.git] / aaa-idm-store-h2 / src / test / java / org / opendaylight / aaa / datastore / h2 / IdmLightConfigTest.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.aaa.datastore.h2;
9
10 import static com.google.common.truth.Truth.assertThat;
11
12 import org.junit.Test;
13
14 /**
15  * Unit test for IdmLightConfig.
16  *
17  * @author Michael Vorburger
18  */
19 public class IdmLightConfigTest {
20
21     @Test
22     public void testDefaults() {
23         IdmLightConfig config = new IdmLightConfigBuilder().dbUser("foo").dbPwd("bar").build();
24         assertThat(config.getDbDriver()).isEqualTo("org.h2.Driver");
25         assertThat(config.getDbConnectionString()).isEqualTo("jdbc:h2:./data/idmlight.db");
26         assertThat(config.getDbUser()).isEqualTo("foo");
27         assertThat(config.getDbPwd()).isEqualTo("bar");
28         assertThat(config.getDbValidTimeOut()).isEqualTo(3);
29     }
30
31     @Test
32     public void testCustomDirectory() {
33         IdmLightConfigBuilder builder = new IdmLightConfigBuilder();
34         builder.dbUser("foo").dbPwd("bar");
35         builder.dbDirectory("target");
36         IdmLightConfig config = builder.build();
37         assertThat(config.getDbConnectionString()).isEqualTo("jdbc:h2:target/idmlight.db");
38     }
39
40     @Test
41     public void testCustomConnectionString() {
42         IdmLightConfigBuilder builder = new IdmLightConfigBuilder();
43         builder.dbUser("foo").dbPwd("bar");
44         builder.dbConnectionString("jdbc:mysql://localhost/test");
45         IdmLightConfig config = builder.build();
46         assertThat(config.getDbConnectionString()).isEqualTo("jdbc:mysql://localhost/test");
47     }
48
49 }