Esempio n. 1
0
 @Test
 public void testValidation() throws Exception {
   final XmlElement xml =
       XmlElement.fromString(
           "<validate xmlns=\""
               + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0
               + "\"><source><candidate/></source></validate>");
   final Element okElement = XmlUtil.readXmlToElement("<ok/>");
   final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
   doNothing().when(facade).validateConfiguration();
   final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
   Element ok = validate.handleWithNoSubsequentOperations(XmlUtil.newDocument(), xml);
   assertEquals(XmlUtil.toString(okElement), XmlUtil.toString(ok));
 }
  @Test
  public void testKeyOrder() throws Exception {
    verifyResponse(
        edit("messages/mapping/editConfigs/editConfig_merge_multiple_keys_1.xml"), RPC_REPLY_OK);
    verifyResponse(commit(), RPC_REPLY_OK);
    final Document configRunning = getConfigRunning();
    final String responseAsString = XmlUtil.toString(configRunning);
    verifyResponse(
        configRunning,
        XmlFileLoader.xmlFileToDocument(
            "messages/mapping/editConfigs/editConfig_merge_multiple_keys_1_control.xml"));

    final int key3 = responseAsString.indexOf("key3");
    final int key1 = responseAsString.indexOf("key1");
    final int key2 = responseAsString.indexOf("key2");

    assertTrue(
        String.format(
            "Key ordering invalid, should be key3(%d) < key1(%d) < key2(%d)", key3, key1, key2),
        key3 < key1 && key1 < key2);

    deleteDatastore();
  }
 public CapabilityStrippingConfigSnapshotHolder(Element snapshot, Set<String> capabilities) {
   final XmlElement configElement = XmlElement.fromDomElement(snapshot);
   configSnapshot = XmlUtil.toString(configElement.getDomElement());
   stripCapabilitiesResult = stripCapabilities(configElement, capabilities);
 }