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
9 package org.opendaylight.ovsdb.openstack.netvirt.impl;
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Matchers.anyBoolean;
14 import static org.mockito.Matchers.anyInt;
15 import static org.mockito.Matchers.anyLong;
16 import static org.mockito.Matchers.anyString;
17 import static org.mockito.Matchers.eq;
18 import static org.mockito.Mockito.mock;
19 import static org.mockito.Mockito.times;
20 import static org.mockito.Mockito.when;
22 import java.lang.reflect.Constructor;
23 import java.lang.reflect.Field;
24 import java.net.InetAddress;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.List;
32 import org.apache.commons.lang3.tuple.Pair;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.Mock;
37 import org.mockito.Mockito;
38 import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
39 import org.opendaylight.neutron.spi.INeutronPortCRUD;
40 import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
41 import org.opendaylight.neutron.spi.NeutronFloatingIP;
42 import org.opendaylight.neutron.spi.NeutronNetwork;
43 import org.opendaylight.neutron.spi.NeutronPort;
44 import org.opendaylight.neutron.spi.NeutronRouter;
45 import org.opendaylight.neutron.spi.NeutronRouter_Interface;
46 import org.opendaylight.neutron.spi.NeutronSubnet;
47 import org.opendaylight.neutron.spi.Neutron_IPs;
48 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
49 import org.opendaylight.ovsdb.openstack.netvirt.api.ArpProvider;
50 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
51 import org.opendaylight.ovsdb.openstack.netvirt.api.InboundNatProvider;
52 import org.opendaylight.ovsdb.openstack.netvirt.api.L3ForwardingProvider;
53 import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
54 import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
55 import org.opendaylight.ovsdb.openstack.netvirt.api.RoutingProvider;
56 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
57 import org.opendaylight.ovsdb.openstack.netvirt.api.Status;
58 import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode;
59 import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
60 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
64 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
65 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
66 import org.osgi.framework.BundleContext;
67 import org.osgi.framework.ServiceReference;
68 import org.powermock.api.mockito.PowerMockito;
69 import org.powermock.api.support.membermodification.MemberMatcher;
70 import org.powermock.api.support.membermodification.MemberModifier;
71 import org.powermock.core.classloader.annotations.PrepareForTest;
72 import org.powermock.modules.junit4.PowerMockRunner;
73 import org.powermock.reflect.Whitebox;
76 * Unit test for {@link NeutronL3Adapter}
78 @PrepareForTest({ServiceHelper.class, InetAddress.class, NeutronL3Adapter.class})
79 @RunWith(PowerMockRunner.class)
80 public class NeutronL3AdapterTest {
82 @Mock private NeutronL3Adapter neutronL3Adapter;
84 private static final String ID = "45";
85 private static final String IP = "127.0.0.1";
86 private static final String MALFORM_IP = "127.0.0.1.5";
87 private static final String INTF_NAME = "br-int";
88 private static final String EXTERNAL_ROUTER_MAC_UPDATE = "";
89 private static final String UUID = "7da709ff-397f-4778-a0e8-994811272fdb";
90 private static final String FIXED_IP_ADDRESS = "192.168.1.0";
91 private static final String FLOATING_IP_ADDRESS = "192.168.1.1";
92 private static final String OWNER_ROUTER_INTERFACE = "network:router_interface";
93 private static final String OWNER_FLOATING_IP = "network:floatingip";
94 private static final String MAC_ADDRESS = "00:00:5E:00:02:01";
95 private static final String MAC_ADDRESS_2 = "00:00:5E:00:02:02";
96 private static final String PORT_INT = "port_int";
97 private static final String SEG_ID = "2";
98 private static final String CIDR = "192.168.100.0/24";
99 private static final String OFPort = "OFPort|45";
100 private static final String IP_MASK = "127.0.0.1/32";
102 @SuppressWarnings("rawtypes")
103 private Class floatingIpClass;
104 private Object floatingIpObject;
107 public void setUp() throws Exception{
108 neutronL3Adapter = PowerMockito.mock(NeutronL3Adapter.class, Mockito.CALLS_REAL_METHODS);
110 // init instance variables
111 MemberModifier.field(NeutronL3Adapter.class, "enabled").set(neutronL3Adapter, true);
113 // floating ip (nested private class from NeutronL3Adapter)
114 floatingIpClass = Whitebox.getInnerClassType(NeutronL3Adapter.class, "FloatIpData");
115 floatingIpObject = createFloatingIpObject();
119 public void testUpdateExternalRouterMac() throws Exception {
120 // Suppress the called to these functions
121 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "flushExistingIpRewrite"));
122 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "rebuildExistingIpRewrite"));
124 neutronL3Adapter.updateExternalRouterMac(EXTERNAL_ROUTER_MAC_UPDATE);
126 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("flushExistingIpRewrite");
127 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("rebuildExistingIpRewrite");
131 public void testhandleNeutronSubnetEvent() throws Exception {
132 // Nothing to be done here
133 neutronL3Adapter.handleNeutronSubnetEvent(mock(NeutronSubnet.class), Action.ADD);
137 public void testHandleNeutronPortEvent() throws Exception {
138 Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<String, NeutronRouter_Interface>();
140 Neutron_IPs neutronIP = mock(Neutron_IPs.class);
141 when(neutronIP.getSubnetUUID()).thenReturn(UUID);
142 List<Neutron_IPs> list_neutronIP = new ArrayList<Neutron_IPs>();
143 list_neutronIP.add(neutronIP);
144 NeutronPort neutronPort = mock(NeutronPort.class);
145 when(neutronPort.getDeviceOwner()).thenReturn(OWNER_ROUTER_INTERFACE);
146 when(neutronPort.getFixedIPs()).thenReturn(list_neutronIP);
148 // init instance variables
149 MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , mock(INeutronPortCRUD.class));
150 subnetIdToRouterInterfaceCache.put(UUID, mock(NeutronRouter_Interface.class));
151 MemberModifier.field(NeutronL3Adapter.class, "subnetIdToRouterInterfaceCache").set(neutronL3Adapter , subnetIdToRouterInterfaceCache);
153 // Suppress the called to these functions
154 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "updateL3ForNeutronPort", NeutronPort.class, boolean.class));
155 Mockito.doNothing().when(neutronL3Adapter).handleNeutronRouterInterfaceEvent(any(NeutronRouter.class), any(NeutronRouter_Interface.class), any(Action.class));
157 neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.ADD);
158 Mockito.verify(neutronL3Adapter).handleNeutronRouterInterfaceEvent(any(NeutronRouter.class), any(NeutronRouter_Interface.class), eq(Action.ADD));
160 when(neutronPort.getDeviceOwner()).thenReturn("");
161 neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.ADD);
162 Mockito.verify(neutronL3Adapter, times(2)).handleNeutronRouterInterfaceEvent(any(NeutronRouter.class), any(NeutronRouter_Interface.class), eq(Action.ADD));
163 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("updateL3ForNeutronPort", any(NeutronPort.class), eq(false));
165 neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.DELETE);
166 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("updateL3ForNeutronPort", any(NeutronPort.class), eq(true));
170 public void testhandleNeutronRouterEvent() throws Exception {
171 // Nothing to be done here
172 neutronL3Adapter.handleNeutronRouterEvent(mock(NeutronRouter.class), Action.ADD);
176 public void testHandleNeutronRouterInterfaceEvent() throws Exception {
178 NeutronRouter_Interface neutronRouterInterface = mock(NeutronRouter_Interface.class);
179 when(neutronRouterInterface.getPortUUID()).thenReturn(UUID);
180 when(neutronRouterInterface.getSubnetUUID()).thenReturn(UUID);
182 Neutron_IPs neutronIP = mock(Neutron_IPs.class);
183 when(neutronIP.getSubnetUUID()).thenReturn(UUID);
184 NeutronPort neutronPort = mock(NeutronPort.class);
185 List<Neutron_IPs> list_neutronIP = new ArrayList<Neutron_IPs>();
186 list_neutronIP.add(neutronIP);
187 when(neutronPort.getFixedIPs()).thenReturn(list_neutronIP);
188 List<NeutronPort> list_neutronPort = new ArrayList<>();
189 list_neutronPort.add(neutronPort);
190 INeutronPortCRUD neutronPortCache = mock(INeutronPortCRUD.class);
191 when(neutronPortCache.getAllPorts()).thenReturn(list_neutronPort);
193 // init instance variables
194 MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , neutronPortCache);
196 // Suppress the called to these functions
197 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowsForNeutronRouterInterface", NeutronRouter_Interface.class, Boolean.class));
198 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "updateL3ForNeutronPort", NeutronPort.class, boolean.class));
200 neutronL3Adapter.handleNeutronRouterInterfaceEvent(mock(NeutronRouter.class), neutronRouterInterface, Action.ADD);
201 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForNeutronRouterInterface", any(NeutronRouter_Interface.class), eq(false));
202 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("updateL3ForNeutronPort", any(NeutronPort.class), eq(false));
204 neutronL3Adapter.handleNeutronRouterInterfaceEvent(mock(NeutronRouter.class), neutronRouterInterface, Action.DELETE);
205 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForNeutronRouterInterface", any(NeutronRouter_Interface.class), eq(true));
206 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("updateL3ForNeutronPort", any(NeutronPort.class), eq(true));
210 public void testHandleNeutronFloatingIPEvent() throws Exception {
212 NeutronFloatingIP neutronFloatingIP = mock(NeutronFloatingIP.class);
213 when(neutronFloatingIP.getFixedIPAddress()).thenReturn(FIXED_IP_ADDRESS);
214 when(neutronFloatingIP.getFloatingIPAddress()).thenReturn(FLOATING_IP_ADDRESS);
215 when(neutronFloatingIP.getID()).thenReturn(UUID);
217 // Suppress the called to these functions
218 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowsForFloatingIPArpAdd", NeutronFloatingIP.class));
219 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowsForFloatingIPInbound", NeutronFloatingIP.class, Action.class));
220 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowsForFloatingIPOutbound", NeutronFloatingIP.class, Action.class));
221 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowsForFloatingIPArpDelete", String.class));
223 neutronL3Adapter.handleNeutronFloatingIPEvent(neutronFloatingIP, Action.ADD);
224 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForFloatingIPArpAdd", any(NeutronFloatingIP.class));
225 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForFloatingIPInbound", any(NeutronFloatingIP.class), eq(Action.ADD));
226 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForFloatingIPOutbound", any(NeutronFloatingIP.class), eq(Action.ADD));
228 neutronL3Adapter.handleNeutronFloatingIPEvent(neutronFloatingIP, Action.DELETE);
229 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForFloatingIPArpDelete", anyString());
230 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForFloatingIPInbound", any(NeutronFloatingIP.class), eq(Action.DELETE));
231 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForFloatingIPOutbound", any(NeutronFloatingIP.class), eq(Action.DELETE));
234 @SuppressWarnings({ "unchecked", "rawtypes" })
236 public void testProgramFlowsForFloatingIPInbound() throws Exception {
237 Map floatIpDataMapCache = new HashMap();
239 NeutronFloatingIP neutronFloatingIp = mock(NeutronFloatingIP.class);
240 when(neutronFloatingIp.getID()).thenReturn(ID);
242 // init instance variables
243 floatIpDataMapCache .put(ID, floatingIpObject);
244 MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
246 // Suppress the called to these functions
247 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programInboundIpRewriteStage1", Long.class, Long.class, String.class, String.class, String.class, Action.class));
249 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForFloatingIPInbound", neutronFloatingIp, Action.ADD);
250 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programInboundIpRewriteStage1", anyLong(), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
253 @SuppressWarnings({ "unchecked", "rawtypes" })
255 public void testProgramFlowsForFloatingIPOutbound() throws Exception {
256 Map floatIpDataMapCache = new HashMap();
258 NeutronFloatingIP neutronFloatingIp = mock(NeutronFloatingIP.class);
259 when(neutronFloatingIp.getID()).thenReturn(ID);
261 // init instance variables
262 floatIpDataMapCache.put(ID, floatingIpObject);
263 MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
265 // Suppress the called to these functions
266 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage1", floatingIpClass, Action.class));
268 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForFloatingIPOutbound", neutronFloatingIp, Action.ADD);
269 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage1", any(floatingIpClass), eq(Action.ADD));
272 @SuppressWarnings({ "unchecked", "rawtypes" })
274 public void testFlushExistingIpRewrite() throws Exception {
275 Map floatIpDataMapCache = new HashMap();
277 // init instance variables
278 floatIpDataMapCache.put(ID, floatingIpObject);
279 MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
281 // Suppress the called to these functions
282 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage1", floatingIpClass, Action.class));
284 Whitebox.invokeMethod(neutronL3Adapter, "flushExistingIpRewrite");
285 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage1", any(floatingIpClass), eq(Action.DELETE));
288 @SuppressWarnings({ "unchecked", "rawtypes" })
290 public void testRebuildExistingIpRewrite() throws Exception {
291 Map floatIpDataMapCache = new HashMap();
293 // init instance variables
294 floatIpDataMapCache.put(ID, floatingIpObject);
295 MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
297 // Suppress the called to these functions
298 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage1", floatingIpClass, Action.class));
300 Whitebox.invokeMethod(neutronL3Adapter, "rebuildExistingIpRewrite");
301 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage1", any(floatingIpClass), eq(Action.ADD));
304 @SuppressWarnings({ "unchecked", "rawtypes" })
306 public void testProgramFlowsForFloatingIPArpAdd() throws Exception {
307 Map<String, Pair> neutronPortToDpIdCache = new HashMap<String, Pair>();
308 Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
309 Map floatIpDataMapCache = new HashMap();
311 NeutronFloatingIP neutronFloatingIP = mock(NeutronFloatingIP.class);
312 when(neutronFloatingIP.getFixedIPAddress()).thenReturn(FIXED_IP_ADDRESS);
313 when(neutronFloatingIP.getFloatingIPAddress()).thenReturn(FLOATING_IP_ADDRESS);
314 when(neutronFloatingIP.getPortUUID()).thenReturn(UUID);
315 NeutronPort neutronPort = mock(NeutronPort.class);
316 when(neutronPort.getMacAddress()).thenReturn(MAC_ADDRESS);
317 NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
318 when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
319 when(neutronNetwork.getID()).thenReturn(ID);
321 // init instance variables
322 floatIpDataMapCache.put(ID, floatingIpObject);
323 neutronPortToDpIdCache.put(UUID, mock(Pair.class));
324 networkIdToRouterMacCache.put(ID, MAC_ADDRESS);
325 INeutronNetworkCRUD neutronNetworkCache = mock(INeutronNetworkCRUD.class);
326 when(neutronNetworkCache.getNetwork(anyString())).thenReturn(neutronNetwork);
327 INeutronPortCRUD neutronPortCache = mock(INeutronPortCRUD.class);
328 when(neutronPortCache.getPort(anyString())).thenReturn(neutronPort);
329 PowerMockito.doReturn(neutronPort).when(neutronL3Adapter, "findNeutronPortForFloatingIp", anyString());
330 PowerMockito.doReturn(Long.valueOf(15)).when(neutronL3Adapter, "findOFPortForExtPatch", anyLong());
331 MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
332 MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
333 MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , neutronPortCache);
334 MemberModifier.field(NeutronL3Adapter.class, "neutronNetworkCache").set(neutronL3Adapter , neutronNetworkCache);
335 MemberModifier.field(NeutronL3Adapter.class, "networkIdToRouterMacCache").set(neutronL3Adapter , networkIdToRouterMacCache);
337 // Suppress the called to these functions
338 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "findNeutronPortForFloatingIp", String.class));
339 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "findOFPortForExtPatch", Long.class));
340 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage1", Long.class, String.class, String.class, String.class, Action.class));
342 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForFloatingIPArpAdd", neutronFloatingIP);
343 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("findNeutronPortForFloatingIp", anyString());
344 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("findOFPortForExtPatch", anyLong());
345 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
348 @SuppressWarnings({ "unchecked", "rawtypes" })
350 public void testProgramFlowsForFloatingIPArpDelete() throws Exception {
351 Map floatIpDataMapCache = new HashMap();
353 // init instance variables
354 floatIpDataMapCache.put(ID, floatingIpObject);
355 MemberModifier.field(NeutronL3Adapter.class, "floatIpDataMapCache").set(neutronL3Adapter , floatIpDataMapCache);
357 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage1", Long.class, String.class, String.class, String.class, Action.class));
359 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForFloatingIPArpDelete", ID);
360 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
364 public void testFindNeutronPortForFloatingIp() throws Exception {
365 NeutronPort neutronPort = mock(NeutronPort.class);
366 when(neutronPort.getDeviceOwner()).thenReturn(OWNER_FLOATING_IP);
367 when(neutronPort.getDeviceID()).thenReturn(ID);
368 List<NeutronPort> list_neutronPort = new ArrayList<>();
369 list_neutronPort.add(neutronPort);
370 INeutronPortCRUD neutronPortCache = mock(INeutronPortCRUD.class);
371 when(neutronPortCache.getAllPorts()).thenReturn(list_neutronPort);
373 MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , neutronPortCache);
375 assertEquals("Error, did not return the correct NeutronPort", neutronPort, Whitebox.invokeMethod(neutronL3Adapter, "findNeutronPortForFloatingIp", ID));
379 public void testFindOFPortForExtPatch() throws Exception {
380 ConfigurationService configurationService = mock(ConfigurationService.class);
381 when(configurationService.getPatchPortName(any(Pair.class))).thenReturn(PORT_INT);
382 MemberModifier.field(NeutronL3Adapter.class, "configurationService").set(neutronL3Adapter , configurationService);
383 List<Node> nodes = new ArrayList<Node>();
384 nodes.add(mock(Node.class));
385 NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
386 when(nodeCacheManager.getBridgeNodes()).thenReturn(nodes);
387 MemberModifier.field(NeutronL3Adapter.class, "nodeCacheManager").set(neutronL3Adapter , nodeCacheManager);
388 Southbound southbound = mock(Southbound.class);
389 when(southbound.getDataPathId(any(Node.class))).thenReturn(Long.valueOf(ID));
390 OvsdbTerminationPointAugmentation terminationPointOfBridge = mock(OvsdbTerminationPointAugmentation.class);
391 when(terminationPointOfBridge.getOfport()).thenReturn(Long.valueOf(ID));
392 when(southbound.getTerminationPointOfBridge(any(Node.class), anyString())).thenReturn(terminationPointOfBridge);
393 MemberModifier.field(NeutronL3Adapter.class, "southbound").set(neutronL3Adapter , southbound);
395 assertEquals("Error, did not return the correct NeutronPort", Long.valueOf(ID), Whitebox.invokeMethod(neutronL3Adapter, "findOFPortForExtPatch", Long.valueOf(ID)));
399 public void testHandleNeutronNetworkEvent() throws Exception {
400 // Nothing to be done here
401 Whitebox.invokeMethod(neutronL3Adapter, "handleNeutronNetworkEvent", mock(NeutronNetwork.class), Action.ADD);
405 public void testHandleInterfaceEvent() throws Exception {
406 Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
407 // init instance variables
408 TenantNetworkManager tenantNetworkManager = mock(TenantNetworkManager.class);
409 MemberModifier.field(NeutronL3Adapter.class, "tenantNetworkManager").set(neutronL3Adapter , tenantNetworkManager);
410 MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
413 NodeId nodeId = mock(NodeId.class);
414 when(nodeId.getValue()).thenReturn(ID);
415 Node node = mock(Node.class);
416 when(node.getNodeId()).thenReturn(nodeId);
418 OvsdbTerminationPointAugmentation intf = mock(OvsdbTerminationPointAugmentation.class);
419 when(intf.getInterfaceUuid()).thenReturn(mock(Uuid.class));
420 when(intf.getName()).thenReturn(INTF_NAME);
422 NeutronPort neutronPort = mock(NeutronPort.class);
423 when(neutronPort.getPortUUID()).thenReturn(UUID);
425 when(tenantNetworkManager.getTenantPort(intf)).thenReturn(neutronPort);
427 // Suppress the called to these functions
428 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "getDpidForIntegrationBridge", Node.class));
429 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "handleInterfaceEventAdd", String.class, Long.class, Uuid.class));
430 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "handleInterfaceEventDelete", OvsdbTerminationPointAugmentation.class, Long.class));
432 PowerMockito.when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class)).thenReturn(Long.valueOf(45));
433 Mockito.doNothing().when(neutronL3Adapter).handleNeutronPortEvent(any(NeutronPort.class), any(Action.class));
435 neutronL3Adapter.handleInterfaceEvent(node, intf, mock(NeutronNetwork.class), Action.ADD);
436 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("getDpidForIntegrationBridge", any(Node.class));
437 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("handleInterfaceEventAdd", any(String.class), anyLong(), any(Uuid.class));
438 Mockito.verify(neutronL3Adapter).handleNeutronPortEvent(neutronPort, Action.ADD);
440 neutronL3Adapter.handleInterfaceEvent(node, intf, mock(NeutronNetwork.class), Action.DELETE);
441 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("handleInterfaceEventDelete", any(OvsdbTerminationPointAugmentation.class), anyLong());
442 Mockito.verify(neutronL3Adapter).handleNeutronPortEvent(neutronPort, Action.DELETE);
446 public void testHandleInterfaceEventAdd() throws Exception {
447 Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
448 // init instance variables
449 MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
450 int temp = neutronPortToDpIdCache.size();
452 Whitebox.invokeMethod(neutronL3Adapter, "handleInterfaceEventAdd", "", Long.valueOf(5), mock(Uuid.class));
454 assertEquals("Error, did not add the port", temp+1, neutronPortToDpIdCache.size());
457 @SuppressWarnings("unchecked")
459 public void testHandleInterfaceEventDelete() throws Exception {
460 Map<String, Pair<Long, Uuid>> neutronPortToDpIdCache = new HashMap<String, Pair<Long,Uuid>>();
461 OvsdbTerminationPointAugmentation intf = mock(OvsdbTerminationPointAugmentation.class);
462 Uuid uuid = mock(Uuid.class);
463 when(intf.getInterfaceUuid()).thenReturn(uuid );
464 Pair<Long, Uuid> pair = mock(Pair.class);
465 when(pair.getRight()).thenReturn(uuid);
467 // init instance variables
468 neutronPortToDpIdCache.put("key", pair);
469 MemberModifier.field(NeutronL3Adapter.class, "neutronPortToDpIdCache").set(neutronL3Adapter , neutronPortToDpIdCache);
470 int temp = neutronPortToDpIdCache.size();
472 Whitebox.invokeMethod(neutronL3Adapter, "handleInterfaceEventDelete", intf, Long.valueOf(ID));
474 assertEquals("Error, did not remove the port", temp-1, neutronPortToDpIdCache.size());
478 public void testUpdateL3ForNeutronPort() throws Exception {
479 Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
481 Neutron_IPs neutronIp = mock(Neutron_IPs.class);
482 when(neutronIp.getIpAddress()).thenReturn(FIXED_IP_ADDRESS);
483 List<Neutron_IPs> neutronIps = new ArrayList<Neutron_IPs>();
484 neutronIps.add(neutronIp);
485 NeutronPort neutronPort = mock(NeutronPort.class);
486 when(neutronPort.getNetworkUUID()).thenReturn(UUID);
487 when(neutronPort.getMacAddress()).thenReturn(MAC_ADDRESS_2);
488 when(neutronPort.getFixedIPs()).thenReturn(neutronIps);
489 NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
490 when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
491 List<Node> nodes = new ArrayList<Node>();
492 nodes.add(mock(Node.class));
493 PowerMockito.doReturn(Long.valueOf(15)).when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class));
495 // init instance variables
496 networkIdToRouterMacCache .put(UUID, MAC_ADDRESS);
497 MemberModifier.field(NeutronL3Adapter.class, "networkIdToRouterMacCache").set(neutronL3Adapter , networkIdToRouterMacCache);
498 INeutronNetworkCRUD neutronNetworkCache = mock(INeutronNetworkCRUD.class);
499 when(neutronNetworkCache.getNetwork(anyString())).thenReturn(neutronNetwork);
500 MemberModifier.field(NeutronL3Adapter.class, "neutronNetworkCache").set(neutronL3Adapter , neutronNetworkCache);
501 NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
502 when(nodeCacheManager.getBridgeNodes()).thenReturn(nodes);
503 MemberModifier.field(NeutronL3Adapter.class, "nodeCacheManager").set(neutronL3Adapter , nodeCacheManager);
504 MemberModifier.field(NeutronL3Adapter.class, "flgDistributedARPEnabled").set(neutronL3Adapter , true);
506 // Suppress the called to these functions
507 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "getDpidForIntegrationBridge", Node.class));
508 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programL3ForwardingStage1", Node.class, Long.class, String.class, String.class, String.class, Action.class));
509 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage1", Long.class, String.class, String.class, String.class, Action.class));
511 Whitebox.invokeMethod(neutronL3Adapter, "updateL3ForNeutronPort", neutronPort, false);
512 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("getDpidForIntegrationBridge", any(Node.class));
513 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programL3ForwardingStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
514 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
516 Whitebox.invokeMethod(neutronL3Adapter, "updateL3ForNeutronPort", neutronPort, true);
517 PowerMockito.verifyPrivate(neutronL3Adapter, times(2)).invoke("getDpidForIntegrationBridge", any(Node.class));
518 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programL3ForwardingStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
519 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
522 // either add or remove item in l3ForwardingCache
524 public void testProgramL3ForwardingStage1() throws Exception {
525 Set<String> l3ForwardingCache = new HashSet<String>();
527 NodeId nodeId = mock(NodeId.class);
528 when(nodeId.getValue()).thenReturn(ID);
529 Node node = mock(Node.class);
530 when(node.getNodeId()).thenReturn(nodeId);
532 // Suppress the called to these functions
533 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programL3ForwardingStage2", Node.class, Long.class, String.class, String.class, String.class, Action.class));
535 // init instance variables
536 MemberModifier.field(NeutronL3Adapter.class, "l3ForwardingCache").set(neutronL3Adapter , l3ForwardingCache );
537 PowerMockito.when(neutronL3Adapter, "programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD)).thenReturn(new Status(StatusCode.SUCCESS));
538 PowerMockito.when(neutronL3Adapter, "programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE)).thenReturn(new Status(StatusCode.SUCCESS));
540 int temp = l3ForwardingCache.size();
542 Whitebox.invokeMethod(neutronL3Adapter, "programL3ForwardingStage1", node, Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.ADD);
543 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
544 assertEquals("Error, did not add the value", temp, l3ForwardingCache.size()-1);
546 l3ForwardingCache.add(node.getNodeId().getValue() + ":" + SEG_ID + ":" + IP);
547 temp = l3ForwardingCache.size();
549 Whitebox.invokeMethod(neutronL3Adapter, "programL3ForwardingStage1", node, Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.DELETE);
550 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programL3ForwardingStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
551 assertEquals("Error, did not delete the value", temp, l3ForwardingCache.size()+1);
555 public void testProgramL3ForwardingStage2() throws Exception {
556 NodeId nodeId = mock(NodeId.class);
557 when(nodeId.getValue()).thenReturn(ID);
558 Node node = mock(Node.class);
559 when(node.getNodeId()).thenReturn(nodeId);
561 assertEquals("Error, this not return the correct status code", new Status(StatusCode.BADREQUEST), Whitebox.invokeMethod(neutronL3Adapter, "programL3ForwardingStage2", node, Long.valueOf(45), SEG_ID, MAC_ADDRESS, MALFORM_IP, Action.ADD));
563 PowerMockito.mockStatic(InetAddress.class);
564 InetAddress inetAddress = mock(InetAddress.class);
565 PowerMockito.when(InetAddress.getByName(anyString())).thenReturn(inetAddress);
567 assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programL3ForwardingStage2", node, Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.ADD));
571 public void testProgramFlowsForNeutronRouterInterface() throws Exception {
572 Map<String, String> networkIdToRouterMacCache = new HashMap<String, String>();
573 Map<String, List<Neutron_IPs>> networkIdToRouterIpListCache = new HashMap<String, List<Neutron_IPs>>();
574 Map<String, NeutronRouter_Interface> subnetIdToRouterInterfaceCache = new HashMap<String, NeutronRouter_Interface>();
576 NeutronRouter_Interface intf = mock(NeutronRouter_Interface.class);
577 when(intf.getPortUUID()).thenReturn(UUID);
578 when(intf.getSubnetUUID()).thenReturn(UUID);
579 Neutron_IPs neutronIp = mock(Neutron_IPs.class);
580 when(neutronIp.getIpAddress()).thenReturn(FIXED_IP_ADDRESS);
581 List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
583 NeutronPort neutronPort = mock(NeutronPort.class);
584 when(neutronPort.getMacAddress()).thenReturn(MAC_ADDRESS);
585 when(neutronPort.getFixedIPs()).thenReturn(ips);
586 when(neutronPort.getNetworkUUID()).thenReturn(UUID);
587 NeutronSubnet neutronSubnet = mock(NeutronSubnet.class);
588 when(neutronSubnet.getNetworkUUID()).thenReturn(UUID);
589 when(neutronSubnet.getGatewayIP()).thenReturn(IP);
590 when(neutronSubnet.getCidr()).thenReturn("cidr");
591 NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
592 when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
593 when(neutronNetwork.getRouterExternal()).thenReturn(false); //might change that to true
594 when(neutronNetwork.getNetworkUUID()).thenReturn(UUID);
595 NeutronRouter neutronRouter = mock(NeutronRouter.class);
597 Node node = mock(Node.class);
598 List<Node> nodes = new ArrayList<Node>();
601 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "getDpidForIntegrationBridge", Node.class));
602 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowsForNeutronRouterInterfacePair", Node.class, Long.class, NeutronRouter_Interface.class, NeutronRouter_Interface.class, NeutronNetwork.class, String.class, String.class, String.class, int.class, Action.class, Boolean.class));
603 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programFlowForNetworkFromExternal", Node.class, Long.class, String.class, String.class, String.class, int.class, Action.class));
604 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage1", Long.class, String.class, String.class, String.class, Action.class));
605 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programIpRewriteExclusionStage1", Node.class, Long.class, String.class, String.class, Action.class));
607 // init instance variables
608 INeutronPortCRUD neutronPortCache = mock(INeutronPortCRUD.class);
609 PowerMockito.when(neutronPortCache.getPort(anyString())).thenReturn(neutronPort);
610 PowerMockito.when(neutronPortCache.getAllPorts()).thenReturn(new ArrayList<NeutronPort>());
611 INeutronSubnetCRUD neutronSubnetCache = mock(INeutronSubnetCRUD.class);
612 PowerMockito.when(neutronSubnetCache.getSubnet(anyString())).thenReturn(neutronSubnet);
613 INeutronNetworkCRUD neutronNetworkCache = mock(INeutronNetworkCRUD.class);
614 PowerMockito.when(neutronNetworkCache.getNetwork(anyString())).thenReturn(neutronNetwork);
615 NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
616 PowerMockito.when(nodeCacheManager.getBridgeNodes()).thenReturn(nodes);
617 MemberModifier.field(NeutronL3Adapter.class, "networkIdToRouterMacCache").set(neutronL3Adapter , networkIdToRouterMacCache);
618 MemberModifier.field(NeutronL3Adapter.class, "networkIdToRouterIpListCache").set(neutronL3Adapter , networkIdToRouterIpListCache);
619 MemberModifier.field(NeutronL3Adapter.class, "subnetIdToRouterInterfaceCache").set(neutronL3Adapter , subnetIdToRouterInterfaceCache);
620 MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , neutronPortCache);
621 MemberModifier.field(NeutronL3Adapter.class, "neutronSubnetCache").set(neutronL3Adapter , neutronSubnetCache);
622 MemberModifier.field(NeutronL3Adapter.class, "neutronNetworkCache").set(neutronL3Adapter , neutronNetworkCache);
623 MemberModifier.field(NeutronL3Adapter.class, "nodeCacheManager").set(neutronL3Adapter , nodeCacheManager);
624 PowerMockito.when(neutronL3Adapter, "getDpidForIntegrationBridge", any(Node.class)).thenReturn(Long.valueOf(45));
626 int networkIdToRouterMacCacheSize, networkIdToRouterIpListCacheSize, subnetIdToRouterInterfaceCacheSize;
627 networkIdToRouterMacCacheSize = networkIdToRouterMacCache.size();
628 networkIdToRouterIpListCacheSize = networkIdToRouterIpListCache.size();
629 subnetIdToRouterInterfaceCacheSize = subnetIdToRouterInterfaceCache.size();
631 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForNeutronRouterInterface", intf, false);
633 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("getDpidForIntegrationBridge", any(Node.class));
634 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForNeutronRouterInterfacePair", any(Node.class), anyLong(), any(NeutronRouter_Interface.class), any(NeutronRouter_Interface.class), any(NeutronNetwork.class), anyString(), anyString(), anyString(), anyInt(), eq(Action.ADD), anyBoolean());
635 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowForNetworkFromExternal", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyInt(), eq(Action.ADD));
636 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
637 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programIpRewriteExclusionStage1", any(Node.class), anyLong(), anyString(), anyString(), eq(Action.ADD));
638 assertEquals("Error, did not add the RouterMac", networkIdToRouterMacCacheSize, networkIdToRouterMacCache.size() -1);
639 assertEquals("Error, did not add the RouterIP", networkIdToRouterIpListCacheSize, networkIdToRouterIpListCache.size() -1);
640 assertEquals("Error, did not add the RouterInterface", subnetIdToRouterInterfaceCacheSize, subnetIdToRouterInterfaceCache.size() -1);
642 networkIdToRouterMacCache.put(UUID, MAC_ADDRESS);
643 networkIdToRouterIpListCache.put(UUID, ips);
644 subnetIdToRouterInterfaceCache.put(UUID, intf);
645 networkIdToRouterMacCacheSize = networkIdToRouterMacCache.size();
646 networkIdToRouterIpListCacheSize = networkIdToRouterIpListCache.size();
647 subnetIdToRouterInterfaceCacheSize = subnetIdToRouterInterfaceCache.size();
649 Whitebox.invokeMethod(neutronL3Adapter, "handleNeutronRouterInterfaceEvent", neutronRouter, intf, Action.DELETE);
651 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowsForNeutronRouterInterface", intf, true);
652 PowerMockito.verifyPrivate(neutronL3Adapter, times(2)).invoke("getDpidForIntegrationBridge", any(Node.class));
653 PowerMockito.verifyPrivate(neutronL3Adapter, times(2)).invoke("programFlowsForNeutronRouterInterfacePair", any(Node.class), anyLong(), any(NeutronRouter_Interface.class), any(NeutronRouter_Interface.class), any(NeutronNetwork.class), anyString(), anyString(), anyString(), anyInt(), eq(Action.DELETE), anyBoolean());
654 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programFlowForNetworkFromExternal", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyInt(), eq(Action.DELETE));
655 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage1", anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
656 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programIpRewriteExclusionStage1", any(Node.class), anyLong(), anyString(), anyString(), eq(Action.DELETE));
657 assertEquals("Error, did not remove the RouterMac", networkIdToRouterMacCacheSize, networkIdToRouterMacCache.size() +1);
658 assertEquals("Error, did not remove the RouterIP", networkIdToRouterIpListCacheSize, networkIdToRouterIpListCache.size() +1);
659 assertEquals("Error, did not remove the RouterInterface", subnetIdToRouterInterfaceCacheSize, subnetIdToRouterInterfaceCache.size() +1);
663 public void testProgramFlowForNetworkFromExternal() throws Exception {
664 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programRouterInterfaceStage1", Node.class, Long.class, String.class, String.class, String.class, String.class, int.class, Action.class));
666 Whitebox.invokeMethod(neutronL3Adapter, "programFlowForNetworkFromExternal", mock(Node.class), Long.valueOf(12), "", "", "", 4, Action.ADD);
668 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), any(Action.class));
672 public void testProgramFlowsForNeutronRouterInterfacePair() throws Exception {
673 NeutronRouter_Interface srcNeutronRouterInterface = mock(NeutronRouter_Interface.class);
674 when(srcNeutronRouterInterface.getSubnetUUID()).thenReturn(UUID);
675 when(srcNeutronRouterInterface.getID()).thenReturn(ID);
676 when(srcNeutronRouterInterface.getPortUUID()).thenReturn(UUID);
677 NeutronRouter_Interface dstNeutronRouterInterface = mock(NeutronRouter_Interface.class);
678 NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
679 when(neutronNetwork.getTenantID()).thenReturn(ID);
680 when(neutronNetwork.getProviderSegmentationID()).thenReturn(ID);
681 Neutron_IPs ip = mock(Neutron_IPs.class);
682 when(ip.getIpAddress()).thenReturn(IP);
683 List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
687 NeutronPort neutronPort = mock(NeutronPort.class);
688 when(neutronPort.getMacAddress()).thenReturn(MAC_ADDRESS);
689 when(neutronPort.getFixedIPs()).thenReturn(ips);
690 NeutronSubnet neutronSubnet = mock(NeutronSubnet.class);
691 when(neutronSubnet.getNetworkUUID()).thenReturn(UUID);
692 when(neutronSubnet.getCidr()).thenReturn(CIDR);
694 INeutronSubnetCRUD neutronSubnetCache = mock(INeutronSubnetCRUD.class);
695 PowerMockito.when(neutronSubnetCache.getSubnet(anyString())).thenReturn(neutronSubnet);
696 MemberModifier.field(NeutronL3Adapter.class, "neutronSubnetCache").set(neutronL3Adapter , neutronSubnetCache);
697 INeutronNetworkCRUD neutronNetworkCache = mock(INeutronNetworkCRUD.class);
698 PowerMockito.when(neutronNetworkCache.getNetwork(anyString())).thenReturn(neutronNetwork);
699 MemberModifier.field(NeutronL3Adapter.class, "neutronNetworkCache").set(neutronL3Adapter , neutronNetworkCache);
700 INeutronPortCRUD neutronPortCache = mock(INeutronPortCRUD.class);
701 PowerMockito.when(neutronPortCache.getPort(anyString())).thenReturn(neutronPort);
702 MemberModifier.field(NeutronL3Adapter.class, "neutronPortCache").set(neutronL3Adapter , neutronPortCache);
704 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programRouterInterfaceStage1", Node.class, Long.class, String.class, String.class, String.class, String.class, int.class, Action.class));
705 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "getMaskLenFromCidr", String.class));
707 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForNeutronRouterInterfacePair", mock(Node.class), Long.valueOf(12), srcNeutronRouterInterface, dstNeutronRouterInterface, neutronNetwork, SEG_ID, MAC_ADDRESS, IP, 4, Action.ADD, false);
708 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), any(Action.class));
710 Whitebox.invokeMethod(neutronL3Adapter, "programFlowsForNeutronRouterInterfacePair", mock(Node.class), Long.valueOf(12), srcNeutronRouterInterface, dstNeutronRouterInterface, neutronNetwork, SEG_ID, MAC_ADDRESS, IP, 4, Action.ADD, true);
711 PowerMockito.verifyPrivate(neutronL3Adapter, times(2)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), any(Action.class));
712 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("getMaskLenFromCidr", anyString());
713 PowerMockito.verifyPrivate(neutronL3Adapter, times(4)).invoke("programFlowsForNeutronRouterInterfacePair", any(Node.class), anyLong(), any(NeutronRouter_Interface.class), any(NeutronRouter_Interface.class), any(NeutronNetwork.class), anyString(), anyString(), anyString(), anyInt(), any(Action.class), eq(false)); //3 + 1 above
717 public void testProgramRouterInterfaceStage1() throws Exception {
718 Set<String> routerInterfacesCache = new HashSet<String>();
720 NodeId nodeId = mock(NodeId.class);
721 when(nodeId.getValue()).thenReturn(ID);
722 Node node = mock(Node.class);
723 when(node.getNodeId()).thenReturn(nodeId);
725 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programRouterInterfaceStage2", Node.class, Long.class, String.class, String.class, String.class, String.class, int.class, Action.class));
727 MemberModifier.field(NeutronL3Adapter.class, "routerInterfacesCache").set(neutronL3Adapter , routerInterfacesCache);
728 PowerMockito.when(neutronL3Adapter, "programRouterInterfaceStage2", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
730 int t = routerInterfacesCache.size();
732 Whitebox.invokeMethod(neutronL3Adapter, "programRouterInterfaceStage1", node, Long.valueOf(12), SEG_ID, SEG_ID, MAC_ADDRESS, IP, 4, Action.ADD);
734 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), eq(Action.ADD));
735 assertEquals("Error, did not add the interface", t, routerInterfacesCache.size() - 1);
737 t = routerInterfacesCache.size();
738 Whitebox.invokeMethod(neutronL3Adapter, "programRouterInterfaceStage1", node, Long.valueOf(12), SEG_ID, SEG_ID, MAC_ADDRESS, IP, 4, Action.DELETE);
740 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programRouterInterfaceStage1", any(Node.class), anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt(), eq(Action.DELETE));
741 assertEquals("Error, did not delete the interface", t, routerInterfacesCache.size() + 1);
744 // either add or remove routerInterfacesCache
746 public void testProgramRouterInterfaceStage2() throws Exception {
747 NodeId nodeId = mock(NodeId.class);
748 when(nodeId.getValue()).thenReturn(ID);
749 Node node = mock(Node.class);
750 when(node.getNodeId()).thenReturn(nodeId);
752 assertEquals("Error, this not return the correct status code", new Status(StatusCode.BADREQUEST), Whitebox.invokeMethod(neutronL3Adapter, "programRouterInterfaceStage2", node, Long.valueOf(45), SEG_ID, SEG_ID , MAC_ADDRESS, MALFORM_IP, 4, Action.ADD));
754 PowerMockito.mockStatic(InetAddress.class);
755 InetAddress inetAddress = mock(InetAddress.class);
756 PowerMockito.when(InetAddress.getByName(anyString())).thenReturn(inetAddress);
758 assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programRouterInterfaceStage2", node, Long.valueOf(45), SEG_ID, SEG_ID, MAC_ADDRESS, IP, 4, Action.ADD));
762 //either add or remove staticArpEntryCache
764 public void testProgramStaticArpStage1() throws Exception {
765 Set<String> staticArpEntryCache = new HashSet<String>();
767 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programStaticArpStage2", Long.class, String.class, String.class, String.class, Action.class));
769 MemberModifier.field(NeutronL3Adapter.class, "staticArpEntryCache").set(neutronL3Adapter , staticArpEntryCache);
770 PowerMockito.when(neutronL3Adapter, "programStaticArpStage2", anyLong(), anyString(), anyString(), anyString(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
772 int t = staticArpEntryCache.size();
774 Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage1", Long.valueOf(12), PORT_INT, MAC_ADDRESS, IP, Action.ADD);
776 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage2", anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
777 assertEquals("Error, did not add the static arp", t, staticArpEntryCache.size() - 1);
779 t = staticArpEntryCache.size();
780 Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage1", Long.valueOf(12), PORT_INT, MAC_ADDRESS, IP, Action.DELETE);
782 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programStaticArpStage2", anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
783 assertEquals("Error, did not delete the static arp", t, staticArpEntryCache.size() + 1);
787 public void testProgramStaticArpStage2() throws Exception {
788 assertEquals("Error, this not return the correct status code", new Status(StatusCode.BADREQUEST), Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage2", Long.valueOf(45), PORT_INT, MAC_ADDRESS, MALFORM_IP, Action.ADD));
790 PowerMockito.mockStatic(InetAddress.class);
791 InetAddress inetAddress = mock(InetAddress.class);
792 PowerMockito.when(InetAddress.getByName(anyString())).thenReturn(inetAddress);
794 assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programStaticArpStage2", Long.valueOf(45), PORT_INT, MAC_ADDRESS, IP, Action.ADD));
797 // either add or remove inboundIpRewriteCache
799 public void testProgramInboundIpRewriteStage1() throws Exception {
800 Set<String> inboundIpRewriteCache = new HashSet<String>();
802 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programInboundIpRewriteStage2", Long.class, Long.class, String.class, String.class, String.class, Action.class));
804 MemberModifier.field(NeutronL3Adapter.class, "inboundIpRewriteCache").set(neutronL3Adapter , inboundIpRewriteCache);
805 PowerMockito.when(neutronL3Adapter, "programInboundIpRewriteStage2", anyLong(), anyLong(), anyString(), anyString(), anyString(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
807 int t = inboundIpRewriteCache.size();
809 Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage1", Long.valueOf(12), Long.valueOf(12), PORT_INT, MAC_ADDRESS, IP, Action.ADD);
811 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programInboundIpRewriteStage2", anyLong(), anyLong(), anyString(), anyString(), anyString(), eq(Action.ADD));
812 assertEquals("Error, did not add the inboundIpRewrite", t, inboundIpRewriteCache.size() - 1);
814 t = inboundIpRewriteCache.size();
815 Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage1", Long.valueOf(12), Long.valueOf(12),PORT_INT, MAC_ADDRESS, IP, Action.DELETE);
817 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programInboundIpRewriteStage2", anyLong(), anyLong(), anyString(), anyString(), anyString(), eq(Action.DELETE));
818 assertEquals("Error, did not delete the inboundIpRewrite", t, inboundIpRewriteCache.size() + 1);
822 public void testProgramInboundIpRewriteStage2() throws Exception {
823 assertEquals("Error, this not return the correct status code", new Status(StatusCode.BADREQUEST), Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage2", Long.valueOf(45), Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.ADD));
825 PowerMockito.mockStatic(InetAddress.class);
826 InetAddress inetAddress = mock(InetAddress.class);
827 PowerMockito.when(InetAddress.getByName(anyString())).thenReturn(inetAddress);
829 assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programInboundIpRewriteStage2", Long.valueOf(45), Long.valueOf(45), SEG_ID, MAC_ADDRESS, IP, Action.ADD));
832 // either add or remove outboundIpRewriteExclusionCache
834 public void testProgramIpRewriteExclusionStage1() throws Exception {
835 Set<String> outboundIpRewriteExclusionCache = new HashSet<String>();
837 NodeId nodeId = mock(NodeId.class);
838 when(nodeId.getValue()).thenReturn(ID);
839 Node node = mock(Node.class);
840 when(node.getNodeId()).thenReturn(nodeId);
842 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programIpRewriteExclusionStage2", Node.class, Long.class, String.class, String.class, Action.class));
844 MemberModifier.field(NeutronL3Adapter.class, "outboundIpRewriteExclusionCache").set(neutronL3Adapter , outboundIpRewriteExclusionCache);
845 PowerMockito.when(neutronL3Adapter, "programIpRewriteExclusionStage2", any(Node.class), anyLong(), anyString(), anyString(), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
847 int t = outboundIpRewriteExclusionCache.size();
849 Whitebox.invokeMethod(neutronL3Adapter, "programIpRewriteExclusionStage1", node, Long.valueOf(12), SEG_ID, CIDR, Action.ADD);
851 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programIpRewriteExclusionStage2", any(Node.class), anyLong(), anyString(), anyString(), eq(Action.ADD));
852 assertEquals("Error, did not add the outboundIpRewriteExclusion", t, outboundIpRewriteExclusionCache.size() - 1);
854 t = outboundIpRewriteExclusionCache.size();
855 Whitebox.invokeMethod(neutronL3Adapter, "programIpRewriteExclusionStage1", node, Long.valueOf(12), SEG_ID, CIDR, Action.DELETE);
857 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programIpRewriteExclusionStage2", any(Node.class), anyLong(), anyString(), anyString(), eq(Action.DELETE));
858 assertEquals("Error, did not delete the outboundIpRewriteExclusion", t, outboundIpRewriteExclusionCache.size() + 1);
862 public void testProgramIpRewriteExclusionStage2() throws Exception {
863 NodeId nodeId = mock(NodeId.class);
864 when(nodeId.getValue()).thenReturn(ID);
865 Node node = mock(Node.class);
866 when(node.getNodeId()).thenReturn(nodeId);
868 assertEquals("Error, this not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programIpRewriteExclusionStage2", node, Long.valueOf(45), SEG_ID, CIDR, Action.ADD));
871 // either add or remove outboundIpRewriteCache
872 @SuppressWarnings("unchecked")
874 public void testProgramOutboundIpRewriteStage1() throws Exception{
875 Set<String> outboundIpRewriteCache = new HashSet<String>();
877 MemberModifier.suppress(MemberMatcher.method(NeutronL3Adapter.class, "programOutboundIpRewriteStage2", floatingIpClass, Action.class));
879 MemberModifier.field(NeutronL3Adapter.class, "outboundIpRewriteCache").set(neutronL3Adapter , outboundIpRewriteCache);
880 PowerMockito.when(neutronL3Adapter, "programOutboundIpRewriteStage2", any(floatingIpClass), any(Action.class)).thenReturn(new Status(StatusCode.SUCCESS));
882 int t = outboundIpRewriteCache.size();
884 Whitebox.invokeMethod(neutronL3Adapter, "programOutboundIpRewriteStage1", floatingIpObject, Action.ADD);
886 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage2", any(floatingIpClass), eq(Action.ADD));
887 assertEquals("Error, did not add the outbound ip", t, outboundIpRewriteCache.size() - 1);
889 t = outboundIpRewriteCache.size();
890 Whitebox.invokeMethod(neutronL3Adapter, "programOutboundIpRewriteStage1", floatingIpObject, Action.DELETE);
892 PowerMockito.verifyPrivate(neutronL3Adapter, times(1)).invoke("programOutboundIpRewriteStage2", any(floatingIpClass), eq(Action.DELETE));
893 assertEquals("Error, did not delete the outbound ip", t, outboundIpRewriteCache.size() + 1);
897 public void testPrepareProgramOutboundIpRewriteStage2() throws Exception {
898 assertEquals("Error, did not return the correct status code", new Status(StatusCode.BADREQUEST), Whitebox.invokeMethod(neutronL3Adapter, "programOutboundIpRewriteStage2", floatingIpObject, Action.ADD));
900 PowerMockito.mockStatic(InetAddress.class);
901 InetAddress inetAddress = mock(InetAddress.class);
902 PowerMockito.when(InetAddress.getByName(anyString())).thenReturn(inetAddress);
904 assertEquals("Error, did not return the correct status code", new Status(StatusCode.SUCCESS), Whitebox.invokeMethod(neutronL3Adapter, "programOutboundIpRewriteStage2", floatingIpObject, Action.ADD));
908 public void testGetMaskLenFromCidr() throws Exception {
909 assertEquals("Error, did not return the correct mask", 32, Whitebox.invokeMethod(neutronL3Adapter, "getMaskLenFromCidr", IP_MASK));
913 public void testGetDpidForIntegrationBridge() throws Exception {
914 Southbound southbound = mock(Southbound.class);
915 ConfigurationService configurationService = mock(ConfigurationService.class);
917 MemberModifier.field(NeutronL3Adapter.class, "southbound").set(neutronL3Adapter , southbound);
918 MemberModifier.field(NeutronL3Adapter.class, "configurationService").set(neutronL3Adapter , configurationService);
920 PowerMockito.when(southbound.getBridge(any(Node.class), anyString())).thenReturn(mock(OvsdbBridgeAugmentation.class));
921 PowerMockito.when(configurationService.getIntegrationBridgeName()).thenReturn("");
922 PowerMockito.when(southbound.getDataPathId(any(Node.class))).thenReturn(Long.valueOf(45));
924 assertEquals("Error, did not return the correct Dpid", Long.valueOf(45), Whitebox.invokeMethod(neutronL3Adapter, "getDpidForIntegrationBridge", mock(Node.class)));
928 public void testencodeExcplicitOFPort() throws Exception {
929 assertEquals("Error, did not correctly encode the port", OFPort, NeutronL3Adapter.encodeExcplicitOFPort(Long.valueOf(45)));
933 public void testSetDependencies() throws Exception {
934 TenantNetworkManager tenantNetworkManager = mock(TenantNetworkManager.class);
935 ConfigurationService configurationService = mock(ConfigurationService.class);
936 ArpProvider arpProvider = mock(ArpProvider.class);
937 InboundNatProvider inboundNatProvider = mock(InboundNatProvider.class);
938 OutboundNatProvider outboundNatProvider = mock(OutboundNatProvider.class);
939 RoutingProvider routingProvider = mock(RoutingProvider.class);
940 L3ForwardingProvider l3ForwardingProvider = mock(L3ForwardingProvider.class);
941 NodeCacheManager nodeCacheManager = mock(NodeCacheManager.class);
942 Southbound southbound = mock(Southbound.class);
944 PowerMockito.mockStatic(ServiceHelper.class);
945 PowerMockito.when(ServiceHelper.getGlobalInstance(TenantNetworkManager.class, neutronL3Adapter)).thenReturn(tenantNetworkManager);
946 PowerMockito.when(ServiceHelper.getGlobalInstance(ConfigurationService.class, neutronL3Adapter)).thenReturn(configurationService);
947 PowerMockito.when(ServiceHelper.getGlobalInstance(ArpProvider.class, neutronL3Adapter)).thenReturn(arpProvider);
948 PowerMockito.when(ServiceHelper.getGlobalInstance(InboundNatProvider.class, neutronL3Adapter)).thenReturn(inboundNatProvider);
949 PowerMockito.when(ServiceHelper.getGlobalInstance(OutboundNatProvider.class, neutronL3Adapter)).thenReturn(outboundNatProvider);
950 PowerMockito.when(ServiceHelper.getGlobalInstance(RoutingProvider.class, neutronL3Adapter)).thenReturn(routingProvider);
951 PowerMockito.when(ServiceHelper.getGlobalInstance(L3ForwardingProvider.class, neutronL3Adapter)).thenReturn(l3ForwardingProvider);
952 PowerMockito.when(ServiceHelper.getGlobalInstance(NodeCacheManager.class, neutronL3Adapter)).thenReturn(nodeCacheManager);
953 PowerMockito.when(ServiceHelper.getGlobalInstance(Southbound.class, neutronL3Adapter)).thenReturn(southbound);
955 neutronL3Adapter.setDependencies(mock(BundleContext.class), mock(ServiceReference.class));
957 assertEquals("Error, did not return the correct object", getField("tenantNetworkManager"), tenantNetworkManager);
958 assertEquals("Error, did not return the correct object", getField("configurationService"), configurationService);
959 assertEquals("Error, did not return the correct object", getField("arpProvider"), arpProvider);
960 assertEquals("Error, did not return the correct object", getField("inboundNatProvider"), inboundNatProvider);
961 assertEquals("Error, did not return the correct object", getField("outboundNatProvider"), outboundNatProvider);
962 assertEquals("Error, did not return the correct object", getField("routingProvider"), routingProvider);
963 assertEquals("Error, did not return the correct object", getField("l3ForwardingProvider"), l3ForwardingProvider);
964 assertEquals("Error, did not return the correct object", getField("nodeCacheManager"), nodeCacheManager);
965 assertEquals("Error, did not return the correct object", getField("southbound"), southbound);
969 public void testSetDependenciesObject() throws Exception{
970 INeutronNetworkCRUD iNeutronNetworkCRUD = mock(INeutronNetworkCRUD.class);
971 neutronL3Adapter.setDependencies(iNeutronNetworkCRUD);
972 assertEquals("Error, did not return the correct object", getField("neutronNetworkCache"), iNeutronNetworkCRUD);
974 INeutronPortCRUD iNeutronPortCRUD = mock(INeutronPortCRUD.class);
975 neutronL3Adapter.setDependencies(iNeutronPortCRUD);
976 assertEquals("Error, did not return the correct object", getField("neutronPortCache"), iNeutronPortCRUD);
978 INeutronSubnetCRUD iNeutronSubnetCRUD = mock(INeutronSubnetCRUD.class);
979 neutronL3Adapter.setDependencies(iNeutronSubnetCRUD);
980 assertEquals("Error, did not return the correct object", getField("neutronSubnetCache"), iNeutronSubnetCRUD);
982 ArpProvider arpProvider = mock(ArpProvider.class);
983 neutronL3Adapter.setDependencies(arpProvider);
984 assertEquals("Error, did not return the correct object", getField("arpProvider"), arpProvider);
986 InboundNatProvider inboundNatProvider = mock(InboundNatProvider.class);
987 neutronL3Adapter.setDependencies(inboundNatProvider);
988 assertEquals("Error, did not return the correct object", getField("inboundNatProvider"), inboundNatProvider);
990 OutboundNatProvider outboundNatProvider = mock(OutboundNatProvider.class);
991 neutronL3Adapter.setDependencies(outboundNatProvider);
992 assertEquals("Error, did not return the correct object", getField("outboundNatProvider"), outboundNatProvider);
994 RoutingProvider routingProvider = mock(RoutingProvider.class);
995 neutronL3Adapter.setDependencies(routingProvider);
996 assertEquals("Error, did not return the correct object", getField("routingProvider"), routingProvider);
998 L3ForwardingProvider l3ForwardingProvider = mock(L3ForwardingProvider.class);
999 neutronL3Adapter.setDependencies(l3ForwardingProvider);
1000 assertEquals("Error, did not return the correct object", getField("l3ForwardingProvider"), l3ForwardingProvider);
1003 private Object getField(String fieldName) throws Exception {
1004 Field field = NeutronL3Adapter.class.getDeclaredField(fieldName);
1005 field.setAccessible(true);
1006 return field.get(neutronL3Adapter);
1009 @SuppressWarnings("rawtypes")
1010 private Object createFloatingIpObject() throws Exception{
1011 Class clazz = Whitebox.getInnerClassType(NeutronL3Adapter.class, "FloatIpData");
1012 Constructor [] constructors = clazz.getConstructors();
1013 Constructor c = constructors[0];
1014 return c.newInstance(new NeutronL3Adapter(), Long.valueOf(415), Long.valueOf(415), "a", "b", "c", "d", "e");