2 * Copyright (c) 2015 Inocybe 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.ovsdb.openstack.netvirt.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Matchers.anyString;
13 import static org.mockito.Matchers.same;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.when;
17 import java.util.HashMap;
19 import java.util.concurrent.ConcurrentHashMap;
20 import java.util.concurrent.ConcurrentMap;
23 import org.junit.runner.RunWith;
24 import org.mockito.InjectMocks;
25 import org.mockito.Mock;
26 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
27 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
28 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
29 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
30 import org.powermock.api.mockito.PowerMockito;
31 import org.powermock.core.classloader.annotations.PrepareForTest;
32 import org.powermock.modules.junit4.PowerMockRunner;
35 * Unit test for {@link ConfigurationServiceImpl}
37 @Ignore // TODO SB_MIGRATION
38 @PrepareForTest(ConfigProperties.class)
39 @RunWith(PowerMockRunner.class)
40 public class ConfigurationServiceImplTest {
43 private ConfigurationServiceImpl configurationServiceImpl;
45 private static final String HOST_ADDRESS = "127.0.0.1";
48 * Test method {@link ConfigurationServiceImpl#getTunnelEndPoint(Node)}
51 public void testGetTunnelEndPoint() throws Exception {
52 //Row row = mock(Row.class);
53 //ConcurrentMap<String, Row> ovsTable = new ConcurrentHashMap();
54 //ovsTable.put("key", row);
56 //OpenVSwitch ovsRow = mock(OpenVSwitch.class);
57 Map<String, String> configs = new HashMap();
58 configs.put(Constants.TUNNEL_ENDPOINT_KEY, HOST_ADDRESS);
59 //Column<GenericTableSchema, Map<String, String>> otherConfigColumn = mock(Column.class);
61 //when(ovsRow.getOtherConfigColumn()).thenReturn(otherConfigColumn);
62 //when(otherConfigColumn.getData()).thenReturn(configs);
64 /* TODO SB_MIGRATION */
65 //when(ovsdbConfigurationService.getRows(any(Node.class), anyString())).thenReturn(ovsTable);
66 //when(ovsdbConfigurationService.getTypedRow(any(Node.class),same(OpenVSwitch.class), any(Row.class))).thenReturn(ovsRow);
68 //assertEquals("Error, did not return address of tunnelEndPoint", HOST_ADDRESS, configurationServiceImpl.getTunnelEndPoint(mock(Node.class)).getHostAddress());
72 * Test method {@link ConfigurationServiceImpl#getDefaultGatewayMacAddress(Node)}
75 public void testGetDefaultGatewayMacAddress(){
76 Node node = mock(Node.class);
77 NodeId nodeId = mock(NodeId.class);
78 PowerMockito.mockStatic(ConfigProperties.class);
80 when(node.getNodeId()).thenReturn(nodeId);
81 when(nodeId.getValue()).thenReturn("nodeIdValue");
82 PowerMockito.when(ConfigProperties.getProperty(configurationServiceImpl.getClass(),
83 "ovsdb.l3gateway.mac." + node.getNodeId().getValue())).thenReturn("gateway");
85 assertEquals("Error, did not return the defaultGatewayMacAddress of the node", "gateway",
86 configurationServiceImpl.getDefaultGatewayMacAddress(node));