2 * Copyright (c) 2014 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.controller.netconf.client;
11 import com.google.common.base.Optional;
12 import io.netty.channel.Channel;
13 import io.netty.util.HashedWheelTimer;
14 import io.netty.util.Timer;
15 import io.netty.util.concurrent.Promise;
16 import org.apache.sshd.common.SessionListener;
17 import org.junit.Test;
18 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
19 import org.opendaylight.protocol.framework.SessionListenerFactory;
20 import org.opendaylight.protocol.framework.SessionNegotiator;
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.mockito.Mockito.doReturn;
25 import static org.mockito.Mockito.mock;
27 public class NetconfClientSessionNegotiatorFactoryTest {
29 public void testGetSessionNegotiator() throws Exception {
30 NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
31 Timer timer = new HashedWheelTimer();
32 SessionListenerFactory listenerFactory = mock(SessionListenerFactory.class);
33 doReturn(sessionListener).when(listenerFactory).getSessionListener();
35 Channel channel = mock(Channel.class);
36 Promise promise = mock(Promise.class);
37 NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(timer,
38 Optional.<NetconfHelloMessageAdditionalHeader>absent(), 200L);
40 SessionNegotiator sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise);
41 assertNotNull(sessionNegotiator);