f2d2a858119782394a729bc82251e7a5d552b760
[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.protocol.pcep.impl.tls.SslContextFactory;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PathType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.StoreType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.TlsBuilder;
20
21 public class SslContextFactoryTest {
22
23     @Test
24     public void testSslContextFactory() {
25         final SslContextFactory sslContextFactory = new SslContextFactory(createTlsConfig());
26         final SSLContext sslContext = sslContextFactory.getServerContext();
27         assertNotNull(sslContext);
28     }
29
30     public static Tls createTlsConfig() {
31         return new TlsBuilder().setCertificatePassword("opendaylight").setKeystore("/exemplary-ctlKeystore")
32                 .setKeystorePassword("opendaylight").setKeystorePathType(PathType.CLASSPATH)
33                 .setKeystoreType(StoreType.JKS).setTruststore("/exemplary-ctlTrustStore")
34                 .setTruststorePassword("opendaylight").setTruststorePathType(PathType.CLASSPATH)
35                 .setTruststoreType(StoreType.JKS).build();
36     }
37 }