WifiConfigStoreParser { public static List<WifiNetwork> parse(InputStream in) throws XmlPullParserException, IOException { List<WifiNetwork> wifiNetworks = new ArrayList<>(); try { XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(in, null); while (parser.next() != XmlPullParser.END_DOCUMENT) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } if (parser.getName().equalsIgnoreCase("NetworkList")) { wifiNetworks.addAll(readNetworkList(parser)); } } return wifiNetworks; } finally { in.close(); } } WifiConfigStoreParser(); static List<WifiNetwork> parse(InputStream in);  }
@Test public void parse() throws XmlPullParserException, IOException { InputStream wifiConfigStoreFileStream = getClass().getClassLoader().getResourceAsStream("test_WifiConfigStore.xml"); List<WifiNetwork> parsedWifiNetworks = WifiConfigStoreParser.parse(wifiConfigStoreFileStream); assertEquals(expectedWifiNetworks.size(), parsedWifiNetworks.size()); for (int i = 0; i < expectedWifiNetworks.size(); i++) { assertEquals(expectedWifiNetworks.get(i), parsedWifiNetworks.get(i)); } }