TLS support
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / core / SslKeyStoreTest.java
1 /*
2  * Copyright (c) 2014 Brocade Communications 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.openflowjava.protocol.impl.core;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.io.InputStream;
15
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.MockitoAnnotations;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType;
20
21 /**
22  *
23  * @author jameshall
24  */
25 public class SslKeyStoreTest {
26
27     /**
28      * Sets up test environment
29      */
30     @Before
31     public void setUp() {
32         MockitoAnnotations.initMocks(this);
33     }
34
35     /**
36      * Test keystore file access
37      * @throws Exception 
38      */
39     @Test
40     public void testAsInputStream() throws Exception {
41         InputStream inputStream = SslKeyStore.asInputStream("src/main/resources/key.bin", PathType.PATH);
42         assertNotNull( inputStream );
43         inputStream.close();
44     }
45
46     /**
47      * Test certificate password retrieval
48      */
49     @Test
50     public void testGetCertificatePassword() {
51         char[] password = SslKeyStore.getCertificatePassword();
52         assertNotNull(password);
53         assertTrue (password.length>0) ;
54     }
55
56     /**
57      * Test keystore password retrieval
58      */
59     @Test
60     public void testGetKeyStorePassword() {
61         char[] password = SslKeyStore.getKeyStorePassword() ;
62         assertNotNull(password);
63         assertTrue (password.length>0) ;
64     }
65 }