### Question:
VirtualNetworkFilter implements IFloodlightModule, IVirtualNetworkService, IOFMessageListener { @Override public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) { switch (msg.getType()) { case PACKET_IN: return processPacketIn(sw, (OFPacketIn)msg, cntx); default: break; } log.warn("Received unexpected message {}", msg); return Command.CONTINUE; }  @Override void createNetwork(String guid, String network, Integer gateway); @Override void deleteNetwork(String guid); @Override void addHost(MACAddress mac, String guid, String port); @Override void deleteHost(MACAddress mac, String port); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override Collection <VirtualNetwork> listNetworks();  }### Answer:
@Test public void testForwarding() { testAddHost(); IOFMessageListener listener = getVirtualNetworkListener(); cntx = new FloodlightContext(); IFloodlightProviderService.bcStore.put(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet)mac1ToMac2PacketIntestPacket); Command ret = listener.receive(sw1, mac1ToMac2PacketIn, cntx); assertTrue(ret == Command.CONTINUE); cntx = new FloodlightContext(); IFloodlightProviderService.bcStore.put(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet)mac1ToMac4PacketIntestPacket); ret = listener.receive(sw1, mac1ToMac4PacketIn, cntx); assertTrue(ret == Command.STOP); }
@Test public void testDefaultGateway() { testAddHost(); IOFMessageListener listener = getVirtualNetworkListener(); cntx = new FloodlightContext(); IFloodlightProviderService.bcStore.put(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet)mac1ToGwPacketIntestPacket); deviceService.learnEntity(((Ethernet)mac1ToGwPacketIntestPacket).getDestinationMAC().toLong(), null, IPv4.toIPv4Address(gw1), null, null); Command ret = listener.receive(sw1, mac1ToGwPacketIn, cntx); assertTrue(ret == Command.CONTINUE); }
@Test public void testDhcp() { IOFMessageListener listener = getVirtualNetworkListener(); Ethernet dhcpPacket = PacketFactory.DhcpDiscoveryRequestEthernet(mac1); OFPacketIn dhcpPacketOf = PacketFactory.DhcpDiscoveryRequestOFPacketIn(mac1); cntx = new FloodlightContext(); IFloodlightProviderService.bcStore.put(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, dhcpPacket); Command ret = listener.receive(sw1, dhcpPacketOf, cntx); assertTrue(ret == Command.CONTINUE); }