@Test public void testParseComputeQuotaResponse() { Quota results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseComputeQuotaResponse(COMPUTEQUOTARESPONSE); assertEquals(20, results.getCpu()); assertEquals(51200, results.getMemory()); assertEquals(10, results.getNumVms()); results = parser.parseComputeQuotaResponse(COMPUTEQUOTAMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }
public Quota parseComputeQuotaResponse(String response) throws OCCIException { Element vcpu, ram, servers; Quota ret = new Quota(); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing compute quota response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" vcpu = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" ram = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" servers = (Element) xpath.selectSingleNode(xmldoc); if (vcpu != null && ram != null && servers!= null) { ret.setCpu(Integer.parseInt(vcpu.getValue())); ret.setMemory(Integer.parseInt(ram.getValue())); ret.setNumVms(Integer.parseInt(servers.getValue())); } 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] Compute quota response parsed..."); return ret; }
OpenStackParser { public Quota parseComputeQuotaResponse(String response) throws OCCIException { Element vcpu, ram, servers; Quota ret = new Quota(); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing compute quota response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" vcpu = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" ram = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" servers = (Element) xpath.selectSingleNode(xmldoc); if (vcpu != null && ram != null && servers!= null) { ret.setCpu(Integer.parseInt(vcpu.getValue())); ret.setMemory(Integer.parseInt(ram.getValue())); ret.setNumVms(Integer.parseInt(servers.getValue())); } 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] Compute quota response parsed..."); return ret; } }
OpenStackParser { public Quota parseComputeQuotaResponse(String response) throws OCCIException { Element vcpu, ram, servers; Quota ret = new Quota(); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing compute quota response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" vcpu = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" ram = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" servers = (Element) xpath.selectSingleNode(xmldoc); if (vcpu != null && ram != null && servers!= null) { ret.setCpu(Integer.parseInt(vcpu.getValue())); ret.setMemory(Integer.parseInt(ram.getValue())); ret.setNumVms(Integer.parseInt(servers.getValue())); } 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] Compute quota response parsed..."); return ret; }  }
OpenStackParser { public Quota parseComputeQuotaResponse(String response) throws OCCIException { Element vcpu, ram, servers; Quota ret = new Quota(); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing compute quota response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" vcpu = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" ram = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" servers = (Element) xpath.selectSingleNode(xmldoc); if (vcpu != null && ram != null && servers!= null) { ret.setCpu(Integer.parseInt(vcpu.getValue())); ret.setMemory(Integer.parseInt(ram.getValue())); ret.setNumVms(Integer.parseInt(servers.getValue())); } 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] Compute quota 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 Quota parseComputeQuotaResponse(String response) throws OCCIException { Element vcpu, ram, servers; Quota ret = new Quota(); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing compute quota response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" vcpu = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" ram = (Element) xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" servers = (Element) xpath.selectSingleNode(xmldoc); if (vcpu != null && ram != null && servers!= null) { ret.setCpu(Integer.parseInt(vcpu.getValue())); ret.setMemory(Integer.parseInt(ram.getValue())); ret.setNumVms(Integer.parseInt(servers.getValue())); } 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] Compute quota 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; }