+ Document configRunning = getConfigRunning();
+ String asString = XmlUtil.toString(configRunning);
+ assertThat(asString, containsString("test-identity2"));
+ assertThat(asString, containsString("test-identity1"));
+ assertEquals(2, countSubstringOccurence(asString, "</identities>"));
+
+ edit("netconfMessages/editConfig_identities_inner_replace.xml");
+ commit();
+ configRunning = getConfigRunning();
+ asString = XmlUtil.toString(configRunning);
+ // test-identity1 was removed by replace
+ assertThat(asString, not(containsString("test-identity2")));
+ // now only 1 identities entry is present
+ assertEquals(1, countSubstringOccurence(asString, "</identities>"));
+ }
+
+ private int countSubstringOccurence(final String string, final String substring) {
+ final Matcher matches = Pattern.compile(substring).matcher(string);
+ int count = 0;
+ while (matches.find()) {
+ count++;
+ }
+ return count;