Merge "BUG-1140: inPort disappeared from match"
[controller.git] / opendaylight / netconf / netconf-ssh / src / test / java / org / opendaylight / controller / netconf / netty / SSHTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.netconf.netty;
10
11 import static org.mockito.Matchers.anyString;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
14
15 import io.netty.channel.nio.NioEventLoopGroup;
16 import org.junit.Test;
17 import org.opendaylight.controller.netconf.ssh.NetconfSSHServer;
18 import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider;
19 import org.opendaylight.controller.netconf.ssh.authentication.PEMGenerator;
20 import org.opendaylight.controller.netconf.util.osgi.NetconfConfigUtil;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 public class SSHTest {
25     public static final Logger logger = LoggerFactory.getLogger(SSHTest.class);
26
27     @Test
28     public void test() throws Exception {
29         new Thread(new EchoServer(), "EchoServer").start();
30         AuthProvider authProvider = mock(AuthProvider.class);
31         doReturn(PEMGenerator.generate().toCharArray()).when(authProvider).getPEMAsCharArray();
32         doReturn(true).when(authProvider).authenticated(anyString(), anyString());
33         NetconfSSHServer thread = NetconfSSHServer.start(10831, NetconfConfigUtil.getNetconfLocalAddress(), authProvider, new NioEventLoopGroup());
34         Thread.sleep(2000);
35         logger.info("Closing socket");
36         thread.close();
37         thread.join();
38     }
39 }