@Test public void should_parse_all_possible_elements_and_attributes() throws Exception { SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); SAXParser saxParser = saxParserFactory.newSAXParser(); bsp = new BundleSaxHandler(); InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("bundle-loading/xml/xml-strategy/bundle-full.xml"); saxParser.parse(is, bsp); BundleStorageUnit bsu = bsp.getBsu(); assertThat(bsu.getName()).isEqualTo("bundle-full"); assertThat(bsu.getDependencies()).hasSize(1); assertThat(bsu.getDependencies()).contains("other-bundle"); assertThat(bsu.getAssetStorageUnits()).hasSize(2); assertThat(bsu.getAssetStorageUnits()).extracting("name").contains("asset1", "asset2"); assertThat(bsu.getAssetStorageUnits()).extracting("version").contains("1.0.0", "2.0.0"); assertThat(bsu.getAssetStorageUnits()).extracting("type").contains(AssetType.js); assertThat(bsu.getAssetStorageUnits()).extracting("locations").hasSize(2); }
public BundleStorageUnit getBsu() { return bsu; }
BundleSaxHandler extends DefaultHandler { public BundleStorageUnit getBsu() { return bsu; } }
BundleSaxHandler extends DefaultHandler { public BundleStorageUnit getBsu() { return bsu; } BundleSaxHandler(); }
BundleSaxHandler extends DefaultHandler { public BundleStorageUnit getBsu() { return bsu; } BundleSaxHandler(); @Override void startElement(String uri, String s1, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); @Override void warning(SAXParseException e); @Override void error(SAXParseException e); @Override void fatalError(SAXParseException e); BundleStorageUnit getBsu(); }
BundleSaxHandler extends DefaultHandler { public BundleStorageUnit getBsu() { return bsu; } BundleSaxHandler(); @Override void startElement(String uri, String s1, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); @Override void warning(SAXParseException e); @Override void error(SAXParseException e); @Override void fatalError(SAXParseException e); BundleStorageUnit getBsu(); static final String EL_BUNDLE; static final String EL_NAME; static final String EL_ASSET; static final String EL_DEPENDENCY; static final String EL_LOCATIONS; static final String EL_LOCATION; static final String ATTR_NAME; static final String ATTR_VERSION; static final String ATTR_TYPE; static final String ATTR_CONDITION; static final String ATTR_KEY; static final String JAXP_SCHEMA_LANGUAGE; static final String W3C_XML_SCHEMA; static final String JAXP_SCHEMA_SOURCE; }