Bug 2231 - Secure transport for PCEP
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / SslContextFactoryTest.java
1 /*
2  * Copyright (c) 2015 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.protocol.pcep.impl;
10
11 import static org.junit.Assert.assertNotNull;
12
13 import javax.net.ssl.SSLContext;
14 import org.junit.Test;
15 import org.opendaylight.controller.config.yang.pcep.impl.Tls;
16 import org.opendaylight.protocol.pcep.impl.tls.SslContextFactory;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.PathType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.StoreType;
19
20 public class SslContextFactoryTest {
21
22     @Test
23     public void testSslContextFactory() {
24         final SslContextFactory sslContextFactory = new SslContextFactory(createTlsConfig());
25         final SSLContext sslContext = sslContextFactory.getServerContext();
26         assertNotNull(sslContext);
27     }
28
29     public static Tls createTlsConfig() {
30         final Tls tlsConfig = new Tls();
31         tlsConfig.setCertificatePassword("opendaylight");
32         tlsConfig.setKeystore("/exemplary-ctlKeystore");
33         tlsConfig.setKeystorePassword("opendaylight");
34         tlsConfig.setKeystorePathType(PathType.CLASSPATH);
35         tlsConfig.setKeystoreType(StoreType.JKS);
36         tlsConfig.setTruststore("/exemplary-ctlTrustStore");
37         tlsConfig.setTruststorePassword("opendaylight");
38         tlsConfig.setTruststorePathType(PathType.CLASSPATH);
39         tlsConfig.setTruststoreType(StoreType.JKS);
40         return tlsConfig;
41     }
42
43 }