Search in sources :

Example 46 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class CopyConfigTest method testConfigMissing.

@Test
public void testConfigMissing() {
    final DocumentedException e = assertThrows(DocumentedException.class, () -> copyConfig("messages/mapping/copyConfigs/copyConfig_no_config.xml"));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.MISSING_ELEMENT);
    assertEquals(e.getErrorType(), ErrorType.PROTOCOL);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 47 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class CopyConfigTest method testSourceMissing.

@Test
public void testSourceMissing() {
    final DocumentedException e = assertThrows(DocumentedException.class, () -> copyConfig("messages/mapping/copyConfigs/copyConfig_no_source.xml"));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.MISSING_ELEMENT);
    assertEquals(e.getErrorType(), ErrorType.PROTOCOL);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 48 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class CopyConfigTest method testRunning.

@Test
public void testRunning() {
    final DocumentedException e = assertThrows(DocumentedException.class, () -> copyConfig("messages/mapping/copyConfigs/copyConfig_running.xml"));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.OPERATION_NOT_SUPPORTED);
    assertEquals(e.getErrorType(), ErrorType.PROTOCOL);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Example 49 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class CopyConfigTest method testExternalConfigInvalid.

@Test
public void testExternalConfigInvalid() throws Exception {
    // Ask class loader for URI of config file and use it as <url> in <copy-config> RPC:
    final String template = XmlFileLoader.fileToString("messages/mapping/copyConfigs/copyConfig_from_file.xml");
    final URI uri = getClass().getClassLoader().getResource("messages/mapping/copyConfigs/config_file_invalid.xml").toURI();
    final String copyConfig = template.replaceFirst("URL", uri.toString());
    final Document request = XmlUtil.readXmlToDocument(copyConfig);
    final DocumentedException e = assertThrows(DocumentedException.class, () -> copyConfig(request));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.OPERATION_FAILED);
    assertEquals(e.getErrorType(), ErrorType.APPLICATION);
    assertTrue(e.getCause() instanceof SAXException);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Document(org.w3c.dom.Document) URI(java.net.URI) SAXException(org.xml.sax.SAXException) Test(org.junit.Test)

Example 50 with DocumentedException

use of org.opendaylight.netconf.api.DocumentedException in project netconf by opendaylight.

the class CopyConfigTest method testUnsupportedTargetUrlProtocol.

@Test
public void testUnsupportedTargetUrlProtocol() {
    final DocumentedException e = assertThrows(DocumentedException.class, () -> copyConfig("messages/mapping/copyConfigs/copyConfig_to_unsupported_url_protocol.xml"));
    assertEquals(e.getErrorSeverity(), ErrorSeverity.ERROR);
    assertEquals(e.getErrorTag(), ErrorTag.OPERATION_NOT_SUPPORTED);
    assertEquals(e.getErrorType(), ErrorType.PROTOCOL);
}
Also used : DocumentedException(org.opendaylight.netconf.api.DocumentedException) Test(org.junit.Test)

Aggregations

DocumentedException (org.opendaylight.netconf.api.DocumentedException)54 Test (org.junit.Test)25 XmlElement (org.opendaylight.netconf.api.xml.XmlElement)14 Document (org.w3c.dom.Document)9 NetconfDocumentedException (org.opendaylight.netconf.api.NetconfDocumentedException)6 ExecutionException (java.util.concurrent.ExecutionException)5 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)5 Element (org.w3c.dom.Element)5 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 List (java.util.List)3 XMLNamespace (org.opendaylight.yangtools.yang.common.XMLNamespace)3 XmlNodeConverter (io.lighty.codecs.util.XmlNodeConverter)2 DeserializationException (io.lighty.codecs.util.exception.DeserializationException)2 Response (io.lighty.netconf.device.response.Response)2 ResponseData (io.lighty.netconf.device.response.ResponseData)2 Reader (java.io.Reader)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2