Skip to content
Snippets Groups Projects
Commit f6d2fe38 authored by Alex Reimers's avatar Alex Reimers
Browse files

Fix unit tests to work with module config parameters.

parent f41cdeee
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,7 @@ public class FloodlightModuleContext implements IFloodlightModuleContext { ...@@ -72,6 +72,7 @@ public class FloodlightModuleContext implements IFloodlightModuleContext {
public void createConfigMaps(Set<IFloodlightModule> moduleSet) { public void createConfigMaps(Set<IFloodlightModule> moduleSet) {
for (IFloodlightModule mod : moduleSet) { for (IFloodlightModule mod : moduleSet) {
Map<String, String> moduleParams = new HashMap<String, String>(); Map<String, String> moduleParams = new HashMap<String, String>();
System.out.println();
configParams.put(mod.getClass(), moduleParams); configParams.put(mod.getClass(), moduleParams);
} }
} }
......
...@@ -24,6 +24,7 @@ import java.util.Date; ...@@ -24,6 +24,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -37,6 +38,7 @@ import net.floodlightcontroller.core.IOFMessageListener.Command; ...@@ -37,6 +38,7 @@ import net.floodlightcontroller.core.IOFMessageListener.Command;
import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.OFMessageFilterManager; import net.floodlightcontroller.core.OFMessageFilterManager;
import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockFloodlightProvider;
import net.floodlightcontroller.counter.CounterStore; import net.floodlightcontroller.counter.CounterStore;
import net.floodlightcontroller.counter.ICounterStoreService; import net.floodlightcontroller.counter.ICounterStoreService;
...@@ -80,17 +82,30 @@ public class ControllerTest extends FloodlightTestCase { ...@@ -80,17 +82,30 @@ public class ControllerTest extends FloodlightTestCase {
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
FloodlightModuleContext fmc = new FloodlightModuleContext(); FloodlightModuleContext fmc = new FloodlightModuleContext();
Set<IFloodlightModule> modSet = new HashSet<IFloodlightModule>();
FloodlightProvider cm = new FloodlightProvider(); FloodlightProvider cm = new FloodlightProvider();
controller = (Controller)cm.getServiceImpls().get(IFloodlightProviderService.class); controller = (Controller)cm.getServiceImpls().get(IFloodlightProviderService.class);
fmc.addService(IFloodlightProviderService.class, controller); fmc.addService(IFloodlightProviderService.class, controller);
modSet.add(cm);
MemoryStorageSource memstorage = new MemoryStorageSource(); MemoryStorageSource memstorage = new MemoryStorageSource();
fmc.addService(IStorageSourceService.class, memstorage); fmc.addService(IStorageSourceService.class, memstorage);
modSet.add(memstorage);
RestApiServer restApi = new RestApiServer(); RestApiServer restApi = new RestApiServer();
fmc.addService(IRestApiService.class, restApi); fmc.addService(IRestApiService.class, restApi);
modSet.add(restApi);
CounterStore cs = new CounterStore(); CounterStore cs = new CounterStore();
fmc.addService(ICounterStoreService.class, cs); fmc.addService(ICounterStoreService.class, cs);
modSet.add(cs);
PktInProcessingTime ppt = new PktInProcessingTime(); PktInProcessingTime ppt = new PktInProcessingTime();
fmc.addService(IPktInProcessingTimeService.class, ppt); fmc.addService(IPktInProcessingTimeService.class, ppt);
modSet.add(ppt);
fmc.createConfigMaps(modSet);
ppt.init(fmc); ppt.init(fmc);
restApi.init(fmc); restApi.init(fmc);
memstorage.init(fmc); memstorage.init(fmc);
......
...@@ -19,7 +19,9 @@ package net.floodlightcontroller.devicemanager.internal; ...@@ -19,7 +19,9 @@ package net.floodlightcontroller.devicemanager.internal;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock; import static org.easymock.EasyMock.createNiceMock;
...@@ -31,6 +33,7 @@ import static org.easymock.EasyMock.verify; ...@@ -31,6 +33,7 @@ import static org.easymock.EasyMock.verify;
import net.floodlightcontroller.core.IFloodlightProviderService; import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockFloodlightProvider;
import net.floodlightcontroller.devicemanager.Device; import net.floodlightcontroller.devicemanager.Device;
import net.floodlightcontroller.devicemanager.DeviceAttachmentPoint; import net.floodlightcontroller.devicemanager.DeviceAttachmentPoint;
...@@ -74,14 +77,20 @@ public class DeviceManagerImplTest extends FloodlightTestCase { ...@@ -74,14 +77,20 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
super.setUp(); super.setUp();
FloodlightModuleContext fmc = new FloodlightModuleContext(); FloodlightModuleContext fmc = new FloodlightModuleContext();
Set<IFloodlightModule> modSet = new HashSet<IFloodlightModule>();
RestApiServer restApi = new RestApiServer(); RestApiServer restApi = new RestApiServer();
modSet.add(restApi);
mockFloodlightProvider = getMockFloodlightProvider(); mockFloodlightProvider = getMockFloodlightProvider();
modSet.add(mockFloodlightProvider);
deviceManager = new DeviceManagerImpl(); deviceManager = new DeviceManagerImpl();
modSet.add(deviceManager);
fmc.addService(IDeviceManagerService.class, deviceManager); fmc.addService(IDeviceManagerService.class, deviceManager);
storageSource = new MemoryStorageSource(); storageSource = new MemoryStorageSource();
modSet.add(storageSource);
fmc.addService(IStorageSourceService.class, storageSource); fmc.addService(IStorageSourceService.class, storageSource);
fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider); fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
fmc.addService(IRestApiService.class, restApi); fmc.addService(IRestApiService.class, restApi);
fmc.createConfigMaps(modSet);
restApi.init(fmc); restApi.init(fmc);
storageSource.init(fmc); storageSource.init(fmc);
deviceManager.init(fmc); deviceManager.init(fmc);
......
...@@ -23,7 +23,9 @@ import org.openflow.util.HexString; ...@@ -23,7 +23,9 @@ import org.openflow.util.HexString;
import net.floodlightcontroller.core.FloodlightContext; import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.core.IOFSwitch; import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException; import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.test.MockFloodlightProvider; import net.floodlightcontroller.core.test.MockFloodlightProvider;
import net.floodlightcontroller.test.FloodlightTestCase; import net.floodlightcontroller.test.FloodlightTestCase;
import net.floodlightcontroller.restserver.RestApiServer; import net.floodlightcontroller.restserver.RestApiServer;
...@@ -176,6 +178,9 @@ public class StaticFlowTests extends FloodlightTestCase { ...@@ -176,6 +178,9 @@ public class StaticFlowTests extends FloodlightTestCase {
staticFlowEntryPusher.setStorageSource(storage); staticFlowEntryPusher.setStorageSource(storage);
FloodlightModuleContext fmc = new FloodlightModuleContext();
Set<IFloodlightModule> modSet = new HashSet<IFloodlightModule>();
MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider(); MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
Map<Long, IOFSwitch> switchMap = new HashMap<Long, IOFSwitch>(); Map<Long, IOFSwitch> switchMap = new HashMap<Long, IOFSwitch>();
switchMap.put(dpid, mockSwitch); switchMap.put(dpid, mockSwitch);
...@@ -183,8 +188,10 @@ public class StaticFlowTests extends FloodlightTestCase { ...@@ -183,8 +188,10 @@ public class StaticFlowTests extends FloodlightTestCase {
mockFloodlightProvider.setSwitches(switchMap); mockFloodlightProvider.setSwitches(switchMap);
staticFlowEntryPusher.setFloodlightProvider(mockFloodlightProvider); staticFlowEntryPusher.setFloodlightProvider(mockFloodlightProvider);
RestApiServer restApi = new RestApiServer(); RestApiServer restApi = new RestApiServer();
modSet.add(restApi);
fmc.createConfigMaps(modSet);
try { try {
restApi.init(null); restApi.init(fmc);
} catch (FloodlightModuleException e) { } catch (FloodlightModuleException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -17,7 +17,11 @@ ...@@ -17,7 +17,11 @@
package net.floodlightcontroller.storage.memory.tests; package net.floodlightcontroller.storage.memory.tests;
import java.util.HashSet;
import java.util.Set;
import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.restserver.IRestApiService; import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.restserver.RestApiServer; import net.floodlightcontroller.restserver.RestApiServer;
import net.floodlightcontroller.storage.memory.MemoryStorageSource; import net.floodlightcontroller.storage.memory.MemoryStorageSource;
...@@ -32,6 +36,10 @@ public class MemoryStorageTest extends StorageTest { ...@@ -32,6 +36,10 @@ public class MemoryStorageTest extends StorageTest {
restApi = new RestApiServer(); restApi = new RestApiServer();
FloodlightModuleContext fmc = new FloodlightModuleContext(); FloodlightModuleContext fmc = new FloodlightModuleContext();
fmc.addService(IRestApiService.class, restApi); fmc.addService(IRestApiService.class, restApi);
Set<IFloodlightModule> modSet = new HashSet<IFloodlightModule>();
modSet.add(restApi);
modSet.add(storageSource);
fmc.createConfigMaps(modSet);
restApi.init(fmc); restApi.init(fmc);
storageSource.init(fmc); storageSource.init(fmc);
restApi.startUp(fmc); restApi.startUp(fmc);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment