2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.sal.connect.netconf;
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Matchers.anyCollectionOf;
14 import static org.mockito.Matchers.eq;
15 import static org.mockito.Mockito.after;
16 import static org.mockito.Mockito.doAnswer;
17 import static org.mockito.Mockito.doNothing;
18 import static org.mockito.Mockito.doReturn;
19 import static org.mockito.Mockito.mock;
20 import static org.mockito.Mockito.timeout;
21 import static org.mockito.Mockito.times;
22 import static org.mockito.Mockito.verify;
24 import com.google.common.collect.HashMultimap;
25 import com.google.common.collect.Iterables;
26 import com.google.common.collect.Lists;
27 import com.google.common.collect.Sets;
28 import com.google.common.util.concurrent.Futures;
29 import com.google.common.util.concurrent.SettableFuture;
30 import java.io.IOException;
31 import java.net.InetSocketAddress;
32 import java.util.ArrayList;
33 import java.util.Collection;
34 import java.util.Collections;
35 import java.util.HashMap;
37 import java.util.concurrent.ExecutorService;
38 import java.util.concurrent.Executors;
39 import org.junit.Test;
40 import org.mockito.ArgumentCaptor;
41 import org.mockito.Mockito;
42 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
43 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
44 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
45 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
46 import org.opendaylight.netconf.api.NetconfMessage;
47 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
48 import org.opendaylight.netconf.api.xml.XmlUtil;
49 import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
50 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver;
51 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
52 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
53 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
54 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
55 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
56 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
57 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
59 import org.opendaylight.yangtools.yang.common.QName;
60 import org.opendaylight.yangtools.yang.common.Revision;
61 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
62 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
63 import org.opendaylight.yangtools.yang.model.api.Module;
64 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
65 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
66 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
67 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
68 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
69 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
70 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
71 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
72 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
73 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
74 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
75 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
76 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
77 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
78 import org.xml.sax.SAXException;
80 @SuppressWarnings("checkstyle:IllegalCatch")
81 public class NetconfDeviceTest {
83 private static final NetconfMessage NOTIFICATION;
85 private static final ContainerNode COMPOSITE_NODE;
89 COMPOSITE_NODE = mockClass(ContainerNode.class);
90 } catch (final Exception e) {
91 throw new RuntimeException(e);
94 NOTIFICATION = new NetconfMessage(XmlUtil
95 .readXmlToDocument(NetconfDeviceTest.class.getResourceAsStream("/notification-payload.xml")));
96 } catch (SAXException | IOException e) {
97 throw new ExceptionInInitializerError(e);
101 private static final DOMRpcResult RPC_RESULT = new DefaultDOMRpcResult(COMPOSITE_NODE);
103 public static final String TEST_NAMESPACE = "test:namespace";
104 public static final String TEST_MODULE = "test-module";
105 public static final String TEST_REVISION = "2013-07-22";
106 public static final SourceIdentifier TEST_SID =
107 RevisionSourceIdentifier.create(TEST_MODULE, Revision.of(TEST_REVISION));
108 public static final String TEST_CAPABILITY =
109 TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION;
111 public static final SourceIdentifier TEST_SID2 =
112 RevisionSourceIdentifier.create(TEST_MODULE + "2", Revision.of(TEST_REVISION));
113 public static final String TEST_CAPABILITY2 =
114 TEST_NAMESPACE + "?module=" + TEST_MODULE + "2" + "&revision=" + TEST_REVISION;
116 private static final NetconfDeviceSchemasResolver STATE_SCHEMAS_RESOLVER =
117 (deviceRpc, remoteSessionCapabilities, id) -> NetconfStateSchemas.EMPTY;
120 public void testNetconfDeviceFlawedModelFailedResolution() throws Exception {
121 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
122 final NetconfDeviceCommunicator listener = getListener();
124 final SchemaContextFactory schemaFactory = getSchemaFactory();
125 final SchemaContext schema = getSchema();
126 final SchemaRepository schemaRepository = getSchemaRepository();
128 final SchemaResolutionException schemaResolutionException =
129 new SchemaResolutionException("fail first", TEST_SID, new Throwable("YangTools parser fail"));
130 doAnswer(invocation -> {
131 if (((Collection<?>) invocation.getArguments()[0]).size() == 2) {
132 return Futures.immediateFailedFuture(schemaResolutionException);
134 return Futures.immediateFuture(schema);
136 }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
138 final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id) -> {
139 final Module first = Iterables.getFirst(schema.getModules(), null);
140 final QName qName = QName.create(first.getQNameModule(), first.getName());
141 final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName);
142 final NetconfStateSchemas.RemoteYangSchema source2 =
143 new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2"));
144 return new NetconfStateSchemas(Sets.newHashSet(source1, source2));
147 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
148 .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver);
150 final NetconfDevice device = new NetconfDeviceBuilder()
151 .setReconnectOnSchemasChange(true)
152 .setSchemaResourcesDTO(schemaResourcesDTO)
153 .setGlobalProcessingExecutor(getExecutor())
155 .setSalFacade(facade)
157 // Monitoring supported
158 final NetconfSessionPreferences sessionCaps =
159 getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2));
160 device.onRemoteSessionUp(sessionCaps, listener);
162 Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(
163 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class));
164 Mockito.verify(schemaFactory, times(2)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
168 public void testNetconfDeviceFailFirstSchemaFailSecondEmpty() throws Exception {
169 final ArrayList<String> capList = Lists.newArrayList(TEST_CAPABILITY);
171 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
172 final NetconfDeviceCommunicator listener = getListener();
174 final SchemaContextFactory schemaFactory = getSchemaFactory();
175 final SchemaRepository schemaRepository = getSchemaRepository();
177 // Make fallback attempt to fail due to empty resolved sources
178 final SchemaResolutionException schemaResolutionException
179 = new SchemaResolutionException("fail first",
180 Collections.emptyList(), HashMultimap.create());
181 doReturn(Futures.immediateFailedFuture(schemaResolutionException))
182 .when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
184 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
185 .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, STATE_SCHEMAS_RESOLVER);
186 final NetconfDevice device = new NetconfDeviceBuilder()
187 .setReconnectOnSchemasChange(true)
188 .setSchemaResourcesDTO(schemaResourcesDTO)
189 .setGlobalProcessingExecutor(getExecutor())
191 .setSalFacade(facade)
194 // Monitoring not supported
195 final NetconfSessionPreferences sessionCaps = getSessionCaps(false, capList);
196 device.onRemoteSessionUp(sessionCaps, listener);
198 Mockito.verify(facade, Mockito.timeout(5000)).onDeviceDisconnected();
199 Mockito.verify(listener, Mockito.timeout(5000)).close();
200 Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
204 public void testNetconfDeviceMissingSource() throws Exception {
205 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
206 final NetconfDeviceCommunicator listener = getListener();
207 final SchemaContext schema = getSchema();
209 final SchemaContextFactory schemaFactory = getSchemaFactory();
210 final SchemaRepository schemaRepository = getSchemaRepository();
212 // Make fallback attempt to fail due to empty resolved sources
213 final MissingSchemaSourceException schemaResolutionException =
214 new MissingSchemaSourceException("fail first", TEST_SID);
215 doReturn(Futures.immediateFailedFuture(schemaResolutionException))
216 .when(schemaRepository).getSchemaSource(eq(TEST_SID), eq(YangTextSchemaSource.class));
217 doAnswer(invocation -> {
218 if (((Collection<?>) invocation.getArguments()[0]).size() == 2) {
219 return Futures.immediateFailedFuture(schemaResolutionException);
221 return Futures.immediateFuture(schema);
223 }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
225 final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id) -> {
226 final Module first = Iterables.getFirst(schema.getModules(), null);
227 final QName qName = QName.create(first.getQNameModule(), first.getName());
228 final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName);
229 final NetconfStateSchemas.RemoteYangSchema source2 =
230 new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2"));
231 return new NetconfStateSchemas(Sets.newHashSet(source1, source2));
234 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
235 .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver);
237 final NetconfDevice device = new NetconfDeviceBuilder()
238 .setReconnectOnSchemasChange(true)
239 .setSchemaResourcesDTO(schemaResourcesDTO)
240 .setGlobalProcessingExecutor(getExecutor())
242 .setSalFacade(facade)
244 // Monitoring supported
245 final NetconfSessionPreferences sessionCaps =
246 getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2));
247 device.onRemoteSessionUp(sessionCaps, listener);
249 Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(
250 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class));
251 Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
254 private static SchemaSourceRegistry getSchemaRegistry() {
255 final SchemaSourceRegistry mock = mock(SchemaSourceRegistry.class);
256 final SchemaSourceRegistration<?> mockReg = mock(SchemaSourceRegistration.class);
257 doNothing().when(mockReg).close();
258 doReturn(mockReg).when(mock).registerSchemaSource(
259 any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class),
260 any(PotentialSchemaSource.class));
264 private static SchemaRepository getSchemaRepository() {
265 final SchemaRepository mock = mock(SchemaRepository.class);
266 final SchemaSourceRepresentation mockRep = mock(SchemaSourceRepresentation.class);
267 doReturn(Futures.immediateFuture(mockRep))
268 .when(mock).getSchemaSource(any(SourceIdentifier.class), eq(YangTextSchemaSource.class));
273 public void testNotificationBeforeSchema() throws Exception {
274 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
275 final NetconfDeviceCommunicator listener = getListener();
276 final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
277 final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
278 doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
279 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO =
280 new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
281 schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
282 final NetconfDevice device = new NetconfDeviceBuilder()
283 .setReconnectOnSchemasChange(true)
284 .setSchemaResourcesDTO(schemaResourcesDTO)
285 .setGlobalProcessingExecutor(getExecutor())
287 .setSalFacade(facade)
290 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
291 Lists.newArrayList(TEST_CAPABILITY));
292 device.onRemoteSessionUp(sessionCaps, listener);
294 device.onNotification(NOTIFICATION);
295 device.onNotification(NOTIFICATION);
296 verify(facade, times(0)).onNotification(any(DOMNotification.class));
298 verify(facade, times(0)).onNotification(any(DOMNotification.class));
299 schemaFuture.set(NetconfToNotificationTest.getNotificationSchemaContext(getClass(), false));
300 verify(facade, timeout(10000).times(2)).onNotification(any(DOMNotification.class));
302 device.onNotification(NOTIFICATION);
303 verify(facade, timeout(10000).times(3)).onNotification(any(DOMNotification.class));
307 public void testNetconfDeviceReconnect() throws Exception {
308 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
309 final NetconfDeviceCommunicator listener = getListener();
311 final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory();
313 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
314 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
315 final NetconfDevice device = new NetconfDeviceBuilder()
316 .setReconnectOnSchemasChange(true)
317 .setSchemaResourcesDTO(schemaResourcesDTO)
318 .setGlobalProcessingExecutor(getExecutor())
320 .setSalFacade(facade)
322 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
323 Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
324 device.onRemoteSessionUp(sessionCaps, listener);
326 verify(schemaContextProviderFactory, timeout(5000)).createSchemaContext(any(Collection.class));
327 verify(facade, timeout(5000)).onDeviceConnected(
328 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
330 device.onRemoteSessionDown();
331 verify(facade, timeout(5000)).onDeviceDisconnected();
333 device.onRemoteSessionUp(sessionCaps, listener);
335 verify(schemaContextProviderFactory, timeout(5000).times(2)).createSchemaContext(any(Collection.class));
336 verify(facade, timeout(5000).times(2)).onDeviceConnected(
337 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
341 public void testNetconfDeviceDisconnectListenerCallCancellation() throws Exception {
342 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
343 final NetconfDeviceCommunicator listener = getListener();
344 final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
345 final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
346 doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
347 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO
348 = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
349 schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
350 final NetconfDevice device = new NetconfDeviceBuilder()
351 .setReconnectOnSchemasChange(true)
352 .setSchemaResourcesDTO(schemaResourcesDTO)
353 .setGlobalProcessingExecutor(getExecutor())
355 .setSalFacade(facade)
357 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
358 Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
359 //session up, start schema resolution
360 device.onRemoteSessionUp(sessionCaps, listener);
362 device.onRemoteSessionDown();
363 verify(facade, timeout(5000)).onDeviceDisconnected();
364 //complete schema setup
365 schemaFuture.set(getSchema());
366 //facade.onDeviceDisconnected() was called, so facade.onDeviceConnected() shouldn't be called anymore
367 verify(facade, after(1000).never()).onDeviceConnected(any(), any(), any());
371 public void testNetconfDeviceAvailableCapabilitiesBuilding() throws Exception {
372 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
373 final NetconfDeviceCommunicator listener = getListener();
375 final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory();
377 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
378 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
379 final NetconfDevice device = new NetconfDeviceBuilder()
380 .setReconnectOnSchemasChange(true)
381 .setSchemaResourcesDTO(schemaResourcesDTO)
382 .setGlobalProcessingExecutor(getExecutor())
384 .setSalFacade(facade)
386 final NetconfDevice netconfSpy = Mockito.spy(device);
388 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
389 Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
390 final Map<QName, AvailableCapability.CapabilityOrigin> moduleBasedCaps = new HashMap<>();
391 moduleBasedCaps.putAll(sessionCaps.getModuleBasedCapsOrigin());
393 .put(QName.create("(test:qname:side:loading)test"), AvailableCapability.CapabilityOrigin.UserDefined);
395 netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener);
397 final ArgumentCaptor<NetconfSessionPreferences> argument =
398 ArgumentCaptor.forClass(NetconfSessionPreferences.class);
399 verify(facade, timeout(5000))
400 .onDeviceConnected(any(SchemaContext.class), argument.capture(), any(DOMRpcService.class));
401 final NetconfDeviceCapabilities netconfDeviceCaps = argument.getValue().getNetconfDeviceCapabilities();
403 netconfDeviceCaps.getResolvedCapabilities()
404 .forEach(entry -> assertEquals("Builded 'AvailableCapability' schemas should match input capabilities.",
406 QName.create(entry.getCapability())).getName(), entry.getCapabilityOrigin().getName()));
409 private static SchemaContextFactory getSchemaFactory() throws Exception {
410 final SchemaContextFactory schemaFactory = mockClass(SchemaContextFactory.class);
411 doReturn(Futures.immediateFuture(getSchema()))
412 .when(schemaFactory).createSchemaContext(any(Collection.class));
413 return schemaFactory;
416 public static SchemaContext getSchema() {
417 return YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
420 private static RemoteDeviceHandler<NetconfSessionPreferences> getFacade() throws Exception {
421 final RemoteDeviceHandler<NetconfSessionPreferences> remoteDeviceHandler =
422 mockCloseableClass(RemoteDeviceHandler.class);
423 doNothing().when(remoteDeviceHandler).onDeviceConnected(
424 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class));
425 doNothing().when(remoteDeviceHandler).onDeviceDisconnected();
426 doNothing().when(remoteDeviceHandler).onNotification(any(DOMNotification.class));
427 return remoteDeviceHandler;
430 private static <T extends AutoCloseable> T mockCloseableClass(final Class<T> remoteDeviceHandlerClass)
432 final T mock = mockClass(remoteDeviceHandlerClass);
433 doNothing().when(mock).close();
437 private static <T> T mockClass(final Class<T> remoteDeviceHandlerClass) {
438 final T mock = mock(remoteDeviceHandlerClass);
439 Mockito.doReturn(remoteDeviceHandlerClass.getSimpleName()).when(mock).toString();
443 public RemoteDeviceId getId() {
444 return new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22));
447 public ExecutorService getExecutor() {
448 return Executors.newSingleThreadExecutor();
451 public MessageTransformer<NetconfMessage> getMessageTransformer() throws Exception {
452 final MessageTransformer<NetconfMessage> messageTransformer = mockClass(MessageTransformer.class);
453 doReturn(NOTIFICATION).when(messageTransformer).toRpcRequest(any(SchemaPath.class), any(NormalizedNode.class));
454 doReturn(RPC_RESULT).when(messageTransformer).toRpcResult(any(NetconfMessage.class), any(SchemaPath.class));
455 doReturn(COMPOSITE_NODE).when(messageTransformer).toNotification(any(NetconfMessage.class));
456 return messageTransformer;
459 public NetconfSessionPreferences getSessionCaps(final boolean addMonitor,
460 final Collection<String> additionalCapabilities) {
461 final ArrayList<String> capabilities = Lists.newArrayList(
462 XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
463 XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1);
466 capabilities.add(NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString());
469 capabilities.addAll(additionalCapabilities);
471 return NetconfSessionPreferences.fromStrings(
475 public NetconfDeviceCommunicator getListener() throws Exception {
476 final NetconfDeviceCommunicator remoteDeviceCommunicator = mockCloseableClass(NetconfDeviceCommunicator.class);
477 // doReturn(Futures.immediateFuture(rpcResult))
478 // .when(remoteDeviceCommunicator).sendRequest(any(NetconfMessage.class), any(QName.class));
479 return remoteDeviceCommunicator;