@Test
public void testOnIpv4PacketReceived() throws InterruptedException, ExecutionException {

	Ipv4PacketReceived packetReceived = mock(Ipv4PacketReceived.class);
	List<PacketChain> packetChains = new ArrayList<PacketChain>();
	PacketChain packetChain1 = mock(PacketChain.class);
	PacketChain packetChain2 = mock(PacketChain.class);
	PacketChain packetChain3 = mock(PacketChain.class);
	RawPacket rawPacket = mock(RawPacket.class);
	EthernetPacket ethernetPacket = mock(EthernetPacket.class);
	Ipv4Packet ipv4Packet = mock(Ipv4Packet.class);
	packetChains.add(packetChain1);
	packetChains.add(packetChain2);
	packetChains.add(packetChain3);
	List<Header8021q> headers = mock(ArrayList.class);
	byte[] payload = new byte[100];
	for (byte index = 1; payload.length <= index; index++) {
		payload[index] = index;
	}
	NodeConnectorRef ncRef = mock(NodeConnectorRef.class);
	ReadOnlyTransaction readTx = mock(ReadOnlyTransaction.class);
	CheckedFuture<Optional<NodeConnector>, ReadFailedException> checkedNodes = mock(CheckedFuture.class);
	Optional<NodeConnector> nc = mock(Optional.class);
	NodeConnector nodeConnector = mock(NodeConnector.class);
	NodeConnectorId ncId = new NodeConnectorId("openflow:20:17");
	Ipv4Address destIpAddress = new Ipv4Address("192.168.10.1");
	BgpPeer bgpPeer = mock(BgpPeer.class);
	Future<RpcResult<Void>> future = mock(Future.class);
	when(packetReceived.getPacketChain()).thenReturn(packetChains);
	when(packetChain1.getPacket()).thenReturn(rawPacket);
	when(packetChain2.getPacket()).thenReturn(ethernetPacket);
	when(packetChain3.getPacket()).thenReturn(ipv4Packet);
	when(ipv4Packet.getProtocol()).thenReturn(KnownIpProtocols.Icmp);
	when(ethernetPacket.getHeader8021q()).thenReturn(headers);
	when(packetReceived.getPayload()).thenReturn(payload);
	when(rawPacket.getIngress()).thenReturn(ncRef);
	when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx);
	when(readTx.read(any(LogicalDatastoreType.class),
			(InstanceIdentifier<NodeConnector>) any(InstanceIdentifier.class))).thenReturn(checkedNodes);
	when(checkedNodes.get()).thenReturn(nc);
	when(nc.isPresent()).thenReturn(Boolean.valueOf(true));
	when(nc.get()).thenReturn(nodeConnector);
	when(nodeConnector.getId()).thenReturn(ncId);
	when(ipv4Packet.getDestinationIpv4()).thenReturn(destIpAddress);
	when(routingConfigService.getBgpPeerByIpAddress(any(IpAddress.class))).thenReturn(bgpPeer);
	when(bgpPeer.getPeerDpId()).thenReturn(NodeId.getDefaultInstance("21"));
	when(bgpPeer.getPeerPort()).thenReturn(Long.valueOf(18));
	when(packetService.transmitPacket(any(TransmitPacketInput.class))).thenReturn(future);
	connectivityManager.onIpv4PacketReceived(packetReceived);
	verify(packetService, times(1)).transmitPacket(any(TransmitPacketInput.class));
}