2 * Copyright © 2015 Yale University 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.yang.gen.v1.urn.alto.northbound.route.example.impl.rev151021;
10 import org.junit.Test;
11 import org.opendaylight.controller.config.api.DependencyResolver;
12 import org.opendaylight.controller.config.api.JmxAttribute;
13 import org.opendaylight.controller.config.api.ModuleIdentifier;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
15 import org.opendaylight.alto.core.northbound.api.AltoNorthboundRouter;
17 import javax.management.ObjectName;
19 import static org.mockito.Matchers.any;
20 import static org.mockito.Matchers.eq;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.verify;
23 import static org.mockito.Mockito.when;
25 public class AltoNorthboundRouteExampleModuleTest {
27 public void testCustomValidation() {
28 AltoNorthboundRouteExampleModule module = new AltoNorthboundRouteExampleModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
30 // ensure no exceptions on validation
31 // currently this method is empty
32 module.customValidation();
36 public void testCreateInstance() throws Exception {
38 DependencyResolver dependencyResolver = mock(DependencyResolver.class);
39 BindingAwareBroker broker = mock(BindingAwareBroker.class);
40 AltoNorthboundRouter router = mock(AltoNorthboundRouter.class);
41 when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
42 when(dependencyResolver.resolveInstance(eq(AltoNorthboundRouter.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(router);
44 // create instance of module with injected mocks
45 AltoNorthboundRouteExampleModule module = new AltoNorthboundRouteExampleModule(mock(ModuleIdentifier.class), dependencyResolver);
47 // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
48 AutoCloseable closeable = module.getInstance();
50 // ensure no exceptions on close
53 // verify that the route is released after closed
54 verify(router).removeRoute("example");