@Test public void testStaticHost() throws UnknownHostException { String ip; assertNotNull(this.hosttracker); // create one node and two node connectors Node node1 = NodeCreator.createOFNode(1L); NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1); NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1); // test addStaticHost(), store into inactive host DB Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, "0"); Assert.assertTrue(st.isSuccess()); st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", nc1_2, "0"); Assert.assertTrue(st.isSuccess()); // check inactive DB Iterator<HostNodeConnector> hnci = this.hosttracker.getInactiveStaticHosts().iterator(); while (hnci.hasNext()) { ip = hnci.next().getNetworkAddressAsString(); Assert.assertTrue(ip.equals("192.168.0.8") || ip.equals("192.168.0.13")); } // check active host DB hnci = this.hosttracker.getActiveStaticHosts().iterator(); Assert.assertFalse(hnci.hasNext()); // test removeStaticHost() st = this.hosttracker.removeStaticHost("192.168.0.8"); Assert.assertTrue(st.isSuccess()); hnci = this.hosttracker.getInactiveStaticHosts().iterator(); while (hnci.hasNext()) { ip = hnci.next().getNetworkAddressAsString(); Assert.assertTrue(ip.equals("192.168.0.13")); } }
public Status validateMeter(Meter meter) { String meterName; Status returnStatus = null; if (null != meter) { meterName = meter.getMeterName(); if (!FRMUtil.isNameValid(meterName)) { logger.error("Meter Name is invalid %s" + meterName); returnStatus = new Status(StatusCode.BADREQUEST, "Meter Name is invalid"); return returnStatus; } for (int i = 0; i < meter.getMeterBandHeaders().getMeterBandHeader().size(); i++) { if (null != meter.getFlags() && !meter.getFlags().isMeterBurst()) { if (0 < meter.getMeterBandHeaders().getMeterBandHeader().get(i).getBurstSize()) { logger.error("Burst size should only be associated when Burst FLAG is set"); returnStatus = new Status( StatusCode.BADREQUEST, "Burst size should only be associated when Burst FLAG is set"); break; } } } if (null != returnStatus && !returnStatus.isSuccess()) { return returnStatus; } else if (null != meter.getMeterBandHeaders()) { BandType setBandType = null; DscpRemark dscpRemark = null; for (int i = 0; i < meter.getMeterBandHeaders().getMeterBandHeader().size(); i++) { setBandType = meter.getMeterBandHeaders().getMeterBandHeader().get(i).getBandType(); if (setBandType instanceof DscpRemark) { dscpRemark = (DscpRemark) setBandType; if (0 > dscpRemark.getRate()) {} } else if (setBandType instanceof Drop) { if (0 < dscpRemark.getPercLevel()) { logger.error("Number of drop Precedence level"); } } else if (setBandType instanceof Experimenter) { } } } } return new Status(StatusCode.SUCCESS); }