2 * Copyright (c) 2015 Cisco Systems, 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.openflowplugin.impl.lifecycle;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.mockito.Mock;
14 import org.mockito.Mockito;
15 import org.mockito.runners.MockitoJUnitRunner;
16 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
17 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
18 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
19 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
20 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
21 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
22 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
24 @RunWith(MockitoJUnitRunner.class)
25 public class LifecycleServiceImplTest {
27 private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create("test node");
29 private DeviceInfo deviceInfo;
31 private DeviceContext deviceContext;
33 private RpcContext rpcContext;
35 private RoleContext roleContext;
37 private StatisticsContext statContext;
39 private LifecycleService lifecycleService;
43 lifecycleService = new LifecycleServiceImpl(deviceContext, rpcContext, roleContext, statContext);
44 Mockito.when(deviceInfo.getServiceIdentifier()).thenReturn(SERVICE_GROUP_IDENTIFIER);
48 public void instantiateServiceInstance() throws Exception {
49 lifecycleService.instantiateServiceInstance();
50 Mockito.verify(deviceContext).startupClusterServices();
54 public void closeServiceInstance() throws Exception {
55 lifecycleService.closeServiceInstance();
56 Mockito.verify(deviceContext).stopClusterServices();