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.ModuleImport;
65 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
66 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
67 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
68 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
69 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
70 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
71 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
72 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
73 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
74 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
75 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
76 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
77 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
78 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
79 import org.xml.sax.SAXException;
81 @SuppressWarnings("checkstyle:IllegalCatch")
82 public class NetconfDeviceTest {
84 private static final NetconfMessage NOTIFICATION;
86 private static final ContainerNode COMPOSITE_NODE;
90 COMPOSITE_NODE = mockClass(ContainerNode.class);
91 } catch (final Exception e) {
92 throw new RuntimeException(e);
95 NOTIFICATION = new NetconfMessage(XmlUtil
96 .readXmlToDocument(NetconfDeviceTest.class.getResourceAsStream("/notification-payload.xml")));
97 } catch (SAXException | IOException e) {
98 throw new ExceptionInInitializerError(e);
102 private static final DOMRpcResult RPC_RESULT = new DefaultDOMRpcResult(COMPOSITE_NODE);
104 public static final String TEST_NAMESPACE = "test:namespace";
105 public static final String TEST_MODULE = "test-module";
106 public static final String TEST_REVISION = "2013-07-22";
107 public static final SourceIdentifier TEST_SID =
108 RevisionSourceIdentifier.create(TEST_MODULE, Revision.of(TEST_REVISION));
109 public static final String TEST_CAPABILITY =
110 TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION;
112 public static final SourceIdentifier TEST_SID2 =
113 RevisionSourceIdentifier.create(TEST_MODULE + "2", Revision.of(TEST_REVISION));
114 public static final String TEST_CAPABILITY2 =
115 TEST_NAMESPACE + "?module=" + TEST_MODULE + "2" + "&revision=" + TEST_REVISION;
117 private static final NetconfDeviceSchemasResolver STATE_SCHEMAS_RESOLVER =
118 (deviceRpc, remoteSessionCapabilities, id) -> NetconfStateSchemas.EMPTY;
121 public void testNetconfDeviceFlawedModelFailedResolution() throws Exception {
122 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
123 final NetconfDeviceCommunicator listener = getListener();
125 final SchemaContextFactory schemaFactory = getSchemaFactory();
126 final SchemaContext schema = getSchema();
127 final SchemaRepository schemaRepository = getSchemaRepository();
129 final SchemaResolutionException schemaResolutionException =
130 new SchemaResolutionException("fail first", TEST_SID, new Throwable("YangTools parser fail"));
131 doAnswer(invocation -> {
132 if (((Collection<?>) invocation.getArguments()[0]).size() == 2) {
133 return Futures.immediateFailedFuture(schemaResolutionException);
135 return Futures.immediateFuture(schema);
137 }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
139 final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id) -> {
140 final Module first = Iterables.getFirst(schema.getModules(), null);
141 final QName qName = QName.create(first.getQNameModule(), first.getName());
142 final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName);
143 final NetconfStateSchemas.RemoteYangSchema source2 =
144 new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2"));
145 return new NetconfStateSchemas(Sets.newHashSet(source1, source2));
148 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
149 .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver);
151 final NetconfDevice device = new NetconfDeviceBuilder()
152 .setReconnectOnSchemasChange(true)
153 .setSchemaResourcesDTO(schemaResourcesDTO)
154 .setGlobalProcessingExecutor(getExecutor())
156 .setSalFacade(facade)
158 // Monitoring supported
159 final NetconfSessionPreferences sessionCaps =
160 getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2));
161 device.onRemoteSessionUp(sessionCaps, listener);
163 Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(
164 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class));
165 Mockito.verify(schemaFactory, times(2)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
169 public void testNetconfDeviceFailFirstSchemaFailSecondEmpty() throws Exception {
170 final ArrayList<String> capList = Lists.newArrayList(TEST_CAPABILITY);
172 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
173 final NetconfDeviceCommunicator listener = getListener();
175 final SchemaContextFactory schemaFactory = getSchemaFactory();
176 final SchemaRepository schemaRepository = getSchemaRepository();
178 // Make fallback attempt to fail due to empty resolved sources
179 final SchemaResolutionException schemaResolutionException
180 = new SchemaResolutionException("fail first",
181 Collections.<SourceIdentifier>emptyList(), HashMultimap.<SourceIdentifier, ModuleImport>create());
182 doReturn(Futures.immediateFailedFuture(schemaResolutionException))
183 .when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
185 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
186 .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, STATE_SCHEMAS_RESOLVER);
187 final NetconfDevice device = new NetconfDeviceBuilder()
188 .setReconnectOnSchemasChange(true)
189 .setSchemaResourcesDTO(schemaResourcesDTO)
190 .setGlobalProcessingExecutor(getExecutor())
192 .setSalFacade(facade)
195 // Monitoring not supported
196 final NetconfSessionPreferences sessionCaps = getSessionCaps(false, capList);
197 device.onRemoteSessionUp(sessionCaps, listener);
199 Mockito.verify(facade, Mockito.timeout(5000)).onDeviceDisconnected();
200 Mockito.verify(listener, Mockito.timeout(5000)).close();
201 Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
205 public void testNetconfDeviceMissingSource() throws Exception {
206 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
207 final NetconfDeviceCommunicator listener = getListener();
208 final SchemaContext schema = getSchema();
210 final SchemaContextFactory schemaFactory = getSchemaFactory();
211 final SchemaRepository schemaRepository = getSchemaRepository();
213 // Make fallback attempt to fail due to empty resolved sources
214 final MissingSchemaSourceException schemaResolutionException =
215 new MissingSchemaSourceException("fail first", TEST_SID);
216 doReturn(Futures.immediateFailedFuture(schemaResolutionException))
217 .when(schemaRepository).getSchemaSource(eq(TEST_SID), eq(YangTextSchemaSource.class));
218 doAnswer(invocation -> {
219 if (((Collection<?>) invocation.getArguments()[0]).size() == 2) {
220 return Futures.immediateFailedFuture(schemaResolutionException);
222 return Futures.immediateFuture(schema);
224 }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
226 final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id) -> {
227 final Module first = Iterables.getFirst(schema.getModules(), null);
228 final QName qName = QName.create(first.getQNameModule(), first.getName());
229 final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName);
230 final NetconfStateSchemas.RemoteYangSchema source2 =
231 new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2"));
232 return new NetconfStateSchemas(Sets.newHashSet(source1, source2));
235 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice
236 .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver);
238 final NetconfDevice device = new NetconfDeviceBuilder()
239 .setReconnectOnSchemasChange(true)
240 .setSchemaResourcesDTO(schemaResourcesDTO)
241 .setGlobalProcessingExecutor(getExecutor())
243 .setSalFacade(facade)
245 // Monitoring supported
246 final NetconfSessionPreferences sessionCaps =
247 getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2));
248 device.onRemoteSessionUp(sessionCaps, listener);
250 Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(
251 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class));
252 Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
255 private static SchemaSourceRegistry getSchemaRegistry() {
256 final SchemaSourceRegistry mock = mock(SchemaSourceRegistry.class);
257 final SchemaSourceRegistration<?> mockReg = mock(SchemaSourceRegistration.class);
258 doNothing().when(mockReg).close();
259 doReturn(mockReg).when(mock).registerSchemaSource(
260 any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class),
261 any(PotentialSchemaSource.class));
265 private static SchemaRepository getSchemaRepository() {
266 final SchemaRepository mock = mock(SchemaRepository.class);
267 final SchemaSourceRepresentation mockRep = mock(SchemaSourceRepresentation.class);
268 doReturn(Futures.immediateFuture(mockRep))
269 .when(mock).getSchemaSource(any(SourceIdentifier.class), eq(YangTextSchemaSource.class));
274 public void testNotificationBeforeSchema() throws Exception {
275 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
276 final NetconfDeviceCommunicator listener = getListener();
277 final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
278 final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
279 doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
280 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO =
281 new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
282 schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
283 final NetconfDevice device = new NetconfDeviceBuilder()
284 .setReconnectOnSchemasChange(true)
285 .setSchemaResourcesDTO(schemaResourcesDTO)
286 .setGlobalProcessingExecutor(getExecutor())
288 .setSalFacade(facade)
291 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
292 Lists.newArrayList(TEST_CAPABILITY));
293 device.onRemoteSessionUp(sessionCaps, listener);
295 device.onNotification(NOTIFICATION);
296 device.onNotification(NOTIFICATION);
297 verify(facade, times(0)).onNotification(any(DOMNotification.class));
299 verify(facade, times(0)).onNotification(any(DOMNotification.class));
300 schemaFuture.set(NetconfToNotificationTest.getNotificationSchemaContext(getClass(), false));
301 verify(facade, timeout(10000).times(2)).onNotification(any(DOMNotification.class));
303 device.onNotification(NOTIFICATION);
304 verify(facade, timeout(10000).times(3)).onNotification(any(DOMNotification.class));
308 public void testNetconfDeviceReconnect() throws Exception {
309 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
310 final NetconfDeviceCommunicator listener = getListener();
312 final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory();
314 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
315 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
316 final NetconfDevice device = new NetconfDeviceBuilder()
317 .setReconnectOnSchemasChange(true)
318 .setSchemaResourcesDTO(schemaResourcesDTO)
319 .setGlobalProcessingExecutor(getExecutor())
321 .setSalFacade(facade)
323 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
324 Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
325 device.onRemoteSessionUp(sessionCaps, listener);
327 verify(schemaContextProviderFactory, timeout(5000)).createSchemaContext(any(Collection.class));
328 verify(facade, timeout(5000)).onDeviceConnected(
329 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
331 device.onRemoteSessionDown();
332 verify(facade, timeout(5000)).onDeviceDisconnected();
334 device.onRemoteSessionUp(sessionCaps, listener);
336 verify(schemaContextProviderFactory, timeout(5000).times(2)).createSchemaContext(any(Collection.class));
337 verify(facade, timeout(5000).times(2)).onDeviceConnected(
338 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
342 public void testNetconfDeviceDisconnectListenerCallCancellation() throws Exception {
343 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
344 final NetconfDeviceCommunicator listener = getListener();
345 final SchemaContextFactory schemaContextProviderFactory = mock(SchemaContextFactory.class);
346 final SettableFuture<SchemaContext> schemaFuture = SettableFuture.create();
347 doReturn(schemaFuture).when(schemaContextProviderFactory).createSchemaContext(any(Collection.class));
348 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO
349 = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(),
350 schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
351 final NetconfDevice device = new NetconfDeviceBuilder()
352 .setReconnectOnSchemasChange(true)
353 .setSchemaResourcesDTO(schemaResourcesDTO)
354 .setGlobalProcessingExecutor(getExecutor())
356 .setSalFacade(facade)
358 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
359 Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
360 //session up, start schema resolution
361 device.onRemoteSessionUp(sessionCaps, listener);
363 device.onRemoteSessionDown();
364 verify(facade, timeout(5000)).onDeviceDisconnected();
365 //complete schema setup
366 schemaFuture.set(getSchema());
367 //facade.onDeviceDisconnected() was called, so facade.onDeviceConnected() shouldn't be called anymore
368 verify(facade, after(1000).never()).onDeviceConnected(any(), any(), any());
372 public void testNetconfDeviceAvailableCapabilitiesBuilding() throws Exception {
373 final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
374 final NetconfDeviceCommunicator listener = getListener();
376 final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory();
378 final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO(
379 getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER);
380 final NetconfDevice device = new NetconfDeviceBuilder()
381 .setReconnectOnSchemasChange(true)
382 .setSchemaResourcesDTO(schemaResourcesDTO)
383 .setGlobalProcessingExecutor(getExecutor())
385 .setSalFacade(facade)
387 final NetconfDevice netconfSpy = Mockito.spy(device);
389 final NetconfSessionPreferences sessionCaps = getSessionCaps(true,
390 Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION));
391 final Map<QName, AvailableCapability.CapabilityOrigin> moduleBasedCaps = new HashMap<>();
392 moduleBasedCaps.putAll(sessionCaps.getModuleBasedCapsOrigin());
394 .put(QName.create("(test:qname:side:loading)test"), AvailableCapability.CapabilityOrigin.UserDefined);
396 netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener);
398 final ArgumentCaptor<NetconfSessionPreferences> argument =
399 ArgumentCaptor.forClass(NetconfSessionPreferences.class);
400 verify(facade, timeout(5000))
401 .onDeviceConnected(any(SchemaContext.class), argument.capture(), any(DOMRpcService.class));
402 final NetconfDeviceCapabilities netconfDeviceCaps = argument.getValue().getNetconfDeviceCapabilities();
404 netconfDeviceCaps.getResolvedCapabilities()
405 .forEach(entry -> assertEquals("Builded 'AvailableCapability' schemas should match input capabilities.",
407 QName.create(entry.getCapability())).getName(), entry.getCapabilityOrigin().getName()));
410 private static SchemaContextFactory getSchemaFactory() throws Exception {
411 final SchemaContextFactory schemaFactory = mockClass(SchemaContextFactory.class);
412 doReturn(Futures.immediateFuture(getSchema()))
413 .when(schemaFactory).createSchemaContext(any(Collection.class));
414 return schemaFactory;
417 public static SchemaContext getSchema() {
418 return YangParserTestUtils.parseYangResource("/schemas/test-module.yang");
421 private static RemoteDeviceHandler<NetconfSessionPreferences> getFacade() throws Exception {
422 final RemoteDeviceHandler<NetconfSessionPreferences> remoteDeviceHandler =
423 mockCloseableClass(RemoteDeviceHandler.class);
424 doNothing().when(remoteDeviceHandler).onDeviceConnected(
425 any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class));
426 doNothing().when(remoteDeviceHandler).onDeviceDisconnected();
427 doNothing().when(remoteDeviceHandler).onNotification(any(DOMNotification.class));
428 return remoteDeviceHandler;
431 private static <T extends AutoCloseable> T mockCloseableClass(final Class<T> remoteDeviceHandlerClass)
433 final T mock = mockClass(remoteDeviceHandlerClass);
434 doNothing().when(mock).close();
438 private static <T> T mockClass(final Class<T> remoteDeviceHandlerClass) {
439 final T mock = mock(remoteDeviceHandlerClass);
440 Mockito.doReturn(remoteDeviceHandlerClass.getSimpleName()).when(mock).toString();
444 public RemoteDeviceId getId() {
445 return new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22));
448 public ExecutorService getExecutor() {
449 return Executors.newSingleThreadExecutor();
452 public MessageTransformer<NetconfMessage> getMessageTransformer() throws Exception {
453 final MessageTransformer<NetconfMessage> messageTransformer = mockClass(MessageTransformer.class);
454 doReturn(NOTIFICATION).when(messageTransformer).toRpcRequest(any(SchemaPath.class), any(NormalizedNode.class));
455 doReturn(RPC_RESULT).when(messageTransformer).toRpcResult(any(NetconfMessage.class), any(SchemaPath.class));
456 doReturn(COMPOSITE_NODE).when(messageTransformer).toNotification(any(NetconfMessage.class));
457 return messageTransformer;
460 public NetconfSessionPreferences getSessionCaps(final boolean addMonitor,
461 final Collection<String> additionalCapabilities) {
462 final ArrayList<String> capabilities = Lists.newArrayList(
463 XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
464 XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1);
467 capabilities.add(NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString());
470 capabilities.addAll(additionalCapabilities);
472 return NetconfSessionPreferences.fromStrings(
476 public NetconfDeviceCommunicator getListener() throws Exception {
477 final NetconfDeviceCommunicator remoteDeviceCommunicator = mockCloseableClass(NetconfDeviceCommunicator.class);
478 // doReturn(Futures.immediateFuture(rpcResult))
479 // .when(remoteDeviceCommunicator).sendRequest(any(NetconfMessage.class), any(QName.class));
480 return remoteDeviceCommunicator;