@Test public void testParseVirtualInterfacesResponse() { List<Compute.Nic> results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseVirtualInterfacesResponse(VIRTUALINTERFACESRESPONSE); assertEquals(1, results.size()); assertEquals("a26887c6-c47b-4654-abb5-dfadf7d3f803", results.get(0).getNetwork().getHref()); assertEquals("fa:16:3e:7d:31:9a", results.get(0).getMac()); results = parser.parseVirtualInterfacesResponse( VIRTUALINTERFACESMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }
public List<Nic> parseVirtualInterfacesResponse (String response) throws OCCIException { List<Nic> ret = null; Nic nic; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing virtual interfaces response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List macList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List networkList = xpath.selectNodes(xmldoc); if (macList.size() > 0 && networkList.size() > 0) { ret = new ArrayList<Nic>(); for (int i = 0 ; i < macList.size() ; i++) { nic = new Nic(); link = new Link(); link.setHref(((Attribute)networkList.get(i)).getValue()); nic.setMac(((Attribute)macList.get(i)).getValue()); nic.setNetwork(link); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Virtual interfaces response parsed..."); return ret; }
OpenStackParser { public List<Nic> parseVirtualInterfacesResponse (String response) throws OCCIException { List<Nic> ret = null; Nic nic; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing virtual interfaces response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List macList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List networkList = xpath.selectNodes(xmldoc); if (macList.size() > 0 && networkList.size() > 0) { ret = new ArrayList<Nic>(); for (int i = 0 ; i < macList.size() ; i++) { nic = new Nic(); link = new Link(); link.setHref(((Attribute)networkList.get(i)).getValue()); nic.setMac(((Attribute)macList.get(i)).getValue()); nic.setNetwork(link); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Virtual interfaces response parsed..."); return ret; } }
OpenStackParser { public List<Nic> parseVirtualInterfacesResponse (String response) throws OCCIException { List<Nic> ret = null; Nic nic; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing virtual interfaces response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List macList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List networkList = xpath.selectNodes(xmldoc); if (macList.size() > 0 && networkList.size() > 0) { ret = new ArrayList<Nic>(); for (int i = 0 ; i < macList.size() ; i++) { nic = new Nic(); link = new Link(); link.setHref(((Attribute)networkList.get(i)).getValue()); nic.setMac(((Attribute)macList.get(i)).getValue()); nic.setNetwork(link); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Virtual interfaces response parsed..."); return ret; }  }
OpenStackParser { public List<Nic> parseVirtualInterfacesResponse (String response) throws OCCIException { List<Nic> ret = null; Nic nic; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing virtual interfaces response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List macList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List networkList = xpath.selectNodes(xmldoc); if (macList.size() > 0 && networkList.size() > 0) { ret = new ArrayList<Nic>(); for (int i = 0 ; i < macList.size() ; i++) { nic = new Nic(); link = new Link(); link.setHref(((Attribute)networkList.get(i)).getValue()); nic.setMac(((Attribute)macList.get(i)).getValue()); nic.setNetwork(link); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Virtual interfaces response parsed..."); return ret; }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); }
OpenStackParser { public List<Nic> parseVirtualInterfacesResponse (String response) throws OCCIException { List<Nic> ret = null; Nic nic; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing virtual interfaces response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List macList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", COMPUTENAMESPACE); xpath.addNamespace("OS-EXT-VIF-NET", VIFNAMESPACE); List networkList = xpath.selectNodes(xmldoc); if (macList.size() > 0 && networkList.size() > 0) { ret = new ArrayList<Nic>(); for (int i = 0 ; i < macList.size() ; i++) { nic = new Nic(); link = new Link(); link.setHref(((Attribute)networkList.get(i)).getValue()); nic.setMac(((Attribute)macList.get(i)).getValue()); nic.setNetwork(link); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Virtual interfaces response parsed..."); return ret; }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); static final String KEYSTONENAMESPACE; static final String QUANTUMNAMESPACE; static final String PROVIDERNAMESPACE; static final String ROUTERNAMESPACE; static final String XSINAMESPACE; static final String VOLUMENAMESPACE; static final String ATOMNAMESPACE; static final String COMPUTENAMESPACE; static final String VIFNAMESPACE; static final String COMMONNAMESPACE; static final String BLOCKNAMESPACE; static final String OSVOLHOSTATTRNAMESPACE; static final String OSVOLIMAGEMETANAMESPACE; static final String OSVOLTENANTATTRNAMESPACE; }