3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.datastore.internal;
12 import org.apache.felix.dm.Component;
13 import org.apache.felix.dm.ServiceDependency;
15 import org.junit.BeforeClass;
16 import org.junit.Test;
17 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
19 import static junit.framework.Assert.assertNotNull;
20 import static org.junit.Assert.assertEquals;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
24 public class ActivatorTest {
26 private static ServiceDependency serviceDependency;
29 public static void initialize(){
30 serviceDependency = mock(ServiceDependency.class);
33 private class ActivatorTestImpl extends Activator{
34 protected ServiceDependency createServiceDependency() {
35 return ActivatorTest.serviceDependency;
40 public void construct(){
41 assertNotNull(new Activator());
45 public void construct_OnInvokeOfGlobalImpl_ShouldReturnNotNullObject(){
46 Activator activator = new Activator();
48 assertNotNull(activator.getGlobalImplementations());
49 assertEquals(ClusteredDataStoreManager.class,activator.getGlobalImplementations()[0]);
53 public void construct_OnInvokeOfConfigGlobalInstance_ShouldNotThrowAnyExceptions(){
54 Activator activator = new ActivatorTestImpl();
56 Component c = mock(Component.class);
57 Object clusterDataStoreMgr = ClusteredDataStoreManager.class;
59 when(serviceDependency.setService(IClusterGlobalServices.class)).thenReturn(serviceDependency);
60 when(serviceDependency.setCallbacks("setClusterGlobalServices",
61 "unsetClusterGlobalServices")).thenReturn(serviceDependency);
62 when(serviceDependency.setRequired(true)).thenReturn(serviceDependency);
65 activator.configureGlobalInstance(c, clusterDataStoreMgr);