2 * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowjava.protocol.impl.core;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import java.security.cert.X509Certificate;
16 import javax.net.ssl.TrustManager;
17 import javax.net.ssl.X509TrustManager;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.mockito.MockitoAnnotations;
27 public class SslTrustManagerFactoryTest {
30 * Sets up test environment
34 MockitoAnnotations.initMocks(this);
41 public void testGetTrustManagers() throws Exception {
42 TrustManager[] tmArray = SslTrustManagerFactory.getTrustManagers() ;
44 assertNotNull( tmArray );
45 for ( TrustManager tm : tmArray ) {
46 if ( tm.getClass() == X509TrustManager.class ) {
47 X509Certificate[] certsArray = ((X509TrustManager)tm).getAcceptedIssuers() ;
48 assertTrue( certsArray.length > 0 ) ;
50 // Boolean caught = false;
52 // ((X509TrustManager)tm).checkClientTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ;
53 // } catch (CertificateException ce) {
56 // assertTrue( caught ) ;
60 // ((X509TrustManager)tm).checkServerTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ;
61 // } catch (CertificateException ce) {
64 // assertTrue( caught ) ;