Merge "Fixed potential class pool override in integration tests."
[controller.git] / opendaylight / netconf / netconf-ssh / src / test / java / org / opendaylight / controller / netconf / KeyGeneratorTest.java
1 /*
2  * Copyright (c) 2013 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;
10
11 import org.junit.After;
12 import org.junit.Before;
13 import org.junit.Ignore;
14 import org.junit.Test;
15 import org.mockito.Mock;
16 import org.mockito.MockitoAnnotations;
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.usermanager.IUserManager;
21 import org.opendaylight.controller.usermanager.UserConfig;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.net.Inet4Address;
26 import java.net.InetSocketAddress;
27
28 import static org.junit.Assert.assertTrue;
29 import static org.mockito.Matchers.any;
30 import static org.mockito.Mockito.doReturn;
31
32 // This test is intended to be verified using ssh
33 @Ignore
34 public class KeyGeneratorTest {
35
36     @Mock
37     private IUserManager iUserManager;
38     File tempFile;
39
40     @Before
41     public void setUp() throws IOException {
42         MockitoAnnotations.initMocks(this);
43         doReturn(null).when(iUserManager).addLocalUser(any(UserConfig.class));
44         tempFile = File.createTempFile("odltest", ".tmp");
45         tempFile.deleteOnExit();
46     }
47
48     @After
49     public void tearDown() {
50         assertTrue(tempFile.delete());
51     }
52
53     @Test
54     public void test() throws Exception {
55         String pem = PEMGenerator.generateTo(tempFile);
56
57         AuthProvider authProvider = new AuthProvider(iUserManager, pem);
58         InetSocketAddress inetSocketAddress = new InetSocketAddress(Inet4Address.getLoopbackAddress().getHostAddress(), 8383);
59         NetconfSSHServer server = NetconfSSHServer.start(1830, inetSocketAddress, authProvider);
60
61         Thread serverThread = new  Thread(server,"netconf SSH server thread");
62         serverThread.start();
63         serverThread.join();
64     }
65 }