Search in sources :

Example 71 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.

the class DeviceTest method sharedDatastoreTest.

@Test
public void sharedDatastoreTest() throws InterruptedException, ExecutionException, TimeoutException, SAXException, IOException, URISyntaxException {
    final SimpleNetconfClientSessionListener sessionListener = SESSION_LISTENERS.get(0);
    final NetconfMessage createToasterResponse = sendRequestToDevice(CREATE_TOASTER_REQUEST_XML, sessionListener);
    assertTrue(containsOkElement(createToasterResponse));
    for (SimpleNetconfClientSessionListener listener : SESSION_LISTENERS) {
        final NetconfMessage toasterData = sendRequestToDevice(GET_TOASTER_DATA_REQUEST_XML, listener);
        final String toasterDarknessFactor = toasterData.getDocument().getDocumentElement().getElementsByTagName("darknessFactor").item(0).getTextContent();
        Assertions.assertEquals(EXPECTED_DARKNESS_FACTOR, toasterDarknessFactor);
    }
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SimpleNetconfClientSessionListener(org.opendaylight.netconf.client.SimpleNetconfClientSessionListener) Test(org.junit.jupiter.api.Test)

Example 72 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.

the class DeviceTest method getSchemaTest.

@Test
public void getSchemaTest() throws IOException, URISyntaxException, SAXException, InterruptedException, ExecutionException, TimeoutException {
    final SimpleNetconfClientSessionListener sessionListener = new SimpleNetconfClientSessionListener();
    try (NetconfClientSession session = dispatcher.createClient(createSHHConfig(sessionListener)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
        final NetconfMessage schemaResponse = sendRequestToDevice(GET_SCHEMAS_REQUEST_XML, sessionListener);
        final NodeList schema = schemaResponse.getDocument().getDocumentElement().getElementsByTagName("schema");
        assertTrue(schema.getLength() > 0);
        boolean networkTopologySchemaContained = false;
        for (int i = 0; i < schema.getLength(); i++) {
            if (schema.item(i).getNodeType() == Node.ELEMENT_NODE) {
                final Element item = (Element) schema.item(i);
                final String schemaName = item.getElementsByTagName("identifier").item(0).getTextContent();
                final String schemaNameSpace = item.getElementsByTagName("namespace").item(0).getTextContent();
                if ("network-topology".equals(schemaName) && "urn:TBD:params:xml:ns:yang:network-topology".equals(schemaNameSpace)) {
                    networkTopologySchemaContained = true;
                }
            }
        }
        assertTrue(networkTopologySchemaContained);
    }
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SimpleNetconfClientSessionListener(org.opendaylight.netconf.client.SimpleNetconfClientSessionListener) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) NetconfClientSession(org.opendaylight.netconf.client.NetconfClientSession) Test(org.junit.jupiter.api.Test)

Example 73 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.

the class DeviceTest method deviceConfigOperationsTest.

@Test
public void deviceConfigOperationsTest() throws InterruptedException, ExecutionException, IOException, TimeoutException, URISyntaxException, SAXException {
    final SimpleNetconfClientSessionListener sessionListener = new SimpleNetconfClientSessionListener();
    try (NetconfClientSession session = dispatcher.createClient(createSHHConfig(sessionListener)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
        final NetconfMessage createTopoResponse = sendRequestToDevice(CREATE_TOPOLOGY_CONFIG_REQUEST_XML, sessionListener);
        assertTrue(containsOkElement(createTopoResponse));
        final NetconfMessage mergeTopoResponse = sendRequestToDevice(MERGE_TOPOLOGY_CONFIG_REQUEST_XML, sessionListener);
        assertTrue(containsOkElement(mergeTopoResponse));
        final NetconfMessage getConfigDataResponse = sendRequestToDevice(GET_CONFIG_REQUEST_XML, sessionListener);
        final NodeList topologies = getConfigDataResponse.getDocument().getElementsByTagName("topology");
        assertEquals(topologies.getLength(), 2);
        if (getTopologyID(topologies.item(0)).equals("test-config-topology")) {
            assertEquals(getTopologyID(topologies.item(0)), "test-config-topology");
            assertEquals(getTopologyID(topologies.item(1)), "test-config-topology-merge");
        } else {
            assertEquals(getTopologyID(topologies.item(1)), "test-config-topology");
            assertEquals(getTopologyID(topologies.item(0)), "test-config-topology-merge");
        }
        final NodeList nodes = getConfigDataResponse.getDocument().getElementsByTagName("node");
        assertEquals(nodes.getLength(), 1);
        final NetconfMessage deleteTopologyResponse = sendRequestToDevice(DELETE_TOPOLOGY_CONFIG_REQUEST_XML, sessionListener);
        assertTrue(containsOkElement(deleteTopologyResponse));
        final NetconfMessage getConfigDataResponseAfterDelete = sendRequestToDevice(GET_CONFIG_REQUEST_XML, sessionListener);
        final NodeList topologiesAfterDelete = getConfigDataResponseAfterDelete.getDocument().getElementsByTagName("topology");
        assertEquals(topologiesAfterDelete.getLength(), 1);
    }
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SimpleNetconfClientSessionListener(org.opendaylight.netconf.client.SimpleNetconfClientSessionListener) NodeList(org.w3c.dom.NodeList) NetconfClientSession(org.opendaylight.netconf.client.NetconfClientSession) Test(org.junit.jupiter.api.Test)

Example 74 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.

the class ActionDeviceTest method getSchemaTest.

@Test
public void getSchemaTest() throws IOException, URISyntaxException, SAXException, InterruptedException, ExecutionException, TimeoutException {
    final SimpleNetconfClientSessionListener sessionListener = new SimpleNetconfClientSessionListener();
    try (NetconfClientSession session = dispatcher.createClient(createSHHConfig(sessionListener)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
        final NetconfMessage schemaResponse = sentRequesttoDevice(sessionListener, "get_schemas_request.xml");
        final NodeList schema = schemaResponse.getDocument().getDocumentElement().getElementsByTagName("schema");
        assertTrue(schema.getLength() > 0);
        boolean exampleDataCenterSchemaContained = false;
        for (int i = 0; i < schema.getLength(); i++) {
            if (schema.item(i).getNodeType() == Node.ELEMENT_NODE) {
                final Element item = (Element) schema.item(i);
                final String schemaName = item.getElementsByTagName("identifier").item(0).getTextContent();
                final String schemaNameSpace = item.getElementsByTagName("namespace").item(0).getTextContent();
                if ("example-data-center".equals(schemaName) && "urn:example:data-center".equals(schemaNameSpace)) {
                    exampleDataCenterSchemaContained = true;
                }
            }
        }
        assertTrue(exampleDataCenterSchemaContained);
    }
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SimpleNetconfClientSessionListener(org.opendaylight.netconf.client.SimpleNetconfClientSessionListener) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) NetconfClientSession(org.opendaylight.netconf.client.NetconfClientSession) Test(org.junit.jupiter.api.Test)

Example 75 with NetconfMessage

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

the class NetconfClientSessionNegotiatorFactory method getSessionNegotiator.

@Override
public NetconfClientSessionNegotiator getSessionNegotiator(final NetconfSessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory, final Channel channel, final Promise<NetconfClientSession> promise) {
    NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
    NetconfHelloMessage helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader);
    NetconfClientSessionPreferences proposal = new NetconfClientSessionPreferences(helloMessage, startExiMessage);
    return new NetconfClientSessionNegotiator(proposal, promise, channel, timer, sessionListenerFactory.getSessionListener(), connectionTimeoutMillis);
}
Also used : NetconfClientSessionPreferences(org.opendaylight.netconf.api.NetconfClientSessionPreferences) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) NetconfHelloMessage(org.opendaylight.netconf.api.messages.NetconfHelloMessage)

Aggregations

NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)125 Test (org.junit.Test)72 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)40 Document (org.w3c.dom.Document)28 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)23 QName (org.opendaylight.yangtools.yang.common.QName)17 DOMSourceAnyxmlNode (org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode)15 Test (org.junit.jupiter.api.Test)13 SimpleNetconfClientSessionListener (org.opendaylight.netconf.client.SimpleNetconfClientSessionListener)13 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)13 Node (org.w3c.dom.Node)13 NetconfClientSession (org.opendaylight.netconf.client.NetconfClientSession)12 ArrayList (java.util.ArrayList)11 Element (org.w3c.dom.Element)11 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)10 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)9 ChannelFuture (io.netty.channel.ChannelFuture)8 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)8