Merge "JUnit test - InMemoryDbModule"
authorFlorin Coras <florin.coras+odl@gmail.com>
Fri, 11 Mar 2016 18:08:17 +0000 (18:08 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 11 Mar 2016 18:08:17 +0000 (18:08 +0000)
mappingservice/inmemorydb/pom.xml
mappingservice/inmemorydb/src/test/java/org/opendaylight/controller/config/yang/config/lfm/mappingservice_dao/inmemorydb/InMemoryDbModuleTest.java [new file with mode: 0644]

index 47a8934ed3beb5681ee622b057868316ac2d93fc..889d7f2b3113d1b1fff9495e7942b8831de21bce 100644 (file)
       <groupId>${project.groupId}</groupId>
       <artifactId>mappingservice.api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <version>1.10.19</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <!--
diff --git a/mappingservice/inmemorydb/src/test/java/org/opendaylight/controller/config/yang/config/lfm/mappingservice_dao/inmemorydb/InMemoryDbModuleTest.java b/mappingservice/inmemorydb/src/test/java/org/opendaylight/controller/config/yang/config/lfm/mappingservice_dao/inmemorydb/InMemoryDbModuleTest.java
new file mode 100644 (file)
index 0000000..215618c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yang.config.lfm.mappingservice_dao.inmemorydb;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
+
+public class InMemoryDbModuleTest {
+
+    private InMemoryDbModule module;
+
+    @Before
+    public void setUp() throws Exception {
+        new InMemoryDbModule(
+                Mockito.mock(ModuleIdentifier.class),
+                Mockito.mock(DependencyResolver.class),
+                Mockito.mock(InMemoryDbModule.class),
+                Mockito.mock(AutoCloseable.class)
+        );
+
+        module = new InMemoryDbModule(
+                Mockito.mock(ModuleIdentifier.class),
+                Mockito.mock(DependencyResolver.class)
+        );
+    }
+
+    @Test
+    public void testCustomValidation() throws Exception {
+        module.customValidation();
+    }
+
+    @Test
+    public void testCreateInstance() throws Exception {
+        int recordTimeout = 200;
+        module.setRecordTimeout(recordTimeout);
+        AutoCloseable instance = module.createInstance();
+        Assert.assertTrue(instance instanceof HashMapDb);
+        Assert.assertEquals(recordTimeout, ((HashMapDb) instance).getRecordTimeOut());
+    }
+}
\ No newline at end of file