### Question:
FeatureParser { public ParsedFeature parse(Uri parent, String xml) throws GadgetException { Element doc; try { doc = XmlUtil.parse(xml); } catch (XmlException e) { throw new GadgetException(GadgetException.Code.MALFORMED_XML_DOCUMENT, e); } String name = null; List<String> deps = Lists.newArrayList(); List<ParsedFeature.Bundle> bundles = Lists.newArrayList(); boolean supportDefer = false; NodeList children = doc.getChildNodes(); for (int i = 0, j = children.getLength(); i < j; ++i) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element)child; if (element.getTagName().equals("name")) { name = element.getTextContent(); } else if (element.getTagName().equals("dependency")) { deps.add(element.getTextContent()); } else { String type = element.getTagName().toLowerCase(); List<ParsedFeature.Resource> resources = Lists.newArrayList(); NodeList resourceKids = element.getElementsByTagName("script"); for (int x = 0, y = resourceKids.getLength(); x < y; ++x) { Element resourceChild = (Element)resourceKids.item(x); String src = resourceChild.getAttribute("src"); String content = resourceChild.getTextContent(); Map<String, String> attribs = getAttribs(resourceChild); Uri source = null; if (src != null && src.length() > 0) { if (!"false".equals(attribs.get("inline"))) { source = parent.resolve(FeatureRegistry.getComponentUri(src)); } else { source = Uri.parse(src); } } resources.add(new ParsedFeature.Resource( source, src != null && src.length() != 0 ? null : content, getAttribs(resourceChild))); } List<ApiDirective> apiDirectives = Lists.newArrayList(); NodeList apiKids = element.getElementsByTagName("api"); for (int x = 0, y = apiKids.getLength(); x < y; ++x) { Element apiChild = (Element)apiKids.item(x); supportDefer = "true".equalsIgnoreCase(apiChild.getAttribute("supportDefer")); NodeList apiElems = apiChild.getChildNodes(); for (int a = 0, b = apiElems.getLength(); a < b; ++a) { Node apiElemNode = apiElems.item(a); if (apiElemNode.getNodeType() == Node.ELEMENT_NODE) { Element apiElem = (Element)apiElemNode; boolean isImport = "uses".equals(apiElem.getNodeName()); boolean isExport = "exports".equals(apiElem.getNodeName()); if (isImport || isExport) { apiDirectives.add(new ApiDirective( apiElem.getAttribute("type"), apiElem.getTextContent(), isImport)); } } } } bundles.add(new ParsedFeature.Bundle(name, type, getAttribs(element), resources, apiDirectives, supportDefer)); } } } return new ParsedFeature(name, deps, bundles); }  ParsedFeature parse(Uri parent, String xml);  }### Answer:
@Test(expected=GadgetException.class) public void parseInvalidXml() throws GadgetException { new FeatureParser().parse(Uri.parse(""), "This is not valid XML."); }