1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.harmony.xnet.tests.javax.net.ssl; 19 20 import java.security.Principal; 21 import java.security.cert.Certificate; 22 23 import javax.net.ssl.SSLPeerUnverifiedException; 24 import javax.net.ssl.SSLSession; 25 import javax.net.ssl.SSLSessionContext; 26 import javax.net.ssl.SSLSessionBindingEvent; 27 import javax.security.cert.X509Certificate; 28 29 import junit.framework.TestCase; 30 31 32 /** 33 * Tests for <code>SSLSessionBindingEvent</code> class constructors and methods. 34 * 35 */ 36 public class SSLSessionBindingEventTest extends TestCase { 37 38 public final void testSSLSessionBindingEvent() { 39 SSLSession ses = new MySSLSession(); 40 SSLSessionBindingEvent event = new SSLSessionBindingEvent(ses, "test"); 41 42 assertEquals("test", event.getName()); 43 assertEquals(ses, event.getSession()); 44 } 45 46 } 47 class MySSLSession implements SSLSession { 48 /* 49 * @see javax.net.ssl.SSLSession#getApplicationBufferSize() 50 */ 51 public int getApplicationBufferSize() { 52 return 0; 53 } 54 55 /* 56 * @see javax.net.ssl.SSLSession#getCipherSuite() 57 */ 58 public String getCipherSuite() { 59 return "MyTestCipherSuite"; 60 } 61 62 /* 63 * @see javax.net.ssl.SSLSession#getCreationTime() 64 */ 65 public long getCreationTime() { 66 return 0; 67 } 68 69 /* 70 * @see javax.net.ssl.SSLSession#getId() 71 */ 72 public byte[] getId() { 73 return null; 74 } 75 76 /* 77 * @see javax.net.ssl.SSLSession#getLastAccessedTime() 78 */ 79 public long getLastAccessedTime() { 80 return 0; 81 } 82 83 /* 84 * @see javax.net.ssl.SSLSession#getLocalCertificates() 85 */ 86 public Certificate[] getLocalCertificates() { 87 return null; 88 } 89 90 /* 91 * @see javax.net.ssl.SSLSession#getLocalPrincipal() 92 */ 93 public Principal getLocalPrincipal() { 94 return null; 95 } 96 97 /* 98 * @see javax.net.ssl.SSLSession#getPacketBufferSize() 99 */ 100 public int getPacketBufferSize() { 101 return 0; 102 } 103 104 /* 105 * @see javax.net.ssl.SSLSession#getPeerCertificateChain() 106 */ 107 public X509Certificate[] getPeerCertificateChain() 108 throws SSLPeerUnverifiedException { 109 throw new SSLPeerUnverifiedException("test exception"); 110 } 111 112 /* 113 * @see javax.net.ssl.SSLSession#getPeerCertificates() 114 */ 115 public Certificate[] getPeerCertificates() 116 throws SSLPeerUnverifiedException { 117 throw new SSLPeerUnverifiedException("test exception"); 118 } 119 120 /* 121 * @see javax.net.ssl.SSLSession#getPeerHost() 122 */ 123 public String getPeerHost() { 124 return null; 125 } 126 127 /* 128 * @see javax.net.ssl.SSLSession#getPeerPort() 129 */ 130 public int getPeerPort() { 131 return 0; 132 } 133 134 /* 135 * @see javax.net.ssl.SSLSession#getPeerPrincipal() 136 */ 137 public Principal getPeerPrincipal() throws SSLPeerUnverifiedException { 138 return null; 139 } 140 141 /* 142 * @see javax.net.ssl.SSLSession#getProtocol() 143 */ 144 public String getProtocol() { 145 return null; 146 } 147 148 /* 149 * @see javax.net.ssl.SSLSession#getSessionContext() 150 */ 151 public SSLSessionContext getSessionContext() { 152 return null; 153 } 154 155 /* 156 * @see javax.net.ssl.SSLSession#getValue(java.lang.String) 157 */ 158 public Object getValue(String name) { 159 return null; 160 } 161 162 /* 163 * @see javax.net.ssl.SSLSession#getValueNames() 164 */ 165 public String[] getValueNames() { 166 return null; 167 } 168 169 /* 170 * @see javax.net.ssl.SSLSession#invalidate() 171 */ 172 public void invalidate() { 173 } 174 175 /* 176 * @see javax.net.ssl.SSLSession#isValid() 177 */ 178 public boolean isValid() { 179 return false; 180 } 181 182 /* 183 * @see javax.net.ssl.SSLSession#putValue(java.lang.String, 184 * java.lang.Object) 185 */ 186 public void putValue(String name, Object value) { 187 } 188 189 /* 190 * @see javax.net.ssl.SSLSession#removeValue(java.lang.String) 191 */ 192 public void removeValue(String name) { 193 } 194 195 } 196 197