2 * Copyright (c) 2016 Red Hat, Inc. 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
8 package org.opendaylight.aaa.datastore.h2;
10 import static com.google.common.truth.Truth.assertThat;
12 import org.junit.Test;
15 * Unit test for IdmLightConfig.
17 * @author Michael Vorburger
19 public class IdmLightConfigTest {
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);
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");
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");