@Test
public void testDeviceIPV4AddrChanged() {

	
	reset(topology);
	expect(topology.getOpenflowDomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes();
	expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
	expect(topology.isAttachmentPointPort(DatapathId.of(2L), OFPort.of(1))).andReturn(true).anyTimes();
	replay(topology);
	int[] cidr = new int[2];
	ACLRule rule1;
	IResultSet resultSet;
	Iterator<IResultSet> it;
	Map<String, Object> row;

	// a new AP[dpid:00:00:00:00:00:00:00:01 port:1] appears
	deviceManager.learnEntity(MacAddress.of("00:00:00:00:00:01"),
			VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1), OFPort.of(1));
	
	// rule1 indicates host(10.0.0.0/28) can not access TCP port 80 in host(10.0.0.254/32)
	rule1 = new ACLRule();
	rule1.setNw_src("10.0.0.0/28");
	cidr = IPAddressUtil.parseCIDR("10.0.0.0/28");
	rule1.setNw_src_prefix(cidr[0]);
	rule1.setNw_src_maskbits(cidr[1]);
	rule1.setNw_dst("10.0.0.254/32");
	cidr = IPAddressUtil.parseCIDR("10.0.0.254/32");
	rule1.setNw_dst_prefix(cidr[0]);
	rule1.setNw_dst_maskbits(cidr[1]);
	rule1.setNw_proto(6);
	rule1.setTp_dst(80);
	rule1.setAction(Action.DENY);
	assertEquals(acl.addRule(rule1), true);
	assertEquals(acl.getRules().size(), 1);
	resultSet = storageService.getRow(
			StaticFlowEntryPusher.TABLE_NAME, "ACLRule_1_00:00:00:00:00:00:00:01");
	it = resultSet.iterator();
	assertEquals(it.hasNext(), false);
	
	// a new AP[dpid:00:00:00:00:00:00:00:01 port:1 ip:10.0.0.1] appears
	deviceManager.learnEntity(MacAddress.of("00:00:00:00:00:01"),
			VlanVid.ZERO, IPv4Address.of("10.0.0.1"), IPv6Address.NONE, DatapathId.of(1), OFPort.of(1));
	
	resultSet = storageService.getRow(
			StaticFlowEntryPusher.TABLE_NAME, "ACLRule_1_00:00:00:00:00:00:00:01");
	it = resultSet.iterator();
	while(it.hasNext()){
		row = it.next().getRow();
		assertEquals(row.get("switch").toString(),"00:00:00:00:00:00:00:01");
		assertEquals(row.get("priority").toString(),"30000");
		assertEquals(row.get("eth_type").toString(),"2048");
		assertEquals(row.get("ipv4_src").toString(),"10.0.0.0/28");
		assertEquals(row.get("ipv4_dst").toString(),"10.0.0.254/32");
		assertEquals(row.get("ip_proto").toString(),"6");
		assertEquals(row.get("tp_dst").toString(),"80");
		assertEquals(row.get("actions"), null);
	}
}